precomp_mat.hpp 1.7 KB

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