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.3KB

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