CommaInitializer.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_COMMAINITIALIZER_H
12 #define EIGEN_COMMAINITIALIZER_H
13 
14 namespace Eigen {
15 
27 template<typename XprType>
29 {
30  typedef typename XprType::Scalar Scalar;
31  typedef typename XprType::Index Index;
32 
33  inline CommaInitializer(XprType& xpr, const Scalar& s)
34  : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1)
35  {
36  m_xpr.coeffRef(0,0) = s;
37  }
38 
39  template<typename OtherDerived>
40  inline CommaInitializer(XprType& xpr, const DenseBase<OtherDerived>& other)
41  : m_xpr(xpr), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows())
42  {
43  m_xpr.block(0, 0, other.rows(), other.cols()) = other;
44  }
45 
46  /* inserts a scalar value in the target matrix */
47  CommaInitializer& operator,(const Scalar& s)
48  {
49  if (m_col==m_xpr.cols())
50  {
52  m_col = 0;
54  eigen_assert(m_row<m_xpr.rows()
55  && "Too many rows passed to comma initializer (operator<<)");
56  }
57  eigen_assert(m_col<m_xpr.cols()
58  && "Too many coefficients passed to comma initializer (operator<<)");
60  m_xpr.coeffRef(m_row, m_col++) = s;
61  return *this;
62  }
63 
64  /* inserts a matrix expression in the target matrix */
65  template<typename OtherDerived>
67  {
68  if(other.cols()==0 || other.rows()==0)
69  return *this;
70  if (m_col==m_xpr.cols())
71  {
73  m_col = 0;
74  m_currentBlockRows = other.rows();
76  && "Too many rows passed to comma initializer (operator<<)");
77  }
78  eigen_assert(m_col<m_xpr.cols()
79  && "Too many coefficients passed to comma initializer (operator<<)");
80  eigen_assert(m_currentBlockRows==other.rows());
81  if (OtherDerived::SizeAtCompileTime != Dynamic)
82  m_xpr.template block<OtherDerived::RowsAtCompileTime != Dynamic ? OtherDerived::RowsAtCompileTime : 1,
83  OtherDerived::ColsAtCompileTime != Dynamic ? OtherDerived::ColsAtCompileTime : 1>
84  (m_row, m_col) = other;
85  else
86  m_xpr.block(m_row, m_col, other.rows(), other.cols()) = other;
87  m_col += other.cols();
88  return *this;
89  }
90 
92  {
94  && m_col == m_xpr.cols()
95  && "Too few coefficients passed to comma initializer (operator<<)");
96  }
97 
105  inline XprType& finished() { return m_xpr; }
106 
107  XprType& m_xpr; // target expression
108  Index m_row; // current row id
109  Index m_col; // current col id
110  Index m_currentBlockRows; // current block height
111 };
112 
126 template<typename Derived>
128 {
129  return CommaInitializer<Derived>(*static_cast<Derived*>(this), s);
130 }
131 
133 template<typename Derived>
134 template<typename OtherDerived>
137 {
138  return CommaInitializer<Derived>(*static_cast<Derived *>(this), other);
139 }
140 
141 } // end namespace Eigen
142 
143 #endif // EIGEN_COMMAINITIALIZER_H
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:63
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: matrix.hpp:471
CommaInitializer & operator,(const DenseBase< OtherDerived > &other)
Block< Derived > block(Index startRow, Index startCol, Index blockRows, Index blockCols)
Definition: BlockMethods.h:56
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:41
CommaInitializer< Derived > operator<<(const Scalar &s)
Helper class used by the comma initializer operator.
CommaInitializer(XprType &xpr, const Scalar &s)
CommaInitializer & operator,(const Scalar &s)
CommaInitializer(XprType &xpr, const DenseBase< OtherDerived > &other)
#define eigen_assert(x)


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:30