Another way to do this is to create a permutation matrix to extract known and unknown rows out of your vectors.
This method is a little more complicated, but much more programmer friendly:
Say your eq. system is:
K . T = Q
where K
is 3x3
, and T
and Q
are 3x1
vectors. You can create a permutation Pf
matrix in a way that when it multiplied by T
, result is unknown part of T
matrix (which is only T2), in your case permutation matrix will be a 1x3
matrix:
Pf = [0 1 0]
|100|
Tf = Pf * T = [0 1 0]* |T2 | = [T2]
|0 |
another permutation matrix will gets the known part out of T
matrix, in your case it will be a 2x3
matrix:
| 1 0 0|
Ps = | 0 0 1|
Ts = Ps * T = | 1 0 0| |100| |100|
| 0 0 1| *| T2| = |0 |
|0 |
Now everything is ready, you can assume the system like this:
K . T = Q
K = |Kff Kfs|
|Ksf Kss|
Q = |Qf|
|Qs|
T = |Tf|
|Ts|
where f
is prefix for unknown right side, and s
prefix is for known right side. you can find Pf
, Ps
, Qf
, Qs
, Kff
, Kfs
, Ksf
and Kss
like this:
Tf = Pf * T
Ts = Ps * T
Qf = Pf * Q
Qs = Ps * Q
Kff = pf * K * pf` (note: ` denotes the transpose)
Kfs = pf * K * ps` (note: ` denotes the transpose)
Ksf = ps * K * pf` (note: ` denotes the transpose)
Kss = ps * K * ps` (note: ` denotes the transpose)
now unknown vectors Tf
and Qs
needs to be found:
K . T = Q
|Kff Kfs| |Tf| = |Qf|
|Ksf Kss| |Ts| |Qs|
means that:
Kff * Tf + Kfs * Ts = Qf
Ksf * Tf + Kss * Ts = Qs
from first one:
Tf = Kff^-1 * (Qf - Kfs * Ts)
with above equation you can find Tf (note that all right sides are known matrix and vectors, so numeric operations need to be performed)
and from second one:
Qs = Ksf * Tf + Kss * Ts
this way both Qs
and Tf
are found. Once you found Tf
and Qs
, you can do this to form original T
and Q
matrix:
Q = Ps` * Qs + Pf` * Qf
T = Ps` * Ts + Pf` * Tf