BlockSparseArrays.jl
A block sparse array type in Julia based on the BlockArrays.jl
interface.
Installation instructions
This package resides in the ITensor/ITensorRegistry
local registry. In order to install, simply add that registry through your package manager. This step is only required once.
julia> using Pkg: Pkg
julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
or:
julia> Pkg.Registry.add(url="git@github.com:ITensor/ITensorRegistry.git")
if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.
Then, the package can be added as usual through the package manager:
julia> Pkg.add("BlockSparseArrays")
Examples
using BlockArrays: Block
using BlockSparseArrays: BlockSparseArray, blockstoredlength
using Test: @test
a = BlockSparseArray{Float64}(undef, [2, 3], [2, 3])
a[Block(1, 2)] = randn(2, 3)
a[Block(2, 1)] = randn(3, 2)
@test blockstoredlength(a) == 2
b = a .+ 2 .* a'
@test Array(b) ≈ Array(a) + 2 * Array(a')
@test blockstoredlength(b) == 2
Test Passed
This page was generated using Literate.jl.