Go to the source code of this file.
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| | Matrix (int n) |
| | Constructs a vector or row matrix with size n.
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| | Matrix (const std::vector< double > &v) |
| | Constructs a vector or row matrix from a vector of doubles.
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| Scalar & | operator() (Index i) |
| | Access element at index i (mutable).
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| const Scalar & | operator() (Index i) const |
| | Access element at index i (const).
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| Scalar & | operator[] (Index i) |
| | Access element at index i (mutable) via operator[].
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| const Scalar & | operator[] (Index i) const |
| | Access element at index i (const) via operator[].
|
| template<typename OtherDerived, int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| void | put (Index start_id, const MatrixBase< OtherDerived > &x) |
| | Inserts values from matrix x starting at index start_id.
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| void | resize_save_values (Index n) |
| | Resizes the vector or row matrix to size n, preserving existing values.
|
This file is included in the declaration of Eigen::MatrixBase, thanks to the preprocessor token EIGEN_MATRIX_PLUGIN. See: https://eigen.tuxfamily.org/dox/TopicCustomizing_Plugins.html and the file codac2_matrices.h
- Date
- 2024
- Author
- Simon Rohou
- Copyright
- Copyright 2024 Codac Team
- License: GNU Lesser General Public License (LGPL)
◆ Matrix() [1/2]
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
Constructs a vector or row matrix with size n.
- Precondition
- The matrix is a vector or row vector (
IsVectorOrRow<R,C>).
- Parameters
-
Initializes the matrix to zero if Scalar is not an interval domain.
29{
30 Base::template _init2<int,int>(R == 1 ? 1 : n, C == 1 ? 1 : n);
31 if constexpr(!IsIntervalDomain<Scalar>)
33}
auto & init()
Initializes all elements of the matrix with default intervals.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:113
◆ Matrix() [2/2]
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
| Matrix |
( |
const std::vector< double > & | v | ) |
|
|
explicit |
Constructs a vector or row matrix from a vector of doubles.
- Precondition
- The matrix is a vector or row vector (
IsVectorOrRow<R,C>).
- Parameters
-
| v | Vector of doubles to initialize the matrix. |
46{
47 for(size_t i = 0 ; i < v.size() ; i++)
48 (*this)[i] = v[i];
49}
Matrix()=delete
Deleted default constructor to prevent default instantiation when either the number of rows or column...
◆ operator()() [1/2]
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
| Scalar & operator() |
( |
Index | i | ) |
|
|
inline |
Access element at index i (mutable).
- Precondition
- The matrix is a vector or row vector (
IsVectorOrRow<R,C>).
- Parameters
-
- Returns
- Reference to the element at index
i.
62{
63 return const_cast<Scalar&
>(
const_cast<const Matrix<Scalar,R,C>*
>(
this)->operator()(i));
64}
Matrix(const Matrix< double, R, C > &lb, const Matrix< double, R, C > &ub)
Constructs an interval matrix from lower and upper bound matrices.
Definition codac2_Matrix_addons_IntervalMatrixBase.h:50
◆ operator()() [2/2]
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
| const Scalar & operator() |
( |
Index | i | ) |
const |
|
inline |
Access element at index i (const).
- Precondition
- The matrix is a vector or row vector (
IsVectorOrRow<R,C>).
- Parameters
-
- Returns
- Const reference to the element at index
i.
77{
78 assert_release(i >= 0 && i < this->size());
79 return this->PlainObjectBase<Matrix<Scalar,R,C>>::operator()(i);
80}
◆ operator[]() [1/2]
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
| Scalar & operator[] |
( |
Index | i | ) |
|
|
inline |
Access element at index i (mutable) via operator[].
- Precondition
- The matrix is a vector or row vector (
IsVectorOrRow<R,C>).
- Parameters
-
- Returns
- Reference to the element at index
i.
93{
94 return const_cast<Scalar&
>(
const_cast<const Matrix<Scalar,R,C>*
>(
this)->operator[](i));
95}
◆ operator[]() [2/2]
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
| const Scalar & operator[] |
( |
Index | i | ) |
const |
|
inline |
Access element at index i (const) via operator[].
- Precondition
- The matrix is a vector or row vector (
IsVectorOrRow<R,C>).
- Parameters
-
- Returns
- Const reference to the element at index
i.
108{
109 assert_release(i >= 0 && i < this->size());
110 return this->PlainObjectBase<Matrix<Scalar,R,C>>::operator[](i);
111}
◆ put()
template<typename OtherDerived, int R = RowsAtCompileTime, int C = ColsAtCompileTime>
| void put |
( |
Index | start_id, |
|
|
const MatrixBase< OtherDerived > & | x ) |
|
inline |
Inserts values from matrix x starting at index start_id.
- Precondition
- The matrix and
x are both vectors or row vectors.
- Parameters
-
| start_id | Start index for insertion. |
| x | The matrix whose values will be inserted. |
191{
192 assert_release(start_id >= 0 && start_id < this->size());
193 assert_release(start_id+x.size() <= this->size());
194
195 this->segment(start_id,x.size()) << x;
196}
◆ resize_save_values()
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
| void resize_save_values |
( |
Index | n | ) |
|
|
inline |
Resizes the vector or row matrix to size n, preserving existing values.
- Precondition
- The matrix is a vector or row vector.
- Parameters
-
Eigen's resize() discards existing data, so this function copies existing values before resizing and restores them afterward.
212{
213
214 auto copy = *this;
215 this->resize(n);
216 for(Index i = 0 ; i < std::min((Index)copy.size(),n) ; i++)
217 (*this)[i] = copy[i];
218}