StateC

class sisl.physics.StateC(state, c, parent=None, **info)[source]

An object handling a set of vectors describing a given state with associated coefficients c

Parameters:
state : array_like

state vectors state[i, :] containing the i’th state vector

c : array_like

coefficients for the states c[i] containing the i’th coefficient

parent : obj, optional

a parent object that defines the origin of the state.

**info : dict, optional

an info dictionary that turns into an attribute on the object. This info may contain anything that may be relevant for the state.

Notes

This class should be subclassed!

Attributes

c
dkind The data-type of the state (in str)
dtype Data-type for the state
info
parent
shape Returns the shape of the state
state

Methods

__init__(state, c[, parent]) Define a state container with a given set of states and coefficients for the states
asCoefficient()
asState()
copy() Return a copy (only the coefficients and states are copied), parent and info are passed by reference
degenerate(eps) Find degenerate coefficients with a specified precision
iter([asarray]) An iterator looping over the states in this system
norm() Return a vector with the norm of each state \(\sqrt{\langle\psi|\psi\rangle}\)
norm2([sum]) Return a vector with the norm of each state \(\langle\psi|\psi\rangle\)
normalize() Return a normalized state where each state has \(|\psi|^2=1\)
outer([idx]) Return the outer product for the indices idx (or all if None) by \(\sum_i|\psi_i\rangle c_i\langle\psi_i|\)
sort([ascending]) Sort and return a new StateC by sorting the coefficients (default to ascending)
sub(idx) Return a new state with only the specified states
asCoefficient()[source]
asState()[source]
c
copy()[source]

Return a copy (only the coefficients and states are copied), parent and info are passed by reference

degenerate(eps)[source]

Find degenerate coefficients with a specified precision

Parameters:
eps : float

the precision above which coefficients are not considered degenerate

Returns:
list of numpy.ndarray: a list of indices
dkind

The data-type of the state (in str)

dtype

Data-type for the state

info
iter(asarray=False)

An iterator looping over the states in this system

Parameters:
asarray: bool, optional

if true the yielded values are the state vectors, i.e. a numpy array. Otherwise an equivalent object is yielded.

Yields:
state : State

a state only containing individual elements, if asarray is false

state : numpy.ndarray

a state only containing individual elements, if asarray is true

norm()

Return a vector with the norm of each state \(\sqrt{\langle\psi|\psi\rangle}\)

Returns:
numpy.ndarray

the normalization for each state

norm2(sum=True)

Return a vector with the norm of each state \(\langle\psi|\psi\rangle\)

Parameters:
sum : bool, optional

if true the summed site square is returned (a vector). For false a matrix with normalization squared per site is returned.

Returns:
numpy.ndarray

the normalization for each state

normalize()[source]

Return a normalized state where each state has \(|\psi|^2=1\)

This is roughly equivalent to:

>>> state = StateC(np.arange(10), 1)
>>> n = state.norm()
>>> norm_state = StateC(state.state / n.reshape(-1, 1), state.c.copy())
>>> norm_state.c[0] == 1
Returns:
state : a new state with all states normalized, otherwise equal to this
outer(idx=None)[source]

Return the outer product for the indices idx (or all if None) by \(\sum_i|\psi_i\rangle c_i\langle\psi_i|\)

Parameters:
idx : int or array_like, optional

only perform an outer product of the specified indices, otherwise all states are used

Returns:
numpy.ndarray : a matrix with the sum of outer state products
parent
shape

Returns the shape of the state

sort(ascending=True)[source]

Sort and return a new StateC by sorting the coefficients (default to ascending)

Parameters:
ascending : bool, optional

sort the contained elements ascending, else they will be sorted descending

state
sub(idx)[source]

Return a new state with only the specified states

Parameters:
idx : int or array_like

indices that are retained in the returned object

Returns:
StateC : a new object with a subset of the states