use of org.ojalgo.scalar.ComplexNumber in project ojAlgo by optimatika.
the class ComplexDenseStore method aggregateAll.
public ComplexNumber aggregateAll(final Aggregator aggregator) {
final int tmpRowDim = myRowDim;
final int tmpColDim = myColDim;
final AggregatorFunction<ComplexNumber> tmpMainAggr = aggregator.getFunction(ComplexAggregator.getSet());
if (tmpColDim > AggregateAll.THRESHOLD) {
final DivideAndConquer tmpConquerer = new DivideAndConquer() {
@Override
public void conquer(final int aFirst, final int aLimit) {
final AggregatorFunction<ComplexNumber> tmpPartAggr = aggregator.getFunction(ComplexAggregator.getSet());
ComplexDenseStore.this.visit(tmpRowDim * aFirst, tmpRowDim * aLimit, 1, tmpPartAggr);
synchronized (tmpMainAggr) {
tmpMainAggr.merge(tmpPartAggr.get());
}
}
};
tmpConquerer.invoke(0, tmpColDim, AggregateAll.THRESHOLD);
} else {
ComplexDenseStore.this.visit(0, this.size(), 1, tmpMainAggr);
}
return tmpMainAggr.get();
}
use of org.ojalgo.scalar.ComplexNumber in project ojAlgo by optimatika.
the class ComplexDenseStore method applyLU.
public void applyLU(final int iterationPoint, final BasicArray<ComplexNumber> multipliers) {
final ComplexNumber[] tmpData = data;
final ComplexNumber[] tmpColumn = ((ComplexArray) multipliers).data;
if ((myColDim - iterationPoint - 1) > ApplyLU.THRESHOLD) {
final DivideAndConquer tmpConquerer = new DivideAndConquer() {
@Override
protected void conquer(final int aFirst, final int aLimit) {
ApplyLU.invoke(tmpData, myRowDim, aFirst, aLimit, tmpColumn, iterationPoint);
}
};
tmpConquerer.invoke(iterationPoint + 1, myColDim, ApplyLU.THRESHOLD);
} else {
ApplyLU.invoke(tmpData, myRowDim, iterationPoint + 1, myColDim, tmpColumn, iterationPoint);
}
}
use of org.ojalgo.scalar.ComplexNumber in project ojAlgo by optimatika.
the class GenerateApplyAndCopyHouseholderRow method invoke.
public static boolean invoke(final ComplexNumber[] data, final int structure, final int row, final int col, final Householder.Complex destination) {
final int tmpColDim = data.length / structure;
final ComplexNumber[] tmpVector = destination.vector;
destination.first = col;
double tmpNormInf = PrimitiveMath.ZERO;
for (int j = col; j < tmpColDim; j++) {
tmpNormInf = PrimitiveFunction.MAX.invoke(tmpNormInf, (tmpVector[j] = data[row + (j * structure)]).norm());
}
boolean retVal = tmpNormInf != PrimitiveMath.ZERO;
ComplexNumber tmpVal;
double tmpNorm2 = PrimitiveMath.ZERO;
if (retVal) {
for (int j = col + 1; j < tmpColDim; j++) {
tmpVal = tmpVector[j].divide(tmpNormInf);
tmpNorm2 += tmpVal.norm() * tmpVal.norm();
tmpVector[j] = tmpVal;
}
final double value = tmpNorm2;
retVal = !PrimitiveScalar.isSmall(PrimitiveMath.ONE, value);
}
if (retVal) {
ComplexNumber tmpScale = tmpVector[col].divide(tmpNormInf);
tmpNorm2 += tmpScale.norm() * tmpScale.norm();
tmpNorm2 = PrimitiveFunction.SQRT.invoke(tmpNorm2);
data[(row + (col * structure))] = ComplexNumber.makePolar(tmpNorm2 * tmpNormInf, tmpScale.phase());
tmpScale = tmpScale.subtract(ComplexNumber.makePolar(tmpNorm2, tmpScale.phase()));
tmpVector[col] = ComplexNumber.ONE;
for (int j = col + 1; j < tmpColDim; j++) {
data[row + (j * structure)] = tmpVector[j] = ComplexFunction.DIVIDE.invoke(tmpVector[j], tmpScale).conjugate();
}
destination.beta = ComplexNumber.valueOf(tmpScale.norm() / tmpNorm2);
}
return retVal;
}
use of org.ojalgo.scalar.ComplexNumber in project ojAlgo by optimatika.
the class HouseholderLeft method invoke.
public static void invoke(final ComplexNumber[] data, final int structure, final int first, final int limit, final Householder.Complex householder) {
final ComplexNumber[] tmpHouseholderVector = householder.vector;
final int tmpFirstNonZero = householder.first;
final ComplexNumber tmpBeta = householder.beta;
ComplexNumber tmpScale;
int tmpIndex;
for (int j = first; j < limit; j++) {
tmpScale = ComplexNumber.ZERO;
tmpIndex = tmpFirstNonZero + (j * structure);
for (int i = tmpFirstNonZero; i < structure; i++) {
tmpScale = tmpScale.add(tmpHouseholderVector[i].conjugate().multiply(data[tmpIndex++]));
}
tmpScale = tmpScale.multiply(tmpBeta);
tmpIndex = tmpFirstNonZero + (j * structure);
for (int i = tmpFirstNonZero; i < structure; i++) {
data[tmpIndex] = data[tmpIndex].subtract(tmpScale.multiply(tmpHouseholderVector[i]));
tmpIndex++;
}
}
}
use of org.ojalgo.scalar.ComplexNumber in project ojAlgo by optimatika.
the class HouseholderRight method invoke.
public static void invoke(final ComplexNumber[] data, final int first, final int limit, final int tmpColDim, final Householder.Complex householder) {
final ComplexNumber[] tmpHouseholderVector = householder.vector;
final int tmpFirstNonZero = householder.first;
final ComplexNumber tmpBeta = householder.beta;
final int tmpRowDim = data.length / tmpColDim;
ComplexNumber tmpScale;
int tmpIndex;
for (int i = first; i < limit; i++) {
tmpScale = ComplexNumber.ZERO;
tmpIndex = i + (tmpFirstNonZero * tmpRowDim);
for (int j = tmpFirstNonZero; j < tmpColDim; j++) {
tmpScale = tmpScale.add(tmpHouseholderVector[j].conjugate().multiply(data[tmpIndex].conjugate()));
tmpIndex += tmpRowDim;
}
tmpScale = tmpScale.multiply(tmpBeta);
tmpIndex = i + (tmpFirstNonZero * tmpRowDim);
for (int j = tmpFirstNonZero; j < tmpColDim; j++) {
data[tmpIndex] = data[tmpIndex].conjugate().subtract(tmpScale.multiply(tmpHouseholderVector[j])).conjugate();
tmpIndex += tmpRowDim;
}
}
}
Aggregations