sablib
Loading...
Searching...
No Matches
spdiags.h File Reference

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.

Functions

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).

Detailed Description

Python's SciPy-like spdiags() function.

Author
Izadori

Definition in file spdiags.h.

Function Documentation

◆ 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
dataMatrix containing the elements to be placed on the diagonals as columns.
diagsVector indicating the positions where the elements should be placed (0: diagonal, positive: upper triangular, negative: lower triangular).
mNumber of rows in the resulting sparse matrix (if -1, determined by data).
nNumber 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_argumentThrown 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
dataMatrix containing the elements to be placed on the diagonals as columns.
diagsList indicating the positions where the elements should be placed.
mNumber of rows in the resulting sparse matrix.
nNumber of columns in the resulting sparse matrix.
Returns
A sparse matrix with the elements placed on the specified diagonals.
Exceptions
std::invalid_argumentThrown 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
dataMatrix containing the elements to be placed on the diagonals as columns.
diagsVector indicating the positions where the elements should be placed.
mNumber of rows in the resulting sparse matrix.
nNumber of columns in the resulting sparse matrix.
Returns
A sparse matrix with the elements placed on the specified diagonals.
Exceptions
std::invalid_argumentThrown if the size of diags is larger than the number of rows in data.

Definition at line 77 of file spdiags.h.