関数solution_QR マニュアル

(The documentation of function solution_QR)

Last Update: 2021/12/6


◆機能・用途(Purpose)

連立一次方程式の解および逆行列をQR分解を用いて計算する。
Calculate the solution of a simultaneous linear equation or an inverse matrix using a QR decomposition.


◆形式(Format)

#include <matrix/inverse.h>
inline struct matrix solution_QR
(const struct matrix A,const struct matrix B)


◆引数(Arguments)

A 連立方程式の係数行列A。正方行列でなければならない。
A matrix A composed of the coefficients of the simultaneous equation. This matrix must be a square matrix.
B 連立方程式の右辺から成る行列B。 行数はAの行数と等しくなければならないが列数は任意である。 例えばBの列数を1にすれば連立一次方程式の解の計算になる。 またBを単位正方行列にした場合には Aの逆行列の計算になる。
A matrix composed of the right hand side of the simultaneous equation. The number of rows of this matrix must be equal to that of A, and the number of columns is arbitrary. For example, if B has only one column, then the problem reduces to solving a simultaneous equation. If a unit square matrix is used for B, then the problem reduces to calculation of the inverse of A.


◆戻り値(Return value)

方程式AX=Bの解X。 行列AのランクpAの行数よりも小さい場合には Xp+1行目以降を0とした解が返される。
The solution X of an equation AX=B. When the rank p of the matrix A is less than the number of rows of it, then the solution X will have the value 0 for all the components after (p+1)th raw.


◆使用例(Example)

struct matrix A=get_matrix_memory(2,2);
struct matrix I2=unit_matrix(2);
A.main[0][0]=1.0;
A.main[0][1]=2.0;
A.main[1][0]=3.0;
A.main[1][1]=4.0;
struct matrix Ainv=solution_QR(A,I2);


◆検証(Validation)

この関数が実際に正しい結果を与えるか否かの検証のため、 A, Bを乱数を用いて生成し、 この関数を用いてXを求めた後、 AXを計算して Bと一致するかをチェックした。 AXの計算には 関数multiply_matrix (matrix/operation.h)を用いた。 結果は以下の通りであった。
To examine if this function gives a correct result, A and B were generated by random values, and X was calculated using this function, and then AX was calculated and compared with B. Function multiply_matrix (matrix/operation.h) was used for the calculation of AX. The result was as follows.

A=(5.542348e101.180734e095.946389e105.832139e105.107910e102.357166e091.389110e096.061486e101.676399e098.405894e109.754172e107.404720e101.276538e099.070130e104.890220e105.082556e10) B=(7.325038e106.491890e103.288509e097.671914e102.856718e081.917195e093.393252e095.790534e10) X=(2.778448e+011.360895e+001.097511e+017.518685e011.782558e+011.150001e+006.554215e+011.694993e01) AX=(7.325038e106.491890e103.288509e097.671914e102.856718e081.917195e093.393252e095.790534e10) この結果から、AXBは一致しており、 Xを正しく求められたことが分かる。
In this result, AX is consistent with B, indicating that X was solved correctly.


◆補足(Additional remarks)