Search in sources :

Example 11 with RowMajorMatrix

use of jmbench.matrix.RowMajorMatrix in project Java-Matrix-Benchmark by lessthanoptimal.

the class SolverOverflow method check.

@Override
public boolean check(int testPoint) {
    // System.out.println("check = "+testPoint);
    double scale = Math.pow(scaling, testPoint);
    RowMajorOps.scale(scale, A, A_scale);
    RowMajorOps.scale(scale, b, b_scale);
    BenchmarkMatrix[] inputsB = new BenchmarkMatrix[2];
    BenchmarkMatrix[] outputB = new BenchmarkMatrix[1];
    inputsB[0] = factory.convertToLib(A_scale);
    inputsB[1] = factory.convertToLib(b_scale);
    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 error = StabilityBenchmark.residualErrorMetric(A_scale, x, b_scale);
    // was countable, it only become uncountable when computing the error.
    if (Double.isNaN(error) || Double.isInfinite(error) || error > breakingPoint) {
        reason = OutputError.LARGE_ERROR;
        return false;
    }
    System.gc();
    Thread.yield();
    return true;
}
Also used : DetectedException(jmbench.interfaces.DetectedException) MatrixProcessorInterface(jmbench.interfaces.MatrixProcessorInterface) RowMajorMatrix(jmbench.matrix.RowMajorMatrix) BenchmarkMatrix(jmbench.interfaces.BenchmarkMatrix) DetectedException(jmbench.interfaces.DetectedException)

Example 12 with RowMajorMatrix

use of jmbench.matrix.RowMajorMatrix in project Java-Matrix-Benchmark by lessthanoptimal.

the class SvdAccuracy method processResults.

@Override
protected void processResults(RowMajorMatrix[] inputs, RowMajorMatrix[] results) {
    RowMajorMatrix U = results[0];
    RowMajorMatrix S = results[1];
    RowMajorMatrix V = results[2];
    if (RowMajorOps.hasUncountable(U) || RowMajorOps.hasUncountable(S) || RowMajorOps.hasUncountable(V)) {
        reason = OutputError.UNCOUNTABLE;
        return;
    }
    RowMajorMatrix US = new RowMajorMatrix(U.numRows, S.numCols);
    RowMajorMatrix V_tran = new RowMajorMatrix(V.numCols, V.numRows);
    RowMajorMatrix foundA = new RowMajorMatrix(A.numRows, A.numCols);
    RowMajorOps.transpose(V, V_tran);
    RowMajorOps.mult(U, S, US);
    RowMajorOps.mult(US, V_tran, foundA);
    foundResult = StabilityBenchmark.residualError(foundA, A);
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix)

Example 13 with RowMajorMatrix

use of jmbench.matrix.RowMajorMatrix in project Java-Matrix-Benchmark by lessthanoptimal.

the class OverflowTestBase method check.

@Override
public boolean check(int testPoint) {
    double scale = Math.pow(scaling, testPoint);
    Ascaled.set(A);
    RowMajorOps.scale(scale, Ascaled);
    RowMajorMatrix[] inputs = new RowMajorMatrix[] { Ascaled };
    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 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]);
    for (RowMajorMatrix R : results) {
        if (RowMajorOps.hasUncountable(R)) {
            reason = OutputError.UNCOUNTABLE;
            return false;
        }
    }
    return checkResults(results);
}
Also used : DetectedException(jmbench.interfaces.DetectedException) MatrixProcessorInterface(jmbench.interfaces.MatrixProcessorInterface) RowMajorMatrix(jmbench.matrix.RowMajorMatrix) BenchmarkMatrix(jmbench.interfaces.BenchmarkMatrix) DetectedException(jmbench.interfaces.DetectedException)

Example 14 with RowMajorMatrix

use of jmbench.matrix.RowMajorMatrix in project Java-Matrix-Benchmark by lessthanoptimal.

the class SolverCommon method createMatrix.

protected void createMatrix(int m, int n, double svMag) {
    // System.out.println("Matrix size = ("+m+" , "+n+" )");
    RowMajorMatrix U = RowMajorOps.createOrthogonal(m, m, rand);
    RowMajorMatrix V = RowMajorOps.createOrthogonal(n, n, rand);
    int o = Math.min(m, n);
    double[] sv = new double[o];
    for (int i = 0; i < o; i++) sv[i] = svMag;
    A = createMatrix(U, V, sv);
    RowMajorMatrix x = RowMajorOps.createRandom(n, 1, rand);
    b = new RowMajorMatrix(m, 1);
    // make sure b is reasonable
    RowMajorOps.mult(A, x, b);
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix)

Example 15 with RowMajorMatrix

use of jmbench.matrix.RowMajorMatrix in project Java-Matrix-Benchmark by lessthanoptimal.

the class ResultsChecking method checkResult.

public static OutputError checkResult(RowMajorMatrix found, RowMajorMatrix expected, double tol) {
    if (found == null) {
        return OutputError.MISC;
    }
    // see if the found output has uncountable numbers in it
    if (RowMajorOps.hasUncountable(found)) {
        return OutputError.UNCOUNTABLE;
    }
    RowMajorMatrix residual = new RowMajorMatrix(expected.numRows, expected.numCols);
    RowMajorOps.subtract(found, expected, residual);
    double top = RowMajorOps.normF(residual);
    double bottom = RowMajorOps.normF(expected);
    if (bottom == 0)
        return OutputError.ZERO_INPUT;
    if (top / bottom > tol) {
        return OutputError.LARGE_ERROR;
    }
    return OutputError.NO_ERROR;
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix)

Aggregations

RowMajorMatrix (jmbench.matrix.RowMajorMatrix)29 BenchmarkMatrix (jmbench.interfaces.BenchmarkMatrix)6 DetectedException (jmbench.interfaces.DetectedException)5 MatrixProcessorInterface (jmbench.interfaces.MatrixProcessorInterface)5 DenseMatrix (jeigen.DenseMatrix)1 DMatrixRMaj (org.ejml.data.DMatrixRMaj)1 SimpleMatrix (org.ejml.simple.SimpleMatrix)1