qml.math¶
This package contains unified functions for framework-agnostic tensor and array manipulation. Given the input tensor-like object, the call is dispatched to the corresponding array manipulation framework, allowing for end-to-end differentiation to be preserved.
Warning
These functions are experimental, and only a subset of common functionality is supported. Furthermore, the names and behaviour of these functions may differ from similar functions in common frameworks; please refer to the function docstrings for more details.
The following frameworks are currently supported:
NumPy
Autograd
TensorFlow
PyTorch
JAX
Functions¶
|
Add arguments element-wise. |
|
Returns True if two arrays are element-wise equal within a tolerance. |
|
Returns True if two tensors are element-wise equal along a given axis. |
|
Creates an array or tensor object of the target framework. |
|
Combine a sequence of 2D tensors to form a block diagonal tensor. |
|
Casts the given tensor to a new type. |
|
Casts a tensor to the same dtype as another. |
|
Concatenate a sequence of tensors along the specified axis. |
|
Convert a tensor to the same type as another. |
|
Calculate the covariance matrix of a list of commuting observables, given the joint probability distribution of the system in the shared eigenbasis. |
|
Detach a tensor from its trace and return just its numerical values. |
|
Construct a diagonal tensor from a list of scalars. |
|
Convenience function to compute a (full) density matrix from a state vector. |
|
Returns the matrix or dot product of two tensors. |
|
Evaluates the Einstein summation convention on the operands. |
|
Re-express a matrix acting on a subspace defined by a set of wire labels according to a global wire order. |
|
Compute the expectation value of an operator with respect to a pure state. |
|
Creates an identity array or tensor object of the target framework. |
|
Compute the fidelity for two states (given as density matrices) acting on quantum systems with the same size. |
|
Compute the fidelity for two states (given as state vectors) acting on quantum systems with the same size. |
|
Frobenius inner product between two matrices. |
An interface independent way of getting the name of the datatype. |
|
|
Determines the correct framework to dispatch to given a tensor-like object or a sequence of tensor-like objects. |
|
Given a deep data structure with interface-specific scalars at the bottom, return their interface name. |
|
Returns a set containing the trainable indices of a sequence of values. |
|
Returns True if the tensor is considered to be in a backpropagation environment, it works for Autograd, TensorFlow and Jax. |
|
Returns True if the tensor is considered abstract. |
|
Test whether a function is independent of its input arguments, both numerically and analytically. |
|
Return True if the tensor has a non-zero complex component. |
|
Compute the marginal probability given a joint probability distribution expressed as a tensor. |
|
Compute the maximum entropy of a density matrix on a given subsystem. |
|
Compute the minimum entropy from a density matrix. |
|
Decorator to dispatch arguments handled by the interface. |
|
Compute the mutual information between two subsystems given a state: |
|
Returns a tensor of all ones with the same shape and dtype as the input tensor. |
|
Compute the reduced density matrix by tracing out the provided indices. |
|
Computes the purity of a density matrix. |
|
Compute the density matrix from a state represented with a density matrix. |
|
Compute the density matrix from a state vector. |
|
Compute the quantum relative entropy of one state with respect to another. |
|
Returns True if the tensor is considered trainable. |
|
Compute the square root matrix of a density matrix where \(\rho = \sqrt{\rho} \times \sqrt{\rho}\) |
|
In-place addition of a multidimensional value over various indices of a tensor. |
|
Stack a sequence of tensors along the specified axis. |
|
Compute the singular value decomposition of a tensor in each interface. |
|
Returns the tensor product of two tensors. |
|
Compute the trace distance between two quantum states. |
|
Unwrap a sequence of objects to NumPy arrays. |
|
Compute the Von Neumann entropy from a density matrix on a given subsystem. |
|
Compute the Von Neumann entanglement entropy between two subsystems in a given state. |
|
Returns elements chosen from x or y depending on a boolean tensor condition, or the indices of entries satisfying the condition. |