28struct CommaInitializer
30 typedef typename XprType::Scalar Scalar;
31 typedef typename XprType::Index Index;
33 inline CommaInitializer(XprType& xpr,
const Scalar& s)
34 : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1)
36 m_xpr.coeffRef(0,0) = s;
39 template<
typename OtherDerived>
41 : m_xpr(xpr), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows())
43 m_xpr.block(0, 0, other.rows(), other.cols()) = other;
49 inline CommaInitializer(
const CommaInitializer& o)
50 : m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) {
52 const_cast<CommaInitializer&
>(o).m_row = m_xpr.rows();
53 const_cast<CommaInitializer&
>(o).m_col = m_xpr.cols();
54 const_cast<CommaInitializer&
>(o).m_currentBlockRows = 0;
58 CommaInitializer& operator,(
const Scalar& s)
60 if (m_col==m_xpr.cols())
62 m_row+=m_currentBlockRows;
64 m_currentBlockRows = 1;
65 eigen_assert(m_row<m_xpr.rows()
66 &&
"Too many rows passed to comma initializer (operator<<)");
68 eigen_assert(m_col<m_xpr.cols()
69 &&
"Too many coefficients passed to comma initializer (operator<<)");
70 eigen_assert(m_currentBlockRows==1);
71 m_xpr.coeffRef(m_row, m_col++) = s;
76 template<
typename OtherDerived>
79 if (m_col==m_xpr.cols() && (other.cols()!=0 || other.rows()!=m_currentBlockRows))
81 m_row+=m_currentBlockRows;
83 m_currentBlockRows = other.rows();
84 eigen_assert(m_row+m_currentBlockRows<=m_xpr.rows()
85 &&
"Too many rows passed to comma initializer (operator<<)");
87 eigen_assert((m_col + other.cols() <= m_xpr.cols())
88 &&
"Too many coefficients passed to comma initializer (operator<<)");
89 eigen_assert(m_currentBlockRows==other.rows());
90 m_xpr.template block<OtherDerived::RowsAtCompileTime, OtherDerived::ColsAtCompileTime>
91 (m_row, m_col, other.rows(), other.cols()) = other;
92 m_col += other.cols();
96 inline ~CommaInitializer()
109 eigen_assert(((m_row+m_currentBlockRows) == m_xpr.rows() || m_xpr.cols() == 0)
110 && m_col == m_xpr.cols()
111 &&
"Too few coefficients passed to comma initializer (operator<<)");
118 Index m_currentBlockRows;