14.2.15 Class Expression¶
- mosek::fusion::Expression¶
Abstract base class for all objects which can be used as linear expressions of the form \(Ax+b.\)
The main use of this class is to store the result of expressions created by the static methods provided by
Expr
.- Members
Expression.eval – Evaluate the expression and push the result onto the work stack.
Expression.getDim – Return the d’th dimension in the expression.
Expression.getND – Return the number of dimensions in the expression.
Expression.getShape – Get the shape of the expression.
Expression.getSize – Return the total number of elements in the expression (the product of the dimensions).
Expression.index – Get a single element in the expression.
Expression.pick – Pick a number of elements from the expression.
Expression.slice – Get a slice of the expression.
Expression.toString – Return a string representation of the expression object.
- Implemented by
- Expression.eval¶
void eval(WorkStack::t rs, WorkStack::t ws, WorkStack::t xs)
Evaluate the expression and push the result onto the
rs
work stack.
- Expression.getDim¶
int getDim(int d)
Return the d’th dimension in the expression.
- Parameters
d
(int
)- Return
(
int
)
- Expression.getND¶
int getND()
Return the number of dimensions in the expression.
- Return
(
int
)
- Expression.getShape¶
shared_ptr<ndarray<int,1>> getShape()
Get the shape of the expression.
- Return
(
int
[])
- Expression.getSize¶
long long getSize()
Return the total number of elements in the expression (the product of the dimensions).
- Return
(
long long
)
- Expression.index¶
Expression::t index(int i) Expression::t index(shared_ptr<ndarray<int,1>> indexes)
Get a single element in the expression.
- Parameters
i
(int
) – Index of the element to pick.indexes
(int
[]) – Multi-dimensional index of the element to pick.
- Return
- Expression.pick¶
Expression::t pick(shared_ptr<ndarray<int,1>> indexes) Expression::t pick(shared_ptr<ndarray<int,2>> indexrows)
Picks a number of elements from the expression and returns them as a one-dimensional expression.
- Parameters
indexes
(int
[]) – Indexes of the elements to pickindexrows
(int
[][]) – Indexes of the elements to pick. Each row defines a separate multi-dimensional index.
- Return
- Expression.slice¶
Expression::t slice(int first, int last) Expression::t slice(shared_ptr<ndarray<int,1>> firsta, shared_ptr<ndarray<int,1>> lasta)
Get a slice of the expression.
- Parameters
first
(int
) – Index of the first element in the slice.last
(int
) – Index of the last element in the slice plus one.firsta
(int
[]) – Multi-dimensional index of the first element in the slice.lasta
(int
[]) – Multi-dimensional index of the element after the end of the slice.
- Return
- Expression.toString¶
string toString()
Return a string representation of the expression object.
- Return
(
string
)