Search in sources :

Example 6 with BenchmarkMatrix

use of jmbench.interfaces.BenchmarkMatrix in project Java-Matrix-Benchmark by lessthanoptimal.

the class AccuracyTestBase method evaluateTestCase.

protected void evaluateTestCase() {
    reason = OutputError.NO_ERROR;
    foundResult = Double.NaN;
    RowMajorMatrix[] inputs = createInputs();
    BenchmarkMatrix[] inputsB = new BenchmarkMatrix[inputs.length];
    BenchmarkMatrix[] outputB = new BenchmarkMatrix[getNumOutputs()];
    for (int i = 0; i < inputs.length; i++) {
        inputsB[i] = factory.convertToLib(inputs[i]);
    }
    MatrixProcessorInterface operation = createAlgorithm();
    if (operation == null) {
        reason = OutputError.NOT_SUPPORTED;
        return;
    }
    try {
        operation.process(inputsB, outputB, 1);
    } catch (DetectedException e) {
        reason = OutputError.DETECTED_FAILURE;
        return;
    } catch (Exception e) {
        addUnexpectedException(e);
        reason = OutputError.UNEXPECTED_EXCEPTION;
        return;
    }
    RowMajorMatrix[] results = new RowMajorMatrix[outputB.length];
    for (int i = 0; i < results.length; i++) results[i] = factory.convertToRowMajor(outputB[i]);
    processResults(inputs, results);
}
Also used : DetectedException(jmbench.interfaces.DetectedException) MatrixProcessorInterface(jmbench.interfaces.MatrixProcessorInterface) RowMajorMatrix(jmbench.matrix.RowMajorMatrix) BenchmarkMatrix(jmbench.interfaces.BenchmarkMatrix) DetectedException(jmbench.interfaces.DetectedException)

Example 7 with BenchmarkMatrix

use of jmbench.interfaces.BenchmarkMatrix in project Java-Matrix-Benchmark by lessthanoptimal.

the class SolverSingular method check.

@Override
public boolean check(int testPoint) {
    sv[whichSV] = Math.pow(0.9, testPoint) * svMag;
    RowMajorMatrix A_adj = createMatrix(U, V, sv);
    BenchmarkMatrix[] inputsB = new BenchmarkMatrix[2];
    BenchmarkMatrix[] outputB = new BenchmarkMatrix[1];
    inputsB[0] = factory.convertToLib(A_adj);
    inputsB[1] = factory.convertToLib(b);
    MatrixProcessorInterface operation = createAlgorithm();
    if (operation == null) {
        reason = OutputError.NOT_SUPPORTED;
        return false;
    }
    try {
        operation.process(inputsB, outputB, 1);
    } catch (DetectedException e) {
        reason = OutputError.DETECTED_FAILURE;
        return false;
    } catch (Exception e) {
        addUnexpectedException(e);
        reason = OutputError.UNEXPECTED_EXCEPTION;
        return false;
    }
    RowMajorMatrix[] results = new RowMajorMatrix[outputB.length];
    for (int i = 0; i < results.length; i++) results[i] = factory.convertToRowMajor(outputB[i]);
    RowMajorMatrix x = results[0];
    if (RowMajorOps.hasUncountable(x)) {
        reason = OutputError.UNCOUNTABLE;
        return false;
    }
    double residual = StabilityBenchmark.residualErrorMetric(A_adj, x, b);
    // System.out.println(residual);
    if (residual > breakingPoint) {
        reason = OutputError.LARGE_ERROR;
        return false;
    }
    return true;
}
Also used : DetectedException(jmbench.interfaces.DetectedException) MatrixProcessorInterface(jmbench.interfaces.MatrixProcessorInterface) RowMajorMatrix(jmbench.matrix.RowMajorMatrix) BenchmarkMatrix(jmbench.interfaces.BenchmarkMatrix) DetectedException(jmbench.interfaces.DetectedException)

Aggregations

BenchmarkMatrix (jmbench.interfaces.BenchmarkMatrix)7 MatrixProcessorInterface (jmbench.interfaces.MatrixProcessorInterface)6 RowMajorMatrix (jmbench.matrix.RowMajorMatrix)6 DetectedException (jmbench.interfaces.DetectedException)5 Random (java.util.Random)1 TestResults (jmbench.tools.TestResults)1