# Options for Sparse Distributed Linear Algebra

**URL:** https://discourse.julialang.org/t/options-for-sparse-distributed-linear-algebra/71744
**Category:** Numerics
**Created:** [November 18, 2021, 8:42pm UTC](https://discourse.julialang.org/t/options-for-sparse-distributed-linear-algebra/71744 "2021-11-18T20:42:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lucasbanting](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lucasbanting/32/30936_2.png) [@lucasbanting](https://discourse.julialang.org/u/lucasbanting)
#### Post date: [November 18, 2021, 8:42pm UTC](https://discourse.julialang.org/t/options-for-sparse-distributed-linear-algebra/71744/1 "2021-11-18T20:42:51Z")

</div>

What is the current state of sparse distributed linear algebra in Julia?

I am interested in switching from C++ to Julia for finite element codes. In C PETSc seems to be the best option for sparse distributed linear algebra. I know PETSc is available as PETSc.jl, but I was curious if there is anything that uses native julia code.

I have found Julia has both Sparse and Darrays, could you have a DArray that is a distributed sparse array?

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [November 18, 2021, 9:38pm UTC](https://discourse.julialang.org/t/options-for-sparse-distributed-linear-algebra/71744/2 "2021-11-18T21:38:32Z")

</div>

> [@lucasbanting](#):
>
> I have found Julia has both Sparse and Darrays, could you have a DArray that is a distributed sparse array?

[GitHub - fverdugo/PartitionedArrays.jl: Vectors and sparse matrices partitioned into pieces for parallel distributed-memory computations.](https://github.com/fverdugo/PartitionedArrays.jl) provides sparse distributed arrays compatible with native Julia iterative solvers, e.g. IterativeSolvers.jl.

(PETSc’s advantage is that it provides a lot of built-in preconditioners, and it is more mature in general, but is also a lot more constrained e.g. in the data types that it supports.)

---

<div class="post-metadata">

### Author: ![andreasnoack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andreasnoack/32/27_2.png) [@andreasnoack](https://discourse.julialang.org/u/andreasnoack)
#### Post date: [November 19, 2021, 7:52am UTC](https://discourse.julialang.org/t/options-for-sparse-distributed-linear-algebra/71744/3 "2021-11-19T07:52:21Z")

</div>

> [@lucasbanting](#):
>
> I have found Julia has both Sparse and Darrays, could you have a DArray that is a distributed sparse array?

The answer is yes

```julia
julia> DArray((10, 10)) do I
         sprandn(map(length, I)..., 0.2)
       end
10×10 DArray{Float64, 2, SparseMatrixCSC{Float64, Int64}}:
 -1.52489 0.0 -0.572173 0.0 0.0 0.0 0.0 0.0848087 0.0 0.0
  0.0 0.0 0.0 0.0 0.0 0.0 0.125291 0.0 0.0 0.0
  0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.663207 0.0 0.0
  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
  1.41673 0.0 0.0 0.0 0.0 0.202435 0.0 0.0 0.0 0.0
  0.0 -0.908404 0.0 0.0 0.0 0.0 0.0 0.0 1.28937 0.150807
  0.0 0.331869 -0.0888742 0.0 0.0 0.0 0.0 0.0 0.0 0.0
  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -1.21831 0.0
 -2.76374 0.0 0.0 0.0 0.0 0.0 -0.419705 0.0 0.0 0.0
  0.344988 0.0 -0.451797 -1.21672 0.0 0.0 0.0 0.0 1.16045 0.0

```

but such a matrix will often end up hitting generic fallbacks which will be extremely slow so you’d probably be better off with the package that Steve links to.
