for (int n=0; n<NUMBER_OF_REPETITIONS; n++) {
prepareNewMatrixSize(random);
final int numRow = getNumRow();
final int numCol = getNumCol();
double[] elements = createRandomPositiveValues(numRow * numCol);
final Matrix reference = new Matrix(elements, numCol).transpose();
if (!(reference.det() >= DETERMINANT_THRESHOLD)) {
continue; // To close to a singular matrix - search an other one.
}
final MatrixSIS matrix = Matrices.create(numRow, numCol, elements);
/*
* Computes new random value for the argument. We mix positive and negative values,
* but with more positive values than negative ones in order to reduce the chances
* to have a product of zero for an element.
*/
final int nx = random.nextInt(8) + 1;
elements = new double[numCol * nx];
for (int k=0; k<elements.length; k++) {
elements[k] = 8 - random.nextDouble() * 10;
}
final Matrix referenceArg = new Matrix(elements, nx).transpose();
final MatrixSIS matrixArg = Matrices.create(numCol, nx, elements);
/*
* Performs the operation and compare.
*/
final Matrix referenceResult = reference.solve(referenceArg);
final MatrixSIS matrixResult = matrix.solve(matrixArg);
assertEqualsJAMA(referenceResult, matrixResult, SolverTest.TOLERANCE);
}
}