Template Class StateVectorRawCPU

Inheritance Relationships

Base Type

Class Documentation

template<class PrecisionT = double>
class StateVectorRawCPU : public Pennylane::StateVectorCPU<double, StateVectorRawCPU<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

PrecisionT – Floating point precision of underlying statevector data.

Public Types

using BaseType = StateVectorCPU<PrecisionT, StateVectorRawCPU<PrecisionT>>
using ComplexPrecisionT = std::complex<PrecisionT>

Public Functions

inline StateVectorRawCPU(ComplexPrecisionT *data, 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 -> ComplexPrecisionT*

Get the underlying data pointer.

Returns

const ComplexPrecisionT* Pointer to statevector data.

inline auto getData() -> ComplexPrecisionT*

Get the underlying data pointer.

Returns

ComplexPrecisionT* Pointer to statevector data.

inline void changeDataPtr(ComplexPrecisionT *data, size_t length)

Redefine statevector data pointer.

Parameters
  • data – New raw data pointer.

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

inline void setDataFrom(ComplexPrecisionT *new_data, size_t length)

Set statevector data from another data.

Parameters
  • data – New raw data pointer.

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

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

Get the number of data elements in the statevector array.

Returns

std::size_t