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 eigen_assert(m_xpr.rows() > 0 && m_xpr.cols() > 0
37 &&
"Cannot comma-initialize a 0x0 matrix (operator<<)");
38 m_xpr.coeffRef(0,0) = s;
41 template<
typename OtherDerived>
44 : m_xpr(xpr), m_row(0), m_col(other.
cols()), m_currentBlockRows(other.
rows())
46 eigen_assert(m_xpr.rows() >= other.
rows() && m_xpr.cols() >= other.
cols()
47 &&
"Cannot comma-initialize a 0x0 matrix (operator<<)");
48 m_xpr.block(0, 0, other.
rows(), other.
cols()) = other;
56 : m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) {
67 if (m_col==m_xpr.cols())
69 m_row+=m_currentBlockRows;
71 m_currentBlockRows = 1;
72 eigen_assert(m_row<m_xpr.rows()
73 &&
"Too many rows passed to comma initializer (operator<<)");
75 eigen_assert(m_col<m_xpr.cols()
76 &&
"Too many coefficients passed to comma initializer (operator<<)");
77 eigen_assert(m_currentBlockRows==1);
78 m_xpr.coeffRef(m_row, m_col++) = s;
83 template<
typename OtherDerived>
87 if (m_col==m_xpr.cols() && (other.
cols()!=0 || other.
rows()!=m_currentBlockRows))
89 m_row+=m_currentBlockRows;
91 m_currentBlockRows = other.
rows();
92 eigen_assert(m_row+m_currentBlockRows<=m_xpr.rows()
93 &&
"Too many rows passed to comma initializer (operator<<)");
95 eigen_assert((m_col + other.
cols() <= m_xpr.cols())
96 &&
"Too many coefficients passed to comma initializer (operator<<)");
97 eigen_assert(m_currentBlockRows==other.
rows());
98 m_xpr.template block<OtherDerived::RowsAtCompileTime, OtherDerived::ColsAtCompileTime>
99 (m_row, m_col, other.
rows(), other.
cols()) = other;
100 m_col += other.
cols();
106 #if defined VERIFY_RAISES_ASSERT && (!defined EIGEN_NO_ASSERTION_CHECKING) && defined EIGEN_EXCEPTIONS
107 EIGEN_EXCEPTION_SPEC(Eigen::eigen_assert_exception)
122 eigen_assert(((m_row+m_currentBlockRows) == m_xpr.rows() || m_xpr.cols() == 0)
123 && m_col == m_xpr.cols()
124 &&
"Too few coefficients passed to comma initializer (operator<<)");
131 Index m_currentBlockRows;
147 template<
typename Derived>
150 return CommaInitializer<Derived>(*
static_cast<Derived*
>(
this), s);
154 template<
typename Derived>
155 template<
typename OtherDerived>
156 EIGEN_DEVICE_FUNC
inline CommaInitializer<Derived>
159 return CommaInitializer<Derived>(*
static_cast<Derived *
>(
this), other);
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:47
CommaInitializer< Derived > operator<<(const Scalar &s)
Definition: CommaInitializer.h:148
Index cols() const
Definition: EigenBase.h:63
Index rows() const
Definition: EigenBase.h:60
Namespace containing all symbols from the Eigen library.
Definition: Core:134
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Helper class used by the comma initializer operator.
Definition: CommaInitializer.h:29
XprType & finished()
Definition: CommaInitializer.h:121