You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

matrixmxn.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef MATRIXMXN_H
  2. #define MATRIXMXN_H
  3. #define uge_gm_tmpl_mnt template<unsigned M, unsigned N, class T>
  4. #define uge_gm_tmpl_mn template<unsigned M, unsigned N>
  5. #define uge_gm_tmpl_p template<unsigned P>
  6. #define uge_gm_tmpl_mntp template<unsigned M, unsigned N, class T, unsigned P>
  7. uge_gm_tmpl_mn class MatrixMxN;
  8. uge_gm_tmpl_mnt class GenericMatrix
  9. {
  10. public:
  11. virtual ~GenericMatrix();
  12. T& setScalar(unsigned i, unsigned j, double value);
  13. double getScalar(unsigned i, unsigned j) const;
  14. bool isNull() const;
  15. bool equal(const T& other) const;
  16. T& fill(double k);
  17. T& fill(double scalars[M][N]);
  18. T& add(double k);
  19. T& add(double scalars[M][N]);
  20. T& add(const T& other);
  21. T& sub(double k);
  22. T& sub(double scalars[M][N]);
  23. T& sub(const T& other);
  24. T& mult(double k);
  25. T& mult(double scalars[M][N]);
  26. T& mult(const T& other);
  27. uge_gm_tmpl_p MatrixMxN<M, P> multMatrix(double scalars[N][P]);
  28. uge_gm_tmpl_p MatrixMxN<M, P> multMatrix(const MatrixMxN<N, P>& other);
  29. T& div(double k);
  30. T& div(double scalars[M][N]);
  31. T& div(const T& other);
  32. T operator+() const;
  33. T operator+(const double& k) const;
  34. T& operator+=(const double& k);
  35. T operator+(const T& other) const;
  36. T& operator+=(const T& other);
  37. T operator-() const;
  38. T operator-(const double& k) const;
  39. T& operator-=(const double& k);
  40. T operator-(const T& other) const;
  41. T& operator-=(const T& other);
  42. T operator*(const double& k) const;
  43. T& operator*=(const double& k);
  44. T operator*(const T& other) const;
  45. T& operator*=(const T& other);
  46. T operator/(const double& k) const;
  47. T& operator/=(const double& k);
  48. T operator/(const T& other) const;
  49. T& operator/=(const T& other);
  50. bool operator==(const T& other) const;
  51. bool operator!=(const T& other) const;
  52. bool operator!() const;
  53. operator bool() const;
  54. protected:
  55. double _scalars[M][N];
  56. private:
  57. T* getThis() const;
  58. };
  59. uge_gm_tmpl_mn class MatrixMxN: public GenericMatrix<M, N, MatrixMxN<M, N> >
  60. {
  61. public:
  62. MatrixMxN();
  63. MatrixMxN(double k);
  64. MatrixMxN(double scalars[M][N]);
  65. virtual ~MatrixMxN();
  66. protected:
  67. using GenericMatrix<M, N, MatrixMxN<M, N> >::_scalars;
  68. };
  69. #include "matrixmxn.hxx"
  70. #endif // MATRIXMXN_H