aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/CwiseBinaryOp.h
diff options
context:
space:
mode:
authorGravatar Hauke Heibel <hauke.heibel@gmail.com>2010-03-13 13:15:27 +0100
committerGravatar Hauke Heibel <hauke.heibel@gmail.com>2010-03-13 13:15:27 +0100
commitb9644f332330a7242fa13e8194e87ba4b5678f58 (patch)
tree47490d57b78832a7fec4fa53c6784e0fbd77a517 /Eigen/src/Core/CwiseBinaryOp.h
parent3e08c22028933be56078bdbeb1684dfafbf536d7 (diff)
Propagate fixed size dimensions if available (on MSVC it leads >2.5x speedup for some reductions).
Diffstat (limited to 'Eigen/src/Core/CwiseBinaryOp.h')
-rw-r--r--Eigen/src/Core/CwiseBinaryOp.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h
index 9ed005dce..fc455350c 100644
--- a/Eigen/src/Core/CwiseBinaryOp.h
+++ b/Eigen/src/Core/CwiseBinaryOp.h
@@ -121,8 +121,20 @@ class CwiseBinaryOp : ei_no_assignment_operator,
ei_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
}
- EIGEN_STRONG_INLINE int rows() const { return m_lhs.rows(); }
- EIGEN_STRONG_INLINE int cols() const { return m_lhs.cols(); }
+ EIGEN_STRONG_INLINE int rows() const {
+ // return the fixed size type if available to enable compile time optimizations
+ if (ei_traits<ei_cleantype<LhsNested>::type>::RowsAtCompileTime==Dynamic)
+ return m_rhs.rows();
+ else
+ return m_lhs.rows();
+ }
+ EIGEN_STRONG_INLINE int cols() const {
+ // return the fixed size type if available to enable compile time optimizations
+ if (ei_traits<ei_cleantype<LhsNested>::type>::ColsAtCompileTime==Dynamic)
+ return m_rhs.cols();
+ else
+ return m_lhs.cols();
+ }
/** \returns the left hand side nested expression */
const _LhsNested& lhs() const { return m_lhs; }