From 640259be6214e4d6ed7e6e1dc7f060019a1b50d8 Mon Sep 17 00:00:00 2001 From: Anthony Date: Mon, 7 Oct 2024 10:47:27 -0400 Subject: [PATCH] docs --- doc/code/physics/utils/bargmann_calculations.rst | 4 ++-- doc/code/physics/utils/fock_calculations.rst | 4 ++-- mrmustard/math/backend_numpy.py | 2 +- mrmustard/math/backend_tensorflow.py | 2 +- .../math/lattice/strategies/compactFock/diagonal_amps.py | 6 +++--- .../math/lattice/strategies/compactFock/diagonal_grad.py | 8 ++++---- .../strategies/compactFock/singleLeftoverMode_amps.py | 6 +++--- .../strategies/compactFock/singleLeftoverMode_grad.py | 6 +++--- .../lattice/strategies/julia/compactFock/diagonal_grad.jl | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/doc/code/physics/utils/bargmann_calculations.rst b/doc/code/physics/utils/bargmann_calculations.rst index 22362d468..08e1e953e 100644 --- a/doc/code/physics/utils/bargmann_calculations.rst +++ b/doc/code/physics/utils/bargmann_calculations.rst @@ -1,8 +1,8 @@ Calculations on Bargmann objects ================================ -.. currentmodule:: mrmustard.physics.bargmann +.. currentmodule:: mrmustard.physics.bargmann_utils -.. automodapi:: mrmustard.physics.bargmann +.. automodapi:: mrmustard.physics.bargmann_utils :no-heading: :include-all-objects: diff --git a/doc/code/physics/utils/fock_calculations.rst b/doc/code/physics/utils/fock_calculations.rst index a26b9f512..8a3f3d936 100644 --- a/doc/code/physics/utils/fock_calculations.rst +++ b/doc/code/physics/utils/fock_calculations.rst @@ -1,8 +1,8 @@ Calculations on Fock objects ============================ -.. currentmodule:: mrmustard.physics.fock +.. currentmodule:: mrmustard.physics.fock_utils -.. automodapi:: mrmustard.physics.fock +.. automodapi:: mrmustard.physics.fock_utils :no-heading: :include-all-objects: diff --git a/mrmustard/math/backend_numpy.py b/mrmustard/math/backend_numpy.py index 2ebde8f9e..18bffa73b 100644 --- a/mrmustard/math/backend_numpy.py +++ b/mrmustard/math/backend_numpy.py @@ -535,7 +535,7 @@ def hermite_renormalized_binomial( def reorder_AB_bargmann(self, A: np.ndarray, B: np.ndarray) -> tuple[np.ndarray, np.ndarray]: r"""In mrmustard.math.numba.compactFock~ dimensions of the Fock representation are ordered like [mode0,mode0,mode1,mode1,...] - while in mrmustard.physics.bargmann the ordering is [mode0,mode1,...,mode0,mode1,...]. Here we reorder A and B. + while in mrmustard.physics.bargmann_utils the ordering is [mode0,mode1,...,mode0,mode1,...]. Here we reorder A and B. """ ordering = np.arange(2 * A.shape[0] // 2).reshape(2, -1).T.flatten() A = self.gather(A, ordering, axis=1) diff --git a/mrmustard/math/backend_tensorflow.py b/mrmustard/math/backend_tensorflow.py index 593083e5c..ede56c91c 100644 --- a/mrmustard/math/backend_tensorflow.py +++ b/mrmustard/math/backend_tensorflow.py @@ -554,7 +554,7 @@ def grad(dLdGconj): def reorder_AB_bargmann(self, A: tf.Tensor, B: tf.Tensor) -> tuple[tf.Tensor, tf.Tensor]: r"""In mrmustard.math.compactFock.compactFock~ dimensions of the Fock representation are ordered like [mode0,mode0,mode1,mode1,...] - while in mrmustard.physics.bargmann the ordering is [mode0,mode1,...,mode0,mode1,...]. Here we reorder A and B. + while in mrmustard.physics.bargmann_utils the ordering is [mode0,mode1,...,mode0,mode1,...]. Here we reorder A and B. """ ordering = ( np.arange(2 * A.shape[0] // 2).reshape(2, -1).T.flatten() diff --git a/mrmustard/math/lattice/strategies/compactFock/diagonal_amps.py b/mrmustard/math/lattice/strategies/compactFock/diagonal_amps.py index 4a765fe52..1b6ac8800 100644 --- a/mrmustard/math/lattice/strategies/compactFock/diagonal_amps.py +++ b/mrmustard/math/lattice/strategies/compactFock/diagonal_amps.py @@ -21,7 +21,7 @@ def use_offDiag_pivot( """ Apply recurrence relation for pivot of type [a+1,a,b,b,c,c,...] / [a,a,b+1,b,c,c,...] / [a,a,b,b,c+1,c,...] Args: - A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) M (int): number of modes cutoffs (tuple): upper bounds for the number of photons in each mode params (tuple): (a,b,c,...) @@ -88,7 +88,7 @@ def use_diag_pivot(A, B, M, cutoffs, params, arr0, arr1): # pragma: no cover """ Apply recurrence relation for pivot of type [a,a,b,b,c,c...] Args: - A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) M (int): number of modes cutoffs (tuple): upper bounds for the number of photons in each mode params (tuple): (a,b,c,...) @@ -139,7 +139,7 @@ def fock_representation_diagonal_amps_NUMBA( Returns the PNR probabilities of a mixed state according to algorithm 1 of: https://doi.org/10.22331/q-2023-08-29-1097 Args: - A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) M (int): number of modes cutoffs (tuple): upper bounds for the number of photons in each mode arr0 (array): submatrix of the fock representation that contains Fock amplitudes of the type [a,a,b,b,c,c...] diff --git a/mrmustard/math/lattice/strategies/compactFock/diagonal_grad.py b/mrmustard/math/lattice/strategies/compactFock/diagonal_grad.py index 3279c991d..eba86a9ec 100644 --- a/mrmustard/math/lattice/strategies/compactFock/diagonal_grad.py +++ b/mrmustard/math/lattice/strategies/compactFock/diagonal_grad.py @@ -21,7 +21,7 @@ def calc_dA_dB(i, G_in_dA, G_in_dB, G_in, A, B, K_l, K_i, M, pivot_val, pivot_va Args: i (int): the element of the multidim index that is increased G_in, G_in_dA, G_in_dB (array, array, array): all Fock amplitudes from the 'read' group in the recurrence relation and their derivatives w.r.t. A and B - A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) K_l, K_i (vector, vector): SQRT[pivot], SQRT[pivot + 1] M (int): number of modes pivot_val, pivot_val_dA, pivot_val_dB (array, array, array): Fock amplitude at the position of the pivot and its derivatives w.r.t. A and B @@ -63,7 +63,7 @@ def use_offDiag_pivot_grad( """ Apply recurrence relation for pivot of type [a+1,a,b,b,c,c,...] / [a,a,b+1,b,c,c,...] / [a,a,b,b,c+1,c,...] Args: - A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) M (int): number of modes cutoffs (tuple): upper bounds for the number of photons in each mode params (tuple): (a,b,c,...) @@ -201,7 +201,7 @@ def use_diag_pivot_grad(A, B, M, cutoffs, params, arr0, arr1, arr0_dA, arr1_dA, """ Apply recurrence relation for pivot of type [a,a,b,b,c,c...] Args: - A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) M (int): number of modes cutoffs (tuple): upper bounds for the number of photons in each mode params (tuple): (a,b,c,...) @@ -265,7 +265,7 @@ def fock_representation_diagonal_grad_NUMBA( Returns the gradients of the PNR probabilities of a mixed state according to algorithm 1 of https://doi.org/10.22331/q-2023-08-29-1097 Args: - A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) M (int): number of modes cutoffs (tuple): upper bounds for the number of photons in each mode arr0 (array): submatrix of the fock representation that contains Fock amplitudes of the type [a,a,b,b,c,c...] diff --git a/mrmustard/math/lattice/strategies/compactFock/singleLeftoverMode_amps.py b/mrmustard/math/lattice/strategies/compactFock/singleLeftoverMode_amps.py index 67f74da4f..6f6adbfa9 100644 --- a/mrmustard/math/lattice/strategies/compactFock/singleLeftoverMode_amps.py +++ b/mrmustard/math/lattice/strategies/compactFock/singleLeftoverMode_amps.py @@ -100,7 +100,7 @@ def use_offDiag_pivot( """ Apply recurrence relation for pivot of type [a+1,a,b,b,c,c,...] / [a,a,b+1,b,c,c,...] / [a,a,b,b,c+1,c,...] Args: - A, B (array, Vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, Vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) M (int): number of detected modes cutoffs (tuple): upper bounds for the number of photons in each mode params (tuple): (a,b,c,...) @@ -202,7 +202,7 @@ def use_diag_pivot(A, B, M, cutoff_leftoverMode, cutoffs_tail, params, arr0, arr """ Apply recurrence relation for pivot of type [a,a,b,b,c,c...] Args: - A, B (array, Vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, Vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) M (int): number of detected modes cutoffs (tuple): upper bounds for the number of photons in each mode params (tuple): (a,b,c,...) @@ -281,7 +281,7 @@ def fock_representation_1leftoverMode_amps_NUMBA( Returns the density matrices in the upper, undetected mode of a circuit when all other modes are PNR detected according to algorithm 2 of https://doi.org/10.22331/q-2023-08-29-1097 Args: - A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) M (int): number of modes cutoffs (tuple): upper bounds for the number of photons in each mode arr0 (array): submatrix of the fock representation that contains Fock amplitudes of the type [a,a,b,b,c,c...] diff --git a/mrmustard/math/lattice/strategies/compactFock/singleLeftoverMode_grad.py b/mrmustard/math/lattice/strategies/compactFock/singleLeftoverMode_grad.py index 6d1df9f73..6c6c63c04 100644 --- a/mrmustard/math/lattice/strategies/compactFock/singleLeftoverMode_grad.py +++ b/mrmustard/math/lattice/strategies/compactFock/singleLeftoverMode_grad.py @@ -298,7 +298,7 @@ def use_offDiag_pivot_grad( """ Apply recurrence relation for pivot of type [a+1,a,b,b,c,c,...] / [a,a,b+1,b,c,c,...] / [a,a,b,b,c+1,c,...] Args: - A, B (array, Vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, Vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) M (int): number of detected modes cutoffs (tuple): upper bounds for the number of photons in each mode params (tuple): (a,b,c,...) @@ -499,7 +499,7 @@ def use_diag_pivot_grad( """ Apply recurrence relation for pivot of type [a,a,b,b,c,c...] Args: - A, B (array, Vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, Vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) M (int): number of detected modes cutoffs (tuple): upper bounds for the number of photons in each mode params (tuple): (a,b,c,...) @@ -594,7 +594,7 @@ def fock_representation_1leftoverMode_grad_NUMBA( Returns the gradients of the density matrices in the upper, undetected mode of a circuit when all other modes are PNR detected (according to algorithm 2 of https://doi.org/10.22331/q-2023-08-29-1097) Args: - A, B (array, Vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, Vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) M (int): number of modes cutoffs (tuple): upper bounds for the number of photons in each mode arr0 (array): submatrix of the fock representation that contains Fock amplitudes of the type [a,a,b,b,c,c...] diff --git a/mrmustard/math/lattice/strategies/julia/compactFock/diagonal_grad.jl b/mrmustard/math/lattice/strategies/julia/compactFock/diagonal_grad.jl index 15324c59c..9dfce8a0d 100644 --- a/mrmustard/math/lattice/strategies/julia/compactFock/diagonal_grad.jl +++ b/mrmustard/math/lattice/strategies/julia/compactFock/diagonal_grad.jl @@ -8,7 +8,7 @@ function calc_dA_dB(i, G_in_dA, G_in_dB, G_in, A, B, K_l, K_i, M, pivot_val, piv Args: i (int): the element of the multidim index that is increased G_in, G_in_dA, G_in_dB (array, array, array): all Fock amplitudes from the 'read' group in the recurrence relation and their derivatives w.r.t. A and B - A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock.ABC) + A, B (array, vector): required input for recurrence relation (given by mrmustard.physics.fock_utils.ABC) K_l, K_i (vector, vector): SQRT[pivot], SQRT[pivot + 1] M (int): number of modes pivot_val, pivot_val_dA, pivot_val_dB (array, array, array): Fock amplitude at the position of the pivot and its derivatives w.r.t. A and B