I have successfully computed the (device-relative earth orientation) rotation $\mathbf{R}$ from my geomagnetic vector $\mathbf{m}$ and gravity vector reading $\mathbf{g}$ as follows:
$\mathbf{R} = \begin{bmatrix} \textrm{normalize}(\mathbf{m}\times\mathbf{g})^T\\ \textrm{normalize}(\mathbf{g}\times(\mathbf{m}\times\mathbf{g}))^T\\ \textrm{normalize}(\mathbf{g})^T \end{bmatrix}$.
I also have my Latitude($\phi$), Longitude ($\lambda$), Altitude ($h$) from GPS.
I have transformed this into its absolute Cartesian form, $[x,y,z]^T$ using the equations given in this link.
But now my problem is to convert the relative rotation $\mathbf{R}$ to its absolute form $\mathbf{R}_{abs}$.
What are the equations that I have to use here?
Thanks.