Eigen::CommaInitializer< XprType > Class Template Reference

Helper class used by the comma initializer operator. More...

#include <CommaInitializer.h>

Public Types

typedef XprType::Scalar Scalar
 

Public Member Functions

EIGEN_DEVICE_FUNC CommaInitializer (XprType &xpr, const Scalar &s)
 
template<typename OtherDerived >
EIGEN_DEVICE_FUNC CommaInitializer (XprType &xpr, const DenseBase< OtherDerived > &other)
 
EIGEN_DEVICE_FUNC CommaInitializer (const CommaInitializer &o)
 
EIGEN_DEVICE_FUNC CommaInitializeroperator, (const Scalar &s)
 
template<typename OtherDerived >
EIGEN_DEVICE_FUNC CommaInitializeroperator, (const DenseBase< OtherDerived > &other)
 
EIGEN_DEVICE_FUNC ~CommaInitializer ()
 
EIGEN_DEVICE_FUNC XprTypefinished ()
 

Public Attributes

XprTypem_xpr
 
Index m_row
 
Index m_col
 
Index m_currentBlockRows
 

Detailed Description

template<typename XprType>
class Eigen::CommaInitializer< XprType >

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.

See also
\blank MatrixBase::operator<<, CommaInitializer::finished()

Member Typedef Documentation

◆ Scalar

template<typename XprType >
typedef XprType::Scalar Eigen::CommaInitializer< XprType >::Scalar

Constructor & Destructor Documentation

◆ CommaInitializer() [1/3]

template<typename XprType >
EIGEN_DEVICE_FUNC Eigen::CommaInitializer< XprType >::CommaInitializer ( XprType xpr,
const Scalar s 
)
inline
35  : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1) {
36  eigen_assert(m_xpr.rows() > 0 && m_xpr.cols() > 0 && "Cannot comma-initialize a 0x0 matrix (operator<<)");
37  m_xpr.coeffRef(0, 0) = s;
38  }
#define eigen_assert(x)
Definition: Macros.h:910
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: CwiseBinaryOp.h:116
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: CwiseBinaryOp.h:111
RealScalar s
Definition: level1_cplx_impl.h:130
XprType & m_xpr
Definition: CommaInitializer.h:114
Index m_currentBlockRows
Definition: CommaInitializer.h:117
Index m_col
Definition: CommaInitializer.h:116
Index m_row
Definition: CommaInitializer.h:115

References eigen_assert, Eigen::CommaInitializer< XprType >::m_xpr, and s.

◆ CommaInitializer() [2/3]

template<typename XprType >
template<typename OtherDerived >
EIGEN_DEVICE_FUNC Eigen::CommaInitializer< XprType >::CommaInitializer ( XprType xpr,
const DenseBase< OtherDerived > &  other 
)
inline
42  : m_xpr(xpr), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows()) {
43  eigen_assert(m_xpr.rows() >= other.rows() && m_xpr.cols() >= other.cols() &&
44  "Cannot comma-initialize a 0x0 matrix (operator<<)");
45  m_xpr.template block<OtherDerived::RowsAtCompileTime, OtherDerived::ColsAtCompileTime>(0, 0, other.rows(),
46  other.cols()) = other;
47  }

References eigen_assert, and Eigen::CommaInitializer< XprType >::m_xpr.

◆ CommaInitializer() [3/3]

template<typename XprType >
EIGEN_DEVICE_FUNC Eigen::CommaInitializer< XprType >::CommaInitializer ( const CommaInitializer< XprType > &  o)
inline
53  : m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) {
54  // Mark original object as finished. In absence of R-value references we need to const_cast:
55  const_cast<CommaInitializer&>(o).m_row = m_xpr.rows();
56  const_cast<CommaInitializer&>(o).m_col = m_xpr.cols();
57  const_cast<CommaInitializer&>(o).m_currentBlockRows = 0;
58  }
EIGEN_DEVICE_FUNC CommaInitializer(XprType &xpr, const Scalar &s)
Definition: CommaInitializer.h:34

