Template Class StateVectorLQubitManaged

Inheritance Relationships

Base Type

Class Documentation

template<class fp_t = double>
class StateVectorLQubitManaged : public Pennylane::LightningQubit::StateVectorLQubit<double, StateVectorLQubitManaged<double>>

StateVector class where data resides in CPU memory. Memory ownership resides within class.

Template Parameters

fp_t – Precision data type

Public Types

using PrecisionT = fp_t
using ComplexT = std::complex<PrecisionT>
using CFP_t = ComplexT
using MemoryStorageT = Pennylane::Util::MemoryStorageLocation::Internal
using StateVectorT = StateVectorLQubitManaged<PrecisionT>

Public Functions

inline explicit StateVectorLQubitManaged(std::size_t num_qubits, Threading threading = Threading::SingleThread, CPUMemoryModel memory_model = bestCPUMemoryModel())

Create a new statevector in the computational basis state |0…0>

Parameters
  • num_qubits – Number of qubits

  • threading – Threading option the statevector to use

  • memory_model – Memory model the statevector will use

template<class OtherDerived>
inline explicit StateVectorLQubitManaged(const StateVectorLQubit<PrecisionT, OtherDerived> &other)

Construct a statevector from another statevector.

Template Parameters

OtherDerived – A derived type of StateVectorLQubit to use for construction.

Parameters

other – Another statevector to construct the statevector from

inline StateVectorLQubitManaged(const ComplexT *other_data, std::size_t other_size, Threading threading = Threading::SingleThread, CPUMemoryModel memory_model = bestCPUMemoryModel())

Construct a statevector from data pointer.

Parameters
  • other_data – Data pointer to construct the statevector from.

  • other_size – Size of the data

  • threading – Threading option the statevector to use

  • memory_model – Memory model the statevector will use

template<class Alloc>
inline explicit StateVectorLQubitManaged(const std::vector<std::complex<PrecisionT>, Alloc> &other, Threading threading = Threading::SingleThread, CPUMemoryModel memory_model = bestCPUMemoryModel())

Construct a statevector from a data vector.

Template Parameters

Alloc – Allocator type of std::vector to use for constructing statevector.

Parameters
  • other – Data to construct the statevector from

  • threading – Threading option the statevector to use

  • memory_model – Memory model the statevector will use

StateVectorLQubitManaged(const StateVectorLQubitManaged &rhs) = default
StateVectorLQubitManaged(StateVectorLQubitManaged&&) noexcept = default
StateVectorLQubitManaged &operator=(const StateVectorLQubitManaged&) = default
StateVectorLQubitManaged &operator=(StateVectorLQubitManaged&&) noexcept = default
~StateVectorLQubitManaged() = default
inline auto getData() -> ComplexT*
inline auto getData() const -> const ComplexT*
inline auto getDataVector() -> std::vector<ComplexT, AlignedAllocator<ComplexT>>&

Get underlying data vector.

inline auto getDataVector() const -> const std::vector<ComplexT, AlignedAllocator<ComplexT>>&
inline void updateData(const ComplexT *new_data, std::size_t new_size)

Update data of the class to new_data.

Parameters
  • new_data – data pointer to new data.

  • new_size – size of underlying data storage.

template<class Alloc>
inline void updateData(const std::vector<ComplexT, Alloc> &new_data)

Update data of the class to new_data.

Template Parameters

Alloc – Allocator type of std::vector to use for updating data.

Parameters

new_data – std::vector contains data.

inline AlignedAllocator<ComplexT> allocator() const