Search in sources :

Example 1 with RowMajorMatrix

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

the class JeigenAlgorithmFactory method convertToRowMajor.

@Override
public RowMajorMatrix convertToRowMajor(BenchmarkMatrix orig) {
    if (orig == null)
        return null;
    DenseMatrix A = orig.getOriginal();
    RowMajorMatrix ret = new RowMajorMatrix(orig.numRows(), orig.numCols());
    System.arraycopy(A.getValues(), 0, ret.data, 0, ret.data.length);
    return ret;
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix) DenseMatrix(jeigen.DenseMatrix)

Example 2 with RowMajorMatrix

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

the class MtjAlgorithmFactory method convertToMtj.

/**
 * Converts a BenchmarkMatrix in EML into a DenseMatrix in MTJ
 *
 * @param orig A BenchmarkMatrix in EML
 * @return A DenseMatrix in MTJ
 */
public static DenseMatrix convertToMtj(RowMajorMatrix orig) {
    DenseMatrix ret = new DenseMatrix(orig.getNumRows(), orig.getNumCols());
    // MTJ's format is the transpose of this format
    RowMajorMatrix temp = new RowMajorMatrix(1, 1);
    temp.numRows = orig.numCols;
    temp.numCols = orig.numRows;
    temp.data = ret.getData();
    RowMajorOps.transpose(orig, temp);
    return ret;
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix)

Example 3 with RowMajorMatrix

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

the class SvdOverflow method checkResults.

@Override
protected boolean checkResults(RowMajorMatrix[] results) {
    RowMajorMatrix U = results[0];
    RowMajorMatrix S = results[1];
    RowMajorMatrix V = results[2];
    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);
    double error = StabilityBenchmark.residualError(foundA, Ascaled);
    if (error > breakingPoint) {
        reason = OutputError.LARGE_ERROR;
        return false;
    }
    return true;
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix)

Example 4 with RowMajorMatrix

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

the class SvdOverflow method createMatrix.

@Override
protected void createMatrix(int m, int n) {
    // 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);
    // randomly generate singular values and put into ascending order
    double[] sv = new double[o];
    for (int i = 0; i < o; i++) // perturb it from being exactly svMag since that is a pathological case for some
    // algorithms and not common in real world scenarios
    sv[i] = svMag + rand.nextDouble() * BenchmarkToolsMasterApp.SMALL_PERTURBATION;
    A = SolverCommon.createMatrix(U, V, sv);
    Ascaled = new RowMajorMatrix(m, n);
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix)

Example 5 with RowMajorMatrix

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

the class SolveOverGenerator method createInputs.

@Override
public BenchmarkMatrix[] createInputs(MatrixFactory factory, Random rand, int size) {
    BenchmarkMatrix[] inputs = new BenchmarkMatrix[2];
    // A
    inputs[0] = factory.create(3 * size, size);
    // B
    inputs[1] = factory.create(3 * size, 1);
    randomize(inputs[0], -1, 1, rand);
    // make sure an exact solution exists
    RowMajorMatrix A = new RowMajorMatrix(inputs[0]);
    RowMajorMatrix B = new RowMajorMatrix(3 * size, 1);
    RowMajorMatrix X = RowMajorOps.createRandom(size, 1, -1, 1, rand);
    RowMajorOps.mult(A, X, B);
    convertToBm(B, inputs[1]);
    return inputs;
}
Also used : RowMajorMatrix(jmbench.matrix.RowMajorMatrix) BenchmarkMatrix(jmbench.interfaces.BenchmarkMatrix)

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