I am not satisfied yet. Can I avoid using the outer Do loop by turning it into a Fold or a Nest? The only idea I was able to come up with involved a Nested ReplacePart function, but I think it would be just some pretentious sweeping under the rug. Am I mistaken?

In case you are not aware there is a built-in function CholeskyDecomposition.
–
Mr.Wizard♦Jun 11 '12 at 14:23

3

Thanks for welcoming me! Anyway, I am aware of the existence of the built-in function and I have used it to test results for both implementations, but for my Computational Physics course I have to implement a Cholesky decomposition by myself. I am free to do it in whatever programming language I want, so I picked Mathematica since it is the one I am most familiar with. I know that the procedural implementation would be more than enough for my course, but I'm trying to learn functional programming as well by myself in the meanwhile. :)
–
Andrea ColonnaJun 11 '12 at 14:25

As a tiny note, PositiveDefiniteMatrixQ[] internally computes a Cholesky decomposition to prove the positive-definiteness of a matrix, so in effect, you're doing a Cholesky decomposition twice... :)
–
Guess who it is.♦Jun 12 '12 at 9:20

It indeed looks better, but wouldn't Append make it actually run slower than the procedural approach?
–
Andrea ColonnaJun 11 '12 at 14:59

1

@Andrea you're not a beginning user, are you? :-) Possibly, but I am working toward elegance, not performance. If your ultimate goal is performance you need to include that in your question.
–
Mr.Wizard♦Jun 11 '12 at 15:06

@Andrea how large are the matrices you will be using?
–
Mr.Wizard♦Jun 11 '12 at 15:08

An alternate to Append is a linked list form. It may speed things up, while retaining a measure of elegance.
–
rcollyerJun 11 '12 at 15:11

@rcollyer I'm not sure that will be true in this case as the intermediate result needs to be used; it cannot be flattened (only) at the end.
–
Mr.Wizard♦Jun 11 '12 at 15:13

This is not a functional implementation (as it stands, it's rather MATLAB-ish), but I'll leave this snippet around and hope somebody could make something purely functional out of this outer product form of Cholesky decomposition:

Sometimes loops are the right choice. Despite everyone's best efforts I did not feel that any answer truly improved on the original.
–
Mr.Wizard♦Jun 12 '12 at 14:06

Well, that question I asked on triangular recursions quite a while back also comes to mind. Still, I feel that outer product Cholesky is much more compact than OP's original route...
–
Guess who it is.♦Jun 12 '12 at 14:09

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.