アルファテスト終了(1/2) VfuncとEqSysとMatとVec
アルファテスト終了(1/2) VfuncとEqSysとMatとVec
アルファテストの対象は
1.MatのLU分解
2.一元一次方程式(2x-5=0)でのVec、Matの解とVfunc(Newton/Simplex)の解の比較
3.一元三次方程式(x^3+3x^2+4x+2=0でのVecの解とVfuncの解(Newton/Simplex)の比較
4.三元一次連立方程式(*下記)でのMatの解とEqSysの解(Newton/Simplex)の比較
* x+y+z-1=0 & y+z-1=0 & x+z-1=0
このあと実施予定のベータテストは
5.三元非線形連立方程式(4.の延長)の求解
6.線形単回帰関数の観測に基づく係数の推定
7.線形重回帰関数の観測に基づく係数の推定
8.非線形関数の観測に基づくパラメータ推定
ちょいと面倒
でも、完成すると例のあれに取りかかれる。
(5のテストケースにしよう)
1.MatのLU分解
2.一元一次方程式(2x-5=0)でのVec、Matの解とVfunc(Newton/Simplex)の解の比較
3.一元三次方程式(x^3+3x^2+4x+2=0でのVecの解とVfuncの解(Newton/Simplex)の比較
4.三元一次連立方程式(*下記)でのMatの解とEqSysの解(Newton/Simplex)の比較
* x+y+z-1=0 & y+z-1=0 & x+z-1=0
このあと実施予定のベータテストは
5.三元非線形連立方程式(4.の延長)の求解
6.線形単回帰関数の観測に基づく係数の推定
7.線形重回帰関数の観測に基づく係数の推定
8.非線形関数の観測に基づくパラメータ推定
ちょいと面倒
でも、完成すると例のあれに取りかかれる。
(5のテストケースにしよう)
このライブラリは上記8までテストできたらパッケージlll.Locに含めた形で公開予定
ただし、使い易さ重視なので、 メモリ使用効率・計算効率・収束性・頑健性・計算精度・デバッグ効率については一切保障はないことに注意
ただし、使い易さ重視なので、 メモリ使用効率・計算効率・収束性・頑健性・計算精度・デバッグ効率については一切保障はないことに注意
アルファテストドライバ
// // Test for Vfunc, EqSys, Mat, Vec, and their solver methods. // Created by Classiclll on 06/03/19. // import lll.Loc.*; public void setup() { // Mat test Mat m = new Mat( new double[][] { {1,1,1}, {0,1,1}, {1,0,1} } ); println("[ Mat Test ]\n"+ m); println(">>singularity\n"+ m.isSingular()); println(">>LU\n"+ m.luDecompose()); println(">>Inverce of m\n"+ m.inverse()); println(">>Identity check\n"+ m.inverse().mul(m)); println(">>counter Identity\n"+ m.mul(m.inverse())); // simple, first order linear equation, 2x-5=0 Vec svec = new Vec(new double[]{2}); Mat smat = new Mat(new double[][]{{2}}); SimpleFunc simple = new SimpleFunc() ;//sample implementation of Vfunc Vec x0 = new Vec(new double[]{3}); Vec k = new Vec(new double[]{5}); println("\n[ 1st order eq, 2x-5=0 ]"); println(">>DKA Method\n"+ svec.solve(5)); println(">>LU Method\n"+ smat.solve(k)); println(">>Newton Method\n"+ simple.solveByNewton(x0, null)); println(">>Simplex Method\n"+ simple.solveBySimplex(x0, null, 1000)); // Polynomial Equation test, sample implementation of Vfunc PolyFunc poly = new PolyFunc() ; //sample implementation of Vfunc Vec f = new Vec( new double[] {1,3,4} ); println("\n[ Polynomial equation, x^3+3x^2+4x+2=0 ]"); println(">>DKA Method of Vec\n"+ f.solve(-2)); println(">>Newton Method of Vfunc\n"+poly.solveByNewton(x0,null)); println(">>Simplex Method of Vfunc\n"+poly.solveBySimplex(x0,null,1000)); // Linear Equation System test, sample implementation of EqSys LinearFunc linear = new LinearFunc() ;//sample implementation of EqSys Vec x1 = new Vec(new double[]{0,1,1}); Vec b = new Vec(new double[]{1,1,1}); println("\n[ linear eqs, x+y+z-1=0 & y+z-1=0 & x+z-1=0 ]"); println(">>LU Method of Mat\n"+ m.solve(b)); println(">>NewtonMethod of EqSys\n"+linear.solveByNewton(x1)); println(">>SimplexMethod of EqSys\n"+linear.solveBySimplex(x1,1000)); } }
テスト結果
[ Mat Test ] Mat{{1.0, 1.0, 1.0}, {0.0, 1.0, 1.0}, {1.0, 0.0, 1.0}} >>singularity false >>LU Mat{{1.0, 1.0, 1.0}, {0.0, 1.0, 1.0}, {1.0, -1.0, 1.0}} >>Inverce of m Mat{{1.0, -1.0, 0.0}, {1.0, 0.0, -1.0}, {-1.0, 1.0, 1.0}} >>Identity check Mat{{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}} >>counter Identity Mat{{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}} [ 1st order eq, 2x-5=0 ] >>DKA Method Mat{{2.5}, {0.0}} >>LU Method Vec(2.5) >>Newton Method Vec(2.5) >>Simplex Method Vec(2.499999999994543) [ Polynomial equation, x^3+3x^2+4x+2=0 ] >>DKA Method of Vec Mat{{-1.0, -1.0, -1.0}, {-1.0000000000000002, 2.350988701644575E-38, 1.0}} >>Newton Method of Vfunc Vec(-1.0) >>Simplex Method of Vfunc Vec(-1.000000000005457) [ linear eqs, x+y+z-1=0 & y+z-1=0 & x+z-1=0 ] >>LU Method of Mat Vec(0.0 ,0.0 ,1.0) >>NewtonMethod of EqSys Vec(0.0 ,0.0 ,1.0) >>SimplexMethod of EqSys Vec(1.4803462177757E-9 ,1.4690450453997226E-9 ,0.999999997764883)