Math¶
bosonic
¶
per(mtx, column, selected, prod, output=False)
¶
Row expansion for the permanent of matrix mtx. The counter column is the current column, selected is a list of indices of selected rows, and prod accumulates the current product.
Source code in src/squint/math/bosonic.py
permanent(mat)
¶
get_fixed_sum_tuples(length, total)
¶
Generate all tuples of a given length that sum to a specified total.
Source code in src/squint/math/bosonic.py
compile_Aij_indices(i_s: jnp.array, j_s: jnp.array, m: int, n: int)
¶
Compile all indices for generating the \(A_{ij}\) matrices for all i and j combinations.
Source code in src/squint/math/bosonic.py
compute_transition_amplitudes(unitary: jnp.array, transition_inds: jnp.array)
¶
Calculates all i -> j transition amplitudes in a jit-able manner.
Source code in src/squint/math/bosonic.py
gellmann
¶
The code for the gellman function is adapted from the PySME project,
which is licensed under the MIT license.
Source: https://pysme.readthedocs.io/en/latest/_modules/gellmann.html .. module:: gellmann.py :synopsis: Generate generalized Gell-Mann matrices .. moduleauthor:: Jonathan Gross jarthurgross@gmail.com
Functions to generate the generalized Pauli (i.e., Gell-Mann matrices)
gellmann(j, k, d)
¶
Returns a generalized Gell-Mann matrix of dimension d. According to the
convention in Bloch Vectors for Qubits by Bertlmann and Krammer (2008),
returns :math:\Lambda^j for :math:1\leq j=k\leq d-1,
:math:\Lambda^{kj}_s for :math:1\leq k<j\leq d,
:math:\Lambda^{jk}_a for :math:1\leq j<k\leq d, and
:math:I for :math:j=k=d.
:param j: First index for generalized Gell-Mann matrix :type j: positive integer :param k: Second index for generalized Gell-Mann matrix :type k: positive integer :param d: Dimension of the generalized Gell-Mann matrix :type d: positive integer :returns: A genereralized Gell-Mann matrix. :rtype: numpy.array
Source code in src/squint/math/gellmann.py
information_matrices
¶
qfim(psi: Array, dspi: Array)
¶
Computes the quantum Fisher information matrix from the already computed arrays representing the probability amplitudes and their gradients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psi
|
Array
|
Quantum amplitudes. |
required |
dpsi
|
Array
|
Gradients of the quantum amplitudes. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
qfim |
ndarray
|
Quantum Fisher information matrix. |
Source code in src/squint/math/information_matrices.py
quantum_fisher_information_matrix(_forward_amplitudes: Callable, _grad_amplitudes: Callable, *params: PyTree)
¶
Performs the forward pass to compute quantum amplitudes and their gradients,
and then calculates the quantum Fisher information matrix.
Args:
_forward_amplitudes (Callable): Function to compute quantum amplitudes.
_grad_amplitudes (Callable): Function to compute gradients of quantum amplitudes.
*params (list[PyTree]): Parameters for the quantum circuit, partitioned via eqx.partition.
The argnum is already defined in the callables
Returns:
qfim (jnp.ndarray): Quantum Fisher information matrix.
Source code in src/squint/math/information_matrices.py
cfim(p: Array, dp: Array)
¶
Computes the classical Fisher information matrix from the already computed arrays representing the probabilities and their gradients. Args: p (Array): Classical probabilities. dp (Array): Gradients of the classical probabilities. Returns: cfim (jnp.ndarray): Classical Fisher information matrix.
Source code in src/squint/math/information_matrices.py
classical_fisher_information_matrix(_forward_prob: Callable, _grad_prob: Callable, *params: PyTree)
¶
Performs the forward pass to compute classical probabilities and their gradients,
and then calculates the classical Fisher information matrix.
Args:
_forward_prob (Callable): Function to compute classical probabilities.
_grad_prob (Callable): Function to compute gradients of classical probabilities.
*params (list[PyTree]): Parameters for the quantum circuit, partitioned via eqx.partition.
The argnum is already defined in the callables
Returns:
cfim (jnp.ndarray): Classical Fisher information matrix.