Search code examples
c++matrixinversion

C++ Boost: determinant and inversion of complex matrix


Do you know whether boost has functions that can calculate the determinant and the inversion of a complex matrix? The matrix dimension isn't large (less than 50).

Inversion: Input: matrix M = A +i*B with A,B two real matrices of dimension (n x n) with n <50.

Output:

  • Inversion: matrix N = C + iD with C,D two real matrices of dimension (n x n) such that: (A +iB)^T (C+ i*D) = I (I: the identity matrix)
  • Determinant: det(A+iB)

I googled but didn't succeed.

Thank you in advance.


Solution

  • Finally I know why these operators on inversion and determinant of matrices aren't implemented. It's because we have closed-form solution of these 2 operators from classical operators on real matrices.

    For matrix inversion: we have this closed-form solution https://fr.mathworks.com/matlabcentral/fileexchange/49373-complex-matrix-inversion-by-real-matrix-inversion

    For matrix determinant, we have:

    det((A+iB))= det (A * (I + i A1.B)) (with A1 is the inversed matrix of A)
    = det(A) * det (I + i A1.B))

    = det(A) * det (U1 (I + iD) U2) (with U1 = A1.B, U2 is the invered matrix of U1, D is the diagonal matrix of U1) = det(A) *det(I +iD). It's easy to calculated the determinant of I +iD which is a diagonal matrix.

    So, det(A+iB) = det(A) * det(I +iD) with D: the matrix of eigenvalues of (A^(-1) * B)