dwave.optimization.mathematical.logical_and#

logical_and(lhs: ArraySymbol, rhs: ArraySymbol)[source]#

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

Parameters:
  • lhs – Left-hand side symbol.

  • rhs – Right-hand side 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.]