September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,11 @@
var [const] GSL=Import("zklGSL"); // libGSL (GNU Scientific Library)
a:=GSL.Matrix(6,6).set(
1.00, 0.00, 0.00, 0.00, 0.00, 0.00,
1.00, 0.63, 0.39, 0.25, 0.16, 0.10,
1.00, 1.26, 1.58, 1.98, 2.49, 3.13,
1.00, 1.88, 3.55, 6.70, 12.62, 23.80,
1.00, 2.51, 6.32, 15.88, 39.90, 100.28,
1.00, 3.14, 9.87, 31.01, 97.41, 306.02);
b:=GSL.VectorFromData(-0.01, 0.61, 0.91, 0.99, 0.60, 0.02);
x:=a.AxEQb(b);
x.format(8,5).println();

View file

@ -0,0 +1,23 @@
fcn gaussEliminate(a,b){ // modifies a&b --> vector
n:=b.len();
foreach dia in ([0..n-1]){
maxRow:=dia; max:=a[dia][dia];
foreach row in ([dia+1 .. n-1]){
if((tmp:=a[row][dia].abs()) > max){ maxRow=row; max=tmp; }
}
a.swap(dia,maxRow); b.swap(dia,maxRow); // swap rows
foreach row in ([dia+1 .. n-1]){
ar:=a[row]; ad:=a[dia]; tmp:=ar[dia] / ad[dia];
foreach col in ([dia+1 .. n-1]){ ar[col]-=tmp*ad[col]; }
ar[dia]=0.0;
b[row]-=tmp*b[dia];
}
}
x:=(0).pump(n,List().write); // -->list filled with garbage
foreach row in ([n-1 .. 0,-1]){
tmp:=b[row]; ar:=a[row];
foreach j in ([n-1 .. row+1,-1]){ tmp-=x[j]*ar[j]; }
x[row]=tmp/a[row][row];
}
x
}

View file

@ -0,0 +1,8 @@
a:=List( List(1.00, 0.00, 0.00, 0.00, 0.00, 0.00,),
List(1.00, 0.63, 0.39, 0.25, 0.16, 0.10,),
List(1.00, 1.26, 1.58, 1.98, 2.49, 3.13,),
List(1.00, 1.88, 3.55, 6.70, 12.62, 23.80,),
List(1.00, 2.51, 6.32, 15.88, 39.90, 100.28,),
List(1.00, 3.14, 9.87, 31.01, 97.41, 306.02) );
b:=List( -0.01, 0.61, 0.91, 0.99, 0.60, 0.02 );
gaussEliminate(a,b).println();