LU decomposition: Difference between revisions

Content added Content deleted
(→‎{{header|Go}}: added version with flat representation)
(LU composition of Matlab / Octave)
Line 1,094: Line 1,094:
[[File:LUex1.png]]
[[File:LUex1.png]]
[[File:LUex2.png]]
[[File:LUex2.png]]


=={{header|Matlab / Octave}}==

LU decomposition is part of language

<lang Matlab>
A = [
1 3 5
2 4 7
1 1 0];

[L,U,P] = lu(A)</lang>
gives the output:
<lang Matlab> L =

1.00000 0.00000 0.00000
0.50000 1.00000 0.00000
0.50000 -1.00000 1.00000

U =

2.00000 4.00000 7.00000
0.00000 1.00000 1.50000
0.00000 0.00000 -2.00000

P =

0 1 0
1 0 0
0 0 1

</lang>
2nd example:
<lang Matlab> A = [
11 9 24 2
1 5 2 6
3 17 18 1
2 5 7 1 ];

[L,U,P] = lu(A)</lang>
gives the output:
<lang Matlab> L =

1.00000 0.00000 0.00000 0.00000
0.27273 1.00000 0.00000 0.00000
0.09091 0.28750 1.00000 0.00000
0.18182 0.23125 0.00360 1.00000

U =

11.00000 9.00000 24.00000 2.00000
0.00000 14.54545 11.45455 0.45455
0.00000 0.00000 -3.47500 5.68750
0.00000 0.00000 0.00000 0.51079

P =

1 0 0 0
0 0 1 0
0 1 0 0
0 0 0 1
</lang>


=={{header|Python}}==
=={{header|Python}}==