Search in sources :

Example 21 with RowMajorMatrix

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

the class InvSymmAccuracy method processResults.

@Override
protected void processResults(RowMajorMatrix[] inputs, RowMajorMatrix[] results) {
    RowMajorMatrix A_inv = results[0];
    if (RowMajorOps.hasUncountable(A_inv)) {
        reason = OutputError.UNCOUNTABLE;
        return;
    }
    RowMajorOps.mult(A, A_inv, I_found);
    foundResult = StabilityBenchmark.residualError(I_found, I);
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix)

Example 22 with RowMajorMatrix

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

the class SolverCommon method createMatrix.

public static RowMajorMatrix createMatrix(RowMajorMatrix U, RowMajorMatrix V, double[] sv) {
    RowMajorMatrix S = RowMajorOps.diagR(U.numRows, V.numRows, sv);
    RowMajorMatrix tmp = new RowMajorMatrix(U.numRows, V.numRows);
    RowMajorOps.mult(U, S, tmp);
    RowMajorOps.multTransB(tmp, V, S);
    return S;
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix)

Example 23 with RowMajorMatrix

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

the class SolverSingular method evaluateNearlySingular.

private void evaluateNearlySingular(int m, int n) {
    U = RowMajorOps.createOrthogonal(m, m, rand);
    V = RowMajorOps.createOrthogonal(n, n, rand);
    int o = Math.min(m, n);
    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);
    RowMajorOps.mult(A, x, b);
    reason = OutputError.NO_ERROR;
    int point = search.findCriticalPoint(-1, findMaxPow(0.9) + 1);
    foundResult = Math.pow(0.9, point) * svMag;
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix)

Example 24 with RowMajorMatrix

use of jmbench.matrix.RowMajorMatrix 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)

Example 25 with RowMajorMatrix

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

the class EigSymmOverflow method checkResults.

@Override
protected boolean checkResults(RowMajorMatrix[] results) {
    RowMajorMatrix D = results[0];
    RowMajorMatrix V = results[1];
    RowMajorOps.mult(Ascaled, V, L);
    RowMajorOps.mult(V, D, R);
    double error = StabilityBenchmark.residualError(L, R);
    if (error > breakingPoint) {
        reason = OutputError.LARGE_ERROR;
        return false;
    }
    return true;
}
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