MLinExpr::MLinExpr()
Construct a MLinExpr object with the given shape and a constant.
Synopsis
MLinExpr(const Shape<N> &shp, double constant)
Arguments
shp
: shape of MLinExpr.
constant
: constant number.
MLinExpr::MLinExpr()
Construct a MLinExpr object with the given shape and a linear expression.
Synopsis
MLinExpr(const Shape<N> &shp, const Expr &expr)
Arguments
shp
: shape of MLinExpr.
expr
: a linear expression.
MLinExpr::MLinExpr()
Construct a MLinExpr object with the given shape and a MExpression object.
Synopsis
MLinExpr(const Shape<N> &shp, const MExpression &expr)
Arguments
shp
: shape of MLinExpr.
expr
: a MExpression object.
MLinExpr::AddConstant()
Add constant to each expression in MLinExpr object.
Synopsis
void AddConstant(double constant)
Arguments
constant
: the value of the constant.
MLinExpr::AddConstant()
Add constants to each expression in MLinExpr object.
Synopsis
template <class T> void AddConstant(const NdArray<T, N> &constants)
Arguments
constants
: N-dimension NdArray object.
MLinExpr::AddExpr()
Add a linear expression to each expression in MLinExpr object.
Synopsis
void AddExpr(const Expr &expr, double mult)
Arguments
expr
: linear expression object.
mult
: the multiplier of linear expression, default value is 1.0.
MLinExpr::AddMExpr()
Add MExpression to each expression in MLinExpr object.
Synopsis
void AddMExpr(const MExpression &expr, double mult)
Arguments
expr
: MExpression object.
mult
: the multiplier of MExpression, default value is 1.0.
MLinExpr::AddMLinExpr()
Add linear expressions to MLinExpr object.
Synopsis
void AddMLinExpr(const MLinExpr<N> &exprs, double mult)
Arguments
exprs
: N-dimension MLinExpr object.
mult
: the same multiplier for added linear expressions, default value is 1.0.
MLinExpr::AddTerm()
Add a linear term to MLinExpr object.
Synopsis
void AddTerm(const Var &var, double coeff)
Arguments
var
: variable of new term.
coeff
: coefficient of new term.
MLinExpr::AddTerms()
Add terms to expressions in MLinExpr object.
Synopsis
void AddTerms(const MVar<N> &vars, double mult)
Arguments
vars
: N-dimension MVar object for added terms.
mult
: the same coefficient for added terms, default value 1.0.
MLinExpr::AddTerms()
Add terms to expressions in MLinExpr object.
Synopsis
void AddTerms(const MVar<N> &vars, const NdArray<double, N> &coeffs)
Arguments
vars
: N-dimension MVar object for added terms.
coeffs
: N-dimension NdArray object of coefficients for added terms.
MLinExpr::Clear()
Clear MLinExpr object.
Synopsis
void Clear()
MLinExpr::Clone()
Clone MLinExpr object.
Synopsis
MLinExpr Clone()
Return
new MLinExpr object.
MLinExpr::Diagonal()
Get diagonals of MLinExpr object.
Synopsis
MLinExpr<N - 1> Diagonal(
int offset,
int axis1,
int axis2)
Arguments
offset
: offset of the diagonal from the main diagonal. Can be positive or negative.
axis1
: 1st axis of MLinExpr.
axis2
: 2nd axis of MLinExpr.Return
(N-1)-dimensional diagonals.
MLinExpr::Expand()
Expand shape of MLinExpr object.
Synopsis
MLinExpr<N + 1> Expand(int axis)
Arguments
axis
: axis of MLinExpr.Return
MLinExpr object of (N+1)-dimensional shape.
MLinExpr::Flatten()
Flatten a MLinExpr object to a 1-dimensional shape.
Synopsis
MLinExpr<1> Flatten()
Return
a MLinExpr object collapsed into one dimension.
MLinExpr::GetDim()
Get i-th dimension of MLinExpr object.
Synopsis
size_t GetDim(int i)
Arguments
i
: index of dimensionReturn
i-th dimension.
MLinExpr::GetND()
Get number of dimensions of MLinExpr object.
Synopsis
int GetND()
Return
number of dimensions.
MLinExpr::GetShape()
Get shape of MLinExpr object.
Synopsis
Shape<N> GetShape()
Return
shape object.
MLinExpr::GetSize()
Get size of MLinExpr object.
Synopsis
size_t GetSize()
Return
number of MExpressions.
MLinExpr::Item()
Get expression of given index from MLinExpr object.
Synopsis
MExpression &Item(size_t idx)
Arguments
idx
: index of expression.Return
expression object.
MLinExpr::operator[]()
Get expression of given index from MLinExpr object.
Synopsis
MExpression &operator[](size_t i)
Arguments
i
: index of expression.Return
expression object.
MLinExpr::operator[]()
Get constraints of given view from MLinExpr object.
Synopsis
MLinExpr operator[](const View &view)
Arguments
view
: view of multi-dimensional array.Return
new MLinExpr object.
MLinExpr::Represent()
String representation of MLinExpr object.
Synopsis
std::string Represent(size_t maxlen)
Arguments
maxlen
: max length of representation.Return
string object.
MLinExpr::Reshape()
Reshape MLinExpr object to new shape.
Synopsis
template <int M> MLinExpr<M> Reshape(const Shape<M> &shape)
Arguments
shape
: new shape of M-dimensions.Return
M-dimensional MLinExpr object.
MLinExpr::SetItem()
Set expression of given index to MLinExpr object.
Synopsis
void SetItem(size_t idx, const MExpression &expr)
Arguments
idx
: index of element.
expr
: MExpression object.
MLinExpr::Squeeze()
Remove axis of length 1 from shape of MLinExpr object.
Synopsis
MLinExpr<N - 1> Squeeze(int axis)
Arguments
axis
: axis of MLinExpr, where the length is 1.Return
MLinExpr object of (N-1)-dimensional shape.
MLinExpr::SubConstant()
Substract constants from each expression in MLinExpr object.
Synopsis
template <class T> void SubConstant(const NdArray<T, N> &constants)
Arguments
constants
: N-dimension NdArray object.
MLinExpr::Sum()
Sum of all expressions in MLinExpr object.
Synopsis
MLinExpr<0> Sum()
Return
sum in zero dimension.
MLinExpr::Sum()
Sum of expressions at given axis of MLinExpr object.
Synopsis
MLinExpr<N - 1> Sum(int axis)
Arguments
axis
: axis of MLinExprReturn
MLinExpr object in (N-1)-dimension.
MLinExpr::Transpose()
Perform matrix transpose of MLinExpr object.
Synopsis
MLinExpr<N> Transpose()
Return
transposed MLinExpr object.