Eigen::CommaInitializer< XprType > Class Template Reference

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

Public Types

typedef XprType::Scalar Scalar
 

Public Member Functions

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

Public Attributes

Index m_col
 
Index m_currentBlockRows
 
Index m_row
 
XprType & m_xpr
 

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
MatrixBase::operator<<, CommaInitializer::finished()

Definition at line 30 of file CommaInitializer.h.

Member Typedef Documentation

◆ Scalar

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

Definition at line 32 of file CommaInitializer.h.

Constructor & Destructor Documentation

◆ CommaInitializer() [1/3]

template<typename XprType >
Eigen::CommaInitializer< XprType >::CommaInitializer ( XprType &  xpr,
const Scalar s 
)
inline

Definition at line 35 of file CommaInitializer.h.

36  : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1)
37  {
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;
41  }
#define eigen_assert(x)
Definition: Macros.h:902

◆ CommaInitializer() [2/3]

template<typename XprType >
template<typename OtherDerived >
Eigen::CommaInitializer< XprType >::CommaInitializer ( XprType &  xpr,
const DenseBase< OtherDerived > &  other 
)
inline

Definition at line 45 of file CommaInitializer.h.

46  : m_xpr(xpr), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows())
47  {
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;
51  }

◆ CommaInitializer() [3/3]

template<typename XprType >
Eigen::CommaInitializer< XprType >::CommaInitializer ( const CommaInitializer< XprType > &  o)
inline

Definition at line 57 of file CommaInitializer.h.

58  : m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) {
59  // Mark original object as finished. In absence of R-value references we need to const_cast:
60  const_cast<CommaInitializer&>(o).m_row = m_xpr.rows();
61  const_cast<CommaInitializer&>(o).m_col = m_xpr.cols();
62  const_cast<CommaInitializer&>(o).m_currentBlockRows = 0;
63  }
CommaInitializer(XprType &xpr, const Scalar &s)

◆ ~CommaInitializer()

template<typename XprType >
Eigen::CommaInitializer< XprType >::~CommaInitializer ( )
inline

Definition at line 107 of file CommaInitializer.h.

111  {
112  finished();
113  }

Member Function Documentation

◆ finished()

template<typename XprType >
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());
Matrix< float, 3, 3 > Matrix3f
3×3 matrix of type float.
Definition: Matrix.h:501

Definition at line 123 of file CommaInitializer.h.

123  {
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<<)");
127  return m_xpr;
128  }

◆ operator,() [1/2]

template<typename XprType >
template<typename OtherDerived >
CommaInitializer& Eigen::CommaInitializer< XprType >::operator, ( const DenseBase< OtherDerived > &  other)
inline

Definition at line 87 of file CommaInitializer.h.

88  {
89  if (m_col==m_xpr.cols() && (other.cols()!=0 || other.rows()!=m_currentBlockRows))
90  {
92  m_col = 0;
93  m_currentBlockRows = other.rows();
95  && "Too many rows passed to comma initializer (operator<<)");
96  }
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();
103  return *this;
104  }

◆ operator,() [2/2]

template<typename XprType >
CommaInitializer& Eigen::CommaInitializer< XprType >::operator, ( const Scalar s)
inline

Definition at line 67 of file CommaInitializer.h.

68  {
69  if (m_col==m_xpr.cols())
70  {
72  m_col = 0;
74  eigen_assert(m_row<m_xpr.rows()
75  && "Too many rows passed to comma initializer (operator<<)");
76  }
77  eigen_assert(m_col<m_xpr.cols()
78  && "Too many coefficients passed to comma initializer (operator<<)");
80  m_xpr.coeffRef(m_row, m_col++) = s;
81  return *this;
82  }

Member Data Documentation

◆ m_col

template<typename XprType >
Index Eigen::CommaInitializer< XprType >::m_col

Definition at line 132 of file CommaInitializer.h.

◆ m_currentBlockRows

template<typename XprType >
Index Eigen::CommaInitializer< XprType >::m_currentBlockRows

Definition at line 133 of file CommaInitializer.h.

◆ m_row

template<typename XprType >
Index Eigen::CommaInitializer< XprType >::m_row

Definition at line 131 of file CommaInitializer.h.

◆ m_xpr

template<typename XprType >
XprType& Eigen::CommaInitializer< XprType >::m_xpr

Definition at line 130 of file CommaInitializer.h.


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