public Solver getSolver(RealMatrix M) {
if (M == null) {
return null;
}
RRQRDecomposition decomposition = new RRQRDecomposition(M, SINGULARITY_THRESHOLD);
DecompositionSolver solver = decomposition.getSolver();
if (solver.isNonSingular()) {
return new Solver(solver);
}
// Otherwise try to report apparent rank
int apparentRank = decomposition.getRank(0.01); // Better value?
log.warn("{} x {} matrix is near-singular (threshold {}). Add more data or decrease the " +
"value of als.hyperparams.features, to <= about {}",
M.getRowDimension(),
M.getColumnDimension(),
SINGULARITY_THRESHOLD,