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;
}
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));
}
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);
}
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());
}
}
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;
}
Aggregations