I'm working through an implementation of the solution from 16.3.1 Dealing with the nullspace in the case of a singular within-class scatter matrix when performing discriminant analysis. In this section it is suggested that the $M{\times}M$ singular matrix $B$, representing the within-class scatter for the $N{\times}M$ dataset $X$, can be made to be invertible by projecting it into an orthonormal basis of $X$.
So, for example, if I take the QR decomposition of $X$, find the $N{\times}M$ orthonormal basis $Q$ of $X$, and apply the suggested projection $B'=QXQ^{T}$, then I would find $B'$ is a $N{\times}N$ non-singular matrix.
In the case I've been testing, $X$ is a $50{\times}71$ matrix containing a 71-dimensional data sample per row and $B$ is the respective $71{\times}71$ within-class scatter with $rank(B)=40$. After performing the projection I found $rank(B')=40$ for the resulting $50{\times}50$ matrix. In fact the projection appears to have no effect on rank regardless of the dimensions used. So contrary to what is said in the textbook the projection of $B$ is doesn't appear to be invertible.
So now I'm left wondering: have I misunderstood what is mentioned in the text/is there something I'm not considering or doing that I should be; is what's shown in the text in fact incorrect and an alternative technique should be used; or is this purely an implementation thing (I'm writing my implementation with the Jama matrix library)? Ruling out the first two possibilities would make it easy to debug the third, so any insight would be greatly appreciated. Thanks in advance!