API

Index

Reference

Muscle.TensorType
Tensor{T,N,A<:AbstractArray{T,N}} <: AbstractArray{T,N}

An array-like object with named dimensions (i.e. Index).

source
Muscle.TensorMethod
Tensor(data::AbstractArray{T,N}, inds::AbstractVector{Index})
Tensor(data::AbstractArray{T,N}, inds::NTuple{N,Index}) where {T,N}
Tensor(data::AbstractArray{T,0}) where {T}
Tensor(data::Number)

Construct a tensor with the given data and indices.

source
Base.adjointMethod
Base.adjoint(::Tensor)

Return the adjoint of the tensor.

Note

This method doesn't transpose the array. It is equivalent to conj.

source
Base.catMethod
Base.cat(a::Tensor, b::Tensor; dims)

Concatenate two tensors a and b along the specified dimensions dims.

The indices of the tensors must be equal, otherwise the second tensor will be permuted to match the first one.

Note

dims must be a list of Index.

source
Base.conjMethod
Base.conj(::Tensor)

Return the conjugate of the tensor.

source
Base.dropdimsMethod
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.

source
Base.getindexMethod
Base.getindex(::Tensor, i...)
Base.getindex(::Tensor; i...)
(::Tensor)[index=i...]

Return the element of the tensor at the given indices.

source
Base.lengthMethod
Base.length(::Tensor)

Return the length of the underlying array.

source
Base.parentMethod
Base.parent(::Tensor)

Return the underlying array of the tensor.

source
Base.permutedimsMethod
Base.permutedims(tensor::Tensor, perm)

Permute the dimensions of tensor according to the given permutation perm. The inds will be permuted accordingly.

source
Base.replaceMethod
Base.replace(::Tensor, old_new::Pair{Index,Index}...)

Replace the indices of the tensor according to the given pairs of old and new indices.

Warning

This method does not support cyclic replacements.

source
Base.selectdimMethod
Base.selectdim(tensor::Tensor, dim::Index, 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

source
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.

source
Base.similarMethod
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.

source
Base.sizeMethod
Base.size(::Tensor[, i::Index])

Return the size of the underlying array. If the dimension i (specified by Index or Integer) is specified, then the size of the corresponding dimension is returned.

source
Base.viewMethod
Base.view(tensor::Tensor, i...)
Base.view(tensor::Tensor, inds::Pair{<:Index,<: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.

source
Base.zeroMethod
Base.zero(tensor::Tensor)

Return a tensor of the same size, eltype and inds as tensor but filled with zeros.

source
Muscle.binary_einsumFunction
binary_einsum(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`.
source
Muscle.binary_einsum!Function
binary_einsum!(c::Tensor, a::Tensor, b::Tensor)

Perform a binary tensor contraction operation between a and b and store the result in c.

source
Muscle.dimMethod
dim(tensor::Tensor, i)

Return the location of the dimension of tensor corresponding to the given index i.

source
Muscle.expandMethod
expand(tensor::Tensor, ind::Index, size; method=:zeros)

Pad the tensor along the dimension specified by ind to reach new size. Supported methods are :zeros and :rand.

source
Muscle.extendMethod
extend(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.

source
Muscle.fuseMethod
fuse(tensor, parinds; ind=first(parinds))

Fuses parinds, leaves them on the right-side internally permuted with permutator and names it as ind.

source
Muscle.tensor_eigen_thinFunction
Muscle.tensor_eigen_thin(tensor::Tensor; inds_u, inds_uinv, ind_lambda, kwargs...)

Perform eigen factorization on a tensor. Either inds_u or inds_uinv must be specified.

Keyword arguments

  • inds_u: left / U indices to be used in the eigen factorization, except for ind_lambda.
  • inds_uinv: right / right indices to be used in the eigen factorization, except for ind_lambda.
  • ind_lambda: name of the virtual bond.
  • inplace: If true, it will use A as workspace variable to save space. Defaults to false.
  • kwargs...: additional keyword arguments to be passed to LinearAlgebra.eigen.
source
Muscle.tensor_qr_thinFunction
tensor_qr_thin(tensor::Tensor; inds_q, inds_r, ind_virtual, kwargs...)

Perform QR factorization on a tensor. Either inds_q or inds_r must be specified.

Keyword arguments

  • inds_q: left indices to be used in the QR factorization. Defaults to all indices of t except inds_r.
  • inds_r: right indices to be used in the QR factorization. Defaults to all indices of t except inds_q.
  • ind_virtual: name of the virtual bond. Defaults to a random Index{Symbol}.
source
Muscle.tensor_svd_thinFunction
Muscle.tensor_svd_thin(tensor::Tensor; inds_u, inds_v, ind_s, kwargs...)

Perform SVD factorization on a tensor. Either inds_u or inds_v must be specified.

Keyword arguments

  • inds_u: left / U indices to be used in the SVD factorization, except for ind_s.
  • inds_v: right / right indices to be used in the SVD factorization, except for ind_s.
  • ind_s: name of the virtual bond.
  • inplace: If true, it will use A as workspace variable to save space. Defaults to false.
  • kwargs...: additional keyword arguments to be passed to LinearAlgebra.svd.
source
Muscle.tensor_svd_truncFunction
Muscle.tensor_svd_trunc(tensor::Tensor; inds_u, inds_v, ind_s, threshold, maxbondim, kwargs...)

Same as tensorsvdthin() but with truncation, additional keyword arguments are

  • threshold: relative cutoff for singular values
  • maxdim: maximum bond dimension
source
Muscle.unary_einsumFunction
unary_einsum(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.
source
Muscle.unary_einsum!Function
unary_einsum!(c::Tensor, a::Tensor)

Perform a unary tensor contraction operation on a and store the result in c.

source