diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-08-06 15:57:26 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-08-06 17:07:43 +0100 |
commit | 1d3657c760228be246554ab0e7bfe9c2818e5a5b (patch) | |
tree | 457c398c0f202fd5cc62130b70537c12b4ff2145 /include/YAGE/Math | |
parent | c2d74ea23c2270732b2090ef7d9f92c636a00b59 (diff) | |
download | YAGE-1d3657c760228be246554ab0e7bfe9c2818e5a5b.tar.gz YAGE-1d3657c760228be246554ab0e7bfe9c2818e5a5b.zip |
Improving matrix class
Diffstat (limited to 'include/YAGE/Math')
-rw-r--r-- | include/YAGE/Math/matrix.hpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/include/YAGE/Math/matrix.hpp b/include/YAGE/Math/matrix.hpp index 2aca04db..8f490b41 100644 --- a/include/YAGE/Math/matrix.hpp +++ b/include/YAGE/Math/matrix.hpp @@ -96,6 +96,7 @@ protected: public: /// Initializes the size of the data_ vector Matrix<Rows, Cols, Type>() : data_(Rows*Cols) {} + Matrix<Rows, Cols, Type>(const std::vector<Type>& data) : data_(data) {} /// Returns the row size of the Matrix int rowSize() const @@ -273,8 +274,7 @@ Matrix<M, N, T> operator*(Matrix<M, N, T> lhs, const T &rhs) } template<int M, int N, class T> -Matrix<M, N, T> operator*(const T &lhs, Matrix<M, N, T> rhs) -{ +Matrix<M, N, T> operator*(const T &lhs, Matrix<M, N, T> rhs) { for(auto &data : rhs) { data*=lhs; @@ -312,7 +312,8 @@ template<int Rows=2, class Type=double> class Vector : public Matrix<Rows, 1, Ty { public: Vector<Rows, Type>() : Matrix<Rows, 1, Type>() {} - explicit Vector<Rows, Type>(const Matrix<Rows, 1, Type> &other) : Matrix<Rows, 1, Type>(other) {} + Vector<Rows, Type>(const Matrix<Rows, 1, Type>& other) : Matrix<Rows, 1, Type>(other) {} + Vector<Rows, Type>(const std::vector<Type>& data) : Matrix<Rows, 1, Type>(data) {} Type& operator[](int col) { @@ -345,6 +346,7 @@ template<class Type=double> class Vector2 : public Vector<2, Type> { public: Vector2<Type>() : Vector<2, Type>() {} + Vector2<Type>(const std::vector<Type>& data) : Vector<2, Type>(data) {} Vector2<Type>(Type x, Type y) { |