mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-09 07:00:27 +08:00
Revert to allowing default Matrix constructor even for dynamic size (which is
then set to 1). Discussion with jonasp made me remember why we did so in Eigen1. Also add default constructor to Eval
This commit is contained in:
parent
8ba3055447
commit
b036eca902
@ -56,6 +56,7 @@ template<typename Expression> class Eval : NoOperatorEquals,
|
||||
typedef Expression Base;
|
||||
friend class MatrixBase<Scalar, Expression>;
|
||||
|
||||
Eval() : MatrixType() {}
|
||||
Eval(const Expression& expression) : MatrixType(expression) {}
|
||||
};
|
||||
|
||||
|
@ -42,9 +42,9 @@
|
||||
* All matrix and vector types are just typedefs to specializations of this class template.
|
||||
*
|
||||
* These typedefs are as follows:
|
||||
* \li \c %Matrix##Size##Type for square matrices
|
||||
* \li \c Vector##Size##Type for vectors (matrices with one column)
|
||||
* \li \c RowVector##Size##Type for row-vectors (matrices with one row)
|
||||
* \li \c %Matrix\#\#Size\#\#Type for square matrices
|
||||
* \li \c Vector\#\#Size\#\#Type for vectors (matrices with one column)
|
||||
* \li \c RowVector\#\#Size\#\#Type for row-vectors (matrices with one row)
|
||||
*
|
||||
* where \c Size can be
|
||||
* \li \c 2 for fixed size 2
|
||||
@ -57,7 +57,7 @@
|
||||
* \li \c f for type \c float
|
||||
* \li \c d for type \c double
|
||||
* \li \c cf for type \c std::complex<float>
|
||||
* \li \c cd for type \c std::complex<float>
|
||||
* \li \c cd for type \c std::complex<double>
|
||||
*
|
||||
* Examples:
|
||||
* \li \c Matrix2d is a typedef for \c Matrix<double,2,2>
|
||||
@ -163,14 +163,13 @@ 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, 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.
|
||||
/** Default constructor.
|
||||
*
|
||||
* For fixed-size matrices, does nothing.
|
||||
*
|
||||
* For dynamic-size matrices, dynamic dimensions are set to 1.
|
||||
*/
|
||||
explicit Matrix() : Storage()
|
||||
{
|
||||
assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0);
|
||||
}
|
||||
explicit Matrix() : Storage() {}
|
||||
|
||||
/** Constructs a vector or row-vector with given dimension. \only_for_vectors
|
||||
*
|
||||
|
@ -80,7 +80,7 @@ class MatrixStorage<Scalar, Dynamic, ColsAtCompileTime>
|
||||
{ return ColsAtCompileTime; }
|
||||
|
||||
public:
|
||||
MatrixStorage(int dim) : m_rows(dim)
|
||||
MatrixStorage(int dim = 1) : m_rows(dim)
|
||||
{
|
||||
m_data = new Scalar[m_rows * ColsAtCompileTime];
|
||||
}
|
||||
@ -92,9 +92,6 @@ class MatrixStorage<Scalar, Dynamic, ColsAtCompileTime>
|
||||
|
||||
~MatrixStorage()
|
||||
{ delete[] m_data; }
|
||||
|
||||
private:
|
||||
MatrixStorage();
|
||||
};
|
||||
|
||||
template<typename Scalar, int RowsAtCompileTime>
|
||||
@ -123,7 +120,7 @@ class MatrixStorage<Scalar, RowsAtCompileTime, Dynamic>
|
||||
{ return m_cols; }
|
||||
|
||||
public:
|
||||
MatrixStorage(int dim) : m_cols(dim)
|
||||
MatrixStorage(int dim = 1) : m_cols(dim)
|
||||
{
|
||||
m_data = new Scalar[m_cols * RowsAtCompileTime];
|
||||
}
|
||||
@ -135,9 +132,6 @@ class MatrixStorage<Scalar, RowsAtCompileTime, Dynamic>
|
||||
|
||||
~MatrixStorage()
|
||||
{ delete[] m_data; }
|
||||
|
||||
private:
|
||||
MatrixStorage();
|
||||
};
|
||||
|
||||
template<typename Scalar>
|
||||
@ -167,17 +161,13 @@ class MatrixStorage<Scalar, Dynamic, Dynamic>
|
||||
|
||||
public:
|
||||
|
||||
MatrixStorage(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||
MatrixStorage(int rows = 1, int cols = 1) : 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
|
||||
|
Loading…
Reference in New Issue
Block a user