Template Class SparseHamiltonian

Inheritance Relationships

Base Type

  • public SparseHamiltonianBase< StateVectorT >

Class Documentation

template<class StateVectorT>
class SparseHamiltonian : public SparseHamiltonianBase<StateVectorT>

Sparse representation of Hamiltonian<StateVectorT>

Public Types

using PrecisionT = typename StateVectorT::PrecisionT
using ComplexT = typename StateVectorT::ComplexT
using IdxT = typename BaseType::IdxT

Public Functions

template<typename T1, typename T2, typename T3 = T2, typename T4>
inline explicit SparseHamiltonian(T1 &&data, T2 &&indices, T3 &&offsets, T4 &&wires)

Create a SparseHamiltonian from data, indices and offsets in CSR format.

Parameters
  • data – Arguments to construct data

  • indices – Arguments to construct indices

  • offsets – Arguments to construct offsets

  • wires – Arguments to construct wires

inline void applyInPlace(StateVectorT &sv) const override

Updates the statevector SV:->SV’, where SV’ = a*H*SV, and where H is a sparse Hamiltonian.

Public Static Functions

static inline auto create(std::initializer_list<ComplexT> data, std::initializer_list<IdxT> indices, std::initializer_list<IdxT> offsets, std::initializer_list<std::size_t> wires) -> std::shared_ptr<SparseHamiltonian<StateVectorT>>

Convenient wrapper for the constructor as the constructor does not convert the std::shared_ptr with a derived class correctly.

This function is useful as std::make_shared does not handle brace-enclosed initializer list correctly.

Parameters
  • data – Argument to construct data

  • indices – Argument to construct indices

  • offsets – Argument to construct ofsets

  • wires – Argument to construct wires