I submitted a school assignment, so I saved the code as an article.
conditions:
・ Solve ʻax = b.  ・ ʻA is a random number matrix of 500 * 500 (components 1 to 9)
・ The 2 norms of (b-ax) are thrown into ʻerr1` as an error.
・ Language is Java.
Whole source
	public static main {
		long t0;
		long time;
		int n =500;
		int m=100;
		double [][]a =new double[n][n];
		double []b =new double[n];
		double []x2 =new double[n];
		double err1 =0.0;
		//Issue err1
		t0 = System.currentTimeMillis();
		for(int s=0;s<m;s++){
			for(int j=0;j<n;j++){
				for(int i=0;i<n;i++){
					a[i][j]=Math.abs((Math.random()));
					b[i]  =Math.abs((Math.random()));
				}
			}
			x2 =Calc.pivotGauss(a, b);
			err1 =Calc.vecNorm2(Calc.subVec(b,Calc.matVec(a, x2)));
			System.out.println(err2);
		}
		time = System.currentTimeMillis()-t0;
		System.out.println("\n Processing time:"+time);
	}
        Recommended Posts