How to use matrices in C++

Please, is there a way to easily define matrices and perform matrix of any size operations in C++? I can’t find any way to do so: seems like FMatrix is only 4x4, seems like TMatrix does not have any operator for operations… While searching for a solution I found class named Matrix33 in “ThirdParty/openexr/Deploy/include/ImathMatrix.h” that seems to fit the purpose (at least for 3x3 matrices) but I can’t find a way to use it in my code
I’m desperate… Please help… :’(


No easy way, though matrix seems very intuitive and simple for a client they are devious,crooked for a programmer.

They hide insidious issues… Sorry,didn’t meant to scare you, but pay attention.
The can lead to memory/CPU leak, wrong behaviour…

That said, you can overload operators to add matrix operations.

Or you can make your own matrix type… I suggest to make a one dimensional array and add logic to mimic matrix behaviour… For example… If you want a 5x5 make an array of 25 and use X+Yx5 formula to access elements

I didn’t know matrices were such an issue, I guess I have no choice then ^^
Thank you for your answer and your suggestion :slight_smile:

What are you trying to accomplish? What matrix operations do you need? There’s no need to be scared of matrices.

I needed matrices for basic operations like matrice multiplication, transposition and inversion. I tried to build matrices with arrays as suggested above but I wasn’t very comfortable with arrays (still a beginner) so I ended up using the Eigen library alongside with Unreal Engine. I don’t know if it will cause any issue but it worked fine so far.
Thank you for your answer ^^