Robert, I didn't code D3D9, so I don't really know how to fix it there. The code is slightly different there.
Harri, I am displeased to hear this, that is a very very poor excuse. The code is not that hard to follow, all of the Direct3D docs are online just like GL, and the functions themselves by virtue of verbosity are self-explanatory. You know much more about matrices than I do, I've never even taken a matrix math course yet, in my life, and I managed to write the transformation code for D3D. Please make an earnest attempt to do so, I believe in you.