Template Class StateVectorLQubitRaw

Inheritance Relationships

Base Type

Class Documentation

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

State-vector operations class.

This class binds to a given statevector data array, and defines all operations to manipulate the statevector data for quantum circuit simulation. We define gates as methods to allow direct manipulation of the bound data, as well as through a string-based function dispatch. The bound data is assumed to be complex, and is required to be in either 32-bit (64-bit complex<float>) or 64-bit (128-bit complex<double>) floating point representation.

Template Parameters

fp_t – Floating point precision of underlying statevector data.

Public Types

using PrecisionT = fp_t
using ComplexT = std::complex<PrecisionT>
using CFP_t = ComplexT
using MemoryStorageT = Pennylane::Util::MemoryStorageLocation::External

Public Functions

inline StateVectorLQubitRaw(ComplexT *data, std::size_t length, Threading threading = Threading::SingleThread)

Construct state-vector from a raw data pointer.

Memory model is automatically deduced from a pointer.

Parameters
  • data – Raw data pointer.

  • length – The size of the data, i.e. 2^(number of qubits).

  • threading – Threading option the statevector to use

inline auto getData() const -> ComplexT*

Get the underlying data pointer.

Returns

const ComplexT* Pointer to statevector data.

inline auto getData() -> ComplexT*

Get the underlying data pointer.

Returns

ComplexT* Pointer to statevector data.

inline auto getDataVector() -> std::vector<ComplexT>

Get a copy of underlying data.

Returns

a std::vector<ComplexT> object that stores statevector data.

inline auto getLength() const -> std::size_t

Get the number of data elements in the statevector array.

Returns

std::size_t

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.