PSLAMCH returns zero

Open discussion regarding features, bugs, issues, vendors, etc.

PSLAMCH returns zero

Postby tjcarroll » Wed Aug 31, 2011 2:38 pm

Hi,
I'm using PSSYEVX to get the eigenvalues and eigenvectors of large matrices. Things seem to be working okay...except for this issue with PSLAMCH. I'm using it (as recommend in the PSSYEVX documentation) to determine the tolerance:

Code: Select all
ABSTOL=2*pslamch_(&ictxt, 'u');


(I've tried 's' as well.)

The problem is that PSSYEVX returns INFO=2, indicating that not all eigenvectors converged. When I check ABSTOL, I see that it equals zero. The documentation indicates that this is not an optimal value -- but how do I choose an appropriate value? Why would PSLAMCH return a value of zero?

Also, even though INFO=2, all of the elements of IFAIL are zero.

Any suggestions?

Thanks!
tom
tjcarroll
 
Posts: 10
Joined: Thu Nov 06, 2008 8:48 am

Re: PSLAMCH returns zero

Postby tjcarroll » Wed Aug 31, 2011 4:04 pm

Okay, I've narrowed my problem down a bit. PSLAMCH works fine when I call it from my fortran code:

Code: Select all
     
ABSTOL =2*PSLAMCH(CONTEXT, 'U')
PRINT *, ABSTOL


yields 2.3509887E-38.

However, when I call PSLAMCH from my c code, I get zero:

Code: Select all
char uu = 'U';
float ABSTOL=2*pslamch_(&ictxt, &uu);


What am I doing wrong?

Thanks!
tom
tjcarroll
 
Posts: 10
Joined: Thu Nov 06, 2008 8:48 am

Re: PSLAMCH returns zero

Postby Julien Langou » Wed Aug 31, 2011 4:16 pm

Do you have a prototype for PSLAMCH in your C code?
So something like: extern float pslamch_ ( );
J
Julien Langou
 
Posts: 734
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Re: PSLAMCH returns zero

Postby tjcarroll » Wed Aug 31, 2011 4:50 pm

Hi Julien,
Thanks - that worked! But now I have a question: I do not have prototypes for other functions (pslaprint and pssyevx for example), but they seem to work fine. Do I need similar prototypes for them? Am I only lucky that they are working correctly?

Thanks for your help--
tom
tjcarroll
 
Posts: 10
Joined: Thu Nov 06, 2008 8:48 am

Re: PSLAMCH returns zero

Postby Julien Langou » Wed Aug 31, 2011 5:36 pm

When the function returns a value (like pslamch, pslange, psdot, etc. ) then you absolutely needs to declare the prototype of the function. When you compile your C code, although the compiler sees that pslamch is supposed to return something, there is no way for the compiler to know what the function pslamch is supposed to return (without the prototype). (Is it an int, float, char, double, long double?) But the compiler absolutely needs to know the type, because it needs to prepare the space for the returned value. So by default I think the compiler assumes you are returning an int and this is not correct in the pslamch case. For the subroutines which do not return any value, having no prototype is fine.

(Having prototype is always recommended. It enables you to find some miscalled at compile time though.)

Yeah ... we need to have a C interface to ScaLAPACK with a nice header .h file as we have for LAPACK.

Cheers,
J
Julien Langou
 
Posts: 734
Joined: Thu Dec 09, 2004 12:32 pm
Location: Denver, CO, USA

Re: PSLAMCH returns zero

Postby tjcarroll » Wed Aug 31, 2011 5:42 pm

Hi Julien,
Thanks - that is a wonderfully clear explanation!

Yes - I've spent quite a bit of time porting my old fortran code over to c. Mostly because it's tough to find undergraduates who know anything about fortran :). With this last bit of info, I think I've got everything working well.

Cheers,
tom

ps The one that really threw me for a loop was getting pslaprint (or any function that took a string as a parameter) to work. I finally did figure out to include the string length as a function parameter....
tjcarroll
 
Posts: 10
Joined: Thu Nov 06, 2008 8:48 am


Return to User Discussion

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 2 guests