The LAPACK forum has moved to https://github.com/Reference-LAPACK/lapack/discussions.

CLAPACK dgees_ function

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

CLAPACK dgees_ function

Postby unadulterated » Tue Aug 03, 2010 7:41 pm

Hi thr
I am struggling to make this dgees_ function work while working in C with CLAPACK.

/* Subroutine int dgees_(char *jobvs, char *sort, L_fp select, integer *n,
doublereal *a, integer *lda, integer *sdim, doublereal *wr,
doublereal *wi, doublereal *vs, integer *ldvs, doublereal *work,
integer *lwork, logical *bwork, integer *info);
*/

2 of the inputs to the function are logical, I dont know how to give logical variable and logical array.
For the logical variable (select) .. i tried 1 or 0
for logical array .. i tried int bwork[size]

further I will be glad if someone can post a snippet of their usage of this dgees_().

Also I am getting error : select is not L_fp, am not sure which type is L_fp???

someone please help me..

I am using g++/ gcc... tried both.
unadulterated
 
Posts: 8
Joined: Tue Aug 03, 2010 3:36 pm

Re: CLAPACK dgees_ function

Postby cottrell » Mon Aug 09, 2010 2:14 pm

2 of the inputs to the function are logical, I dont know how to give logical variable and logical array.

Include clapack.h for the definition of the "logical" type. In C you'd allocate bwork via something like
Code: Select all
logical *bwork = malloc(N * sizeof(logical));

where N is the order of the A matrix.
For the logical variable (select) .. i tried 1 or 0

"select" is not a logical variable, it's a function that returns a logical value.
As it says in the docs:

SELECT (external procedure) LOGICAL FUNCTION of two
DOUBLE PRECISION arguments.

This is required only if you want to order the eigenvalues on the diagonal of the
real Schur form so that selected eigenvalues are at the top left (sort = S);
otherwise you can pass NULL for this argument.

Allin Cottrell
cottrell
 
Posts: 73
Joined: Thu Jan 15, 2009 1:40 pm

Re: CLAPACK dgees_ function

Postby unadulterated » Mon Aug 09, 2010 5:47 pm

Thank you very much. I was able to figure out the bwork, and the SELECT logical function i came to know this after your explanation.

Can you please help me this SELECT logical function, I am seeing this fortran example : http://www.nag.com/lapack-ex/examples/source/dgees-ex.f
this link has a SELECT logical function towards the end of the code..

But how do I write a similar logical function for c language code? I have a different requirement.

now i want to have all the eigen values with
-ve real part
to sorted to the left top of the schur form.
for that i have started using this logical fucntion..

logical SELECT(double ar, double ai)
{
logical d;
if (ar <= 0.0)
d = TRUE_;
else
d = FALSE_;
return d;
}

its not working... can you please suggest what is that I am doing wrong..
unadulterated
 
Posts: 8
Joined: Tue Aug 03, 2010 3:36 pm

Re: CLAPACK dgees_ function

Postby unadulterated » Tue Aug 10, 2010 11:05 am

I am pasting a function in FORTRAN from the link in my previous post....
and i wanted to write the same code in C (just for checking whether what I am doing is right or not)... have written that.. (below the fortran code).. but the way i have written is not working... need help.. to sort this one.
==============================================
Code: Select all
      LOGICAL FUNCTION SELECT(AR,AI)
*     .. Scalar Arguments ..
*
*     Logical function SELECT for use with DGEES
*
*     Returns the value .TRUE. if the imaginary part of the eigenvalue
*     (AR + AI*i) is zero, i.e. the eigenvalue is real
*
      DOUBLE PRECISION        AI, AR
*     .. Local Scalars ..
      LOGICAL                 D
*     .. Executable Statements ..
      IF (AI.EQ.0.0D0) THEN
         D = .TRUE.
      ELSE
         D = .FALSE.
      END IF
*
      SELECT = D
*
      RETURN
      END
[code]
=============================================
[code]
logical SELECT(double ar, double ai)
{
    //printf("Inside SELECT function!\n");
    //printf("%f, %f\n", ar, ai);
    logical d;
    if (ai == 0.0)
        d = TRUE_;
    else
        d = FALSE_;
    return d;
}
unadulterated
 
Posts: 8
Joined: Tue Aug 03, 2010 3:36 pm

Re: CLAPACK dgees_ function

Postby cottrell » Tue Aug 10, 2010 4:37 pm

I am pasting a function in FORTRAN from the link in my previous post....
and i wanted to write the same code in C (just for checking whether what I am doing is right or not)... have written that.. (below the fortran code).. but the way i have written is not working...

I suspect that the arguments to SELECT may be passed fortran-style, in which case
you'd want something like...
Code: Select all
logical SELECT(double *ar, double *ai)
{
    //printf("Inside SELECT function!\n");
    //printf("%g, %g\n", *ar, *ai);
    return *ar < 0.0;
}

Allin Cottrell
cottrell
 
Posts: 73
Joined: Thu Jan 15, 2009 1:40 pm

Re: CLAPACK dgees_ function

Postby unadulterated » Tue Aug 10, 2010 4:41 pm

thanks a lot .. it worked.. was waiting for your reply.. thanks again...
unadulterated
 
Posts: 8
Joined: Tue Aug 03, 2010 3:36 pm


Return to User Discussion

Who is online

Users browsing this forum: No registered users and 7 guests