use of org.ojalgo.concurrent.DivideAndConquer in project ojAlgo by optimatika.
the class HouseholderHermitian method invoke.
public static void invoke(final ComplexNumber[] data, final Householder.Complex householder, final ComplexNumber[] worker) {
final ComplexNumber[] tmpVector = householder.vector;
final int tmpFirst = householder.first;
final int tmpLength = tmpVector.length;
final ComplexNumber tmpBeta = householder.beta;
final int tmpCount = tmpLength - tmpFirst;
if (tmpCount > MultiplyHermitianAndVector.THRESHOLD) {
final DivideAndConquer tmpConqurer = new DivideAndConquer() {
@Override
protected void conquer(final int first, final int limit) {
MultiplyHermitianAndVector.invoke(worker, first, limit, data, tmpVector, tmpFirst, ComplexNumber.FACTORY);
}
};
tmpConqurer.invoke(tmpFirst, tmpLength, MultiplyHermitianAndVector.THRESHOLD);
} else {
MultiplyHermitianAndVector.invoke(worker, tmpFirst, tmpLength, data, tmpVector, tmpFirst, ComplexNumber.FACTORY);
}
ComplexNumber tmpVal = ComplexNumber.ZERO;
for (int c = tmpFirst; c < tmpLength; c++) {
// tmpVal += tmpVector[c] * worker[c];
tmpVal = tmpVal.add(tmpVector[c].conjugate().multiply(worker[c]));
}
// tmpVal *= (tmpBeta / TWO);
tmpVal = ComplexFunction.DIVIDE.invoke(tmpVal.multiply(tmpBeta), ComplexNumber.TWO);
for (int c = tmpFirst; c < tmpLength; c++) {
// worker[c] = tmpBeta * (worker[c] - (tmpVal * tmpVector[c]));
worker[c] = tmpBeta.multiply(worker[c].subtract(tmpVal.multiply(tmpVector[c])));
}
if (tmpCount > HermitianRank2Update.THRESHOLD) {
final DivideAndConquer tmpConqurer = new DivideAndConquer() {
@Override
protected void conquer(final int first, final int limit) {
HermitianRank2Update.invoke(data, first, limit, tmpVector, worker);
}
};
tmpConqurer.invoke(tmpFirst, tmpLength, HermitianRank2Update.THRESHOLD);
} else {
HermitianRank2Update.invoke(data, tmpFirst, tmpLength, tmpVector, worker);
}
}
Aggregations