From 61e7d329c6bafaf269a619ffb2bb80a24b1fb210 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Tue, 13 Jun 2017 17:43:39 +0100 Subject: Working on matrix functions --- include/YAGE/Math/matrix.hpp | 97 +++++++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 32 deletions(-) (limited to 'include') diff --git a/include/YAGE/Math/matrix.hpp b/include/YAGE/Math/matrix.hpp index 3b18be0b..5a9e80f2 100644 --- a/include/YAGE/Math/matrix.hpp +++ b/include/YAGE/Math/matrix.hpp @@ -4,12 +4,15 @@ #include #include #include +#include +#include #include namespace yage { template class Matrix; +template class Vector; namespace detail { @@ -47,21 +50,69 @@ protected: public: Matrix() : data_(Rows*Cols) {} - int rowSize() + int rowSize() const { return Rows; } - int colSize() + int colSize() const { return Cols; } + Matrix<1, Cols, Type> getRow(int row) const + { + Matrix<1, Cols, Type> rowMatrix; + for(int i=0; i getCol(int col) const + { + Matrix colMatrix; + for(int i=0; i operator[](int row) { return detail::Row(this, row); } + detail::Row operator[](int row) const + { + // TODO got to fix this + return detail::Row((Matrix*)this, row); + } + Matrix& operator=(const Matrix &other) { if(this!=&other) @@ -111,25 +162,7 @@ public: friend std::ostream& operator<<(std::ostream &os, const Matrix &mat) { - os<<'['; - for(std::size_t i=0; i class Vector : public Matrix() : Matrix() {} - explicit Vector(const Matrix &other) - { - this->data_=other.data_; - } + explicit Vector(const Matrix &other) : Matrix(other) {} Type& operator[](int col) { @@ -188,12 +218,15 @@ namespace matrix template Matrix transpose(const Matrix &m) { - static_assert(M!=1, "Called wrong transpose"); -} - -template Vector transpose(const Matrix<1, N, T> &m) -{ - + Matrix trans; + for(int i=0; i T dot(const Vector &v1, const Vector &v2) @@ -223,7 +256,7 @@ Matrix multiply(const Matrix &m1, const Matrix &m2) return res; } -} // vector +} // matrix } // yage -- cgit