General sparsity class. More...
#include <sparsity.hpp>
The storage format is a compressed column storage (CCS) format.
In this format, the structural non-zero elements are stored in column-major order, starting from the upper left corner of the matrix and ending in the lower right corner.
In addition to the dimension (size1(), size2()), (i.e. the number of rows and the number of columns respectively), there are also two vectors of integers:
Note that with this format, it is cheap to loop over all the non-zero elements of a particular column, at constant time per element, but expensive to jump to access a location (i, j).
If the matrix is dense, i.e. length(row) == size1()*size2(), the format reduces to standard dense column major format, which allows access to an arbitrary element in constant time.
Since the object is reference counted (it inherits from SharedObject), several matrices are allowed to share the same sparsity pattern.
The implementations of methods marked as such in this class has been taken from the CSparse package and modified to fit CasADi data structures and separation of sparsity pattern calculation and numerical evaluation. These functions are Copyright(c) Timothy A. Davis, 2006-2009 and licensed as a derivative work under the GNU LGPL
Extra doc: https://github.com/casadi/casadi/wiki/L_b9
Definition at line 103 of file sparsity.hpp.
Public Types | |
typedef SparsityInterface< Sparsity > | B |
Base class. More... | |
using | internal_base_type = SharedObjectInternal |
using | base_type = SharedObject |
Public Member Functions | |
Sparsity (casadi_int dummy=0) | |
Default constructor. More... | |
Sparsity (casadi_int nrow, casadi_int ncol) | |
Pattern with all structural zeros. More... | |
Sparsity (casadi_int nrow, casadi_int ncol, const std::vector< casadi_int > &colind, const std::vector< casadi_int > &row, bool order_rows=false) | |
Construct from sparsity pattern vectors given in compressed column storage format. More... | |
Sparsity (const std::pair< casadi_int, casadi_int > &rc) | |
Create a sparse matrix with all structural zeros. More... | |
Sparsity (casadi_int nrow, casadi_int ncol, const casadi_int *colind, const casadi_int *row, bool order_rows=false) | |
Construct from sparsity pattern vectors given in compressed column storage format. More... | |
SparsityInternal * | get () const |
const std::vector< casadi_int > | permutation_vector (bool invert=false) const |
Construct permutation vector from permutation matrix. More... | |
Sparsity | get_diag (std::vector< casadi_int > &mapping) const |
std::vector< casadi_int > | compress (bool canonical=true) const |
Compress a sparsity pattern. More... | |
const SparsityInternal * | operator-> () const |
Access a member function or object. More... | |
const SparsityInternal & | operator* () const |
Reference to internal structure. More... | |
bool | operator!= (const Sparsity &y) const |
Check if two sparsity patterns are difference. More... | |
bool | is_stacked (const Sparsity &y, casadi_int n) const |
Check if pattern is horizontal repeat of another. More... | |
operator const casadi_int * () const | |
Implicit or explicit type conversion to C representation. More... | |
operator const std::vector< casadi_int > & () const | |
Implicit or explicit type conversion to compact representation. More... | |
operator SparsityStruct () const | |
Implicit or explicit type conversion to C representation. More... | |
Dict | info () const |
void | to_file (const std::string &filename, const std::string &format_hint="") const |
void | serialize (std::ostream &stream) const |
Serialize. More... | |
std::string | serialize () const |
Serialize. More... | |
void | serialize (SerializingStream &s) const |
Serialize an object. More... | |
const casadi_int * | row () const |
Get a reference to row-vector,. More... | |
const casadi_int * | colind () const |
Get a reference to the colindex of all column element (see class description) More... | |
std::vector< casadi_int > | get_row () const |
Get the row for each non-zero entry. More... | |
std::vector< casadi_int > | get_colind () const |
Get the column index for each column. More... | |
casadi_int | colind (casadi_int cc) const |
Get a reference to the colindex of column cc (see class description) More... | |
casadi_int | row (casadi_int el) const |
Get the row of a non-zero element. More... | |
std::vector< casadi_int > | get_col () const |
Get the column for each non-zero entry. More... | |
void | resize (casadi_int nrow, casadi_int ncol) |
Resize. More... | |
casadi_int | add_nz (casadi_int rr, casadi_int cc) |
Get the index of a non-zero element. More... | |
casadi_int | get_nz (casadi_int rr, casadi_int cc) const |
Get the index of an existing non-zero element. More... | |
bool | has_nz (casadi_int rr, casadi_int cc) const |
Returns true if the pattern has a non-zero at location rr, cc. More... | |
std::vector< casadi_int > | get_nz (const std::vector< casadi_int > &rr, const std::vector< casadi_int > &cc) const |
Get a set of non-zero element. More... | |
void | get_nz (std::vector< casadi_int > &indices) const |
Get the nonzero index for a set of elements. More... | |
std::vector< casadi_int > | get_lower () const |
Get nonzeros in lower triangular part. More... | |
std::vector< casadi_int > | get_upper () const |
Get nonzeros in upper triangular part. More... | |
void | get_ccs (std::vector< casadi_int > &colind, std::vector< casadi_int > &row) const |
Get the sparsity in compressed column storage (CCS) format. More... | |
void | get_crs (std::vector< casadi_int > &rowind, std::vector< casadi_int > &col) const |
Get the sparsity in compressed row storage (CRS) format. More... | |
void | get_triplet (std::vector< casadi_int > &row, std::vector< casadi_int > &col) const |
Get the sparsity in sparse triplet format. More... | |
Sparsity | sub (const std::vector< casadi_int > &rr, const std::vector< casadi_int > &cc, std::vector< casadi_int > &mapping, bool ind1=false) const |
Get a submatrix. More... | |
Sparsity | sub (const std::vector< casadi_int > &rr, const Sparsity &sp, std::vector< casadi_int > &mapping, bool ind1=false) const |
Get a set of elements. More... | |
Sparsity | T () const |
Transpose the matrix. More... | |
Sparsity | transpose (std::vector< casadi_int > &mapping, bool invert_mapping=false) const |
Transpose the matrix and get the reordering of the non-zero entries. More... | |
bool | is_transpose (const Sparsity &y) const |
Check if the sparsity is the transpose of another. More... | |
bool | is_reshape (const Sparsity &y) const |
Check if the sparsity is a reshape of another. More... | |
bool | is_subset (const Sparsity &rhs) const |
Is subset? More... | |
Sparsity | sparsity_cast_mod (const Sparsity &X, const Sparsity &Y) const |
Propagates subset according to sparsity cast. More... | |
Sparsity | pattern_inverse () const |
Take the inverse of a sparsity pattern; flip zeros and non-zeros. More... | |
template<typename DataType > | |
void | set (DataType *data, const DataType *val_data, const Sparsity &val_sp) const |
template<typename DataType > | |
void | add (DataType *data, const DataType *val_data, const Sparsity &val_sp) const |
template<typename DataType > | |
void | bor (DataType *data, const DataType *val_data, const Sparsity &val_sp) const |
std::string | class_name () const |
Get class name. More... | |
void | disp (std::ostream &stream, bool more=false) const |
Print a description of the object. More... | |
std::string | get_str (bool more=false) const |
Get string representation. More... | |
void | print_ptr (std::ostream &stream=casadi::uout()) const |
void | own (SharedObjectInternal *node) |
void | assign (SharedObjectInternal *node) |
Assign the node to a node class pointer without reference counting. More... | |
casadi_int | getCount () const |
Get the reference count. More... | |
void | swap (GenericShared &other) |
Swap content with another instance. More... | |
std::string | debug_repr () const |
bool | is_null () const |
Is a null pointer? More... | |
casadi_int | __hash__ () const |
Returns a number that is unique for a given Node. More... | |
GenericWeakRef< SharedObject, SharedObjectInternal > * | weak () |
Get a weak reference to the object. More... | |
Check if two sparsity patterns are identical | |
bool | is_equal (const Sparsity &y) const |
bool | is_equal (casadi_int nrow, casadi_int ncol, const std::vector< casadi_int > &colind, const std::vector< casadi_int > &row) const |
bool | is_equal (casadi_int nrow, casadi_int ncol, const casadi_int *colind, const casadi_int *row) const |
bool | operator== (const Sparsity &y) const |
Size and element counting | |
casadi_int | size1 () const |
Get the number of rows. More... | |
casadi_int | rows () const |
Get the number of rows, Octave-style syntax. More... | |
casadi_int | size2 () const |
Get the number of columns. More... | |
casadi_int | columns () const |
Get the number of columns, Octave-style syntax. More... | |
casadi_int | numel () const |
The total number of elements, including structural zeros, i.e. size2()*size1() More... | |
double | density () const |
The percentage of nonzero. More... | |
bool | is_empty (bool both=false) const |
Check if the sparsity is empty. More... | |
casadi_int | nnz () const |
Get the number of (structural) non-zeros. More... | |
casadi_int | nnz_upper (bool strictly=false) const |
Number of non-zeros in the upper triangular half,. More... | |
casadi_int | nnz_lower (bool strictly=false) const |
Number of non-zeros in the lower triangular half,. More... | |
casadi_int | nnz_diag () const |
Number of non-zeros on the diagonal, i.e. the number of elements (i, j) with j==i. More... | |
casadi_int | bw_upper () const |
Upper half-bandwidth. More... | |
casadi_int | bw_lower () const |
Lower half-bandwidth. More... | |
std::pair< casadi_int, casadi_int > | size () const |
Get the shape. More... | |
casadi_int | size (casadi_int axis) const |
Get the size along a particular dimensions. More... | |
Sparsity | combine (const Sparsity &y, bool f0x_is_zero, bool function0_is_zero, std::vector< unsigned char > &mapping) const |
Combine two sparsity patterns. More... | |
Sparsity | combine (const Sparsity &y, bool f0x_is_zero, bool function0_is_zero) const |
Combine two sparsity patterns. More... | |
Sparsity | unite (const Sparsity &y, std::vector< unsigned char > &mapping) const |
Union of two sparsity patterns. More... | |
Sparsity | unite (const Sparsity &y) const |
Union of two sparsity patterns. More... | |
Sparsity | operator+ (const Sparsity &b) const |
Union of two sparsity patterns. More... | |
Sparsity | intersect (const Sparsity &y, std::vector< unsigned char > &mapping) const |
Intersection of two sparsity patterns. More... | |
Sparsity | intersect (const Sparsity &y) const |
Intersection of two sparsity patterns. More... | |
Sparsity | operator* (const Sparsity &b) const |
Intersection of two sparsity patterns. More... | |
Static Public Member Functions | |
static Sparsity | create (SparsityInternal *node) |
Create from node. More... | |
static Sparsity | upper (casadi_int n) |
Create a upper triangular square sparsity pattern *. More... | |
static Sparsity | lower (casadi_int n) |
Create a lower triangular square sparsity pattern *. More... | |
static Sparsity | band (casadi_int n, casadi_int p) |
Create a single band in a square sparsity pattern. More... | |
static Sparsity | banded (casadi_int n, casadi_int p) |
Create banded square sparsity pattern. More... | |
static Sparsity | rowcol (const std::vector< casadi_int > &row, const std::vector< casadi_int > &col, casadi_int nrow, casadi_int ncol) |
Construct a block sparsity pattern from (row, col) vectors. More... | |
static Sparsity | nonzeros (casadi_int nrow, casadi_int ncol, const std::vector< casadi_int > &nz, bool ind1=SWIG_IND1) |
Create a sparsity from nonzeros. More... | |
static Sparsity | permutation (const std::vector< casadi_int > &p, bool invert=false) |
Construct a permutation matrix P from a permutation vector p. More... | |
static Sparsity | from_file (const std::string &filename, const std::string &format_hint="") |
static Sparsity | deserialize (std::istream &stream) |
Build Sparsity from serialization. More... | |
static Sparsity | deserialize (const std::string &s) |
Build Sparsity from serialization. More... | |
static Sparsity | deserialize (DeserializingStream &s) |
Deserialize. More... | |
static void | mul_sparsityF (const bvec_t *x, const Sparsity &x_sp, const bvec_t *y, const Sparsity &y_sp, bvec_t *z, const Sparsity &z_sp, bvec_t *w) |
Propagate sparsity using 0-1 logic through a matrix product,. More... | |
static void | mul_sparsityR (bvec_t *x, const Sparsity &x_sp, bvec_t *y, const Sparsity &y_sp, bvec_t *z, const Sparsity &z_sp, bvec_t *w) |
Propagate sparsity using 0-1 logic through a matrix product,. More... | |
static Sparsity | scalar (bool dense_scalar=true) |
Create a scalar sparsity pattern *. More... | |
static Sparsity | dense (casadi_int nrow, casadi_int ncol=1) |
Create a dense rectangular sparsity pattern *. More... | |
static Sparsity | dense (const std::pair< casadi_int, casadi_int > &rc) |
Create a dense rectangular sparsity pattern *. More... | |
static Sparsity | unit (casadi_int n, casadi_int el) |
Create the sparsity pattern for a unit vector of length n and a nonzero on. More... | |
static Sparsity | diag (casadi_int nrow) |
Create diagonal sparsity pattern *. More... | |
static Sparsity | diag (casadi_int nrow, casadi_int ncol) |
Create diagonal sparsity pattern *. More... | |
static Sparsity | diag (const std::pair< casadi_int, casadi_int > &rc) |
Create diagonal sparsity pattern *. More... | |
static Sparsity | triplet (casadi_int nrow, casadi_int ncol, const std::vector< casadi_int > &row, const std::vector< casadi_int > &col, std::vector< casadi_int > &mapping, bool invert_mapping) |
Create a sparsity pattern given the nonzeros in sparse triplet form *. More... | |
static Sparsity | triplet (casadi_int nrow, casadi_int ncol, const std::vector< casadi_int > &row, const std::vector< casadi_int > &col) |
Create a sparsity pattern given the nonzeros in sparse triplet form *. More... | |
static Sparsity | compressed (const std::vector< casadi_int > &v, bool order_rows=false) |
static Sparsity | compressed (const casadi_int *v, bool order_rows=false) |
Protected Member Functions | |
void | count_up () |
void | count_down () |
Static Private Member Functions | |
static std::vector< Sparsity > | diagsplit (const Sparsity &x, const std::vector< casadi_int > &output_offset) |
static std::vector< Sparsity > | diagsplit (const Sparsity &x, casadi_int incr) |
static std::vector< Sparsity > | diagsplit (const Sparsity &x, casadi_int incr1, casadi_int incr2) |
static Sparsity | mtimes (const std::vector< Sparsity > &args) |
static std::vector< Sparsity > | horzsplit (const Sparsity &x, casadi_int incr) |
static std::vector< Sparsity > | vertsplit (const Sparsity &x, casadi_int incr) |
typedef std::unordered_multimap< std::size_t, WeakRef > | CachingMap |
Enlarge matrix. More... | |
static std::set< std::string > | file_formats = {"mtx"} |
Enlarge matrix. More... | |
void | enlarge (casadi_int nrow, casadi_int ncol, const std::vector< casadi_int > &rr, const std::vector< casadi_int > &cc, bool ind1=false) |
Enlarge matrix. More... | |
void | enlargeRows (casadi_int nrow, const std::vector< casadi_int > &rr, bool ind1=false) |
Enlarge the matrix along the first dimension (i.e. insert rows) More... | |
void | enlargeColumns (casadi_int ncol, const std::vector< casadi_int > &cc, bool ind1=false) |
Enlarge the matrix along the second dimension (i.e. insert columns) More... | |
Sparsity | makeDense (std::vector< casadi_int > &mapping) const |
Make a patten dense. More... | |
std::vector< casadi_int > | erase (const std::vector< casadi_int > &rr, const std::vector< casadi_int > &cc, bool ind1=false) |
Erase rows and/or columns of a matrix. More... | |
std::vector< casadi_int > | erase (const std::vector< casadi_int > &rr, bool ind1=false) |
Erase elements of a matrix. More... | |
void | append (const Sparsity &sp) |
Append another sparsity patten vertically (NOTE: only efficient if vector) More... | |
void | appendColumns (const Sparsity &sp) |
Append another sparsity patten horizontally. More... | |
bool | is_scalar (bool scalar_and_dense=false) const |
Is scalar? More... | |
bool | is_dense () const |
Is dense? More... | |
bool | is_row () const |
Check if the pattern is a row vector (i.e. size1()==1) More... | |
bool | is_column () const |
Check if the pattern is a column vector (i.e. size2()==1) More... | |
bool | is_vector () const |
Check if the pattern is a row or column vector. More... | |
bool | is_diag () const |
Is diagonal? More... | |
bool | is_square () const |
Is square? More... | |
bool | is_symmetric () const |
Is symmetric? More... | |
bool | is_triu (bool strictly=false) const |
Is upper triangular? More... | |
bool | is_tril (bool strictly=false) const |
Is lower triangular? More... | |
bool | is_singular () const |
Check whether the sparsity-pattern indicates structural singularity. More... | |
bool | is_permutation () const |
Is this a permutation matrix? More... | |
bool | is_selection (bool allow_empty=false) const |
Is this a selection matrix? More... | |
bool | is_orthonormal (bool allow_empty=false) const |
Are both rows and columns orthonormal ? More... | |
bool | is_orthonormal_rows (bool allow_empty=false) const |
Are the rows of the pattern orthonormal ? More... | |
bool | is_orthonormal_columns (bool allow_empty=false) const |
Are the columns of the pattern orthonormal ? More... | |
bool | rowsSequential (bool strictly=true) const |
Do the rows appear sequentially on each column. More... | |
void | removeDuplicates (std::vector< casadi_int > &mapping) |
Remove duplicate entries. More... | |
std::vector< casadi_int > | etree (bool ata=false) const |
Calculate the elimination tree. More... | |
Sparsity | ldl (std::vector< casadi_int > &p, bool amd=true) const |
Symbolic LDL factorization. More... | |
void | qr_sparse (Sparsity &V, Sparsity &R, std::vector< casadi_int > &prinv, std::vector< casadi_int > &pc, bool amd=true) const |
Symbolic QR factorization. More... | |
casadi_int | dfs (casadi_int j, casadi_int top, std::vector< casadi_int > &xi, std::vector< casadi_int > &pstack, const std::vector< casadi_int > &pinv, std::vector< bool > &marked) const |
Depth-first search on the adjacency graph of the sparsity. More... | |
casadi_int | scc (std::vector< casadi_int > &index, std::vector< casadi_int > &offset) const |
Find the strongly connected components of the bigraph defined by the sparsity pattern. More... | |
casadi_int | btf (std::vector< casadi_int > &rowperm, std::vector< casadi_int > &colperm, std::vector< casadi_int > &rowblock, std::vector< casadi_int > &colblock, std::vector< casadi_int > &coarse_rowblock, std::vector< casadi_int > &coarse_colblock) const |
Calculate the block triangular form (BTF) More... | |
std::vector< casadi_int > | amd () const |
Approximate minimal degree preordering. More... | |
void | spsolve (bvec_t *X, bvec_t *B, bool tr) const |
Propagate sparsity through a linear solve. More... | |
std::vector< casadi_int > | find (bool ind1=SWIG_IND1) const |
Get the location of all non-zero elements as they would appear in a Dense matrix. More... | |
void | find (std::vector< casadi_int > &loc, bool ind1=false) const |
Get the location of all nonzero elements (inplace version) More... | |
Sparsity | uni_coloring (const Sparsity &AT=Sparsity(), casadi_int cutoff=std::numeric_limits< casadi_int >::max()) const |
Perform a unidirectional coloring: A greedy distance-2 coloring algorithm. More... | |
Sparsity | star_coloring (casadi_int ordering=1, casadi_int cutoff=std::numeric_limits< casadi_int >::max()) const |
Perform a star coloring of a symmetric matrix: More... | |
Sparsity | star_coloring2 (casadi_int ordering=1, casadi_int cutoff=std::numeric_limits< casadi_int >::max()) const |
Perform a star coloring of a symmetric matrix: More... | |
std::vector< casadi_int > | largest_first () const |
Order the columns by decreasing degree. More... | |
Sparsity | pmult (const std::vector< casadi_int > &p, bool permute_rows=true, bool permute_columns=true, bool invert_permutation=false) const |
Permute rows and/or columns. More... | |
std::string | dim (bool with_nz=false) const |
Get the dimension as a string. More... | |
std::string | postfix_dim () const |
Dimension string as a postfix to a name. More... | |
std::string | repr_el (casadi_int k) const |
Describe the nonzero location k as a string. More... | |
void | spy (std::ostream &stream=casadi::uout()) const |
Print a textual representation of sparsity. More... | |
void | spy_matlab (const std::string &mfile) const |
Generate a script for Matlab or Octave which visualizes. More... | |
void | export_code (const std::string &lang, std::ostream &stream=casadi::uout(), const Dict &options=Dict()) const |
Export matrix in specific language. More... | |
std::size_t | hash () const |
Enlarge matrix. More... | |
template<typename T > | |
void | set (T *data, const T *val_data, const Sparsity &val_sp) const |
Assign the nonzero entries of one sparsity pattern to the nonzero. More... | |
template<typename T > | |
void | add (T *data, const T *val_data, const Sparsity &val_sp) const |
Add the nonzero entries of one sparsity pattern to the nonzero entries. More... | |
template<typename T > | |
void | bor (T *data, const T *val_data, const Sparsity &val_sp) const |
Bitwise or of the nonzero entries of one sparsity pattern and the nonzero. More... | |
static Sparsity | horzcat (const std::vector< Sparsity > &sp) |
Accessed by SparsityInterface. More... | |
static Sparsity | vertcat (const std::vector< Sparsity > &sp) |
Enlarge matrix. More... | |
static Sparsity | blockcat (const std::vector< std::vector< Sparsity > > &v) |
Enlarge matrix. More... | |
static Sparsity | diagcat (const std::vector< Sparsity > &v) |
Enlarge matrix. More... | |
static std::vector< Sparsity > | horzsplit (const Sparsity &x, const std::vector< casadi_int > &offset) |
Enlarge matrix. More... | |
static std::vector< Sparsity > | vertsplit (const Sparsity &x, const std::vector< casadi_int > &offset) |
Enlarge matrix. More... | |
static std::vector< Sparsity > | diagsplit (const Sparsity &x, const std::vector< casadi_int > &offset1, const std::vector< casadi_int > &offset2) |
Enlarge matrix. More... | |
static Sparsity | mtimes (const Sparsity &x, const Sparsity &y) |
Enlarge matrix. More... | |
static Sparsity | mac (const Sparsity &x, const Sparsity &y, const Sparsity &z) |
Enlarge matrix. More... | |
static Sparsity | reshape (const Sparsity &x, casadi_int nrow, casadi_int ncol) |
Enlarge matrix. More... | |
static Sparsity | reshape (const Sparsity &x, const Sparsity &sp) |
Enlarge matrix. More... | |
static Sparsity | sparsity_cast (const Sparsity &x, const Sparsity &sp) |
Enlarge matrix. More... | |
static casadi_int | sprank (const Sparsity &x) |
Enlarge matrix. More... | |
static casadi_int | norm_0_mul (const Sparsity &x, const Sparsity &A) |
Enlarge matrix. More... | |
static Sparsity | kron (const Sparsity &a, const Sparsity &b) |
Enlarge matrix. More... | |
static Sparsity | triu (const Sparsity &x, bool includeDiagonal=true) |
Enlarge matrix. More... | |
static Sparsity | tril (const Sparsity &x, bool includeDiagonal=true) |
Enlarge matrix. More... | |
static Sparsity | sum2 (const Sparsity &x) |
Enlarge matrix. More... | |
static Sparsity | sum1 (const Sparsity &x) |
Enlarge matrix. More... | |
static CachingMap & | getCache () |
Cached sparsity patterns. More... | |
static const Sparsity & | getScalar () |
(Dense) scalar More... | |
static const Sparsity & | getScalarSparse () |
(Sparse) scalar More... | |
static const Sparsity & | getEmpty () |
Empty zero-by-zero. More... | |
static std::string | type_name () |
Readable name of the public class. More... | |
static bool | test_cast (const SharedObjectInternal *ptr) |
Check if a particular cast is allowed. More... | |
static Sparsity | kkt (const Sparsity &H, const Sparsity &J, bool with_x_diag=true, bool with_lam_g_diag=true) |
Get KKT system sparsity. More... | |
static std::string | file_format (const std::string &filename, const std::string &format_hint, const std::set< std::string > &file_formats) |
Enlarge matrix. More... | |
typedef SparsityInterface<Sparsity> casadi::Sparsity::B |
Definition at line 138 of file sparsity.hpp.
|
inherited |
Definition at line 103 of file shared_object.hpp.
typedef std::unordered_multimap<std::size_t, WeakRef> casadi::Sparsity::CachingMap |
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 881 of file sparsity.hpp.
|
inherited |
Definition at line 102 of file shared_object.hpp.
|
explicit |
Definition at line 68 of file sparsity.cpp.
Referenced by band(), banded(), compressed(), dense(), deserialize(), diag(), diagcat(), enlargeColumns(), enlargeRows(), horzcat(), horzsplit(), kkt(), kron(), ldl(), lower(), permutation(), triplet(), unit(), upper(), and vertcat().
casadi::Sparsity::Sparsity | ( | casadi_int | nrow, |
casadi_int | ncol | ||
) |
Extra doc: https://github.com/casadi/casadi/wiki/L_ba
Definition at line 78 of file sparsity.cpp.
casadi::Sparsity::Sparsity | ( | casadi_int | nrow, |
casadi_int | ncol, | ||
const std::vector< casadi_int > & | colind, | ||
const std::vector< casadi_int > & | row, | ||
bool | order_rows = false |
||
) |
|
explicit |
casadi::Sparsity::Sparsity | ( | casadi_int | nrow, |
casadi_int | ncol, | ||
const casadi_int * | colind, | ||
const casadi_int * | row, | ||
bool | order_rows = false |
||
) |
Definition at line 99 of file sparsity.cpp.
|
inherited |
If the Object does not point to any node, "0" is returned.
Extra doc: https://github.com/casadi/casadi/wiki/L_av
Definition at line 124 of file generic_shared_impl.hpp.
void casadi::Sparsity::add | ( | DataType * | data, |
const DataType * | val_data, | ||
const Sparsity & | val_sp | ||
) | const |
Definition at line 1339 of file sparsity.hpp.
References colind(), dim(), is_empty(), nnz(), row(), size1(), and size2().
void casadi::Sparsity::add | ( | T * | data, |
const T * | val_data, | ||
const Sparsity & | val_sp | ||
) | const |
of another sparsity pattern
Extra doc: https://github.com/casadi/casadi/wiki/L_dm
casadi_int casadi::Sparsity::add_nz | ( | casadi_int | rr, |
casadi_int | cc | ||
) |
Add the element if it does not exist and copy object if it's not unique
Extra doc: https://github.com/casadi/casadi/wiki/L_ce
Definition at line 194 of file sparsity.cpp.
References colind(), get_colind(), get_row(), is_dense(), nnz(), row(), size1(), and size2().
std::vector< casadi_int > casadi::Sparsity::amd | ( | ) | const |
Fill-reducing ordering applied to the sparsity pattern of a linear system prior to factorization. The system must be symmetric, for an unsymmetric matrix A, first form the square of the pattern, A'*A.
The implementation is a modified version of cs_amd in CSparse Copyright(c) Timothy A. Davis, 2006-2009 Licensed as a derivative work under the GNU LGPL
Extra doc: https://github.com/casadi/casadi/wiki/L_d8
Definition at line 707 of file sparsity.cpp.
Referenced by casadi::LinsolLdl::init(), ldl(), and qr_sparse().
void casadi::Sparsity::append | ( | const Sparsity & | sp | ) |
Definition at line 470 of file sparsity.cpp.
References casadi::SparsityInternal::_appendVector(), dim(), is_column(), size1(), size2(), and vertcat().
void casadi::Sparsity::appendColumns | ( | const Sparsity & | sp | ) |
Definition at line 499 of file sparsity.cpp.
References casadi::SparsityInternal::_appendColumns(), dim(), size1(), and size2().
Referenced by casadi::Sqpmethod::init().
|
inherited |
improper use will cause memory leaks!
Extra doc: https://github.com/casadi/casadi/wiki/L_at
Definition at line 97 of file generic_shared_impl.hpp.
|
static |
band(n, 0) is equivalent to diag(n)
band(n, -1) has a band below the diagonal
p | indicate |
Extra doc: https://github.com/casadi/casadi/wiki/L_bj
Definition at line 1070 of file sparsity.cpp.
References colind(), casadi::SparsityInterface< Sparsity >::offset(), row(), and Sparsity().
Referenced by banded(), casadi::BSplineCommon::derivative_coeff(), and casadi::SlicotDple::init_mem().
|
static |
banded(n, 0) is equivalent to diag(n)
banded(n, 1) is tri-diagonal matrix
Extra doc: https://github.com/casadi/casadi/wiki/L_bk
Definition at line 1095 of file sparsity.cpp.
References band(), and Sparsity().
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1605 of file sparsity.cpp.
References horzcat(), and vertcat().
Referenced by kkt().
void casadi::Sparsity::bor | ( | DataType * | data, |
const DataType * | val_data, | ||
const Sparsity & | val_sp | ||
) | const |
Definition at line 1419 of file sparsity.hpp.
References colind(), dim(), is_empty(), nnz(), row(), size1(), and size2().
void casadi::Sparsity::bor | ( | T * | data, |
const T * | val_data, | ||
const Sparsity & | val_sp | ||
) | const |
entries of another sparsity pattern
Extra doc: https://github.com/casadi/casadi/wiki/L_dn
Referenced by casadi::Project::sp_reverse().
casadi_int casadi::Sparsity::btf | ( | std::vector< casadi_int > & | rowperm, |
std::vector< casadi_int > & | colperm, | ||
std::vector< casadi_int > & | rowblock, | ||
std::vector< casadi_int > & | colblock, | ||
std::vector< casadi_int > & | coarse_rowblock, | ||
std::vector< casadi_int > & | coarse_colblock | ||
) | const |
See Direct Methods for Sparse Linear Systems by Davis (2006).
The function computes the Dulmage-Mendelsohn decomposition, which allows you to reorder the rows and columns of a matrix to bring it into block triangular form (BTF).
It will not consider the distance of off-diagonal elements to the diagonal: there is no guarantee you will get a block-diagonal matrix if you supply a randomly permuted block-diagonal matrix.
If your matrix is symmetrical, this method is of limited use; permutation can make it non-symmetric.
The implementation is a modified version of cs_dmperm in CSparse Copyright(c) Timothy A. Davis, 2006-2009 Licensed as a derivative work under the GNU LGPL
Extra doc: https://github.com/casadi/casadi/wiki/L_d7
Definition at line 711 of file sparsity.cpp.
Referenced by casadi::SymbolicQr::init(), and sprank().
casadi_int casadi::Sparsity::bw_lower | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_by
Definition at line 1388 of file sparsity.cpp.
casadi_int casadi::Sparsity::bw_upper | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_bx
Definition at line 1384 of file sparsity.cpp.
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_au
Definition at line 31 of file shared_object.cpp.
Referenced by casadi::FmuFunction::check_mem_count(), casadi::MXFunction::export_code_body(), and casadi::BlazingSplineFunction::merge().
const casadi_int * casadi::Sparsity::colind | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_c8
Definition at line 168 of file sparsity.cpp.
Referenced by casadi::SparsityInternal::_mtimes(), add(), add_nz(), band(), casadi::SparsityInternal::bfs(), casadi::KinsolInterface::bjac(), bor(), casadi::Blocksqp::calcHessianUpdateExact(), casadi::Blocksqp::calcLagrangeGradient(), casadi::casadi_func_cons_jac(), casadi::FmuFunction::check_hessian(), casadi::GenericMatrix< MatType >::colind(), colind(), casadi::SparsityInternal::combineGen(), compressed(), casadi::construct_nlpsol(), casadi::IndexReduction::dae_struct_detect(), dense(), casadi::detect_simple_bounds_gen(), diag(), diagcat(), casadi::KinsolInterface::djac(), casadi::Transpose::eval_gen(), casadi::BonminUserClass::eval_h(), casadi::IpoptUserClass::eval_h(), casadi::AlpaqaProblem::eval_hess_L(), casadi::AlpaqaProblem::eval_hess_ψ(), casadi::AlpaqaProblem::eval_jac_g(), casadi::BonminUserClass::eval_jac_g(), casadi::IpoptUserClass::eval_jac_g(), casadi::FmuFunction::eval_task(), get_ccs(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_jac_sparsity_hierarchical_symm(), casadi::FunctionInternal::get_sparsity_out(), horzsplit(), casadi::SqicInterface::init(), casadi::Dple::init(), casadi::AmplInterface::init(), casadi::Blocksqp::init(), casadi::BonminInterface::init(), casadi::FatropConicInterface::init(), casadi::HpipmInterface::init(), casadi::HpmpcInterface::init(), casadi::SlicotDple::init(), casadi::SuperscsInterface::init(), casadi::ClarabelInterface::init_dependent(), casadi::HighsInterface::init_dependent(), casadi::CplexInterface::init_mem(), is_equal(), casadi::SparsityInternal::is_equal(), casadi::SparsityInternal::is_stacked(), casadi::XFunction< DerivedType, MatType, NodeType >::jac(), kron(), lower(), casadi::FmuFunction::make_symmetric(), mul_sparsityF(), mul_sparsityR(), casadi::SparsityInternal::multiply(), norm_0_mul(), permutation(), casadi::Matrix< Scalar >::print_dense(), casadi::Matrix< Scalar >::print_sparse(), casadi::CvodesInterface::psetupF(), casadi::IdasInterface::psetupF(), casadi::FmuFunction::remove_nans(), casadi::Conic::sdp_to_socp_init(), set(), casadi::WorhpInterface::set_work(), casadi::CbcInterface::solve(), casadi::ClpInterface::solve(), casadi::CplexInterface::solve(), casadi::GurobiInterface::solve(), casadi::OoqpInterface::solve(), casadi::OsqpInterface::solve(), casadi::QpoasesInterface::solve(), casadi::SuperscsInterface::solve(), casadi::WorhpInterface::solve(), casadi::Blocksqp::solveQP(), casadi::Rank1::sp_forward(), casadi::Solve< Tr >::sp_forward(), casadi::Transpose::sp_forward(), casadi::FunctionInternal::sp_forward_block(), casadi::Rank1::sp_reverse(), casadi::Solve< Tr >::sp_reverse(), casadi::Transpose::sp_reverse(), casadi::FunctionInternal::sp_reverse(), Sparsity(), casadi::SparsityInternal::uni_coloring(), unit(), casadi::DaeBuilderInternal::update_dependencies(), upper(), and casadi::SnoptInterface::userfun().
casadi_int casadi::Sparsity::colind | ( | casadi_int | cc | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_cb
Definition at line 180 of file sparsity.cpp.
References colind(), size2(), and casadi::str().
|
inline |
Definition at line 340 of file sparsity.hpp.
Sparsity casadi::Sparsity::combine | ( | const Sparsity & | y, |
bool | f0x_is_zero, | ||
bool | function0_is_zero | ||
) | const |
Returns the new sparsity pattern as well as a mapping with the same length as the number of non-zero elements The mapping matrix contains the arguments for each nonzero, the first bit indicates if the first argument is nonzero, the second bit indicates if the second argument is nonzero (note that none of, one of or both of the arguments can be nonzero)
Extra doc: https://github.com/casadi/casadi/wiki/L_cl
Definition at line 404 of file sparsity.cpp.
References casadi::SparsityInternal::combine().
Sparsity casadi::Sparsity::combine | ( | const Sparsity & | y, |
bool | f0x_is_zero, | ||
bool | function0_is_zero, | ||
std::vector< unsigned char > & | mapping | ||
) | const |
Returns the new sparsity pattern as well as a mapping with the same length as the number of non-zero elements The mapping matrix contains the arguments for each nonzero, the first bit indicates if the first argument is nonzero, the second bit indicates if the second argument is nonzero (note that none of, one of or both of the arguments can be nonzero)
Extra doc: https://github.com/casadi/casadi/wiki/L_cl
Definition at line 398 of file sparsity.cpp.
References casadi::SparsityInternal::combine().
Referenced by casadi::MXNode::get_binary().
std::vector< casadi_int > casadi::Sparsity::compress | ( | bool | canonical = true | ) | const |
Definition at line 1305 of file sparsity.cpp.
References is_dense(), size1(), and size2().
Referenced by casadi::CodeGenerator::add_sparsity(), and serialize().
|
static |
Create from a single vector containing the pattern in compressed column storage format: The format: The first two entries are the number of rows (nrow) and columns (ncol) The next ncol+1 entries are the column offsets (colind). Note that the last element, colind[ncol], gives the number of nonzeros The last colind[ncol] entries are the row indices
Definition at line 1340 of file sparsity.cpp.
References colind(), dense(), nnz(), row(), and Sparsity().
|
static |
Create from a single vector containing the pattern in compressed column storage format: The format: The first two entries are the number of rows (nrow) and columns (ncol) The next ncol+1 entries are the column offsets (colind). Note that the last element, colind[ncol], gives the number of nonzeros The last colind[ncol] entries are the row indices
Definition at line 1325 of file sparsity.cpp.
References dense(), nnz(), and size().
Referenced by deserialize(), casadi::GenericExternal::get_jac_sparsity(), casadi::GenericExternal::get_sparsity_in(), casadi::GenericExternal::get_sparsity_out(), and qr_sparse().
|
protectedinherited |
Definition at line 134 of file generic_shared_impl.hpp.
|
protectedinherited |
Definition at line 133 of file generic_shared_impl.hpp.
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_bc
Definition at line 72 of file sparsity.cpp.
References casadi::GenericShared< Shared, Internal >::own().
|
inherited |
Definition at line 113 of file generic_shared_impl.hpp.
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_be
Definition at line 1012 of file sparsity.cpp.
References colind(), row(), and Sparsity().
Referenced by casadi::Constant< Value >::_get_binary(), casadi::SparsityInternal::_mtimes(), casadi::DaeBuilder::add_variable(), casadi::DaeBuilder::add_variable_new(), casadi::BSpline::BSpline(), casadi::BSplineParametric::BSplineParametric(), compressed(), casadi::GetNonzerosParam::create(), casadi::Matrix< Scalar >::densify(), casadi::MX::densify(), casadi::Determinant::Determinant(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_jac_sparsity_hierarchical_symm(), casadi::MXNode::get_mac(), casadi::Nlpsol::get_reverse(), casadi::BlazingSplineFunction::get_sparsity_in(), casadi::Expm::get_sparsity_in(), casadi::FmuFunction::get_sparsity_in(), casadi::Integrator::get_sparsity_in(), casadi::Interpolant::get_sparsity_in(), casadi::BlazingSplineFunction::get_sparsity_out(), casadi::Conic::get_sparsity_out(), casadi::FmuFunction::get_sparsity_out(), casadi::Integrator::get_sparsity_out(), casadi::Interpolant::get_sparsity_out(), casadi::Nlpsol::get_sparsity_out(), casadi::MX::inf(), casadi::SqicInterface::init(), casadi::Dple::init(), casadi::Blocksqp::init(), casadi::HpipmInterface::init(), casadi::HpmpcInterface::init(), casadi::Feasiblesqpmethod::init(), casadi::Qrsqp::init(), casadi::Sqpmethod::init(), casadi::SlicotDple::init_mem(), casadi::Inverse::Inverse(), casadi::FunctionInternal::jac_sparsity(), kron(), casadi::LogSumExp::LogSumExp(), casadi::SparsityInternal::makeDense(), casadi::MX::MX(), casadi::MX::nan(), casadi::GenericMatrix< MatType >::ones(), casadi::SparsityInternal::pattern_inverse(), casadi::Convexify::setup(), casadi::MX::solve(), Sparsity(), sum1(), sum2(), casadi::GenericMatrix< MatType >::sym(), casadi::SymbolicMX::SymbolicMX(), and casadi::GenericMatrix< MatType >::zeros().
|
inlinestatic |
Extra doc: https://github.com/casadi/casadi/wiki/L_be
Definition at line 162 of file sparsity.hpp.
double casadi::Sparsity::density | ( | ) | const |
Equivalent to (100.0 * nnz())/numel(), but avoids overflow
Extra doc: https://github.com/casadi/casadi/wiki/L_br
Definition at line 136 of file sparsity.cpp.
References nnz(), size1(), and size2().
Referenced by casadi::FunctionInternal::get_jac_sparsity_gen(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), and casadi::FunctionInternal::get_jac_sparsity_hierarchical_symm().
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_c4
Definition at line 2012 of file sparsity.cpp.
References deserialize().
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_c6
Definition at line 1996 of file sparsity.cpp.
References compressed(), Sparsity(), and casadi::DeserializingStream::unpack().
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_c3
Definition at line 1983 of file sparsity.cpp.
Referenced by deserialize().
casadi_int casadi::Sparsity::dfs | ( | casadi_int | j, |
casadi_int | top, | ||
std::vector< casadi_int > & | xi, | ||
std::vector< casadi_int > & | pstack, | ||
const std::vector< casadi_int > & | pinv, | ||
std::vector< bool > & | marked | ||
) | const |
See Direct Methods for Sparse Linear Systems by Davis (2006).
Extra doc: https://github.com/casadi/casadi/wiki/L_d5
Definition at line 696 of file sparsity.cpp.
Referenced by casadi::SparsityInternal::scc().
|
inlinestatic |
Extra doc: https://github.com/casadi/casadi/wiki/L_bi
Definition at line 190 of file sparsity.hpp.
References diag().
Referenced by casadi::SolveUnity< Tr >::A_sp(), casadi::OsqpInterface::codegen_init_mem(), casadi::BSplineCommon::derivative_coeff(), diag(), casadi::Factory< MatType >::get_output(), casadi::Blocksqp::init(), casadi::SundialsInterface::init(), casadi::SuperscsInterface::init(), casadi::Sqpmethod::init(), casadi::OsqpInterface::init_mem(), casadi::SlicotDple::init_mem(), kkt(), casadi::Convexify::setup(), casadi::Integrator::sp_jac_dae(), and casadi::Integrator::sp_jac_rdae().
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_bi
Definition at line 568 of file sparsity.cpp.
References colind(), casadi::range(), row(), and Sparsity().
|
inlinestatic |
Extra doc: https://github.com/casadi/casadi/wiki/L_bi
Definition at line 192 of file sparsity.hpp.
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1520 of file sparsity.cpp.
References colind(), row(), and Sparsity().
|
static |
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1612 of file sparsity.cpp.
References casadi::is_monotone(), size1(), size2(), casadi::str(), and casadi::GenericMatrix< MatType >::zeros().
std::string casadi::Sparsity::dim | ( | bool | with_nz = false | ) | const |
Definition at line 587 of file sparsity.cpp.
Referenced by add(), append(), appendColumns(), bor(), casadi::Conic::Conic(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_jac_sparsity_hierarchical_symm(), casadi::Dple::init(), casadi::Nlpsol::init(), is_singular(), mtimes(), mul_sparsityF(), mul_sparsityR(), norm_0_mul(), postfix_dim(), casadi::MX::project(), and set().
|
inherited |
Definition at line 35 of file shared_object.cpp.
References casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null().
Referenced by casadi::Nlpsol::disp_more(), and casadi::CsparseInterface::nfact().
void casadi::Sparsity::enlarge | ( | casadi_int | nrow, |
casadi_int | ncol, | ||
const std::vector< casadi_int > & | rr, | ||
const std::vector< casadi_int > & | cc, | ||
bool | ind1 = false |
||
) |
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 544 of file sparsity.cpp.
References enlargeColumns(), and enlargeRows().
Referenced by casadi::MX::enlarge(), and casadi::Sqpmethod::init().
void casadi::Sparsity::enlargeColumns | ( | casadi_int | ncol, |
const std::vector< casadi_int > & | cc, | ||
bool | ind1 = false |
||
) |
Extra doc: https://github.com/casadi/casadi/wiki/L_ct
Definition at line 550 of file sparsity.cpp.
References size1(), size2(), and Sparsity().
Referenced by enlarge(), and casadi::FunctionInternal::from_compact().
void casadi::Sparsity::enlargeRows | ( | casadi_int | nrow, |
const std::vector< casadi_int > & | rr, | ||
bool | ind1 = false |
||
) |
Extra doc: https://github.com/casadi/casadi/wiki/L_cs
Definition at line 559 of file sparsity.cpp.
References size1(), size2(), and Sparsity().
Referenced by enlarge(), and casadi::FunctionInternal::from_compact().
std::vector< casadi_int > casadi::Sparsity::erase | ( | const std::vector< casadi_int > & | rr, |
bool | ind1 = false |
||
) |
Extra doc: https://github.com/casadi/casadi/wiki/L_cw
Definition at line 346 of file sparsity.cpp.
std::vector< casadi_int > casadi::Sparsity::erase | ( | const std::vector< casadi_int > & | rr, |
const std::vector< casadi_int > & | cc, | ||
bool | ind1 = false |
||
) |
Extra doc: https://github.com/casadi/casadi/wiki/L_cv
Definition at line 339 of file sparsity.cpp.
Referenced by casadi::MX::erase(), and casadi::FmuFunction::init().
std::vector< casadi_int > casadi::Sparsity::etree | ( | bool | ata = false | ) | const |
See Direct Methods for Sparse Linear Systems by Davis (2006). If the parameter ata is false, the algorithm is equivalent to MATLAB's etree(A), except that the indices are zero-based. If ata is true, the algorithm is equivalent to MATLAB's etree(A, 'col').
The implementation is a modified version of cs_etree in CSparse Copyright(c) Timothy A. Davis, 2006-2009 Licensed as a derivative work under the GNU LGPL
Extra doc: https://github.com/casadi/casadi/wiki/L_d2
Definition at line 615 of file sparsity.cpp.
References casadi::SparsityInternal::etree(), casadi::get_ptr(), size1(), and size2().
void casadi::Sparsity::export_code | ( | const std::string & | lang, |
std::ostream & | stream = casadi::uout() , |
||
const Dict & | options = Dict() |
||
) | const |
lang: only 'matlab' supported for now
* options: * inline: Indicates if you want everything on a single line (default: False) * name: Name of exported variable (default: 'sp') * as_matrix: Matlab does not have a sparsity object. (default: false) * With this option true, a numeric matrix will be constructed *
Extra doc: https://github.com/casadi/casadi/wiki/L_dj
Definition at line 778 of file sparsity.cpp.
Referenced by casadi::XFunction< DerivedType, MatType, NodeType >::export_code(), casadi::MXFunction::export_code_body(), and casadi::Linsol::nfact().
|
static |
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1888 of file sparsity.cpp.
References file_formats, casadi::filename(), and casadi::str().
Referenced by from_file(), and to_file().
std::vector< casadi_int > casadi::Sparsity::find | ( | bool | ind1 = SWIG_IND1 | ) | const |
A : DenseMatrix 4 x 3 B : SparseMatrix 4 x 3 , 5 structural non-zeros
k = A.find() A[k] will contain the elements of A that are non-zero in B
Inverse of nonzeros
.
Extra doc: https://github.com/casadi/casadi/wiki/L_da
Definition at line 735 of file sparsity.cpp.
Referenced by casadi::GetNonzeros::ad_forward(), casadi::SetNonzeros< Add >::ad_forward(), casadi::GetNonzeros::ad_reverse(), casadi::SetNonzeros< Add >::ad_reverse(), casadi::GetNonzeros::eval_mx(), casadi::SetNonzeros< Add >::eval_mx(), casadi::Matrix< Scalar >::set(), and casadi::MX::set().
void casadi::Sparsity::find | ( | std::vector< casadi_int > & | loc, |
bool | ind1 = false |
||
) | const |
Definition at line 741 of file sparsity.cpp.
|
static |
Definition at line 1925 of file sparsity.cpp.
References file_format(), file_formats, casadi::filename(), nnz(), row(), size1(), size2(), and triplet().
SparsityInternal * casadi::Sparsity::get | ( | ) | const |
Definition at line 2018 of file sparsity.cpp.
References casadi::GenericShared< SharedObject, SharedObjectInternal >::get().
Referenced by casadi::SparsityInternal::is_equal(), casadi::SparsityInternal::maxtrans(), and operator*().
void casadi::Sparsity::get_ccs | ( | std::vector< casadi_int > & | colind, |
std::vector< casadi_int > & | row | ||
) | const |
Definition at line 376 of file sparsity.cpp.
References colind(), get_colind(), get_row(), and row().
Referenced by get_crs().
std::vector< casadi_int > casadi::Sparsity::get_col | ( | ) | const |
Together with the row-vector, this vector gives the sparsity of the matrix in sparse triplet format, i.e. the column and row for each non-zero elements
Extra doc: https://github.com/casadi/casadi/wiki/L_cd
Definition at line 368 of file sparsity.cpp.
Referenced by casadi::GetNonzeros::ad_forward(), casadi::SetNonzeros< Add >::ad_forward(), casadi::GetNonzeros::ad_reverse(), casadi::SetNonzeros< Add >::ad_reverse(), casadi::GetNonzeros::eval_mx(), casadi::SetNonzeros< Add >::eval_mx(), get_triplet(), casadi::DaeBuilderInternal::hess_sparsity(), casadi::SnoptInterface::init(), casadi::MX::set(), casadi::KnitroInterface::solve(), and to_file().
std::vector< casadi_int > casadi::Sparsity::get_colind | ( | ) | const |
Together with the row-vector, one obtains the sparsity pattern in the column compressed format.
Extra doc: https://github.com/casadi/casadi/wiki/L_ca
Definition at line 364 of file sparsity.cpp.
Referenced by add_nz(), casadi::OsqpInterface::codegen_body(), casadi::OsqpInterface::codegen_init_mem(), get_ccs(), casadi::GenericMatrix< MatType >::get_colind(), info(), casadi::FatropInterface::init(), casadi::HpipmInterface::init(), casadi::OsqpInterface::init_mem(), and casadi::SuperscsInterface::init_mem().
void casadi::Sparsity::get_crs | ( | std::vector< casadi_int > & | rowind, |
std::vector< casadi_int > & | col | ||
) | const |
Definition at line 381 of file sparsity.cpp.
Sparsity casadi::Sparsity::get_diag | ( | std::vector< casadi_int > & | mapping | ) | const |
Get the diagonal of the matrix/create a diagonal matrix (mapping will contain the nonzero mapping) When the input is square, the diagonal elements are returned. If the input is vector-like, a diagonal matrix is constructed with it.
Definition at line 611 of file sparsity.cpp.
References casadi::SparsityInternal::get_diag().
Referenced by casadi::MX::diag().
std::vector< casadi_int > casadi::Sparsity::get_lower | ( | ) | const |
Definition at line 987 of file sparsity.cpp.
casadi_int casadi::Sparsity::get_nz | ( | casadi_int | rr, |
casadi_int | cc | ||
) | const |
return -1 if the element does not exist
Extra doc: https://github.com/casadi/casadi/wiki/L_cf
Definition at line 246 of file sparsity.cpp.
Referenced by casadi::GetNonzeros::ad_forward(), casadi::SetNonzeros< Add >::ad_forward(), casadi::GetNonzeros::ad_reverse(), casadi::SetNonzeros< Add >::eval_mx(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_jac_sparsity_hierarchical_symm(), has_nz(), casadi::MX::kron(), and casadi::MX::set().
std::vector< casadi_int > casadi::Sparsity::get_nz | ( | const std::vector< casadi_int > & | rr, |
const std::vector< casadi_int > & | cc | ||
) | const |
return -1 if the element does not exist
Extra doc: https://github.com/casadi/casadi/wiki/L_cg
Definition at line 264 of file sparsity.cpp.
void casadi::Sparsity::get_nz | ( | std::vector< casadi_int > & | indices | ) | const |
The index vector is used both for input and outputs and must be sorted by increasing nonzero index, i.e. column-wise. Elements not found in the sparsity pattern are set to -1.
Extra doc: https://github.com/casadi/casadi/wiki/L_ch
Definition at line 745 of file sparsity.cpp.
std::vector< casadi_int > casadi::Sparsity::get_row | ( | ) | const |
Together with the column-vector, this vector gives the sparsity of the matrix in sparse triplet format, and together with the colind vector, one obtains the sparsity in column compressed format.
Extra doc: https://github.com/casadi/casadi/wiki/L_c9
Definition at line 372 of file sparsity.cpp.
Referenced by add_nz(), casadi::OsqpInterface::codegen_init_mem(), get_ccs(), casadi::GenericMatrix< MatType >::get_row(), get_triplet(), casadi::DaeBuilderInternal::hess_sparsity(), info(), casadi::FatropInterface::init(), casadi::HpipmInterface::init(), casadi::OsqpInterface::init_mem(), casadi::SuperscsInterface::init_mem(), permutation_vector(), casadi::MX::set(), casadi::KnitroInterface::solve(), and to_file().
|
inlineinherited |
Definition at line 91 of file shared_object.hpp.
void casadi::Sparsity::get_triplet | ( | std::vector< casadi_int > & | row, |
std::vector< casadi_int > & | col | ||
) | const |
Definition at line 385 of file sparsity.cpp.
References get_col(), get_row(), and row().
Referenced by casadi::ProxqpInterface::solve().
std::vector< casadi_int > casadi::Sparsity::get_upper | ( | ) | const |
Definition at line 991 of file sparsity.cpp.
|
static |
Definition at line 524 of file sparsity.cpp.
|
inherited |
Definition at line 103 of file generic_shared_impl.hpp.
|
static |
Definition at line 539 of file sparsity.cpp.
|
static |
Definition at line 529 of file sparsity.cpp.
|
static |
Definition at line 534 of file sparsity.cpp.
bool casadi::Sparsity::has_nz | ( | casadi_int | rr, |
casadi_int | cc | ||
) | const |
Definition at line 241 of file sparsity.cpp.
References get_nz().
std::size_t casadi::Sparsity::hash | ( | ) | const |
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 795 of file sparsity.cpp.
Extra doc: https://github.com/casadi/casadi/wiki/L_cq
Definition at line 1392 of file sparsity.cpp.
References nnz(), size1(), Sparsity(), and triplet().
Referenced by blockcat().
|
static |
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1547 of file sparsity.cpp.
References colind(), casadi::is_monotone(), casadi::SparsityInterface< Sparsity >::offset(), row(), size1(), size2(), Sparsity(), and casadi::str().
Referenced by vertsplit().
Dict casadi::Sparsity::info | ( | ) | const |
Obtain information about sparsity
Definition at line 1881 of file sparsity.cpp.
References get_colind(), get_row(), casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null(), size1(), and size2().
Returns the new sparsity pattern as well as a mapping with the same length as the number of non-zero elements The value is 1 if the non-zero comes from the first (i.e. this) object, 2 if it is from the second and 3 (i.e. 1 | 2) if from both
Extra doc: https://github.com/casadi/casadi/wiki/L_cn
Definition at line 422 of file sparsity.cpp.
References casadi::SparsityInternal::combine().
Sparsity casadi::Sparsity::intersect | ( | const Sparsity & | y, |
std::vector< unsigned char > & | mapping | ||
) | const |
Returns the new sparsity pattern as well as a mapping with the same length as the number of non-zero elements The value is 1 if the non-zero comes from the first (i.e. this) object, 2 if it is from the second and 3 (i.e. 1 | 2) if from both
Extra doc: https://github.com/casadi/casadi/wiki/L_cn
Definition at line 417 of file sparsity.cpp.
References casadi::SparsityInternal::combine().
Referenced by casadi::MXNode::get_dot(), operator*(), and casadi::MX::project().
bool casadi::Sparsity::is_column | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_cy
Definition at line 285 of file sparsity.cpp.
Referenced by append(), casadi::Rootfinder::init(), casadi::GenericMatrix< MatType >::is_column(), postfix_dim(), casadi::Matrix< Scalar >::print_default(), and casadi::Matrix< Scalar >::print_vector().
bool casadi::Sparsity::is_dense | ( | ) | const |
Definition at line 273 of file sparsity.cpp.
Referenced by casadi::SparsityInternal::_mtimes(), add_nz(), compress(), casadi::AlpaqaProblem::eval_hess_L(), casadi::AlpaqaProblem::eval_hess_ψ(), casadi::AlpaqaProblem::eval_jac_g(), casadi::XFunction< DerivedType, MatType, NodeType >::export_code(), casadi::AlpaqaProblem::get_hess_L_num_nonzeros(), casadi::AlpaqaProblem::get_hess_ψ_num_nonzeros(), casadi::AlpaqaProblem::get_jac_g_num_nonzeros(), casadi::MXNode::get_project(), casadi::Constant< Value >::get_project(), casadi::Integrator::init(), casadi::Rootfinder::init(), casadi::GenericMatrix< MatType >::is_dense(), casadi::Function::jac_sparsity(), kron(), casadi::Integrator::map2oracle(), postfix_dim(), and casadi::Scpgen::regularize().
bool casadi::Sparsity::is_diag | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_247
Definition at line 277 of file sparsity.cpp.
Referenced by casadi::SparsityInternal::_mtimes().
bool casadi::Sparsity::is_empty | ( | bool | both = false | ) | const |
A sparsity is considered empty if one of the dimensions is zero (or optionally both dimensions)
Extra doc: https://github.com/casadi/casadi/wiki/L_bs
Definition at line 144 of file sparsity.cpp.
Referenced by casadi::SparsityInternal::_mtimes(), add(), bor(), casadi::FunctionInternal::check_mat(), casadi::ConstantMX::create(), casadi::MXNode::get_mmax(), casadi::MXNode::get_mmin(), casadi::ZeroByZero::get_reshape(), casadi::Integrator::init(), casadi::Nlpsol::init(), casadi::GenericMatrix< MatType >::is_empty(), casadi::Integrator::map2oracle(), postfix_dim(), casadi::Matrix< Scalar >::print_default(), casadi::Call::projectArg(), and set().
bool casadi::Sparsity::is_equal | ( | casadi_int | nrow, |
casadi_int | ncol, | ||
const casadi_int * | colind, | ||
const casadi_int * | row | ||
) | const |
bool casadi::Sparsity::is_equal | ( | casadi_int | nrow, |
casadi_int | ncol, | ||
const std::vector< casadi_int > & | colind, | ||
const std::vector< casadi_int > & | row | ||
) | const |
bool casadi::Sparsity::is_equal | ( | const Sparsity & | y | ) | const |
Definition at line 443 of file sparsity.cpp.
|
inherited |
Definition at line 117 of file generic_shared_impl.hpp.
bool casadi::Sparsity::is_orthonormal | ( | bool | allow_empty = false | ) | const |
[in] | allow_empty | Disregard empty rows and columns in the analysis |
Extra doc: https://github.com/casadi/casadi/wiki/L_24f
Definition at line 305 of file sparsity.cpp.
Referenced by casadi::MX::solve().
bool casadi::Sparsity::is_orthonormal_columns | ( | bool | allow_empty = false | ) | const |
[in] | allow_empty | Disregard empty columns in the analysis |
Extra doc: https://github.com/casadi/casadi/wiki/L_24h
Definition at line 313 of file sparsity.cpp.
bool casadi::Sparsity::is_orthonormal_rows | ( | bool | allow_empty = false | ) | const |
[in] | allow_empty | Disregard empty rows in the analysis |
Extra doc: https://github.com/casadi/casadi/wiki/L_24g
Definition at line 309 of file sparsity.cpp.
bool casadi::Sparsity::is_permutation | ( | ) | const |
A Matrix P is permutation matrix if right multiplication with a dense vector v leads to a vector with the same elements, but permuted.
Implies square
Equivalent to is_orthonormal(false)
Extra doc: https://github.com/casadi/casadi/wiki/L_24d
Definition at line 297 of file sparsity.cpp.
Referenced by permutation_vector().
bool casadi::Sparsity::is_reshape | ( | const Sparsity & | y | ) | const |
Definition at line 791 of file sparsity.cpp.
Referenced by casadi::MXNode::get_reshape(), casadi::SparsityCast::get_reshape(), casadi::MX::MX(), casadi::MX::reshape(), and reshape().
bool casadi::Sparsity::is_row | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_cx
Definition at line 281 of file sparsity.cpp.
Referenced by casadi::GenericMatrix< MatType >::is_row().
bool casadi::Sparsity::is_scalar | ( | bool | scalar_and_dense = false | ) | const |
Definition at line 269 of file sparsity.cpp.
Referenced by casadi::SparsityInternal::_mtimes(), casadi::Matrix< Scalar >::_sym(), casadi::FunctionInternal::check_mat(), casadi::Integrator::init(), casadi::Integrator::map2oracle(), and postfix_dim().
bool casadi::Sparsity::is_selection | ( | bool | allow_empty = false | ) | const |
A Matrix S is selection matrix if right multiplication with a dense vector leads to a vector with a subset of the elements of the original vector
[in] | allow_empty | Allow the resultant vector to have structural zeros |
Equivalent to is_orthonormal_rows(allow_empty)
Extra doc: https://github.com/casadi/casadi/wiki/L_24e
Definition at line 301 of file sparsity.cpp.
bool casadi::Sparsity::is_singular | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_24c
Definition at line 1299 of file sparsity.cpp.
References dim(), is_square(), size2(), and sprank().
Referenced by casadi::Integrator::init(), casadi::Rootfinder::init(), and casadi::CsparseInterface::nfact().
bool casadi::Sparsity::is_square | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_248
Definition at line 293 of file sparsity.cpp.
Referenced by casadi::Expm::Expm(), is_singular(), casadi::GenericMatrix< MatType >::is_square(), kkt(), and casadi::Convexify::setup().
bool casadi::Sparsity::is_stacked | ( | const Sparsity & | y, |
casadi_int | n | ||
) | const |
Definition at line 439 of file sparsity.cpp.
bool casadi::Sparsity::is_subset | ( | const Sparsity & | rhs | ) | const |
Definition at line 426 of file sparsity.cpp.
Referenced by casadi::SparsityCast::ad_reverse().
bool casadi::Sparsity::is_symmetric | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_249
Definition at line 317 of file sparsity.cpp.
Referenced by casadi::Conic::Conic(), casadi::Dple::init(), casadi::FatropInterface::init(), casadi::Feasiblesqpmethod::init(), casadi::Sqpmethod::init(), casadi::FunctionInternal::jac_sparsity(), ldl(), and casadi::Convexify::setup().
bool casadi::Sparsity::is_transpose | ( | const Sparsity & | y | ) | const |
Definition at line 787 of file sparsity.cpp.
bool casadi::Sparsity::is_tril | ( | bool | strictly = false | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_24b
Definition at line 321 of file sparsity.cpp.
Referenced by casadi::MadnlpInterface::init(), casadi::GenericMatrix< MatType >::is_tril(), and casadi::Convexify::setup().
bool casadi::Sparsity::is_triu | ( | bool | strictly = false | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_24a
Definition at line 325 of file sparsity.cpp.
Referenced by casadi::IpoptInterface::init(), casadi::GenericMatrix< MatType >::is_triu(), and casadi::Convexify::setup().
bool casadi::Sparsity::is_vector | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_cz
Definition at line 289 of file sparsity.cpp.
Referenced by casadi::FunctionInternal::check_mat(), casadi::Integrator::init(), casadi::GenericMatrix< MatType >::is_vector(), casadi::Integrator::map2oracle(), and casadi::Call::projectArg().
|
static |
[H + I1, J'; J, I2] where I1 and I2 are optional
Extra doc: https://github.com/casadi/casadi/wiki/L_dk
Definition at line 1961 of file sparsity.cpp.
References blockcat(), diag(), is_square(), size(), size1(), size2(), Sparsity(), and T().
Referenced by casadi::Ipqp::init(), and casadi::Qrqp::init().
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1434 of file sparsity.cpp.
References colind(), dense(), casadi::get_ptr(), is_dense(), nnz(), row(), size1(), size2(), and Sparsity().
std::vector< casadi_int > casadi::Sparsity::largest_first | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_de
Definition at line 765 of file sparsity.cpp.
Sparsity casadi::Sparsity::ldl | ( | std::vector< casadi_int > & | p, |
bool | amd = true |
||
) | const |
Returns the sparsity pattern of L^T
The implementation is a modified version of LDL Copyright(c) Timothy A. Davis, 2005-2013 Licensed as a derivative work under the GNU LGPL
Extra doc: https://github.com/casadi/casadi/wiki/L_d3
Definition at line 621 of file sparsity.cpp.
References amd(), casadi::get_ptr(), is_symmetric(), ldl(), casadi::SparsityInternal::ldl_colind(), casadi::SparsityInternal::ldl_row(), casadi::range(), size1(), Sparsity(), and sub().
Referenced by casadi::SuperscsInterface::init(), casadi::LinsolLdl::init(), and ldl().
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_bh
Definition at line 1049 of file sparsity.cpp.
References colind(), row(), and Sparsity().
Referenced by casadi::Convexify::setup(), and casadi::OptiNode::variable().
|
inlinestatic |
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 705 of file sparsity.hpp.
Sparsity casadi::Sparsity::makeDense | ( | std::vector< casadi_int > & | mapping | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_cu
Definition at line 583 of file sparsity.cpp.
References casadi::SparsityInternal::makeDense().
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 430 of file sparsity.cpp.
References casadi::SparsityInternal::_mtimes(), dim(), size1(), and size2().
Referenced by casadi::MX::mtimes(), qr_sparse(), sum1(), and sum2().
|
static |
no memory allocation: z = mul(x, y)
with work vector Forward mode.
Extra doc: https://github.com/casadi/casadi/wiki/L_co
Definition at line 1747 of file sparsity.cpp.
References colind(), dim(), row(), size1(), and size2().
Referenced by casadi::Multiplication::sp_forward().
|
static |
no memory allocation: z = mul(x, y)
with work vector Reverse mode.
Extra doc: https://github.com/casadi/casadi/wiki/L_cp
Definition at line 1791 of file sparsity.cpp.
References casadi::casadi_fill(), colind(), dim(), row(), size1(), and size2().
Referenced by casadi::Multiplication::sp_reverse().
casadi_int casadi::Sparsity::nnz | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_bt
Definition at line 148 of file sparsity.cpp.
Referenced by casadi::Matrix< Scalar >::_sym(), casadi::MX::_sym(), casadi::SetNonzeros< Add >::ad_forward(), casadi::GetNonzeros::ad_reverse(), casadi::SetNonzeros< Add >::ad_reverse(), add(), add_nz(), bor(), casadi::Switch::codegen_body(), casadi::FastNewton::codegen_body(), casadi::Sqpmethod::codegen_body(), casadi::OsqpInterface::codegen_init_mem(), casadi::Sqpmethod::codegen_solve_elastic_mode(), casadi::SparsityInternal::combineGen1(), compressed(), casadi::ConstantFile::ConstantFile(), casadi::ConstantMX::create(), density(), casadi::FmuFunction::eval(), casadi::Switch::eval(), casadi::HorzRepsum::eval_gen(), casadi::AlpaqaProblem::eval_hess_L(), casadi::AlpaqaProblem::eval_hess_ψ(), casadi::AlpaqaProblem::eval_jac_g(), casadi::Scpgen::eval_mat(), casadi::SetNonzeros< Add >::eval_mx(), casadi::Switch::eval_sx(), casadi::LinsolQr::finalize(), from_file(), casadi::LinsolLdl::generate(), casadi::LinsolQr::generate(), casadi::HorzRepsum::generate(), casadi::UnaryMX::generate(), casadi::AlpaqaProblem::get_hess_L_num_nonzeros(), casadi::AlpaqaProblem::get_hess_ψ_num_nonzeros(), casadi::AlpaqaProblem::get_jac_g_num_nonzeros(), casadi::FunctionInternal::get_jac_sparsity_gen(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_jac_sparsity_hierarchical_symm(), casadi::BonminInterface::get_nlp_info(), casadi::IpoptInterface::get_nlp_info(), casadi::Call::get_output(), casadi::MultipleOutput::get_output(), casadi::MXNode::get_project(), casadi::MXNode::get_sparsity_cast(), casadi::FunctionInternal::get_sparsity_out(), horzcat(), casadi::FmuFunction::init(), casadi::Switch::init(), casadi::AmplInterface::init(), casadi::Blocksqp::init(), casadi::BonminInterface::init(), casadi::CbcInterface::init(), casadi::ClpInterface::init(), casadi::FatropConicInterface::init(), casadi::FatropInterface::init(), casadi::HpipmInterface::init(), casadi::HpmpcInterface::init(), casadi::IpoptInterface::init(), casadi::MadnlpInterface::init(), casadi::OsqpInterface::init(), casadi::SLEQPInterface::init(), casadi::SnoptInterface::init(), casadi::KinsolInterface::init(), casadi::SundialsInterface::init(), casadi::SuperscsInterface::init(), casadi::FastNewton::init(), casadi::Feasiblesqpmethod::init(), casadi::Ipqp::init(), casadi::Newton::init(), casadi::Qrqp::init(), casadi::Qrsqp::init(), casadi::Scpgen::init(), casadi::Sqpmethod::init(), casadi::ClarabelInterface::init_dependent(), casadi::HighsInterface::init_dependent(), casadi::Blocksqp::init_mem(), casadi::CbcInterface::init_mem(), casadi::ClpInterface::init_mem(), casadi::CplexInterface::init_mem(), casadi::HpmpcInterface::init_mem(), casadi::OsqpInterface::init_mem(), casadi::ProxqpInterface::init_mem(), casadi::QpoasesInterface::init_mem(), casadi::SuperscsInterface::init_mem(), casadi::LinsolLdl::init_mem(), casadi::LinsolQr::init_mem(), casadi::Lsqr::init_mem(), kron(), casadi::MX::MX(), casadi::LinsolQr::nfact(), norm_0_mul(), casadi::Matrix< Scalar >::print_default(), casadi::Matrix< Scalar >::print_dense(), casadi::Matrix< Scalar >::print_sparse(), casadi::Matrix< Scalar >::print_vector(), casadi::CodeGenerator::project(), casadi::QpoasesInterface::qpoases_init(), casadi::FmuFunction::remove_nans(), casadi::Reshape::Reshape(), row(), set(), casadi::FatropInterface::set_fatrop_prob(), casadi::IpoptInterface::set_ipopt_prob(), casadi::MadnlpInterface::set_madnlp_prob(), casadi::Blocksqp::set_work(), casadi::BonminInterface::set_work(), casadi::IpoptInterface::set_work(), casadi::SLEQPInterface::set_work(), casadi::SnoptInterface::set_work(), casadi::KinsolInterface::set_work(), casadi::SundialsInterface::set_work(), casadi::WorhpInterface::set_work(), casadi::FastNewton::set_work(), casadi::Newton::set_work(), casadi::Qrsqp::set_work(), casadi::Scpgen::set_work(), casadi::Convexify::setup(), casadi::CplexInterface::solve(), casadi::ProxqpInterface::solve(), casadi::QpoasesInterface::solve(), casadi::SuperscsInterface::solve(), casadi::Ipqp::solve(), casadi::KnitroInterface::solve(), casadi::Feasiblesqpmethod::solve(), casadi::Qrsqp::solve(), casadi::Sqpmethod::solve(), casadi::Sqpmethod::solve_elastic_mode(), casadi::MXNode::sp_forward(), casadi::HorzRepsum::sp_forward(), casadi::Split::sp_forward(), casadi::FunctionInternal::sp_forward_block(), casadi::MXNode::sp_reverse(), casadi::HorzRepmat::sp_reverse(), casadi::HorzRepsum::sp_reverse(), casadi::Split::sp_reverse(), casadi::FunctionInternal::sp_reverse(), casadi::MX::sparsity_cast(), sparsity_cast(), casadi::SparsityCast::SparsityCast(), to_file(), and vertcat().
casadi_int casadi::Sparsity::nnz_diag | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_bw
Definition at line 360 of file sparsity.cpp.
casadi_int casadi::Sparsity::nnz_lower | ( | bool | strictly = false | ) | const |
i.e. the number of elements (i, j) with j<=i
Extra doc: https://github.com/casadi/casadi/wiki/L_bv
Definition at line 352 of file sparsity.cpp.
Referenced by casadi::WorhpInterface::set_work().
casadi_int casadi::Sparsity::nnz_upper | ( | bool | strictly = false | ) | const |
i.e. the number of elements (i, j) with j>=i
Extra doc: https://github.com/casadi/casadi/wiki/L_bu
Definition at line 356 of file sparsity.cpp.
Referenced by casadi::OsqpInterface::codegen_init_mem(), casadi::OoqpInterface::init(), casadi::OsqpInterface::init(), casadi::MumpsInterface::init_mem(), and casadi::OsqpInterface::init_mem().
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_23g
Definition at line 1285 of file sparsity.cpp.
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1665 of file sparsity.cpp.
References colind(), dim(), casadi::get_ptr(), nnz(), row(), size1(), and size2().
Referenced by casadi::GenericMatrix< MatType >::norm_0_mul().
casadi_int casadi::Sparsity::numel | ( | ) | const |
Beware of overflow
Extra doc: https://github.com/casadi/casadi/wiki/L_bq
Definition at line 132 of file sparsity.cpp.
Referenced by casadi::FunctionInternal::get_sparsity_out(), casadi::Nlpsol::init(), casadi::Matrix< Scalar >::print_default(), and casadi::reduce_index_gen().
casadi::Sparsity::operator const casadi_int * | ( | ) | const |
In the C runtime, sparsity patterns are represented as a "const casadi_int*". This enables using the C runtime functions using a natural syntax.
Extra doc: https://github.com/casadi/casadi/wiki/L_bn
Definition at line 1661 of file sparsity.cpp.
casadi::Sparsity::operator const std::vector< casadi_int > & | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_bo
Definition at line 1314 of file sparsity.cpp.
casadi::Sparsity::operator SparsityStruct | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_bp
Definition at line 1318 of file sparsity.cpp.
|
inline |
const SparsityInternal & casadi::Sparsity::operator* | ( | ) | const |
Returns the new sparsity pattern as well as a mapping with the same length as the number of non-zero elements The value is 1 if the non-zero comes from the first (i.e. this) object, 2 if it is from the second and 3 (i.e. 1 | 2) if from both
Extra doc: https://github.com/casadi/casadi/wiki/L_cn
Definition at line 461 of file sparsity.cpp.
References intersect().
Extra doc: https://github.com/casadi/casadi/wiki/L_cm
Definition at line 457 of file sparsity.cpp.
References unite().
const SparsityInternal * casadi::Sparsity::operator-> | ( | ) | const |
Definition at line 112 of file sparsity.cpp.
References casadi::GenericShared< SharedObject, SharedObjectInternal >::operator->().
|
inline |
|
inherited |
Assign the node to a node class pointer (or null)
Definition at line 90 of file generic_shared_impl.hpp.
Sparsity casadi::Sparsity::pattern_inverse | ( | ) | const |
Definition at line 466 of file sparsity.cpp.
References casadi::SparsityInternal::pattern_inverse().
Referenced by casadi::HpipmInterface::init(), and casadi::HpmpcInterface::init().
|
static |
Right multiplication of P with a vector leads to the same results as indexing that vector with p
P @ v = v[p]
The inverse of a permutation matrix is equal to its transpose (property of orthonormality)
Extra doc: https://github.com/casadi/casadi/wiki/L_244
Definition at line 1364 of file sparsity.cpp.
References colind(), casadi::invert_permutation(), casadi::is_permutation(), casadi::range(), and Sparsity().
const std::vector< casadi_int > casadi::Sparsity::permutation_vector | ( | bool | invert = false | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_245
Definition at line 1375 of file sparsity.cpp.
References get_row(), casadi::invert_permutation(), and is_permutation().
Referenced by casadi::MXNode::get_mac().
Sparsity casadi::Sparsity::pmult | ( | const std::vector< casadi_int > & | p, |
bool | permute_rows = true , |
||
bool | permute_columns = true , |
||
bool | invert_permutation = false |
||
) | const |
Multiply the sparsity with a permutation matrix from the left and/or from the right P * A * trans(P), A * trans(P) or A * trans(P) with P defined by an index vector containing the row for each col. As an alternative, P can be transposed (inverted).
Extra doc: https://github.com/casadi/casadi/wiki/L_df
Definition at line 769 of file sparsity.cpp.
References casadi::invert_permutation(), and casadi::SparsityInternal::pmult().
Referenced by casadi::SparsityInternal::star_coloring(), and casadi::SparsityInternal::star_coloring2().
std::string casadi::Sparsity::postfix_dim | ( | ) | const |
Rules:
Otherwise: "[5x10,3nz]"
Extra doc: https://github.com/casadi/casadi/wiki/L_dg
Definition at line 591 of file sparsity.cpp.
References dim(), is_column(), is_dense(), is_empty(), is_scalar(), size1(), and casadi::str().
|
inherited |
Print the pointer to the internal class
Definition at line 43 of file shared_object.cpp.
References casadi::GenericShared< SharedObject, SharedObjectInternal >::get().
void casadi::Sparsity::qr_sparse | ( | Sparsity & | V, |
Sparsity & | R, | ||
std::vector< casadi_int > & | prinv, | ||
std::vector< casadi_int > & | pc, | ||
bool | amd = true |
||
) | const |
Returns the sparsity pattern of V (compact representation of Q) and R as well as vectors needed for the numerical factorization and solution. The implementation is a modified version of CSparse Copyright(c) Timothy A. Davis, 2006-2009 Licensed as a derivative work under the GNU LGPL
Extra doc: https://github.com/casadi/casadi/wiki/L_d4
Definition at line 653 of file sparsity.cpp.
References amd(), compressed(), casadi::get_ptr(), mtimes(), casadi::SparsityInternal::qr_init(), qr_sparse(), casadi::SparsityInternal::qr_sparsities(), casadi::range(), size1(), size2(), sub(), and T().
Referenced by casadi::FastNewton::init(), casadi::LinsolQr::init(), casadi::Qrqp::init(), and qr_sparse().
void casadi::Sparsity::removeDuplicates | ( | std::vector< casadi_int > & | mapping | ) |
The same indices will be removed from the mapping vector, which must have the same length as the number of nonzeros
Extra doc: https://github.com/casadi/casadi/wiki/L_d1
Definition at line 731 of file sparsity.cpp.
std::string casadi::Sparsity::repr_el | ( | casadi_int | k | ) | const |
Definition at line 607 of file sparsity.cpp.
Referenced by casadi::OracleFunction::calc_function().
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 260 of file sparsity.cpp.
References casadi::SparsityInternal::_reshape().
Referenced by casadi::MX::reshape().
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 250 of file sparsity.cpp.
References is_reshape().
void casadi::Sparsity::resize | ( | casadi_int | nrow, |
casadi_int | ncol | ||
) |
Definition at line 188 of file sparsity.cpp.
References size1(), and size2().
Referenced by casadi::SparsityInternal::combineGen1(), casadi::SparsityInternal::dmperm(), and casadi::SparsityInternal::pmult().
const casadi_int * casadi::Sparsity::row | ( | ) | const |
containing rows for all non-zero elements (see class description)
Extra doc: https://github.com/casadi/casadi/wiki/L_c7
Definition at line 164 of file sparsity.cpp.
Referenced by casadi::SparsityInternal::_mtimes(), casadi::GetNonzeros::ad_forward(), casadi::SetNonzeros< Add >::ad_forward(), casadi::SetNonzeros< Add >::ad_reverse(), add(), add_nz(), band(), casadi::SparsityInternal::bfs(), casadi::KinsolInterface::bjac(), bor(), casadi::Blocksqp::calcHessianUpdateExact(), casadi::Blocksqp::calcLagrangeGradient(), casadi::casadi_func_cons_jac(), casadi::FmuFunction::check_hessian(), casadi::SparsityInternal::combineGen(), compressed(), casadi::construct_nlpsol(), casadi::IndexReduction::dae_struct_detect(), dense(), casadi::detect_simple_bounds_gen(), diag(), diagcat(), casadi::KinsolInterface::djac(), casadi::BonminUserClass::eval_h(), casadi::IpoptUserClass::eval_h(), casadi::AlpaqaProblem::eval_hess_L(), casadi::AlpaqaProblem::eval_hess_ψ(), casadi::AlpaqaProblem::eval_jac_g(), casadi::BonminUserClass::eval_jac_g(), casadi::IpoptUserClass::eval_jac_g(), casadi::GetNonzeros::eval_mx(), casadi::SetNonzeros< Add >::eval_mx(), casadi::FmuFunction::eval_task(), from_file(), get_ccs(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_jac_sparsity_hierarchical_symm(), casadi::FunctionInternal::get_sparsity_out(), get_triplet(), horzsplit(), casadi::SqicInterface::init(), casadi::FmuFunction::init(), casadi::AmplInterface::init(), casadi::Blocksqp::init(), casadi::FatropConicInterface::init(), casadi::HpipmInterface::init(), casadi::HpmpcInterface::init(), casadi::SuperscsInterface::init(), casadi::ClarabelInterface::init_dependent(), casadi::HighsInterface::init_dependent(), casadi::CplexInterface::init_mem(), is_equal(), casadi::SparsityInternal::is_equal(), casadi::SparsityInternal::is_stacked(), casadi::XFunction< DerivedType, MatType, NodeType >::jac(), kron(), lower(), casadi::FmuFunction::make_symmetric(), mul_sparsityF(), mul_sparsityR(), casadi::SparsityInternal::multiply(), nonzeros(), norm_0_mul(), casadi::Matrix< Scalar >::print_dense(), casadi::Matrix< Scalar >::print_sparse(), casadi::Matrix< Scalar >::print_vector(), casadi::CvodesInterface::psetupF(), casadi::IdasInterface::psetupF(), casadi::FmuFunction::remove_nans(), casadi::GenericMatrix< MatType >::row(), row(), rowcol(), casadi::Conic::sdp_to_socp_init(), set(), casadi::WorhpInterface::set_work(), casadi::CbcInterface::solve(), casadi::ClpInterface::solve(), casadi::CplexInterface::solve(), casadi::GurobiInterface::solve(), casadi::OoqpInterface::solve(), casadi::QpoasesInterface::solve(), casadi::SuperscsInterface::solve(), casadi::WorhpInterface::solve(), casadi::Blocksqp::solveQP(), casadi::Rank1::sp_forward(), casadi::Solve< Tr >::sp_forward(), casadi::FunctionInternal::sp_forward_block(), casadi::Rank1::sp_reverse(), casadi::Solve< Tr >::sp_reverse(), casadi::FunctionInternal::sp_reverse(), Sparsity(), to_file(), triplet(), casadi::SparsityInternal::uni_coloring(), unit(), casadi::DaeBuilderInternal::update_dependencies(), and upper().
casadi_int casadi::Sparsity::row | ( | casadi_int | el | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_cc
Definition at line 172 of file sparsity.cpp.
References nnz(), row(), and casadi::str().
|
static |
|
inline |
Definition at line 334 of file sparsity.hpp.
bool casadi::Sparsity::rowsSequential | ( | bool | strictly = true | ) | const |
[in] | strictly | if true, then do not allow multiple entries |
Extra doc: https://github.com/casadi/casadi/wiki/L_d0
Definition at line 727 of file sparsity.cpp.
|
inlinestatic |
Extra doc: https://github.com/casadi/casadi/wiki/L_bd
Definition at line 153 of file sparsity.hpp.
Referenced by casadi::Bilin::Bilin(), casadi::Call::Call(), casadi::Dot::Dot(), casadi::Find::Find(), casadi::FunctionInternal::get_sparsity_in(), casadi::Switch::get_sparsity_in(), casadi::FunctionInternal::get_sparsity_out(), casadi::Conic::get_sparsity_out(), casadi::MMax::MMax(), casadi::MMin::MMin(), casadi::Norm::Norm(), casadi::simpleIntegrator(), and casadi::Split::Split().
casadi_int casadi::Sparsity::scc | ( | std::vector< casadi_int > & | index, |
std::vector< casadi_int > & | offset | ||
) | const |
of a square matrix
See Direct Methods for Sparse Linear Systems by Davis (2006). Returns:
In the case that the matrix is symmetric, the result has a particular interpretation: Given a symmetric matrix A and n = A.scc(p, r)
=> A[p, p] will appear block-diagonal with n blocks and with the indices of the block boundaries to be found in r.
The implementation is a modified version of cs_scc in CSparse Copyright(c) Timothy A. Davis, 2006-2009 Licensed as a derivative work under the GNU LGPL
Extra doc: https://github.com/casadi/casadi/wiki/L_d6
Definition at line 703 of file sparsity.cpp.
References casadi::SparsityInterface< Sparsity >::offset().
Referenced by casadi::Conic::sdp_to_socp_init(), and casadi::Convexify::setup().
std::string casadi::Sparsity::serialize | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_c2
Definition at line 2006 of file sparsity.cpp.
Referenced by serialize().
void casadi::Sparsity::serialize | ( | SerializingStream & | s | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_c5
Definition at line 1988 of file sparsity.cpp.
References compress(), casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null(), and casadi::SerializingStream::pack().
void casadi::Sparsity::serialize | ( | std::ostream & | stream | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_c1
Definition at line 1978 of file sparsity.cpp.
References serialize().
void casadi::Sparsity::set | ( | DataType * | data, |
const DataType * | val_data, | ||
const Sparsity & | val_sp | ||
) | const |
Definition at line 1248 of file sparsity.hpp.
References colind(), dim(), is_empty(), nnz(), row(), size1(), and size2().
void casadi::Sparsity::set | ( | T * | data, |
const T * | val_data, | ||
const Sparsity & | val_sp | ||
) | const |
entries of another sparsity pattern
Extra doc: https://github.com/casadi/casadi/wiki/L_dl
Referenced by casadi::Project::sp_forward().
std::pair< casadi_int, casadi_int > casadi::Sparsity::size | ( | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_bz
Definition at line 152 of file sparsity.cpp.
Referenced by casadi::SparsityInternal::_mtimes(), casadi::GetNonzeros::ad_forward(), casadi::FunctionInternal::check_mat(), casadi::SparsityInternal::combineGen(), compressed(), casadi::GetNonzeros::eval_mx(), casadi::Matrix< Scalar >::get(), casadi::MX::get(), casadi::MXNode::get_binary(), casadi::Expm::get_forward(), casadi::FunctionInternal::get_jac_sparsity_gen(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_jac_sparsity_hierarchical_symm(), casadi::Expm::get_reverse(), casadi::Integrator::init(), kkt(), casadi::Integrator::map2oracle(), casadi::MX::MX(), casadi::MX::project(), casadi::Call::projectArg(), casadi::replace_mat(), casadi::Matrix< Scalar >::set(), casadi::MX::set(), casadi::simpleIntegrator(), and casadi::MXNode::to_matrix().
casadi_int casadi::Sparsity::size | ( | casadi_int | axis | ) | const |
casadi_int casadi::Sparsity::size1 | ( | ) | const |
Definition at line 124 of file sparsity.cpp.
Referenced by casadi::SolveUnity< Tr >::A_sp(), casadi::GetNonzeros::ad_forward(), casadi::SetNonzeros< Add >::ad_forward(), casadi::SetNonzeros< Add >::ad_reverse(), add(), add_nz(), append(), appendColumns(), casadi::Function::assert_sparsity_out(), bor(), casadi::FmuFunction::check_hessian(), casadi::FunctionInternal::check_mat(), casadi::FastNewton::codegen_body(), casadi::FunctionInternal::codegen_meta(), casadi::SparsityInternal::combineGen(), compress(), casadi::Conic::Conic(), casadi::IndexReduction::dae_struct_detect(), density(), diagsplit(), enlargeColumns(), enlargeRows(), casadi::FunctionInternal::ensure_stacked(), etree(), casadi::GetNonzeros::eval_mx(), casadi::SetNonzeros< Add >::eval_mx(), casadi::XFunction< DerivedType, MatType, NodeType >::export_code(), casadi::FunctionInternal::from_compact(), from_file(), casadi::Expm::get_forward(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_partition(), casadi::Dple::get_reverse(), casadi::Expm::get_reverse(), casadi::FunctionInternal::get_sparsity_out(), horzcat(), horzsplit(), info(), casadi::Dple::init(), casadi::FmuFunction::init(), casadi::Rootfinder::init(), casadi::Switch::init(), casadi::FatropInterface::init(), casadi::SlicotExpm::init(), casadi::FastNewton::init(), casadi::LinsolLdl::init(), casadi::SymbolicQr::init_mem(), casadi::SparsityInternal::is_equal(), casadi::SparsityInternal::is_stacked(), casadi::FunctionInternal::jac_sparsity(), kkt(), kron(), ldl(), casadi::FmuFunction::make_symmetric(), mtimes(), mul_sparsityF(), mul_sparsityR(), casadi::SparsityInternal::multiply(), norm_0_mul(), casadi::Vertcat::off(), casadi::Diagcat::off(), casadi::OptiNode::parameter(), postfix_dim(), casadi::Matrix< Scalar >::print_default(), casadi::Matrix< Scalar >::print_dense(), casadi::Matrix< Scalar >::print_sparse(), casadi::Matrix< Scalar >::print_vector(), casadi::Call::projectArg(), casadi::IdasInterface::psetupF(), qr_sparse(), casadi::FmuFunction::remove_nans(), casadi::replace_mat(), resize(), casadi::Conic::sdp_to_socp_init(), set(), casadi::FatropInterface::set_fatrop_prob(), casadi::IpoptInterface::set_ipopt_prob(), casadi::MadnlpInterface::set_madnlp_prob(), casadi::FastNewton::set_work(), casadi::Convexify::setup(), casadi::simpleIntegrator(), size(), casadi::CbcInterface::solve(), casadi::ClpInterface::solve(), casadi::ProxqpInterface::solve(), casadi::QpoasesInterface::solve(), casadi::SuperscsInterface::solve(), casadi::Solve< Tr >::sp_forward(), casadi::Integrator::sp_jac_aug(), casadi::Solve< Tr >::sp_reverse(), sum1(), to_file(), and casadi::OptiNode::variable().
casadi_int casadi::Sparsity::size2 | ( | ) | const |
Definition at line 128 of file sparsity.cpp.
Referenced by casadi::SparsityInternal::_mtimes(), casadi::GetNonzeros::ad_forward(), casadi::SetNonzeros< Add >::ad_reverse(), add(), add_nz(), append(), appendColumns(), casadi::Function::assert_sparsity_out(), casadi::KinsolInterface::bjac(), bor(), casadi::casadi_func_cons_jac(), casadi::FunctionInternal::check_mat(), casadi::FastNewton::codegen_body(), casadi::FunctionInternal::codegen_meta(), colind(), casadi::SparsityInternal::combineGen(), compress(), casadi::Conic::Conic(), casadi::IndexReduction::dae_struct_detect(), density(), diagsplit(), casadi::KinsolInterface::djac(), enlargeColumns(), enlargeRows(), casadi::FunctionInternal::ensure_stacked(), etree(), casadi::Transpose::eval_gen(), casadi::BonminUserClass::eval_h(), casadi::IpoptUserClass::eval_h(), casadi::BonminUserClass::eval_jac_g(), casadi::IpoptUserClass::eval_jac_g(), casadi::GetNonzeros::eval_mx(), casadi::FmuFunction::eval_task(), casadi::XFunction< DerivedType, MatType, NodeType >::export_code(), casadi::FunctionInternal::from_compact(), from_file(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_partition(), casadi::FunctionInternal::get_sparsity_out(), horzsplit(), info(), casadi::Dple::init(), casadi::FmuFunction::init(), casadi::FatropConicInterface::init(), casadi::FatropInterface::init(), casadi::HpipmInterface::init(), casadi::HpmpcInterface::init(), casadi::SuperscsInterface::init(), casadi::FastNewton::init(), casadi::Ipqp::init(), casadi::SymbolicQr::init(), casadi::ClarabelInterface::init_dependent(), casadi::HighsInterface::init_dependent(), casadi::Blocksqp::init_mem(), casadi::CbcInterface::init_mem(), casadi::ClpInterface::init_mem(), casadi::CplexInterface::init_mem(), casadi::QpoasesInterface::init_mem(), casadi::SparsityInternal::is_equal(), is_singular(), casadi::SparsityInternal::is_stacked(), casadi::XFunction< DerivedType, MatType, NodeType >::jac(), casadi::FunctionInternal::jac_sparsity(), kkt(), kron(), mtimes(), mul_sparsityF(), mul_sparsityR(), casadi::SparsityInternal::multiply(), norm_0_mul(), casadi::Horzcat::off(), casadi::Diagcat::off(), casadi::OptiNode::parameter(), casadi::Matrix< Scalar >::print_default(), casadi::Matrix< Scalar >::print_dense(), casadi::Matrix< Scalar >::print_sparse(), casadi::Call::projectArg(), casadi::CvodesInterface::psetupF(), qr_sparse(), casadi::replace_mat(), resize(), casadi::Conic::sdp_to_socp_init(), set(), casadi::FastNewton::set_work(), size(), casadi::CbcInterface::solve(), casadi::ClpInterface::solve(), casadi::CplexInterface::solve(), casadi::GurobiInterface::solve(), casadi::ProxqpInterface::solve(), casadi::QpoasesInterface::solve(), casadi::Rank1::sp_forward(), casadi::Transpose::sp_forward(), casadi::FunctionInternal::sp_forward_block(), casadi::Integrator::sp_jac_aug(), casadi::Rank1::sp_reverse(), casadi::Transpose::sp_reverse(), casadi::FunctionInternal::sp_reverse(), sum2(), to_file(), casadi::OptiNode::variable(), and vertcat().
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 255 of file sparsity.cpp.
References nnz().
Assumption: 'this' is a subset of X.
Example:
X = [ * . . .; . * . .; . . * .; . . . *] Y = [* *; . . ; * *] x = [ * . . .; . . . .; . . * .; . . . *] returns [* *; . . ; . *]
Extra doc: https://github.com/casadi/casadi/wiki/L_246
Definition at line 1844 of file sparsity.cpp.
References casadi::X, and casadi::Y.
Referenced by casadi::SparsityCast::ad_forward(), and casadi::SparsityCast::ad_reverse().
|
static |
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1655 of file sparsity.cpp.
References btf().
Referenced by is_singular(), and casadi::GenericMatrix< MatType >::sprank().
Extra doc: https://github.com/casadi/casadi/wiki/L_d9
Definition at line 723 of file sparsity.cpp.
References casadi::X.
Referenced by casadi::Solve< Tr >::sp_forward(), casadi::Integrator::sp_forward(), casadi::Rootfinder::sp_forward(), casadi::Solve< Tr >::sp_reverse(), casadi::Integrator::sp_reverse(), and casadi::Rootfinder::sp_reverse().
void casadi::Sparsity::spy | ( | std::ostream & | stream = casadi::uout() | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_dh
Definition at line 783 of file sparsity.cpp.
void casadi::Sparsity::spy_matlab | ( | const std::string & | mfile | ) | const |
the sparsity using the spy command
Extra doc: https://github.com/casadi/casadi/wiki/L_di
Definition at line 774 of file sparsity.cpp.
Sparsity casadi::Sparsity::star_coloring | ( | casadi_int | ordering = 1 , |
casadi_int | cutoff = std::numeric_limits<casadi_int>::max() |
||
) | const |
A greedy distance-2 coloring algorithm Algorithm 4.1 in What Color Is Your Jacobian? Graph Coloring for Computing Derivatives A. H. GEBREMEDHIN, F. MANNE, A. POTHEN SIAM Rev., 47(4), 629–705 (2006)
Ordering options: None (0), largest first (1)
Extra doc: https://github.com/casadi/casadi/wiki/L_dc
Definition at line 757 of file sparsity.cpp.
References casadi::SparsityInternal::star_coloring().
Referenced by casadi::FunctionInternal::get_jac_sparsity_hierarchical_symm(), casadi::FunctionInternal::get_partition(), casadi::FmuFunction::init(), and casadi::SparsityInternal::star_coloring().
Sparsity casadi::Sparsity::star_coloring2 | ( | casadi_int | ordering = 1 , |
casadi_int | cutoff = std::numeric_limits<casadi_int>::max() |
||
) | const |
A new greedy distance-2 coloring algorithm Algorithm 4.1 in NEW ACYCLIC AND STAR COLORING ALGORITHMS WITH APPLICATION TO COMPUTING HESSIANS A. H. GEBREMEDHIN, A. TARAFDAR, F. MANNE, A. POTHEN SIAM J. SCI. COMPUT. Vol. 29, No. 3, pp. 1042–1072 (2007)
Ordering options: None (0), largest first (1)
Extra doc: https://github.com/casadi/casadi/wiki/L_dd
Definition at line 761 of file sparsity.cpp.
References casadi::SparsityInternal::star_coloring2().
Referenced by casadi::SparsityInternal::star_coloring2().
Sparsity casadi::Sparsity::sub | ( | const std::vector< casadi_int > & | rr, |
const Sparsity & | sp, | ||
std::vector< casadi_int > & | mapping, | ||
bool | ind1 = false |
||
) | const |
Returns the sparsity of the corresponding elements, with a mapping such that submatrix[k] = originalmatrix[mapping[k]]
Extra doc: https://github.com/casadi/casadi/wiki/L_cj
Definition at line 329 of file sparsity.cpp.
References casadi::SparsityInternal::sub().
Sparsity casadi::Sparsity::sub | ( | const std::vector< casadi_int > & | rr, |
const std::vector< casadi_int > & | cc, | ||
std::vector< casadi_int > & | mapping, | ||
bool | ind1 = false |
||
) | const |
Returns the sparsity of the submatrix, with a mapping such that submatrix[k] = originalmatrix[mapping[k]]
Extra doc: https://github.com/casadi/casadi/wiki/L_ci
Definition at line 334 of file sparsity.cpp.
References casadi::SparsityInternal::sub().
Referenced by casadi::Matrix< Scalar >::get(), casadi::MX::get(), casadi::FmuInternal::hess_sparsity(), casadi::LinsolLdl::init(), casadi::FmuInternal::jac_sparsity(), ldl(), qr_sparse(), casadi::Convexify::setup(), casadi::SuperscsInterface::solve(), and casadi::FunctionInternal::to_compact().
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1651 of file sparsity.cpp.
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1647 of file sparsity.cpp.
|
inherited |
Definition at line 106 of file generic_shared_impl.hpp.
Sparsity casadi::Sparsity::T | ( | ) | const |
Definition at line 394 of file sparsity.cpp.
References casadi::SparsityInternal::T().
Referenced by casadi::construct_nlpsol(), casadi::detect_simple_bounds_gen(), casadi::Matrix< Scalar >::get(), casadi::MX::get(), get_crs(), casadi::FmuFunction::get_jac_sparsity(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_jac_sparsity_hierarchical_symm(), casadi::MX::get_nz(), casadi::FunctionInternal::get_partition(), casadi::FmuFunction::get_sparsity_out(), casadi::FmuFunction::init(), casadi::AmplInterface::init(), casadi::FatropConicInterface::init(), casadi::FatropInterface::init(), casadi::HpipmInterface::init(), casadi::HpmpcInterface::init(), casadi::OoqpInterface::init(), casadi::Qrqp::init(), casadi::Scpgen::init(), casadi::XFunction< DerivedType, MatType, NodeType >::jac(), casadi::FunctionInternal::jac_sparsity(), kkt(), qr_sparse(), casadi::Convexify::setup(), casadi::Transpose::Transpose(), uni_coloring(), and vertsplit().
|
static |
Definition at line 120 of file sparsity.cpp.
void casadi::Sparsity::to_file | ( | const std::string & | filename, |
const std::string & | format_hint = "" |
||
) | const |
Export sparsity pattern to file
Supported formats:
Definition at line 1906 of file sparsity.cpp.
References file_format(), file_formats, casadi::filename(), get_col(), get_row(), nnz(), casadi::Filesystem::open(), row(), size1(), and size2().
Referenced by casadi::FatropInterface::init().
Sparsity casadi::Sparsity::transpose | ( | std::vector< casadi_int > & | mapping, |
bool | invert_mapping = false |
||
) | const |
[out] | mapping | the non-zeros of the original matrix for each non-zero of the new matrix |
Extra doc: https://github.com/casadi/casadi/wiki/L_ck
Definition at line 390 of file sparsity.cpp.
References casadi::SparsityInternal::transpose().
Referenced by casadi::XFunction< DerivedType, MatType, NodeType >::jac(), and casadi::Conic::sdp_to_socp_init().
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 979 of file sparsity.cpp.
References casadi::SparsityInternal::_tril().
Referenced by casadi::Convexify::setup(), and casadi::GenericMatrix< MatType >::tril().
|
static |
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_bm
Definition at line 1127 of file sparsity.cpp.
References row(), Sparsity(), and casadi::str().
Referenced by casadi::SparsityInternal::_mtimes(), casadi::SparsityInternal::_reshape(), casadi::BSpline::dual(), from_file(), casadi::FunctionInternal::get_jac_sparsity_gen(), casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_jac_sparsity_hierarchical_symm(), casadi::DaeBuilderInternal::hess_sparsity(), horzcat(), casadi::XFunction< DerivedType, MatType, NodeType >::jac(), casadi::DaeBuilderInternal::jac_sparsity(), nonzeros(), casadi::SparsityInternal::pmult(), casadi::QpoasesInterface::qpoases_init(), rowcol(), casadi::Matrix< Scalar >::set(), casadi::MX::set(), casadi::SparsityInternal::star_coloring(), casadi::SparsityInternal::sub(), casadi::SparsityInternal::transpose(), triplet(), and vertcat().
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 983 of file sparsity.cpp.
References casadi::SparsityInternal::_triu().
Referenced by casadi::OsqpInterface::codegen_init_mem(), casadi::OsqpInterface::init_mem(), casadi::Convexify::setup(), and casadi::GenericMatrix< MatType >::triu().
|
inlinestatic |
Definition at line 1140 of file sparsity.hpp.
Sparsity casadi::Sparsity::uni_coloring | ( | const Sparsity & | AT = Sparsity() , |
casadi_int | cutoff = std::numeric_limits<casadi_int>::max() |
||
) | const |
(Algorithm 3.1 in A. H. GEBREMEDHIN, F. MANNE, A. POTHEN)
Extra doc: https://github.com/casadi/casadi/wiki/L_db
Definition at line 749 of file sparsity.cpp.
References casadi::GenericShared< Shared, Internal >::is_null(), T(), and casadi::SparsityInternal::uni_coloring().
Referenced by casadi::FunctionInternal::get_jac_sparsity_hierarchical(), casadi::FunctionInternal::get_partition(), and casadi::FmuFunction::init().
|
static |
position el *
Extra doc: https://github.com/casadi/casadi/wiki/L_bf
Definition at line 1104 of file sparsity.cpp.
References colind(), row(), and Sparsity().
Referenced by casadi::SuperscsInterface::init().
Extra doc: https://github.com/casadi/casadi/wiki/L_cm
Definition at line 413 of file sparsity.cpp.
References casadi::SparsityInternal::combine().
Sparsity casadi::Sparsity::unite | ( | const Sparsity & | y, |
std::vector< unsigned char > & | mapping | ||
) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_cm
Definition at line 409 of file sparsity.cpp.
References casadi::SparsityInternal::combine().
Referenced by casadi::SetNonzeros< Add >::ad_forward(), casadi::GetNonzeros::ad_reverse(), casadi::SetNonzeros< Add >::eval_mx(), casadi::Switch::get_sparsity_in(), casadi::Switch::get_sparsity_out(), operator+(), and casadi::MX::unite().
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_bg
Definition at line 1028 of file sparsity.cpp.
References colind(), row(), and Sparsity().
Referenced by casadi::Convexify::setup().
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1478 of file sparsity.cpp.
References nnz(), size2(), Sparsity(), and triplet().
Referenced by append(), and blockcat().
|
static |
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1596 of file sparsity.cpp.
References horzsplit(), casadi::SparsityInterface< Sparsity >::offset(), and T().
|
inherited |
Extra doc: https://github.com/casadi/casadi/wiki/L_aw
Definition at line 131 of file generic_shared_impl.hpp.
|
static |
Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros
For the matrices A to B A(m, n) length(jj)=m , length(ii)=n B(nrow, ncol)
A=enlarge(m, n, ii, jj) makes sure that
B[jj, ii] == A
Extra doc: https://github.com/casadi/casadi/wiki/L_cr
Definition at line 1183 of file sparsity.hpp.
Referenced by file_format(), from_file(), and to_file().