[JAVA] Code for solving the random number matrix with Pivot Gaussian elimination and Gaussian elimination and comparing the accuracy

I submitted a school assignment, so I saved the code as an article. The essential Pivot Gaussian elimination and Gaussian elimination code are separate articles. conditions: ・ Solve ʻax = b. ・ ʻA is a random number matrix of 500 * 500 (components 1 to 9) -Throw the 2 norms of (b-ax) into ʻerr1 (Gauss) , ʻerr2 (Pivot Gauss) as an error. ・ Language is Java. Whole source

	public static void main(String[] args) {
		//TODO auto-generated method stub

		long t0;
		long time;
		int n =500;
		int m=100;
		double [][]a =new double[n][n];
		double []b =new double[n];
		double []x1 =new double[n];
		double []x2 =new double[n];
		double err1=0.0;
	//	double []err2 =new double[n];
	//	double []err1 = new double[n];
		double err2 =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()));
				}
			}
		
			x1 =Calc.Gauss(a, b);
			err1 = Calc.vecNorm2(Calc.subVec(b,Calc.matVec(a, x1)));
			x2 =Calc.pivotGauss(a, b);
			err2 =Calc.vecNorm2(Calc.subVec(b,Calc.matVec(a, x2)));
			System.out.println(err1);
			System.out.println(err2);
		//System.out.println("\n"+err2);
		}
		//System.out.println(Math.abs((Math.random())));
		time = System.currentTimeMillis()-t0;
		System.out.println("\n Processing time:"+time);
		//Calc.printVec2(err1);
	}

Recommended Posts

Code for solving the random number matrix with Pivot Gaussian elimination and Gaussian elimination and comparing the accuracy
Code for solving a random number matrix with the Pivot Gauss elimination method
Accuracy comparison between Pivot Gaussian elimination and Gaussian elimination
Prepare the environment for java11 and javaFx with Ubuntu 18.4