precomp_mat.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. Scaling = 0,
  35. ReflecX = 1,
  36. ReflecY = 2,
  37. ReflecZ = 3,
  38. SwapXY = 4,
  39. SwapXZ = 5,
  40. R_Perm = 0,
  41. C_Perm = 6,
  42. Perm_Count=12
  43. } Perm_Type;
  44. template <class T>
  45. class PrecompMat{
  46. public:
  47. PrecompMat(bool homogen, int max_d);
  48. Matrix<T>& Mat(int l, Mat_Type type, size_t indx);
  49. Permutation<T>& Perm_R(int l, Mat_Type type, size_t indx);
  50. Permutation<T>& Perm_C(int l, Mat_Type type, size_t indx);
  51. Permutation<T>& Perm(Mat_Type type, size_t indx);
  52. size_t CompactData(int l, Mat_Type type, Matrix<char>& comp_data, size_t offset=0);
  53. void Save2File(const char* fname, bool replace=false);
  54. void LoadFile(const char* fname, MPI_Comm comm);
  55. std::vector<T>& RelativeTrgCoord();
  56. bool Homogen();
  57. private:
  58. std::vector<std::vector<Matrix <T> > > mat;
  59. std::vector<std::vector<Permutation<T> > > perm;
  60. std::vector<std::vector<Permutation<T> > > perm_r;
  61. std::vector<std::vector<Permutation<T> > > perm_c;
  62. std::vector<T> rel_trg_coord;
  63. bool homogeneous;
  64. int max_depth;
  65. };
  66. }//end namespace
  67. #include <precomp_mat.txx>
  68. #endif //_PrecompMAT_HPP_