From d5b26e1a9428f7dd951dbf8ea08a5035620fa2e5 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Tue, 6 Jun 2017 11:10:29 +0100 Subject: Building matrix --- include/YAGE/Math/matrix.hpp | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/YAGE/Math/matrix.hpp b/include/YAGE/Math/matrix.hpp index b6807c09..76c90c16 100644 --- a/include/YAGE/Math/matrix.hpp +++ b/include/YAGE/Math/matrix.hpp @@ -1,29 +1,44 @@ #ifndef YAGE_MATH_MATRIX_HPP #define YAGE_MATH_MATRIX_HPP +#include +#include + namespace yage { -template class Matrix +template class Matrix; + +template class Row { + friend class Matrix; private: - Type x[Cols][Rows]; + std::shared_ptr> parent_; + int index_; public: - Matrix() + Row(std::shared_ptr> parent, int index) : + parent_(parent), index_(index) + {} + + Type &operator[](int col) { - for(int i=0; idata_[index_*Cols+col]; } +}; + +template class Matrix +{ +private: + std::vector data_; + +public: + Matrix() : data_(Rows*Cols) {} + Matrix(int rows, int cols) : data_(rows*cols) {} - Type get(int i, int j) const + Row operator[](int row) { - return x[i][j]; + return Row(std::make_shared>(*this), row); } }; -- cgit