revert most of previous commit. It really is better to forbid default

constructor for dynamic-size matrices. Now why do I feel like a beheaded
chicken running around?
This commit is contained in:
Benoit Jacob 2008-01-08 10:39:36 +00:00
parent b036eca902
commit 47d354924b
3 changed files with 20 additions and 10 deletions

View File

@ -56,7 +56,6 @@ template<typename Expression> class Eval : NoOperatorEquals,
typedef Expression Base;
friend class MatrixBase<Scalar, Expression>;
Eval() : MatrixType() {}
Eval(const Expression& expression) : MatrixType(expression) {}
};

View File

@ -163,13 +163,14 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage
static Map<Matrix> map(Scalar* array, int size);
static Map<Matrix> map(Scalar* array);
/** Default constructor.
*
* For fixed-size matrices, does nothing.
*
* For dynamic-size matrices, dynamic dimensions are set to 1.
/** Default constructor, does nothing. Only for fixed-size matrices.
* For dynamic-size matrices and vectors, this constructor is forbidden (guarded by
* an assertion) because it would leave the matrix without an allocated data buffer.
*/
explicit Matrix() : Storage() {}
explicit Matrix() : Storage()
{
assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0);
}
/** Constructs a vector or row-vector with given dimension. \only_for_vectors
*

View File

@ -80,7 +80,7 @@ class MatrixStorage<Scalar, Dynamic, ColsAtCompileTime>
{ return ColsAtCompileTime; }
public:
MatrixStorage(int dim = 1) : m_rows(dim)
MatrixStorage(int dim) : m_rows(dim)
{
m_data = new Scalar[m_rows * ColsAtCompileTime];
}
@ -92,6 +92,9 @@ class MatrixStorage<Scalar, Dynamic, ColsAtCompileTime>
~MatrixStorage()
{ delete[] m_data; }
private:
MatrixStorage();
};
template<typename Scalar, int RowsAtCompileTime>
@ -120,7 +123,7 @@ class MatrixStorage<Scalar, RowsAtCompileTime, Dynamic>
{ return m_cols; }
public:
MatrixStorage(int dim = 1) : m_cols(dim)
MatrixStorage(int dim) : m_cols(dim)
{
m_data = new Scalar[m_cols * RowsAtCompileTime];
}
@ -132,6 +135,9 @@ class MatrixStorage<Scalar, RowsAtCompileTime, Dynamic>
~MatrixStorage()
{ delete[] m_data; }
private:
MatrixStorage();
};
template<typename Scalar>
@ -161,13 +167,17 @@ class MatrixStorage<Scalar, Dynamic, Dynamic>
public:
MatrixStorage(int rows = 1, int cols = 1) : m_rows(rows), m_cols(cols)
MatrixStorage(int rows, int cols) : m_rows(rows), m_cols(cols)
{
m_data = new Scalar[m_rows * m_cols];
}
~MatrixStorage()
{ delete[] m_data; }
private:
MatrixStorage();
MatrixStorage(int dim);
};
#endif // EIGEN_MATRIXSTORAGE_H