Question on Transformations: The order of matrix multiplication.

Q: Thanks alot for your reply regarding GetDefaultMatrix(). It was
very helpful, as always. I am still having a time trying to get my
head around transformations. Background on us, we are parsing PDF docs
and converting them to another format, which also uses matrix

We need to flip the y-axis, so from your response below and the
documentation I have read, I should be able to get the page default
matrix (with flip_y=true) and multiply a transformation matrix by that
to get my result. In other words, the following pseudo-code should

Matrix2D mtx = element.GetCTM();
Matrix2D flipit = pdfPage.GetDefaultMatrix(true); Matrix2D result =
mtx * flipit; //Need to implement matrix multiplication here. ie
result[x, y] = mtx row(x) * flipit column(y)

Other.Format.Matrix final = new Other.Format.Matrix(result);

Am I understanding this part correctly?
A: Actually the order of multiplication is the other way around: from
right to left. This convention follows the PostScript/PDF convention.

Matrix2D result = pdfPage.GetDefaultMatrix(true) * element.GetCTM() ;

or perhaps

Matrix2D device_mtx = ...
Matrix2D result = device_mtx * pdfPage.GetDefaultMatrix(true) *
element.GetCTM() ;

In this case the element will be first transformed using the CTM (the
Current Transformation Matrix), followed by default page matrix (which
will also invert the content on the page as well as take into account
page rotation/offset). The element will be then transformed using
device_mtx into your custom coordinate system (e.g. screen or target
format coord system).