aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-01-07 21:19:36 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-01-07 21:19:36 +0000
commitb036eca902c85b647bbae52f3f3a41fd93bd59a7 (patch)
treeca3c7ddb25f5c6ac8af48c7a62b0636c8776669c /Eigen/src
parent8ba30554473ebcf3ac1c5a5e8b2139af0d730046 (diff)
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
Diffstat (limited to 'Eigen/src')
-rw-r--r--Eigen/src/Core/Eval.h1
-rw-r--r--Eigen/src/Core/Matrix.h21
-rw-r--r--Eigen/src/Core/MatrixStorage.h16
3 files changed, 14 insertions, 24 deletions
diff --git a/Eigen/src/Core/Eval.h b/Eigen/src/Core/Eval.h
index 7fa661c48..efa68a7cb 100644
--- a/Eigen/src/Core/Eval.h
+++ b/Eigen/src/Core/Eval.h
@@ -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) {}
};
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index 25ef36182..a829a2f8f 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -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
*
diff --git a/Eigen/src/Core/MatrixStorage.h b/Eigen/src/Core/MatrixStorage.h
index ebeaf4922..db4feb195 100644
--- a/Eigen/src/Core/MatrixStorage.h
+++ b/Eigen/src/Core/MatrixStorage.h
@@ -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