I think the function you're looking for is cvx.multiply

For example:

In [1]: import cvxpy as cvx

In [2]: n = 10

In [3]: X = cvx.Variable((n, 1))

In [4]: V = cvx.Variable((n, n))

In [5]: cvx.multiply(X, V*X)
Out[5]: Expression(UNKNOWN, UNKNOWN, (10, 1))

In the 1.0 update notes, they mention that this function used to be called mul_elemwise (<1.0), which may have been the source of your confusion.

Answer from captaincapsaicin on Stack Overflow
🌐
Cvxpy
cvxpy.org › tutorial › functions › index.html
Atomic Functions -
Historically, CVXPY used expr1 * expr2 to denote matrix multiplication. This is now deprecated. Starting with Python 3.5, users can write expr1 @ expr2 for matrix multiplication and dot products.
🌐
Snyk
snyk.io › advisor › cvxpy › functions › cvxpy.multiply
How to use the cvxpy.multiply function in cvxpy | Snyk
cvxgrp / cvxportfolio / cvxportfolio / costs.py View on Github · constr += [z == 0] second_term = 0 else: # it is a pd series no_trade = second_term.index[second_term.isnull()] second_term[no_trade] = 0 constr += [z[second_term.index.get_loc(tick)] == 0 for tick in no_trade] try: self.expression = cvx.multiply( time_locator(self.half_spread, t), cvx.abs(z)) except TypeError: self.expression = cvx.multiply( time_locator(self.half_spread, t).values, cvx.abs(z)) try: self.expression += cvx.multiply(second_term, cvx.abs(z) ** self.power) except TypeError: self.expression += cvx.multiply( second_term.values, cvx.abs(z) ** self.power) return cvx.sum(self.expression), constr
🌐
Cvxpy
cvxpy.org › api_reference › cvxpy.atoms.affine.html
Affine Atoms -
class cvxpy.atoms.affine.binary_operators.MulExpression(lh_exp, rh_exp)[source]¶ ... Matrix multiplication.
🌐
Cvxpy
cvxpy.org › tutorial › advanced › index.html
Advanced Features -
# Addition and subtraction. prob1 + prob2 == Problem(prob1.objective + prob2.objective, prob1.constraints + prob2.constraints) prob1 - prob2 == Problem(prob1.objective - prob2.objective, prob1.constraints + prob2.constraints) # Multiplication (alpha is any scalar). alpha*prob == Problem(alpha*prob.objective, prob.constraints) Note that the + operator concatenates lists of constraints, since this is the default behavior for Python lists. The in-place operators +=, -=, and *= are also supported for objectives and problems and follow the same rules as above. If you are interested in getting the standard form that CVXPY produces for a problem, you can use the get_problem_data method.
🌐
Cvxpy
cvxpy.org › version › 1.1 › tutorial › dgp › index.html
Disciplined Geometric Programming — CVXPY 1.1.24 documentation
To multiply two arrays or matrices elementwise, use the multiply atom. Finally, to take the product of the entries of an Expression, use the prod atom. The transpose of any expression can be obtained using the syntax expr.T. Transpose is a log-log affine function.
🌐
Cvxpy
cvxpy.org › version › 1.2 › api_reference › cvxpy.atoms.affine.html
Affine Atoms — CVXPY 1.2 documentation
Multiplies two expressions elementwise. cvxpy.partial_trace(expr, dims: Tuple[int], axis: int | None = 0)[source]¶
🌐
Cvxpy
cvxpy.org › _modules › cvxpy › expressions › expression.html
cvxpy.expressions.expression -
Returns ------- Expression The expression raised to ``power``. """ return cvxtypes.power()(self, power) def __rpow__(self, base: float) -> "Expression": raise NotImplementedError("CVXPY currently does not support variables " "on the right side of **. Consider using the" " identity that a**x = cp.exp(cp.multiply(np" ".log(a), x)).") @staticmethod def cast(expr_like) -> "Expression": """ If expr_like is an Expression, return it.
Find elsewhere
🌐
GitHub
github.com › cvxpy › cvxpy › issues › 1188
cvxpy is interpreting element-wise multiplication as matrix multiplication · Issue #1188 · cvxpy/cvxpy
import cvxpy as cp import numpy as np N = 5 Q = cp.Parameter((N, N)) x = cp.Variable(N) t = cp.min(cp.multiply(x, (Q @ x))) objective = cp.Minimize(t) matrix = np.random.random((N, N)) a_matrix = matrix.T @ matrix Q.value = a_matrix prob = cp.Problem(objective) prob.solve() print("status:", prob.status) print("optimal value", prob.value)
Author   ghost
🌐
Cvxpy
cvxpy.org › version › 1.2 › updates › index.html
Changes to CVXPY — CVXPY 1.2 documentation
Since version 0.4, CVXPY has used * to perform matrix multiplication. As of version 1.1, this behavior is officially deprecated. All matrix multiplication should now be performed with the python standard @ operator.
🌐
Stack Exchange
scicomp.stackexchange.com › questions › 44627 › help-with-cvxpy-multiplication
python - Help with CVXPY multiplication - Computational Science Stack Exchange
October 14, 2024 - import numpy as np import cvxpy as cp from scipy.linalg import toeplitz N = 6 M = 200 vc = 1/M * 1/np.tan(np.pi/2/M * np.arange(1, 2*M)) vc[1::2] = 0 vc = np.insert(vc, 0, 0) Km = toeplitz(vc, np.zeros(2*M)) Km_t = np.transpose(Km) Km2 = Km - Km_t # Crossing symmetry matrix C = np.array([[1/N, N/2 + 1/2 - 1/N, (1 - N)/2], [1/N, 1/2 - 1/N, 1/2], [-1/N, 1/2 + 1/N, 1/2]]) K = np.kron(np.eye(3), Km2[0:M, 0:M]) + np.kron(C, Km2[0:M, M:]) count = 0 while count < 10: ReS = cp.Variable(3*M) ImS = K@ReS constraints = [] constraints += [cp.abs(ReS+1j*ImS) <=1] ReSt = cp.transpose(ReS) z0 = 0.3j zj = np.
🌐
Cvxpy
cvxpy.org › version › 1.4 › api_reference › cvxpy.atoms.affine.html
Affine Atoms — CVXPY 1.4 documentation
cvxpy.atoms.stats.mean(x, axis=None, keepdims=False)[source]¶ · Returns the mean of x. ... Multiplies two expressions elementwise.
🌐
Cvxpy
cvxpy.org › version › 1.1 › tutorial › functions › index.html
Atomic Functions — CVXPY 1.1.24 documentation
Historically, CVXPY used expr1 * expr2 to denote matrix multiplication. This is now deprecated. Starting with Python 3.5, users can write expr1 @ expr2 for matrix multiplication and dot products.
🌐
Blogger
yetanothermathprogrammingconsultant.blogspot.com › 2019 › 11 › cvxpy-matrix-style-modeling-limits.html
Yet Another Math Programming Consultant: CVXPY matrix style modeling limits
November 7, 2019 - The second model with the summations requires some explanation. In Python * is for elementwise multiplication and @ for matrix multiplication. In CVXPY however, @, * and matmul are used both for matrix multiplication while multiply is for elementwise multiplication.
🌐
Cvxpy
cvxpy.org › api_reference › cvxpy.expressions.html
Expressions -
Expression : Matrix multiplication of two expressions.
🌐
Stack Overflow
stackoverflow.com › questions › 32530818 › multiplying-two-variables-in-cvxpy
python - Multiplying two variables in CVXPY - Stack Overflow
January 31, 2018 - I'm in need of an LP where you can multiply two non-constants. Here is the following code that I am trying to perform: import cvxpy as cvx a = cvx.Variable() b = cvx.Variable() c = cvx.Variable() obj = cvx.Maximize(((0.4270437386 * a) + (0.1737677971 * b) + (0.21763175116 * c) - 0.03) / (((((2 * a * 0.424718270) * b) * (0.195770376 ** 0.5)) * (0.022090814 ** 0.5)) * ((2 * c * -0.041137487) * b * (0.194241184 ** 0.5) * (0.022090814 ** 0.5)) * (2 * a * 0.363033596 * c * (0.195770376** 0.5) * (0.194241184 ** 0.5)))) Unfortunately this raises an error: cvxpy.error.DCPError: Cannot multiply two non-constants.
🌐
Cvxpy
cvxpy.org › api_reference › cvxpy.atoms.html
Atoms -
cvxpy.atoms.stats.mean · multiply · cvxpy.multiply · outer · cvxpy.outer · Parameters · x · y · Returns · Return type · partial_trace · cvxpy.partial_trace · Parameters · expr · dims · axis · partial_transpose · cvxpy.partial_transpose · Parameters ·