quspin.basis.bitwise_or
- quspin.basis.bitwise_or(x1, x2, out=None, where=None)
Bitwise OR operation x1 | x2.
Performs pair-wise bitwise OR operation on pairs of basis states in integer representation.
- Parameters:
- x1array-like
a collection of integers which contain basis states to apply pair-wise OR on.
- x2array-like
a collection of integers which contain basis states to apply pair-wise OR on.
- outarray-like, optional
an array to hold the resulting x1 | x2 integer.
- where: array_like[bool], optional
an array of booleans (mask) to define which pairs of elements of (x1,x2) to apply the bitwise OR operation on.
- Returns:
- numpy.ndarray
array of unsigned integers containing the result of the bitwise operation. Output is of same data type as x.
Examples
>>> from quspin.basis import spin_basis_general, basis_int_to_python_int >>> N=100 # sites >>> basis=spin_basis_general(N,Nup=1) # 1 particle >>> x1=[basis.states[0]] # large integer stored as a byte >>> x2=[basis.states[1]] # large integer stored as a byte >>> x1_or_x2=bitwise_or(x1,x2) >>> print('x1 integer stored as a byte:') >>> print(x1) >>> x1_int=basis_int_to_python_int(x1) # cast byte as python integer >>> print('x1 integer in integer form:') >>> print(x1_int) >>> print('result in integer form:') >>> print(basis_int_to_python_int(x1_or_x2))