qp.labs.trotter_error.SparseState¶
- class SparseState(state)[source]¶
Bases:
TrotterStateA wrapper class to allow scipy sparse vectors to be used in the Trotter error estimation functions.
This class is intended to instantiate states to be used along with the
SparseFragmentclass.Example >>> from pennylane.labs.trotter_error import SparseFragment, SparseState >>> from scipy.sparse import csr_array
>>> matrix = csr_array([[1, 0], [0, 1]]) >>> vector = csr_array([1, 0], shape=(1, 2))
>>> frag = SparseFragment(matrix) >>> state = SparseState(vector)
>>> frag.apply(state) SparseState(<Compressed Sparse Row sparse array of dtype 'int64' with 1 stored elements and shape (1, 2)>)
Methods
dot(other)Compute the dot product of two states.
initialize_parallel_job(backend)Set up required for parallel compatibility.
start_parallel_job(backend)Start perturbation error computation in parallel.
zero_state(dim)Return a representation of the zero state.
- dot(other)[source]¶
Compute the dot product of two states.
- Parameters:
other – the state to take the dot product with
- Returns:
the dot product of self and other
- Return type:
complex
- initialize_parallel_job(backend)¶
Set up required for parallel compatibility. This method is called in
perturbation_error()before the parallel computations are called. Any required setup for parallel jobs goes into this function.
- start_parallel_job(backend)¶
Start perturbation error computation in parallel. This method is the first operation called in each parallel job dispatched by
perturbation_error(). Anything necessary to start the parallel job (such as reading from disk memory) goes into this function.