Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
    
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.) –  Hans Lundmark Jan 29 '11 at 15:36
    
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. –  user6383 Jan 29 '11 at 15:45
    
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? –  Rasmus Jan 29 '11 at 15:57
    
"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. –  user6383 Jan 29 '11 at 20:08
    
@Rasmus: In other words, "Postgrad" in the UK = "Graduate Student" in the US. –  Arturo Magidin Jan 29 '11 at 21:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.