It is possible to pointwise multiply a scalar vector with an MVar object:

$$\begin{align} \begin{bmatrix} a_1 \\ a_2 \\ a_3 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix}= \begin{bmatrix} a_1 x_1 \\ a_2 x_2 \\ a_3 x_3 \end{bmatrix}. \end{align}$$

To do so, convert the scalar vector to a (sparse) diagonal matrix:

import gurobipy as gp

import numpy as np

import scipy.sparse as sp

m = gp.Model()

x = m.addMVar(3)

a = np.array([1.0, 2.0, 3.0])

A = sp.diags(a)

expr = A @ x

**Note:** Gurobi 9.0 introduced the first version of the Python matrix API. The developers are continually working to improve the usability of the matrix API.

### Further information

- How do I pointwise multiply two MVars with the matrix-friendly Python API?
- How do I multiply two MLinExpr objects together with the matrix-friendly Python API?
- How do I multiply an array and a 2-D MVar object using the matrix-friendly Python API?
- How do I pointwise multiply a numpy vector with a (1,) MVar with the matrix-friendly Python API?