zhbmv function

void zhbmv(
  1. String UPLO,
  2. int N,
  3. int K,
  4. Complex ALPHA,
  5. Matrix<Complex> A_,
  6. int LDA,
  7. Array<Complex> X_,
  8. int INCX,
  9. Complex BETA,
  10. Array<Complex> Y_,
  11. int INCY,
)

Implementation

void zhbmv(
  final String UPLO,
  final int N,
  final int K,
  final Complex ALPHA,
  final Matrix<Complex> A_,
  final int LDA,
  final Array<Complex> X_,
  final int INCX,
  final Complex BETA,
  final Array<Complex> Y_,
  final int INCY,
) {
  final A = A_.having(ld: LDA);
  final X = X_.having();
  final Y = Y_.having();
  Complex TEMP1, TEMP2;
  int I, INFO, IX, IY, J, JX, JY, KPLUS1, KX, KY, L;

  // Test the input parameters.

  INFO = 0;
  if (!lsame(UPLO, 'U') && !lsame(UPLO, 'L')) {
    INFO = 1;
  } else if (N < 0) {
    INFO = 2;
  } else if (K < 0) {
    INFO = 3;
  } else if (LDA < (K + 1)) {
    INFO = 6;
  } else if (INCX == 0) {
    INFO = 8;
  } else if (INCY == 0) {
    INFO = 11;
  }
  if (INFO != 0) {
    xerbla('ZHBMV', INFO);
    return;
  }

  // Quick return if possible.

  if ((N == 0) || ((ALPHA == Complex.zero) && (BETA == Complex.one))) return;

  // Set up the start points in  X  and  Y.

  if (INCX > 0) {
    KX = 1;
  } else {
    KX = 1 - (N - 1) * INCX;
  }
  if (INCY > 0) {
    KY = 1;
  } else {
    KY = 1 - (N - 1) * INCY;
  }

  // Start the operations. In this version the elements of the array A
  // are accessed sequentially with one pass through A.

  // First form  y := beta*y.

  if (BETA != Complex.one) {
    if (INCY == 1) {
      if (BETA == Complex.zero) {
        for (I = 1; I <= N; I++) {
          Y[I] = Complex.zero;
        }
      } else {
        for (I = 1; I <= N; I++) {
          Y[I] = BETA * Y[I];
        }
      }
    } else {
      IY = KY;
      if (BETA == Complex.zero) {
        for (I = 1; I <= N; I++) {
          Y[IY] = Complex.zero;
          IY += INCY;
        }
      } else {
        for (I = 1; I <= N; I++) {
          Y[IY] = BETA * Y[IY];
          IY += INCY;
        }
      }
    }
  }
  if (ALPHA == Complex.zero) return;
  if (lsame(UPLO, 'U')) {
    // Form  y  when upper triangle of A is stored.

    KPLUS1 = K + 1;
    if ((INCX == 1) && (INCY == 1)) {
      for (J = 1; J <= N; J++) {
        TEMP1 = ALPHA * X[J];
        TEMP2 = Complex.zero;
        L = KPLUS1 - J;
        for (I = max(1, J - K); I <= J - 1; I++) {
          Y[I] += TEMP1 * A[L + I][J];
          TEMP2 += A[L + I][J].conjugate() * X[I];
        }
        Y[J] += TEMP1 * A[KPLUS1][J].real.toComplex() + ALPHA * TEMP2;
      }
    } else {
      JX = KX;
      JY = KY;
      for (J = 1; J <= N; J++) {
        TEMP1 = ALPHA * X[JX];
        TEMP2 = Complex.zero;
        IX = KX;
        IY = KY;
        L = KPLUS1 - J;
        for (I = max(1, J - K); I <= J - 1; I++) {
          Y[IY] += TEMP1 * A[L + I][J];
          TEMP2 += A[L + I][J].conjugate() * X[IX];
          IX += INCX;
          IY += INCY;
        }
        Y[JY] += TEMP1 * A[KPLUS1][J].real.toComplex() + ALPHA * TEMP2;
        JX += INCX;
        JY += INCY;
        if (J > K) {
          KX += INCX;
          KY += INCY;
        }
      }
    }
  } else {
    // Form  y  when lower triangle of A is stored.

    if ((INCX == 1) && (INCY == 1)) {
      for (J = 1; J <= N; J++) {
        TEMP1 = ALPHA * X[J];
        TEMP2 = Complex.zero;
        Y[J] += TEMP1 * A[1][J].real.toComplex();
        L = 1 - J;
        for (I = J + 1; I <= min(N, J + K); I++) {
          Y[I] += TEMP1 * A[L + I][J];
          TEMP2 += A[L + I][J].conjugate() * X[I];
        }
        Y[J] += ALPHA * TEMP2;
      }
    } else {
      JX = KX;
      JY = KY;
      for (J = 1; J <= N; J++) {
        TEMP1 = ALPHA * X[JX];
        TEMP2 = Complex.zero;
        Y[JY] += TEMP1 * A[1][J].real.toComplex();
        L = 1 - J;
        IX = JX;
        IY = JY;
        for (I = J + 1; I <= min(N, J + K); I++) {
          IX += INCX;
          IY += INCY;
          Y[IY] += TEMP1 * A[L + I][J];
          TEMP2 += A[L + I][J].conjugate() * X[IX];
        }
        Y[JY] += ALPHA * TEMP2;
        JX += INCX;
        JY += INCY;
      }
    }
  }
}