aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/math/Matrix.h
diff options
context:
space:
mode:
Diffstat (limited to 'meowpp/math/Matrix.h')
-rw-r--r--meowpp/math/Matrix.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/meowpp/math/Matrix.h b/meowpp/math/Matrix.h
new file mode 100644
index 0000000..0a52d8c
--- /dev/null
+++ b/meowpp/math/Matrix.h
@@ -0,0 +1,74 @@
+#ifndef math_Matrix_H__
+#define math_Matrix_H__
+
+
+#include <cstdlib>
+
+#include <vector>
+
+namespace meow{
+ template<class Entry>
+ class Matrix{
+ private:
+ size_t _rows;
+ size_t _cols;
+ std::vector<Entry> _entries;
+ //
+ size_t index(size_t __r, size_t __c) const;
+ public:
+ Matrix();
+ Matrix(Matrix const& __m);
+ Matrix(size_t __rows, size_t __cols, Entry const& __entry);
+ ~Matrix();
+
+ Matrix& copy(Matrix const& __m);
+
+ bool valid() const;
+
+ size_t rows() const;
+ size_t cols() const;
+ size_t size(size_t __rows, size_t __cols);
+
+ Entry const& entry(size_t __i, size_t __j) const;
+ Entry const& entry(size_t __i, size_t __j, Entry const& __entry);
+ void entries(size_t __rFirst, size_t __rLast,
+ size_t __cFirst, size_t __cLast,
+ Entry const& __entry);
+
+ Matrix subMatrix(size_t __rFirst, size_t __rLast,
+ size_t __cFirst, size_t __cLast) const;
+ Matrix row(size_t __row) const;
+ Matrix col(size_t __col) const;
+
+ Matrix positive() const;
+ Matrix negative() const;
+
+ Matrix add(Matrix const& __m) const;
+ Matrix sub(Matrix const& __m) const;
+ Matrix mul(Matrix const& __m) const;
+
+ Matrix mul(Entry const& __s) const;
+ Matrix div(Entry const& __s) const;
+
+ Matrix identity () const;
+ Matrix& identitied();
+
+ Matrix transpose () const;
+ Matrix& transposed();
+
+ Matrix& operator=(Matrix const& __m);
+ Entry const& operator()(size_t __i, size_t __j) const;
+ Entry & operator()(size_t __i, size_t __j);
+ Matrix operator+() const;
+ Matrix operator-() const;
+ Matrix operator+(Matrix const& __m) const;
+ Matrix operator-(Matrix const& __m) const;
+ Matrix operator*(Matrix const& __m) const;
+ Matrix operator*(Entry const& __s) const;
+ Matrix operator/(Entry const& __s) const;
+ };
+}
+
+#include "Matrix.hpp"
+
+#endif // math_Matrix_H__