Could I get a tip or an example how to make a test class for this code? The main idea is to get the sum of the matrix and the vector in the test class with the method "public static double[] sumthem...". I tried to make it work, but here no matter what I do, I cannot assert a value (result, actual, matrix,vector - doesn't work for any of them).
public static double[] sumthem(double[] [] matrix, double[] vector) {
int rows = matrix.length;
int columns = matrix[0].length;
double[] result = new double[rows];
for(int singleRow = 0; singleRow < rows; singleRow++) {
double sum = 0.0;
for(int singleColumn = 0; singleColumn<columns; singleColumn++) {
sum += matrix[singleRow][singleColumn] * vector[singleColumn];
}
result[singleRow] = sum;
}
return result;
}
Aucun commentaire:
Enregistrer un commentaire