References Eigen::CommaInitializer< XprType >::m_col, Eigen::CommaInitializer< XprType >::m_currentBlockRows, Eigen::CommaInitializer< XprType >::m_row, and Eigen::CommaInitializer< XprType >::m_xpr.

◆ ~CommaInitializer()

template<typename XprType >
EIGEN_DEVICE_FUNC Eigen::CommaInitializer< XprType >::~CommaInitializer ( )
inline
97  {
98  finished();
99  }
EIGEN_DEVICE_FUNC XprType & finished()
Definition: CommaInitializer.h:108

References Eigen::CommaInitializer< XprType >::finished().

Member Function Documentation

◆ finished()

template<typename XprType >
EIGEN_DEVICE_FUNC XprType& Eigen::CommaInitializer< XprType >::finished ( )
inline
Returns
the built matrix once all its coefficients have been set. Calling finished is 100% optional. Its purpose is to write expressions like this:
quaternion.fromRotationMatrix((Matrix3f() << axis0, axis1, axis2).finished());
void quaternion(void)
Definition: geo_quaternion.cpp:47
108  {
109  eigen_assert(((m_row + m_currentBlockRows) == m_xpr.rows() || m_xpr.cols() == 0) && m_col == m_xpr.cols() &&
110  "Too few coefficients passed to comma initializer (operator<<)");
111  return m_xpr;
112  }

References eigen_assert, Eigen::CommaInitializer< XprType >::m_col, Eigen::CommaInitializer< XprType >::m_currentBlockRows, Eigen::CommaInitializer< XprType >::m_row, and Eigen::CommaInitializer< XprType >::m_xpr.

Referenced by Eigen::CommaInitializer< XprType >::~CommaInitializer().

◆ operator,() [1/2]

template<typename XprType >
template<typename OtherDerived >
EIGEN_DEVICE_FUNC CommaInitializer& Eigen::CommaInitializer< XprType >::operator, ( const DenseBase< OtherDerived > &  other)
inline
76  {
77  if (m_col == m_xpr.cols() && (other.cols() != 0 || other.rows() != m_currentBlockRows)) {
79  m_col = 0;
80  m_currentBlockRows = other.rows();
82  "Too many rows passed to comma initializer (operator<<)");
83  }
84  eigen_assert((m_col + other.cols() <= m_xpr.cols()) &&
85  "Too many coefficients passed to comma initializer (operator<<)");
86  eigen_assert(m_currentBlockRows == other.rows());
87  m_xpr.template block<OtherDerived::RowsAtCompileTime, OtherDerived::ColsAtCompileTime>(m_row, m_col, other.rows(),
88  other.cols()) = other;
89  m_col += other.cols();
90  return *this;
91  }

References eigen_assert, Eigen::CommaInitializer< XprType >::m_col, Eigen::CommaInitializer< XprType >::m_currentBlockRows, Eigen::CommaInitializer< XprType >::m_row, and Eigen::CommaInitializer< XprType >::m_xpr.

◆ operator,() [2/2]

template<typename XprType >
EIGEN_DEVICE_FUNC CommaInitializer& Eigen::CommaInitializer< XprType >::operator, ( const Scalar s)
inline
61  {
62  if (m_col == m_xpr.cols()) {
64  m_col = 0;
66  eigen_assert(m_row < m_xpr.rows() && "Too many rows passed to comma initializer (operator<<)");
67  }
68  eigen_assert(m_col < m_xpr.cols() && "Too many coefficients passed to comma initializer (operator<<)");
70  m_xpr.coeffRef(m_row, m_col++) = s;
71  return *this;
72  }

References eigen_assert, Eigen::CommaInitializer< XprType >::m_col, Eigen::CommaInitializer< XprType >::m_currentBlockRows, Eigen::CommaInitializer< XprType >::m_row, Eigen::CommaInitializer< XprType >::m_xpr, and s.

Member Data Documentation

◆ m_col

◆ m_currentBlockRows

◆ m_row

◆ m_xpr


The documentation for this class was generated from the following file: