SpinToolkit python documentation

Classes

class spintoolkit_py.Vec3

Bases: pybind11_builtins.pybind11_object

Real 3-vector.

__init__(self)

Default constructor, initialize to [0, 0, 0].

__init__(self, x0: float, x1: float, x2: float)

Construct with three numbers.

dot(self: spintoolkit_py.Vec3, y: spintoolkit_py.Vec3) float

Return \(\vec{x} \cdot \vec{y}\).

fill_zeros(self: spintoolkit_py.Vec3) spintoolkit_py.Vec3

\(\vec{x} \rightarrow 0\).

normalize(self: spintoolkit_py.Vec3) spintoolkit_py.Vec3

\(\vec{x} \rightarrow \vec{x} / |\vec{x}|\).

nrm2(self: spintoolkit_py.Vec3) float

Return \(\sqrt{|\vec{x}|^2}\).

class spintoolkit_py.Vec4

Bases: pybind11_builtins.pybind11_object

Real 4-vector.

__init__(self)

Default constructor, initialize to [0, 0, 0, 0].

__init__(self, x0: float, x1: float, x2: float, x3: float)

Construct with four numbers.

dot(self: spintoolkit_py.Vec4, y: spintoolkit_py.Vec4) float

Return \(\vec{x} \cdot \vec{y}\).

fill_zeros(self: spintoolkit_py.Vec4) spintoolkit_py.Vec4

\(\vec{x} \rightarrow 0\).

normalize(self: spintoolkit_py.Vec4) spintoolkit_py.Vec4

\(\vec{x} \rightarrow \vec{x} / |\vec{x}|\).

nrm2(self: spintoolkit_py.Vec4) float

Return \(\sqrt{|\vec{x}|^2}\).

class spintoolkit_py.Vec5

Bases: pybind11_builtins.pybind11_object

Real 5-vector.

__init__(self)

Default constructor, initialize to [0, 0, 0, 0, 0].

__init__(self, x0: float, x1: float, x2: float, x3: float, x4: float)

Construct with five numbers.

dot(self: spintoolkit_py.Vec5, y: spintoolkit_py.Vec5) float

Return \(\vec{x} \cdot \vec{y}\).

fill_zeros(self: spintoolkit_py.Vec5) spintoolkit_py.Vec5

\(\vec{x} \rightarrow 0\).

normalize(self: spintoolkit_py.Vec5) spintoolkit_py.Vec5

\(\vec{x} \rightarrow \vec{x} / |\vec{x}|\).

nrm2(self: spintoolkit_py.Vec5) float

Return \(\sqrt{|\vec{x}|^2}\).

class spintoolkit_py.cx_Vec3

Bases: pybind11_builtins.pybind11_object

Complex 3-vector.

__init__(self)

Default constructor, initialize to [0, 0, 0].

__init__(self, x0: complex, x1: complex, x2: complex)

Construct with three numbers.

fill_zeros(self: spintoolkit_py.cx_Vec3) spintoolkit_py.cx_Vec3

\(\vec{x} \rightarrow 0\).

normalize(self: spintoolkit_py.cx_Vec3) spintoolkit_py.cx_Vec3

\(\vec{x} \rightarrow \vec{x} / |\vec{x}|\).

nrm2(self: spintoolkit_py.cx_Vec3) float

Return \(\sqrt{|\vec{x}|^2}\).

class spintoolkit_py.Mat3

Bases: pybind11_builtins.pybind11_object

3x3 real matrix stored in column major order.

__init__(self)

Default constructor, initialize to a zero matrix.

__init__(self, type: str)

Construct according to an input type.

Parameters:

type – ‘0’: zero; ‘1’: identity matrix.

__init__(self, x00: float, x01: float, x02: float, x10: float, x11: float, x12: float, x20: float, x21: float, x22: float)

Construct row by row.

det(self: spintoolkit_py.Mat3) float

Determinant.

diag(self: spintoolkit_py.Mat3) spintoolkit_py.Vec3

Return \([A_{00}, A_{11}, A_{22}]\) as a 3-vector.

fill_identity(self: spintoolkit_py.Mat3) spintoolkit_py.Mat3

\(A \rightarrow 1\).

fill_zeros(self: spintoolkit_py.Mat3) spintoolkit_py.Mat3

\(A \rightarrow 0\).

inv(self: spintoolkit_py.Mat3) spintoolkit_py.Mat3

Return a copy of matrix inversion \(A^{-1}\).

is_diagmat(self: spintoolkit_py.Mat3, atol: SupportsFloat = 1e-12) bool

Check if the matrix is diagonal.

is_identity(self: spintoolkit_py.Mat3, atol: SupportsFloat = 1e-12) bool

Check if the matrix is identity.

is_rotation_mat(self: spintoolkit_py.Mat3, atol: SupportsFloat = 1e-07) bool

Check if the matrix is a rotation matrix: determinant=1 and \(A A^T=1\).

is_symmetric(self: spintoolkit_py.Mat3, atol: SupportsFloat = 1e-12) bool

Check if the matrix is symmetric.

nrm2(self: spintoolkit_py.Mat3) float

Return \(\sqrt{\sum_{ij} |A_{ij}|^2}\).

trace(self: spintoolkit_py.Mat3) float

Trace.

transpose(self: spintoolkit_py.Mat3) spintoolkit_py.Mat3

Return a copy of matrix transposition \(A^T\).

class spintoolkit_py.Mat4

Bases: pybind11_builtins.pybind11_object

4x4 real matrix stored in column major order.

__init__(self)

Default constructor, initialize to a zero matrix.

__init__(self, type: str)

Construct according to an input type.

Parameters:

type – ‘0’: zero; ‘1’: identity matrix.

__init__(self, x00: float, x01: float, x02: float, x03: float, x10: float, x11: float, x12: float, x13: float, x20: float, x21: float, x22: float, x23: float, x30: float, x31: float, x32: float, x33: float)

Construct row by row.

det(self: spintoolkit_py.Mat4) float

Determinant.

diag(self: spintoolkit_py.Mat4) spintoolkit_py.Vec4

Return \([A_{00}, A_{11}, A_{22}, A_{33}]\) as a 4-vector.

fill_identity(self: spintoolkit_py.Mat4) spintoolkit_py.Mat4

\(A \rightarrow 1\).

fill_zeros(self: spintoolkit_py.Mat4) spintoolkit_py.Mat4

\(A \rightarrow 0\).

inv(self: spintoolkit_py.Mat4) spintoolkit_py.Mat4

Return a copy of matrix inversion \(A^{-1}\).

is_diagmat(self: spintoolkit_py.Mat4, atol: SupportsFloat = 1e-12) bool

Check if the matrix is diagonal.

is_identity(self: spintoolkit_py.Mat4, atol: SupportsFloat = 1e-12) bool

Check if the matrix is identity.

is_symmetric(self: spintoolkit_py.Mat4, atol: SupportsFloat = 1e-12) bool

Check if the matrix is symmetric.

nrm2(self: spintoolkit_py.Mat4) float

Return \(\sqrt{\sum_{ij} |A_{ij}|^2}\).

trace(self: spintoolkit_py.Mat4) float

Trace.

transpose(self: spintoolkit_py.Mat4) spintoolkit_py.Mat4

Return a copy of matrix transposition \(A^T\).

class spintoolkit_py.cx_Mat3

Bases: pybind11_builtins.pybind11_object

3x3 complex matrix stored in column major order.

__init__(self)

Default constructor, initialize to a zero matrix.

__init__(self, type: str)

Construct according to an input type.

Parameters:

type – ‘0’: zero; ‘1’: identity matrix.

__init__(self, x00: complex, x01: complex, x02: complex, x10: complex, x11: complex, x12: complex, x20: complex, x21: complex, x22: complex)

Construct row by row.

adjoint(self: spintoolkit_py.cx_Mat3) spintoolkit_py.cx_Mat3

Return a copy of matrix conjugate transposition \(A^\dagger\).

det(self: spintoolkit_py.cx_Mat3) complex

Determinant.

diag(self: spintoolkit_py.cx_Mat3) spintoolkit_py.cx_Vec3

Return \([A_{00}, A_{11}, A_{22}]\) as a 3-vector.

fill_identity(self: spintoolkit_py.cx_Mat3) spintoolkit_py.cx_Mat3

\(A \rightarrow 1\).

fill_zeros(self: spintoolkit_py.cx_Mat3) spintoolkit_py.cx_Mat3

\(A \rightarrow 0\).

is_diagmat(self: spintoolkit_py.cx_Mat3, atol: SupportsFloat = 1e-12) bool

Check if the matrix is diagonal.

is_hermitian(self: spintoolkit_py.cx_Mat3, atol: SupportsFloat = 1e-12) bool

Check if the matrix is Hermitian.

is_identity(self: spintoolkit_py.cx_Mat3, atol: SupportsFloat = 1e-12) bool

Check if the matrix is identity.

nrm2(self: spintoolkit_py.cx_Mat3) float

Return \(\sqrt{\sum_{ij} |A_{ij}|^2}\).

trace(self: spintoolkit_py.cx_Mat3) complex

Trace.

transpose(self: spintoolkit_py.cx_Mat3) spintoolkit_py.cx_Mat3

Return a copy of matrix transposition \(A^T\).

class spintoolkit_py.MatrixD

Bases: pybind11_builtins.pybind11_object

M x N real matrix stored in column major order.

__init__(self)

Default constructor.

__init__(self, row: int, col: int, type: str = '0')

Construct with given row and column numbers.

Parameters:
  • row – Number of rows.

  • col – Number of columns.

  • type – ‘0’: zero; ‘1’: identity matrix; ‘r’: random matrix. (Default: ‘0’)

det(self: spintoolkit_py.MatrixD) float

Determinant.

fill_zeros(self: spintoolkit_py.MatrixD) spintoolkit_py.MatrixD

\(A \rightarrow 0\).

inv(self: spintoolkit_py.MatrixD) spintoolkit_py.MatrixD

Return a copy of matrix inversion \(A^{-1}\) (if square).

is_diagmat(self: spintoolkit_py.MatrixD, atol: SupportsFloat = 1e-12) bool

Check if the matrix is diagonal.

is_empty(self: spintoolkit_py.MatrixD) bool

Check if the matrix is empty.

is_orthogonal(self: spintoolkit_py.MatrixD, atol: SupportsFloat = 1e-12) bool

Check if the matrix is orthogonal.

is_symmetric(self: spintoolkit_py.MatrixD, atol: SupportsFloat = 1e-12) bool

Check if the matrix is symmetric.

n_cols(self: spintoolkit_py.MatrixD) int

Number of columns.

n_rows(self: spintoolkit_py.MatrixD) int

Number of rows.

nrm2(self: spintoolkit_py.MatrixD) float

Return \(\sqrt{\sum_{ij} |A_{ij}|^2}\).

nullspace(self: spintoolkit_py.MatrixD, atol: SupportsFloat = 1e-12) spintoolkit_py.MatrixD

Return the Null space \(\{\vec{x}\in K^N | A\vec{x} = 0\}\).

reset(self: spintoolkit_py.MatrixD) spintoolkit_py.MatrixD

Reset (destroy) the matrix.

resize(self: spintoolkit_py.MatrixD, row: SupportsInt, col: SupportsInt) spintoolkit_py.MatrixD

Change the matrix size (original data will be lost).

rref(self: spintoolkit_py.MatrixD, atol: SupportsFloat = 1e-12) spintoolkit_py.MatrixD

Return the reduced row echelon form (avoid using this in any heavy numerics).

trace(self: spintoolkit_py.MatrixD) float

Trace.

transpose(self: spintoolkit_py.MatrixD) spintoolkit_py.MatrixD

Return a copy of matrix transposition \(A^T\).

class spintoolkit_py.MatrixZ

Bases: pybind11_builtins.pybind11_object

M x N complex matrix stored in column major order.

__init__(self)

Default constructor.

__init__(self, row: int, col: int, type: str = '0')

Construct with given row and column numbers.

Parameters:
  • row – Number of rows.

  • col – Number of columns.

  • type – ‘0’: zero; ‘1’: identity matrix; ‘r’: random matrix. (Default: ‘0’)

adjoint(self: spintoolkit_py.MatrixZ) spintoolkit_py.MatrixZ

Return a copy of matrix conjugate transposition \(A^\dagger\).

det(self: spintoolkit_py.MatrixZ) complex

Determinant.

fill_zeros(self: spintoolkit_py.MatrixZ) spintoolkit_py.MatrixZ

\(A \rightarrow 0\).

inv(self: spintoolkit_py.MatrixZ) spintoolkit_py.MatrixZ

Return a copy of matrix inversion \(A^{-1}\) (if square).

is_diagmat(self: spintoolkit_py.MatrixZ, atol: SupportsFloat = 1e-12) bool

Check if the matrix is diagonal.

is_empty(self: spintoolkit_py.MatrixZ) bool

Check if the matrix is empty.

is_hermitian(self: spintoolkit_py.MatrixZ, atol: SupportsFloat = 1e-12) bool

Check if the matrix is Hermitian.

is_unitary(self: spintoolkit_py.MatrixZ, atol: SupportsFloat = 1e-12) bool

Check if the matrix is unitary.

n_cols(self: spintoolkit_py.MatrixZ) int

Number of columns.

n_rows(self: spintoolkit_py.MatrixZ) int

Number of rows.

nrm2(self: spintoolkit_py.MatrixZ) float

Return \(\sqrt{\sum_{ij} |A_{ij}|^2}\).

nullspace(self: spintoolkit_py.MatrixZ, atol: SupportsFloat = 1e-12) spintoolkit_py.MatrixZ

Return the Null space \(\{\vec{x}\in K^N | A\vec{x} = 0\}\).

reset(self: spintoolkit_py.MatrixZ) spintoolkit_py.MatrixZ

Reset (destroy) the matrix.

resize(self: spintoolkit_py.MatrixZ, row: SupportsInt, col: SupportsInt) spintoolkit_py.MatrixZ

Change the matrix size (original data will be lost).

rref(self: spintoolkit_py.MatrixZ, atol: SupportsFloat = 1e-12) spintoolkit_py.MatrixZ

Return the reduced row echelon form (avoid using this in any heavy numerics).

trace(self: spintoolkit_py.MatrixZ) complex

Trace.

transpose(self: spintoolkit_py.MatrixZ) spintoolkit_py.MatrixZ

Return a copy of matrix transposition \(A^T\).

class spintoolkit_py.spin_matrices

Bases: pybind11_builtins.pybind11_object

Spin matrices (Sx, Sy, Sz) for general spin S.

__init__(self)

Default constructor.

__init__(self, *, S: float)

Construct with a given spin magnitude.

Parameters:

S – Magnitude of the spin (integer or half-integer).

Sx(self: spintoolkit_py.spin_matrices) spintoolkit_py.MatrixZ

Returns matrix \(S^x\).

Sy(self: spintoolkit_py.spin_matrices) spintoolkit_py.MatrixZ

Returns matrix \(S^y\).

Sz(self: spintoolkit_py.spin_matrices) spintoolkit_py.MatrixZ

Returns matrix \(S^z\).

class spintoolkit_py.stevens_matrices

Bases: pybind11_builtins.pybind11_object

Stevens matrices \(O_l^m\) for general spin S.

__init__(self)

Default constructor.

__init__(self, *, S: float, l: int)

Construct with a given spin magnitude S and rank l.

Parameters:
  • S – Magnitude of the spin (integer or half-integer).

  • l – Rank.

rank(self: spintoolkit_py.stevens_matrices) int

Return rank \(l\).

class spintoolkit_py.Vec3List

Bases: pybind11_builtins.pybind11_object

List of spin dipoles as real 3-vectors.

__init__(self, size: int)

Create Vec3List with a given size (elements default initialized to 0).

__init__(self, size: int, value: spintoolkit_py.Vec3)

Create Vec3List with given size and value.

resize(self, size: int)

Resize vector to a given size.

resize(self, size: int, value: spintoolkit_py.Vec3)

Resize vector to a given size with fill value.

size(self: spintoolkit_py.Vec3List) int

Return the number of elements.

class spintoolkit_py.VecZList

Bases: pybind11_builtins.pybind11_object

List of SU(N) coherent states as complex vectors.

__init__(self, size: int)

Create VecZList with given size (elements default initialized).

__init__(self, size: int, value: list[complex])

Create VecZList with given size and value.

resize(self, size: int)

Resize vector to a given size.

resize(self, size: int, value: list[complex])

Resize vector to a given size with fill value.

size(self: spintoolkit_py.VecZList) int

Return the number of elements.

Allowed Operators

  • +=
    • Vec3 += Vec3

    • Vec4 += Vec4

    • Vec5 += Vec5

    • cx_Vec3 += cx_Vec3

    • cx_Vec3 += Vec3

    • Mat3 += Mat3

    • Mat4 += Mat4

    • cx_Mat3 += cx_Mat3

    • cx_Mat3 += Mat3

    • MatrixD += MatrixD

    • MatrixD += float

    • MatrixZ += MatrixZ

    • MatrixZ += float

    • MatrixZ += complex

  • -=
    • Vec3 -= Vec3

    • Vec4 -= Vec4

    • Vec5 -= Vec5

    • cx_Vec3 -= cx_Vec3

    • cx_Vec3 -= Vec3

    • Mat3 -= Mat3

    • Mat4 -= Mat4

    • cx_Mat3 -= cx_Mat3

    • cx_Mat3 -= Mat3

    • MatrixD -= MatrixD

    • MatrixD -= float

    • MatrixZ -= MatrixZ

    • MatrixZ -= float

    • MatrixZ -= complex

  • *=
    • Vec3 *= float

    • Vec4 *= float

    • Vec5 *= float

    • cx_Vec3 *= float

    • cx_Vec3 *= complex

    • Mat3 *= float

    • Mat3 *= Mat3

    • Mat4 *= float

    • Mat4 *= Mat4

    • cx_Mat3 *= float

    • cx_Mat3 *= complex

    • cx_Mat3 *= cx_Mat3

    • cx_Mat3 *= Mat3

    • MatrixD *= float

    • MatrixZ *= float

    • MatrixZ *= complex

  • %=
    • Vec3 %= Vec3 (Schur product)

    • Vec4 %= Vec4 (Schur product)

    • Vec5 %= Vec5 (Schur product)

    • cx_Vec3 %= cx_Vec3 (Schur product)

  • -
    • -Vec3

    • -Vec4

    • -Vec5

    • -cx_Vec3

    • -Mat3

    • -Mat4

    • -cx_Mat3

    • -MatrixD

    • -MatrixZ

  • +
    • Vec3 + Vec3 -> Vec3

    • Vec4 + Vec4 -> Vec4

    • Vec5 + Vec5 -> Vec5

    • cx_Vec3 + cx_Vec3 -> cx_Vec3

    • cx_Vec3 + Vec3 -> cx_Vec3

    • Vec3 + cx_Vec3 -> cx_Vec3

    • Mat3 + Mat3 -> Mat3

    • Mat4 + Mat4 -> Mat4

    • cx_Mat3 + cx_Mat3 -> cx_Mat3

    • cx_Mat3 + Mat3 -> cx_Mat3

    • Mat3 + cx_Mat3 -> cx_Mat3

    • MatrixD + MatrixD -> MatrixD

    • float + MatrixD -> MatrixD

    • MatrixD + float -> MatrixD

    • MatrixZ + MatrixZ -> MatrixZ

    • float + MatrixZ -> MatrixZ

    • MatrixZ + float -> MatrixZ

    • complex + MatrixZ -> MatrixZ

    • MatrixZ + complex -> MatrixZ

  • -
    • Vec3 - Vec3 -> Vec3

    • Vec4 - Vec4 -> Vec4

    • Vec5 - Vec5 -> Vec5

    • cx_Vec3 - cx_Vec3 -> cx_Vec3

    • cx_Vec3 - Vec3 -> Vec3

    • Vec3 - cx_Vec3 -> cx_Vec3

    • Mat3 - Mat3 -> Mat3

    • Mat4 - Mat4 -> Mat4

    • cx_Mat3 - cx_Mat3 -> cx_Mat3

    • cx_Mat3 - Mat3 -> cx_Mat3

    • Mat3 - cx_Mat3 -> cx_Mat3

    • MatrixD - MatrixD -> MatrixD

    • float - MatrixD -> MatrixD

    • MatrixD - float -> MatrixD

    • MatrixZ - MatrixZ -> MatrixZ

    • float - MatrixZ -> MatrixZ

    • MatrixZ - float -> MatrixZ

    • complex - MatrixZ -> MatrixZ

    • MatrixZ - complex -> MatrixZ

  • *
    • float * Vec3 -> Vec3

    • Vec3 * float -> Vec3

    • Mat3 * Vec3 -> Vec3

    • float * Vec4 -> Vec4

    • Vec4 * float -> Vec4

    • Mat4 * Vec4 -> Vec4

    • float * Vec5 -> Vec5

    • Vec5 * float -> Vec5

    • float * cx_Vec3 -> cx_Vec3

    • cx_Vec3 * float -> cx_Vec3

    • complex * cx_Vec3 -> cx_Vec3

    • cx_Vec3 * complex -> cx_Vec3

    • complex * Vec3 -> cx_Vec3

    • Vec3 * complex -> cx_Vec3

    • Mat3 * cx_Vec3 -> cx_Vec3

    • cx_Mat3 * Vec3 -> cx_Vec3

    • cx_Mat3 * cx_Vec3 -> cx_Vec3

    • float * Mat3 -> Mat3

    • Mat3 * float -> Mat3

    • Mat3 * Mat3 -> Mat3

    • float * Mat4 -> Mat4

    • Mat4 * float -> Mat4

    • Mat4 * Mat4 -> Mat4

    • float * cx_Mat3 -> cx_Mat3

    • cx_Mat3 * float -> cx_Mat3

    • complex * cx_Mat3 -> cx_Mat3

    • cx_Mat3 * complex -> cx_Mat3

    • complex * Mat3 -> cx_Mat3

    • Mat3 * complex -> cx_Mat3

    • cx_Mat3 * cx_Mat3 -> cx_Mat3

    • cx_Mat3 * Mat3 -> cx_Mat3

    • Mat3 * cx_Mat3 -> cx_Mat3

    • float * MatrixD -> MatrixD

    • MatrixD * float -> MatrixD

    • MatrixD * MatrixD -> MatrixD

    • float * MatrixZ -> MatrixZ

    • MatrixZ * float -> MatrixZ

    • complex * MatrixZ -> MatrixZ

    • MatrixZ * complex -> MatrixZ

    • MatrixZ * MatrixZ -> MatrixZ

  • %
    • Vec3 % Vec3 -> Vec3 (Schur product)

    • Vec4 % Vec4 -> Vec4 (Schur product)

    • Vec5 % Vec5 -> Vec5 (Schur product)

    • cx_Vec3 % cx_Vec3 -> cx_Vec3 (Schur product)

Functions

spintoolkit_py.cross(x: spintoolkit_py.Vec3, y: spintoolkit_py.Vec3) spintoolkit_py.Vec3

Return \(\vec{x} \times \vec{y}\).

Parameters:
  • x – The vector \(\vec{x}\).

  • y – The vector \(\vec{y}\).

spintoolkit_py.normalize(x: spintoolkit_py.Vec3) spintoolkit_py.Vec3

Return \(\vec{x}/|\vec{x}|\).

Parameters:

x – The vector to be normalized.

Return type:

spintoolkit_py.Vec3

spintoolkit_py.normalize(x: spintoolkit_py.Vec4) spintoolkit_py.Vec4

Return \(\vec{x}/|\vec{x}|\).

Parameters:

x – The vector to be normalized.

Return type:

spintoolkit_py.Vec4

spintoolkit_py.normalize(x: spintoolkit_py.Vec5) spintoolkit_py.Vec5

Return \(\vec{x}/|\vec{x}|\).

Parameters:

x – The vector to be normalized.

Return type:

spintoolkit_py.Vec5

spintoolkit_py.normalize(x: spintoolkit_py.cx_Vec3) spintoolkit_py.cx_Vec3

Return \(\vec{x}/|\vec{x}|\).

Parameters:

x – The vector to be normalized.

Return type:

spintoolkit_py.cx_Vec3

spintoolkit_py.dot(x: spintoolkit_py.Vec3, y: spintoolkit_py.Vec3) float

Return \(\vec{x} \cdot \vec{y}\).

Parameters:
  • x – The first vector.

  • y – The second vector.

Return type:

float

spintoolkit_py.dot(x: spintoolkit_py.Vec4, y: spintoolkit_py.Vec4) float

Return \(\vec{x} \cdot \vec{y}\).

Parameters:
  • x – The first vector.

  • y – The second vector.

Return type:

float

spintoolkit_py.dot(x: spintoolkit_py.Vec5, y: spintoolkit_py.Vec5) float

Return \(\vec{x} \cdot \vec{y}\).

Parameters:
  • x – The first vector.

  • y – The second vector.

Return type:

float

spintoolkit_py.kron(A: spintoolkit_py.MatrixD, B: spintoolkit_py.MatrixD) spintoolkit_py.MatrixD

Return Kronecker tensor product. Given matrix \(_nA_p\) and matrix \(_mB_q\), generates a matrix \(_{nm}C_{pq} = A \otimes B\).

Parameters:
  • A – The first matrix.

  • B – The second matrix.

Return type:

spintoolkit_py.MatrixD

spintoolkit_py.kron(A: spintoolkit_py.MatrixZ, B: spintoolkit_py.MatrixZ) spintoolkit_py.MatrixZ

Return Kronecker tensor product. Given matrix \(_nA_p\) and matrix \(_mB_q\), generates a matrix \(_{nm}C_{pq} = A \otimes B\).

Parameters:
  • A – The first matrix.

  • B – The second matrix.

Return type:

spintoolkit_py.MatrixZ

spintoolkit_py.solve(A: spintoolkit_py.MatrixD, B: list[float]) list[float]

Solve \(A \vec{X} = B\), where A should be a square matrix.

Parameters:
  • A – The square matrix on LHS.

  • B – RHS of the equation.

Return type:

list[float]

Returns:

Solution X.

spintoolkit_py.solve(A: spintoolkit_py.MatrixZ, B: list[complex]) list[complex]

Solve \(A \vec{X} = B\), where A should be a square matrix.

Parameters:
  • A – The square matrix on LHS.

  • B – RHS of the equation.

Return type:

list[complex]

Returns:

Solution X.

spintoolkit_py.solve(A: spintoolkit_py.MatrixD, B: spintoolkit_py.MatrixD) spintoolkit_py.MatrixD

Solve \(A X = B\), where A should be a square matrix.

Parameters:
  • A – The square matrix on LHS.

  • B – RHS of the equation.

Return type:

spintoolkit_py.MatrixD

Returns:

Solution X.

spintoolkit_py.solve(A: spintoolkit_py.MatrixZ, B: spintoolkit_py.MatrixZ) spintoolkit_py.MatrixZ

Solve \(A X = B\), where A should be a square matrix.

Parameters:
  • A – The square matrix on LHS.

  • B – RHS of the equation.

Return type:

spintoolkit_py.MatrixZ

Returns:

Solution X.

spintoolkit_py.solve_triangular(A: spintoolkit_py.MatrixD, B: list[float], uplo: str) list[float]

Solve \(A \vec{X} = B\), where A should be a triangular matrix.

Parameters:
  • A – The triangular matrix on LHS.

  • B – RHS of the equation.

  • uplo – ‘U’: if A is upper triangular; ‘L’: if A is lower triangular.

Return type:

list[float]

Returns:

Solution X.

spintoolkit_py.solve_triangular(A: spintoolkit_py.MatrixZ, B: list[complex], uplo: str) list[complex]

Solve \(A \vec{X} = B\), where A should be a triangular matrix.

Parameters:
  • A – The triangular matrix on LHS.

  • B – RHS of the equation.

  • uplo – ‘U’: if A is upper triangular; ‘L’: if A is lower triangular.

Return type:

list[complex]

Returns:

Solution X.

spintoolkit_py.solve_triangular(A: spintoolkit_py.MatrixD, B: spintoolkit_py.MatrixD, uplo: str) spintoolkit_py.MatrixD

Solve \(A X = B\), where A should be a triangular matrix.

Parameters:
  • A – The triangular matrix on LHS.

  • B – RHS of the equation.

  • uplo – ‘U’: if A is upper triangular; ‘L’: if A is lower triangular.

Return type:

spintoolkit_py.MatrixD

Returns:

Solution X.

spintoolkit_py.solve_triangular(A: spintoolkit_py.MatrixZ, B: spintoolkit_py.MatrixZ, uplo: str) spintoolkit_py.MatrixZ

Solve \(A X = B\), where A should be a triangular matrix.

Parameters:
  • A – The triangular matrix on LHS.

  • B – RHS of the equation.

  • uplo – ‘U’: if A is upper triangular; ‘L’: if A is lower triangular.

Return type:

spintoolkit_py.MatrixZ

Returns:

Solution X.

spintoolkit_py.solve_symmetric(A: spintoolkit_py.MatrixD, B: list[float]) list[float]

Solve \(A \vec{X} = B\), where A should be a real symmetric matrix.

Parameters:
  • A – The real symmetric matrix on LHS.

  • B – RHS of the equation.

Return type:

list[float]

Returns:

Solution X.

spintoolkit_py.solve_Hermitian(A: spintoolkit_py.MatrixZ, B: list[complex]) list[complex]

Solve \(A \vec{X} = B\), where A should be a complex Hermitian matrix.

Parameters:
  • A – The complex Hermitian matrix on LHS.

  • B – RHS of the equation.

Return type:

list[complex]

Returns:

Solution X.

spintoolkit_py.solve_symmetric(A: spintoolkit_py.MatrixD, B: spintoolkit_py.MatrixD) spintoolkit_py.MatrixD

Solve \(A X = B\), where A should be a real symmetric matrix.

Parameters:
  • A – The real symmetric matrix on LHS.

  • B – RHS of the equation.

Return type:

spintoolkit_py.MatrixD

Returns:

Solution X.

spintoolkit_py.solve_Hermitian(A: spintoolkit_py.MatrixZ, B: spintoolkit_py.MatrixZ) spintoolkit_py.MatrixZ

Solve \(A X = B\), where A should be a complex Hermitian matrix.

Parameters:
  • A – The complex Hermitian matrix on LHS.

  • B – RHS of the equation.

Return type:

spintoolkit_py.MatrixZ

Returns:

Solution X.

spintoolkit_py.chol(A: spintoolkit_py.MatrixD, uplo: str) spintoolkit_py.MatrixD

Cholesky decomposition: \(A = R^T R\) (if uplo=’U’), or \(A = R R^T\) (if uplo=’L’).

Parameters:
  • A – The symmetric positive-definite matrix to be decomposed.

  • uplo – ‘U’/’L’: upper/lower half of A and R referenced.

Return type:

spintoolkit_py.MatrixD

Returns:

The triangular matrix R.

spintoolkit_py.chol(A: spintoolkit_py.MatrixZ, uplo: str) spintoolkit_py.MatrixZ

Cholesky decomposition: \(A = R^\dagger R\) (if uplo=’U’), or \(A = R R^\dagger\) (if uplo=’L’).

Parameters:
  • A – The hermitian positive-definite matrix to be decomposed.

  • uplo – ‘U’/’L’: upper/lower half of A and R referenced.

Return type:

spintoolkit_py.MatrixZ

Returns:

The triangular matrix R.

spintoolkit_py.svd(A: spintoolkit_py.MatrixD) tuple[spintoolkit_py.MatrixD, list[float], spintoolkit_py.MatrixD]

Singular Value Decomposition \(A = U S V^T\).

Parameters:

A\(m\times n\) matrix to be decomposed.

Returns:
  • U (spintoolkit_py.MatrixD) - \(m\times m\) orthogonal matrix.

  • s (list[float]) - Singular values in descending order.

  • V (spintoolkit_py.MatrixD) - \(n\times n\) orthogonal matrix.

spintoolkit_py.svd(A: spintoolkit_py.MatrixZ) tuple[spintoolkit_py.MatrixZ, list[float], spintoolkit_py.MatrixZ]

Singular Value Decomposition \(A = U S V^\dagger\).

Parameters:

A\(m\times n\) matrix to be decomposed.

Returns:
  • U (spintoolkit_py.MatrixZ) - \(m\times m\) unitary matrix U.

  • s (list[float]) - Singular values in descending order.

  • V (spintoolkit_py.MatrixZ) - \(n\times n\) unitary matrix.

spintoolkit_py.eig_gen(A: spintoolkit_py.MatrixD) tuple[list[complex], spintoolkit_py.MatrixD]

Eigen decomposition of a dense general square matrix \(AV=V\text{diag}(e_0,\ldots,e_{n-1})\).

Parameters:

A – The matrix to be decomposed.

Returns:
  • eigval (list[complex]) - The eigenvalues.

  • eigvec (spintoolkit_py.MatrixD) - The eigenvector matrix V.

spintoolkit_py.eig_gen(A: spintoolkit_py.MatrixZ) tuple[list[complex], spintoolkit_py.MatrixZ]

Eigen decomposition of a dense general square matrix \(AV=V\text{diag}(e_0,\ldots,e_{n-1})\).

Parameters:

A – The matrix to be decomposed.

Returns:
  • eigval (list[complex]) - The eigenvalues.

  • eigvec (spintoolkit_py.MatrixZ) - The eigenvector matrix V.

spintoolkit_py.eig_sym(A: spintoolkit_py.MatrixD) tuple[list[float], spintoolkit_py.MatrixD]

Eigen decomposition of a dense symmetric matrix \(AV=V\text{diag}(e_0,\ldots,e_{n-1})\).

Parameters:

A – The symmetric matrix to be decomposed.

Returns:
  • eigval (list[float]) - The eigenvalues in ascending order.

  • eigvec (spintoolkit_py.MatrixD) - The eigenvector matrix V.

spintoolkit_py.eig_sym(A: spintoolkit_py.MatrixZ) tuple[list[float], spintoolkit_py.MatrixZ]

Eigen decomposition of a dense Hermitian matrix \(AV=V\text{diag}(e_0,\ldots,e_{n-1})\).

Parameters:

A – The hermitian matrix to be decomposed.

Returns:
  • eigval (list[float]) - The eigenvalues in ascending order.

  • eigvec (spintoolkit_py.MatrixZ) - The eigenvector matrix V.