行列Aの逆行列A^(-1)を求めます。 Matrix?もしくはComplexMatrix?クラスのinverse()メソッドを使うだけです。
#include <iostream> #include <octave/config.h> #include <octave/CMatrix.h> using namespace std; int main() { cout.precision(3); cout.setf(ios::fixed); Complex const IU(0.0, 1.0); int const N = 3; ComplexMatrix A(N, N); A(0,0) = 3.0 + IU; A(0,1) = 2.0 ; A(0,2) = IU; A(1,0) = 4.0 ; A(1,1) = 1.0 + IU ; A(1,2) = 6.0; A(2,0) = 5.0*IU ; A(2,1) = 3.0 - IU ; A(2,2) = -4.0*IU; cout << "originam matrix : A = " << endl << A << endl; ComplexMatrix A_inv = A.inverse(); cout << "inverse matrix : A^(-1) = " << endl << A_inv << endl; cout << "A A^(-1) = " << endl << A * A_inv << endl; cout << "A^(-1) A = " << endl << A_inv * A << endl; }
originam matrix : A = (3.000,1.000) (2.000,0.000) (0.000,1.000) (4.000,0.000) (1.000,1.000) (6.000,0.000) (0.000,5.000) (3.000,-1.000) (-0.000,-4.000) inverse matrix : A^(-1) = (0.061,0.118) (0.094,-0.043) (-0.049,-0.112) (0.407,-0.141) (-0.134,-0.043) (0.037,0.165) (-0.132,-0.123) (0.119,0.058) (0.054,0.041) A A^(-1) = (1.000,-0.000) (-0.000,0.000) (-0.000,0.000) (-0.000,-0.000) (1.000,0.000) (0.000,0.000) (-0.000,0.000) (0.000,0.000) (1.000,-0.000) A^(-1) A = (1.000,-0.000) (0.000,0.000) (0.000,-0.000) (-0.000,0.000) (1.000,0.000) (-0.000,0.000) (0.000,0.000) (0.000,-0.000) (1.000,0.000)
&ref(): File not found: "wikilogo1.png" at page "逆行列を求めたい"; |