Python's SciPy-like spdiags() function.
More...
#include <algorithm>
#include <initializer_list>
#include <stdexcept>
#include <vector>
#include <Eigen/Eigen>
Go to the source code of this file.
|
| template<typename Derived> |
| Eigen::SparseMatrix< typename Derived::PlainObject::Scalar > | sablib::Spdiags (const Eigen::MatrixBase< Derived > &data, const Eigen::VectorXi &diags, const int m=-1, const int n=-1) |
| | Returns a sparse matrix with the specified elements on its diagonals.
|
| template<typename Derived> |
| Eigen::SparseMatrix< typename Derived::PlainObject::Scalar > | sablib::Spdiags (const Eigen::MatrixBase< Derived > &data, const std::vector< int > &diags, const int m=-1, const int n=-1) |
| | Returns a sparse matrix with the specified elements on its diagonals (std::vector<int> version).
|
| template<typename Derived> |
| Eigen::SparseMatrix< typename Derived::PlainObject::Scalar > | sablib::Spdiags (const Eigen::MatrixBase< Derived > &data, const std::initializer_list< int > &diags, const int m=-1, const int n=-1) |
| | Returns a sparse matrix with the specified elements on its diagonals (std::initializer_list<int> version).
|
Python's SciPy-like spdiags() function.
- Author
- Izadori
Definition in file spdiags.h.
◆ Spdiags() [1/3]
template<typename Derived>
| Eigen::SparseMatrix< typename Derived::PlainObject::Scalar > sablib::Spdiags |
( |
const Eigen::MatrixBase< Derived > & | data, |
|
|
const Eigen::VectorXi & | diags, |
|
|
const int | m = -1, |
|
|
const int | n = -1 ) |
Returns a sparse matrix with the specified elements on its diagonals.
- Parameters
-
| data | Matrix containing the elements to be placed on the diagonals as columns. |
| diags | Vector indicating the positions where the elements should be placed (0: diagonal, positive: upper triangular, negative: lower triangular). |
| m | Number of rows in the resulting sparse matrix (if -1, determined by data). |
| n | Number of columns in the resulting sparse matrix (if -1, determined by data). |
- Returns
- A sparse matrix with the elements placed on the specified diagonals.
- Exceptions
-
| std::invalid_argument | Thrown if the size of diags is larger than the number of rows in data. |
Definition at line 30 of file spdiags.h.
◆ Spdiags() [2/3]
template<typename Derived>
| Eigen::SparseMatrix< typename Derived::PlainObject::Scalar > sablib::Spdiags |
( |
const Eigen::MatrixBase< Derived > & | data, |
|
|
const std::initializer_list< int > & | diags, |
|
|
const int | m = -1, |
|
|
const int | n = -1 ) |
|
inline |
Returns a sparse matrix with the specified elements on its diagonals (std::initializer_list<int> version).
- Parameters
-
| data | Matrix containing the elements to be placed on the diagonals as columns. |
| diags | List indicating the positions where the elements should be placed. |
| m | Number of rows in the resulting sparse matrix. |
| n | Number of columns in the resulting sparse matrix. |
- Returns
- A sparse matrix with the elements placed on the specified diagonals.
- Exceptions
-
| std::invalid_argument | Thrown if the size of diags is larger than the number of rows in data. |
Definition at line 98 of file spdiags.h.
◆ Spdiags() [3/3]
template<typename Derived>
| Eigen::SparseMatrix< typename Derived::PlainObject::Scalar > sablib::Spdiags |
( |
const Eigen::MatrixBase< Derived > & | data, |
|
|
const std::vector< int > & | diags, |
|
|
const int | m = -1, |
|
|
const int | n = -1 ) |
|
inline |
Returns a sparse matrix with the specified elements on its diagonals (std::vector<int> version).
- Parameters
-
| data | Matrix containing the elements to be placed on the diagonals as columns. |
| diags | Vector indicating the positions where the elements should be placed. |
| m | Number of rows in the resulting sparse matrix. |
| n | Number of columns in the resulting sparse matrix. |
- Returns
- A sparse matrix with the elements placed on the specified diagonals.
- Exceptions
-
| std::invalid_argument | Thrown if the size of diags is larger than the number of rows in data. |
Definition at line 77 of file spdiags.h.