style: enable ParameterName in CheckStyle. (#5196)

* Enabled: ParameterName in CheckStyle.

* Refactored to fix  bug caused by selfAssignment of variables in VectorCrossproduct class
This commit is contained in:
Godwill Christopher
2024-05-31 14:01:11 -06:00
committed by GitHub
parent 2568b96784
commit c42b1c940c
23 changed files with 139 additions and 139 deletions

View File

@ -6,34 +6,34 @@ public final class Gaussian {
private Gaussian() {
}
public static ArrayList<Double> gaussian(int mat_size, ArrayList<Double> matrix) {
public static ArrayList<Double> gaussian(int matSize, ArrayList<Double> matrix) {
ArrayList<Double> answerArray = new ArrayList<Double>();
int i;
int j = 0;
double[][] mat = new double[mat_size + 1][mat_size + 1];
double[][] x = new double[mat_size][mat_size + 1];
double[][] mat = new double[matSize + 1][matSize + 1];
double[][] x = new double[matSize][matSize + 1];
// Values from arraylist to matrix
for (i = 0; i < mat_size; i++) {
for (j = 0; j <= mat_size; j++) {
for (i = 0; i < matSize; i++) {
for (j = 0; j <= matSize; j++) {
mat[i][j] = matrix.get(i);
}
}
mat = gaussianElimination(mat_size, i, mat);
answerArray = valueOfGaussian(mat_size, x, mat);
mat = gaussianElimination(matSize, i, mat);
answerArray = valueOfGaussian(matSize, x, mat);
return answerArray;
}
// Perform Gaussian elimination
public static double[][] gaussianElimination(int mat_size, int i, double[][] mat) {
public static double[][] gaussianElimination(int matSize, int i, double[][] mat) {
int step = 0;
for (step = 0; step < mat_size - 1; step++) {
for (i = step; i < mat_size - 1; i++) {
for (step = 0; step < matSize - 1; step++) {
for (i = step; i < matSize - 1; i++) {
double a = (mat[i + 1][step] / mat[step][step]);
for (int j = step; j <= mat_size; j++) {
for (int j = step; j <= matSize; j++) {
mat[i + 1][j] = mat[i + 1][j] - (a * mat[step][j]);
}
}
@ -42,27 +42,27 @@ public final class Gaussian {
}
// calculate the x_1, x_2, ... values of the gaussian and save it in an arraylist.
public static ArrayList<Double> valueOfGaussian(int mat_size, double[][] x, double[][] mat) {
public static ArrayList<Double> valueOfGaussian(int matSize, double[][] x, double[][] mat) {
ArrayList<Double> answerArray = new ArrayList<Double>();
int i;
int j;
for (i = 0; i < mat_size; i++) {
for (j = 0; j <= mat_size; j++) {
for (i = 0; i < matSize; i++) {
for (j = 0; j <= matSize; j++) {
x[i][j] = mat[i][j];
}
}
for (i = mat_size - 1; i >= 0; i--) {
for (i = matSize - 1; i >= 0; i--) {
double sum = 0;
for (j = mat_size - 1; j > i; j--) {
for (j = matSize - 1; j > i; j--) {
x[i][j] = x[j][j] * x[i][j];
sum = x[i][j] + sum;
}
if (x[i][i] == 0) {
x[i][i] = 0;
} else {
x[i][i] = (x[i][mat_size] - sum) / (x[i][i]);
x[i][i] = (x[i][matSize] - sum) / (x[i][i]);
}
answerArray.add(x[i][j]);
}