# Where can I find certain matrix multiplication optimizations?

**URL:** <https://discourse.julialang.org/t/where-can-i-find-certain-matrix-multiplication-optimizations/107868>\
**Category:** Numerics\
**Tags:** linearalgebra\
**Created:** [December 20, 2023, 5:02pm UTC](https://discourse.julialang.org/t/where-can-i-find-certain-matrix-multiplication-optimizations/107868 "2023-12-20T17:02:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![meisel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/meisel/32/205601_2.png) [@meisel](https://discourse.julialang.org/u/meisel)\
**Post date:** [December 20, 2023, 5:02pm UTC](https://discourse.julialang.org/t/where-can-i-find-certain-matrix-multiplication-optimizations/107868/1 "2023-12-20T17:02:47Z")

</div>

Hi, there are a couple matrix multiplication optimizations that would have a big impact on the performance of my project. They are:

- Automatic coalescing of additions with multiplications, since \*gemm APIs typically allow for an add as well
- Only computing one triangle of a matrix product if I know that it’s a symmetric matrix

Am I missing these in the docs, or do they exist somewhere (or maybe in some third-party Julia project)?

---

<div class="post-metadata">

**Author:** ![palday](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palday/32/12640_2.png) [@palday](https://discourse.julialang.org/u/palday)\
**Post date:** [December 20, 2023, 5:35pm UTC](https://discourse.julialang.org/t/where-can-i-find-certain-matrix-multiplication-optimizations/107868/2 "2023-12-20T17:35:09Z")

</div>

For your first point, have you seen [`mul!`](https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#LinearAlgebra.mul!) ?

Note also that many special matrix types have specialized methods to make things more efficient, e.g. `Symmetric`.

---

<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:** [December 20, 2023, 6:24pm UTC](https://discourse.julialang.org/t/where-can-i-find-certain-matrix-multiplication-optimizations/107868/3 "2023-12-20T18:24:38Z")

</div>

> [@meisel](#):
>
> Only computing one triangle of a matrix product if I know that it’s a symmetric matrix

See e.g. [`BLAS.syrk!`](https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#LinearAlgebra.BLAS.syrk!) and [`syr2k!`](https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#LinearAlgebra.BLAS.syr2k!).
