precomp_mat.hpp 1.7 KB

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