Affine Atoms¶
All of the atoms listed here are affine in their arguments.
MulExpression¶
-
class
cvxpy.atoms.affine.binary_operators.
MulExpression
(lh_exp, rh_exp)[source]¶ Bases:
cvxpy.atoms.affine.binary_operators.BinaryOperator
Matrix multiplication.
The semantics of multiplication are exactly as those of NumPy’s matmul function, except here multiplication by a scalar is permitted. MulExpression objects can be created by using the ‘*’ operator of the Expression class.
- Parameters
lh_exp (
Expression
) – The left-hand side of the multiplication.rh_exp (
Expression
) – The right-hand side of the multiplication.
Bmat¶
-
cvxpy.atoms.affine.bmat.
bmat
(block_lists)[source]¶ Constructs a block matrix.
Takes a list of lists. Each internal list is stacked horizontally. The internal lists are stacked vertically.
- Parameters
block_lists (
list
oflists
) – The blocks of the block matrix.- Returns
The CVXPY expression representing the block matrix.
- Return type
CVXPY expression
conv¶
-
class
cvxpy.atoms.affine.conv.
conv
(lh_expr, rh_expr)[source]¶ Bases:
cvxpy.atoms.affine.affine_atom.AffAtom
1D discrete convolution of two vectors.
The discrete convolution \(c\) of vectors \(a\) and \(b\) of lengths \(n\) and \(m\), respectively, is a length-\((n+m-1)\) vector where
\[c_k = \sum_{i+j=k} a_ib_j, \quad k=0, \ldots, n+m-2.\]- Parameters
lh_expr (
Constant
) – A constant 1D vector or a 2D column vector.rh_expr (
Expression
) – A 1D vector or a 2D column vector.
diag¶
diff¶
-
cvxpy.atoms.affine.diff.
diff
(x, k=1, axis=0)[source]¶ Vector of kth order differences.
Takes in a vector of length n and returns a vector of length n-k of the kth order differences.
diff(x) returns the vector of differences between adjacent elements in the vector, that is
[x[2] - x[1], x[3] - x[2], …]
diff(x, 2) is the second-order differences vector, equivalently diff(diff(x))
diff(x, 0) returns the vector x unchanged
index¶
-
class
cvxpy.atoms.affine.index.
index
(expr, key, orig_key=None)[source]¶ Bases:
cvxpy.atoms.affine.affine_atom.AffAtom
Indexing/slicing into an Expression.
CVXPY supports NumPy-like indexing semantics via the Expression class’ overloading of the
[]
operator. This is a low-level class constructed by that operator, and it should not be instantiated directly.- Parameters
expr (
Expression
) – The expression indexed/sliced into.key – The index/slicing key (i.e. expr[key[0],key[1]]).
multiply¶
-
class
cvxpy.atoms.affine.binary_operators.
multiply
(lh_expr, rh_expr)[source]¶ Bases:
cvxpy.atoms.affine.binary_operators.MulExpression
Multiplies two expressions elementwise.
reshape¶
-
class
cvxpy.atoms.affine.reshape.
reshape
(expr, shape, order='F')[source]¶ Bases:
cvxpy.atoms.affine.affine_atom.AffAtom
Reshapes the expression.
Vectorizes the expression then unvectorizes it into the new shape. The entries are reshaped and stored in column-major order, also known as Fortran order.
- Parameters
expr (
Expression
) – The expression to promote.shape (
tuple
orint
) – The shape to promote to.order (
F(ortran)
orC
) –
upper_tri¶
-
class
cvxpy.atoms.affine.upper_tri.
upper_tri
(expr)[source]¶ Bases:
cvxpy.atoms.affine.affine_atom.AffAtom
The vectorized strictly upper-triagonal entries.
The vectorization is performed by concatenating (partial) rows. For example, if ``` A = np.array([[10, 11, 12, 13],
[14, 15, 16, 17], [18, 19, 20, 21], [22, 23, 24, 25]])
` then we have `
upper_tri(A).value == np.array([11, 12, 13, 16, 17, 21]) ```