qml.math¶
This package contains unified functions for frameworkagnostic tensor and array manipulation. Given the input tensorlike object, the call is dispatched to the corresponding array manipulation framework, allowing for endtoend 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.
Internally, these functions dispatch by using the TensorBox
class, a container and API for
arraylike objects that allows array manipulation to be performed in a unified manner for supported
tensor/array manipulation frameworks.
The following frameworks are currently supported:
NumPy
Autograd
TensorFlow
PyTorch
Functions¶

Returns the transpose of the tensor by reversing the order of the axes. 

Returns the elementwise absolute value. 

Returns True if two arrays are elementwise equal within a tolerance. 

Returns True if two tensors are elementwise equal along a given axis. 

Returns the elementwise angle of a complex tensor. 

Returns the elementwise inverse sine of the tensor 

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. 

Conjugate a tensor. 

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. 

Construct a diagonal tensor from a list of scalars. 

Returns the matrix or dot product of two tensors. 

Expand the shape of an array by adding a new dimension of size 1 at the specified axis location. 

Flattens an Ndimensional tensor to a 1dimensional tensor. 

Gather tensor values given a tuple of indices. 

Returns the name of the package that any array/tensor manipulations will dispatch to. 

Compute the marginal probability given a joint probability distribution expressed as a tensor. 

Returns a tensor of all ones with the same shape and dtype as the input tensor. 

Returns True if the tensor is considered trainable. 

Gives a new shape to a tensor without changing its data. 

Adds a scalar value to a specific index of a tensor. 

Returns the shape of the tensor. 

Returns the elementwise square root. 

Remove singledimensional entries from the shape of an array. 

Stack a sequence of tensors along the specified axis. 

TensorBox: Returns the sum of the tensor elements across the specified dimensions. 

Gather elements from a tensor. 

Returns the tensor as a NumPy 

Returns elements chosen from x or y depending on a boolean tensor condition. 

Decorator to automate the wrapping of TensorBox method outputs. 
Contents
Downloads