For the legal operations on optimization variables and expressions:
x1
and x2
represent optimization
arrays of arbitrary size.
x3
represents a 2-D optimization array.
a
is a scalar numeric constant.
M
is a constant numeric matrix.
c
is an array of the same size as
x1
.
These operations on optimization variables or expressions return an optimization expression.
Addition of a constant, x1+c
or
c+x1
Addition of two or more variables, x1+x2
Unary plus, +x1
Subtraction of a constant, x1-c
Subtraction of two or more variables, x1–x2
Unary minus, -x1
Multiplication by a constant scalar, a*x1
or
a.*x1
or x1*a
or
x1.*a
Division by a constant scalar, x1/a
or
x1./a
or a\x1
or
a.\x1
Pointwise multiplication by an array, c.*x1
or
x1.*c
Pointwise division by an array, x1./c
or
c.\x1
Multiplication of a 2-D variable by a 2-D matrix, M*x3
or x3*M
Dot product of a variable and an array dot(x1,c)
or
dot(c,x1)
Linear combination of variables, including sum
,
sum(x1)
, sum(x1,2)
Transpose operation, x1'
or
x1.'
Concatenation (cat
, vertcat
, and
horzcat
)
Reshape operation, reshape(x1,[10 1])
These operations on optimization variables return an optimization variable with
the IsReference
property value true
.
N-D numeric indexing (includes colon and end
)
N-D logical indexing
N-D string indexing
N-D mixed indexing (combination of numeric, logical, colon, end, and string)
Linear numeric indexing (includes colon and end
)
Linear logical indexing
Linear string indexing
Optimization expressions support all the operations that optimization variables
support, and return optimization expressions. Also, you can index into or assign
into an optimization expression using numeric, logical, string, or linear indexing,
including the colon and end
operators for numeric or linear
indexing.
Constraints are any two comparable expressions that include
one of these comparison operators: ==
, <=
,
or >=
. Comparable expressions have the same size, or one of the
expressions must be scalar, meaning of size 1-by-1. For examples, see Expressions for Constraints.
Internally, some functions and operations call only the documented supported
operations. In these cases you can obtain sensible results from the functions or
operations. For example, currently squeeze
internally calls
reshape
, which is a documented supported operation. So if you
squeeze
an optimization variable then you can obtain a
sensible expression.
OptimizationExpression
| OptimizationVariable