11 #ifndef EIGEN_COMMAINITIALIZER_H
12 #define EIGEN_COMMAINITIALIZER_H
14 #include "./InternalHeaderCheck.h"
29 template<
typename XprType>
32 typedef typename XprType::Scalar Scalar;
36 : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1)
38 eigen_assert(m_xpr.rows() > 0 && m_xpr.cols() > 0
39 &&
"Cannot comma-initialize a 0x0 matrix (operator<<)");
40 m_xpr.coeffRef(0,0) = s;
43 template<
typename OtherDerived>
46 : m_xpr(xpr), m_row(0), m_col(other.
cols()), m_currentBlockRows(other.
rows())
48 eigen_assert(m_xpr.rows() >= other.
rows() && m_xpr.cols() >= other.
cols()
49 &&
"Cannot comma-initialize a 0x0 matrix (operator<<)");
50 m_xpr.template block<OtherDerived::RowsAtCompileTime, OtherDerived::ColsAtCompileTime>(0, 0, other.
rows(), other.
cols()) = other;
58 : m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) {
69 if (m_col==m_xpr.cols())
71 m_row+=m_currentBlockRows;
73 m_currentBlockRows = 1;
74 eigen_assert(m_row<m_xpr.rows()
75 &&
"Too many rows passed to comma initializer (operator<<)");
77 eigen_assert(m_col<m_xpr.cols()
78 &&
"Too many coefficients passed to comma initializer (operator<<)");
79 eigen_assert(m_currentBlockRows==1);
80 m_xpr.coeffRef(m_row, m_col++) = s;
85 template<
typename OtherDerived>
89 if (m_col==m_xpr.cols() && (other.
cols()!=0 || other.
rows()!=m_currentBlockRows))
91 m_row+=m_currentBlockRows;
93 m_currentBlockRows = other.
rows();
94 eigen_assert(m_row+m_currentBlockRows<=m_xpr.rows()
95 &&
"Too many rows passed to comma initializer (operator<<)");
97 eigen_assert((m_col + other.
cols() <= m_xpr.cols())
98 &&
"Too many coefficients passed to comma initializer (operator<<)");
99 eigen_assert(m_currentBlockRows==other.
rows());
100 m_xpr.template block<OtherDerived::RowsAtCompileTime, OtherDerived::ColsAtCompileTime>
101 (m_row, m_col, other.
rows(), other.
cols()) = other;
102 m_col += other.
cols();
108 #if defined VERIFY_RAISES_ASSERT && (!defined EIGEN_NO_ASSERTION_CHECKING) && defined EIGEN_EXCEPTIONS
109 EIGEN_EXCEPTION_SPEC(Eigen::eigen_assert_exception)
124 eigen_assert(((m_row+m_currentBlockRows) == m_xpr.rows() || m_xpr.cols() == 0)
125 && m_col == m_xpr.cols()
126 &&
"Too few coefficients passed to comma initializer (operator<<)");
133 Index m_currentBlockRows;
149 template<
typename Derived>
152 return CommaInitializer<Derived>(*
static_cast<Derived*
>(
this), s);
156 template<
typename Derived>
157 template<
typename OtherDerived>
158 EIGEN_DEVICE_FUNC
inline CommaInitializer<Derived>
161 return CommaInitializer<Derived>(*
static_cast<Derived *
>(
this), other);
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:42
CommaInitializer< Derived > operator<<(const Scalar &s)
Definition: CommaInitializer.h:150
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:65
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:62
Namespace containing all symbols from the Eigen library.
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59
Helper class used by the comma initializer operator.
Definition: CommaInitializer.h:31
XprType & finished()
Definition: CommaInitializer.h:123