11 #ifndef EIGEN_COMMAINITIALIZER_H 12 #define EIGEN_COMMAINITIALIZER_H 27 template<
typename XprType>
30 typedef typename XprType::Scalar Scalar;
34 : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1)
36 m_xpr.coeffRef(0,0) = s;
39 template<
typename OtherDerived>
42 : m_xpr(xpr), m_row(0), m_col(other.
cols()), m_currentBlockRows(other.
rows())
44 m_xpr.block(0, 0, other.
rows(), other.
cols()) = other;
51 inline CommaInitializer(
const CommaInitializer& o)
52 : m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) {
54 const_cast<CommaInitializer&
>(o).m_row = m_xpr.rows();
55 const_cast<CommaInitializer&
>(o).m_col = m_xpr.cols();
56 const_cast<CommaInitializer&
>(o).m_currentBlockRows = 0;
61 CommaInitializer& operator,(
const Scalar& s)
63 if (m_col==m_xpr.cols())
65 m_row+=m_currentBlockRows;
67 m_currentBlockRows = 1;
68 eigen_assert(m_row<m_xpr.rows()
69 &&
"Too many rows passed to comma initializer (operator<<)");
71 eigen_assert(m_col<m_xpr.cols()
72 &&
"Too many coefficients passed to comma initializer (operator<<)");
73 eigen_assert(m_currentBlockRows==1);
74 m_xpr.coeffRef(m_row, m_col++) = s;
79 template<
typename OtherDerived>
85 m_col += other.
cols();
88 if (m_col==m_xpr.cols())
90 m_row+=m_currentBlockRows;
92 m_currentBlockRows = other.
rows();
93 eigen_assert(m_row+m_currentBlockRows<=m_xpr.rows()
94 &&
"Too many rows passed to comma initializer (operator<<)");
96 eigen_assert((m_col<m_xpr.cols() || (m_xpr.cols()==0 && m_col==0))
97 &&
"Too many coefficients passed to comma initializer (operator<<)");
98 eigen_assert(m_currentBlockRows==other.
rows());
99 if (OtherDerived::SizeAtCompileTime !=
Dynamic)
100 m_xpr.template block<OtherDerived::RowsAtCompileTime !=
Dynamic ? OtherDerived::RowsAtCompileTime : 1,
101 OtherDerived::ColsAtCompileTime !=
Dynamic ? OtherDerived::ColsAtCompileTime : 1>
102 (m_row, m_col) = other;
104 m_xpr.block(m_row, m_col, other.
rows(), other.
cols()) = other;
105 m_col += other.
cols();
110 inline ~CommaInitializer()
111 #if defined VERIFY_RAISES_ASSERT && (!defined EIGEN_NO_ASSERTION_CHECKING) && defined EIGEN_EXCEPTIONS 112 EIGEN_EXCEPTION_SPEC(Eigen::eigen_assert_exception)
115 eigen_assert((m_row+m_currentBlockRows) == m_xpr.rows()
116 && m_col == m_xpr.cols()
117 &&
"Too few coefficients passed to comma initializer (operator<<)");
133 Index m_currentBlockRows;
149 template<
typename Derived>
156 template<
typename Derived>
157 template<
typename OtherDerived>
166 #endif // EIGEN_COMMAINITIALIZER_H XprType & finished()
Definition: CommaInitializer.h:128
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:66
Namespace containing all symbols from the Eigen library.
Definition: Core:271
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:41
CommaInitializer< Derived > operator<<(const Scalar &s)
Definition: CommaInitializer.h:150
Helper class used by the comma initializer operator.
Definition: CommaInitializer.h:28
Index rows() const
Definition: EigenBase.h:58
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: XprHelper.h:35
const int Dynamic
Definition: Constants.h:21
Index cols() const
Definition: EigenBase.h:61