https://github.com/itensor/blocksparsearrays.jl
https://github.com/itensor/blocksparsearrays.jl
Last synced: 26 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/itensor/blocksparsearrays.jl
- Owner: ITensor
- License: apache-2.0
- Created: 2024-11-20T22:53:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-04-16T06:06:26.000Z (about 1 month ago)
- Last Synced: 2026-04-16T08:17:15.203Z (about 1 month ago)
- Language: Julia
- Size: 2.4 MB
- Stars: 3
- Watchers: 2
- Forks: 3
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BlockSparseArrays.jl
[](https://itensor.github.io/BlockSparseArrays.jl/stable/)
[](https://itensor.github.io/BlockSparseArrays.jl/dev/)
[](https://github.com/ITensor/BlockSparseArrays.jl/actions/workflows/Tests.yml?query=branch%3Amain)
[](https://codecov.io/gh/ITensor/BlockSparseArrays.jl)
[](https://github.com/ITensor/ITensorFormatter.jl)
[](https://github.com/JuliaTesting/Aqua.jl)
A block sparse array type in Julia based on the [`BlockArrays.jl`](https://github.com/JuliaArrays/BlockArrays.jl) interface.
## Support

BlockSparseArrays.jl is supported by the Flatiron Institute, a division of the Simons Foundation.
## 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
julia> using Pkg: Pkg
julia> Pkg.Registry.add(url = "https://github.com/ITensor/ITensorRegistry")
```
or:
```julia
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
julia> Pkg.add("BlockSparseArrays")
```
## Examples
````julia
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
````
---
*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*