2
$\begingroup$

I am a computational physics postgrad student, working with libraries like ATLAS and MAGMA. I have a matrix which is upper-triangular, and is the result of a Cholesky decomposition. I need to convert the upper-triangular matrix in to a symmetric, square matrix where the elements of the lower triangle are

mat(j,i) = mat(i,j)

I have a naive routine in C++ that simply does the above in a loop, but it's incredibly slow. I believe it's so slow because the CPU cache is poorly utilised - element i,j is quite far from element j,i.

Is there a clever mathematical trick that I can use to optimise this loop? Or alternatively, does anyone know of any fuctions in BLAS/similar libraries that can do this kind of operation?

Many thanks in advance for any advice you can give.

  • 0
    If the libraries have efficient routines for matrix transposition, maybe you could just try $S=U+U^T$? (Provided that $U$ is strictly upper triangular of course, otherwise you have to divide the diagonal by 2 afterwards.)2011-01-29
  • 0
    Thanks Hans, funnily enough that approach occurred to me not long after posting this question! I am trying to find out whether such a tranposition method exists and how efficient it is.2011-01-29
  • 0
    May I ask out of curiosity: what is a postgrad student? Someone who has completed a master's degree but hasn't started PhD studies?2011-01-29
  • 0
    "Postgrad" is a catch all term in the UK for anybody studying a postgraduate degree, whether that be a master's, Ph.D. or Other. I'm studying an M.Sc. by Research, which is a bastard child of Master's and Ph.D.2011-01-29
  • 0
    @Rasmus: In other words, "Postgrad" in the UK = "Graduate Student" in the US.2011-01-29
  • 0
    @user6383, Arturo Magidin: Thanks a lot for the explanation.2011-01-30
  • 0
    @HansLundmark Please consider converting your comment into an answer, so that this question gets removed from the [unanswered tab](http://meta.math.stackexchange.com/q/3138). If you do so, it is helpful to post it to [this chat room](http://chat.stackexchange.com/rooms/9141) to make people aware of it (and attract some upvotes). For further reading upon the issue of too many unanswered questions, see [here](http://meta.stackexchange.com/q/143113), [here](http://meta.math.stackexchange.com/q/1148) or [here](http://meta.math.stackexchange.com/a/9868).2015-05-05

0 Answers 0