Efficient algorithm for the numerical estimation of the 3D rotation matrix.

I am writing a program related to computer vision and I am stuck in a problem. I have a system of quadratic equations.



where M is a constant matrix of 3×3 and unity It's the 3×3 identity matrix.

The first set of equations contains 6 independent equations that leave us with 3 degrees of freedom from the SO (3) group. The second set of 3 equations only states that the matrix sim it's symmetrical

Since this program will repeatedly solve these equations, I am looking for an efficient algorithm and / or a C / C ++ implementation that can run on Raspberry Pi, that is, not on monsters like Matlab, Mathematica or root.