dwave.optimization.mathematical.multiply#

multiply(x1: ArraySymbol, x2: ArraySymbol, *xi: ArraySymbol) Multiply | NaryMultiply[source]#

Return an element-wise multiplication on the given symbols.

In the underlying directed acyclic expression graph, produces a Multiply node if two array nodes are provided and a NaryMultiply node otherwise.

Parameters:
  • x1 – Input array symbol.

  • x2 – Input array symbol.

  • *xi – Additional input array symbols.

Returns:

A symbol that multiplies the given symbols element-wise. Multipying two symbols returns a Minimum. Multiplying three or more symbols returns a NaryMinimum.

Examples

This example multiplies two integer symbols of size \(1 \times 2\). Equivalently, you can use the * operator (e.g., i * j).

>>> from dwave.optimization import Model
>>> from dwave.optimization.mathematical import multiply
...
>>> model = Model()
>>> i = model.integer(2)
>>> j = model.integer(2)
>>> k = multiply(i, j)   # alternatively: k = i * j
>>> with model.lock():
...     model.states.resize(1)
...     i.set_state(0, [3, 5])
...     j.set_state(0, [7, 2])
...     print(k.state(0))
[21. 10.]