Tensor tools

I/O functions

ElemCo.TensorTools.save!Function
save!(EC::ECInfo, fname::String, a::AbstractArray...; description="tmp", overwrite=true)

Save array or tuple of arrays a to file fname in EC.scr directory. Add file to EC.files with description.

source
save!(EC::ECInfo, fname::String, a::Tuple; description="tmp", overwrite=true)

Save tuple of arrays a to file fname in EC.scr directory. Add file to EC.files with description.

source
ElemCo.TensorTools.loadFunction
load(EC::ECInfo, fname::String)

Load array from file fname in EC.scr directory.

source
load(EC::ECInfo, fname::String, ::Val{N}, T::Type=Float64; skip_error=false) where {N}

Type-stable load array from file fname in EC.scr directory.

The type T and number of dimensions N are given explicitly. If skip_error is true, return empty Array{T,N} if the dimension/type is wrong.

source
ElemCo.TensorTools.mmapFunction
mmap(EC::ECInfo, fname::String)

Memory-map an existing file for reading. Return a pointer to the file and the mmaped array.

source
ElemCo.TensorTools.newmmapFunction
newmmap(EC::ECInfo, fname::String, dims::Tuple{Vararg{Int}}, Type=Float64; description="tmp")

Create a new memory-map file for writing (overwrites existing file). Add file to EC.files with description. Return a pointer to the file and the mmaped array.

source

Integral extraction

ElemCo.TensorTools.ints1Function
ints1(EC::ECInfo, spaces::String, spincase = nothing)

Return subset of 1e⁻ integrals according to spaces.

The spincase∈{,} can explicitly be given, or will be deduced from upper/lower case of spaces specification.

source
ElemCo.TensorTools.ints2Function
ints2(EC::ECInfo, sp1, sp2, sp3, sp4, spincase)

Return subset of 2e⁻ integrals according to spaces sp1, sp2, sp3, sp4.

The sp1, sp2, sp3, sp4 are arrays or ranges of indices. The spincase∈{,,:αβ} has to be explicitly given. If the last two indices are stored as triangular - make them full.

source
ints2(EC::ECInfo, spaces::String, spincase = nothing)

Return subset of 2e⁻ integrals according to spaces.

The spincase∈{,,:αβ} can explicitly be given, or will be deduced from upper/lower case of spaces specification. If the last two indices are stored as triangular - make them full.

source

Tensor manipulation

ElemCo.TensorTools.sqrtinvcholFunction
sqrtinvchol(A::AbstractMatrix; tol = 1e-8, verbose = false)

Return NON-SYMMETRIC (pseudo)sqrt-inverse of a hermitian matrix using Cholesky decomposition.

Starting from $A^{-1} = A^{-1} L (A^{-1} L)^† = M M^†$ with $A = L L^†$. By solving the equation $L^† M = 1$ (for low-rank: using QR decomposition). Return M.

source
ElemCo.TensorTools.invcholFunction
invchol(A::AbstractMatrix; tol = 1e-8, verbose = false)

Return (pseudo)inverse of a hermitian matrix using Cholesky decomposition .

The inverse is calculated as $A^{-1} = A^{-1} L (A^{-1} L)^† = M M^†$ with $A = L L^†$. By solving the equation $L^† M = 1$ (for low-rank: using QR decomposition)

source
ElemCo.TensorTools.rotate_eigenvectors_to_realFunction
rotate_eigenvectors_to_real(evecs::AbstractMatrix, evals::AbstractVector)

Transform complex eigenvectors of a real matrix to a real space such that they block-diagonalize the matrix.

Return the eigenvectors and "eigenvalues" (the diagonal of the matrix) in the real space.

source

Other exported functions

ElemCo.TensorTools.balance_norms!Function
balance_norms!(evecs::AbstractMatrix, leftvecs=nothing)

Balance the norms of left and right eigenvectors.

Make each pair of left and right eigenvectors have the same norm.

source
ElemCo.TensorTools.detri_int2!Method
detri_int2!(out, allint2, norb, sp1, sp2, sp3, sp4)

Return full 2e⁻ integrals <sp1 sp2 | sp3 sp4> from allint2 with last two indices as a triangular index. The result is stored in out.

source
ElemCo.TensorTools.detri_int2Method
detri_int2(allint2, norb, sp1, sp2, sp3, sp4)

Return full 2e⁻ integrals <sp1 sp2 | sp3 sp4> from allint2 with last two indices as a triangular index.

source
ElemCo.TensorTools.ints2!Function
ints2!(out::AbstractArray{Float64,4}, EC::ECInfo, spaces::String, spincase = nothing)

Return subset of 2e⁻ integrals according to spaces.

The spincase∈{,,:αβ} can explicitly be given, or will be deduced from upper/lower case of spaces specification. If the last two indices are stored as triangular - make them full. The result is stored in out.

source
ElemCo.TensorTools.ints2!Method
ints2!(out::AbstractArray{Float64,4}, EC::ECInfo, sp1, sp2, sp3, sp4, spincase)

Return subset of 2e⁻ integrals according to spaces sp1, sp2, sp3, sp4.

The sp1, sp2, sp3, sp4 are arrays or ranges of indices. The spincase∈{,,:αβ} has to be explicitly given. If the last two indices are stored as triangular - make them full. The result is stored in out.

source
ElemCo.TensorTools.load!Method
load!(EC::ECInfo, fname::String, arrs::AbstractArray{T,N}...; skip_error=false)

Load array(s) from file fname in EC.scr directory.

The type and number of dimensions are deduced from the first array in arrs. If skip_error is true, return false if the dimension/type is wrong.

source
ElemCo.TensorTools.load_allMethod
load_all(EC::ECInfo, fname::String, ::Val{N}, T::Type=Float64; skip_error=false) where {N}

Type-stable load arrays from file fname in EC.scr directory.

The type T and number of dimensions N are given explicitly (have to be the same for all arrays). Return an array of arrays. If skip_error is true, return empty Array{T,N}[Array{T,N}()] if the dimension/type is wrong.

source
ElemCo.TensorTools.print_nonzerosMethod
print_nonzeros(tensor::AbstractArray; ϵ=1.e-12, fname::String="")

Print cartesian index alongside value of array for elements with absolute value greater or equal than ϵ either to stdout or to a file.

source

Internal functions

ElemCo.TensorTools.triindsFunction
triinds(norb, sp1::AbstractArray{Int}, sp2::AbstractArray{Int}, reverseCartInd = false)

Generate set of CartesianIndex for addressing the lhs and a bitmask for the rhs for transforming a triangular index from 1:norb to two original indices in spaces sp1 and sp2. If reverse: the cartesian indices are reversed.

source