public static void invoke(
      final ComplexNumber[] aData,
      final Householder.Complex aHouseholder,
      final ComplexNumber[] aWorker) {

    final ComplexNumber[] tmpVector = aHouseholder.vector;
    final int tmpFirst = aHouseholder.first;
    final int tmpLength = tmpVector.length;
    final ComplexNumber tmpBeta = aHouseholder.beta;
    final int tmpCount = tmpLength - tmpFirst;

    if (tmpCount > THRESHOLD) {

      final DivideAndConquer tmpConqurer =
          new DivideAndConquer() {

            @Override
            protected void conquer(final int aFirst, final int aLimit) {
              MultiplyHermitianAndVector.invoke(
                  aWorker, aFirst, aLimit, aData, tmpVector, tmpFirst);
            }
          };

      tmpConqurer.invoke(tmpFirst, tmpLength, THRESHOLD);

    } else {

      MultiplyHermitianAndVector.invoke(aWorker, tmpFirst, tmpLength, aData, tmpVector, tmpFirst);
    }

    ComplexNumber tmpVal = ComplexNumber.ZERO;
    for (int c = tmpFirst; c < tmpLength; c++) {
      // tmpVal += tmpVector[c] * aWorker[c];
      tmpVal = tmpVal.add(tmpVector[c].conjugate().multiply(aWorker[c]));
    }
    // tmpVal *= (tmpBeta / TWO);
    tmpVal = ComplexFunction.DIVIDE.invoke(tmpVal.multiply(tmpBeta), ComplexNumber.TWO);
    for (int c = tmpFirst; c < tmpLength; c++) {
      // aWorker[c] = tmpBeta * (aWorker[c] - (tmpVal * tmpVector[c]));
      aWorker[c] = tmpBeta.multiply(aWorker[c].subtract(tmpVal.multiply(tmpVector[c])));
    }

    if (tmpCount > THRESHOLD) {

      final DivideAndConquer tmpConqurer =
          new DivideAndConquer() {

            @Override
            protected void conquer(final int aFirst, final int aLimit) {
              HermitianRank2Update.invoke(aData, aFirst, aLimit, tmpVector, aWorker);
            }
          };

      tmpConqurer.invoke(tmpFirst, tmpLength, THRESHOLD);

    } else {

      HermitianRank2Update.invoke(aData, tmpFirst, tmpLength, tmpVector, aWorker);
    }
  }
Example #2
0
  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 =
        ComplexDenseStore.FACTORY.makeZero(tmpRowDim, tmpColDim);
    final PhysicalStore<ComplexNumber> tmpRHS = ComplexDenseStore.FACTORY.makeZero(tmpRowDim, 1);

    for (int i = 0; i < tmpRowDim; i++) {

      ComplexNumber tmpX = ComplexNumber.ONE;
      final ComplexNumber tmpXfactor = ComplexNumber.valueOf((Number) x.get(i));
      final ComplexNumber tmpY = ComplexNumber.valueOf((Number) 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.makeComplex();
    tmpQR.decompose(tmpBody);
    this.set(tmpQR.solve(tmpRHS));
  }
Example #3
0
  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;
  }
Example #4
0
    @Override
    protected Rotation<ComplexNumber>[] rotations(
        final PhysicalStore<ComplexNumber> aStore,
        final int aLowInd,
        final int aHighInd,
        final Rotation<ComplexNumber>[] retVal) {

      final ComplexNumber a00 = aStore.get(aLowInd, aLowInd);
      final ComplexNumber a01 = aStore.get(aLowInd, aHighInd);
      final ComplexNumber a10 = aStore.get(aHighInd, aLowInd);
      final ComplexNumber a11 = aStore.get(aHighInd, aHighInd);

      final ComplexNumber x = a00.add(a11);
      final ComplexNumber y = a10.subtract(a01);

      ComplexNumber t; // tan, cot or something temporary

      // Symmetrise - Givens
      final ComplexNumber cg; // cos Givens
      final ComplexNumber sg; // sin Givens

      if (ComplexNumber.isSmall(PrimitiveMath.ONE, y)) {
        cg = x.signum();
        sg = ComplexNumber.ZERO;
      } else if (ComplexNumber.isSmall(PrimitiveMath.ONE, x)) {
        sg = y.signum();
        cg = ComplexNumber.ZERO;
      } else if (y.compareTo(x) == 1) {
        t = x.divide(y); // cot
        sg = y.signum().divide(ComplexFunction.SQRT1PX2.invoke(t));
        cg = sg.multiply(t);
      } else {
        t = y.divide(x); // tan
        cg = x.signum().divide(ComplexFunction.SQRT1PX2.invoke(t));
        sg = cg.multiply(t);
      }

      final ComplexNumber b00 = cg.multiply(a00).add(sg.multiply(a10));
      final ComplexNumber b11 = cg.multiply(a11).subtract(sg.multiply(a01));
      final ComplexNumber b2 =
          cg.multiply(a01.add(a10)).add(sg.multiply(a11.subtract(a00))); // b01 + b10

      t = b11.subtract(b00).divide(b2);
      t = t.signum().divide(ComplexFunction.SQRT1PX2.invoke(t).add(t.norm()));

      // Annihilate - Jacobi
      final ComplexNumber cj = ComplexFunction.SQRT1PX2.invoke(t).invert(); // Cos Jacobi
      final ComplexNumber sj = cj.multiply(t); // Sin Jacobi

      retVal[1] = new Rotation.Complex(aLowInd, aHighInd, cj, sj); // Jacobi
      retVal[0] =
          new Rotation.Complex(
              aLowInd,
              aHighInd,
              cj.multiply(cg).add(sj.multiply(sg)),
              cj.multiply(sg).subtract(sj.multiply(cg))); // Givens - Jacobi

      return retVal;
    }