Calling transposeToRef with the matrix itself as argument will lead to incorrect behavior, as you’re storing the transposed values on the same matrix you’re transposing. The expected use is to call transposeToRef with a different matrix, I just created one here and they have the same result: matrix transpose self | Babylon.js Playground (babylonjs.com)
It’s a waste of memory creating Matrix forced by the internal impl of transposeToRef. And there is nothing in the docs saying that it’s forbidden to apply transposeToRef on the matrix itself.
If it is not accepted to fix this in transposeToRef, a transposeInplace method could be added as an alternative, with docs about how to choose which one to use.