Sorry, Gilles, I was not clear enough. What I agreeing with was the proposal to add an inverse(RealMatrix) method to MatrixUtils that would handle any RealMatrix, throwing only if the matrix is singular or non-square. This method would essentially replace what used to be in RealMatrix itself, but which users now have to get a decomposition solver to do, or use the block matrix version you reference. It would include a default solver-based implementation (which one?), but first check if the matrix is diagonal (using instanceOf) and if so, inline or delegate to the impl for diagonal matrices.

I agree with you that we should not clutter the Utils classes, which is why I was ambivalent on exposing the DiagonalMatrix version itself. I think it is a good idea though to make a general inverse method available so people just wanting an inverse don't have to search around to figure out the decomp solver API. I know the blockInverse method is already there; but it is really a specialized implementation and requires an additional parameter, so I would be +1 to add a simple, general-purpose method.

Patch welcome.

Please note that there exists an extensive issue report about refactoring the CM matrix (and "vector") API.