From a587346b479ebcecbee7292896911866b8b84f20 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Mon, 26 Nov 2007 09:11:12 +0000 Subject: [PATCH] Matrix(int,int) constructor no longer takes default arguments. Instead, introduce Matrix() and Matrix(int); however, dynamic dimensions are required to be specified in the constructor (we no longer default to 1) --- src/Core/Matrix.h | 5 +++-- src/Core/MatrixStorage.h | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/Core/Matrix.h b/src/Core/Matrix.h index b0a9e003c..c703e5b2b 100644 --- a/src/Core/Matrix.h +++ b/src/Core/Matrix.h @@ -80,8 +80,9 @@ class Matrix : public Object<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, *=) EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, /=) - explicit Matrix(int rows = RowsAtCompileTime, - int cols = ColsAtCompileTime) : Storage(rows, cols) {} + explicit Matrix() : Storage() {} + explicit Matrix(int dim) : Storage(dim) {} + explicit Matrix(int rows, int cols) : Storage(rows, cols) {} template Matrix(const Object& other) : Storage(other.rows(), other.cols()) diff --git a/src/Core/MatrixStorage.h b/src/Core/MatrixStorage.h index e03397015..70dadc3e1 100644 --- a/src/Core/MatrixStorage.h +++ b/src/Core/MatrixStorage.h @@ -44,10 +44,16 @@ class MatrixStorage { return ColsAtCompileTime; } public: + MatrixStorage() {} + + MatrixStorage(int dim) + { + assert((RowsAtCompileTime == 1 && ColsAtCompileTime == dim) + || (ColsAtCompileTime == 1 && RowsAtCompileTime == dim)); + } + MatrixStorage(int rows, int cols) { - EIGEN_UNUSED(rows); - EIGEN_UNUSED(cols); assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0 && rows == RowsAtCompileTime && cols == ColsAtCompileTime); } @@ -80,6 +86,12 @@ class MatrixStorage { return ColsAtCompileTime; } public: + MatrixStorage(int dim) : m_rows(dim) + { + assert(m_rows > 0 && ColsAtCompileTime > 0); + m_array = new Scalar[m_rows * ColsAtCompileTime]; + } + MatrixStorage(int rows, int cols) : m_rows(rows) { assert(m_rows > 0 && cols == ColsAtCompileTime && ColsAtCompileTime > 0); @@ -88,6 +100,9 @@ class MatrixStorage ~MatrixStorage() { delete[] m_array; } + + private: + MatrixStorage(); }; template @@ -115,6 +130,12 @@ class MatrixStorage { return m_cols; } public: + MatrixStorage(int dim) : m_cols(dim) + { + assert(m_cols > 0 && RowsAtCompileTime > 0); + m_array = new Scalar[m_cols * RowsAtCompileTime]; + } + MatrixStorage(int rows, int cols) : m_cols(cols) { assert(rows == RowsAtCompileTime && RowsAtCompileTime > 0 && cols > 0); @@ -123,6 +144,9 @@ class MatrixStorage ~MatrixStorage() { delete[] m_array; } + + private: + MatrixStorage(); }; template @@ -159,6 +183,10 @@ class MatrixStorage ~MatrixStorage() { delete[] m_array; } + + private: + MatrixStorage(); + MatrixStorage(int dim); }; #endif // EIGEN_MATRIXSTORAGE_H