Tensor
Tenet.Tensor Type
Tensor{T,N,A<:AbstractArray{T,N}} <: AbstractArray{T,N}An array-like object with named dimensions.
sourceTenet.Tensor Method
Tensor(data::AbstractArray{T,N}, inds::AbstractVector{Symbol})
Tensor(data::AbstractArray{T,N}, inds::NTuple{N,Symbol}) where {T,N}
Tensor(data::AbstractArray{T,0}) where {T}
Tensor(data::Number)Construct a tensor with the given data and indices.
sourceBase.adjoint Method
Base.adjoint(::Tensor)Return the adjoint of the tensor.
Note
This method doesn't transpose the array. It is equivalent to conj.
Base.dropdims Method
Base.dropdims(tensor::Tensor; dims)Return a tensor where the dimensions specified by dims are removed. size(tensor, dim) == 1 for each dimension in dims.
Base.getindex Method
Base.getindex(::Tensor, i...)
Base.getindex(::Tensor; i...)
(::Tensor)[index=i...]Return the element of the tensor at the given indices. If kwargs are provided, then it is equivalent to calling view.
Base.permutedims Method
Base.permutedims(tensor::Tensor, perm)Permute the dimensions of tensor according to the given permutation perm. The inds will be permuted accordingly.
Base.replace Method
Base.replace(::Tensor, old_new::Pair{Symbol,Symbol}...)Replace the indices of the tensor according to the given pairs of old and new indices.
Warning
This method does not support cyclic replacements.
Base.selectdim Method
Base.selectdim(tensor::Tensor, dim::Symbol, i)
Base.selectdim(tensor::Tensor, dim::Integer, i)Return a view of the tensor where the index for dimension dim equals i.
Note
This method doesn't return a SubArray, but a Tensor wrapping a SubArray.
See also: selectdim
Base.setindex! Method
Base.setindex!(t::Tensor, v, i...)
Base.setindex(::Tensor; i...)
(::Tensor)[index=i...]Set the element of the tensor at the given indices to v. If kwargs are provided, then it is equivalent to calling .= on view.
Base.similar Method
Base.similar(::Tensor{T,N}[, S::Type, dims::Base.Dims{N}; inds])Return a uninitialize tensor of the same size, eltype and inds as tensor. If S is provided, the eltype of the tensor will be S. If dims is provided, the size of the tensor will be dims.
Base.size Method
Base.size(::Tensor[, i::Symbol])Return the size of the underlying array. If the dimension i (specified by Symbol or Integer) is specified, then the size of the corresponding dimension is returned.
Base.view Method
Base.view(tensor::Tensor, i...)
Base.view(tensor::Tensor, inds::Pair{Symbol,<:Any}...)Return a view of the tensor with the given indices. If a Pair is given, the index is replaced by the value of the pair.
Note
This method doesn't return a SubArray, but a Tensor wrapping a SubArray.
Base.zero Method
Base.zero(tensor::Tensor)Return a tensor of the same size, eltype and inds as tensor but filled with zeros.
EinExprs.inds Method
inds(tensor::Tensor)Return the indices of the tensor in the order of the dimensions.
sourceTenet.dim Method
dim(tensor::Tensor, i::Symbol)Return the location of the dimension of tensor corresponding to the given index i.
Tenet.expand Method
expand(tensor::Tensor; label[, axis=1, size=1, method=:zeros])Expand the tensor by adding a new dimension label with the given size at the specified axis. Currently the supported methods are :zeros and :repeat.
Tenet.fuse Method
fuse(tensor, parinds; ind=first(parinds))Fuses parinds, leaves them on the right-side internally permuted with permutator and names it as ind.
Base.:* Method
*(::Tensor, ::Tensor)
*(::Tensor, ::Number)
*(::Number, ::Tensor)Alias for contract.
Base.:+ Method
+(::Tensor, ::Tensor)Add two tensors element-wise. The tensors must have the same indices, alghough the order of the indices can be different.
sourceBase.:- Method
-(::Tensor, ::Tensor)Subtract two tensors element-wise. The tensors must have the same indices, alghough the order of the indices can be different.
sourceLinearAlgebra.lu Method
LinearAlgebra.lu(tensor::Tensor; left_inds, right_inds, virtualind, kwargs...)Perform LU factorization on a tensor. Either left_inds or right_inds must be specified, unless ndims(tensor) == 2 in which case no indices need to be specified.
Keyword arguments
left_inds: left indices to be used in the LU factorization. Defaults to all indices oftexceptright_inds.right_inds: right indices to be used in the LU factorization. Defaults to all indices oftexceptleft_inds.virtualind: name of the virtual bond. Defaults to a randomSymbol.
LinearAlgebra.qr Method
LinearAlgebra.qr(tensor::Tensor; left_inds, right_inds, virtualind, kwargs...)Perform QR factorization on a tensor. Either left_inds or right_inds must be specified, unless ndims(tensor) == 2 in which case no indices need to be specified.
Keyword arguments
left_inds: left indices to be used in the QR factorization. Defaults to all indices oftexceptright_inds.right_inds: right indices to be used in the QR factorization. Defaults to all indices oftexceptleft_inds.virtualind: name of the virtual bond. Defaults to a randomSymbol.
LinearAlgebra.svd Method
LinearAlgebra.svd(tensor::Tensor; left_inds, right_inds, virtualind, kwargs...)Perform SVD factorization on a tensor. Either left_inds or right_inds must be specified, unless ndims(tensor) == 2 in which case no indices need to be specified.
Keyword arguments
left_inds: left indices to be used in the SVD factorization. Defaults to all indices oftexceptright_inds.right_inds: right indices to be used in the SVD factorization. Defaults to all indices oftexceptleft_inds.virtualind: name of the virtual bond. Defaults to a randomSymbol.
Tenet.contract! Method
contract!(c::Tensor, a::Tensor, b::Tensor)Perform a binary tensor contraction operation between a and b and store the result in c.
Tenet.contract! Method
contract!(c::Tensor, a::Tensor)Perform a unary tensor contraction operation on a and store the result in c.
Tenet.contract Method
contract(a::Tensor, b::Tensor; dims=∩(inds(a), inds(b)), out=nothing)Perform a binary tensor contraction operation.
Keyword arguments
- `dims`: indices to contract over. Defaults to the set intersection of the indices of `a` and `b`.
- `out`: indices of the output tensor. Defaults to the set difference of the indices of `a` and `b`.Todo
We are in the process of making contract multi-backend; i.e. let the user choose between different einsum libraries as the engine powering contract. Currently, we use OMEinsum.jl, but it has proven to be slow when used dynamically like we do.
Tenet.contract Method
contract(a::Tensor; dims=∩(inds(a), inds(b)), out=nothing)Perform a unary tensor contraction operation.
Keyword arguments
- `dims`: indices to contract over. Defaults to the repeated indices.
- `out`: indices of the output tensor. Defaults to the unique indices.DocumenterMermaid.MermaidScriptBlock([...])