2013-10-29 2 views
4

복잡한 행렬의 역행을 계산하고 싶습니다. 그것은 내게 lapack 대수 계산과 관련된 많은 루틴이 포함되어 있기 때문에, 그래서 나는 서브 루틴 ZGETRI을 발견했다. 예기치 않게,와 코드 다음 를 컴파일 한 후, 나는백팩을 사용하여 역행렬을 계산하십시오.

는 "의 glibc가를 감지 오류를 얻었다"밖으로 "파일을 실행하고 "ifort는 test.f90 -mkl -heap-배열을 -o "./ out : free() : 유효하지 않은 포인터 : 0x00007fee68f76010 *** "

메모리 맵이 이어지고 마지막으로"중단 (코어 덤프) "됩니다. 이것은 나에게 매우 이상한 일이며 실수가 어디인지 전혀 알지 못합니다. 그건 그렇고, 일부 오류가 컴파일 프로세스에 나타나지 않고 실행중인 프로세스가 인 경우이 오류가 발생한 곳을 감지하는 방법이 있습니까? ? documentation에서

program test 
Implicit none 
integer,parameter::M=300 
complex*16,allocatable,dimension(:,:)::A 
complex*16,allocatable,dimension(:)::WORK 
integer,allocatable,dimension(:)::IPIV 
integer i,j,info,error 

allocate(A(M,M),WORK(M),IPIV(M),stat=error) 
if (error.ne.0)then 
    print *,"error:not enough memory" 
    stop 
end if 

!definition of the test matrix A 
do i=1,M 
    do j=1,M 
     if(j.eq.i)then 
     A(i,j)=(1,0) 
     else 
     A(i,j)=0 
     end if 
    end do 
end do 

call ZGETRI(M,A,M,IPIV,WORK,M,info) 
if(info .eq. 0) then 
    write(*,*)"succeded" 
else 
write(*,*)"failed" 
end if 
deallocate(A,IPIV,WORK,stat=error) 
if (error.ne.0)then 
    print *,"error:fail to release" 
    stop 
end if  
end 

답변

2

:

program test 
    Implicit none 
    integer,parameter::M=300 
    complex*16,allocatable,dimension(:,:)::A 
    complex*16,allocatable,dimension(:)::WORK 
    integer,allocatable,dimension(:)::IPIV 
    integer i,j,info,error 

    allocate(A(M,M),WORK(M),IPIV(M),stat=error) 
    if (error.ne.0)then 
    print *,"error:not enough memory" 
    stop 
    end if 

    !definition of the test matrix A 
    do i=1,M 
    do j=1,M 
     if(j.eq.i)then 
      A(i,j)=(1,0) 
     else 
      A(i,j)=0 
     end if 
    end do 
    end do 

    call ZGETRF(M,M,A,M,IPIV,info) 
    if(info .eq. 0) then 
    write(*,*)"succeded" 
    else 
    write(*,*)"failed" 
    end if 

    call ZGETRI(M,A,M,IPIV,WORK,M,info) 
    if(info .eq. 0) then 
    write(*,*)"succeded" 
    else 
    write(*,*)"failed" 
    end if 
    deallocate(A,IPIV,WORK,stat=error) 
    if (error.ne.0)then 
    print *,"error:fail to release" 
    stop 
    end if  
end 
문서에 대한 링크가 깨진
+0

, 내가 제안 http://www.netlib.org/ :

ZGETRI computes the inverse of a matrix using the LU factorization computed by ZGETRF. 

당신은 ZGETRF 먼저 실행해야 lapack/lug/node38.html – Ross

+0

@ 로스 감사합니다. 링크를 업데이트했습니다. –

관련 문제