This problem arose in my stereo vision project.
I have two matrices: $$ A = \left( \begin{array}{ccc} \text{x1}*\text{p131}-\text{p111} & \text{x1}*\text{p132}-\text{p112} & \text{x1}*\text{p133}-\text{p113} \\ \text{y1}*\text{p131}-\text{p121} & \text{y1}*\text{p132}-\text{p122} & \text{y1}*\text{p133}-\text{p123} \\ \text{x2}*\text{p231}-\text{p211} & \text{x2}*\text{p232}-\text{p212} & \text{x2}*\text{p233}-\text{p212} \\ \text{y2}*\text{p231}-\text{p221} & \text{y2}*\text{p232}-\text{p222} & \text{y2}*\text{p233}-\text{p223} \end{array} \right) $$ $$B = \left( \begin{array}{c} \text{p114}-\text{x1}*\text{p134} \\ \text{p124}-\text{y1}*\text{p134} \\ \text{p214}-\text{x2}*\text{p234} \\ \text{p224}-\text{y2}*\text{p234} \end{array} \right) $$
I computed the following vector k:
k = Simplify[Inverse[Transpose[A].A].Transpose[A].B]
And mathematica output a huge answer for k (as expected), wich I think it's not necessary for me to type it in here.
Here is where my problem starts. This computation must be done at 120 Hz, where all entries of A and B are known, but only $\text{x1,x2,y1}$ and $\text{y2}$ change from time to time (forcing me to recompute the whole transpose and inverse thing every time they change).
I would like to express the matrix k as $$k = k1*k2 $$ where $k1$ entries are functions only of the $\text{p}_{ijk}$ and $k2$ entries are functions only of $\text{x1,x2,y1}$ and $\text{y2}$.
I suppose mathematica won't directly do that, but maybe I could use it to help me in the process.
To illustrate better what I mean for $k=k1*k2$ let me do an example:
Suppose I have the following vector $k$ $$k=\left( \begin{array}{c} \frac{b+a}{a} \\ a-b \\ 1+a.b \\ \frac{a}{b} \end{array} \right)$$
I could rewrite it as $$ k=\left( \begin{array}{c} 1+\frac{b}{a} \\ a-b \\ 1+a.b \\ \frac{a}{b} \end{array} \right) $$
and then as a matrix multiplication:
$$ k=\left( \begin{array}{c} 0 & 0 & 0 & 0 & 1 & 1\\ 1 & -1 & 0 & 0 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 & 1\\ 0 & 0 & 0 & 1 & 0 & 0 \end{array} \right)*\left( \begin{array}{c} a\\ b\\ a.b\\ \frac{a}{b} \\ \frac{b}{a} \\ 1 \end{array} \right) $$
Where only the second factor depends on $a$ and $b$
Hope I made myself clear. Any help would be appreciated!
PseudoInverse
,LeastSquares
andLinearSolve
. $\endgroup$