Search in sources :

Example 81 with NumberContext

use of org.ojalgo.type.context.NumberContext in project ojAlgo by optimatika.

the class BidiagonalTest method testComplexSquareCase.

@Test
public void testComplexSquareCase() {
    final PhysicalStore<ComplexNumber> tmpOriginal = MatrixUtils.makeRandomComplexStore(4, 4);
    final Bidiagonal<ComplexNumber> tmpDecomposition = Bidiagonal.COMPLEX.make();
    tmpDecomposition.decompose(tmpOriginal);
    final MatrixStore<ComplexNumber> tmpReconstructed = tmpDecomposition.reconstruct();
    final MatrixStore<ComplexNumber> tmpQ1 = tmpDecomposition.getQ1();
    final MatrixStore<ComplexNumber> tmpD = tmpDecomposition.getD();
    final MatrixStore<ComplexNumber> tmpQ2 = tmpDecomposition.getQ2();
    if (MatrixDecompositionTests.DEBUG) {
        BasicLogger.debug();
        BasicLogger.debug(tmpDecomposition.toString());
        BasicLogger.debug("Original", tmpOriginal);
        BasicLogger.debug("Q1", tmpQ1);
        BasicLogger.debug("D", tmpD);
        BasicLogger.debug("Q2", tmpQ2);
        BasicLogger.debug("Reconstructed", tmpReconstructed);
        BasicLogger.debug("Q1 orthogonal (left)", tmpQ1.conjugate().multiply(tmpQ1));
        BasicLogger.debug("Q1 orthogonal (right)", tmpQ1.multiply(tmpQ1.conjugate()));
        BasicLogger.debug("Q2 orthogonal (left)", tmpQ2.conjugate().multiply(tmpQ2));
        BasicLogger.debug("Q2 orthogonal (right)", tmpQ2.multiply(tmpQ2.conjugate()));
    }
    TestUtils.assertEquals(tmpOriginal, tmpDecomposition, new NumberContext(7, 4));
    TestUtils.assertEquals(tmpOriginal, tmpReconstructed, new NumberContext(7, 6));
}
Also used : NumberContext(org.ojalgo.type.context.NumberContext) ComplexNumber(org.ojalgo.scalar.ComplexNumber) Test(org.junit.jupiter.api.Test)

Example 82 with NumberContext

use of org.ojalgo.type.context.NumberContext in project ojAlgo by optimatika.

the class LargerCholeskyCase method setUp.

@BeforeEach
@Override
public void setUp() {
    DEFINITION = new NumberContext(7, 4);
    EVALUATION = new NumberContext(7, 3);
    myBigAB = LargerCholeskyCase.getOriginal();
    final Cholesky<BigDecimal> tmpCholesky = Cholesky.BIG.make();
    tmpCholesky.decompose(BigDenseStore.FACTORY.copy(myBigAB));
    myBigAA = RationalMatrix.FACTORY.copy(tmpCholesky.getL());
    myBigAX = myBigAA.transpose();
    myBigI = BasicMatrixTest.getIdentity(myBigAA.countRows(), myBigAA.countColumns(), DEFINITION);
    myBigSafe = BasicMatrixTest.getSafe(myBigAA.countRows(), myBigAA.countColumns(), DEFINITION);
    super.setUp();
}
Also used : NumberContext(org.ojalgo.type.context.NumberContext) BigDecimal(java.math.BigDecimal) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 83 with NumberContext

use of org.ojalgo.type.context.NumberContext in project ojAlgo by optimatika.

the class P20030422Case method setUp.

@BeforeEach
@Override
public void setUp() {
    DEFINITION = new NumberContext(7, 6);
    EVALUATION = new NumberContext(7, 3);
    myBigAA = P20030422Case.getProblematic();
    myBigAX = BasicMatrixTest.getIdentity(myBigAA.countColumns(), myBigAA.countColumns(), DEFINITION);
    myBigAB = myBigAA;
    myBigI = BasicMatrixTest.getIdentity(myBigAA.countRows(), myBigAA.countColumns(), DEFINITION);
    myBigSafe = BasicMatrixTest.getSafe(myBigAA.countRows(), myBigAA.countColumns(), DEFINITION);
    super.setUp();
}
Also used : NumberContext(org.ojalgo.type.context.NumberContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 84 with NumberContext

use of org.ojalgo.type.context.NumberContext in project ojAlgo by optimatika.

the class P20061119Case method setUp.

@Override
@BeforeEach
public void setUp() {
    DEFINITION = new NumberContext(7, 2);
    EVALUATION = NumberContext.getGeneral(8).newPrecision(14);
    myBigAA = P20061119Case.getProblematic();
    myBigAX = BasicMatrixTest.getIdentity(myBigAA.countColumns(), myBigAA.countColumns(), DEFINITION);
    myBigAB = myBigAA;
    myBigI = BasicMatrixTest.getIdentity(myBigAA.countRows(), myBigAA.countColumns(), DEFINITION);
    myBigSafe = BasicMatrixTest.getSafe(myBigAA.countRows(), myBigAA.countColumns(), DEFINITION);
    super.setUp();
}
Also used : NumberContext(org.ojalgo.type.context.NumberContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 85 with NumberContext

use of org.ojalgo.type.context.NumberContext in project ojAlgo by optimatika.

the class StandardType method wholePercentage.

public static NumberContext wholePercentage() {
    final NumberContext retVal = NumberContext.getPercent(2, Locale.getDefault());
    retVal.format(0.01);
    return retVal;
}
Also used : NumberContext(org.ojalgo.type.context.NumberContext)

Aggregations

NumberContext (org.ojalgo.type.context.NumberContext)91 Test (org.junit.jupiter.api.Test)63 ComplexNumber (org.ojalgo.scalar.ComplexNumber)16 PrimitiveDenseStore (org.ojalgo.matrix.store.PrimitiveDenseStore)15 BigDecimal (java.math.BigDecimal)14 BasicMatrix (org.ojalgo.matrix.BasicMatrix)13 BeforeEach (org.junit.jupiter.api.BeforeEach)12 Result (org.ojalgo.optimisation.Optimisation.Result)12 ExpressionsBasedModel (org.ojalgo.optimisation.ExpressionsBasedModel)9 Expression (org.ojalgo.optimisation.Expression)8 Variable (org.ojalgo.optimisation.Variable)8 PrimitiveMatrix (org.ojalgo.matrix.PrimitiveMatrix)6 Optimisation (org.ojalgo.optimisation.Optimisation)6 Uniform (org.ojalgo.random.Uniform)4 BigArray (org.ojalgo.array.BigArray)3 SimultaneousPrimitive (org.ojalgo.matrix.decomposition.HermitianEvD.SimultaneousPrimitive)3 MatrixStore (org.ojalgo.matrix.store.MatrixStore)3 Tag (org.junit.jupiter.api.Tag)2 RationalMatrix (org.ojalgo.matrix.RationalMatrix)2 Solver (org.ojalgo.matrix.decomposition.MatrixDecomposition.Solver)2