Class representing a Slice. More...
#include <slice.hpp>
Note that Python or Octave do not need to use this class. They can just use slicing utility from the host language ( M[0:6] in Python, M(1:7) )
Extra doc: https://github.com/casadi/casadi/wiki/L_13


Public Member Functions | |
| Slice () | |
| Default constructor - all elements. More... | |
| Slice (casadi_int i, bool ind1=false) | |
| A single element (explicit to avoid ambiguity with IM overload. More... | |
| Slice (casadi_int start, casadi_int stop, casadi_int step=1) | |
| A slice. More... | |
| Slice (int start, int stop, int step=1) | |
| Slice (int start, casadi_int stop, int step=1) | |
| Slice (casadi_int start, int stop, int step=1) | |
| std::vector< casadi_int > | all () const |
| Get a vector of indices. More... | |
| std::vector< casadi_int > | all (casadi_int len, bool ind1=false) const |
| Get a vector of indices. More... | |
| std::vector< casadi_int > | all (const Slice &outer, casadi_int len) const |
| Get a vector of indices (nested slice) More... | |
| size_t | size () const |
| Get number of elements. More... | |
| bool | is_empty () const |
| Check if slice is empty. More... | |
| bool | is_scalar (casadi_int len) const |
| Is the slice a scalar. More... | |
| casadi_int | scalar (casadi_int len) const |
| Get scalar (if is_scalar) More... | |
| bool | operator== (const Slice &other) const |
| Check equality. More... | |
| bool | operator!= (const Slice &other) const |
| Check inequality. More... | |
| Slice | apply (casadi_int len, bool ind1=false) const |
| Apply concrete length. More... | |
| Slice | operator- (casadi_int i) const |
| Substract. More... | |
| Slice | operator* (casadi_int i) const |
| std::string | type_name () const |
| Get name of the class. More... | |
| void | disp (std::ostream &stream, bool more=false) const |
| Print a description of the object. More... | |
| std::string | get_str (bool more=false) const |
| Get string representation. More... | |
| Dict | info () const |
| void | serialize (SerializingStream &s) const |
| Serialize an object. More... | |
Static Public Member Functions | |
| static Slice | deserialize (DeserializingStream &s) |
| Deserialize without type information. More... | |
Public Attributes | |
| casadi_int | start |
| start value: negative values will get added to length More... | |
| casadi_int | stop |
| stop value: use std::numeric_limits<casadi_int>::max() to indicate unboundedness More... | |
| casadi_int | step |
| casadi::Slice::Slice | ( | ) |
Definition at line 32 of file slice.cpp.
Referenced by apply(), deserialize(), operator*(), and operator-().
|
explicit |
Definition at line 35 of file slice.cpp.
References stop, and casadi::str().
| casadi::Slice::Slice | ( | casadi_int | start, |
| casadi_int | stop, | ||
| casadi_int | step = 1 |
||
| ) |
| casadi::Slice::Slice | ( | int | start, |
| int | stop, | ||
| int | step = 1 |
||
| ) |
| casadi::Slice::Slice | ( | int | start, |
| casadi_int | stop, | ||
| int | step = 1 |
||
| ) |
| casadi::Slice::Slice | ( | casadi_int | start, |
| int | stop, | ||
| int | step = 1 |
||
| ) |
| std::vector< casadi_int > casadi::Slice::all | ( | ) | const |
Definition at line 90 of file slice.cpp.
References casadi::range(), start, step, and stop.
Referenced by all(), casadi::Matrix< Scalar >::get(), casadi::MX::get(), casadi::MX::get_nz(), casadi::MXNode::get_nz_ref(), casadi::Matrix< Scalar >::set(), casadi::MX::set(), casadi::Matrix< Scalar >::set_nz(), casadi::MX::set_nz(), and size().
| std::vector< casadi_int > casadi::Slice::all | ( | casadi_int | len, |
| bool | ind1 = false |
||
| ) | const |
Definition at line 100 of file slice.cpp.
| std::vector< casadi_int > casadi::Slice::all | ( | const Slice & | outer, |
| casadi_int | len | ||
| ) | const |
| Slice casadi::Slice::apply | ( | casadi_int | len, |
| bool | ind1 = false |
||
| ) | const |
Definition at line 66 of file slice.cpp.
References Slice(), start, step, stop, and casadi::str().
Referenced by all(), and casadi::MX::get().
|
static |
Extra doc: https://github.com/casadi/casadi/wiki/L_15
Definition at line 298 of file slice.cpp.
References Slice(), start, step, stop, and casadi::DeserializingStream::unpack().
Referenced by casadi::DeserializingStream::unpack().
| void casadi::Slice::disp | ( | std::ostream & | stream, |
| bool | more = false |
||
| ) | const |
|
inline |
Definition at line 113 of file slice.hpp.
|
inline |
Obtain information
Definition at line 120 of file slice.hpp.
Referenced by casadi::SubAssign::info(), and casadi::SubRef::info().
| bool casadi::Slice::is_empty | ( | ) | const |
Definition at line 111 of file slice.cpp.
References size().
Referenced by casadi::MXNode::get_nzadd().
| bool casadi::Slice::is_scalar | ( | casadi_int | len | ) | const |
Definition at line 139 of file slice.cpp.
References start, step, and stop.
Referenced by casadi::Matrix< Scalar >::get(), scalar(), casadi::Matrix< Scalar >::set(), and casadi::Matrix< Scalar >::set_nz().
|
inline |
| Slice casadi::Slice::operator* | ( | casadi_int | i | ) | const |
| Slice casadi::Slice::operator- | ( | casadi_int | i | ) | const |
|
inline |
| casadi_int casadi::Slice::scalar | ( | casadi_int | len | ) | const |
Definition at line 146 of file slice.cpp.
References is_scalar(), and start.
Referenced by casadi::Matrix< double >::einstein(), casadi::Matrix< Scalar >::get(), casadi::Matrix< double >::operator->(), casadi::Matrix< Scalar >::set(), and casadi::Matrix< Scalar >::set_nz().
| void casadi::Slice::serialize | ( | SerializingStream & | s | ) | const |
Extra doc: https://github.com/casadi/casadi/wiki/L_14
Definition at line 292 of file slice.cpp.
References casadi::SerializingStream::pack(), start, step, and stop.
Referenced by casadi::SerializingStream::pack().
| size_t casadi::Slice::size | ( | ) | const |
Definition at line 104 of file slice.cpp.
References all(), start, and stop.
Referenced by casadi::GetNonzerosParam::create(), and is_empty().
|
inline |
| casadi_int casadi::Slice::start |
Definition at line 51 of file slice.hpp.
Referenced by all(), apply(), casadi::SetNonzeros< Add >::create(), casadi::GetNonzeros::create(), deserialize(), disp(), casadi::GetNonzerosSliceParam::eval(), casadi::GetNonzerosParamSlice::eval(), casadi::GetNonzerosSlice::eval_gen(), casadi::GetNonzerosSlice2::eval_gen(), casadi::GetNonzerosSlice::generate(), casadi::GetNonzerosSlice2::generate(), casadi::GetNonzerosSliceParam::generate(), casadi::GetNonzerosParamSlice::generate(), is_scalar(), operator*(), operator-(), operator==(), scalar(), serialize(), size(), casadi::GetNonzerosSlice::sp_forward(), casadi::GetNonzerosSlice2::sp_forward(), casadi::GetNonzerosSlice::sp_reverse(), casadi::GetNonzerosSlice2::sp_reverse(), casadi::to_slice(), and casadi::to_slice2().
| casadi_int casadi::Slice::step |
Definition at line 54 of file slice.hpp.
Referenced by all(), apply(), casadi::SetNonzeros< Add >::create(), casadi::GetNonzeros::create(), deserialize(), disp(), casadi::GetNonzerosSliceParam::eval(), casadi::GetNonzerosParamSlice::eval(), casadi::GetNonzerosSlice::eval_gen(), casadi::GetNonzerosSlice2::eval_gen(), casadi::GetNonzerosSlice::generate(), casadi::GetNonzerosSlice2::generate(), casadi::GetNonzerosSliceParam::generate(), casadi::GetNonzerosParamSlice::generate(), is_scalar(), operator*(), operator-(), operator==(), serialize(), casadi::GetNonzerosSlice::sp_forward(), casadi::GetNonzerosSlice2::sp_forward(), casadi::GetNonzerosSlice::sp_reverse(), casadi::GetNonzerosSlice2::sp_reverse(), casadi::to_slice(), and casadi::to_slice2().
| casadi_int casadi::Slice::stop |
Definition at line 53 of file slice.hpp.
Referenced by all(), apply(), casadi::SetNonzeros< Add >::create(), casadi::GetNonzeros::create(), deserialize(), disp(), casadi::GetNonzerosSliceParam::eval(), casadi::GetNonzerosParamSlice::eval(), casadi::GetNonzerosSlice::eval_gen(), casadi::GetNonzerosSlice2::eval_gen(), casadi::GetNonzerosSlice::generate(), casadi::GetNonzerosSlice2::generate(), casadi::GetNonzerosSliceParam::generate(), casadi::GetNonzerosParamSlice::generate(), is_scalar(), operator*(), operator-(), operator==(), serialize(), size(), Slice(), casadi::GetNonzerosSlice::sp_forward(), casadi::GetNonzerosSlice2::sp_forward(), casadi::GetNonzerosSlice::sp_reverse(), casadi::GetNonzerosSlice2::sp_reverse(), casadi::to_slice(), and casadi::to_slice2().