Hi, everyone.
I’m new to this language, I’ve been loving it so far, despite having encountered some setbacks. One of them could be a memory leak when multiplying a matrix with its transpose. I use the mul!(Y,A,B) function, and the manual makes it clear that Y should not be related to either A or B:
Blockquote mul!(Y, A, B) → Y. Note that Y must not be aliased with either A or B
However, I have experienced nasty memory leaks (i.e. the program gave correct numerical output, but its CPU usage kept increasing) when A and B are related, as e.g.:
B =transpose(A)
mul!( Y , A , B)
My solution has been to use the transpose! function, as in
transpose(!B , A)
mul!( Y , A , B)
Does this make sense? Unfortunately, I am not able to produce a minimal working code, since the leaks go away when simplifying the full code. The later, I am also unable to provide due to confidentiality reasons!
[ BTW, multiplying a matrix by its transpose, thus producing a positive semidefinite symmetric matrix, M =A’ A, which later appears in a linear system M x = y, to be solved as x = M \ y, is an extremely common situation. I appreciate general comments about this, but perhaps it merits a separate topic… ]