precomp_mat.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * \file precomp_mat.hpp
  3. * \author Dhairya Malhotra, dhairya.malhotra@gmail.com
  4. * \date 3-07-2011
  5. * \brief This file contains the definition of the PrecompMat class.
  6. * Handles storage of precomputed translation matrices.
  7. */
  8. #include <mpi.h>
  9. #include <vector>
  10. #include <cstdlib>
  11. #include <pvfmm_common.hpp>
  12. #include <matrix.hpp>
  13. #ifndef _PVFMM_PrecompMAT_HPP_
  14. #define _PVFMM_PrecompMAT_HPP_
  15. namespace pvfmm{
  16. typedef enum{
  17. UC2UE0_Type= 0,
  18. UC2UE1_Type= 1,
  19. DC2DE0_Type= 2,
  20. DC2DE1_Type= 3,
  21. S2U_Type = 4,
  22. U2U_Type = 5,
  23. D2D_Type = 6,
  24. D2T_Type = 7,
  25. U0_Type = 8,
  26. U1_Type = 9,
  27. U2_Type =10,
  28. V_Type =11,
  29. W_Type =12,
  30. X_Type =13,
  31. V1_Type =14,
  32. BC_Type =15,
  33. Type_Count=16
  34. } Mat_Type;
  35. typedef enum{
  36. Scaling = 0,
  37. ReflecX = 1,
  38. ReflecY = 2,
  39. ReflecZ = 3,
  40. SwapXY = 4,
  41. SwapXZ = 5,
  42. R_Perm = 0,
  43. C_Perm = 6,
  44. Perm_Count=12
  45. } Perm_Type;
  46. template <class T>
  47. class PrecompMat{
  48. public:
  49. PrecompMat(bool scale_invar, int max_d);
  50. Matrix<T>& Mat(int l, Mat_Type type, size_t indx);
  51. Permutation<T>& Perm_R(int l, Mat_Type type, size_t indx);
  52. Permutation<T>& Perm_C(int l, Mat_Type type, size_t indx);
  53. Permutation<T>& Perm(Mat_Type type, size_t indx);
  54. size_t CompactData(int l, Mat_Type type, Matrix<char>& comp_data, size_t offset=0);
  55. void Save2File(const char* fname, bool replace=false);
  56. void LoadFile(const char* fname, MPI_Comm comm);
  57. std::vector<T>& RelativeTrgCoord();
  58. bool ScaleInvar();
  59. private:
  60. std::vector<std::vector<Matrix <T> > > mat;
  61. std::vector<std::vector<Permutation<T> > > perm;
  62. std::vector<std::vector<Permutation<T> > > perm_r;
  63. std::vector<std::vector<Permutation<T> > > perm_c;
  64. std::vector<T> rel_trg_coord;
  65. bool scale_invar;
  66. int max_depth;
  67. };
  68. }//end namespace
  69. #include <precomp_mat.txx>
  70. #endif //_PrecompMAT_HPP_