Search in sources :

Example 11 with PrimitiveDenseStore

use of org.ojalgo.matrix.store.PrimitiveDenseStore in project ojAlgo by optimatika.

the class Quaternion method toMultiplicationMatrix.

public MatrixStore<Double> toMultiplicationMatrix() {
    final PrimitiveDenseStore retVal = PrimitiveDenseStore.FACTORY.makeZero(this);
    this.supplyTo(retVal);
    return retVal;
}
Also used : PrimitiveDenseStore(org.ojalgo.matrix.store.PrimitiveDenseStore)

Example 12 with PrimitiveDenseStore

use of org.ojalgo.matrix.store.PrimitiveDenseStore in project ojAlgo by optimatika.

the class Expression method getAdjustedGradient.

public MatrixStore<Double> getAdjustedGradient(final Access1D<?> point) {
    final PrimitiveDenseStore retVal = PrimitiveDenseStore.FACTORY.makeZero(myModel.countVariables(), 1);
    final BinaryFunction<Double> tmpBaseFunc = PrimitiveFunction.ADD;
    double tmpAdjustedFactor;
    UnaryFunction<Double> tmpModFunc;
    for (final IntRowColumn tmpKey : this.getQuadraticKeySet()) {
        tmpAdjustedFactor = this.getAdjustedQuadraticFactor(tmpKey);
        tmpModFunc = tmpBaseFunc.second(tmpAdjustedFactor * point.doubleValue(tmpKey.column));
        retVal.modifyOne(tmpKey.row, 0, tmpModFunc);
        tmpModFunc = tmpBaseFunc.second(tmpAdjustedFactor * point.doubleValue(tmpKey.row));
        retVal.modifyOne(tmpKey.column, 0, tmpModFunc);
    }
    for (final IntIndex tmpKey : this.getLinearKeySet()) {
        tmpAdjustedFactor = this.getAdjustedLinearFactor(tmpKey);
        tmpModFunc = tmpBaseFunc.second(tmpAdjustedFactor);
        retVal.modifyOne(tmpKey.index, 0, tmpModFunc);
    }
    return retVal;
}
Also used : IntRowColumn(org.ojalgo.access.Structure2D.IntRowColumn) IntIndex(org.ojalgo.access.Structure1D.IntIndex) PrimitiveDenseStore(org.ojalgo.matrix.store.PrimitiveDenseStore)

Example 13 with PrimitiveDenseStore

use of org.ojalgo.matrix.store.PrimitiveDenseStore in project ojAlgo by optimatika.

the class GaussianField method getC11.

MatrixStore<Double> getC11(final K[] args) {
    final int tmpLength = args.length;
    final PrimitiveDenseStore retVal = FACTORY.makeZero(tmpLength, tmpLength);
    for (int j = 0; j < tmpLength; j++) {
        for (int i = 0; i < tmpLength; i++) {
            retVal.set(i, j, myCovarianceFunction.invoke(args[i], args[j]));
        }
    }
    return retVal;
}
Also used : PrimitiveDenseStore(org.ojalgo.matrix.store.PrimitiveDenseStore)

Example 14 with PrimitiveDenseStore

use of org.ojalgo.matrix.store.PrimitiveDenseStore in project ojAlgo by optimatika.

the class GaussianField method getC12.

MatrixStore<Double> getC12(final K[] args) {
    final List<ComparableToDouble<K>> tmpObservations = this.getObservations();
    final int tmpRowDim = args.length;
    final int tmpColDim = tmpObservations.size();
    final PrimitiveDenseStore retVal = FACTORY.makeZero(tmpRowDim, tmpColDim);
    for (int j = 0; j < tmpColDim; j++) {
        for (int i = 0; i < tmpRowDim; i++) {
            retVal.set(i, j, myCovarianceFunction.invoke(args[i], tmpObservations.get(j).key));
        }
    }
    return retVal;
}
Also used : ComparableToDouble(org.ojalgo.type.keyvalue.ComparableToDouble) PrimitiveDenseStore(org.ojalgo.matrix.store.PrimitiveDenseStore)

Example 15 with PrimitiveDenseStore

use of org.ojalgo.matrix.store.PrimitiveDenseStore in project ojAlgo by optimatika.

the class GaussianField method getC22.

MatrixDecomposition.Solver<Double> getC22() {
    final List<ComparableToDouble<K>> tmpObservations = this.getObservations();
    final int tmpSize = tmpObservations.size();
    final PrimitiveDenseStore tmpMatrix = FACTORY.makeZero(tmpSize, tmpSize);
    for (int j = 0; j < tmpSize; j++) {
        final K tmpColumnKey = tmpObservations.get(j).key;
        for (int i = 0; i < tmpSize; i++) {
            tmpMatrix.set(i, j, myCovarianceFunction.invoke(tmpObservations.get(i).key, tmpColumnKey));
        }
    }
    final SingularValue<Double> retVal = SingularValue.PRIMITIVE.make();
    retVal.decompose(tmpMatrix);
    return retVal;
}
Also used : ComparableToDouble(org.ojalgo.type.keyvalue.ComparableToDouble) ComparableToDouble(org.ojalgo.type.keyvalue.ComparableToDouble) PrimitiveDenseStore(org.ojalgo.matrix.store.PrimitiveDenseStore)

Aggregations

PrimitiveDenseStore (org.ojalgo.matrix.store.PrimitiveDenseStore)72 Test (org.junit.jupiter.api.Test)37 Optimisation (org.ojalgo.optimisation.Optimisation)16 NumberContext (org.ojalgo.type.context.NumberContext)15 ExpressionsBasedModel (org.ojalgo.optimisation.ExpressionsBasedModel)12 ComparableToDouble (org.ojalgo.type.keyvalue.ComparableToDouble)7 Result (org.ojalgo.optimisation.Optimisation.Result)6 ComplexNumber (org.ojalgo.scalar.ComplexNumber)4 SimultaneousPrimitive (org.ojalgo.matrix.decomposition.HermitianEvD.SimultaneousPrimitive)3 PhysicalStore (org.ojalgo.matrix.store.PhysicalStore)3 Builder (org.ojalgo.optimisation.convex.ConvexSolver.Builder)3 IntRowColumn (org.ojalgo.access.Structure2D.IntRowColumn)2 ComplexDenseStore (org.ojalgo.matrix.store.ComplexDenseStore)2 LinearSolver (org.ojalgo.optimisation.linear.LinearSolver)2 Normal (org.ojalgo.random.Normal)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Disabled (org.junit.jupiter.api.Disabled)1 Tag (org.junit.jupiter.api.Tag)1 ProgrammingError (org.ojalgo.ProgrammingError)1