NodeCentricRepMatrix.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. *
  3. *
  4. */
  5. #ifndef NODECENTRICREPMATRIXINCLUDE
  6. #define NODECENTRICREPMATRIXINCLUDE
  7. /* System - includes */
  8. #include <sys/types.h>
  9. /* std - includes */
  10. #include <stdexcept>
  11. #include <iostream>
  12. #include <valarray>
  13. #include <cmath>
  14. /* omp - includes */
  15. #ifdef NICE_USELIB_OPENMP
  16. #include <omp.h>
  17. #endif
  18. namespace OBJREC
  19. {
  20. class NodeCentricRepMatrix : public std::valarray<double>
  21. {
  22. private:
  23. //! first dimension (y-axes)
  24. uint m;
  25. //! second dimension (x-axes)
  26. uint n;
  27. //! third dimension (number of edges departing from each node)
  28. uint e;
  29. //! check whether the given value is in the range of the given dim
  30. void checkRange ( uint m, uint n, uint e ) const;
  31. /** Matrix Access **/
  32. //! returns the value at (y=m, x=n, e=e), without rangecheck
  33. double atQuick ( uint m, uint n, uint e ) const;
  34. //! returns a non-const referenz to the element at (y=m, x=n, e=e), without rangecheck
  35. double& atQuick ( uint m, uint n, uint e );
  36. public:
  37. /* Constructor and Destructor */
  38. /**
  39. * @brief Simple constructor.
  40. * @param uint - first dimension (y)
  41. * @param uint - second dimension (x)
  42. * @param uint - third dimension (e)
  43. */
  44. NodeCentricRepMatrix ( const uint m, const uint n, const uint e );
  45. /**
  46. * @brief Copy Constructor.
  47. * @param NodeCentricRepMatrix& - matrix, which has to copy into a new Object. Note: Deepcopy!
  48. */
  49. NodeCentricRepMatrix ( const NodeCentricRepMatrix& matrix );
  50. /**
  51. * @brief Destructor. Free Matrix.
  52. */
  53. ~NodeCentricRepMatrix();
  54. /** Getter **/
  55. //! Get the first dimension
  56. uint getM() const {
  57. return m;
  58. };
  59. //! Get the second dimension
  60. uint getN() const {
  61. return n;
  62. };
  63. //! Get the third dimension
  64. uint getE() const {
  65. return e;
  66. };
  67. /** Matrix access **/
  68. //! returns the value at (y=m, x=n, e=e)
  69. double at ( uint m, uint n, uint e ) const;
  70. //! returns a non-const referenz to the element at (y=m, x=n, e=e)
  71. double& at ( uint m, uint n, uint e );
  72. /** Operator **/
  73. //! =+ operator
  74. NodeCentricRepMatrix& operator-= ( NodeCentricRepMatrix const& rhs );
  75. //! + operator
  76. NodeCentricRepMatrix operator- ( NodeCentricRepMatrix const& rhs );
  77. //! Assignt operator (deep copy)
  78. NodeCentricRepMatrix& operator= ( NodeCentricRepMatrix const& matrix );
  79. //! Access operator
  80. double operator() ( const uint m, const uint n, const uint e ) const;
  81. //! Access operator
  82. double& operator() ( const uint m, const uint n, const uint e );
  83. /** static Methodes **/
  84. //! return the max. of matrix
  85. static inline double maxValue ( const NodeCentricRepMatrix& matrix ) {
  86. return matrix.max();
  87. };
  88. /**
  89. * @brief This Function calculates the differenz between Member-Matrix and the given Matrix and check if there is NULL or less then epsilon.
  90. * @param NodeCentricRepMatrix& - given matrix
  91. * @param double - epsilon
  92. * @return true if |M1(j,i,e) - M2(j,i,e)| <= epsilon, false else
  93. */
  94. bool changes ( const OBJREC::NodeCentricRepMatrix& matrix, double epsilon ) const;
  95. };
  96. }
  97. #endif