# Basic LU decomposition problem

I've beens struggling for a while to make my LU decomposition algorithm
work. My implementation is based upon the one outlined in the text
"Numerical Recipes in C++, 2nd edition".

The basic algorithm seems to be working fine, all the rows I would
expect to be there are, however they are permuted (as expected), and
values of the variable indx, i.e. the permutation "vector" are either
incorrect, or my understanding of it is wrong. Hopefuly someone can shed
some light on this problem for me.

I had understood the permutation vector returned by the code in NR to be
a representation of a matrix with just one element per row equal to 1
and the rest 0, i.e the vector

{1, 0, 2}

would represent the matrix

0 1 0
1 0 0
0 0 1

etc.

This indeed appears to be a correct interpretation for many case, but
for some cases, e.g. with the matrix:

4, 8, -10
2, 1, -4
3, -1, 2

the permutation vector is returned as

{2, 2, 2}

which makes no sense to me at all!

My initial assumption was that I'd made a mistake in typing out the
algorithm from NR, but I can't seem to find any mistakes in it now, and
it's still not working how I expected. Clearly under the license of the
code in NR I'm not allowed to post any electronic version of their code,
and I have therfore refrained from doing so. Without pasting code this
question may look like I'm asking the impossible, but really what I'm
looking for is the awnsers to these two questions:

1) Is my interpretation of how the permutation vector should work correct?
2) Has anyone else done the same in the past? It'd be great of someone
can point me in the right direction in terms of correcting this problem!

Thanks,
Alan
.

## Relevant Pages

• Re: Basic LU decomposition problem
... The basic algorithm seems to be working fine, ... I had understood the permutation vector returned by the code in NR to be ... This indeed appears to be a correct interpretation for many case, ... My initial assumption was that I'd made a mistake in typing out the ...
(sci.math.num-analysis)
• Re: Basic LU decomposition problem
... The basic algorithm seems to be working fine, ... I had understood the permutation vector returned by the code in NR to be ... then you calculate P by row sequencing ... the identity matrix with indxthe ...
(sci.math.num-analysis)
• Re: Why do so few people know the difference between arrays and pointers.
... Only after you made a serious mistake or saw the outcome ... > algorithm - even though he theoretically knew it beforehand. ... an algorithm with higher time complexity may be faster than one of ... log^2 ) nanoseconds, and method B taking N^0.7 nanoseconds. ...
(comp.lang.c)
• Re: Commenting in Java
... that obvious from the code alone (and not via an additional step: "Ah I recognise this as algorithm, and I happen to know that only works well with primes")? ... I can tell the story of a similar mistake that I once made, ...
(comp.lang.java.programmer)
• Re: How to calculate SNR for signal which can only detect with noise?
... Someone suggest that for signal which we can only detect with noise, ... source and add some kind of synthesized noise to verify our algorithm. ... do you *know* exactly what signals the data contains, ... "Prejudice" in this context is the mistake of thinking some method ...
(comp.dsp)