List of all members | Public Types | Public Member Functions | Static Public Member Functions | Friends
casadi::Matrix< Scalar > Class Template Reference

Sparse matrix class. SX and DM are specializations. More...

#include <matrix_decl.hpp>

Detailed Description

template<typename Scalar>
class casadi::Matrix< Scalar >

General sparse matrix class that is designed with the idea that "everything is a matrix", that is, also scalars and vectors.
This philosophy makes it easy to use and to interface in particularly with Python and Matlab/Octave.
Index starts with 0.
Index vec happens as follows: (rr, cc) -> k = rr+cc*size1()
Vectors are column vectors.
The storage format is Compressed Column Storage (CCS), similar to that used for sparse matrices in Matlab,
but unlike this format, we do allow for elements to be structurally non-zero but numerically zero.
Matrix<Scalar> is polymorphic with a std::vector<Scalar> that contain all non-identical-zero elements.
The sparsity can be accessed with Sparsity& sparsity()

Author
Joel Andersson
Date
2010-2014

Extra doc: https://github.com/casadi/casadi/wiki/L_18e

Definition at line 95 of file matrix_decl.hpp.

Inheritance diagram for casadi::Matrix< Scalar >:
Inheritance graph
[legend]
Collaboration diagram for casadi::Matrix< Scalar >:
Collaboration graph
[legend]

Public Types

typedef Scalar ScalarType
 Scalar type. More...
 
typedef GenericMatrix< Matrix< Scalar > > B
 Base class. More...
 

Public Member Functions

 Matrix ()
 constructors More...
 
 Matrix (const Matrix< Scalar > &m)
 Copy constructor. More...
 
Matrix< Scalar > & operator= (const Matrix< Scalar > &m)
 Assignment (normal) More...
 
 Matrix (casadi_int nrow, casadi_int ncol)
 Create a sparse matrix with all structural zeros. More...
 
 Matrix (const std::pair< casadi_int, casadi_int > &rc)
 Create a sparse matrix with all structural zeros. More...
 
std::vector< Scalar > * operator-> ()
 Access functions of the node. More...
 
const std::vector< Scalar > * operator-> () const
 Const access functions of the node. More...
 
 Matrix (const Sparsity &sp)
 Create a sparse matrix from a sparsity pattern. More...
 
 Matrix (const Sparsity &sp, const Matrix< Scalar > &d)
 Construct matrix with a given sparsity and nonzeros. More...
 
 Matrix (double val)
 This constructor enables implicit type conversion from a numeric type. More...
 
 Matrix (const std::vector< std::vector< double > > &m)
 Dense matrix constructor with data given as vector of vectors. More...
 
template<typename A >
 Matrix (const std::vector< A > &x)
 Create an expression from a vector. More...
 
template<typename A >
 Matrix (const Matrix< A > &x)
 Create a matrix from another matrix with a different entry type. More...
 
 Matrix (const std::vector< Scalar > &x)
 Construct from a vector. More...
 
 Matrix (std::initializer_list< Scalar > x)
 Construct from initializer list. More...
 
const Scalar scalar () const
 Convert to scalar type. More...
 
bool has_nz (casadi_int rr, casadi_int cc) const
 Returns true if the matrix has a non-zero at location rr, cc. More...
 
bool __nonzero__ () const
 Returns the truth value of a Matrix. More...
 
Matrix< Scalar > operator+ () const
 
Matrix< Scalar > operator- () const
 
Matrix< Scalar > printme (const Matrix< Scalar > &y) const
 
Matrix< Scalar > T () const
 Transpose the matrix. More...
 
void print_split (std::vector< std::string > &nz, std::vector< std::string > &inter) const
 Get strings corresponding to the nonzeros and the interdependencies. More...
 
void disp (std::ostream &stream, bool more=false) const
 Print a representation of the object. More...
 
std::string get_str (bool more=false) const
 Get string representation. More...
 
void print_scalar (std::ostream &stream) const
 Print scalar. More...
 
void print_vector (std::ostream &stream, bool truncate=true) const
 Print vector-style. More...
 
void print_dense (std::ostream &stream, bool truncate=true) const
 Print dense matrix-stype. More...
 
void print_sparse (std::ostream &stream, bool truncate=true) const
 Print sparse matrix style. More...
 
void clear ()
 
void resize (casadi_int nrow, casadi_int ncol)
 
void reserve (casadi_int nnz)
 
void reserve (casadi_int nnz, casadi_int ncol)
 
void erase (const std::vector< casadi_int > &rr, const std::vector< casadi_int > &cc, bool ind1=false)
 Erase a submatrix (leaving structural zeros in its place) More...
 
void erase (const std::vector< casadi_int > &rr, bool ind1=false)
 Erase a submatrix (leaving structural zeros in its place) More...
 
void remove (const std::vector< casadi_int > &rr, const std::vector< casadi_int > &cc)
 Remove columns and rows. 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...
 
const Sparsitysparsity () const
 Const access the sparsity - reference to data member. More...
 
Sparsity get_sparsity () const
 Get an owning reference to the sparsity pattern. More...
 
Matrix< Scalar > get_output (casadi_int oind) const
 Get an output. More...
 
casadi_int element_hash () const
 Returns a number that is unique for a given symbolic scalar. More...
 
bool is_regular () const
 Checks if expression does not contain NaN or Inf. More...
 
bool is_smooth () const
 Check if smooth. More...
 
bool is_leaf () const
 Check if SX is a leaf of the SX graph. More...
 
bool is_commutative () const
 Check whether a binary SX is commutative. More...
 
bool is_symbolic () const
 Check if symbolic (Dense) More...
 
bool is_valid_input () const
 Check if matrix can be used to define function inputs. More...
 
bool has_duplicates () const
 Detect duplicate symbolic expressions. More...
 
void reset_input () const
 Reset the marker for an input expression. More...
 
bool is_constant () const
 Check if the matrix is constant (note that false negative answers are possible) More...
 
bool is_call () const
 Check if function call. More...
 
bool is_output () const
 Check if evaluation output. More...
 
bool has_output () const
 Check if a multiple output node. More...
 
casadi_int which_output () const
 Get the index of evaluation output - only valid when is_output() is true. More...
 
Function which_function () const
 Get function - only valid when is_call() is true. More...
 
bool is_integer () const
 Check if the matrix is integer-valued. More...
 
bool is_zero () const
 check if the matrix is 0 (note that false negative answers are possible) More...
 
bool is_one () const
 check if the matrix is 1 (note that false negative answers are possible) More...
 
bool is_minus_one () const
 check if the matrix is -1 (note that false negative answers are possible) More...
 
bool is_half () const
 check if the matrix is 0.5 (note that false negative answers are possible) More...
 
bool is_value (double val) const
 check if the matrix is value More...
 
bool is_inf () const
 check if the matrix is inf (note that false negative answers are possible) More...
 
bool is_minus_inf () const
 check if the matrix is -inf (note that false negative answers are possible) More...
 
bool is_nonnegative () const
 check if the matrix is not negative More...
 
