From 7f27d3bf881ca3c257ab346c4ef5b6b0d177cdaa Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Thu, 22 Jun 2017 17:47:51 +0100 Subject: Documenting --- include/YAGE/Math/matrix.hpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/YAGE/Math/matrix.hpp b/include/YAGE/Math/matrix.hpp index 5a753616..d4566c98 100644 --- a/include/YAGE/Math/matrix.hpp +++ b/include/YAGE/Math/matrix.hpp @@ -1,3 +1,11 @@ +/* + * created 22-06-17 by Yann Herklotz + * + * Matrix class that contains definitions for matrices, vectors and operations + * on vectors and matrices. + * + */ + #ifndef YAGE_MATH_MATRIX_HPP #define YAGE_MATH_MATRIX_HPP @@ -12,11 +20,15 @@ namespace yage { template class Matrix; -template class Vector; +// includes implementation details that should not be accessible to the user namespace detail { +// Row class +// +// Used to implement the double square bracket operator and be able +// to return the value by reference of the array. template class Row { private: @@ -30,6 +42,7 @@ public: Type& operator[](int col) { + // the index is the y-position of the element in the matrix return parent_->data_[index_*Cols+col]; } @@ -41,8 +54,13 @@ public: } // detail +// Matrix class +// +// Implements the base Matrix class that is inherited by other classes to make them more +// specific. template class Matrix { + // friended with the row class so that it can access protected member data friend class detail::Row; protected: std::vector data_; @@ -60,6 +78,7 @@ public: return Cols; } + // returns the row in a row matrix Matrix<1, Cols, Type> getRow(int row) const { Matrix<1, Cols, Type> rowMatrix; @@ -70,6 +89,7 @@ public: return rowMatrix; } + // returns the column in a column matrix Matrix getCol(int col) const { Matrix colMatrix; @@ -80,16 +100,20 @@ public: return colMatrix; } + // iterator support for begin typename std::vector::iterator begin() { return data_.begin(); } + // iterator support for end typename std::vector::iterator end() { return data_.end(); } + // prints out the matrix, but can also be implemented by other classes to print data + // differently virtual std::string toString() const { std::stringstream ss; -- cgit