Search in sources :

Example 46 with ComplexNumber

use of org.ojalgo.scalar.ComplexNumber in project ojAlgo by optimatika.

the class ComplexPolynomial method invoke.

public ComplexNumber invoke(final ComplexNumber arg) {
    int tmpPower = this.degree();
    ComplexNumber retVal = this.get(tmpPower);
    while (--tmpPower >= 0) {
        retVal = this.get(tmpPower).add(arg.multiply(retVal));
    }
    return retVal;
}
Also used : ComplexNumber(org.ojalgo.scalar.ComplexNumber)

Example 47 with ComplexNumber

use of org.ojalgo.scalar.ComplexNumber in project ojAlgo by optimatika.

the class ComplexPolynomial method estimate.

public void estimate(final Access1D<?> x, final Access1D<?> y) {
    final int tmpRowDim = (int) Math.min(x.count(), y.count());
    final int tmpColDim = this.size();
    final PhysicalStore<ComplexNumber> tmpBody = GenericDenseStore.COMPLEX.makeZero(tmpRowDim, tmpColDim);
    final PhysicalStore<ComplexNumber> tmpRHS = GenericDenseStore.COMPLEX.makeZero(tmpRowDim, 1);
    for (int i = 0; i < tmpRowDim; i++) {
        ComplexNumber tmpX = ComplexNumber.ONE;
        final ComplexNumber tmpXfactor = ComplexNumber.valueOf(x.get(i));
        final ComplexNumber tmpY = ComplexNumber.valueOf(y.get(i));
        for (int j = 0; j < tmpColDim; j++) {
            tmpBody.set(i, j, tmpX);
            tmpX = tmpX.multiply(tmpXfactor);
        }
        tmpRHS.set(i, 0, tmpY);
    }
    final QR<ComplexNumber> tmpQR = QR.COMPLEX.make();
    tmpQR.decompose(tmpBody);
    this.set(tmpQR.getSolution(tmpRHS));
}
Also used : ComplexNumber(org.ojalgo.scalar.ComplexNumber)

Example 48 with ComplexNumber

use of org.ojalgo.scalar.ComplexNumber in project ojAlgo by optimatika.

the class ComplexPolynomial method integrate.

public ComplexNumber integrate(final ComplexNumber fromPoint, final ComplexNumber toPoint) {
    final PolynomialFunction<ComplexNumber> tmpPrim = this.buildPrimitive();
    final ComplexNumber tmpFromVal = tmpPrim.invoke(fromPoint);
    final ComplexNumber tmpToVal = tmpPrim.invoke(toPoint);
    return tmpToVal.subtract(tmpFromVal);
}
Also used : ComplexNumber(org.ojalgo.scalar.ComplexNumber)

Example 49 with ComplexNumber

use of org.ojalgo.scalar.ComplexNumber in project ojAlgo by optimatika.

the class MatrixUtils method copyComplexModulusAndArgument.

/**
 * Simultaneously copies the modulus and argument of the ComplexNumber elements to the destinations.
 */
public static void copyComplexModulusAndArgument(final Access2D<ComplexNumber> source, final ElementsConsumer<?> modDest, final ElementsConsumer<?> argDest) {
    final long tmpCount = FunctionUtils.min(source.count(), modDest.count(), argDest.count());
    ComplexNumber tmpComplexNumber;
    for (long i = 0L; i < tmpCount; i++) {
        tmpComplexNumber = source.get(i);
        modDest.set(i, tmpComplexNumber.getModulus());
        argDest.set(i, tmpComplexNumber.getArgument());
    }
}
Also used : ComplexNumber(org.ojalgo.scalar.ComplexNumber)

Example 50 with ComplexNumber

use of org.ojalgo.scalar.ComplexNumber in project ojAlgo by optimatika.

the class MatrixUtils method isHermitian.

public static boolean isHermitian(final Access2D<?> matrix) {
    final long tmpRowDim = matrix.countRows();
    final long tmpColDim = matrix.countColumns();
    final Number tmpElement = matrix.get(0L);
    boolean retVal = tmpRowDim == tmpColDim;
    if (tmpElement instanceof ComplexNumber) {
        ComplexNumber tmpLowerLeft;
        ComplexNumber tmpUpperRight;
        for (int j = 0; retVal && (j < tmpColDim); j++) {
            retVal &= PrimitiveScalar.isSmall(PrimitiveMath.ONE, ComplexNumber.valueOf(matrix.get(j, j)).i);
            for (int i = j + 1; retVal && (i < tmpRowDim); i++) {
                tmpLowerLeft = ComplexNumber.valueOf(matrix.get(i, j)).conjugate();
                tmpUpperRight = ComplexNumber.valueOf(matrix.get(j, i));
                retVal &= PrimitiveScalar.isSmall(PrimitiveMath.ONE, tmpLowerLeft.subtract(tmpUpperRight).norm());
            }
        }
    } else {
        for (int j = 0; retVal && (j < tmpColDim); j++) {
            for (int i = j + 1; retVal && (i < tmpRowDim); i++) {
                retVal &= PrimitiveScalar.isSmall(PrimitiveMath.ONE, matrix.doubleValue(i, j) - matrix.doubleValue(j, i));
            }
        }
    }
    return retVal;
}
Also used : ComplexNumber(org.ojalgo.scalar.ComplexNumber) ComplexNumber(org.ojalgo.scalar.ComplexNumber)

Aggregations

ComplexNumber (org.ojalgo.scalar.ComplexNumber)53 Test (org.junit.jupiter.api.Test)20 NumberContext (org.ojalgo.type.context.NumberContext)16 DivideAndConquer (org.ojalgo.concurrent.DivideAndConquer)7 ComplexArray (org.ojalgo.array.ComplexArray)5 BigDecimal (java.math.BigDecimal)4 PrimitiveDenseStore (org.ojalgo.matrix.store.PrimitiveDenseStore)4 BasicMatrix (org.ojalgo.matrix.BasicMatrix)3 Householder (org.ojalgo.matrix.transformation.Householder)3 Tag (org.junit.jupiter.api.Tag)2 RationalMatrix (org.ojalgo.matrix.RationalMatrix)2 Solver (org.ojalgo.matrix.decomposition.MatrixDecomposition.Solver)2 ComplexDenseStore (org.ojalgo.matrix.store.ComplexDenseStore)2 Normal (org.ojalgo.random.Normal)2 Quaternion (org.ojalgo.scalar.Quaternion)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Uniform (org.ojalgo.random.Uniform)1