bool is_eye () const
 check if the matrix is an identity matrix (note that false negative answers More...
 
casadi_int op () const
 Get operation type. More...
 
bool is_op (casadi_int op) const
 Is it a certain operation. More...
 
bool has_zeros () const
 Check if the matrix has any zero entries which are not structural zeros. More...
 
std::vector< Scalar > get_nonzeros () const
 Get all nonzeros. More...
 
std::vector< Scalar > get_elements () const
 Get all elements. More...
 
template<typename A >
std::vector< A > get_nonzeros () const
 Get all nonzeros. More...
 
 operator double () const
 Type conversion to double. More...
 
 operator casadi_int () const
 Type conversion to casadi_int. More...
 
template<typename A >
 operator std::vector< A > () const
 Type conversion to a vector. More...
 
std::string name () const
 Get name (only if symbolic scalar) More...
 
Matrix< Scalar > dep (casadi_int ch=0) const
 Get expressions of the children of the expression. More...
 
casadi_int n_dep () const
 Get the number of dependencies of a binary SXElem. More...
 
void export_code (const std::string &lang, std::ostream &stream=casadi::uout(), const Dict &options=Dict()) const
 Export matrix in specific language. More...
 
Dict info () const
 
void serialize (std::ostream &stream) const
 Serialize an object. More...
 
std::string serialize () const
 Serialize. More...
 
void serialize (SerializingStream &s) const
 Serialize an object. More...
 
void to_file (const std::string &filename, const std::string &format="") const
 
 Matrix (const Sparsity &sp, const Scalar &val, bool dummy)
 Sparse matrix with a given sparsity with all values same. More...
 
 Matrix (const Sparsity &sp, const std::vector< Scalar > &d, bool dummy)
 Sparse matrix with a given sparsity and non-zero elements. More...
 
casadi_int nnz () const
 Get the number of (structural) non-zero elements. More...
 
casadi_int nnz_lower () const
 Get the number of non-zeros in the lower triangular half. More...
 
casadi_int nnz_upper () const
 Get the number of non-zeros in the upper triangular half. More...
 
casadi_int nnz_diag () const
 Get get the number of non-zeros on the diagonal. More...
 
casadi_int numel () const
 Get the number of elements. More...
 
casadi_int size1 () const
 Get the first dimension (i.e. number of rows) More...
 
casadi_int rows () const
 Get the number of rows, Octave-style syntax. More...
 
casadi_int size2 () const
 Get the second dimension (i.e. number of columns) More...
 
casadi_int columns () const
 Get the number of columns, Octave-style syntax. More...
 
std::string dim (bool with_nz=false) const
 Get string representation of dimensions. 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...
 
bool is_empty (bool both=false) const
 Check if the sparsity is empty, i.e. if one of the dimensions is zero. More...
 
bool is_dense () const
 Check if the matrix expression is dense. More...
 
bool is_scalar (bool scalar_and_dense=false) const
 Check if the matrix expression is scalar. More...
 
bool is_square () const
 Check if the matrix expression is square. More...
 
bool is_vector () const
 Check if the matrix is a row or column vector. More...
 
bool is_row () const
 Check if the matrix is a row vector (i.e. size1()==1) More...
 
bool is_column () const
 Check if the matrix is a column vector (i.e. size2()==1) More...
 
bool is_triu () const
 Check if the matrix is upper triangular. More...
 
bool is_tril () const
 Check if the matrix is lower triangular. More...
 
const Matrix< Scalar > nz (const K &k) const
 Get vector nonzero or slice of nonzeros. More...
 
NonZeros< Matrix< Scalar >, K > nz (const K &k)
 Access vector nonzero or slice of nonzeros. More...
 
const Matrix< Scalar > operator() (const RR &rr) const
 Get vector element or slice. More...
 
const Matrix< Scalar > operator() (const RR &rr, const CC &cc) const
 Get Matrix element or slice. More...
 
SubIndex< Matrix< Scalar >, RR > operator() (const RR &rr)
 Access Matrix elements (one argument) More...
 
SubMatrix< Matrix< Scalar >, RR, CC > operator() (const RR &rr, const CC &cc)
 Access Matrix elements (two arguments) More...
 
void get (Matrix< Scalar > &m, bool ind1, const Slice &rr) const
 
void get (Matrix< Scalar > &m, bool ind1, const Matrix< casadi_int > &rr) const
 
void get (Matrix< Scalar > &m, bool ind1, const Sparsity &sp) const
 
void get (Matrix< Scalar > &m, bool ind1, const Slice &rr, const Slice &cc) const
 
void get (Matrix< Scalar > &m, bool ind1, const Slice &rr, const Matrix< casadi_int > &cc) const
 
void get (Matrix< Scalar > &m, bool ind1, const Matrix< casadi_int > &rr, const Slice &cc) const
 
void get (Matrix< Scalar > &m, bool ind1, const Matrix< casadi_int > &rr, const Matrix< casadi_int > &cc) const
 
void set (const Matrix< Scalar > &m, bool ind1, const Slice &rr)
 
void set (const Matrix< Scalar > &m, bool ind1, const Matrix< casadi_int > &rr)
 
void set (const Matrix< Scalar > &m, bool ind1, const Sparsity &sp)
 
void set (const Matrix< Scalar > &m, bool ind1, const Slice &rr, const Slice &cc)
 
void set (const Matrix< Scalar > &m, bool ind1, const Slice &rr, const Matrix< casadi_int > &cc)
 
void set (const Matrix< Scalar > &m, bool ind1, const Matrix< casadi_int > &rr, const Slice &cc)
 
void set (const Matrix< Scalar > &m, bool ind1, const Matrix< casadi_int > &rr, const Matrix< casadi_int > &cc)
 
void get_nz (Matrix< Scalar > &m, bool ind1, const Slice &k) const
 
void get_nz (Matrix< Scalar > &m, bool ind1, const Matrix< casadi_int > &k) const
 
void set_nz (const Matrix< Scalar > &m, bool ind1, const Slice &k)
 
void set_nz (const Matrix< Scalar > &m, bool ind1, const Matrix< casadi_int > &k)
 
std::vector< Scalar > & nonzeros ()
 
const std::vector< Scalar > & nonzeros () const
 
std::vector< casadi_int > get_row () const
 Get the sparsity pattern. See the Sparsity class for details. More...
 
std::vector< casadi_int > get_colind () const
 Get the sparsity pattern. See the Sparsity class for details. More...
 
const casadi_int * row () const
 Get the sparsity pattern. See the Sparsity class for details. More...
 
casadi_int row (casadi_int el) const
 Get the sparsity pattern. See the Sparsity class for details. More...
 
const casadi_int * colind () const
 Get the sparsity pattern. See the Sparsity class for details. More...
 
casadi_int colind (casadi_int col) const
 Get the sparsity pattern. See the Sparsity class for details. More...
 

Static Public Member Functions

static bool simplify_ref_count (std::vector< Matrix< Scalar > > &arg, std::vector< Matrix< Scalar > > &res, const Dict &opts=Dict())
 
static bool simplify_const_folding (std::vector< Matrix< Scalar > > &arg, std::vector< Matrix< Scalar > > &res, const Dict &opts=Dict())
 
static bool simplify_combine_terms (std::vector< Matrix< Scalar > > &arg, std::vector< Matrix< Scalar > > &res, const Dict &opts=Dict())
 
static void set_max_depth (casadi_int eq_depth=1)
 Set or reset the depth to which equalities are being checked for simplifications. More...
 
static casadi_int get_max_depth ()
 Get the depth to which equalities are being checked for simplifications. More...
 
static std::vector< Matrix< Scalar > > get_input (const Function &f)
 Get function input. More...
 
static std::vector< Matrix< Scalar > > get_free (const Function &f)
 Get free. More...
 
static std::string type_name ()
 Get name of the class. More...
 
static void print_default (std::ostream &stream, const Sparsity &sp, const Scalar *nonzeros, bool truncate=true)
 Print default style. More...
 
static void print_scalar (std::ostream &stream, const Scalar &e)
 Print scalar. More...
 
static void print_vector (std::ostream &stream, const Sparsity &sp, const Scalar *nonzeros, bool truncate=true)
 Print vector-style. More...
 
static void print_canonical (std::ostream &stream, const Sparsity &sp, const Scalar *nonzeros, bool truncate=true)
 Print canonical style. More...
 
static void print_sparse (std::ostream &stream, const Sparsity &sp, const Scalar *nonzeros, bool truncate=true)
 Print scalar. More...
 
static void print_split (casadi_int nnz, const Scalar *nonzeros, std::vector< std::string > &nz, std::vector< std::string > &inter)
 Get strings corresponding to the nonzeros and the interdependencies. More...
 
static void print_dense (std::ostream &stream, const Sparsity &sp, const Scalar *nonzeros, bool truncate=true)
 Print dense matrix-stype. More...
 
static Matrix< Scalar > eye (casadi_int n)
 create an n-by-n identity matrix More...
 
static void set_precision (casadi_int precision)
 Set the 'precision, width & scientific' used in printing and serializing to streams. More...
 
static void set_width (casadi_int width)
 
static void set_scientific (bool scientific)
 
static casadi_int get_precision ()
 Get the 'precision, width & scientific' used in printing and serializing to streams. More...
 
static casadi_int get_width ()
 
static bool get_scientific ()
 
static void rng (casadi_int seed)
 Seed the random number generator. More...
 
static Matrix< Scalar > deserialize (std::istream &stream)
 Build Sparsity from serialization. More...
 
static Matrix< Scalar > deserialize (const std::string &s)
 Build Sparsity from serialization. More...
 
static Matrix< Scalar > deserialize (DeserializingStream &s)
 
static void to_file (const std::string &filename, const Sparsity &sp, const Scalar *nonzeros, const std::string &format="")
 
static Matrix< double > from_file (const std::string &filename, const std::string &format_hint="")
 
static Matrix< Scalar > _sym (const std::string &name, const Sparsity &sp)
 
static Matrix< Scalar > logsumexp (const Matrix< Scalar > &x)
 
static Matrix< Scalar > binary (casadi_int op, const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 Create nodes by their ID. More...
 
static Matrix< Scalar > unary (casadi_int op, const Matrix< Scalar > &x)
 Create nodes by their ID. More...
 
static Matrix< Scalar > scalar_matrix (casadi_int op, const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 Create nodes by their ID. More...
 
static Matrix< Scalar > matrix_scalar (casadi_int op, const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 Create nodes by their ID. More...
 
static Matrix< Scalar > matrix_matrix (casadi_int op, const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 Create nodes by their ID. More...
 
static std::vector< Matrix< Scalar > > call (const Function &f, const std::vector< Matrix< Scalar > > &x)
 Create nodes by their ID. More...
 
static std::vector< Scalar > call (const Function &f, const std::vector< Scalar > &x)
 Create nodes by their ID. More...
 
static bool is_equal (const Matrix< Scalar > &x, const Matrix< Scalar > &y, casadi_int depth=0)
 
static Matrix< Scalar > mmin (const Matrix< Scalar > &x)
 
static Matrix< Scalar > mmax (const Matrix< Scalar > &x)
 
static Matrix< Scalar > simplify (const Matrix< Scalar > &x)
 
static Matrix< Scalar > transform (const Matrix< Scalar > &x, const Dict &opts=Dict())
 
static Matrix< Scalar > transform (const Matrix< Scalar > &x, const std::vector< std::vector< GenericType > > &passes, const Dict &opts=Dict())
 
static std::vector< Matrix< Scalar > > transform (const std::vector< Matrix< Scalar > > &x, const Dict &opts=Dict())
 
static std::vector< Matrix< Scalar > > transform (const std::vector< Matrix< Scalar > > &x, const std::vector< std::vector< GenericType > > &passes, const Dict &opts=Dict())
 
static Matrix< Scalar > jacobian (const Matrix< Scalar > &f, const Matrix< Scalar > &x, const Dict &opts=Dict())
 
static Sparsity jacobian_sparsity (const Matrix< Scalar > &f, const Matrix< Scalar > &x)
 
static Matrix< Scalar > hessian (const Matrix< Scalar > &f, const Matrix< Scalar > &x, const Dict &opts=Dict())
 
static Matrix< Scalar > hessian (const Matrix< Scalar > &f, const Matrix< Scalar > &x, Matrix< Scalar > &g, const Dict &opts=Dict())
 
static Matrix< Scalar > substitute (const Matrix< Scalar > &ex, const Matrix< Scalar > &v, const Matrix< Scalar > &vdef)
 
static std::vector< Matrix< Scalar > > substitute (const std::vector< Matrix< Scalar > > &ex, const std::vector< Matrix< Scalar > > &v, const std::vector< Matrix< Scalar > > &vdef)
 
static void substitute_inplace (const std::vector< Matrix< Scalar > > &v, std::vector< Matrix< Scalar > > &vdef, std::vector< Matrix< Scalar > > &ex, bool revers)
 
static Matrix< Scalar > pinv (const Matrix< Scalar > &x)
 
static Matrix< Scalar > pinv (const Matrix< Scalar > &A, const std::string &lsolver, const Dict &opts)
 
static Matrix< Scalar > expm_const (const Matrix< Scalar > &A, const Matrix< Scalar > &t)
 
static Matrix< Scalar > expm (const Matrix< Scalar > &A)
 
static Matrix< Scalar > solve (const Matrix< Scalar > &A, const Matrix< Scalar > &b)
 
static Matrix< Scalar > solve (const Matrix< Scalar > &A, const Matrix< Scalar > &b, const std::string &lsolver, const Dict &opts)
 
static Matrix< Scalar > inv (const Matrix< Scalar > &A)
 
static Matrix< Scalar > inv (const Matrix< Scalar > &A, const std::string &lsolver, const Dict &opts)
 
static casadi_int n_nodes (const Matrix< Scalar > &x)
 
static std::string print_operator (const Matrix< Scalar > &x, const std::vector< std::string > &args)
 
static void extract (std::vector< Matrix< Scalar >> &ex, std::vector< Matrix< Scalar >> &v, std::vector< Matrix< Scalar >> &vdef, const Dict &opts=Dict())
 
static void shared (std::vector< Matrix< Scalar > > &ex, std::vector< Matrix< Scalar > > &v, std::vector< Matrix< Scalar > > &vdef, const std::string &v_prefix, const std::string &v_suffix)
 
static Matrix< Scalar > _bilin (const Matrix< Scalar > &A, const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 
static Matrix< Scalar > _rank1 (const Matrix< Scalar > &A, const Matrix< Scalar > &alpha, const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 
static Matrix< Scalar > if_else (const Matrix< Scalar > &x, const Matrix< Scalar > &if_true, const Matrix< Scalar > &if_false, bool short_circuit=false)
 
static Matrix< Scalar > conditional (const Matrix< Scalar > &ind, const std::vector< Matrix< Scalar > > &x, const Matrix< Scalar > &x_default, bool short_circuit=false)
 
static bool depends_on (const Matrix< Scalar > &x, const Matrix< Scalar > &arg)
 
static bool contains (const std::vector< Matrix< Scalar > > &v, const Matrix< Scalar > &n)
 
static bool contains_all (const std::vector< Matrix< Scalar > > &v, const std::vector< Matrix< Scalar > > &n)
 
static bool contains_any (const std::vector< Matrix< Scalar > > &v, const std::vector< Matrix< Scalar > > &n)
 
static Matrix< Scalar > mrdivide (const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 
static Matrix< Scalar > mldivide (const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 
static std::vector< Matrix< Scalar > > symvar (const Matrix< Scalar > &x)
 
static Matrix< Scalar > det (const Matrix< Scalar > &x)
 
static Matrix< Scalar > det (const Matrix< Scalar > &x, const std::string &lsolver, const Dict &dict=Dict())
 
static Matrix< Scalar > inv_minor (const Matrix< Scalar > &x)
 
static Matrix< Scalar > trace (const Matrix< Scalar > &x)
 
static Matrix< Scalar > norm_1 (const Matrix< Scalar > &x)
 
static Matrix< Scalar > norm_2 (const Matrix< Scalar > &x)
 
static Matrix< Scalar > norm_fro (const Matrix< Scalar > &x)
 
static Matrix< Scalar > norm_inf (const Matrix< Scalar > &x)
 
static Matrix< Scalar > sum2 (const Matrix< Scalar > &x)
 
static Matrix< Scalar > sum1 (const Matrix< Scalar > &x)
 
static Matrix< Scalar > dot (const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 
static Matrix< Scalar > nullspace (const Matrix< Scalar > &x)
 
static Matrix< Scalar > diag (const Matrix< Scalar > &x)
 
static Matrix< Scalar > unite (const Matrix< Scalar > &A, const Matrix< Scalar > &B)
 
static Matrix< Scalar > project (const Matrix< Scalar > &x, const Sparsity &sp, bool intersect=false)
 
static Matrix< Scalar > polyval (const Matrix< Scalar > &p, const Matrix< Scalar > &x)
 
static Matrix< Scalar > densify (const Matrix< Scalar > &x, const Matrix< Scalar > &val)
 
static Matrix< Scalar > densify (const Matrix< Scalar > &x)
 
static Matrix< Scalar > einstein (const Matrix< Scalar > &A, const Matrix< Scalar > &B, const Matrix< Scalar > &C, const std::vector< casadi_int > &dim_a, const std::vector< casadi_int > &dim_b, const std::vector< casadi_int > &dim_c, const std::vector< casadi_int > &a, const std::vector< casadi_int > &b, const std::vector< casadi_int > &c)
 
static Matrix< Scalar > einstein (const Matrix< Scalar > &A, const Matrix< Scalar > &B, const std::vector< casadi_int > &dim_a, const std::vector< casadi_int > &dim_b, const std::vector< casadi_int > &dim_c, const std::vector< casadi_int > &a, const std::vector< casadi_int > &b, const std::vector< casadi_int > &c)
 
static Matrix< Scalar > cumsum (const Matrix< Scalar > &x, casadi_int axis=-1)
 
static Matrix< Scalar > _logsumexp (const Matrix< Scalar > &x)
 
static std::vector< Matrix< Scalar > > cse (const std::vector< Matrix< Scalar > > &e)
 
static Matrix< Scalar > blockcat (const std::vector< std::vector< Matrix< Scalar > > > &v)
 
static Matrix< Scalar > horzcat (const std::vector< Matrix< Scalar > > &v)
 
static std::vector< Matrix< Scalar > > horzsplit (const Matrix< Scalar > &x, const std::vector< casadi_int > &offset)
 
static Matrix< Scalar > vertcat (const std::vector< Matrix< Scalar > > &v)
 
static std::vector< Matrix< Scalar > > vertsplit (const Matrix< Scalar > &x, const std::vector< casadi_int > &offset)
 
static std::vector< Matrix< Scalar > > diagsplit (const Matrix< Scalar > &x, const std::vector< casadi_int > &offset1, const std::vector< casadi_int > &offset2)
 
static Matrix< Scalar > reshape (const Matrix< Scalar > &x, casadi_int nrow, casadi_int ncol)
 
static Matrix< Scalar > reshape (const Matrix< Scalar > &x, const Sparsity &sp)
 
static Matrix< Scalar > sparsity_cast (const Matrix< Scalar > &x, const Sparsity &sp)
 
static Matrix< Scalar > kron (const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 
static Matrix< Scalar > mtimes (const Matrix< Scalar > &x, const Matrix< Scalar > &y, const std::string &blas="reference")
 
static Matrix< Scalar > mac (const Matrix< Scalar > &x, const Matrix< Scalar > &y, const Matrix< Scalar > &z, const std::string &blas="reference")
 
static void extract_parametric (const Matrix< Scalar > &expr, const Matrix< Scalar > &par, Matrix< Scalar > &expr_ret, std::vector< Matrix< Scalar > > &symbols, std::vector< Matrix< Scalar >> &parametric, const Dict &opts)
 
static void separate_linear (const Matrix< Scalar > &expr, const Matrix< Scalar > &sym_lin, const Matrix< Scalar > &sym_const, Matrix< Scalar > &expr_const, Matrix< Scalar > &expr_lin, Matrix< Scalar > &expr_nonlin)
 
static Matrix< Scalar > sparsify (const Matrix< Scalar > &x, double tol=0)
 
static void expand (const Matrix< Scalar > &x, Matrix< Scalar > &weights, Matrix< Scalar > &terms)
 
static Matrix< Scalar > pw_const (const Matrix< Scalar > &t, const Matrix< Scalar > &tval, const Matrix< Scalar > &val)
 
static Matrix< Scalar > pw_lin (const Matrix< Scalar > &t, const Matrix< Scalar > &tval, const Matrix< Scalar > &val)
 
static Matrix< Scalar > heaviside (const Matrix< Scalar > &x)
 
static Matrix< Scalar > rectangle (const Matrix< Scalar > &x)
 
static Matrix< Scalar > triangle (const Matrix< Scalar > &x)
 
static Matrix< Scalar > ramp (const Matrix< Scalar > &x)
 
static Matrix< Scalar > gauss_quadrature (const Matrix< Scalar > &f, const Matrix< Scalar > &x, const Matrix< Scalar > &a, const Matrix< Scalar > &b, casadi_int order=5)
 
static Matrix< Scalar > gauss_quadrature (const Matrix< Scalar > &f, const Matrix< Scalar > &x, const Matrix< Scalar > &a, const Matrix< Scalar > &b, casadi_int order, const Matrix< Scalar > &w)
 
static std::vector< std::vector< Matrix< Scalar > > > forward (const std::vector< Matrix< Scalar > > &ex, const std::vector< Matrix< Scalar > > &arg, const std::vector< std::vector< Matrix< Scalar > > > &v, const Dict &opts=Dict())
 
static std::vector< std::vector< Matrix< Scalar > > > reverse (const std::vector< Matrix< Scalar > > &ex, const std::vector< Matrix< Scalar > > &arg, const std::vector< std::vector< Matrix< Scalar > > > &v, const Dict &opts=Dict())
 
static std::vector< bool > which_depends (const Matrix< Scalar > &expr, const Matrix< Scalar > &var, casadi_int order=1, bool tr=false)
 
static Matrix< Scalar > taylor (const Matrix< Scalar > &ex, const Matrix< Scalar > &x, const Matrix< Scalar > &a, casadi_int order)
 
static Matrix< Scalar > mtaylor (const Matrix< Scalar > &ex, const Matrix< Scalar > &x, const Matrix< Scalar > &a, casadi_int order)
 
static Matrix< Scalar > mtaylor (const Matrix< Scalar > &ex, const Matrix< Scalar > &x, const Matrix< Scalar > &a, casadi_int order, const std::vector< casadi_int > &order_contributions)
 
static Matrix< Scalar > poly_coeff (const Matrix< Scalar > &ex, const Matrix< Scalar > &x)
 
static Matrix< Scalar > poly_roots (const Matrix< Scalar > &p)
 
static Matrix< Scalar > eig_symbolic (const Matrix< Scalar > &m)
 
static Matrix< double > evalf (const Matrix< Scalar > &m)
 
static void qr_sparse (const Matrix< Scalar > &A, Matrix< Scalar > &V, Matrix< Scalar > &R, Matrix< Scalar > &beta, std::vector< casadi_int > &prinv, std::vector< casadi_int > &pc, bool amd=true)
 
static Matrix< Scalar > qr_solve (const Matrix< Scalar > &b, const Matrix< Scalar > &v, const Matrix< Scalar > &r, const Matrix< Scalar > &beta, const std::vector< casadi_int > &prinv, const std::vector< casadi_int > &pc, bool tr=false)
 
static void qr (const Matrix< Scalar > &A, Matrix< Scalar > &Q, Matrix< Scalar > &R)
 
static void ldl (const Matrix< Scalar > &A, Matrix< Scalar > &D, Matrix< Scalar > &LT, std::vector< casadi_int > &p, bool amd=true)
 
static Matrix< Scalar > ldl_solve (const Matrix< Scalar > &b, const Matrix< Scalar > &D, const Matrix< Scalar > &LT, const std::vector< casadi_int > &p)
 
static Matrix< Scalar > all (const Matrix< Scalar > &x)
 
static Matrix< Scalar > any (const Matrix< Scalar > &x)
 
static Matrix< Scalar > adj (const Matrix< Scalar > &x)
 
static Matrix< Scalar > minor (const Matrix< Scalar > &x, casadi_int i, casadi_int j)
 
static Matrix< Scalar > cofactor (const Matrix< Scalar > &A, casadi_int i, casadi_int j)
 
static Matrix< Scalar > chol (const Matrix< Scalar > &A)
 
static Matrix< Scalar > norm_inf_mul (const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 
static Matrix< Scalar > diagcat (const std::vector< Matrix< Scalar > > &A)
 
static Matrix< Scalar > triplet (const std::vector< casadi_int > &row, const std::vector< casadi_int > &col, const Matrix< Scalar > &d)
 Construct a sparse matrix from triplet form. More...
 
static Matrix< Scalar > triplet (const std::vector< casadi_int > &row, const std::vector< casadi_int > &col, const Matrix< Scalar > &d, casadi_int nrow, casadi_int ncol)
 Construct a sparse matrix from triplet form. More...
 
static Matrix< Scalar > triplet (const std::vector< casadi_int > &row, const std::vector< casadi_int > &col, const Matrix< Scalar > &d, const std::pair< casadi_int, casadi_int > &rc)
 Construct a sparse matrix from triplet form. More...
 
static Matrix< Scalar > inf (const Sparsity &sp)
 create a matrix with all inf More...
 
static Matrix< Scalar > inf (casadi_int nrow=1, casadi_int ncol=1)
 create a matrix with all inf More...
 
static Matrix< Scalar > inf (const std::pair< casadi_int, casadi_int > &rc)
 create a matrix with all inf More...
 
static Matrix< Scalar > nan (const Sparsity &sp)
 create a matrix with all nan More...
 
static Matrix< Scalar > nan (casadi_int nrow=1, casadi_int ncol=1)
 create a matrix with all nan More...
 
static Matrix< Scalar > nan (const std::pair< casadi_int, casadi_int > &rc)
 create a matrix with all nan More...
 
static Matrix< Scalar > rand (casadi_int nrow=1, casadi_int ncol=1)
 Create a matrix with uniformly distributed random numbers. More...
 
static Matrix< Scalar > rand (const Sparsity &sp)
 Create a matrix with uniformly distributed random numbers. More...
 
static Matrix< Scalar > rand (const std::pair< casadi_int, casadi_int > &rc)
 Create a matrix with uniformly distributed random numbers. More...
 
static Matrix< Scalar > interp1d (const std::vector< double > &x, const Matrix< Scalar > &v, const std::vector< double > &xq, const std::string &mode, bool equidistant)
 Functions called by friend functions defined here. More...
 
static casadi_int sprank (const Matrix< Scalar > &x)
 Functions called by friend functions defined here. More...
 
static casadi_int norm_0_mul (const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 Functions called by friend functions defined here. More...
 
static Matrix< Scalar > tril (const Matrix< Scalar > &x, bool includeDiagonal=true)
 Functions called by friend functions defined here. More...
 
static Matrix< Scalar > triu (const Matrix< Scalar > &x, bool includeDiagonal=true)
 Functions called by friend functions defined here. More...
 
static Matrix< Scalar > sumsqr (const Matrix< Scalar > &x)
 Functions called by friend functions defined here. More...
 
static Matrix< Scalar > linspace (const Matrix< Scalar > &a, const Matrix< Scalar > &b, casadi_int nsteps)
 Functions called by friend functions defined here. More...
 
static Matrix< Scalar > cross (const Matrix< Scalar > &a, const Matrix< Scalar > &b, casadi_int dim=-1)
 Functions called by friend functions defined here. More...
 
static Matrix< Scalar > skew (const Matrix< Scalar > &a)
 Functions called by friend functions defined here. More...
 
static Matrix< Scalar > inv_skew (const Matrix< Scalar > &a)
 Functions called by friend functions defined here. More...
 
static Matrix< Scalar > tril2symm (const Matrix< Scalar > &x)
 Functions called by friend functions defined here. More...
 
static Matrix< Scalar > triu2symm (const Matrix< Scalar > &x)
 Functions called by friend functions defined here. More...
 
static Matrix< Scalar > repsum (const Matrix< Scalar > &x, casadi_int n, casadi_int m=1)
 Functions called by friend functions defined here. More...
 
static Matrix< Scalar > diff (const Matrix< Scalar > &x, casadi_int n=1, casadi_int axis=-1)
 Functions called by friend functions defined here. More...
 
static bool is_linear (const Matrix< Scalar > &expr, const Matrix< Scalar > &var)
 Functions called by friend functions defined here. More...
 
static bool is_quadratic (const Matrix< Scalar > &expr, const Matrix< Scalar > &var)
 Functions called by friend functions defined here. More...
 
static void quadratic_coeff (const Matrix< Scalar > &expr, const Matrix< Scalar > &var, Matrix< Scalar > &A, Matrix< Scalar > &b, Matrix< Scalar > &c, bool check)
 Functions called by friend functions defined here. More...
 
static void linear_coeff (const Matrix< Scalar > &expr, const Matrix< Scalar > &var, Matrix< Scalar > &A, Matrix< Scalar > &b, bool check)
 Functions called by friend functions defined here. More...
 
static Matrix< Scalar > mpower (const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 
static Matrix< Scalar > soc (const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 
static Matrix< Scalar > linearize (const Matrix< Scalar > &f, const Matrix< Scalar > &x, const Matrix< Scalar > &x0, const Dict &opts=Dict())
 
static Matrix< Scalar > gradient (const Matrix< Scalar > &ex, const Matrix< Scalar > &arg, const Dict &opts=Dict())
 
static Matrix< Scalar > tangent (const Matrix< Scalar > &ex, const Matrix< Scalar > &arg, const Dict &opts=Dict())
 
static Matrix< Scalar > jtimes (const Matrix< Scalar > &ex, const Matrix< Scalar > &arg, const Matrix< Scalar > &v, bool tr=false, const Dict &opts=Dict())
 
static Matrix< Scalar > bilin (const Matrix< Scalar > &A, const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 Calculate bilinear/quadratic form x^T A y. More...
 
static Matrix< Scalar > rank1 (const Matrix< Scalar > &A, const Matrix< Scalar > &alpha, const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 Make a rank-1 update to a matrix A. More...
 
Construct symbolic primitives

The "sym" function is intended to work in a similar way as "sym" used in the Symbolic Toolbox for Matlab but instead creating a CasADi symbolic primitive.

static Matrix< Scalar > sym (const std::string &name, casadi_int nrow=1, casadi_int ncol=1)
 Create an nrow-by-ncol symbolic primitive. More...
 
static Matrix< Scalar > sym (const std::string &name, const std::pair< casadi_int, casadi_int > &rc)
 Construct a symbolic primitive with given dimensions. More...
 
static Matrix< Scalar > sym (const std::string &name, const Sparsity &sp)
 Create symbolic primitive with a given sparsity pattern. More...
 
static std::vector< Matrix< Scalar > > sym (const std::string &name, const Sparsity &sp, casadi_int p)
 Create a vector of length p with with matrices. More...
 
static std::vector< Matrix< Scalar > > sym (const std::string &name, casadi_int nrow, casadi_int ncol, casadi_int p)
 Create a vector of length p with nrow-by-ncol symbolic primitives. More...
 
static std::vector< std::vector< Matrix< Scalar > > > sym (const std::string &name, const Sparsity &sp, casadi_int p, casadi_int r)
 Create a vector of length r of vectors of length p with. More...
 
static std::vector< std::vector< Matrix< Scalar > > > sym (const std::string &name, casadi_int nrow, casadi_int ncol, casadi_int p, casadi_int r)
 Create a vector of length r of vectors of length p. More...
 
static Matrix< Scalar > zeros (casadi_int nrow=1, casadi_int ncol=1)
 Create a dense matrix or a matrix with specified sparsity with all entries zero. More...
 
static Matrix< Scalar > zeros (const Sparsity &sp)
 Create a dense matrix or a matrix with specified sparsity with all entries zero. More...
 
static Matrix< Scalar > zeros (const std::pair< casadi_int, casadi_int > &rc)
 Create a dense matrix or a matrix with specified sparsity with all entries zero. More...
 
static Matrix< Scalar > ones (casadi_int nrow=1, casadi_int ncol=1)
 Create a dense matrix or a matrix with specified sparsity with all entries one. More...
 
static Matrix< Scalar > ones (const Sparsity &sp)
 Create a dense matrix or a matrix with specified sparsity with all entries one. More...
 
static Matrix< Scalar > ones (const std::pair< casadi_int, casadi_int > &rc)
 Create a dense matrix or a matrix with specified sparsity with all entries one. More...
 

Static Private Member Functions

static Matrix< Scalar > printme (const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 

Friends

Matrix< Scalar > adj (const Matrix< Scalar > &A)
 Matrix adjoint. More...
 
Matrix< Scalar > minor (const Matrix< Scalar > &x, casadi_int i, casadi_int j)
 Get the (i,j) minor matrix. More...
 
Matrix< Scalar > cofactor (const Matrix< Scalar > &x, casadi_int i, casadi_int j)
 Get the (i,j) cofactor matrix. More...
 
void qr (const Matrix< Scalar > &A, Matrix< Scalar > &Q, Matrix< Scalar > &R)
 QR factorization using the modified Gram-Schmidt algorithm. More...
 
void qr_sparse (const Matrix< Scalar > &A, Matrix< Scalar > &V, Matrix< Scalar > &R, Matrix< Scalar > &beta, std::vector< casadi_int > &prinv, std::vector< casadi_int > &pc, bool amd=true)
 Sparse direct QR factorization. More...
 
Matrix< Scalar > qr_solve (const Matrix< Scalar > &b, const Matrix< Scalar > &v, const Matrix< Scalar > &r, const Matrix< Scalar > &beta, const std::vector< casadi_int > &prinv, const std::vector< casadi_int > &pc, bool tr=false)
 Solve using a sparse QR factorization. More...
 
Matrix< Scalar > chol (const Matrix< Scalar > &A)
 Obtain a Cholesky factorisation of a matrix. More...
 
void ldl (const Matrix< Scalar > &A, Matrix< Scalar > &D, Matrix< Scalar > &LT, std::vector< casadi_int > &p, bool amd=true)
 Sparse LDL^T factorization. More...
 
Matrix< Scalar > ldl_solve (const Matrix< Scalar > &b, const Matrix< Scalar > &D, const Matrix< Scalar > &LT, const std::vector< casadi_int > &p)
 Solve using a sparse LDL^T factorization. More...
 
Matrix< Scalar > any (const Matrix< Scalar > &x)
 Returns true only if any element in the matrix is true. More...
 
Matrix< Scalar > all (const Matrix< Scalar > &x)
 Returns true only if every element in the matrix is true. More...
 
Matrix< Scalar > norm_inf_mul (const Matrix< Scalar > &x, const Matrix< Scalar > &y)
 Inf-norm of a Matrix-Matrix product. More...
 
Matrix< Scalar > sparsify (const Matrix< Scalar > &A, double tol=0)
 Make a matrix sparse by removing numerical zeros. More...
 
void expand (const Matrix< Scalar > &ex, Matrix< Scalar > &weights, Matrix< Scalar > &terms)
 Expand the expression as a weighted sum (with constant weights) More...
 
Matrix< Scalar > pw_const (const Matrix< Scalar > &t, const Matrix< Scalar > &tval, const Matrix< Scalar > &val)
 Create a piecewise constant function. More...
 
Matrix< Scalar > pw_lin (const Matrix< Scalar > &t, const Matrix< Scalar > &tval, const Matrix< Scalar > &val)
 t a scalar variable (e.g. time) More...
 
Matrix< Scalar > heaviside (const Matrix< Scalar > &x)
 Heaviside function. More...
 
Matrix< Scalar > rectangle (const Matrix< Scalar > &x)
 rectangle function More...
 
Matrix< Scalar > triangle (const Matrix< Scalar > &x)
 triangle function More...
 
Matrix< Scalar > ramp (const Matrix< Scalar > &x)
 ramp function More...
 
Matrix< Scalar > mtaylor (const Matrix< Scalar > &ex, const Matrix< Scalar > &x, const Matrix< Scalar > &a, casadi_int order=1)
 multivariate Taylor series expansion More...
 
Matrix< Scalar > mtaylor (const Matrix< Scalar > &ex, const Matrix< Scalar > &x, const Matrix< Scalar > &a, casadi_int order, const std::vector< casadi_int > &order_contributions)
 multivariate Taylor series expansion More...
 
Matrix< Scalar > poly_coeff (const Matrix< Scalar > &f, const Matrix< Scalar > &x)
 extracts polynomial coefficients from an expression More...
 
Matrix< Scalar > poly_roots (const Matrix< Scalar > &p)
 Attempts to find the roots of a polynomial. More...
 
Matrix< Scalar > eig_symbolic (const Matrix< Scalar > &m)
 Attempts to find the eigenvalues of a symbolic matrix. More...
 
Matrix< double > evalf (const Matrix< Scalar > &expr)
 Evaluates the expression numerically. More...
 
Matrix< Scalar > gauss_quadrature (const Matrix< Scalar > &f, const Matrix< Scalar > &x, const Matrix< Scalar > &a, const Matrix< Scalar > &b, casadi_int order=5)
 Integrate f from a to b using Gaussian quadrature with n points. More...
 
Matrix< Scalar > gauss_quadrature (const Matrix< Scalar > &f, const Matrix< Scalar > &x, const Matrix< Scalar > &a, const Matrix< Scalar > &b, casadi_int order, const Matrix< Scalar > &w)
 Integrate f from a to b using Gaussian quadrature with n points. More...
 
Matrix< Scalar > taylor (const Matrix< Scalar > &ex, const Matrix< Scalar > &x, const Matrix< Scalar > &a, casadi_int order=1)
 univariate Taylor series expansion More...
 
Matrix< Scalar > taylor (const Matrix< Scalar > &ex, const Matrix< Scalar > &x)
 univariate Taylor series expansion More...
 
Scalar * ptr ()
 
const Scalar * ptr () const
 
Scalar * get_ptr (Matrix< Scalar > &v)
 
const Scalar * get_ptr (const Matrix< Scalar > &v)
 

Member Typedef Documentation

◆ B

template<typename Scalar >
typedef GenericMatrix<Matrix<Scalar> > casadi::Matrix< Scalar >::B

Definition at line 193 of file matrix_decl.hpp.

◆ ScalarType

template<typename Scalar >
typedef Scalar casadi::Matrix< Scalar >::ScalarType

Definition at line 190 of file matrix_decl.hpp.

Constructor & Destructor Documentation

◆ Matrix() [1/14]

template<typename Scalar >
casadi::Matrix< Scalar >::Matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_18f empty 0-by-0 matrix constructor

Definition at line 586 of file matrix_impl.hpp.

586  : sparsity_(Sparsity(0, 0)) {
587  }

◆ Matrix() [2/14]

template<typename Scalar >
casadi::Matrix< Scalar >::Matrix ( const Matrix< Scalar > &  m)

Definition at line 590 of file matrix_impl.hpp.

590  : sparsity_(m.sparsity_), nonzeros_(m.nonzeros_) {
591  }

◆ Matrix() [3/14]

template<typename Scalar >
casadi::Matrix< Scalar >::Matrix ( casadi_int  nrow,
casadi_int  ncol 
)

◆ Matrix() [4/14]

template<typename Scalar >
casadi::Matrix< Scalar >::Matrix ( const std::pair< casadi_int, casadi_int > &  rc)
explicit

◆ Matrix() [5/14]

template<typename Scalar >
casadi::Matrix< Scalar >::Matrix ( const Sparsity sp)
explicit

Same as Matrix::ones(sparsity)

Extra doc: https://github.com/casadi/casadi/wiki/L_18k

◆ Matrix() [6/14]

template<typename Scalar >
casadi::Matrix< Scalar >::Matrix ( const Sparsity sp,
const Matrix< Scalar > &  d 
)

◆ Matrix() [7/14]

template<typename Scalar >
casadi::Matrix< Scalar >::Matrix ( double  val)

◆ Matrix() [8/14]

template<typename Scalar >
casadi::Matrix< Scalar >::Matrix ( const std::vector< std::vector< double > > &  m)
explicit

◆ Matrix() [9/14]

template<typename Scalar >
template<typename A >
casadi::Matrix< Scalar >::Matrix ( const std::vector< A > &  x)
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_18m

Definition at line 161 of file matrix_decl.hpp.

161  : sparsity_(Sparsity::dense(x.size(), 1)),
162  nonzeros_(std::vector<Scalar>(x.size())) {
163  auto x_it = x.begin();
164  for (auto&& d : nonzeros_) d = static_cast<Scalar>(*x_it++);
165  }
static Sparsity dense(casadi_int nrow, casadi_int ncol=1)
Create a dense rectangular sparsity pattern *.
Definition: sparsity.cpp:1028

◆ Matrix() [10/14]

template<typename Scalar >
template<typename A >
casadi::Matrix< Scalar >::Matrix ( const Matrix< A > &  x)
inline

Assumes that the scalar conversion is valid.

Extra doc: https://github.com/casadi/casadi/wiki/L_18n

Definition at line 174 of file matrix_decl.hpp.

174  : sparsity_(x.sparsity()), nonzeros_(std::vector<Scalar>(x.nnz())) {
175  auto x_it = x->begin();
176  for (auto&& d : nonzeros_) d = static_cast<Scalar>(*x_it++);
177  }

◆ Matrix() [11/14]

template<typename Scalar >
casadi::Matrix< Scalar >::Matrix ( const std::vector< Scalar > &  x)

Definition at line 594 of file matrix_impl.hpp.

594  :
595  sparsity_(Sparsity::dense(x.size(), 1)), nonzeros_(x) {
596  }

◆ Matrix() [12/14]

template<typename Scalar >
casadi::Matrix< Scalar >::Matrix ( std::initializer_list< Scalar >  x)
inline

Definition at line 184 of file matrix_decl.hpp.

184 : Matrix<Scalar>(std::vector<Scalar>(x)) {}

◆ Matrix() [13/14]

template<typename Scalar >
casadi::Matrix< Scalar >::Matrix ( const Sparsity sp,
const Scalar &  val,
bool  dummy 
)

◆ Matrix() [14/14]

template<typename Scalar >
casadi::Matrix< Scalar >::Matrix ( const Sparsity sp,
const std::vector< Scalar > &  d,
bool  dummy 
)

Member Function Documentation

◆ __nonzero__()

bool CASADI_EXPORT casadi::SX::__nonzero__

Definition at line 80 of file matrix_impl.hpp.

80  {
81  if (numel()!=1) {
82  casadi_error("Only scalar Matrix could have a truth value, but you "
83  "provided a shape" + dim());
84  }
85  return nonzeros().at(0)!=0;
86  }
casadi_int numel() const
Get the number of elements.
std::string dim(bool with_nz=false) const
Get string representation of dimensions.
std::vector< Scalar > & nonzeros()

◆ _bilin()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::_bilin ( const Matrix< Scalar > &  A,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
static

Functions called by friend functions defined for GenericMatrix

◆ _logsumexp()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::_logsumexp ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ _rank1()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::_rank1 ( const Matrix< Scalar > &  A,
const Matrix< Scalar > &  alpha,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
static

Functions called by friend functions defined for GenericMatrix

◆ _sym()

SX CASADI_EXPORT casadi::SX::_sym ( const std::string &  name,
const Sparsity sp 
)
static

Definition at line 54 of file sx_instantiator.cpp.

54  {
55  // Create a dense n-by-m matrix
56  std::vector<SXElem> retv;
57 
58  // Check if individial names have been provided
59  if (name[0]=='[') {
60 
61  // Make a copy of the string and modify it as to remove the special characters
62  std::string modname = name;
63  for (std::string::iterator it=modname.begin(); it!=modname.end(); ++it) {
64  switch (*it) {
65  case '(': case ')': case '[': case ']': case '{': case '}': case ',': case ';': *it = ' ';
66  }
67  }
68 
69  std::istringstream iss(modname);
70  std::string varname;
71 
72  // Loop over elements
73  while (!iss.fail()) {
74  // Read the name
75  iss >> varname;
76 
77  // Append to the return vector
78  if (!iss.fail())
79  retv.push_back(SXElem::sym(varname));
80  }
81  } else if (sp.is_scalar(true)) {
82  retv.push_back(SXElem::sym(name));
83  } else {
84  // Scalar
85  std::stringstream ss;
86  for (casadi_int k=0; k<sp.nnz(); ++k) {
87  ss.str("");
88  ss << name << "_" << k;
89  retv.push_back(SXElem::sym(ss.str()));
90  }
91  }
92 
93  // Determine dimensions automatically if empty
94  if (sp.is_scalar(true)) {
95  return SX(retv);
96  } else {
97  return SX(sp, retv, false);
98  }
99  }
std::string name() const
Get name (only if symbolic scalar)
static SXElem sym(const std::string &name)
Create a symbolic primitive.
Definition: sx_elem.cpp:94
Matrix< SXElem > SX
Definition: sx_fwd.hpp:32

References casadi::Sparsity::is_scalar(), casadi::Matrix< Scalar >::name(), casadi::Sparsity::nnz(), and casadi::SXElem::sym().

◆ adj()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::adj ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined here

◆ all()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::all ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined here

◆ any()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::any ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined here

◆ bilin()

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::bilin ( const Matrix< Scalar > &  A,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
staticinherited
Parameters
[in]ycan be omitted, in which case x^T A x is calculated

Extra doc: https://github.com/casadi/casadi/wiki/L_1bo

◆ binary()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::binary ( casadi_int  op,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
static

◆ blockcat()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::blockcat ( const std::vector< std::vector< Matrix< Scalar > > > &  v)
static

Functions called by friend functions defined for SparsityInterface

◆ call() [1/2]

template<typename Scalar >
static std::vector< Matrix<Scalar> > casadi::Matrix< Scalar >::call ( const Function f,
const std::vector< Matrix< Scalar > > &  x 
)
static

◆ call() [2/2]

template<typename Scalar >
static std::vector< Scalar > casadi::Matrix< Scalar >::call ( const Function f,
const std::vector< Scalar > &  x 
)
static

◆ chol()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::chol ( const Matrix< Scalar > &  A)
static

Functions called by friend functions defined here

◆ clear()

template<typename Scalar >
void casadi::Matrix< Scalar >::clear ( )

◆ cofactor()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::cofactor ( const Matrix< Scalar > &  A,
casadi_int  i,
casadi_int  j 
)
static

Functions called by friend functions defined here

◆ colind() [1/2]

const casadi_int* casadi::GenericMatrix< Matrix< Scalar > >::colind ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b8

Definition at line 198 of file generic_matrix.hpp.

198 { return sparsity().colind(); }
Sparsity sparsity() const
Get the sparsity pattern.
const casadi_int * colind() const
Get a reference to the colindex of all column element (see class description)
Definition: sparsity.cpp:168

◆ colind() [2/2]

casadi_int casadi::GenericMatrix< Matrix< Scalar > >::colind ( casadi_int  col) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b8

Definition at line 201 of file generic_matrix.hpp.

201 { return sparsity().colind(col); }

◆ columns()

casadi_int casadi::GenericMatrix< Matrix< Scalar > >::columns ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1av

Definition at line 124 of file generic_matrix.hpp.

124 {return size2();}
casadi_int size2() const
Get the second dimension (i.e. number of columns)

◆ conditional()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::conditional ( const Matrix< Scalar > &  ind,
const std::vector< Matrix< Scalar > > &  x,
const Matrix< Scalar > &  x_default,
bool  short_circuit = false 
)
static

Functions called by friend functions defined for GenericMatrix

◆ contains()

template<typename Scalar >
static bool casadi::Matrix< Scalar >::contains ( const std::vector< Matrix< Scalar > > &  v,
const Matrix< Scalar > &  n 
)
static

Functions called by friend functions defined for GenericMatrix

◆ contains_all()

template<typename Scalar >
static bool casadi::Matrix< Scalar >::contains_all ( const std::vector< Matrix< Scalar > > &  v,
const std::vector< Matrix< Scalar > > &  n 
)
static

Functions called by friend functions defined for GenericMatrix

◆ contains_any()

template<typename Scalar >
static bool casadi::Matrix< Scalar >::contains_any ( const std::vector< Matrix< Scalar > > &  v,
const std::vector< Matrix< Scalar > > &  n 
)
static

Functions called by friend functions defined for GenericMatrix

◆ cross()

Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::cross ( const Matrix< Scalar > &  a,
const Matrix< Scalar > &  b,
casadi_int  dim = -1 
)
staticinherited

Definition at line 227 of file generic_matrix.hpp.

1421  {
1422  casadi_assert(a.size1()==b.size1() && a.size2()==b.size2(),
1423  "cross(a, b): Inconsistent dimensions. Dimension of a ("
1424  + a.dim() + " ) must equal that of b (" + b.dim() + ").");
1425 
1426  casadi_assert(a.size1()==3 || a.size2()==3,
1427  "cross(a, b): One of the dimensions of a should have length 3, but got "
1428  + a.dim() + ".");
1429  casadi_assert(dim==-1 || dim==1 || dim==2,
1430  "cross(a, b, dim): Dim must be 1, 2 or -1 (automatic).");
1431 
1432  std::vector<MatType> ret(3);
1433 
1434  bool t = a.size1()==3;
1435 
1436  if (dim==1) t = true;
1437  if (dim==2) t = false;
1438 
1439  MatType a1 = t ? a(0, Slice()) : a(Slice(), 0);
1440  MatType a2 = t ? a(1, Slice()) : a(Slice(), 1);
1441  MatType a3 = t ? a(2, Slice()) : a(Slice(), 2);
1442 
1443  MatType b1 = t ? b(0, Slice()) : b(Slice(), 0);
1444  MatType b2 = t ? b(1, Slice()) : b(Slice(), 1);
1445  MatType b3 = t ? b(2, Slice()) : b(Slice(), 2);
1446 
1447  ret[0] = a2*b3-a3*b2;
1448  ret[1] = a3*b1-a1*b3;
1449  ret[2] = a1*b2-a2*b1;
1450 
1451  return t ? vertcat(ret) : horzcat(ret);
1452  }
friend MatType vertcat(const std::vector< MatType > &v)
Concatenate a list of matrices vertically.
friend MatType horzcat(const std::vector< MatType > &v)
Concatenate a list of matrices horizontally.

◆ cse()

template<typename Scalar >
static std::vector< Matrix<Scalar> > casadi::Matrix< Scalar >::cse ( const std::vector< Matrix< Scalar > > &  e)
static

Functions called by friend functions defined for GenericMatrix

◆ cumsum()

template<typename Scalar >
Matrix< Scalar > casadi::Matrix< Scalar >::cumsum ( const Matrix< Scalar > &  x,
casadi_int  axis = -1 
)
static

Functions called by friend functions defined for GenericMatrix

Definition at line 537 of file matrix_impl.hpp.

537  {
538  if (axis==-1) axis = x.is_row();
539  Matrix<Scalar> ret = x;
540  if (axis==0) {
541  for (casadi_int i=1;i<x.size1();++i)
542  ret(i, Slice()) += ret(i-1, Slice());
543  } else {
544  for (casadi_int i=1;i<x.size2();++i)
545  ret(Slice(), i) += ret(Slice(), i-1);
546  }
547  return ret;
548  }

References casadi::GenericMatrix< MatType >::is_row(), casadi::GenericMatrix< MatType >::size1(), and casadi::GenericMatrix< MatType >::size2().

◆ densify() [1/2]

template<typename Scalar >
Matrix< Scalar > casadi::Matrix< Scalar >::densify ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

Definition at line 502 of file matrix_impl.hpp.

502  {
503  return densify(x, 0);
504  }
static Matrix< Scalar > densify(const Matrix< Scalar > &x, const Matrix< Scalar > &val)

◆ densify() [2/2]

template<typename Scalar >
Matrix< Scalar > casadi::Matrix< Scalar >::densify ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  val 
)
static

Functions called by friend functions defined for GenericMatrix

Definition at line 507 of file matrix_impl.hpp.

508  {
509  // Check argument
510  casadi_assert_dev(val.is_scalar());
511 
512  // Quick return if possible
513  if (x.is_dense()) return x;
514 
515  // Get sparsity pattern
516  casadi_int nrow = x.size1();
517  casadi_int ncol = x.size2();
518  const casadi_int* colind = x.colind();
519  const casadi_int* row = x.row();
520  auto it = x.nonzeros().cbegin();
521 
522  // New data vector
523  std::vector<Scalar> d(nrow*ncol, val.scalar());
524 
525  // Copy nonzeros
526  for (casadi_int cc=0; cc<ncol; ++cc) {
527  for (casadi_int el=colind[cc]; el<colind[cc+1]; ++el) {
528  d[cc*nrow + row[el]] = *it++;
529  }
530  }
531 
532  // Construct return matrix
533  return Matrix<Scalar>(Sparsity::dense(x.size()), d);
534  }

References casadi::GenericMatrix< MatType >::colind(), casadi::Sparsity::dense(), casadi::GenericMatrix< MatType >::is_dense(), casadi::GenericMatrix< MatType >::is_scalar(), casadi::Matrix< Scalar >::nonzeros(), casadi::GenericMatrix< MatType >::row(), casadi::Matrix< Scalar >::scalar(), casadi::GenericMatrix< MatType >::size(), casadi::GenericMatrix< MatType >::size1(), and casadi::GenericMatrix< MatType >::size2().

◆ dep()

SX CASADI_EXPORT casadi::SX::dep ( casadi_int  ch = 0) const

Only defined if symbolic scalar. Wraps SXElem SXElem::dep(casadi_int ch=0) const.

Extra doc: https://github.com/casadi/casadi/wiki/L_1a9

Definition at line 225 of file sx_instantiator.cpp.

225  {
226  return scalar().dep(ch);
227  }
const Scalar scalar() const
Convert to scalar type.

References casadi::Matrix< Scalar >::scalar().

◆ depends_on()

template<typename Scalar >
static bool casadi::Matrix< Scalar >::depends_on ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  arg 
)
static

Functions called by friend functions defined for GenericMatrix

◆ deserialize() [1/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::deserialize ( const std::string &  s)
static

◆ deserialize() [2/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::deserialize ( DeserializingStream s)
static

◆ deserialize() [3/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::deserialize ( std::istream &  stream)
static

◆ det() [1/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::det ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ det() [2/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::det ( const Matrix< Scalar > &  x,
const std::string &  lsolver,
const Dict dict = Dict() 
)
static

Functions called by friend functions defined for GenericMatrix

◆ diag()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::diag ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ diagcat()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::diagcat ( const std::vector< Matrix< Scalar > > &  A)
static

Functions called by friend functions defined here

◆ diagsplit()

template<typename Scalar >
static std::vector< Matrix<Scalar> > casadi::Matrix< Scalar >::diagsplit ( const Matrix< Scalar > &  x,
const std::vector< casadi_int > &  offset1,
const std::vector< casadi_int > &  offset2 
)
static

Functions called by friend functions defined for SparsityInterface

◆ diff()

Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::diff ( const Matrix< Scalar > &  x,
casadi_int  n = 1,
casadi_int  axis = -1 
)
staticinherited

Definition at line 233 of file generic_matrix.hpp.

1801  {
1802  casadi_assert(axis==-1 || axis==0 || axis==1, "Axis argument invalid");
1803  casadi_assert(n>=1, "n argument invalid");
1804 
1805  MatType ret = x;
1806  for (casadi_int i=0;i<n;++i) {
1807  // Matlab's special case
1808  if (axis==-1 && ret.is_scalar()) return MatType();
1809 
1810  casadi_int local_axis = (axis==-1) ? ret.is_row() : axis;
1811  if (local_axis==0) {
1812  if (ret.size1()<=1) {
1813  ret = MatType::zeros(0, ret.size2());
1814  } else {
1815  ret = ret(Slice(1, ret.size1()), Slice())-ret(Slice(0, ret.size1()-1), Slice());
1816  }
1817  } else {
1818  if (ret.size2()<=1) {
1819  ret = MatType::zeros(ret.size1(), 0);
1820  } else {
1821  ret = ret(Slice(), Slice(1, ret.size2()))-ret(Slice(), Slice(0, ret.size2()-1));
1822  }
1823  }
1824  }
1825  return ret;
1826  }

◆ dim()

std::string casadi::GenericMatrix< Matrix< Scalar > >::dim ( bool  with_nz = false) const
inherited

The representation is e.g. "4x5" or "4x5,10nz"

Extra doc: https://github.com/casadi/casadi/wiki/L_1aw

Definition at line 131 of file generic_matrix.hpp.

1370  {
1371  return sparsity().dim(with_nz);
1372  }
std::string dim(bool with_nz=false) const
Get the dimension as a string.
Definition: sparsity.cpp:588

◆ disp()

template<typename Scalar >
void casadi::Matrix< Scalar >::disp ( std::ostream &  stream,
bool  more = false 
) const

◆ dot()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::dot ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
static

Functions called by friend functions defined for GenericMatrix

◆ eig_symbolic()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::eig_symbolic ( const Matrix< Scalar > &  m)
static

Functions called by friend functions defined here

◆ einstein() [1/2]

template<typename Scalar >
Matrix< Scalar > casadi::Matrix< Scalar >::einstein ( const Matrix< Scalar > &  A,
const Matrix< Scalar > &  B,
const Matrix< Scalar > &  C,
const std::vector< casadi_int > &  dim_a,
const std::vector< casadi_int > &  dim_b,
const std::vector< casadi_int > &  dim_c,
const std::vector< casadi_int > &  a,
const std::vector< casadi_int > &  b,
const std::vector< casadi_int > &  c 
)
static

Functions called by friend functions defined for GenericMatrix

Definition at line 551 of file matrix_impl.hpp.

556  {
557  std::vector<casadi_int> iter_dims;
558  std::vector<casadi_int> strides_a;
559  std::vector<casadi_int> strides_b;
560  std::vector<casadi_int> strides_c;
561  casadi_int n_iter = einstein_process(A, B, C, dim_a, dim_b, dim_c, a, b, c,
562  iter_dims, strides_a, strides_b, strides_c);
563 
564  const std::vector<Scalar>& Av = A.nonzeros();
565  const std::vector<Scalar>& Bv = B.nonzeros();
566 
567  Matrix<Scalar> ret = C;
568  std::vector<Scalar>& Cv = ret.nonzeros();
569 
570  einstein_eval(n_iter, iter_dims, strides_a, strides_b, strides_c,
571  get_ptr(Av), get_ptr(Bv), get_ptr(Cv));
572  return ret;
573  }
friend Scalar * get_ptr(Matrix< Scalar > &v)
GenericMatrix< Matrix< Scalar > > B
Base class.
void einstein_eval(casadi_int n_iter, const std::vector< casadi_int > &iter_dims, const std::vector< casadi_int > &strides_a, const std::vector< casadi_int > &strides_b, const std::vector< casadi_int > &strides_c, const T *a_in, const T *b_in, T *c_in)
Definition: shared.hpp:161
casadi_int einstein_process(const T &A, const T &B, const T &C, const std::vector< casadi_int > &dim_a, const std::vector< casadi_int > &dim_b, const std::vector< casadi_int > &dim_c, const std::vector< casadi_int > &a, const std::vector< casadi_int > &b, const std::vector< casadi_int > &c, std::vector< casadi_int > &iter_dims, std::vector< casadi_int > &strides_a, std::vector< casadi_int > &strides_b, std::vector< casadi_int > &strides_c)
Definition: shared.hpp:35

References casadi::C, casadi::einstein_eval(), casadi::einstein_process(), casadi::get_ptr(), and casadi::Matrix< Scalar >::nonzeros().

Referenced by casadi::Matrix< Scalar >::einstein().

◆ einstein() [2/2]

template<typename Scalar >
Matrix< Scalar > casadi::Matrix< Scalar >::einstein ( const Matrix< Scalar > &  A,
const Matrix< Scalar > &  B,
const std::vector< casadi_int > &  dim_a,
const std::vector< casadi_int > &  dim_b,
const std::vector< casadi_int > &  dim_c,
const std::vector< casadi_int > &  a,
const std::vector< casadi_int > &  b,
const std::vector< casadi_int > &  c 
)
static

Functions called by friend functions defined for GenericMatrix

Definition at line 576 of file matrix_impl.hpp.

580  {
582  dim_a, dim_b, dim_c, a, b, c);
583  }
static Matrix< Scalar > zeros(casadi_int nrow=1, casadi_int ncol=1)
Create a dense matrix or a matrix with specified sparsity with all entries zero.
static Matrix< Scalar > einstein(const Matrix< Scalar > &A, const Matrix< Scalar > &B, const Matrix< Scalar > &C, const std::vector< casadi_int > &dim_a, const std::vector< casadi_int > &dim_b, const std::vector< casadi_int > &dim_c, const std::vector< casadi_int > &a, const std::vector< casadi_int > &b, const std::vector< casadi_int > &c)
T product(const std::vector< T > &values)
product

References casadi::Matrix< Scalar >::einstein(), and casadi::product().

◆ element_hash()

casadi_int CASADI_EXPORT casadi::SX::element_hash

Only defined if symbolic scalar.

Extra doc: https://github.com/casadi/casadi/wiki/L_19n

Definition at line 128 of file sx_instantiator.cpp.

128  {
129  return scalar().__hash__();
130  }

References casadi::Matrix< Scalar >::scalar().

◆ enlarge()

template<typename Scalar >
void casadi::Matrix< Scalar >::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

Extra doc: https://github.com/casadi/casadi/wiki/L_19i

◆ erase() [1/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::erase ( const std::vector< casadi_int > &  rr,
bool  ind1 = false 
)

Erase elements of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_19g

◆ erase() [2/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::erase ( const std::vector< casadi_int > &  rr,
const std::vector< casadi_int > &  cc,
bool  ind1 = false 
)

Erase rows and/or columns of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_19f

◆ evalf()

template<typename Scalar >
static Matrix<double> casadi::Matrix< Scalar >::evalf ( const Matrix< Scalar > &  m)
static

Functions called by friend functions defined here

◆ expand()

template<typename Scalar >
static void casadi::Matrix< Scalar >::expand ( const Matrix< Scalar > &  x,
Matrix< Scalar > &  weights,
Matrix< Scalar > &  terms 
)
static

Functions called by friend functions defined here

◆ expm()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::expm ( const Matrix< Scalar > &  A)
static

Functions called by friend functions defined for GenericMatrix

◆ expm_const()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::expm_const ( const Matrix< Scalar > &  A,
const Matrix< Scalar > &  t 
)
static

Functions called by friend functions defined for GenericMatrix

◆ export_code()

template<typename Scalar >
void casadi::Matrix< Scalar >::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: 'm')
*   indent_level: Level of indentation (default: 0)
*   spoof_zero: Replace numerical zero by a 1e-200 (default: false)
*               might be needed for matlab sparse construct,
*               which doesn't allow numerical zero
* 

Extra doc: https://github.com/casadi/casadi/wiki/L_1ac

Referenced by casadi::MXFunction::export_code_body().

◆ extract()

template<typename Scalar >
static void casadi::Matrix< Scalar >::extract ( std::vector< Matrix< Scalar >> &  ex,
std::vector< Matrix< Scalar >> &  v,
std::vector< Matrix< Scalar >> &  vdef,
const Dict opts = Dict() 
)
static

Functions called by friend functions defined for GenericMatrix

◆ extract_parametric()

template<typename Scalar >
static void casadi::Matrix< Scalar >::extract_parametric ( const Matrix< Scalar > &  expr,
const Matrix< Scalar > &  par,
Matrix< Scalar > &  expr_ret,
std::vector< Matrix< Scalar > > &  symbols,
std::vector< Matrix< Scalar >> &  parametric,
const Dict opts 
)
static

Functions called by friend functions defined for SparsityInterface

◆ eye()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::eye ( casadi_int  n)
static

◆ forward()

template<typename Scalar >
static std::vector<std::vector<Matrix<Scalar> > > casadi::Matrix< Scalar >::forward ( const std::vector< Matrix< Scalar > > &  ex,
const std::vector< Matrix< Scalar > > &  arg,
const std::vector< std::vector< Matrix< Scalar > > > &  v,
const Dict opts = Dict() 
)
static

Functions called by friend functions defined here

◆ from_file()

template<typename Scalar >
static Matrix<double> casadi::Matrix< Scalar >::from_file ( const std::string &  filename,
const std::string &  format_hint = "" 
)
static

◆ gauss_quadrature() [1/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::gauss_quadrature ( const Matrix< Scalar > &  f,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  a,
const Matrix< Scalar > &  b,
casadi_int  order,
const Matrix< Scalar > &  w 
)
static

Functions called by friend functions defined here

◆ gauss_quadrature() [2/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::gauss_quadrature ( const Matrix< Scalar > &  f,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  a,
const Matrix< Scalar > &  b,
casadi_int  order = 5 
)
static

Functions called by friend functions defined here

◆ get() [1/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::get ( Matrix< Scalar > &  m,
bool  ind1,
const Matrix< casadi_int > &  rr 
) const

Get a submatrix, single argument

Definition at line 162 of file matrix_impl.hpp.

162  {
163  // Scalar
164  if (rr.is_scalar(true)) {
165  return get(m, ind1, to_slice(rr, ind1));
166  }
167 
168  // If the indexed matrix is dense, use nonzero indexing
169  if (is_dense()) {
170  return get_nz(m, ind1, rr);
171  }
172 
173  // Get the sparsity pattern - does bounds checking
174  std::vector<casadi_int> mapping;
175  Sparsity sp = sparsity().sub(rr.nonzeros(), rr.sparsity(), mapping, ind1);
176 
177  // If indexed matrix was a row/column vector, make sure that the result is too
178  bool tr = (is_column() && rr.is_row()) || (is_row() && rr.is_column());
179 
180  // Copy nonzeros
181  m = Matrix<Scalar>::zeros(tr ? sp.T() : sp);
182  for (casadi_int k=0; k<mapping.size(); ++k) m->at(k) = nonzeros().at(mapping[k]);
183  }
bool is_dense() const
Check if the matrix expression is dense.
bool is_column() const
Check if the matrix is a column vector (i.e. size2()==1)
bool is_row() const
Check if the matrix is a row vector (i.e. size1()==1)
bool is_scalar(bool scalar_and_dense=false) const
Check if the matrix expression is scalar.
void get(Matrix< Scalar > &m, bool ind1, const Slice &rr) const
const Sparsity & sparsity() const
Const access the sparsity - reference to data member.
void get_nz(Matrix< Scalar > &m, bool ind1, const Slice &k) const
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.
Definition: sparsity.cpp:334
Slice CASADI_EXPORT to_slice(const IM &x, bool ind1=false)
Convert IM to Slice.

References casadi::GenericMatrix< MatType >::is_column(), casadi::GenericMatrix< MatType >::is_row(), casadi::GenericMatrix< MatType >::is_scalar(), casadi::Matrix< Scalar >::nonzeros(), casadi::Matrix< Scalar >::sparsity(), casadi::Sparsity::sub(), and casadi::to_slice().

◆ get() [2/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::get ( Matrix< Scalar > &  m,
bool  ind1,
const Matrix< casadi_int > &  rr,
const Matrix< casadi_int > &  cc 
) const

Get a submatrix, two arguments

Definition at line 121 of file matrix_impl.hpp.

122  {
123  // Scalar
124  if (rr.is_scalar(true) && cc.is_scalar(true)) {
125  return get(m, ind1, to_slice(rr, ind1), to_slice(cc, ind1));
126  }
127 
128  // Make sure dense vectors
129  casadi_assert(rr.is_dense() && rr.is_vector(),
130  "Marix::get: First index must be a dense vector");
131  casadi_assert(cc.is_dense() && cc.is_vector(),
132  "Marix::get: Second index must be a dense vector");
133 
134  // Get the sparsity pattern - does bounds checking
135  std::vector<casadi_int> mapping;
136  Sparsity sp = sparsity().sub(rr.nonzeros(), cc.nonzeros(), mapping, ind1);
137 
138  // Copy nonzeros
139  m = Matrix<Scalar>::zeros(sp);
140  for (casadi_int k=0; k<mapping.size(); ++k) m->at(k) = nonzeros().at(mapping[k]);
141  }
bool is_vector() const
Check if the matrix is a row or column vector.

References casadi::GenericMatrix< MatType >::is_dense(), casadi::GenericMatrix< MatType >::is_scalar(), casadi::GenericMatrix< MatType >::is_vector(), and casadi::to_slice().

◆ get() [3/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::get ( Matrix< Scalar > &  m,
bool  ind1,
const Matrix< casadi_int > &  rr,
const Slice cc 
) const

Get a submatrix, two arguments

Definition at line 114 of file matrix_impl.hpp.

115  {
116  // Fall back on IM-IM
117  get(m, ind1, rr, cc.all(size2(), ind1));
118  }

References casadi::Slice::all().

◆ get() [4/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::get ( Matrix< Scalar > &  m,
bool  ind1,
const Slice rr 
) const

Get a submatrix, single argument

Definition at line 144 of file matrix_impl.hpp.

144  {
145  // Scalar
146  if (rr.is_scalar(numel())) {
147  casadi_int r = rr.scalar(numel());
148  casadi_int k = sparsity().get_nz(r % size1(), r / size1());
149  if (k>=0) {
150  m = nonzeros().at(k);
151  } else {
152  m = Matrix<Scalar>(1, 1);
153  }
154  return;
155  }
156 
157  // Fall back on IM
158  get(m, ind1, rr.all(numel(), ind1));
159  }
casadi_int size1() const
Get the first dimension (i.e. number of rows)
casadi_int get_nz(casadi_int rr, casadi_int cc) const
Get the index of an existing non-zero element.
Definition: sparsity.cpp:246

References casadi::Slice::all(), casadi::Slice::is_scalar(), and casadi::Slice::scalar().

◆ get() [5/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::get ( Matrix< Scalar > &  m,
bool  ind1,
const Slice rr,
const Matrix< casadi_int > &  cc 
) const

Get a submatrix, two arguments

Definition at line 107 of file matrix_impl.hpp.

108  {
109  // Fall back on IM-IM
110  get(m, ind1, rr.all(size1(), ind1), cc);
111  }

◆ get() [6/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::get ( Matrix< Scalar > &  m,
bool  ind1,
const Slice rr,
const Slice cc 
) const

Get a submatrix, two arguments

Definition at line 89 of file matrix_impl.hpp.

90  {
91  // Both are scalar
92  if (rr.is_scalar(size1()) && cc.is_scalar(size2())) {
93  casadi_int k = sparsity().get_nz(rr.scalar(size1()), cc.scalar(size2()));
94  if (k>=0) {
95  m = nonzeros().at(k);
96  } else {
97  m = Matrix<Scalar>(1, 1);
98  }
99  return;
100  }
101 
102  // Fall back on IM-IM
103  get(m, ind1, rr.all(size1(), ind1), cc.all(size2(), ind1));
104  }

References casadi::Slice::all(), casadi::Slice::is_scalar(), and casadi::Slice::scalar().

◆ get() [7/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::get ( Matrix< Scalar > &  m,
bool  ind1,
const Sparsity sp 
) const

Get a submatrix, single argument

Definition at line 186 of file matrix_impl.hpp.

186  {
187  casadi_assert(size()==sp.size(),
188  "Shape mismatch. This matrix has shape "
189  + str(size()) + ", but supplied sparsity index has shape "
190  + str(sp.size()) + ".");
191  m = project(*this, sp);
192  }
std::pair< casadi_int, casadi_int > size() const
Get the shape.
static Matrix< Scalar > project(const Matrix< Scalar > &x, const Sparsity &sp, bool intersect=false)
std::string str(const T &v)
String representation, any type.

References casadi::Sparsity::size(), and casadi::str().

◆ get_colind()

std::vector<casadi_int> casadi::GenericMatrix< Matrix< Scalar > >::get_colind ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b8

Definition at line 195 of file generic_matrix.hpp.

195 { return sparsity().get_colind(); }
std::vector< casadi_int > get_colind() const
Get the column index for each column.
Definition: sparsity.cpp:364

◆ get_elements()

template<typename Scalar >
std::vector<Scalar> casadi::Matrix< Scalar >::get_elements ( ) const

◆ get_free()

std::vector< SX > CASADI_EXPORT casadi::SX::get_free ( const Function f)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_19e

Definition at line 1640 of file sx_instantiator.cpp.

1640  {
1641  return f.free_sx();
1642  }

References casadi::Function::free_sx().

◆ get_input()

std::vector< SX > CASADI_EXPORT casadi::SX::get_input ( const Function f)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_19d

Definition at line 1636 of file sx_instantiator.cpp.

1636  {
1637  return f.sx_in();
1638  }

References casadi::Function::sx_in().

◆ get_max_depth()

casadi_int CASADI_EXPORT casadi::SX::get_max_depth
static

Extra doc: https://github.com/casadi/casadi/wiki/L_19c

Definition at line 49 of file sx_instantiator.cpp.

49  {
50  return SXNode::eq_depth_;
51  }
static casadi_int eq_depth_
Definition: sx_node.hpp:181

References casadi::SXNode::eq_depth_.

◆ get_nonzeros() [1/2]

template<typename Scalar >
std::vector< A > casadi::Matrix< Scalar >::get_nonzeros ( ) const

Implementation of Matrix::get_nonzeros (in public API)

Extra doc: https://github.com/casadi/casadi/wiki/L_1a2

Definition at line 1457 of file matrix_decl.hpp.

1457  {
1458  std::vector<A> ret(nnz());
1459  auto r = ret.begin();
1460  for (auto&& e : nonzeros()) *r++ = static_cast<A>(e);
1461  return ret;
1462  }
casadi_int nnz() const
Get the number of (structural) non-zero elements.

◆ get_nonzeros() [2/2]

template<typename Scalar >
template<typename A >
std::vector<A> casadi::Matrix< Scalar >::get_nonzeros ( ) const

◆ get_nz() [1/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::get_nz ( Matrix< Scalar > &  m,
bool  ind1,
const Matrix< casadi_int > &  k 
) const

Get a set of nonzeros

Definition at line 416 of file matrix_impl.hpp.

416  {
417  // Scalar
418  if (kk.is_scalar(true)) {
419  return get_nz(m, ind1, to_slice(kk, ind1));
420  }
421 
422  // Get nonzeros of kk
423  const std::vector<casadi_int>& k = kk.nonzeros();
424  casadi_int sz = nnz();
425 
426  // Check bounds
427  casadi_assert_in_range(k, -sz+ind1, sz+ind1);
428 
429  // If indexed matrix was a row/column vector, make sure that the result is too
430  bool tr = (is_column() && kk.is_row()) || (is_row() && kk.is_column());
431 
432  // Copy nonzeros
433  m = zeros(tr ? kk.sparsity().T() : kk.sparsity());
434  for (casadi_int el=0; el<k.size(); ++el) {
435  casadi_assert(!(ind1 && k[el]<=0), "Matlab is 1-based, but requested index "
436  + str(k[el]) + ". Note that negative slices are"
437  " disabled in the Matlab interface. "
438  "Possibly you may want to use 'end'.");
439  casadi_int k_el = k[el]-ind1;
440  m->at(el) = nonzeros().at(k_el>=0 ? k_el : k_el+sz);
441  }
442  }

◆ get_nz() [2/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::get_nz ( Matrix< Scalar > &  m,
bool  ind1,
const Slice k 
) const

Get a set of nonzeros

Definition at line 404 of file matrix_impl.hpp.

404  {
405  // Scalar
406  if (kk.is_scalar(nnz())) {
407  m = nonzeros().at(kk.scalar(nnz()));
408  return;
409  }
410 
411  // Fall back on IM
412  get_nz(m, ind1, kk.all(nnz(), ind1));
413  }

◆ get_output()

SX CASADI_EXPORT casadi::SX::get_output ( casadi_int  oind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_28i

Definition at line 167 of file sx_instantiator.cpp.

167  {
168  return scalar().get_output(oind);
169  }

References casadi::Matrix< Scalar >::scalar().

◆ get_precision()

template<typename Scalar >
casadi_int casadi::Matrix< Scalar >::get_precision
static

Definition at line 49 of file matrix_impl.hpp.

49 { return stream_precision_; }

◆ get_row()

std::vector<casadi_int> casadi::GenericMatrix< Matrix< Scalar > >::get_row ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b8

Definition at line 194 of file generic_matrix.hpp.

194 { return sparsity().get_row(); }
std::vector< casadi_int > get_row() const
Get the row for each non-zero entry.
Definition: sparsity.cpp:372

◆ get_scientific()

template<typename Scalar >
bool casadi::Matrix< Scalar >::get_scientific
static

Definition at line 55 of file matrix_impl.hpp.

55 { return stream_scientific_; }

◆ get_sparsity()

template<typename Scalar >
Sparsity casadi::Matrix< Scalar >::get_sparsity ( ) const

◆ get_str()

template<typename Scalar >
std::string casadi::Matrix< Scalar >::get_str ( bool  more = false) const

◆ get_width()

template<typename Scalar >
casadi_int casadi::Matrix< Scalar >::get_width
static

Definition at line 52 of file matrix_impl.hpp.

52 { return stream_width_; }

◆ gradient()

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::gradient ( const Matrix< Scalar > &  ex,
const Matrix< Scalar > &  arg,
const Dict opts = Dict() 
)
staticinherited

Functions called by friend functions defined here

◆ has_duplicates()

bool CASADI_EXPORT casadi::SX::has_duplicates

If there are symbolic primitives appearing more than once, the function will return true and the names of the duplicate expressions will be passed to casadi_warning. Note: Will mark the node using SXElem::set_temp. Make sure to call reset_input() after usage.

Extra doc: https://github.com/casadi/casadi/wiki/L_19t

Definition at line 200 of file sx_instantiator.cpp.

200  {
201  bool has_duplicates = false;
202  for (auto&& i : nonzeros_) {
203  bool is_duplicate = i.get_temp()!=0;
204  if (is_duplicate) {
205  casadi_warning("Duplicate expression: " + str(i));
206  }
207  has_duplicates = has_duplicates || is_duplicate;
208  i.set_temp(1);
209  }
210  return has_duplicates;
211  }
bool has_duplicates() const
Detect duplicate symbolic expressions.

References casadi::str().

◆ has_nz()

template<typename Scalar >
bool casadi::Matrix< Scalar >::has_nz ( casadi_int  rr,
casadi_int  cc 
) const

Definition at line 75 of file matrix_impl.hpp.

75  {
76  return sparsity().has_nz(rr, cc);
77  }
bool has_nz(casadi_int rr, casadi_int cc) const
Returns true if the pattern has a non-zero at location rr, cc.
Definition: sparsity.cpp:241

◆ has_output()

bool CASADI_EXPORT casadi::SX::has_output

Extra doc: https://github.com/casadi/casadi/wiki/L_28l

Definition at line 162 of file sx_instantiator.cpp.

162  {
163  return scalar().has_output();
164  }

References casadi::Matrix< Scalar >::scalar().

◆ has_zeros()

template<typename Scalar >
bool casadi::Matrix< Scalar >::has_zeros ( ) const

◆ heaviside()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::heaviside ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined here

◆ hessian() [1/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::hessian ( const Matrix< Scalar > &  f,
const Matrix< Scalar > &  x,
const Dict opts = Dict() 
)
static

Functions called by friend functions defined for GenericMatrix

◆ hessian() [2/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::hessian ( const Matrix< Scalar > &  f,
const Matrix< Scalar > &  x,
Matrix< Scalar > &  g,
const Dict opts = Dict() 
)
static

Functions called by friend functions defined for GenericMatrix

◆ horzcat()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::horzcat ( const std::vector< Matrix< Scalar > > &  v)
static

Functions called by friend functions defined for SparsityInterface

◆ horzsplit()

template<typename Scalar >
static std::vector<Matrix<Scalar> > casadi::Matrix< Scalar >::horzsplit ( const Matrix< Scalar > &  x,
const std::vector< casadi_int > &  offset 
)
static

Functions called by friend functions defined for SparsityInterface

◆ if_else()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::if_else ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  if_true,
const Matrix< Scalar > &  if_false,
bool  short_circuit = false 
)
static

Functions called by friend functions defined for GenericMatrix

◆ inf() [1/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::inf ( casadi_int  nrow = 1,
casadi_int  ncol = 1 
)
static

◆ inf() [2/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::inf ( const Sparsity sp)
static

◆ inf() [3/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::inf ( const std::pair< casadi_int, casadi_int > &  rc)
static

◆ info()

Dict CASADI_EXPORT casadi::SX::info

Obtain information about sparsity

Definition at line 1645 of file sx_instantiator.cpp.

1645  {
1646  return {{"function", Function("f", std::vector<SX>{}, std::vector<SX>{*this})}};
1647  }

◆ interp1d()

Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::interp1d ( const std::vector< double > &  x,
const Matrix< Scalar > &  v,
const std::vector< double > &  xq,
const std::string &  mode,
bool  equidistant 
)
staticinherited

Definition at line 213 of file generic_matrix.hpp.

1459  {
1460 
1461  bool mode_floor = false;
1462  bool mode_ceil = false;
1463  if (mode=="floor") {
1464  mode_floor = true;
1465  } else if (mode=="ceil") {
1466  mode_ceil = true;
1467  } else if (mode=="linear") {
1468  //
1469  } else {
1470  casadi_error("interp1d(x, v, xq, mode): "
1471  "Mode must be 'floor', 'ceil' or 'linear'. Got '" + mode + "' instead.");
1472  }
1473 
1474  casadi_assert(is_increasing(x), "interp1d(x, v, xq): x must be increasing.");
1475 
1476  casadi_assert(x.size()==v.size1(),
1477  "interp1d(x, v, xq): dimensions mismatch. v expected to have " + str(x.size()) + " rows,"
1478  " but got " + str(v.size1()) + " instead.");
1479 
1480  // Need at least two elements
1481  casadi_assert(x.size()>=2, "interp1d(x, v, xq): x must be at least length 2.");
1482 
1483  // Vectors to compose a sparse matrix
1484  std::vector<double> val;
1485  std::vector<casadi_int> colind(1, 0);
1486  std::vector<casadi_int> row;
1487 
1488  // Number of nonzeros in to-be composed matrix
1489  casadi_int nnz = 0;
1490  for (casadi_int i=0;i<xq.size();++i) {
1491  // Obtain index corresponding to xq[i]
1492  double ind = index_interp1d(x, xq[i], equidistant);
1493 
1494  if (mode_floor) ind = floor(ind);
1495  if (mode_ceil) ind = ceil(ind);
1496 
1497  // Split into integer and fractional part
1498  double int_partd;
1499  double frac_part = modf(ind, &int_partd);
1500  casadi_int int_part = static_cast<casadi_int>(int_partd);
1501 
1502  if (frac_part==0) {
1503  // Create a single entry
1504  val.push_back(1);
1505  row.push_back(int_part);
1506  nnz+=1;
1507  colind.push_back(nnz);
1508  } else {
1509  // Create a double entry
1510  val.push_back(1-frac_part);
1511  val.push_back(frac_part);
1512  row.push_back(int_part);
1513  row.push_back(int_part+1);
1514  nnz+=2;
1515  colind.push_back(nnz);
1516  }
1517  }
1518 
1519  // Construct sparsity for composed matrix
1520  Sparsity sp(x.size(), xq.size() , colind, row);
1521 
1522  return MatType::mtimes(MatType(sp, val).T(), v);
1523 
1524  }
double index_interp1d(const std::vector< double > &x, double xq, bool equidistant)
bool is_increasing(const std::vector< T > &v)
Check if the vector is strictly increasing.

◆ inv() [1/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::inv ( const Matrix< Scalar > &  A)
static

Functions called by friend functions defined for GenericMatrix

◆ inv() [2/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::inv ( const Matrix< Scalar > &  A,
const std::string &  lsolver,
const Dict opts 
)
static

Functions called by friend functions defined for GenericMatrix

◆ inv_minor()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::inv_minor ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ inv_skew()

Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::inv_skew ( const Matrix< Scalar > &  a)
staticinherited

Definition at line 229 of file generic_matrix.hpp.

1538  {
1539  casadi_assert(a.size1()==3 && a.size2()==3,
1540  "inv_skew(a): Expecting 3-by-3 matrix, got " + a.dim() + ".");
1541 
1542  return 0.5*vertcat(std::vector<MatType>({a(2, 1)-a(1, 2), a(0, 2)-a(2, 0), a(1, 0)-a(0, 1)}));
1543  }

◆ is_call()

bool CASADI_EXPORT casadi::SX::is_call

Extra doc: https://github.com/casadi/casadi/wiki/L_28j

Definition at line 152 of file sx_instantiator.cpp.

152  {
153  return scalar().is_call();
154  }

References casadi::Matrix< Scalar >::scalar().

◆ is_column()

bool casadi::GenericMatrix< Matrix< Scalar > >::is_column ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b5

Definition at line 178 of file generic_matrix.hpp.

178 { return sparsity().is_column();}
bool is_column() const
Check if the pattern is a column vector (i.e. size2()==1)
Definition: sparsity.cpp:285

◆ is_commutative()

bool CASADI_EXPORT casadi::SX::is_commutative

Only defined if symbolic scalar.

Extra doc: https://github.com/casadi/casadi/wiki/L_19q

Definition at line 138 of file sx_instantiator.cpp.

138  {
139  return scalar().is_commutative();
140  }

References casadi::Matrix< Scalar >::scalar().

◆ is_constant()

template<typename Scalar >
bool casadi::Matrix< Scalar >::is_constant ( ) const

◆ is_dense()

bool casadi::GenericMatrix< Matrix< Scalar > >::is_dense ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b0

Definition at line 153 of file generic_matrix.hpp.

153 { return sparsity().is_dense();}
bool is_dense() const
Is dense?
Definition: sparsity.cpp:273

◆ is_empty()

bool casadi::GenericMatrix< Matrix< Scalar > >::is_empty ( bool  both = false) const
inlineinherited

(or optionally both dimensions)

Extra doc: https://github.com/casadi/casadi/wiki/L_1az

Definition at line 148 of file generic_matrix.hpp.

148 { return sparsity().is_empty(both);}
bool is_empty(bool both=false) const
Check if the sparsity is empty.
Definition: sparsity.cpp:144

◆ is_equal()

template<typename Scalar >
static bool casadi::Matrix< Scalar >::is_equal ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y,
casadi_int  depth = 0 
)
static

Functions called by friend functions defined for GenericExpression

◆ is_eye()

template<typename Scalar >
bool casadi::Matrix< Scalar >::is_eye ( ) const

◆ is_half()

template<typename Scalar >
bool casadi::Matrix< Scalar >::is_half ( ) const

◆ is_inf()

template<typename Scalar >
bool casadi::Matrix< Scalar >::is_inf ( ) const

◆ is_integer()

template<typename Scalar >
bool casadi::Matrix< Scalar >::is_integer ( ) const

(note that false negative answers are possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_19w

Referenced by casadi::ConstantDM::is_integer().

◆ is_leaf()

bool CASADI_EXPORT casadi::SX::is_leaf

Only defined if symbolic scalar.

Extra doc: https://github.com/casadi/casadi/wiki/L_19p

Definition at line 133 of file sx_instantiator.cpp.

133  {
134  return scalar().is_leaf();
135  }

References casadi::Matrix< Scalar >::scalar().

◆ is_linear()

bool casadi::GenericMatrix< Matrix< Scalar > >::is_linear ( const Matrix< Scalar > &  expr,
const Matrix< Scalar > &  var 
)
staticinherited

Definition at line 235 of file generic_matrix.hpp.

1770  {
1771  return !any(MatType::which_depends(expr, var, 2, true));
1772  }
bool any(const std::vector< bool > &v)
Check if any arguments are true.
Definition: casadi_misc.cpp:88

◆ is_minus_inf()

template<typename Scalar >
bool casadi::Matrix< Scalar >::is_minus_inf ( ) const

◆ is_minus_one()

template<typename Scalar >
bool casadi::Matrix< Scalar >::is_minus_one ( ) const

◆ is_nonnegative()

template<typename Scalar >
bool casadi::Matrix< Scalar >::is_nonnegative ( ) const

(note that false negative answers are possible)

Extra doc: https://github.com/casadi/casadi/wiki/L_2eb

Referenced by casadi::ConstantDM::is_nonnegative().

◆ is_one()

template<typename Scalar >
bool casadi::Matrix< Scalar >::is_one ( ) const

◆ is_op()

bool CASADI_EXPORT casadi::SX::is_op ( casadi_int  op) const

Definition at line 196 of file sx_instantiator.cpp.

196  {
197  return scalar().is_op(op);
198  }
casadi_int op() const
Get operation type.

References casadi::Matrix< Scalar >::op(), and casadi::Matrix< Scalar >::scalar().

◆ is_output()

bool CASADI_EXPORT casadi::SX::is_output

Extra doc: https://github.com/casadi/casadi/wiki/L_28k

Definition at line 157 of file sx_instantiator.cpp.

157  {
158  return scalar().is_output();
159  }

References casadi::Matrix< Scalar >::scalar().

◆ is_quadratic()

bool casadi::GenericMatrix< Matrix< Scalar > >::is_quadratic ( const Matrix< Scalar > &  expr,
const Matrix< Scalar > &  var 
)
staticinherited

Definition at line 236 of file generic_matrix.hpp.

1775  {
1776  return is_linear(gradient(expr, var), var);
1777  }
static bool is_linear(const Matrix< Scalar > &expr, const Matrix< Scalar > &var)
friend Matrix< Scalar > gradient(const Matrix< Scalar > &ex, const Matrix< Scalar > &arg, const Dict &opts=Dict())
Calculate the gradient of an expression.

◆ is_regular()

bool CASADI_EXPORT casadi::SX::is_regular

Definition at line 102 of file sx_instantiator.cpp.

102  {
103  // First pass: ignore symbolics
104  for (casadi_int i=0; i<nnz(); ++i) {
105  const SXElem& x = nonzeros().at(i);
106  if (x.is_constant()) {
107  if (x.is_nan() || x.is_inf() || x.is_minus_inf()) return false;
108  }
109  }
110  // Second pass: don't ignore symbolics
111  for (casadi_int i=0; i<nnz(); ++i) {
112  if (!nonzeros().at(i).is_regular()) return false;
113  }
114  return true;
115  }

References casadi::SXElem::is_constant(), casadi::SXElem::is_inf(), casadi::SXElem::is_minus_inf(), casadi::SXElem::is_nan(), casadi::GenericMatrix< Matrix< Scalar > >::nnz(), and casadi::Matrix< Scalar >::nonzeros().

Referenced by casadi::MX::is_regular().

◆ is_row()

bool casadi::GenericMatrix< Matrix< Scalar > >::is_row ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b4

Definition at line 173 of file generic_matrix.hpp.

173 { return sparsity().is_row();}
bool is_row() const
Check if the pattern is a row vector (i.e. size1()==1)
Definition: sparsity.cpp:281

◆ is_scalar()

bool casadi::GenericMatrix< Matrix< Scalar > >::is_scalar ( bool  scalar_and_dense = false) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b1

Definition at line 158 of file generic_matrix.hpp.

1375  {
1376  return sparsity().is_scalar(scalar_and_dense);
1377  }
bool is_scalar(bool scalar_and_dense=false) const
Is scalar?
Definition: sparsity.cpp:269

◆ is_smooth()

bool CASADI_EXPORT casadi::SX::is_smooth

Extra doc: https://github.com/casadi/casadi/wiki/L_19o

Definition at line 118 of file sx_instantiator.cpp.

118  {
119  // Make a function
120  Function temp("tmp_is_smooth", {SX()}, {*this}, Dict{{"max_io", 0}, {"allow_free", true}});
121 
122  // Run the function on the temporary variable
123  SXFunction* t = temp.get<SXFunction>();
124  return t->is_smooth();
125  }
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.

References casadi::SXFunction::is_smooth().

◆ is_square()

bool casadi::GenericMatrix< Matrix< Scalar > >::is_square ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b2

Definition at line 163 of file generic_matrix.hpp.

163 { return sparsity().is_square();}
bool is_square() const
Is square?
Definition: sparsity.cpp:293

◆ is_symbolic()

bool CASADI_EXPORT casadi::SX::is_symbolic

Check if an expression is a pure symbol. Pure means that no operations should happen on the symbol (not even vec, transpose, index, concatenation, ...) By consequence, a slice of a vector-shaped MX symbol is not a symbol. However, the SX type is really a container format with scalar entries. Therefore, a slice of a vector-shaped SX symbol is still a symbol.

Sparse matrices invariable return false

\seealso is_valid_input

Extra doc: https://github.com/casadi/casadi/wiki/L_19r

Definition at line 182 of file sx_instantiator.cpp.

182  {
183  if (is_dense()) {
184  return is_valid_input();
185  } else {
186  return false;
187  }
188  }
bool is_valid_input() const
Check if matrix can be used to define function inputs.

References casadi::GenericMatrix< Matrix< Scalar > >::is_dense(), and casadi::Matrix< Scalar >::is_valid_input().

◆ is_tril()

bool casadi::GenericMatrix< Matrix< Scalar > >::is_tril ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b7

Definition at line 188 of file generic_matrix.hpp.

188 { return sparsity().is_tril();}
bool is_tril(bool strictly=false) const
Is lower triangular?
Definition: sparsity.cpp:321

◆ is_triu()

bool casadi::GenericMatrix< Matrix< Scalar > >::is_triu ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b6

Definition at line 183 of file generic_matrix.hpp.

183 { return sparsity().is_triu();}
bool is_triu(bool strictly=false) const
Is upper triangular?
Definition: sparsity.cpp:325

◆ is_valid_input()

bool CASADI_EXPORT casadi::SX::is_valid_input

is_valid_input is more forgiving than is_symbolic. Some compositions are allowed: vec, vertcat.

Sparse matrices can return true if all non-zero elements are symbolic

\seealso is_symbolic

Extra doc: https://github.com/casadi/casadi/wiki/L_19s

Definition at line 143 of file sx_instantiator.cpp.

143  {
144  for (casadi_int k=0; k<nnz(); ++k) // loop over non-zero elements
145  if (!nonzeros().at(k)->is_symbolic()) // if an element is not symbolic
146  return false;
147 
148  return true;
149  }

References casadi::GenericMatrix< Matrix< Scalar > >::nnz(), and casadi::Matrix< Scalar >::nonzeros().

Referenced by casadi::Matrix< Scalar >::is_symbolic().

◆ is_value()

template<typename Scalar >
bool casadi::Matrix< Scalar >::is_value ( double  val) const

◆ is_vector()

bool casadi::GenericMatrix< Matrix< Scalar > >::is_vector ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b3

Definition at line 168 of file generic_matrix.hpp.

168 { return sparsity().is_vector();}
bool is_vector() const
Check if the pattern is a row or column vector.
Definition: sparsity.cpp:289

◆ is_zero()

template<typename Scalar >
bool casadi::Matrix< Scalar >::is_zero ( ) const

◆ jacobian()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::jacobian ( const Matrix< Scalar > &  f,
const Matrix< Scalar > &  x,
const Dict opts = Dict() 
)
static

Functions called by friend functions defined for GenericMatrix

Referenced by casadi::AmplInterface::init().

◆ jacobian_sparsity()

template<typename Scalar >
static Sparsity casadi::Matrix< Scalar >::jacobian_sparsity ( const Matrix< Scalar > &  f,
const Matrix< Scalar > &  x 
)
static

Functions called by friend functions defined for GenericMatrix

◆ jtimes()

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::jtimes ( const Matrix< Scalar > &  ex,
const Matrix< Scalar > &  arg,
const Matrix< Scalar > &  v,
bool  tr = false,
const Dict opts = Dict() 
)
staticinherited

Functions called by friend functions defined here

◆ kron()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::kron ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
static

Functions called by friend functions defined for SparsityInterface

◆ ldl()

template<typename Scalar >
static void casadi::Matrix< Scalar >::ldl ( const Matrix< Scalar > &  A,
Matrix< Scalar > &  D,
Matrix< Scalar > &  LT,
std::vector< casadi_int > &  p,
bool  amd = true 
)
static

Functions called by friend functions defined here

◆ ldl_solve()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::ldl_solve ( const Matrix< Scalar > &  b,
const Matrix< Scalar > &  D,
const Matrix< Scalar > &  LT,
const std::vector< casadi_int > &  p 
)
static

Functions called by friend functions defined here

◆ linear_coeff()

void casadi::GenericMatrix< Matrix< Scalar > >::linear_coeff ( const Matrix< Scalar > &  expr,
const Matrix< Scalar > &  var,
Matrix< Scalar > &  A,
Matrix< Scalar > &  b,
bool  check 
)
staticinherited

Definition at line 239 of file generic_matrix.hpp.

1792  {
1793  casadi_assert(expr.is_vector(), "'linear_coeff' only defined for vector expressions.");
1794  if (check)
1795  casadi_assert(is_linear(expr, var), "'linear_coeff' called on non-linear expression.");
1796  A = substitute(jacobian(expr, var), var, 0);
1797  b = vec(substitute(expr, var, 0));
1798  }
static MatType vec(const MatType &x)
friend Matrix< Scalar > substitute(const Matrix< Scalar > &ex, const Matrix< Scalar > &v, const Matrix< Scalar > &vdef)
Substitute variable v with expression vdef in an expression ex.
friend Matrix< Scalar > jacobian(const Matrix< Scalar > &ex, const Matrix< Scalar > &arg, const Dict &opts=Dict())
Calculate Jacobian.

◆ linearize()

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::linearize ( const Matrix< Scalar > &  f,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  x0,
const Dict opts = Dict() 
)
staticinherited

Functions called by friend functions defined here

◆ linspace()

Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::linspace ( const Matrix< Scalar > &  a,
const Matrix< Scalar > &  b,
casadi_int  nsteps 
)
staticinherited

Definition at line 226 of file generic_matrix.hpp.

1408  {
1409  std::vector<MatType> ret(nsteps);
1410  ret[0] = a;
1411  MatType step = (b-a)/static_cast<MatType>(nsteps-1);
1412 
1413  for (casadi_int i=1; i<nsteps-1; ++i)
1414  ret[i] = a + i * step;
1415 
1416  ret[nsteps-1] = b;
1417  return vertcat(ret);
1418  }

◆ logsumexp()

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::logsumexp ( const Matrix< Scalar > &  x)
staticinherited

◆ mac()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::mac ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y,
const Matrix< Scalar > &  z,
const std::string &  blas = "reference" 
)
static

Functions called by friend functions defined for SparsityInterface

◆ matrix_matrix()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::matrix_matrix ( casadi_int  op,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
static

◆ matrix_scalar()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::matrix_scalar ( casadi_int  op,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
static

◆ minor()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::minor ( const Matrix< Scalar > &  x,
casadi_int  i,
casadi_int  j 
)
static

Functions called by friend functions defined here

◆ mldivide()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::mldivide ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
static

Functions called by friend functions defined for GenericMatrix

◆ mmax()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::mmax ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericExpression

◆ mmin()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::mmin ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericExpression

◆ mpower()

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::mpower ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
staticinherited

Functions called by friend functions defined here

◆ mrdivide()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::mrdivide ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
static

Functions called by friend functions defined for GenericMatrix

◆ mtaylor() [1/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::mtaylor ( const Matrix< Scalar > &  ex,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  a,
casadi_int  order 
)
static

Functions called by friend functions defined here

◆ mtaylor() [2/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::mtaylor ( const Matrix< Scalar > &  ex,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  a,
casadi_int  order,
const std::vector< casadi_int > &  order_contributions 
)
static

Functions called by friend functions defined here

◆ mtimes()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::mtimes ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y,
const std::string &  blas = "reference" 
)
static

Functions called by friend functions defined for SparsityInterface

◆ n_dep()

casadi_int CASADI_EXPORT casadi::SX::n_dep

Only defined if symbolic scalar.

Extra doc: https://github.com/casadi/casadi/wiki/L_1aa

Definition at line 230 of file sx_instantiator.cpp.

230  {
231  return scalar().n_dep();
232  }

References casadi::Matrix< Scalar >::scalar().

◆ n_nodes()

template<typename Scalar >
static casadi_int casadi::Matrix< Scalar >::n_nodes ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ name()

std::string CASADI_EXPORT casadi::SX::name

Extra doc: https://github.com/casadi/casadi/wiki/L_1a8

Definition at line 220 of file sx_instantiator.cpp.

220  {
221  return scalar().name();
222  }

References casadi::Matrix< Scalar >::scalar().

Referenced by casadi::Matrix< Scalar >::_sym().

◆ nan() [1/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::nan ( casadi_int  nrow = 1,
casadi_int  ncol = 1 
)
static

◆ nan() [2/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::nan ( const Sparsity sp)
static

◆ nan() [3/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::nan ( const std::pair< casadi_int, casadi_int > &  rc)
static

◆ nnz()

casadi_int casadi::GenericMatrix< Matrix< Scalar > >::nnz
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1an

Definition at line 84 of file generic_matrix.hpp.

1325  {
1326  return sparsity().nnz();
1327  }
casadi_int nnz() const
Get the number of (structural) non-zeros.
Definition: sparsity.cpp:148

◆ nnz_diag()

casadi_int casadi::GenericMatrix< Matrix< Scalar > >::nnz_diag
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1aq

Definition at line 99 of file generic_matrix.hpp.

1340  {
1341  return sparsity().nnz_diag();
1342  }
casadi_int nnz_diag() const
Number of non-zeros on the diagonal, i.e. the number of elements (i, j) with j==i.
Definition: sparsity.cpp:360

◆ nnz_lower()

casadi_int casadi::GenericMatrix< Matrix< Scalar > >::nnz_lower
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1ao

Definition at line 89 of file generic_matrix.hpp.

1330  {
1331  return sparsity().nnz_lower();
1332  }
casadi_int nnz_lower(bool strictly=false) const
Number of non-zeros in the lower triangular half,.
Definition: sparsity.cpp:352

◆ nnz_upper()

casadi_int casadi::GenericMatrix< Matrix< Scalar > >::nnz_upper
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1ap

Definition at line 94 of file generic_matrix.hpp.

1335  {
1336  return sparsity().nnz_upper();
1337  }
casadi_int nnz_upper(bool strictly=false) const
Number of non-zeros in the upper triangular half,.
Definition: sparsity.cpp:356

◆ nonzeros() [1/2]

template<typename Scalar >
std::vector<Scalar>& casadi::Matrix< Scalar >::nonzeros ( )

◆ nonzeros() [2/2]

template<typename Scalar >
const std::vector<Scalar>& casadi::Matrix< Scalar >::nonzeros ( ) const

Access the non-zero elements

◆ norm_0_mul()

static casadi_int casadi::GenericMatrix< Matrix< Scalar > >::norm_0_mul ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
inlinestaticinherited

Definition at line 216 of file generic_matrix.hpp.

216  {
217  return Sparsity::norm_0_mul(x.sparsity(), y.sparsity());
218  }

◆ norm_1()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::norm_1 ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ norm_2()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::norm_2 ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ norm_fro()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::norm_fro ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ norm_inf()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::norm_inf ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ norm_inf_mul()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::norm_inf_mul ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
static

Functions called by friend functions defined here

◆ nullspace()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::nullspace ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

Referenced by casadi::MX::nullspace().

◆ numel()

casadi_int casadi::GenericMatrix< Matrix< Scalar > >::numel
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1ar

Definition at line 104 of file generic_matrix.hpp.

1345  {
1346  return sparsity().numel();
1347  }
casadi_int numel() const
The total number of elements, including structural zeros, i.e. size2()*size1()
Definition: sparsity.cpp:132

◆ nz() [1/2]

NonZeros<Matrix< Scalar > , K> casadi::GenericMatrix< Matrix< Scalar > >::nz ( const K &  k)
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1bc

Definition at line 258 of file generic_matrix.hpp.

258  {
259  return NonZeros<MatType, K>(self(), k);
260  }

◆ nz() [2/2]

const Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::nz ( const K &  k) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1bb

Definition at line 248 of file generic_matrix.hpp.

248  {
249  MatType ret;
250  self().get_nz(ret, false, k);
251  return ret;
252  }

◆ ones() [1/3]

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::ones ( casadi_int  nrow = 1,
casadi_int  ncol = 1 
)
inlinestaticinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1di

Definition at line 1302 of file generic_matrix.hpp.

1302  {
1303  return ones(Sparsity::dense(nrow, ncol));
1304  }
static Matrix< Scalar > ones(casadi_int nrow=1, casadi_int ncol=1)
Create a dense matrix or a matrix with specified sparsity with all entries one.

◆ ones() [2/3]

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::ones ( const Sparsity sp)
inlinestaticinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1di

Definition at line 1305 of file generic_matrix.hpp.

1305 { return MatType(sp, 1, false);}

◆ ones() [3/3]

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::ones ( const std::pair< casadi_int, casadi_int > &  rc)
inlinestaticinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1di

Definition at line 1306 of file generic_matrix.hpp.

1306  {
1307  return ones(rc.first, rc.second);
1308  }

◆ op()

casadi_int CASADI_EXPORT casadi::SX::op

Definition at line 191 of file sx_instantiator.cpp.

191  {
192  return scalar().op();
193  }

References casadi::Matrix< Scalar >::scalar().

Referenced by casadi::Matrix< Scalar >::is_op().

◆ operator casadi_int()

template<typename Scalar >
casadi::Matrix< Scalar >::operator casadi_int ( ) const
explicit

◆ operator double()

template<typename Scalar >
casadi::Matrix< Scalar >::operator double ( ) const
explicit

◆ operator std::vector< A >()

template<typename Scalar >
template<typename A >
casadi::Matrix< Scalar >::operator std::vector< A >
explicit

Implementation of std::vector(Matrix) (in public API)

Extra doc: https://github.com/casadi/casadi/wiki/L_1a7

Definition at line 1467 of file matrix_decl.hpp.

1467  {
1468  // Get sparsity pattern
1469  casadi_int size1 = this->size1(), size2 = this->size2();
1470  const casadi_int *colind = this->colind(), *row = this->row();
1471  // Copy the nonzeros
1472  auto it = nonzeros().begin();
1473  std::vector<A> ret(numel(), 0);
1474  for (casadi_int cc=0; cc<size2; ++cc) {
1475  for (casadi_int el=colind[cc]; el<colind[cc+1]; ++el) {
1476  ret[row[el] + cc*size1] = static_cast<A>(*it++);
1477  }
1478  }
1479  return ret;
1480  }

◆ operator()() [1/4]

SubIndex<Matrix< Scalar > , RR> casadi::GenericMatrix< Matrix< Scalar > >::operator() ( const RR &  rr)
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1bf

Definition at line 286 of file generic_matrix.hpp.

286  {
287  return SubIndex<MatType, RR>(self(), rr);
288  }

◆ operator()() [2/4]

const Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::operator() ( const RR &  rr) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1bd

Definition at line 266 of file generic_matrix.hpp.

266  {
267  MatType ret;
268  self().get(ret, false, rr);
269  return ret;
270  }

◆ operator()() [3/4]

SubMatrix<Matrix< Scalar > , RR, CC> casadi::GenericMatrix< Matrix< Scalar > >::operator() ( const RR &  rr,
const CC &  cc 
)
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1bg

Definition at line 294 of file generic_matrix.hpp.

294  {
295  return SubMatrix<MatType, RR, CC>(self(), rr, cc);
296  }

◆ operator()() [4/4]

const Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::operator() ( const RR &  rr,
const CC &  cc 
) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1be

Definition at line 276 of file generic_matrix.hpp.

276  {
277  MatType ret;
278  self().get(ret, false, rr, cc);
279  return ret;
280  }

◆ operator+()

template<typename Scalar >
Matrix<Scalar> casadi::Matrix< Scalar >::operator+ ( ) const
Examples
SX/SXaddition.cc.

◆ operator-()

template<typename Scalar >
Matrix<Scalar> casadi::Matrix< Scalar >::operator- ( ) const

◆ operator->() [1/2]

template<typename Scalar >
std::vector< Scalar > * casadi::Matrix< Scalar >::operator->

Extra doc: https://github.com/casadi/casadi/wiki/L_18i

Definition at line 606 of file matrix_impl.hpp.

606  {
607  return &nonzeros_;
608  }

◆ operator->() [2/2]

template<typename Scalar >
const std::vector< Scalar > * casadi::Matrix< Scalar >::operator->

Extra doc: https://github.com/casadi/casadi/wiki/L_18j

Definition at line 611 of file matrix_impl.hpp.

611  {
612  return &nonzeros_;
613  }

◆ operator=()

template<typename Scalar >
Matrix< Scalar > & casadi::Matrix< Scalar >::operator= ( const Matrix< Scalar > &  m)

Definition at line 599 of file matrix_impl.hpp.

599  {
600  sparsity_ = m.sparsity_;
601  nonzeros_ = m.nonzeros_;
602  return *this;
603  }

◆ pinv() [1/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::pinv ( const Matrix< Scalar > &  A,
const std::string &  lsolver,
const Dict opts 
)
static

Functions called by friend functions defined for GenericMatrix

◆ pinv() [2/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::pinv ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ poly_coeff()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::poly_coeff ( const Matrix< Scalar > &  ex,
const Matrix< Scalar > &  x 
)
static

Functions called by friend functions defined here

◆ poly_roots()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::poly_roots ( const Matrix< Scalar > &  p)
static

Functions called by friend functions defined here

◆ polyval()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::polyval ( const Matrix< Scalar > &  p,
const Matrix< Scalar > &  x 
)
static

Functions called by friend functions defined for GenericMatrix

◆ print_canonical()

template<typename Scalar >
void casadi::Matrix< Scalar >::print_canonical ( std::ostream &  stream,
const Sparsity sp,
const Scalar *  nonzeros,
bool  truncate = true 
)
static

Definition at line 730 of file matrix_impl.hpp.

731  {
732  casadi_error("'print_canonical' not defined for " + type_name());
733  }
static std::string type_name()
Get name of the class.

◆ print_default()

template<typename Scalar >
void casadi::Matrix< Scalar >::print_default ( std::ostream &  stream,
const Sparsity sp,
const Scalar *  nonzeros,
bool  truncate = true 
)
static

Definition at line 708 of file matrix_impl.hpp.

709  {
710  if (sp.is_empty()) {
711  stream << sp.size1() << "x" << sp.size2();
712  } else if (sp.numel()==1) {
713  if (sp.nnz()==0) {
714  stream << "00";
715  } else {
716  print_scalar(stream, *nonzeros);
717  }
718  } else if (sp.is_column()) {
719  print_vector(stream, sp, nonzeros, truncate);
720  } else if (std::max(sp.size1(), sp.size2())<=10 ||
721  static_cast<double>(sp.nnz())/static_cast<double>(sp.numel())>=0.5) {
722  // if "small" or "dense"
723  print_dense(stream, sp, nonzeros, truncate);
724  } else {
725  print_sparse(stream, sp, nonzeros, truncate);
726  }
727  }
void print_sparse(std::ostream &stream, bool truncate=true) const
Print sparse matrix style.
void print_dense(std::ostream &stream, bool truncate=true) const
Print dense matrix-stype.
void print_vector(std::ostream &stream, bool truncate=true) const
Print vector-style.
void print_scalar(std::ostream &stream) const
Print scalar.

References casadi::Sparsity::is_column(), casadi::Sparsity::is_empty(), casadi::Sparsity::nnz(), casadi::Sparsity::numel(), casadi::Sparsity::size1(), and casadi::Sparsity::size2().

◆ print_dense() [1/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::print_dense ( std::ostream &  stream,
bool  truncate = true 
) const

Definition at line 691 of file matrix_impl.hpp.

691  {
692  print_dense(stream, sparsity(), ptr(), truncate);
693  }
Scalar * ptr()

◆ print_dense() [2/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::print_dense ( std::ostream &  stream,
const Sparsity sp,
const Scalar *  nonzeros,
bool  truncate = true 
)
static

◆ print_operator()

template<typename Scalar >
static std::string casadi::Matrix< Scalar >::print_operator ( const Matrix< Scalar > &  x,
const std::vector< std::string > &  args 
)
static

Functions called by friend functions defined for GenericMatrix

◆ print_scalar() [1/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::print_scalar ( std::ostream &  stream) const

Definition at line 619 of file matrix_impl.hpp.

619  {
620  casadi_assert(numel()==1, "Not a scalar");
621 
622  StreamStateGuard backup(stream);
623 
624  stream.precision(stream_precision_);
625  stream.width(stream_width_);
626  if (stream_scientific_) {
627  stream.setf(std::ios::scientific);
628  } else {
629  stream.unsetf(std::ios::scientific);
630  }
631 
632  if (nnz()==0) {
633  stream << "00";
634  } else {
635  stream << scalar();
636  }
637  stream << std::flush;
638  }

◆ print_scalar() [2/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::print_scalar ( std::ostream &  stream,
const Scalar &  e 
)
static

Definition at line 736 of file matrix_impl.hpp.

736  {
737  std::streamsize precision = stream.precision();
738  std::streamsize width = stream.width();
739  std::ios_base::fmtflags flags = stream.flags();
740 
741  stream.precision(stream_precision_);
742  stream.width(stream_width_);
743  if (stream_scientific_) {
744  stream.setf(std::ios::scientific);
745  } else {
746  stream.unsetf(std::ios::scientific);
747  }
748  stream << e;
749  stream << std::flush;
750 
751  stream.precision(precision);
752  stream.width(width);
753  stream.flags(flags);
754  }

◆ print_sparse() [1/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::print_sparse ( std::ostream &  stream,
bool  truncate = true 
) const

Definition at line 696 of file matrix_impl.hpp.

696  {
697  print_sparse(stream, sparsity(), ptr(), truncate);
698  }

Referenced by casadi::CsparseInterface::nfact().

◆ print_sparse() [2/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::print_sparse ( std::ostream &  stream,
const Sparsity sp,
const Scalar *  nonzeros,
bool  truncate = true 
)
static

Definition at line 782 of file matrix_impl.hpp.

783  {
784  // Access data structures
785  casadi_int size1 = sp.size1();
786  casadi_int size2 = sp.size2();
787  const casadi_int* colind = sp.colind();
788  const casadi_int* row = sp.row();
789  casadi_int nnz = sp.nnz();
790 
791  // Quick return if all zero sparse
792  if (nnz==0) {
793  stream << "all zero sparse: " << size1 << "-by-" << size2 << std::flush;
794  return;
795  }
796 
797  // Print header
798  stream << "sparse: " << size1 << "-by-" << size2 << ", " << nnz << " nnz";
799 
800  // Get components
801  std::vector<std::string> nz, inter;
802  print_split(nnz, nonzeros, nz, inter);
803 
804  // Print intermediate expressions
805  for (casadi_int i=0; i<inter.size(); ++i)
806  stream << std::endl << " @" << (i+1) << "=" << inter[i] << ",";
807  inter.clear();
808 
809  // No need to truncate if less than 1000 nonzeros
810  const casadi_int max_nnz = 1000;
811  if (truncate && nnz<=max_nnz) truncate=false;
812 
813  // Print nonzeros
814  for (casadi_int cc=0; cc<size2; ++cc) {
815  for (casadi_int el=colind[cc]; el<colind[cc+1]; ++el) {
816  if (truncate && el>=3 && el<nnz-3) {
817  if (el==3) stream << std::endl << " ...";
818  } else {
819  stream << std::endl << " (" << row[el] << ", " << cc << ") -> " << nz.at(el);
821  }
822  }
823  }
824  stream << std::flush;
825  }
const Matrix< Scalar > nz(const K &k) const
Get vector nonzero or slice of nonzeros.
static void check()
Raises an error if an interrupt was captured.
void print_split(std::vector< std::string > &nz, std::vector< std::string > &inter) const
Get strings corresponding to the nonzeros and the interdependencies.

References casadi::InterruptHandler::check(), casadi::Sparsity::colind(), casadi::Sparsity::nnz(), casadi::Sparsity::row(), casadi::Sparsity::size1(), and casadi::Sparsity::size2().

◆ print_split() [1/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::print_split ( casadi_int  nnz,
const Scalar *  nonzeros,
std::vector< std::string > &  nz,
std::vector< std::string > &  inter 
)
static

Definition at line 757 of file matrix_impl.hpp.

759  {
760  nz.resize(nnz);
761  inter.resize(0);
762 
763  // Temporary
764  std::stringstream ss;
765  ss.precision(stream_precision_);
766  ss.width(stream_width_);
767  if (stream_scientific_) {
768  ss.setf(std::ios::scientific);
769  } else {
770  ss.unsetf(std::ios::scientific);
771  }
772 
773  // Print nonzeros
774  for (casadi_int i=0; i<nz.size(); ++i) {
775  ss.str(std::string());
776  ss << nonzeros[i];
777  nz[i] = ss.str();
778  }
779  }

◆ print_split() [2/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::print_split ( std::vector< std::string > &  nz,
std::vector< std::string > &  inter 
) const

Definition at line 701 of file matrix_impl.hpp.

702  {
703 
704  print_split(nnz(), ptr(), nz, inter);
705  }

◆ print_vector() [1/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::print_vector ( std::ostream &  stream,
bool  truncate = true 
) const

Definition at line 641 of file matrix_impl.hpp.

641  {
642  print_vector(stream, sparsity(), ptr(), truncate);
643  }

◆ print_vector() [2/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::print_vector ( std::ostream &  stream,
const Sparsity sp,
const Scalar *  nonzeros,
bool  truncate = true 
)
static

Definition at line 646 of file matrix_impl.hpp.

647  {
648  casadi_assert(sp.is_column(), "Not a vector");
649 
650  // Get components
651  std::vector<std::string> nz, inter;
652  print_split(sp.nnz(), nonzeros, nz, inter);
653 
654  // Print intermediate expressions
655  for (casadi_int i=0; i<inter.size(); ++i)
656  stream << "@" << (i+1) << "=" << inter[i] << ", ";
657  inter.clear();
658 
659  // Access data structures
660  const casadi_int* row = sp.row();
661  casadi_int nnz = sp.nnz();
662  casadi_int size1 = sp.size1();
663 
664  // No need to truncate if less than 1000 entries
665  const casadi_int max_numel = 1000;
666  if (truncate && size1<=max_numel) truncate=false;
667 
668  // Nonzero
669  casadi_int el=0;
670 
671  // Loop over rows
672  stream << "[";
673  for (casadi_int rr=0; rr<size1; ++rr) {
674  // String representation
675  std::string s = el<nnz && rr==row[el] ? nz.at(el++) : "00";
676 
677  // Truncate?
678  if (truncate && rr>=3 && rr<size1-3) {
679  // Do not print
680  if (rr==3) stream << ", ...";
681  } else {
682  // Print
683  if (rr!=0) stream << ", ";
684  stream << s;
685  }
686  }
687  stream << "]" << std::flush;
688  }

References casadi::Sparsity::is_column(), casadi::Sparsity::nnz(), casadi::Sparsity::row(), and casadi::Sparsity::size1().

◆ printme()

template<typename Scalar >
Matrix<Scalar> casadi::Matrix< Scalar >::printme ( const Matrix< Scalar > &  y) const

◆ project()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::project ( const Matrix< Scalar > &  x,
const Sparsity sp,
bool  intersect = false 
)
static

Functions called by friend functions defined for GenericMatrix

◆ ptr() [1/2]

template<typename Scalar >
Scalar* casadi::Matrix< Scalar >::ptr ( )

◆ ptr() [2/2]

template<typename Scalar >
const Scalar* casadi::Matrix< Scalar >::ptr ( ) const

Get a pointer to the data

◆ pw_const()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::pw_const ( const Matrix< Scalar > &  t,
const Matrix< Scalar > &  tval,
const Matrix< Scalar > &  val 
)
static

Functions called by friend functions defined here

◆ pw_lin()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::pw_lin ( const Matrix< Scalar > &  t,
const Matrix< Scalar > &  tval,
const Matrix< Scalar > &  val 
)
static

Functions called by friend functions defined here

◆ qr()

template<typename Scalar >
static void casadi::Matrix< Scalar >::qr ( const Matrix< Scalar > &  A,
Matrix< Scalar > &  Q,
Matrix< Scalar > &  R 
)
static

Functions called by friend functions defined here

◆ qr_solve()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::qr_solve ( const Matrix< Scalar > &  b,
const Matrix< Scalar > &  v,
const Matrix< Scalar > &  r,
const Matrix< Scalar > &  beta,
const std::vector< casadi_int > &  prinv,
const std::vector< casadi_int > &  pc,
bool  tr = false 
)
static

Functions called by friend functions defined here

◆ qr_sparse()

template<typename Scalar >
static void casadi::Matrix< Scalar >::qr_sparse ( const Matrix< Scalar > &  A,
Matrix< Scalar > &  V,
Matrix< Scalar > &  R,
Matrix< Scalar > &  beta,
std::vector< casadi_int > &  prinv,
std::vector< casadi_int > &  pc,
bool  amd = true 
)
static

Functions called by friend functions defined here

Referenced by casadi::qr_block_det().

◆ quadratic_coeff()

void casadi::GenericMatrix< Matrix< Scalar > >::quadratic_coeff ( const Matrix< Scalar > &  expr,
const Matrix< Scalar > &  var,
Matrix< Scalar > &  A,
Matrix< Scalar > &  b,
Matrix< Scalar > &  c,
bool  check 
)
staticinherited

Definition at line 237 of file generic_matrix.hpp.

1781  {
1782  casadi_assert(expr.is_scalar(), "'quadratic_coeff' only defined for scalar expressions.");
1783  A = hessian(expr, var);
1784  b = substitute(jacobian(expr, var), var, 0).T();
1785  if (check)
1786  casadi_assert(!depends_on(A, var), "'quadratic_coeff' called on non-quadratic expression.");
1787  c = substitute(expr, var, 0);
1788  }
friend bool depends_on(const Matrix< Scalar > &f, const Matrix< Scalar > &arg)
Check if expression depends on the argument.
friend Matrix< Scalar > hessian(const Matrix< Scalar > &ex, const Matrix< Scalar > &arg, const Dict &opts=Dict())
Hessian and (optionally) gradient.

◆ ramp()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::ramp ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined here

◆ rand() [1/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::rand ( casadi_int  nrow = 1,
casadi_int  ncol = 1 
)
static

◆ rand() [2/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::rand ( const Sparsity sp)
static

◆ rand() [3/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::rand ( const std::pair< casadi_int, casadi_int > &  rc)
static

◆ rank1()

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::rank1 ( const Matrix< Scalar > &  A,
const Matrix< Scalar > &  alpha,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
staticinherited

Calculates A + 1/2 * alpha * x*y'

Extra doc: https://github.com/casadi/casadi/wiki/L_1bp

◆ rectangle()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::rectangle ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined here

◆ remove()

template<typename Scalar >
void casadi::Matrix< Scalar >::remove ( const std::vector< casadi_int > &  rr,
const std::vector< casadi_int > &  cc 
)

Remove/delete rows and/or columns of a matrix

Extra doc: https://github.com/casadi/casadi/wiki/L_19h

◆ repsum()

Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::repsum ( const Matrix< Scalar > &  x,
casadi_int  n,
casadi_int  m = 1 
)
staticinherited

Definition at line 232 of file generic_matrix.hpp.

1556  {
1557  casadi_assert_dev(x.size1() % n==0);
1558  casadi_assert_dev(x.size2() % m==0);
1559  std::vector< std::vector< MatType> > s =
1560  blocksplit(x, x.size1()/n, x.size2()/m);
1561  MatType sum = 0;
1562  for (casadi_int i=0;i<s.size();++i) {
1563  for (casadi_int j=0;j<s[i].size();++j) {
1564  sum = sum + s[i][j];
1565  }
1566  }
1567  return sum;
1568  }
static std::vector< std::vector< MatType > > blocksplit(const MatType &x, const std::vector< casadi_int > &vert_offset, const std::vector< casadi_int > &horz_offset)
friend MatType sum(const MatType &x)
Returns summation of all elements.

◆ reserve() [1/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::reserve ( casadi_int  nnz)

◆ reserve() [2/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::reserve ( casadi_int  nnz,
casadi_int  ncol 
)

◆ reset_input()

void CASADI_EXPORT casadi::SX::reset_input

Extra doc: https://github.com/casadi/casadi/wiki/L_19u

Definition at line 213 of file sx_instantiator.cpp.

213  {
214  for (auto&& i : nonzeros_) {
215  i.set_temp(0);
216  }
217  }

◆ reshape() [1/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::reshape ( const Matrix< Scalar > &  x,
casadi_int  nrow,
casadi_int  ncol 
)
static

Functions called by friend functions defined for SparsityInterface

◆ reshape() [2/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::reshape ( const Matrix< Scalar > &  x,
const Sparsity sp 
)
static

Functions called by friend functions defined for SparsityInterface

◆ resize()

template<typename Scalar >
void casadi::Matrix< Scalar >::resize ( casadi_int  nrow,
casadi_int  ncol 
)

◆ reverse()

template<typename Scalar >
static std::vector<std::vector<Matrix<Scalar> > > casadi::Matrix< Scalar >::reverse ( const std::vector< Matrix< Scalar > > &  ex,
const std::vector< Matrix< Scalar > > &  arg,
const std::vector< std::vector< Matrix< Scalar > > > &  v,
const Dict opts = Dict() 
)
static

Functions called by friend functions defined here

◆ rng()

template<typename Scalar >
void casadi::Matrix< Scalar >::rng ( casadi_int  seed)
static

Definition at line 70 of file matrix_impl.hpp.

70  {
71  rng_.seed(seed);
72  }

◆ row() [1/2]

const casadi_int* casadi::GenericMatrix< Matrix< Scalar > >::row ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b8

Definition at line 197 of file generic_matrix.hpp.

197 { return sparsity().row(); }
const casadi_int * row() const
Get a reference to row-vector,.
Definition: sparsity.cpp:164

◆ row() [2/2]

casadi_int casadi::GenericMatrix< Matrix< Scalar > >::row ( casadi_int  el) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1b8

Definition at line 200 of file generic_matrix.hpp.

200 { return sparsity().row(el); }

◆ rows()

casadi_int casadi::GenericMatrix< Matrix< Scalar > >::rows ( ) const
inlineinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1at

Definition at line 114 of file generic_matrix.hpp.

114 {return size1();}

◆ scalar()

template<typename Scalar >
const Scalar casadi::Matrix< Scalar >::scalar ( ) const

◆ scalar_matrix()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::scalar_matrix ( casadi_int  op,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
static

◆ separate_linear()

template<typename Scalar >
static void casadi::Matrix< Scalar >::separate_linear ( const Matrix< Scalar > &  expr,
const Matrix< Scalar > &  sym_lin,
const Matrix< Scalar > &  sym_const,
Matrix< Scalar > &  expr_const,
Matrix< Scalar > &  expr_lin,
Matrix< Scalar > &  expr_nonlin 
)
static

Functions called by friend functions defined for SparsityInterface

◆ serialize() [1/3]

template<typename Scalar >
std::string casadi::Matrix< Scalar >::serialize ( ) const

◆ serialize() [2/3]

template<typename Scalar >
void casadi::Matrix< Scalar >::serialize ( SerializingStream s) const

◆ serialize() [3/3]

template<typename Scalar >
void casadi::Matrix< Scalar >::serialize ( std::ostream &  stream) const

◆ set() [1/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::set ( const Matrix< Scalar > &  m,
bool  ind1,
const Matrix< casadi_int > &  rr 
)

Set a submatrix, single argument

Definition at line 314 of file matrix_impl.hpp.

314  {
315  // Scalar
316  if (rr.is_scalar(true) && m.is_dense()) {
317  return set(m, ind1, to_slice(rr, ind1));
318  }
319 
320  // Assert dimensions of assigning matrix
321  if (rr.sparsity() != m.sparsity()) {
322  if (rr.size() == m.size()) {
323  // Remove submatrix to be replaced
324  erase(rr.nonzeros(), ind1);
325 
326  // Find the intersection between rr's and m's sparsity patterns
327  Sparsity sp = rr.sparsity() * m.sparsity();
328 
329  // Project both matrices to this sparsity
330  return set(project(m, sp), ind1, Matrix<casadi_int>::project(rr, sp));
331  } else if (m.is_scalar()) {
332  // m scalar means "set all"
333  if (m.is_dense()) {
334  return set(Matrix<Scalar>(rr.sparsity(), m), ind1, rr);
335  } else {
336  return set(Matrix<Scalar>(rr.size()), ind1, rr);
337  }
338  } else if (rr.size1() == m.size2() && rr.size2() == m.size1()
339  && std::min(m.size1(), m.size2()) == 1) {
340  // m is transposed if necessary
341  return set(m.T(), ind1, rr);
342  } else {
343  // Error otherwise
344  casadi_error("Dimension mismatch. lhs is " + str(rr.size())
345  + ", while rhs is " + str(m.size()));
346  }
347  }
348 
349  // Dimensions of this
350  casadi_int sz1 = size1(), sz2 = size2(), sz = nnz(), nel = numel(), rrsz = rr.nnz();
351 
352  // Quick return if nothing to set
353  if (rrsz==0) return;
354 
355  // Check bounds
356  casadi_assert_in_range(rr.nonzeros(), -nel+ind1, nel+ind1);
357 
358  // Dense mode
359  if (is_dense() && m.is_dense()) {
360  return set_nz(m, ind1, rr);
361  }
362 
363  // Construct new sparsity pattern
364  std::vector<casadi_int> new_row =
365  sparsity().get_row(), new_col=sparsity().get_col(), nz(rr.nonzeros());
366  new_row.reserve(sz+rrsz);
367  new_col.reserve(sz+rrsz);
368  nz.reserve(rrsz);
369  for (std::vector<casadi_int>::iterator i=nz.begin(); i!=nz.end(); ++i) {
370  if (ind1) (*i)--;
371  if (*i<0) *i += nel;
372  new_row.push_back(*i % sz1);
373  new_col.push_back(*i / sz1);
374  }
375  Sparsity sp = Sparsity::triplet(sz1, sz2, new_row, new_col);
376 
377  // If needed, update pattern
378  if (sp != sparsity()) *this = project(*this, sp);
379 
380  // Find the nonzeros corresponding to rr
381  sparsity().get_nz(nz);
382 
383  // Carry out the assignments
384  for (casadi_int i=0; i<nz.size(); ++i) {
385  nonzeros().at(nz[i]) = m->at(i);
386  }
387  }
void set(const Matrix< Scalar > &m, bool ind1, const Slice &rr)
void erase(const std::vector< casadi_int > &rr, const std::vector< casadi_int > &cc, bool ind1=false)
Erase a submatrix (leaving structural zeros in its place)
void set_nz(const Matrix< Scalar > &m, bool ind1, const Slice &k)
std::vector< casadi_int > get_col() const
Get the column for each non-zero entry.
Definition: sparsity.cpp:368
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 *.
Definition: sparsity.cpp:1143

References casadi::GenericMatrix< MatType >::is_dense(), casadi::GenericMatrix< MatType >::is_scalar(), casadi::GenericMatrix< MatType >::nnz(), casadi::Matrix< Scalar >::nonzeros(), casadi::GenericMatrix< MatType >::size(), casadi::GenericMatrix< MatType >::size1(), casadi::GenericMatrix< MatType >::size2(), casadi::Matrix< Scalar >::sparsity(), casadi::str(), casadi::Matrix< Scalar >::T(), casadi::to_slice(), and casadi::Sparsity::triplet().

◆ set() [2/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::set ( const Matrix< Scalar > &  m,
bool  ind1,
const Matrix< casadi_int > &  rr,
const Matrix< casadi_int > &  cc 
)

Set a submatrix, two arguments

Definition at line 228 of file matrix_impl.hpp.

229  {
230  // Scalar
231  if (rr.is_scalar(true) && cc.is_scalar(true) && m.is_dense()) {
232  return set(m, ind1, to_slice(rr, ind1), to_slice(cc, ind1));
233  }
234 
235  // Row vector rr (e.g. in MATLAB) is transposed to column vector
236  if (rr.size1()==1 && rr.size2()>1) {
237  return set(m, ind1, rr.T(), cc);
238  }
239 
240  // Row vector cc (e.g. in MATLAB) is transposed to column vector
241  if (cc.size1()==1 && cc.size2()>1) {
242  return set(m, ind1, rr, cc.T());
243  }
244 
245  // Make sure rr and cc are dense vectors
246  casadi_assert(rr.is_dense() && rr.is_column(),
247  "Matrix::set: First index not dense vector");
248  casadi_assert(cc.is_dense() && cc.is_column(),
249  "Matrix::set: Second index not dense vector");
250 
251  // Assert dimensions of assigning matrix
252  if (rr.size1() != m.size1() || cc.size1() != m.size2()) {
253  if (m.is_scalar()) {
254  // m scalar means "set all"
255  return set(repmat(m, rr.size1(), cc.size1()), ind1, rr, cc);
256  } else if (rr.size1() == m.size2() && cc.size1() == m.size1()
257  && std::min(m.size1(), m.size2()) == 1) {
258  // m is transposed if necessary
259  return set(m.T(), ind1, rr, cc);
260  } else {
261  // Error otherwise
262  casadi_error("Dimension mismatch. lhs is " + str(rr.size1()) + "-by-"
263  + str(cc.size1()) + ", while rhs is " + str(m.size()));
264  }
265  }
266 
267  // Dimensions
268  casadi_int sz1 = size1(), sz2 = size2();
269 
270  // Report out-of-bounds
271  casadi_assert_in_range(rr.nonzeros(), -sz1+ind1, sz1+ind1);
272  casadi_assert_in_range(cc.nonzeros(), -sz2+ind1, sz2+ind1);
273 
274  // If we are assigning with something sparse, first remove existing entries
275  if (!m.is_dense()) {
276  erase(rr.nonzeros(), cc.nonzeros(), ind1);
277  }
278 
279  // Collect all assignments
280  IM el = IM::zeros(m.sparsity());
281  for (casadi_int j=0; j<el.size2(); ++j) { // Loop over columns of m
282  casadi_int this_j = cc->at(j) - ind1; // Corresponding column in this
283  if (this_j<0) this_j += sz2;
284  for (casadi_int k=el.colind(j); k<el.colind(j+1); ++k) { // Loop over rows of m
285  casadi_int i = m.row(k);
286  casadi_int this_i = rr->at(i) - ind1; // Corresponding row in this
287  if (this_i<0) this_i += sz1;
288  el->at(k) = this_i + this_j*sz1;
289  }
290  }
291  return set(m, false, el);
292  }
Matrix< Scalar > T() const
Transpose the matrix.
static MatType repmat(const MatType &x, casadi_int n, casadi_int m=1)
Matrix< casadi_int > IM
Definition: im_fwd.hpp:31

◆ set() [3/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::set ( const Matrix< Scalar > &  m,
bool  ind1,
const Matrix< casadi_int > &  rr,
const Slice cc 
)

Set a submatrix, two arguments

Definition at line 221 of file matrix_impl.hpp.

222  {
223  // Fall back on (IM, IM)
224  set(m, ind1, rr, cc.all(size2(), ind1));
225  }

References casadi::Slice::all().

◆ set() [4/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::set ( const Matrix< Scalar > &  m,
bool  ind1,
const Slice rr 
)

Set a submatrix, single argument

Definition at line 295 of file matrix_impl.hpp.

295  {
296  // Scalar
297  if (rr.is_scalar(numel()) && m.is_dense()) {
298  casadi_int r = rr.scalar(numel());
299  casadi_int oldsize = sparsity_.nnz();
300  casadi_int ind = sparsity_.add_nz(r % size1(), r / size1());
301  if (oldsize == sparsity_.nnz()) {
302  nonzeros_.at(ind) = m.scalar();
303  } else {
304  nonzeros_.insert(nonzeros_.begin()+ind, m.scalar());
305  }
306  return;
307  }
308 
309  // Fall back on IM
310  set(m, ind1, rr.all(numel(), ind1));
311  }
casadi_int add_nz(casadi_int rr, casadi_int cc)
Get the index of a non-zero element.
Definition: sparsity.cpp:194

References casadi::Slice::all(), casadi::GenericMatrix< MatType >::is_dense(), casadi::Slice::is_scalar(), casadi::Matrix< Scalar >::scalar(), and casadi::Slice::scalar().

Referenced by casadi::override_num().

◆ set() [5/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::set ( const Matrix< Scalar > &  m,
bool  ind1,
const Slice rr,
const Matrix< casadi_int > &  cc 
)

Set a submatrix, two arguments

Definition at line 214 of file matrix_impl.hpp.

215  {
216  // Fall back on (IM, IM)
217  set(m, ind1, rr.all(size1(), ind1), cc);
218  }

References casadi::Slice::all().

◆ set() [6/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::set ( const Matrix< Scalar > &  m,
bool  ind1,
const Slice rr,
const Slice cc 
)

Set a submatrix, two arguments

Definition at line 195 of file matrix_impl.hpp.

196  {
197  // Both are scalar
198  if (rr.is_scalar(size1()) && cc.is_scalar(size2()) && m.is_dense()) {
199  casadi_int oldsize = sparsity_.nnz();
200  casadi_int ind = sparsity_.add_nz(rr.scalar(size1()), cc.scalar(size2()));
201  if (oldsize == sparsity_.nnz()) {
202  nonzeros_.at(ind) = m.scalar();
203  } else {
204  nonzeros_.insert(nonzeros_.begin()+ind, m.scalar());
205  }
206  return;
207  }
208 
209  // Fall back on (IM, IM)
210  set(m, ind1, rr.all(size1(), ind1), cc.all(size2(), ind1));
211  }

References casadi::Slice::all(), casadi::GenericMatrix< MatType >::is_dense(), casadi::Slice::is_scalar(), casadi::Matrix< Scalar >::scalar(), and casadi::Slice::scalar().

◆ set() [7/7]

template<typename Scalar >
void casadi::Matrix< Scalar >::set ( const Matrix< Scalar > &  m,
bool  ind1,
const Sparsity sp 
)

Set a submatrix, single argument

Definition at line 390 of file matrix_impl.hpp.

390  {
391  casadi_assert(size()==sp.size(),
392  "set(Sparsity sp): shape mismatch. This matrix has shape "
393  + str(size()) + ", but supplied sparsity index has shape "
394  + str(sp.size()) + ".");
395  std::vector<casadi_int> ii = sp.find();
396  if (m.is_scalar()) {
397  (*this)(ii) = densify(m);
398  } else {
399  (*this)(ii) = densify(m(ii));
400  }
401  }

References casadi::Sparsity::find(), casadi::GenericMatrix< MatType >::is_scalar(), casadi::Sparsity::size(), and casadi::str().

◆ set_max_depth()

void CASADI_EXPORT casadi::SX::set_max_depth ( casadi_int  eq_depth = 1)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_19b

Definition at line 44 of file sx_instantiator.cpp.

44  {
45  SXNode::eq_depth_ = eq_depth;
46  }

References casadi::SXNode::eq_depth_.

◆ set_nz() [1/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::set_nz ( const Matrix< Scalar > &  m,
bool  ind1,
const Matrix< casadi_int > &  k 
)

Set a set of nonzeros

Definition at line 457 of file matrix_impl.hpp.

457  {
458  // Scalar
459  if (kk.is_scalar(true)) {
460  return set_nz(m, ind1, to_slice(kk, ind1));
461  }
462 
463  // Assert dimensions of assigning matrix
464  if (kk.sparsity() != m.sparsity()) {
465  if (m.is_scalar()) {
466  // m scalar means "set all"
467  if (!m.is_dense()) return; // Nothing to set
468  return set_nz(Matrix<Scalar>(kk.sparsity(), m), ind1, kk);
469  } else if (kk.size() == m.size()) {
470  // Project sparsity if needed
471  return set_nz(project(m, kk.sparsity()), ind1, kk);
472  } else if (kk.size1() == m.size2() && kk.size2() == m.size1()
473  && std::min(m.size1(), m.size2()) == 1) {
474  // m is transposed if necessary
475  return set_nz(m.T(), ind1, kk);
476  } else {
477  // Error otherwise
478  casadi_error("Dimension mismatch. lhs is " + str(kk.size())
479  + ", while rhs is " + str(m.size()));
480  }
481  }
482 
483  // Get nonzeros
484  const std::vector<casadi_int>& k = kk.nonzeros();
485  casadi_int sz = nnz();
486 
487  // Check bounds
488  casadi_assert_in_range(k, -sz+ind1, sz+ind1);
489 
490  // Set nonzeros, ignoring negative indices
491  for (casadi_int el=0; el<k.size(); ++el) {
492  casadi_assert(!(ind1 && k[el]<=0),
493  "Matlab is 1-based, but requested index " + str(k[el])
494  + ". Note that negative slices are disabled in the Matlab interface. "
495  "Possibly you may want to use 'end'.");
496  casadi_int k_el = k[el]-ind1;
497  nonzeros().at(k_el>=0 ? k_el : k_el+sz) = m->at(el);
498  }
499  }

References casadi::GenericMatrix< MatType >::is_dense(), casadi::GenericMatrix< MatType >::is_scalar(), casadi::Matrix< Scalar >::nonzeros(), casadi::GenericMatrix< MatType >::size(), casadi::GenericMatrix< MatType >::size1(), casadi::GenericMatrix< MatType >::size2(), casadi::Matrix< Scalar >::sparsity(), casadi::str(), casadi::Matrix< Scalar >::T(), and casadi::to_slice().

◆ set_nz() [2/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::set_nz ( const Matrix< Scalar > &  m,
bool  ind1,
const Slice k 
)

Set a set of nonzeros

Definition at line 445 of file matrix_impl.hpp.

445  {
446  // Scalar
447  if (kk.is_scalar(nnz())) {
448  nonzeros().at(kk.scalar(nnz())) = m.scalar();
449  return;
450  }
451 
452  // Fallback on IM
453  set_nz(m, ind1, kk.all(nnz(), ind1));
454  }

References casadi::Slice::all(), casadi::Slice::is_scalar(), casadi::Matrix< Scalar >::scalar(), and casadi::Slice::scalar().

◆ set_precision()

template<typename Scalar >
void casadi::Matrix< Scalar >::set_precision ( casadi_int  precision)
static

Definition at line 40 of file matrix_impl.hpp.

40 { stream_precision_ = precision; }

◆ set_scientific()

template<typename Scalar >
void casadi::Matrix< Scalar >::set_scientific ( bool  scientific)
static

Definition at line 46 of file matrix_impl.hpp.

46 { stream_scientific_ = scientific; }

◆ set_width()

template<typename Scalar >
void casadi::Matrix< Scalar >::set_width ( casadi_int  width)
static

Definition at line 43 of file matrix_impl.hpp.

43 { stream_width_ = width; }

◆ shared()

template<typename Scalar >
static void casadi::Matrix< Scalar >::shared ( std::vector< Matrix< Scalar > > &  ex,
std::vector< Matrix< Scalar > > &  v,
std::vector< Matrix< Scalar > > &  vdef,
const std::string &  v_prefix,
const std::string &  v_suffix 
)
static

Functions called by friend functions defined for GenericMatrix

◆ simplify()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::simplify ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ simplify_combine_terms()

template<typename Scalar >
static bool casadi::Matrix< Scalar >::simplify_combine_terms ( std::vector< Matrix< Scalar > > &  arg,
std::vector< Matrix< Scalar > > &  res,
const Dict opts = Dict() 
)
static

◆ simplify_const_folding()

template<typename Scalar >
static bool casadi::Matrix< Scalar >::simplify_const_folding ( std::vector< Matrix< Scalar > > &  arg,
std::vector< Matrix< Scalar > > &  res,
const Dict opts = Dict() 
)
static

◆ simplify_ref_count()

template<typename Scalar >
static bool casadi::Matrix< Scalar >::simplify_ref_count ( std::vector< Matrix< Scalar > > &  arg,
std::vector< Matrix< Scalar > > &  res,
const Dict opts = Dict() 
)
static

◆ size() [1/2]

std::pair< casadi_int, casadi_int > casadi::GenericMatrix< Matrix< Scalar > >::size
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1ax

Definition at line 136 of file generic_matrix.hpp.

1360  {
1361  return sparsity().size();
1362  }
std::pair< casadi_int, casadi_int > size() const
Get the shape.
Definition: sparsity.cpp:152

◆ size() [2/2]

casadi_int casadi::GenericMatrix< Matrix< Scalar > >::size ( casadi_int  axis) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1ay

Definition at line 141 of file generic_matrix.hpp.

1365  {
1366  return sparsity().size(axis);
1367  }

◆ size1()

casadi_int casadi::GenericMatrix< Matrix< Scalar > >::size1
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1as

Definition at line 109 of file generic_matrix.hpp.

1350  {
1351  return sparsity().size1();
1352  }
casadi_int size1() const
Get the number of rows.
Definition: sparsity.cpp:124

◆ size2()

casadi_int casadi::GenericMatrix< Matrix< Scalar > >::size2
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1au

Definition at line 119 of file generic_matrix.hpp.

1355  {
1356  return sparsity().size2();
1357  }
casadi_int size2() const
Get the number of columns.
Definition: sparsity.cpp:128

◆ skew()

Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::skew ( const Matrix< Scalar > &  a)
staticinherited

Definition at line 228 of file generic_matrix.hpp.

1527  {
1528  casadi_assert(a.is_vector() && (a.size1()==3 || a.size2()==3),
1529  "skew(a): Expecting 3-vector, got " + a.dim() + ".");
1530 
1531  MatType x = a(0);
1532  MatType y = a(1);
1533  MatType z = a(2);
1534  return blockcat(std::vector< std::vector<MatType> >({{0, -z, y}, {z, 0, -x}, {-y, x, 0}}));
1535  }
friend MatType blockcat(const std::vector< std::vector< MatType > > &v)
Construct a matrix from a list of list of blocks.

◆ soc()

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::soc ( const Matrix< Scalar > &  x,
const Matrix< Scalar > &  y 
)
staticinherited

Functions called by friend functions defined here

◆ solve() [1/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::solve ( const Matrix< Scalar > &  A,
const Matrix< Scalar > &  b 
)
static

Functions called by friend functions defined for GenericMatrix

Referenced by casadi::SymbolicQr::init().

◆ solve() [2/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::solve ( const Matrix< Scalar > &  A,
const Matrix< Scalar > &  b,
const std::string &  lsolver,
const Dict opts 
)
static

Functions called by friend functions defined for GenericMatrix

◆ sparsify()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::sparsify ( const Matrix< Scalar > &  x,
double  tol = 0 
)
static

Functions called by friend functions defined here

◆ sparsity()

template<typename Scalar >
const Sparsity& casadi::Matrix< Scalar >::sparsity ( ) const

◆ sparsity_cast()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::sparsity_cast ( const Matrix< Scalar > &  x,
const Sparsity sp 
)
static

Functions called by friend functions defined for SparsityInterface

◆ sprank()

static casadi_int casadi::GenericMatrix< Matrix< Scalar > >::sprank ( const Matrix< Scalar > &  x)
inlinestaticinherited

Definition at line 215 of file generic_matrix.hpp.

215 { return Sparsity::sprank(x.sparsity());}

◆ substitute() [1/2]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::substitute ( const Matrix< Scalar > &  ex,
const Matrix< Scalar > &  v,
const Matrix< Scalar > &  vdef 
)
static

Functions called by friend functions defined for GenericMatrix

◆ substitute() [2/2]

template<typename Scalar >
static std::vector<Matrix<Scalar> > casadi::Matrix< Scalar >::substitute ( const std::vector< Matrix< Scalar > > &  ex,
const std::vector< Matrix< Scalar > > &  v,
const std::vector< Matrix< Scalar > > &  vdef 
)
static

Functions called by friend functions defined for GenericMatrix

◆ substitute_inplace()

template<typename Scalar >
static void casadi::Matrix< Scalar >::substitute_inplace ( const std::vector< Matrix< Scalar > > &  v,
std::vector< Matrix< Scalar > > &  vdef,
std::vector< Matrix< Scalar > > &  ex,
bool  revers 
)
static

Functions called by friend functions defined for GenericMatrix

◆ sum1()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::sum1 ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ sum2()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::sum2 ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ sumsqr()

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::sumsqr ( const Matrix< Scalar > &  x)
inlinestaticinherited

Definition at line 225 of file generic_matrix.hpp.

225 { return dot(x, x);}
friend Matrix< Scalar > dot(const Matrix< Scalar > &x, const Matrix< Scalar > &y)
Inner product of two matrices.

◆ sym() [1/7]

static std::vector<Matrix< Scalar > > casadi::GenericMatrix< Matrix< Scalar > >::sym ( const std::string &  name,
casadi_int  nrow,
casadi_int  ncol,
casadi_int  p 
)
inlinestaticinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1de

Definition at line 1261 of file generic_matrix.hpp.

1262  {
1263  return sym(name, Sparsity::dense(nrow, ncol), p);
1264  }
static Matrix< Scalar > sym(const std::string &name, casadi_int nrow=1, casadi_int ncol=1)
Create an nrow-by-ncol symbolic primitive.

◆ sym() [2/7]

static std::vector<std::vector<Matrix< Scalar > > > casadi::GenericMatrix< Matrix< Scalar > >::sym ( const std::string &  name,
casadi_int  nrow,
casadi_int  ncol,
casadi_int  p,
casadi_int  r 
)
inlinestaticinherited

with nrow-by-ncol symbolic primitives

Extra doc: https://github.com/casadi/casadi/wiki/L_1dg

Definition at line 1280 of file generic_matrix.hpp.

1280  {
1281  return sym(name, Sparsity::dense(nrow, ncol), p, r);
1282  }

◆ sym() [3/7]

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::sym ( const std::string &  name,
casadi_int  nrow = 1,
casadi_int  ncol = 1 
)
inlinestaticinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1da

Examples
SX/SXaddition.cc, and SX/ssym.py.

Definition at line 1233 of file generic_matrix.hpp.

1233  {
1234  return sym(name, Sparsity::dense(nrow, ncol));
1235  }

◆ sym() [4/7]

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::sym ( const std::string &  name,
const Sparsity sp 
)
inlinestaticinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1dc

Definition at line 1247 of file generic_matrix.hpp.

1247  {
1248  return MatType::_sym(name, sp);
1249  }

◆ sym() [5/7]

std::vector< Matrix< Scalar > > casadi::GenericMatrix< Matrix< Scalar > >::sym ( const std::string &  name,
const Sparsity sp,
casadi_int  p 
)
staticinherited

with symbolic primitives of given sparsity

Extra doc: https://github.com/casadi/casadi/wiki/L_1dd

Definition at line 1256 of file generic_matrix.hpp.

1383  {
1384  std::vector<MatType> ret(p);
1385  std::stringstream ss;
1386  for (casadi_int k=0; k<p; ++k) {
1387  ss.str("");
1388  ss << name << k;
1389  ret[k] = sym(ss.str(), sp);
1390  }
1391  return ret;
1392  }

◆ sym() [6/7]

std::vector< std::vector< Matrix< Scalar > > > casadi::GenericMatrix< Matrix< Scalar > >::sym ( const std::string &  name,
const Sparsity sp,
casadi_int  p,
casadi_int  r 
)
staticinherited

symbolic primitives with given sparsity

Extra doc: https://github.com/casadi/casadi/wiki/L_1df

Definition at line 1272 of file generic_matrix.hpp.

1397  {
1398  std::vector<std::vector<MatType> > ret(r);
1399  for (casadi_int k=0; k<r; ++k) {
1400  std::stringstream ss;
1401  ss << name << "_" << k;
1402  ret[k] = sym(ss.str(), sp, p);
1403  }
1404  return ret;
1405  }

◆ sym() [7/7]

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::sym ( const std::string &  name,
const std::pair< casadi_int, casadi_int > &  rc 
)
inlinestaticinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1db

Definition at line 1240 of file generic_matrix.hpp.

1240  {
1241  return sym(name, rc.first, rc.second);
1242  }

◆ symvar()

template<typename Scalar >
static std::vector<Matrix<Scalar> > casadi::Matrix< Scalar >::symvar ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ T()

template<typename Scalar >
Matrix<Scalar> casadi::Matrix< Scalar >::T ( ) const

◆ tangent()

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::tangent ( const Matrix< Scalar > &  ex,
const Matrix< Scalar > &  arg,
const Dict opts = Dict() 
)
staticinherited

Functions called by friend functions defined here

◆ taylor()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::taylor ( const Matrix< Scalar > &  ex,
const Matrix< Scalar > &  x,
const Matrix< Scalar > &  a,
casadi_int  order 
)
static

Functions called by friend functions defined here

◆ to_file() [1/2]

template<typename Scalar >
static void casadi::Matrix< Scalar >::to_file ( const std::string &  filename,
const Sparsity sp,
const Scalar *  nonzeros,
const std::string &  format = "" 
)
static

◆ to_file() [2/2]

template<typename Scalar >
void casadi::Matrix< Scalar >::to_file ( const std::string &  filename,
const std::string &  format = "" 
) const

Export numerical matrix to file

Supported formats:

*   - .mtx   Matrix Market (sparse)
*   - .txt   Ascii full precision representation (sparse)
*            Whitespace separated, aligned.
*            Comments with # % or /
*            Uses C locale
*            Structural zeros represented by 00
*            Does not scale well for large sparse matrices
* 

◆ trace()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::trace ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined for GenericMatrix

◆ transform() [1/4]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::transform ( const Matrix< Scalar > &  x,
const Dict opts = Dict() 
)
static

Functions called by friend functions defined for GenericMatrix

◆ transform() [2/4]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::transform ( const Matrix< Scalar > &  x,
const std::vector< std::vector< GenericType > > &  passes,
const Dict opts = Dict() 
)
static

Functions called by friend functions defined for GenericMatrix

◆ transform() [3/4]

template<typename Scalar >
static std::vector<Matrix<Scalar> > casadi::Matrix< Scalar >::transform ( const std::vector< Matrix< Scalar > > &  x,
const Dict opts = Dict() 
)
static

Functions called by friend functions defined for GenericMatrix

◆ transform() [4/4]

template<typename Scalar >
static std::vector<Matrix<Scalar> > casadi::Matrix< Scalar >::transform ( const std::vector< Matrix< Scalar > > &  x,
const std::vector< std::vector< GenericType > > &  passes,
const Dict opts = Dict() 
)
static

Functions called by friend functions defined for GenericMatrix

◆ triangle()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::triangle ( const Matrix< Scalar > &  x)
static

Functions called by friend functions defined here

◆ tril()

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::tril ( const Matrix< Scalar > &  x,
bool  includeDiagonal = true 
)
inlinestaticinherited

Definition at line 219 of file generic_matrix.hpp.

219  {
220  return project(x, Sparsity::tril(x.sparsity(), includeDiagonal));
221  }
friend Matrix< Scalar > project(const Matrix< Scalar > &A, const Sparsity &sp, bool intersect=false)
Create a new matrix with a given sparsity pattern but with the.

◆ tril2symm()

Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::tril2symm ( const Matrix< Scalar > &  x)
staticinherited

Definition at line 230 of file generic_matrix.hpp.

1547  {
1548  casadi_assert(x.is_square(),
1549  "Shape error in tril2symm. Expecting square shape but got " + x.dim());
1550  casadi_assert(x.nnz_upper()-x.nnz_diag()==0,
1551  "Sparsity error in tril2symm. Found above-diagonal entries in argument: " + x.dim());
1552  return x + x.T() - diag(diag(x));
1553  }
friend Matrix< Scalar > diag(const Matrix< Scalar > &A)
Get the diagonal of a matrix or construct a diagonal.

◆ triplet() [1/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::triplet ( const std::vector< casadi_int > &  row,
const std::vector< casadi_int > &  col,
const Matrix< Scalar > &  d 
)
static

Default matrix size is max(col) x max(row)

Extra doc: https://github.com/casadi/casadi/wiki/L_23t

◆ triplet() [2/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::triplet ( const std::vector< casadi_int > &  row,
const std::vector< casadi_int > &  col,
const Matrix< Scalar > &  d,
casadi_int  nrow,
casadi_int  ncol 
)
static

Default matrix size is max(col) x max(row)

Extra doc: https://github.com/casadi/casadi/wiki/L_23t

◆ triplet() [3/3]

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::triplet ( const std::vector< casadi_int > &  row,
const std::vector< casadi_int > &  col,
const Matrix< Scalar > &  d,
const std::pair< casadi_int, casadi_int > &  rc 
)
static

Default matrix size is max(col) x max(row)

Extra doc: https://github.com/casadi/casadi/wiki/L_23t

◆ triu()

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::triu ( const Matrix< Scalar > &  x,
bool  includeDiagonal = true 
)
inlinestaticinherited

Definition at line 222 of file generic_matrix.hpp.

222  {
223  return project(x, Sparsity::triu(x.sparsity(), includeDiagonal));
224  }

◆ triu2symm()

Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::triu2symm ( const Matrix< Scalar > &  x)
staticinherited

Definition at line 231 of file generic_matrix.hpp.

1571  {
1572  casadi_assert(x.is_square(),
1573  "Shape error in triu2symm. Expecting square shape but got " + x.dim());
1574  casadi_assert(x.nnz_lower()-x.nnz_diag()==0,
1575  "Sparsity error in triu2symm. Found below-diagonal entries in argument: " + x.dim());
1576  return x + x.T() - diag(diag(x));
1577  }

◆ type_name()

template<typename Scalar >
std::string casadi::Matrix< Scalar >::type_name
static

Definition at line 616 of file matrix_impl.hpp.

616 { return matrixName<Scalar>(); }

◆ unary()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::unary ( casadi_int  op,
const Matrix< Scalar > &  x 
)
static

◆ unite()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::unite ( const Matrix< Scalar > &  A,
const Matrix< Scalar > &  B 
)
static

Functions called by friend functions defined for GenericMatrix

◆ vertcat()

template<typename Scalar >
static Matrix<Scalar> casadi::Matrix< Scalar >::vertcat ( const std::vector< Matrix< Scalar > > &  v)
static

Functions called by friend functions defined for SparsityInterface

◆ vertsplit()

template<typename Scalar >
static std::vector< Matrix<Scalar> > casadi::Matrix< Scalar >::vertsplit ( const Matrix< Scalar > &  x,
const std::vector< casadi_int > &  offset 
)
static

Functions called by friend functions defined for SparsityInterface

◆ which_depends()

template<typename Scalar >
static std::vector<bool> casadi::Matrix< Scalar >::which_depends ( const Matrix< Scalar > &  expr,
const Matrix< Scalar > &  var,
casadi_int  order = 1,
bool  tr = false 
)
static

Functions called by friend functions defined here

◆ which_function()

Function CASADI_EXPORT casadi::SX::which_function

Extra doc: https://github.com/casadi/casadi/wiki/L_28n

Definition at line 172 of file sx_instantiator.cpp.

172  {
173  return scalar().which_function();
174  }

References casadi::Matrix< Scalar >::scalar().

◆ which_output()

casadi_int CASADI_EXPORT casadi::SX::which_output

Extra doc: https://github.com/casadi/casadi/wiki/L_28m

Definition at line 177 of file sx_instantiator.cpp.

177  {
178  return scalar().which_output();
179  }

References casadi::Matrix< Scalar >::scalar().

◆ zeros() [1/3]

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::zeros ( casadi_int  nrow = 1,
casadi_int  ncol = 1 
)
inlinestaticinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1dh

Definition at line 1289 of file generic_matrix.hpp.

1289  {
1290  return zeros(Sparsity::dense(nrow, ncol));
1291  }

◆ zeros() [2/3]

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::zeros ( const Sparsity sp)
inlinestaticinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1dh

Definition at line 1292 of file generic_matrix.hpp.

1292 { return MatType(sp, 0, false);}

◆ zeros() [3/3]

static Matrix< Scalar > casadi::GenericMatrix< Matrix< Scalar > >::zeros ( const std::pair< casadi_int, casadi_int > &  rc)
inlinestaticinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_1dh

Definition at line 1293 of file generic_matrix.hpp.

1293  {
1294  return zeros(rc.first, rc.second);
1295  }

Friends And Related Function Documentation

◆ get_ptr [1/2]

template<typename Scalar >
const Scalar* get_ptr ( const Matrix< Scalar > &  v)
friend

Get a pointer to the data

Definition at line 1032 of file matrix_decl.hpp.

1032 { return v.ptr(); }

◆ get_ptr [2/2]

template<typename Scalar >
Scalar* get_ptr ( Matrix< Scalar > &  v)
friend

Get a pointer to the data

Definition at line 1031 of file matrix_decl.hpp.

1031 { return v.ptr(); }

The documentation for this class was generated from the following files: