API

Index

Reference

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

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

source
Muscle.Tensor — Method
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.adjoint — Method
Base.adjoint(::Tensor)

Return the adjoint of the tensor.

Note

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

source
Base.cat — Method
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.conj — Method
Base.conj(::Tensor)

Return the conjugate of the tensor.

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

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

Return the element of the tensor at the given indices.

source
Base.length — Method
Base.length(::Tensor)

Return the length of the underlying array.

source
Base.parent — Method
Base.parent(::Tensor)

Return the underlying array of the tensor.

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

source
Base.replace — Method
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.selectdim — Method
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.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.

source
Base.size — Method
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.view — Method
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.zero — Method
Base.zero(tensor::Tensor)

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

source
Muscle.binary_einsum — Function
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.dim — Method
dim(tensor::Tensor, i)

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

source
Muscle.expand — Method
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.extend — Method
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.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.

source
Muscle.tensor_eigen_thin — Function
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_thin — Function
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_thin — Function
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_trunc — Function
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_einsum — Function
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