N ( NDSparseArray) – An NDSparseArray object. ParametersĪ1 ( float) – A one-dimensional array of constants.Ī2 ( float) – A two-dimensional array of constants. the scalar is added to all entries of the other argument. That matches the shape of the other argument, i.e. If one of the arguments is a single scalar, it is promoted to the shape The arguments must have the same shapes and the returned expression also has that shape. The following types of arguments are allowed:īy symmetry both add(A,B) and add(B,A) are available. Expr.add ¶Įxpr.add(Expression e1, Expression e2) -> ExpressionĮxpr.add(Expression e1, float a1) -> ExpressionĮxpr.add(Expression e1, float a2) -> ExpressionĮxpr.add(float a1, Expression e2) -> ExpressionĮxpr.add(float a2, Expression e2) -> ExpressionĮxpr.add(Expression e1, float c) -> ExpressionĮxpr.add(float c, Expression e2) -> ExpressionĮxpr.add(Expression e1, Matrix m) -> ExpressionĮxpr.add(Matrix m, Expression e2) -> ExpressionĮxpr.add(Expression e1, NDSparseArray n) -> ExpressionĮxpr.add(NDSparseArray n, Expression e2) -> ExpressionĮxpr.add(Expression exps) -> ExpressionĬomputes the sum of two or more expressions or variables. along the first dimension).Įxpr.zeros – Create an expression consisting of zeros. along the second dimension).Įxpr.mulDiag – Compute the diagonal of the product of two matrices.Įxpr.mulElm – Element-wise product of two items.Įxpr.neg – Change the sign of an expressionĮxpr.ones – Create an expression consisting of ones.Įxpr.outer – Return the outer-product of two vectors.Įxpr.repeat – Repeat an expression a number of times in the given dimension.Įxpr.reshape – Reshape the expression into a different shape with the same number of elements.Įxpr.stack – Stack a list of expressions in an arbitrary dimension.Įxpr.sub – Compute the difference of two expressions.Įxpr.sum – Sum the elements of an expression.Įxpr.transpose – Transpose a two-dimensional expression.Įxpr.vstack – Stack a list of expressions vertically (i.e. Static membersĮxpr.add – Compute the sum of expressions.Įxpr.condense – Flatten expression and remove all structural zeros.Įxpr.constTerm – Create an expression consisting of a constant vector of values.Įxpr.dot – Return a scalar expression object representing the dot-product of two items.Įxpr.flatten – Reshape the expression into a vector.Įxpr.hstack – Stack a list of expressions horizontally (i.e. \(A\) is a matrix on sparse form, \(x\) is a variable vector and \(b\) is aĪdditionally, the class defines a set of static methods for constructing and manipulatingīaseExpression.getDim – Return the d’th dimension in the expression.īaseExpression.getND – Return the number of dimensions in the expression.īaseExpression.getShape – Get the shape of the expression.īaseExpression.getSize – Return the total number of elements in the expression (the product of the dimensions).īaseExpression.index – Get a single element in the expression.īaseExpression.pick – Pick a number of elements from the expression.īaseExpression.slice – Get a slice of the expression.īaseExpression.toString – Return a string representation of the expression object.Įxpr.eval – Evaluate the expression and push the result onto the work stack. The function power(expr, p).It represents an expression of the form \(Ax b\), where The power operator expr**p is equivalent to The transpose of any expression can be obtained using the syntaxĮxpr.T. O dimensional : () 1 dimensional : ( 1 ,) Transpose ¶ Indexing drops dimensions while slicing preserves dimensions. While expr selects both rows and columns. If expr is a matrix, then expr selects rows, More generally, expr selects every kthĮlement of expr, starting at i and ending at j-1. Indexing in CVXPY follows exactly the same semantics as NumPy ndarrays.įor example, if expr has shape (5,) then expr gives the second entry. * should be matrix-scalar and vector-scalar multiplicationĮlementwise multiplication can be applied with the multiply function. Starting with Python 3.5, users can writeĮxpr1 expr2 for matrix multiplication and dot products.Īs of CVXPY version 1.1, we are adopting a new should be used for matrix-matrix and matrix-vector multiplication, Historically, CVXPY used expr1 * expr2 to denote matrix multiplication. The expression expr1*expr2 is affine inĬVXPY when one of the expressions is constant, and expr1/expr2 is affine The infix operators , -, *, /, are treated as functions. The DCP rules to mark expressions with a sign and curvature. CVXPY uses the function information in this section and This section of the tutorial describes the atomic functions that can be applied
0 Comments
Leave a Reply. |