Search in sources :

Example 16 with RowMajorMatrix

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

the class SvdAccuracy method createMatrix.

@Override
protected void createMatrix(int m, int n) {
    int o = Math.min(m, n);
    int numS = rand.nextInt(o);
    while (numS == 0) {
        numS = rand.nextInt(o);
    }
    // System.out.println("Matrix size = ("+m+" , "+n+" )");
    RowMajorMatrix U = RowMajorOps.createOrthogonal(m, m, rand);
    RowMajorMatrix V = RowMajorOps.createOrthogonal(n, n, rand);
    // randomly generate singular values and put into ascending order
    sv = new double[o];
    for (int i = 0; i < numS; i++) sv[i] = -rand.nextDouble() * maxMag;
    Arrays.sort(sv);
    for (int i = 0; i < numS; i++) sv[i] = -sv[i];
    A = SolverCommon.createMatrix(U, V, sv);
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix)

Example 17 with RowMajorMatrix

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

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

the class EigSymmAccuracy method processResults.

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

Example 19 with RowMajorMatrix

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

the class EigSymmAccuracy method createMatrix.

@Override
protected void createMatrix(int m, int n) {
    A = RowMajorOps.createSymmetric(m, -1, 1, rand);
    L = new RowMajorMatrix(m, m);
    R = new RowMajorMatrix(m, m);
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix)

Example 20 with RowMajorMatrix

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

the class InvSymmAccuracy method createMatrix.

@Override
protected void createMatrix(int m, int n) {
    A = RowMajorOps.createSymmPosDef(m, rand);
    I_found = new RowMajorMatrix(m, m);
    I = RowMajorOps.identity(m);
}
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