Go to the source code of this file.
|
|
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| | Matrix ()=delete |
| | Deleted default constructor to prevent default instantiation when either the number of rows or columns is dynamic.
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| | Matrix (int r, int c) |
| | Constructs a matrix with given number of rows and columns.
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| | Matrix (int r, int c, const Scalar values[]) |
| | Constructs a non-vector matrix with given dimensions and initializes it from a raw array of values.
|
| template<int R = RowsAtCompileTime, int C = ColsAtCompileTime> |
| void | resize_save_values (Index r, Index c) |
| | Resizes the matrix to (r,c), preserving existing values where possible.
|
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 2023 Codac Team
- License: GNU Lesser General Public License (LGPL)
◆ Matrix() [1/2]
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
Constructs a matrix with given number of rows and columns.
Initializes the matrix storage with dimensions (r,c). If Scalar is not an interval domain, the matrix is initialized with zeros.
- Parameters
-
| r | Number of rows (runtime). |
| c | Number of columns (runtime). |
36{
37 Base::template _init2<int,int>(r,c);
38 if constexpr(!IsIntervalDomain<Scalar>)
40}
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 |
( |
int | r, |
|
|
int | c, |
|
|
const Scalar | values[] ) |
|
explicit |
Constructs a non-vector matrix with given dimensions and initializes it from a raw array of values.
Copies the values from the values array into the matrix elements. If values is null, initializes all elements to zero.
- Parameters
-
| r | Number of rows (runtime). |
| c | Number of columns (runtime). |
| values | Pointer to array of values used to initialize matrix elements. Can be null, in which case the matrix is zero-initialized. |
- Precondition
- The runtime dimensions
r and c must match the compile-time dimensions R and C if these are fixed (not -1).
-
r and c must be non-negative.
62{
63 assert((R==(int)r || R==-1) && (C==(int)c || C==-1));
64 assert(r >= 0 && c >= 0);
65
66 if(values == 0)
68
69 else
70 {
71 Index k = 0;
72 for(Index i = 0 ; i < this->rows() ; i++)
73 for(Index j = 0 ; j < this->cols() ; j++)
74 (*this)(i,j) = values[k++];
75 assert(k == this->size());
76 }
77}
Matrix()=delete
Deleted default constructor to prevent default instantiation when either the number of rows or column...
◆ resize_save_values()
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
| void resize_save_values |
( |
Index | r, |
|
|
Index | c ) |
|
inline |
Resizes the matrix to (r,c), preserving existing values where possible.
- Parameters
-
| r | New number of rows. |
| c | New number of columns. |
This function resizes the matrix while preserving the data in the overlapping region of the old and new sizes. Unlike Eigen's resize(), which discards old data, this function copies existing values into the resized matrix.
171{
172
173 auto copy = *this;
174 this->resize(r,c);
175 for(Index i = 0 ; i < std::min((Index)copy.rows(),r) ; i++)
176 for(Index j = 0 ; j < std::min((Index)copy.cols(),c) ; j++)
177 (*this)(i,j) = copy(i,j);
178}