1
$\begingroup$

I'm tryng to learn to use a lapack subroutine but I got stuck. I hope this is the right forum... In this fortran program I'd like as a test to find the Shur form of the matrix ((0,1)(1,0)) using cgees, but the matrix "m" after the call in which the Shur form should be written, is made only of zeros (other subrotunes like dgemm work and I don't get errors so I don't think is a problem with the linking). Do you know where I do wrong?

.........................................................

program example    
implicit none     
integer :: d,sdim,info    
real(kind=8),allocatable ::rwork(:)    
logical, external :: sel    
complex(kind=8), allocatable :: m(:,:),w(:),vs(:,:),work(:)
logical,allocatable ::bwork(:)
d=2    
!    
allocate(m(d,d))    
allocate(w(d))    
allocate(vs(d,d))    
allocate(work(2*d))    
allocate(rwork(d))    
allocate(bwork(d))    
!    
m(1,1)=(0.d0,0.d0)    
m(1,2)=(1.d0,0.d0)    
m(2,1)=(1.d0,0.d0)    
m(2,2)=(0.d0,0.d0)    
!    
print*,'m_before',m    
!    
print*,'w_before',w        
call cgees('V','S',sel,d,m,d,sdim,w,vs,d,work,-1,rwork,bwork,info)    
print*,'m',m    
print*,'w',w    
print*,'vs',vs    
print*,info        
end program example


logical function sel(x)    
  complex(kind=8) ::x    
  if (dimag(x)>1.d0) then    
     sel = .true.       
  else    
     sel = .false.    
  end if    
  return    
end

.........................................

$\endgroup$
6
  • $\begingroup$ I can't really find the error. Maybe my lapack is not well installed ?? $\endgroup$
    – Thomas
    Dec 23, 2013 at 23:35
  • $\begingroup$ Instead of (1.d0,0.d0), try cmplx(1.d0,0.d0) and so forth for your other matrix assignments. Does this work? $\endgroup$
    – Paul
    Dec 24, 2013 at 15:25
  • $\begingroup$ I put what you said but the result is the same. $\endgroup$
    – Thomas
    Dec 25, 2013 at 10:54
  • 1
    $\begingroup$ Thanks to scicomp.stackexchange.com/questions/10402/… I understood that the problem is that cgees works with single precision arithmetic and not double as I thought!!! This solves the problem :) $\endgroup$
    – Thomas
    Dec 26, 2013 at 14:54
  • 1
    $\begingroup$ I'm glad to hear that you found the answer to your question. It would be a good idea if you could post your comment as an answer and accept it as an answer. $\endgroup$
    – Paul
    Dec 26, 2013 at 15:02

1 Answer 1

3
$\begingroup$

Reading this answer Real eigenvalues finding I understood that the problem is that cgees works with single precision arithmetic and not double as I thought!!! This solves the problem :) ...

In general what I understood is that lapack subroutines are named so that:

  • subroutines beggining with "d" (like DGEMM, DGETRI, DGEES,...) deal with real double precision numbers;

  • subroutines beggining with "c" (like CGEMM, CGETRI, CGEES,...) deal with complex single precision numbers;

  • subroutines beggining with "z" (like ZGEMM, ZGETRI, ZGEES...) deal with complex double precision numbers;

Thx a lot,

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.