use of org.ojalgo.RecoverableCondition in project ojAlgo by optimatika.
the class BasicParser method parse.
/**
* @param reader The CSV data reader
* @param consumer The results consumer
*/
default void parse(final Reader reader, final Consumer<T> consumer) {
String tmpLine = null;
T tmpItem = null;
try (final BufferedReader tmpBufferedReader = new BufferedReader(reader)) {
while ((tmpLine = tmpBufferedReader.readLine()) != null) {
try {
if ((tmpLine.length() > 0) && !tmpLine.startsWith("#") && ((tmpItem = this.parse(tmpLine)) != null)) {
consumer.accept(tmpItem);
}
} catch (final RecoverableCondition xcptn) {
// Skip this line and try the next
}
}
} catch (final IOException exception) {
exception.printStackTrace();
}
}
use of org.ojalgo.RecoverableCondition in project ojAlgo by optimatika.
the class DecompositionProblems method testP20160419.
/**
* A user reported problems related to calculating the pseudoinverse for large (2000x2000) matrices.
*/
@Test
@Tag("slow")
public void testP20160419() {
final PrimitiveDenseStore tmpOrg = PrimitiveDenseStore.FACTORY.makeFilled(2000, 2000, new Normal());
final SingularValue<Double> tmpRaw = new RawSingularValue();
try {
final MatrixStore<Double> tmpInv = tmpRaw.invert(tmpOrg);
TestUtils.assertEquals(tmpOrg, tmpOrg.multiply(tmpInv).multiply(tmpOrg), NumberContext.getGeneral(6, 6));
} catch (final RecoverableCondition exception) {
exception.printStackTrace();
}
}
use of org.ojalgo.RecoverableCondition in project ojAlgo by optimatika.
the class DecompositionProblems method testP20160510InvertLargeMatrix.
/**
* A user discovered that some large (relatively uniform) matrices causes the algorithm to never finsh
* https://github.com/optimatika/ojAlgo/issues/22
*/
@Test
@Tag("slow")
public void testP20160510InvertLargeMatrix() {
final double[][] data = new double[3000][3000];
for (int i = 0; i < data.length; i++) {
for (int j = 0; j < data.length; j++) {
data[i][j] = 0.9;
}
}
data[0][1] = 1.01;
final PrimitiveMatrix input = PrimitiveMatrix.FACTORY.rows(data);
try {
// final SingularValue<Double> svd = SingularValue.make(input);
final SingularValue<Double> svd = new SingularValueDecomposition.Primitive();
svd.invert(input);
} catch (final RecoverableCondition exception) {
// TODO Auto-generated catch block
exception.printStackTrace();
}
// The issue:can't be reached here!!!
}
use of org.ojalgo.RecoverableCondition in project ojAlgo by optimatika.
the class DesignCase method testSolveIdentity.
@Test
public void testSolveIdentity() {
final Access2D<?> tmpIdentity = MatrixStore.PRIMITIVE.makeIdentity(9).get();
final Access2D<?> tmpRandom = PrimitiveDenseStore.FACTORY.makeFilled(9, 1, new Uniform());
final List<MatrixDecomposition<Double>> tmpAllDecomps = MatrixDecompositionTests.getAllPrimitive();
for (final MatrixDecomposition<Double> tmpDecomp : tmpAllDecomps) {
if (tmpDecomp instanceof SolverTask) {
final SolverTask<Double> tmpSolverTask = (SolverTask<Double>) tmpDecomp;
try {
TestUtils.assertEquals(tmpDecomp.getClass().toString(), tmpRandom, tmpSolverTask.solve(tmpIdentity, tmpRandom));
} catch (final RecoverableCondition xcptn) {
TestUtils.fail(tmpDecomp.getClass().toString() + " " + xcptn.getMessage());
}
}
}
}
Aggregations