# Are there any 5-argument versions of \`mul!\` or similar in LinearAlgebra now?

**URL:** <https://discourse.julialang.org/t/are-there-any-5-argument-versions-of-mul-or-similar-in-linearalgebra-now/14585>\
**Category:** Performance\
**Created:** [September 5, 2018, 3:42pm UTC](https://discourse.julialang.org/t/are-there-any-5-argument-versions-of-mul-or-similar-in-linearalgebra-now/14585 "2018-09-05T15:42:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Post date:** [September 5, 2018, 3:42pm UTC](https://discourse.julialang.org/t/are-there-any-5-argument-versions-of-mul-or-similar-in-linearalgebra-now/14585/1 "2018-09-05T15:42:54Z")

</div>

The BLAS routines for multiplication and solving linear systems allow for scalar multipliers, usually written `alpha` and `beta`, so that the general mutating version of a matrix product is equivalent to

```julia
C .= α .* (A * B) + β .* C

```

I thought I saw 5-argument versions of `mul!` with a signature like

```julia
mul!(C::Matrix{T}, A::Matrix{T}, B::Matrix{T}, alpha::T, beta::T)

```

but it appears I was hallucinating.

Are there methods for `mul!`, etc. that would end up calling `LinearAlgebra.BLAS.gemm!`with `alpha` and `beta` arguments?

The reason I want this is because a calculation in a tight inner loop needs to replace `C` by `C - A*B` and I would much prefer to do this in-place. If there are alternative ways to accomplish this I would welcome hearing of them.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [September 5, 2018, 4:37pm UTC](https://discourse.julialang.org/t/are-there-any-5-argument-versions-of-mul-or-similar-in-linearalgebra-now/14585/2 "2018-09-05T16:37:01Z")

</div>

AFAIK, the `gemm_wrapper!` which is the entry point the the BLAS gemm still hardcodes alpha and beta in its call:

> <https://github.com/JuliaLang/julia/blob/8d993569b86608f9588458930a203fa4bc29ad50/stdlib/LinearAlgebra/src/matmul.jl#L458>

Sparse arrays do have this 5 arg version though, heh:

> <https://github.com/JuliaLang/julia/blob/8d993569b86608f9588458930a203fa4bc29ad50/stdlib/SparseArrays/src/linalg.jl#L32>
