Hi Mathoverflow

I hope you bear with me that my linear algebra knowledge is a little rusty, but I have a question that might potentially very easy to answer. Nevertheless it's been bugging me for a good 3 hours now.

I'm trying to find the LU decomposition of a matrix in order to find the determinant. This would be a straightforward process if it weren't for the fact that my matrix library (Meshcach) only gives me back one matrix when use their LU factor method (together with a pivot). So when I have the matrix A:

```
Matrix: 3 by 3
2 4 1
4 -10 2
1 2 4
```

and I call LUfactor, I get the pivot p:

```
Permutation: size: 3
0->0 1->1 2->2
```

and the matrix LU:

```
Matrix: 3 by 3
2 4 1
2 -18 0
0.5 -0 3.5
```

My question is: How do I find the upper matrix from LU? It seems that the library stores the upper and lower matrix as one single matrix, but I can't figure out how to separate them.

The true upper and lower matrices should be:

```
Lower matrix
1 0 0
0.5 1 0
0.25 0.5 1
Upper matrix
4 -10 2
0 -9 0
0 0 3.5
```

But I'm not sure how the output of meschach would be used to obtain them. I'm aware that this might partly be an algorithm question and could be argued to belong in stackoverflow instead, but I really think there is a higher chance of running in to somebody math-savy who can figure out what's going on, than there is of running in to a programmer who dealt with exactly this problem before.

I hope somebody can help

isan overkill because it is dressing up something simple (computing the determinant via GE) in something fancy (computing the LU via GE and then computing the determinant). So althoughmathematicallythe two are essentially equivalent, via any other reasonable metric, doing LU first is the long way round. That said, a) you should ask this on math.SE, b) sometimes routines are overloaded - on Octave, if I do`lu(A)`

then I just get one matrix but if I do`[L U P] = lu(A)`

then I get three, c) you shouldn't be computing determinants anyway. – Andrew Stacey Oct 25 '10 at 7:39