precomp_mat.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #ifndef _PVFMM_PrecompMAT_HPP_
  9. #define _PVFMM_PrecompMAT_HPP_
  10. #include <mpi.h>
  11. #include <pvfmm_common.hpp>
  12. #include <matrix.hpp>
  13. namespace pvfmm{
  14. typedef enum{
  15. UC2UE_Type= 0,
  16. DC2DE_Type= 1,
  17. S2U_Type = 2,
  18. U2U_Type = 3,
  19. D2D_Type = 4,
  20. D2T_Type = 5,
  21. U0_Type = 6,
  22. U1_Type = 7,
  23. U2_Type = 8,
  24. V_Type = 9,
  25. W_Type =10,
  26. X_Type =11,
  27. V1_Type =12,
  28. BC_Type =13,
  29. Type_Count=14
  30. } Mat_Type;
  31. typedef enum{
  32. ReflecX = 0,
  33. ReflecY = 1,
  34. ReflecZ = 2,
  35. SwapXY = 3,
  36. SwapXZ = 4,
  37. R_Perm = 0,
  38. C_Perm = 5,
  39. Perm_Count=10
  40. } Perm_Type;
  41. template <class T>
  42. class PrecompMat{
  43. public:
  44. PrecompMat(bool homogen, int max_d);
  45. Matrix<T>& Mat(int l, Mat_Type type, size_t indx);
  46. Permutation<T>& Perm_R(Mat_Type type, size_t indx);
  47. Permutation<T>& Perm_C(Mat_Type type, size_t indx);
  48. Permutation<T>& Perm(Mat_Type type, size_t indx);
  49. size_t CompactData(int l, Mat_Type type, Matrix<char>& comp_data, size_t offset=0);
  50. void Save2File(const char* fname, bool replace=false);
  51. void LoadFile(const char* fname, MPI_Comm comm);
  52. std::vector<T>& RelativeTrgCoord();
  53. bool Homogen();
  54. private:
  55. std::vector<std::vector<Matrix <T> > > mat;
  56. std::vector<std::vector<Permutation<T> > > perm;
  57. std::vector<std::vector<Permutation<T> > > perm_r;
  58. std::vector<std::vector<Permutation<T> > > perm_c;
  59. std::vector<T> rel_trg_coord;
  60. bool homogeneous;
  61. int max_depth;
  62. };
  63. }//end namespace
  64. #include <precomp_mat.txx>
  65. #endif //_PrecompMAT_HPP_