# Multiply two hermitian or symmetric matrices

**URL:** <https://discourse.julialang.org/t/multiply-two-hermitian-or-symmetric-matrices/120709>\
**Category:** General Usage\
**Created:** [September 30, 2024, 7:10am UTC](https://discourse.julialang.org/t/multiply-two-hermitian-or-symmetric-matrices/120709 "2024-09-30T07:10:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco-Congedo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marco-congedo/32/7321_2.png) [@Marco-Congedo](https://discourse.julialang.org/u/Marco-Congedo)\
**Post date:** [September 30, 2024, 7:10am UTC](https://discourse.julialang.org/t/multiply-two-hermitian-or-symmetric-matrices/120709/1 "2024-09-30T07:10:54Z")

</div>

Hello, is there a specialized `mul` method in julia that can multiply efficiently Hermitian or symmetric matrices without them being of the `Hermitian` or `Symmetric` type ?

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [September 30, 2024, 7:20am UTC](https://discourse.julialang.org/t/multiply-two-hermitian-or-symmetric-matrices/120709/2 "2024-09-30T07:20:36Z")

</div>

Why do you wish to avoid wrapping them? That is the very mechanism through which Julia recognizes this type of matrix and can choose the fastest algorithm.

---

<div class="post-metadata">

**Author:** ![Marco-Congedo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marco-congedo/32/7321_2.png) [@Marco-Congedo](https://discourse.julialang.org/u/Marco-Congedo)\
**Post date:** [September 30, 2024, 4:29pm UTC](https://discourse.julialang.org/t/multiply-two-hermitian-or-symmetric-matrices/120709/3 "2024-09-30T16:29:32Z")

</div>

I guess i should. Is there any overhead?

---

<div class="post-metadata">

**Author:** ![Salmon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/salmon/32/22968_2.png) [@Salmon](https://discourse.julialang.org/u/Salmon)\
**Post date:** [September 30, 2024, 4:58pm UTC](https://discourse.julialang.org/t/multiply-two-hermitian-or-symmetric-matrices/120709/4 "2024-09-30T16:58:09Z")

</div>

there is zero overhead(\*)

> **(\*)**
>
> provided that the compiler can figure out whether the matrix is wrapped or not. If, hypothetically, you generate a matrix and then check whether it is hermitian, symmetric or not and then wrap depending on the outcome there may be a little performance overhead. This can probably be avoided. I guess in many cases you will know beforehand if the matrix will be symmetric or hermitian. If not you can use [function barriers](https://docs.julialang.org/en/v1/manual/performance-tips/#kernel-functions) which will probably make the overhead negligible

---

<div class="post-metadata">

**Author:** ![Marco-Congedo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marco-congedo/32/7321_2.png) [@Marco-Congedo](https://discourse.julialang.org/u/Marco-Congedo)\
**Post date:** [September 30, 2024, 5:09pm UTC](https://discourse.julialang.org/t/multiply-two-hermitian-or-symmetric-matrices/120709/5 "2024-09-30T17:09:14Z")

</div>

Thanks
