# BLAS.gemm on views of matrices does not work

**URL:** <https://discourse.julialang.org/t/blas-gemm-on-views-of-matrices-does-not-work/29306>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 30, 2019, 2:12am UTC](https://discourse.julialang.org/t/blas-gemm-on-views-of-matrices-does-not-work/29306 "2019-09-30T02:12:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaximilianJHuber](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maximilianjhuber/32/2579_2.png) [@MaximilianJHuber](https://discourse.julialang.org/u/MaximilianJHuber)\
**Post date:** [September 30, 2019, 2:12am UTC](https://discourse.julialang.org/t/blas-gemm-on-views-of-matrices-does-not-work/29306/1 "2019-09-30T02:12:37Z")

</div>

I am not sure if this should work:

```julia
using LinearAlgebra
BLAS.gemm('N', 'N', @view(zeros(10,10)[:, 1:3:10]), @view(zeros(10,20)[1:3:10,:]))

```

It fails with `ERROR: matrix does not have contiguous columns`.  
However, so does `BLAS.gemm('N', 'N', zeros(10,4), @view(zeros(10,20)[1:3:10,:]))` where there is no column that could be non-continous, but maybe that is just an imprecise error message.

I am asking because I want to use BLAS calls for matrix multiplication with `StridedArray`s to save on memory allocation and achieve maximal performance.

---

<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:** [September 30, 2019, 3:19am UTC](https://discourse.julialang.org/t/blas-gemm-on-views-of-matrices-does-not-work/29306/2 "2019-09-30T03:19:39Z")

</div>

> [@MaximilianJHuber](#):
>
> `@view(zeros(10,20)[1:3:10,:]))`

The columns are not contiguous in memory here, since you are skipping to every 3rd row in each column, so this memory layout is not supported by BLAS.

(Why are you calling `BLAS.gemm` directly instead of using `mul!`?)

---

<div class="post-metadata">

**Author:** ![MaximilianJHuber](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maximilianjhuber/32/2579_2.png) [@MaximilianJHuber](https://discourse.julialang.org/u/MaximilianJHuber)\
**Post date:** [September 30, 2019, 2:49pm UTC](https://discourse.julialang.org/t/blas-gemm-on-views-of-matrices-does-not-work/29306/3 "2019-09-30T14:49:45Z")

</div>

I see, after reading the [Implementation section of Mutli-dimensional Arrays](https://docs.julialang.org/en/v1/manual/arrays/#Implementation-1) I thought BLAS may also support arrays where the dimension over which is summed up is strided, but that is wrong.

Thanks for the tip!
