openfermion.linalg.LinearQubitOperator

A LinearOperator implied from a QubitOperator.

The idea is that a single i_th qubit operator, O_i, is a 2-by-2 matrix, to be applied on a vector of length n_hilbert / 2^i, performs permutations and/ or adds an extra factor for its first half and the second half, e.g. a Z operator keeps the first half unchanged, while adds a factor of -1 to the second half, while an I keeps it both components unchanged.

Note that the vector length is n_hilbert / 2^i, therefore when one works on i monotonically (in increasing order), one keeps splitting the vector to the right size and then apply O_i on them independently.

Also note that operator O_i, is an envelop operator for all operators after it, i.e. {O_j | j > i}, which implies that starting with i = 0, one can split the vector, apply O_i, split the resulting vector (cached) again for the next operator.

H Hermitian adjoint.

Returns the Hermitian adjoint of self, aka the Hermitian conjugate or Hermitian transpose. For a complex matrix, the Hermitian adjoint is equal to the conjugate transpose.

Can be abbreviated self.H instead of self.adjoint().

Returns

A_H : LinearOperator Hermitian adjoint of self.

T Transpose this linear operator.

Returns a LinearOperator that represents the transpose of this one. Can be abbreviated self.T instead of self.transpose().

Methods

adjoint

Hermitian adjoint.

Returns the Hermitian adjoint of self, aka the Hermitian conjugate or Hermitian transpose. For a complex matrix, the Hermitian adjoint is equal to the conjugate transpose.

Can be abbreviated self.H instead of self.adjoint().

Returns

A_H : LinearOperator Hermitian adjoint of self.

dot

Matrix-matrix or matrix-vector multiplication.

Parameters

x : array_like 1-d or 2-d array, representing a vector or matrix.

Returns

Ax : array 1-d or 2-d array (depending on the shape of x) that represents the result of applying this linear operator on x.

matmat

Matrix-matrix multiplication.

Performs the operation y=AX where A is an MxN linear operator and X dense NK matrix or ndarray.

Parameters

X : {matrix, ndarray} An array with shape (N,K).

Returns

Y : {matrix, ndarray} A matrix or ndarray with shape (M,K) depending on the type of the X argument.

Notes

This matmat wraps any user-specified matmat routine or overridden _matmat method to ensure that y has the correct type.

matvec

Matrix-vector multiplication.

Performs the operation y=A*x where A is an MxN linear operator and x is a column vector or 1-d array.

Parameters

x : {matrix, ndarray} An array with shape (N,) or (N,1).

Returns

y : {matrix, ndarray} A matrix or ndarray with shape (M,) or (M,1) depending on the type and shape of the x argument.

Notes

This matvec wraps the user-specified matvec routine or overridden _matvec method to ensure that y has the correct shape and type.

rmatmat

Adjoint matrix-matrix multiplication.

Performs the operation y = A^H * x where A is an MxN linear operator and x is a column vector or 1-d array, or 2-d array. The default implementation defers to the adjoint.

Parameters

X : {matrix, ndarray} A matrix or 2D array.

Returns

Y : {matrix, ndarray} A matrix or 2D array depending on the type of the input.

Notes

This rmatmat wraps the user-specified rmatmat routine.

rmatvec

Adjoint matrix-vector multiplication.

Performs the operation y = A^H * x where A is an MxN linear operator and x is a column vector or 1-d array.

Parameters

x : {matrix, ndarray} An array with shape (M,) or (M,1).

Returns

y : {matrix, ndarray} A matrix or ndarray with shape (N,) or (N,1) depending on the type and shape of the x argument.

Notes

This rmatvec wraps the user-specified rmatvec routine or overridden _rmatvec method to ensure that y has the correct shape and type.

transpose

Transpose this linear operator.

Returns a LinearOperator that represents the transpose of this one. Can be abbreviated self.T instead of self.transpose().

__add__

__call__

Call self as a function.

__matmul__

__mul__

__neg__

__pow__

__rmatmul__

__rmul__

__sub__

__truediv__

ndim 2