Inv
Returns inverse of matrix.
Calling example:
CALL Inv(A(:,:), InvA(:,:))
CALL Inv(A(:,:,:), InvA(:,:,:))
note
InvA should be allocated.
caution
Currently, Inv can compute inverse of matrix upto 4 by 4. To calculate inverse of big matrix use the following strategy:
First get LU decomposition:
CALL GetLU(A, LU, IPIV)
Then, calculate inverse by
CALL GetLU(A, invA, IPIV)
Interface 1
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE SUBROUTINE Inv(invA, A)
REAL(DFP), INTENT(INOUT) :: invA(:, :)
REAL(DFP), INTENT(IN) :: A(:, :)
END SUBROUTINE Inv
END INTERFACE
program main
use easifemBase
implicit none
real(dfp) :: amat(3,3), ainv(3,3)
call random_number(amat)
call display(Mdencode(amat), "amat: " // char_lf // char_lf)
call inv(invA=ainv, a=amat)
call display(Mdencode(ainv), "ainv: " // char_lf // char_lf)
end program main
See results
amat:
0.88179 | 0.51365 | 0.53015 |
0.24482 | 9.60291E-02 | 0.79165 |
0.25111 | 0.42564 | 9.45404E-04 |
ainv:
2.2076 | -1.4756 | -2.3312 |
-1.3012 | 0.86698 | 3.7241 |
-0.52488 | 1.6144 | 0.26919 |
Interface 2
INTERFACE
MODULE PURE SUBROUTINE Inv(invA, A)
REAL(DFP), INTENT(INOUT) :: invA(:, :, :)
REAL(DFP), INTENT(IN) :: A(:, :, :)
END SUBROUTINE Inv
END INTERFACE