Skip to main content

StateVector

Base class: State

Base class for all state vector representations.

Derived Types

Factories

state_vector(const RealMatrix vector) -> StateVector

State vector factory.

Provides a way to construct a state vector by specifying a vector of coefficients.

Parameters

  • vector: Vector of coefficients.

Example

// A state vector may be constructed as follows:
var state = state_vector(vector([0,0,0,0])) // Returns a default state vector that stores 4 coefficients identically equal to zero. The default StateInfo option is as_complex | as_dense | as_abstract | as_complete

state_vector(const ComplexMatrix vector) -> StateVector

State vector factory.

Provides a way to construct a state vector by specifying a vector of coefficients.

Parameters

  • vector: Vector of coefficients.

Example

// A state vector may be constructed as follows:
var state = state_vector(vector([0,0,0,0])) // Returns a default state vector that stores 4 coefficients identically equal to zero. The default StateInfo option is as_complex | as_dense | as_abstract | as_complete

state_vector(integer num_sites) -> StateVector

State vector factory.

Provides a way to construct a state vector by providing a number of sites.

Parameters

  • num_sites: The number of sites that compose the Hilbert space of the state vector.

Example

var state = state_vector(16) // Returns a default state vector that stores $2^{10}$ coefficients identically set to zero. The default StateInfo option is as_complex | as_dense | as_abstract | as_complete

state_vector(as_complex info, const Map options) -> StateVector

State vector factory.

Provides a way to construct a state vector by providing a StateInfo object and a map of options.

Parameters

  • info: Information about the state vector to be created.
  • options: Options for the state vector creation.

Example

var options = as_fermion | as_number | as_complex
var state = state_vector(options, ["num_sites" : 10, "number" : 5])

state_vector(const StateInfo info, const Map options) -> StateVector

State vector factory.

Provides a way to construct a state vector by providing a StateInfo object and a map of options.

Parameters

  • info: Information about the state vector to be created.
  • options: Options for the state vector creation.

Example

var options = as_fermion | as_number | as_complex
var state = state_vector(options, ["num_sites" : 10, "number" : 5])

state_vector(as_real info, const Map options) -> StateVector

State vector factory.

Provides a way to construct a state vector by providing a StateInfo object and a map of options.

Parameters

  • info: Information about the state vector to be created.
  • options: Options for the state vector creation.

Example

var options = as_fermion | as_number | as_complex
var state = state_vector(options, ["num_sites" : 10, "number" : 5])

Constructors

StateVector(const StateVector state_vector) -> StateVector

Copy constructor for StateVector objects.

Parameters

  • state_vector: The state vector to copy.

Symbols

NameDescription
+Adds two state vectors.
+=In-place addition of two state vectors.
-=In-place subtraction of two state vectors.

Members

NameDescription
coefficientsReturns the vector of coefficients stored by the state vector.
normalizeNormalizes the state vector.
set_constantSets all coefficients of the state vector to a constant value.
set_randomSets the state vector to random values.
set_zeroSets all coefficients of the state vector to zero.