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 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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& add(double k);
  17. T& add(double scalars[M][N]);
  18. T& add(const T& other);
  19. T& sub(double k);
  20. T& sub(double scalars[M][N]);
  21. T& sub(const T& other);
  22. T& mult(double k);
  23. uge_gm_tmpl_p MatrixMxN<M, P> mult(double scalars[N][P]);
  24. uge_gm_tmpl_p MatrixMxN<M, P> mult(const MatrixMxN<N, P>& other);
  25. T& div(double k);
  26. T& div(double scalars[M][N]);
  27. T& div(const T& other);
  28. protected:
  29. double _scalars[M][N];
  30. private:
  31. T* getThis() const;
  32. };
  33. uge_gm_tmpl_mn class MatrixMxN: public GenericMatrix<M, N, MatrixMxN<M, N> >
  34. {
  35. public:
  36. MatrixMxN();
  37. MatrixMxN(double k);
  38. MatrixMxN(double scalars[M][N]);
  39. virtual ~MatrixMxN();
  40. protected:
  41. using GenericMatrix<M, N, MatrixMxN<M, N> >::_scalars;
  42. };
  43. #include "matrixmxn.hxx"
  44. #endif // MATRIXMXN_H