zspcon function

void zspcon(
  1. String UPLO,
  2. int N,
  3. Array<Complex> AP_,
  4. Array<int> IPIV_,
  5. double ANORM,
  6. Box<double> RCOND,
  7. Array<Complex> WORK_,
  8. Box<int> INFO,
)

Implementation

void zspcon(
  final String UPLO,
  final int N,
  final Array<Complex> AP_,
  final Array<int> IPIV_,
  final double ANORM,
  final Box<double> RCOND,
  final Array<Complex> WORK_,
  final Box<int> INFO,
) {
  final AP = AP_.having();
  final IPIV = IPIV_.having();
  final WORK = WORK_.having();
  const ONE = 1.0, ZERO = 0.0;
  bool UPPER;
  int I, IP;
  final ISAVE = Array<int>(3);
  final KASE = Box(0);
  final AINVNM = Box(0.0);

  // Test the input parameters.

  INFO.value = 0;
  UPPER = lsame(UPLO, 'U');
  if (!UPPER && !lsame(UPLO, 'L')) {
    INFO.value = -1;
  } else if (N < 0) {
    INFO.value = -2;
  } else if (ANORM < ZERO) {
    INFO.value = -5;
  }
  if (INFO.value != 0) {
    xerbla('ZSPCON', -INFO.value);
    return;
  }

  // Quick return if possible

  RCOND.value = ZERO;
  if (N == 0) {
    RCOND.value = ONE;
    return;
  } else if (ANORM <= ZERO) {
    return;
  }

  // Check that the diagonal matrix D is nonsingular.

  if (UPPER) {
    // Upper triangular storage: examine D from bottom to top

    IP = N * (N + 1) ~/ 2;
    for (I = N; I >= 1; I--) {
      if (IPIV[I] > 0 && AP[IP] == Complex.zero) return;
      IP -= I;
    }
  } else {
    // Lower triangular storage: examine D from top to bottom.

    IP = 1;
    for (I = 1; I <= N; I++) {
      if (IPIV[I] > 0 && AP[IP] == Complex.zero) return;
      IP += N - I + 1;
    }
  }

  // Estimate the 1-norm of the inverse.

  KASE.value = 0;
  while (true) {
    zlacn2(N, WORK(N + 1), WORK, AINVNM, KASE, ISAVE);
    if (KASE.value == 0) break;

    // Multiply by inv(L*D*L**T) or inv(U*D*U**T).

    zsptrs(UPLO, N, 1, AP, IPIV, WORK.asMatrix(), N, INFO);
  }

  // Compute the estimate of the reciprocal condition number.

  if (AINVNM.value != ZERO) RCOND.value = (ONE / AINVNM.value) / ANORM;
}