Skip to content

cvxpy/star-matmul

Pack Severity Fix Versions
CVXPY warning none, edit by hand CVXPY 1.1+

CVXPY interprets * between non-scalar expressions as matrix multiplication. This use of the operator has been deprecated since 1.1.

prediction = coefficients * weights
prediction = coefficients @ weights

The rule checks pairs of CVXPY vectors and matrices with compatible literal dimensions from a call or an unambiguous local assignment. It reads shapes passed by position or as shape=. For matrix multiplication, the last left dimension must equal the first right dimension. The rule leaves scalar, singleton, incompatible, and unknown shapes alone.

Use @ for a matrix product. For an elementwise product, use cp.multiply(coefficients, weights) with broadcast-compatible shapes.

CVXPY operator guide

CVXPY uses * between these non-scalar expressions for matrix multiplication. Use @ for matrix multiplication or cvxpy.multiply for elementwise multiplication.

See all rules in the CVXPY pack.