diff options
author | 2008-01-11 15:08:04 +0000 | |
---|---|---|
committer | 2008-01-11 15:08:04 +0000 | |
commit | e092cbc75cadef1158d43f07b32e4ae0bf9372e2 (patch) | |
tree | f95fb0f3e6c36c6e6badbed4fcd8d136b8483880 /Eigen/src/Core/OperatorEquals.h | |
parent | aae0667e1e120b5809a7e2fe442d67832ff9ed0f (diff) |
-add set...() methods and their documentation; remove Generic
-use row-major traversal when the number of columns is fixed
and the number of rows is dynamic
-other minor changes
Diffstat (limited to 'Eigen/src/Core/OperatorEquals.h')
-rw-r--r-- | Eigen/src/Core/OperatorEquals.h | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/Eigen/src/Core/OperatorEquals.h b/Eigen/src/Core/OperatorEquals.h index 49da872c0..01086ad40 100644 --- a/Eigen/src/Core/OperatorEquals.h +++ b/Eigen/src/Core/OperatorEquals.h @@ -106,27 +106,45 @@ Derived& MatrixBase<Scalar, Derived> if(Traits::IsVectorAtCompileTime && OtherDerived::Traits::IsVectorAtCompileTime) // copying a vector expression into a vector { - assert(coeffs() == other.coeffs()); + assert(size() == other.size()); if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic && Traits::SizeAtCompileTime <= 25) VectorOperatorEqualsUnroller <Derived, OtherDerived, Traits::SizeAtCompileTime>::run (*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other)); else - for(int i = 0; i < coeffs(); i++) + for(int i = 0; i < size(); i++) coeffRef(i) = other.coeff(i); return *static_cast<Derived*>(this); } else // copying a matrix expression into a matrix { assert(rows() == other.rows() && cols() == other.cols()); - if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic && Traits::SizeAtCompileTime <= 25) + if(EIGEN_UNROLLED_LOOPS + && Traits::SizeAtCompileTime != Dynamic + && Traits::SizeAtCompileTime <= 25) + { MatrixOperatorEqualsUnroller <Derived, OtherDerived, Traits::SizeAtCompileTime>::run (*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other)); + } else - for(int j = 0; j < cols(); j++) + { + if(Traits::ColsAtCompileTime == Dynamic || Traits::RowsAtCompileTime != Dynamic) + { + // traverse in column-major order + for(int j = 0; j < cols(); j++) + for(int i = 0; i < rows(); i++) + coeffRef(i, j) = other.coeff(i, j); + } + else + { + // traverse in row-major order + // in order to allow the compiler to unroll the inner loop for(int i = 0; i < rows(); i++) - coeffRef(i, j) = other.coeff(i, j); + for(int j = 0; j < cols(); j++) + coeffRef(i, j) = other.coeff(i, j); + } + } return *static_cast<Derived*>(this); } } |