Tensor
- class btensor.tensor.Tensor(data, basis=None, variance=None, name=None, numpy_compatible=True, copy_data=True)[source]
A numerical container class with support for automatic basis transformation.
- Parameters
data (ArrayLike) – NumPy array containing the representation of the tensor.
basis (NBasis | None) – Basis object or tuple of Basis objects, representing the Basis along each axis of the input data. Default: nobasis along each axis.
variance (Sequence[int] | None) – Variance along each dimension. Default: -1.
name (str | None) – Name of the tensor. Default: ‘Basis<ID>’ where <ID> is the ID of the basis.
numpy_compatible (bool) – If True, the tensor can be used in standard NumPy function calls. The basis of the tensor will however not be taken into consideration and no automatic basis transformations will be performed. Default: True.
copy_data (bool) – If False, no copy of the NumPy data will be created. Default: True.
- Return type
None
Methods
Create new Tensor instance.
Change basis of tensor.
Change basis of tensor along one or more selected axes.
Change variance of tensor and transform representation accordingly.
Change variance of tensor along a single axis and transform representation accordingly.
Create a copy of the tensor.
Dot product of two tensors.
Get tuple of common bases between two tensors along each axis.
Check if the basis of the tensor is compatible with another tensor's basis along each axis.
Transforms tensor to a different set of basis.
Replace basis of tensor with a new basis.
Replace variance of tensor without corresponding transformation of the representation.
Sum of tensor elements over a given axis or tuple of axes.
Get representation of tensor as a NumPy ndarray.
Returns the sum along diagonals of the tensor.
Return a tensor with axes transposed.
Attributes
TTransposed tensor.
basisBasis of the tensor.
cobChange of basis interface, similar to change_basis, but using []-syntax.
dtypeNumPy's dtype of the underlying ndarray.
ndimNumber of dimensions of the tensor.
numpy_compatibleshapeCurrent shape of the tensor.
varianceTuple with ndim elements with value 1 or -1, for covariance and contravariance, respectively.