diff --git a/Eigen/src/Core/CommaInitializer.h b/Eigen/src/Core/CommaInitializer.h --- a/Eigen/src/Core/CommaInitializer.h +++ b/Eigen/src/Core/CommaInitializer.h @@ -8,16 +8,34 @@ // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef EIGEN_COMMAINITIALIZER_H #define EIGEN_COMMAINITIALIZER_H namespace Eigen { +namespace internal { + + + +template +struct CommaInitializerRef { + typedef typename XprType::Index Index; + XprType& m_xpr; + Index m_row, m_col, m_currentBlockRows; + + explicit CommaInitializerRef(XprType& xpr, Index row, Index col, Index currentBlockRows) + : m_xpr(xpr), m_row(row), m_col(col), m_currentBlockRows(currentBlockRows) { + std::cout << __PRETTY_FUNCTION__ << std::endl; + } +}; + +} // end namespace internal + /** \class CommaInitializer * \ingroup Core_Module * * \brief Helper class used by the comma initializer operator * * This class is internally used to implement the comma initializer feature. It is * the return type of MatrixBase::operator<<, and most of the time this is the only * way it is used. @@ -25,22 +43,54 @@ namespace Eigen { * \sa \ref MatrixBaseCommaInitRef "MatrixBase::operator<<", CommaInitializer::finished() */ template struct CommaInitializer { typedef typename XprType::Scalar Scalar; typedef typename XprType::Index Index; + + operator internal::CommaInitializerRef() + { + std::cout << __PRETTY_FUNCTION__ << std::endl; + internal::CommaInitializerRef ret(m_xpr, m_row, m_col, m_currentBlockRows); + m_row = m_xpr.rows(); + m_col = m_xpr.cols(); + m_currentBlockRows = 0; + return ret; + } + + inline CommaInitializer(XprType& xpr, const Scalar& s) : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1) { m_xpr.coeffRef(0,0) = s; } - + +#ifdef EIGEN_HAVE_RVALUE_REFERENCES + inline CommaInitializer(CommaInitializer&& o) +#else + inline CommaInitializer(CommaInitializer& o) +#endif + : m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) { + std::cout << __PRETTY_FUNCTION__ << std::endl; + o.m_row = m_xpr.rows(); + o.m_col = m_xpr.cols(); + o.m_currentBlockRows = 0; + } + +#ifndef EIGEN_HAVE_RVALUE_REFERENCES + inline CommaInitializer(internal::CommaInitializerRef o) + : m_xpr(o.m_xpr), + m_row(o.m_row), + m_col(o.m_col), + m_currentBlockRows(o.m_currentBlockRows) { + } +#endif template inline CommaInitializer(XprType& xpr, const DenseBase& other) : m_xpr(xpr), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows()) { m_xpr.block(0, 0, other.rows(), other.cols()) = other; } /* inserts a scalar value in the target matrix */ @@ -85,16 +135,17 @@ struct CommaInitializer else m_xpr.block(m_row, m_col, other.rows(), other.cols()) = other; m_col += other.cols(); return *this; } inline ~CommaInitializer() { + std::cout << __PRETTY_FUNCTION__ << m_row << std::endl; eigen_assert((m_row+m_currentBlockRows) == m_xpr.rows() && m_col == m_xpr.cols() && "Too few coefficients passed to comma initializer (operator<<)"); } /** \returns the built matrix once all its coefficients have been set. * Calling finished is 100% optional. Its purpose is to write expressions * like this: