pyqubo.Array.mul

Array.mul(other)[source]

Returns a multiplicity of self by other.

Parameters:other (Array/ndarray/int/float) – Factor.
Returns:Array

Example

>>> from pyqubo import Array, Binary
>>> import numpy as np
>>> array_a = Array([[Binary('a'), Binary('b')], [Binary('c'), 2]])
>>> array_b = Array([[Binary('d'), 1], [Binary('f'), Binary('g')]])
>>> array_a.mul(array_b)
Array([[(Binary(a)*Binary(d)), (Binary(b)*Num(1))],
       [(Binary(c)*Binary(f)), (Binary(g)*Num(2))]])
>>> array_a * array_b
Array([[(Binary(a)*Binary(d)), (Binary(b)*Num(1))],
       [(Binary(c)*Binary(f)), (Binary(g)*Num(2))]])

Product of self and scalar value.

>>> array_a * 5
Array([[(Binary(a)*Num(5)), (Binary(b)*Num(5))],
       [(Binary(c)*Num(5)), 10]])

Product of self and numpy ndarray.

>>> array_a * np.array([[1, 2], [3, 4]])
Array([[(Binary(a)*Num(1)), (Binary(b)*Num(2))],
       [(Binary(c)*Num(3)), 8]])