Skip to main content

State

Base class for all quantum state representations.

Factories

state_vector(integer num_sites) -> State

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(10, as_real | as_spinhalf) // 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(const RealMatrix vector) -> State

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]), as_spinhalf) // 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) -> State

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]), as_spinhalf) // 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, as_real options) -> State

State vector factory.

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

Parameters

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

Example

var options = as_spinhalf | as_real  // Returns a StateInfo option.
var state = state_vector(10, options) // Returns a real spinhalf state vector that stores $2^{10}$ coefficients.

state_vector(integer num_sites, as_complex options) -> State

State vector factory.

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

Parameters

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

Example

var options = as_spinhalf | as_real  // Returns a StateInfo option.
var state = state_vector(10, options) // Returns a real spinhalf state vector that stores $2^{10}$ coefficients.

state_vector(integer num_sites, const StateInfo options) -> State

State vector factory.

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

Parameters

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

Example

var options = as_spinhalf | as_real  // Returns a StateInfo option.
var state = state_vector(10, options) // Returns a real spinhalf state vector that stores $2^{10}$ coefficients.

state_vector(const RealMatrix vector, as_complex options) -> State

State vector factory.

Provides a way to construct a state vector by providing a vector of coefficients and a StateInfo option.

Parameters

  • vector: Vector of coefficients.
  • options: State vector options.

Example

var options = as_spinhalf | as_complex  // Returns a StateInfo option.
var state = state_vector(vector([0,0,0,0]), options) // Returns a complex spinhalf state vector that stores 4 coefficients identically equal to zero.

state_vector(const RealMatrix vector, as_real options) -> State

State vector factory.

Provides a way to construct a state vector by providing a vector of coefficients and a StateInfo option.

Parameters

  • vector: Vector of coefficients.
  • options: State vector options.

Example

var options = as_spinhalf | as_complex  // Returns a StateInfo option.
var state = state_vector(vector([0,0,0,0]), options) // Returns a complex spinhalf state vector that stores 4 coefficients identically equal to zero.

state_vector(const RealMatrix vector, const StateInfo options) -> State

State vector factory.

Provides a way to construct a state vector by providing a vector of coefficients and a StateInfo option.

Parameters

  • vector: Vector of coefficients.
  • options: State vector options.

Example

var options = as_spinhalf | as_complex  // Returns a StateInfo option.
var state = state_vector(vector([0,0,0,0]), options) // Returns a complex spinhalf state vector that stores 4 coefficients identically equal to zero.

state_vector(const ComplexMatrix vector, as_complex options) -> State

State vector factory.

Provides a way to construct a state vector by providing a vector of coefficients and a StateInfo option.

Parameters

  • vector: Vector of coefficients.
  • options: State vector options.

Example

var options = as_spinhalf | as_complex  // Returns a StateInfo option.
var state = state_vector(vector([0,0,0,0]), options) // Returns a complex spinhalf state vector that stores 4 coefficients identically equal to zero.

state_vector(const ComplexMatrix vector, const StateInfo options) -> State

State vector factory.

Provides a way to construct a state vector by providing a vector of coefficients and a StateInfo option.

Parameters

  • vector: Vector of coefficients.
  • options: State vector options.

Example

var options = as_spinhalf | as_complex  // Returns a StateInfo option.
var state = state_vector(vector([0,0,0,0]), options) // Returns a complex spinhalf state vector that stores 4 coefficients identically equal to zero.

Symbols

NameDescription
!=Checks inequality between two states.
*Multiplies a quantum state by a constant coefficient.
*=Multiplies the state by a constant coefficient.
-Subtracts two state vectors.
/Divides a quantum state by a constant coefficient.
/=Divides the state by a constant coefficient.
==Checks equality between two states.

Members

NameDescription
conjugateComputes the complex conjugate of the quantum state.
dimensionReturns the dimension of the basis state at the given site.
dotComputes the inner product between two quantum states.
infoReturns the StateInfo of the current state.
normComputes the norm of the quantum state.
sizeReturns the total number of coefficients needed to represent the state.
squared_normComputes the squared norm of the quantum state.