| 8 | } |
| 9 | |
| 10 | public static ArrayList<Double> gaussian(int matSize, List<Double> matrix) { |
| 11 | int i; |
| 12 | int j = 0; |
| 13 | |
| 14 | double[][] mat = new double[matSize + 1][matSize + 1]; |
| 15 | double[][] x = new double[matSize][matSize + 1]; |
| 16 | |
| 17 | // Values from arraylist to matrix |
| 18 | for (i = 0; i < matSize; i++) { |
| 19 | for (j = 0; j <= matSize; j++) { |
| 20 | mat[i][j] = matrix.get(i); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | mat = gaussianElimination(matSize, i, mat); |
| 25 | return valueOfGaussian(matSize, x, mat); |
| 26 | } |
| 27 | |
| 28 | // Perform Gaussian elimination |
| 29 | public static double[][] gaussianElimination(int matSize, int i, double[][] mat) { |