Re: [问题] complex matrix 的 inverse matrix

楼主: kkarthur (aa)   2012-08-16 02:07:43
※ 引述《forentia (谨慎)》之铭言:
: 请问各位大大
: 要怎么算出complex matrix的反函数?
: 网络上找到的是real的
: 那complex有办法吗?
刚刚好最近有用到, 直接po上来好了
program main
implicit none
complex*16::a(3,3),b(3,3),c(3,3)
data a/10,2.5,(3,7),4,5,6,7,8,9/
print*,'a='
write(*,'(3(F8.4,"+i",F8.4,", "))') , a(1,:)
write(*,'(3(F8.4,"+i",F8.4,", "))') , a(2,:)
write(*,'(3(F8.4,"+i",F8.4,", "))') , a(3,:)
b=zInverse(3,a)
print*,'b='
write(*,'(3(F8.4,"+i",F8.4,", "))') , b(1,:)
write(*,'(3(F8.4,"+i",F8.4,", "))') , b(2,:)
write(*,'(3(F8.4,"+i",F8.4,", "))') , b(3,:)
c=matmul(a,b)
print*,'c='
write(*,'(3(F8.4,"+i",F8.4,", "))') , c(1,:)
write(*,'(3(F8.4,"+i",F8.4,", "))') , c(2,:)
write(*,'(3(F8.4,"+i",F8.4,", "))') , c(3,:)
contains
function zInverse(n, a) result(ra)
integer::n,lda,ipiv(n),info,lwork
complex*16::a(n,n),ra(n,n),work(n)
ra=a
lwork=n
lda=n
call zgetrf(n, n, ra, lda, ipiv, info)
if(info/=0) write(0,*) 'Error occured in zgetrf!'
call zgetri(n, ra, lda, ipiv, work, lwork, info)
if(info/=0) write(0,*) 'Error occured in zgetri!'
endfunction
end
作者: callmei (挨)   2012-08-16 04:30:00
免费?我还以为只有LINUX版本才有非商业版免费说@@
楼主: kkarthur (aa)   2012-08-16 05:19:00
我说的也是指在Linux底下....
作者: YCTzeng (我有一个大密宝)   2012-08-16 08:11:00
新版 ifort -mkl 就可以了。

Links booklink

Contact Us: admin [ a t ] ucptt.com