codac 2.0.0
Loading...
Searching...
No Matches
codac2_MatrixBase_addons_VectorBase.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
requires IsVectorOrRow<R,C>
auto diag_matrix () const
 Converts a vector into a diagonal matrix.
 
template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
requires IsVectorOrRow<R,C>
auto subvector (Index start_id, Index end_id) const
 Extracts a subvector from the current vector.
 

Detailed Description

This file is included in the declaration of Eigen::MatrixBase, thanks to the preprocessor token EIGEN_MATRIXBASE_PLUGIN. See: https://eigen.tuxfamily.org/dox/TopicCustomizing_Plugins.html and the file codac2_matrices.h


Date
2024
Author
Simon Rohou
License: GNU Lesser General Public License (LGPL)

Function Documentation

◆ diag_matrix()

template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
requires IsVectorOrRow<R,C>
auto diag_matrix ( ) const
inline

Converts a vector into a diagonal matrix.

Creates a square matrix whose diagonal entries are taken from the vector. Off-diagonal entries are set to zero. The matrix returned has size equal to the size of the vector.

Returns
A dense matrix with this vector on its diagonal.
28{
29 return this->asDiagonal().toDenseMatrix();
30}

◆ subvector()

template<int R = RowsAtCompileTime, int C = ColsAtCompileTime>
requires IsVectorOrRow<R,C>
auto subvector ( Index start_id,
Index end_id ) const
inline

Extracts a subvector from the current vector.

Returns a new vector containing elements from index start_id to end_id.

Parameters
start_idThe starting index of the subvector.
end_idThe ending index of the subvector.
Returns
A subvector containing elements in the range [start_id, end_id].
Precondition
0 <= start_id <= end_id < this->size()
46{
47 assert_release(end_id >= 0 && start_id >= 0);
48 assert_release(end_id < this->size() && start_id <= end_id);
49 return this->segment(start_id,end_id-start_id+1);
50}