# Best way to construct 2-D Laplacian banded matrix: BandedMatrices, sparse, or BlockBandedMatrices?

**URL:** <https://discourse.julialang.org/t/best-way-to-construct-2-d-laplacian-banded-matrix-bandedmatrices-sparse-or-blockbandedmatrices/29123>\
**Category:** General Usage\
**Tags:** package\
**Created:** [September 24, 2019, 5:36pm UTC](https://discourse.julialang.org/t/best-way-to-construct-2-d-laplacian-banded-matrix-bandedmatrices-sparse-or-blockbandedmatrices/29123 "2019-09-24T17:36:24Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![dlfivefifty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlfivefifty/32/1959_2.png) [@dlfivefifty](https://discourse.julialang.org/u/dlfivefifty)\
**Post date:** [October 17, 2020, 7:47pm UTC](https://discourse.julialang.org/t/best-way-to-construct-2-d-laplacian-banded-matrix-bandedmatrices-sparse-or-blockbandedmatrices/29123/22 "2020-10-17T19:47:33Z")

</div>

A version of BlockBandedMatrices.jl that supports 3D would be awesome! Keep hoping to find a phd student interested in that project: any good undergrads listening, please consider applying to Imperial!

---

<div class="post-metadata">

**Author:** ![fabiopierella](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fabiopierella/32/26642_2.png) [@fabiopierella](https://discourse.julialang.org/u/fabiopierella)\
**Post date:** [June 30, 2021, 1:50pm UTC](https://discourse.julialang.org/t/best-way-to-construct-2-d-laplacian-banded-matrix-bandedmatrices-sparse-or-blockbandedmatrices/29123/23 "2021-06-30T13:50:25Z")

</div>

Hi Chris!

Graet work you are doing in the DiffEqOperators package.  
I was trying to use the solution you suggested to create a 2D Laplacian matrix, but I can’t seem to manage to be able to concretize it to the right Array.

This is my mwe (julia 1.6, DiffEqOperators 4.29.0)

```julia
using LinearAlgebra, DiffEqOperators, Plots

n = 10

Lxx = CenteredDifference{1}(2,2,1.,n) 
Lyy = CenteredDifference{2}(2,2,1.,n) 
D = Lxx + Lyy

heatmap(Array(D, (n,n)))
png("mwe.png")

```

I get the heatmap on the right, while I’d expect something closer to the one on the left.

 ![mew_vs_ref](https://global.discourse-cdn.com/julialang/original/3X/4/9/49cc2d12652e2b1c5c577a2a1a0c25673cbcab30.png)

Is there anything wrong that I am doing?  
Or is this the expected behavior?

Thanks!  
Fabio

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 2, 2021, 12:13pm UTC](https://discourse.julialang.org/t/best-way-to-construct-2-d-laplacian-banded-matrix-bandedmatrices-sparse-or-blockbandedmatrices/29123/24 "2021-07-02T12:13:31Z")

</div>

That is definitely odd. Open an issue.

[Previous page](https://discourse.julialang.org/t/best-way-to-construct-2-d-laplacian-banded-matrix-bandedmatrices-sparse-or-blockbandedmatrices/29123.md?page=1)
