// check diagonal element
int ir = index[rank];
if (c[ir][ir] < small) {
if (rank == 0) {
throw new NotPositiveDefiniteMatrixException();
}
// check remaining diagonal elements
for (int i = rank; i < order; ++i) {
if (c[index[i]][index[i]] < -small) {
// there is at least one sufficiently negative diagonal element,
// the covariance matrix is wrong
throw new NotPositiveDefiniteMatrixException();
}
}
// all remaining diagonal elements are close to zero,
// we consider we have found the rank of the covariance matrix