Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/LU-decomposition/Stata/lu-decomposition-1.stata
Normal file
34
Task/LU-decomposition/Stata/lu-decomposition-1.stata
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
mata
|
||||
: lud(a=(1,3,5\2,4,7\1,1,0),l=.,u=.,p=.)
|
||||
|
||||
: a
|
||||
1 2 3
|
||||
+-------------+
|
||||
1 | 1 3 5 |
|
||||
2 | 2 4 7 |
|
||||
3 | 1 1 0 |
|
||||
+-------------+
|
||||
|
||||
: l
|
||||
1 2 3
|
||||
+----------------+
|
||||
1 | 1 0 0 |
|
||||
2 | .5 1 0 |
|
||||
3 | .5 -1 1 |
|
||||
+----------------+
|
||||
|
||||
: u
|
||||
1 2 3
|
||||
+-------------------+
|
||||
1 | 2 4 7 |
|
||||
2 | 0 1 1.5 |
|
||||
3 | 0 0 -2 |
|
||||
+-------------------+
|
||||
|
||||
: p
|
||||
1
|
||||
+-----+
|
||||
1 | 2 |
|
||||
2 | 1 |
|
||||
3 | 3 |
|
||||
+-----+
|
||||
23
Task/LU-decomposition/Stata/lu-decomposition-2.stata
Normal file
23
Task/LU-decomposition/Stata/lu-decomposition-2.stata
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
void ludec(real matrix a, real matrix l, real matrix u, real vector p) {
|
||||
real scalar i,j,n,s
|
||||
real vector js
|
||||
|
||||
l = a
|
||||
n = rows(a)
|
||||
p = 1::n
|
||||
for (i=1; i<n; i++) {
|
||||
maxindex(abs(l[i::n,i]), 1, js=., .)
|
||||
j = js[1]+i-1
|
||||
if (j!=i) {
|
||||
l[(i\j),.] = l[(j\i),.]
|
||||
p[(i\j)] = p[(j\i)]
|
||||
}
|
||||
for (j=i+1; j<=n; j++) {
|
||||
l[j,i] = s = l[j,i]/l[i,i]
|
||||
l[j,i+1..n] = l[j,i+1..n]-s*l[i,i+1..n]
|
||||
}
|
||||
}
|
||||
|
||||
u = uppertriangle(l)
|
||||
l = lowertriangle(l, 1)
|
||||
}
|
||||
33
Task/LU-decomposition/Stata/lu-decomposition-3.stata
Normal file
33
Task/LU-decomposition/Stata/lu-decomposition-3.stata
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
: ludec(a=(1,3,5\2,4,7\1,1,0),l=.,u=.,p=.)
|
||||
|
||||
: a
|
||||
1 2 3
|
||||
+-------------+
|
||||
1 | 1 3 5 |
|
||||
2 | 2 4 7 |
|
||||
3 | 1 1 0 |
|
||||
+-------------+
|
||||
|
||||
: l
|
||||
1 2 3
|
||||
+----------------+
|
||||
1 | 1 0 0 |
|
||||
2 | .5 1 0 |
|
||||
3 | .5 -1 1 |
|
||||
+----------------+
|
||||
|
||||
: u
|
||||
1 2 3
|
||||
+-------------------+
|
||||
1 | 2 4 7 |
|
||||
2 | 0 1 1.5 |
|
||||
3 | 0 0 -2 |
|
||||
+-------------------+
|
||||
|
||||
: p
|
||||
1
|
||||
+-----+
|
||||
1 | 2 |
|
||||
2 | 1 |
|
||||
3 | 3 |
|
||||
+-----+
|
||||
Loading…
Add table
Add a link
Reference in a new issue