dwave.optimization.mathematical.logical_and#

logical_and(x1: ArraySymbol, x2: ArraySymbol) And[source]#

Return an element-wise logical AND on the given symbols.

Parameters:
  • x1 – Input array symbol.

  • x2 – Input array symbol.

Returns:

A symbol that is the element-wise AND of the given symbols.

Examples

This example ANDs two binary symbols of size \(1 \times 3\).

>>> from dwave.optimization import Model
>>> from dwave.optimization.mathematical import logical_and
...
>>> model = Model()
>>> x = model.binary(3)
>>> y = model.binary(3)
>>> z = logical_and(x, y)
>>> with model.lock():
...     model.states.resize(1)
...     x.set_state(0, [True, True, False])
...     y.set_state(0, [False, True, False])
...     print(z.state(0))
[0. 1. 0.]

See also

And: equivalent symbol.