mrmustard.math¶
The math module¶
A class to manage the different backends supported by Mr Mustard.
Functions¶
|
Categorical distribution over integers. |
Default optimizer for the Euclidean parameters. |
|
|
Symplectic form. |
|
Multivariate normal distribution on R^k and parameterized by a (batch of) length-k loc vector (aka "mu") and a (batch of) k x k scale matrix; covariance = scale @ scale.T where @ denotes matrix-multiplication. |
|
The matrix \(X_n = \begin{bmatrix}0 & I_n\\ I_n & 0\end{bmatrix}.\) |
|
The matrix \(Z_n = \begin{bmatrix}I_n & 0\\ 0 & -I_n\end{bmatrix}.\) |
|
The absolute value of array. |
|
Adds two phase-space tensors (cov matrices, displacement vectors, etc..) on the specified modes. |
|
Returns all the diagonals of a density matrix. |
|
Whether two arrays are equal within tolerance. |
|
Returns |
|
Returns an array of evenly spaced values within a given interval. |
|
Converts an array to a numpy array. |
|
Assigns value to tensor. |
|
Converts a numpy array to a tensor. |
|
Returns an array with at least one dimension. |
|
Returns an array with at least two dimensions. |
|
Returns an array with at least three dimensions by eventually inserting new axes at the beginning. |
|
\(P(out|in) = binom(in, out) * (1-success_prob)**(in-out) * success_prob**out\). |
|
Returns a matrix made from the given blocks. |
|
Returns a block diagonal matrix from the given matrices. |
|
Returns a tensor based on the truth value of the boolean mask. |
|
Casts |
Changes the backend to a different one. |
|
|
Computes the Cholesky decomposition of square matrices. |
|
Clips array to the interval |
|
Concatenates values along the given axis. |
|
The complex conjugate of array. |
Returns a constraint function for the given bounds. |
|
|
Performs a convolution on array with filters. |
|
Convolve two probability distributions (up to 3D) with the same shape. |
|
Convolution of a joint probability with a list of single-index probabilities. |
|
The cosine of an array. |
|
The hyperbolic cosine of array. |
|
A decorator to define a function with a custom gradient. |
|
The adjoint of |
|
The determinant of matrix. |
|
The array made by inserting the given array along the \(k\)-th diagonal. |
|
The array of the main diagonal of array. |
|
The eigenvalues and eigenvectors of a matrix. |
|
The eigenvalues of a tensor. |
|
The result of the Einstein summation convention on the tensors. |
|
Convert the Euclidean gradient to a Riemannian gradient on the tangent bundle of the symplectic manifold. |
|
Convert the Euclidean gradient to a Riemannian gradient on the tangent bundle of the unitary manifold. |
|
The exponential of array element-wise. |
|
The array with an additional dimension inserted at the given axis. |
|
The matrix exponential of matrix. |
|
The identity matrix of size. |
|
The identity matrix of the same shape and dtype as array. |
Whether the given tensor is a tensor of the concrete backend. |
|
|
The values of the array at the given indices. |
|
Renormalized multidimensional Hermite polynomial given by the "exponential" Taylor series of \(exp(C + Bx + 1/2*Ax^2)\) at zero, where the series has \(sqrt(n!)\) at the denominator rather than \(n!\). |
|
First, reorder A and B parameters of Bargmann representation to match conventions in mrmustard.math.compactFock~ Then, calculate the required renormalized multidimensional Hermite polynomial. |
Renormalized multidimensional Hermite polynomial given by the "exponential" Taylor series of \(exp(C + Bx - Ax^2)\) at zero, where the series has \(sqrt(n!)\) at the denominator rather than \(n!\). |
|
|
Renormalized multidimensional Hermite polynomial given by the "exponential" Taylor series of \(exp(C + Bx + 1/2*Ax^2)\) at zero, where the series has \(sqrt(n!)\) at the denominator rather than \(n!\). |
|
Renormalized multidimensional Hermite polynomial given by the "exponential" Taylor series of \(exp(C + Bx + 1/2*Ax^2)\) at zero, where the series has \(sqrt(n!)\) at the denominator rather than \(n!\). |
|
Firsts, reorder A and B parameters of Bargmann representation to match conventions in mrmustard.math.compactFock~ Then, calculates the required renormalized multidimensional Hermite polynomial. |
|
First, reorder A and B parameters of Bargmann representation to match conventions in mrmustard.math.compactFock~ Then, calculates the required renormalized multidimensional Hermite polynomial. |
Renormalized multidimensional Hermite polynomial given by the "exponential" Taylor series of \(exp(C + Bx - Ax^2)\) at zero, where the series has \(sqrt(n!)\) at the denominator rather than \(n!\). |
|
|
The imaginary part of array. |
|
The inverse of tensor. |
Whether the given tensor is trainable. |
|
|
The Kroenecker product of the given tensors. |
|
Left matrix multiplication of a partial matrix and a full matrix. |
|
The natural logarithm of the gamma function of |
|
The natural logarithm of |
|
Given two real tensors representing the real and imaginary part of a complex number, this operation returns a complex tensor. |
|
Transforms elems by applying fn to each element unstacked on axis 0. |
|
The matrix product of the given matrices. |
|
The matrix vector product of |
|
Matrix-vector multiplication between a phase-space matrix and a vector in the specified modes. |
|
The element-wise maximum of |
|
The element-wise minimum of |
|
Returns a new constant with the given value. |
|
Returns a new variable with the given value and bounds. |
|
The norm of array. |
|
Returns an array of ones with the given |
Returns an array of ones with the same shape and |
|
|
The outer product of |
|
The padded array. |
|
The pseudo-inverse of matrix. |
|
Poisson distribution up to |
|
Returns \(x^y\). |
|
The product of all elements in |
A random orthogonal matrix in \(O(N)\). |
|
|
A random symplectic matrix in |
a random unitary matrix in \(U(N)\) |
|
|
The real part of |
|
The reshaped array. |
|
Right matrix multiplication of a full matrix and a partial matrix. |
|
Rotation matrix from quadratures to complex amplitudes. |
|
The array rounded to the nearest integer. |
|
The array with the diagonal set to |
|
The sine of |
|
Apply the same \(2\times 2\) matrix (i.e. single-mode) to a larger number of modes. |
|
Apply the same 2-vector (i.e. single-mode) to a larger number of modes. |
|
The hyperbolic sine of |
|
The solution of the linear system \(Ax = b\). |
|
Sort the array along an axis. |
|
The square root of |
|
The matrix square root. |
|
Removes dimensions of size 1 from the shape of a tensor. |
|
The sum of array. |
|
The tensordot product of |
|
The tiled array. |
|
The trace of array. |
|
The transposed arrays. |
Unitary to orthogonal mapping. |
|
|
Updates a tensor in place by adding the given values. |
|
Updates a tensor in place with the given values. |
|
The loss and gradients of the given cost function. |
|
Returns |
|
Returns an array of zeros with the given shape and |
Returns an array of zeros with the same shape and |