iladlr function

int iladlr(
  1. int M,
  2. int N,
  3. Matrix<double> A_,
  4. int LDA,
)

Implementation

int iladlr(final int M, final int N, final Matrix<double> A_, final int LDA) {
  final A = A_.having(ld: LDA);
  const ZERO = 0.0;

  // Quick test for the common case where one corner is non-zero.
  if (M == 0) return M;

  if (A[M][1] != ZERO || A[M][N] != ZERO) {
    return M;
  }

  // Scan up each column tracking the last zero row seen.
  var result = 0;
  for (var J = 1; J <= N; J++) {
    var I = M;
    while ((A[max(I, 1)][J] == ZERO) && (I >= 1)) {
      I--;
    }
    result = max(result, I);
  }
  return result;
}