diff options
author | Gael Guennebaud <g.gael@free.fr> | 2009-10-13 09:23:09 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2009-10-13 09:23:09 +0200 |
commit | 14430940729b043ae14576d388555fc048619a3c (patch) | |
tree | e60efc573d4b25d509c3a0c6f951d088d3c4a802 | |
parent | 2049f742e4a1a6ff8b7f1617a296a80b2ebb0281 (diff) |
compilation fix: make the generic template ctor explicit
-rw-r--r-- | Eigen/src/Array/Replicate.h | 12 | ||||
-rw-r--r-- | test/array_replicate.cpp | 10 |
2 files changed, 9 insertions, 13 deletions
diff --git a/Eigen/src/Array/Replicate.h b/Eigen/src/Array/Replicate.h index b20bcd49a..653bda666 100644 --- a/Eigen/src/Array/Replicate.h +++ b/Eigen/src/Array/Replicate.h @@ -45,14 +45,10 @@ struct ei_traits<Replicate<MatrixType,RowFactor,ColFactor> > typedef typename ei_nested<MatrixType>::type MatrixTypeNested; typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; enum { - RowsPlusOne = (MatrixType::RowsAtCompileTime != Dynamic) ? - int(MatrixType::RowsAtCompileTime) + 1 : Dynamic, - ColsPlusOne = (MatrixType::ColsAtCompileTime != Dynamic) ? - int(MatrixType::ColsAtCompileTime) + 1 : Dynamic, - RowsAtCompileTime = RowFactor==Dynamic || MatrixType::RowsAtCompileTime==Dynamic + RowsAtCompileTime = RowFactor==Dynamic || int(MatrixType::RowsAtCompileTime)==Dynamic ? Dynamic : RowFactor * MatrixType::RowsAtCompileTime, - ColsAtCompileTime = ColFactor==Dynamic || MatrixType::ColsAtCompileTime==Dynamic + ColsAtCompileTime = ColFactor==Dynamic || int(MatrixType::ColsAtCompileTime)==Dynamic ? Dynamic : ColFactor * MatrixType::ColsAtCompileTime, MaxRowsAtCompileTime = RowsAtCompileTime, @@ -70,7 +66,7 @@ template<typename MatrixType,int RowFactor,int ColFactor> class Replicate EIGEN_GENERIC_PUBLIC_INTERFACE(Replicate) template<typename OriginalMatrixType> - inline Replicate(const OriginalMatrixType& matrix) + inline explicit Replicate(const OriginalMatrixType& matrix) : m_matrix(matrix), m_rowFactor(RowFactor), m_colFactor(ColFactor) { EIGEN_STATIC_ASSERT((ei_is_same_type<MatrixType,OriginalMatrixType>::ret), @@ -113,7 +109,7 @@ template<int RowFactor, int ColFactor> inline const Replicate<Derived,RowFactor,ColFactor> MatrixBase<Derived>::replicate() const { - return derived(); + return Replicate<Derived,RowFactor,ColFactor>(derived()); } /** \nonstableyet diff --git a/test/array_replicate.cpp b/test/array_replicate.cpp index d1608915f..cd0f65f26 100644 --- a/test/array_replicate.cpp +++ b/test/array_replicate.cpp @@ -42,9 +42,9 @@ template<typename MatrixType> void replicate(const MatrixType& m) MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols); - + VectorType v1 = VectorType::Random(rows); - + MatrixX x1, x2; VectorX vx1; @@ -56,17 +56,17 @@ template<typename MatrixType> void replicate(const MatrixType& m) for(int i=0; i<f1; i++) x1.block(i*rows,j*cols,rows,cols) = m1; VERIFY_IS_APPROX(x1, m1.replicate(f1,f2)); - + x2.resize(2*rows,3*cols); x2 << m2, m2, m2, m2, m2, m2; VERIFY_IS_APPROX(x2, (m2.template replicate<2,3>())); - + x2.resize(rows,f1); for (int j=0; j<f1; ++j) x2.col(j) = v1; VERIFY_IS_APPROX(x2, v1.rowwise().replicate(f1)); - + vx1.resize(rows*f2); for (int j=0; j<f2; ++j) vx1.segment(j*rows,rows) = v1; |