complex16* type in C++

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

complex16* type in C++

Postby cheng70 » Sat Oct 22, 2005 12:07 pm

Hello,

I'm calling LAPACK/BLAS from C++ and was wondering what the complex16* type is in C++. I guess it is a built in type of Fortran, which consists of two Real-8 types.
From various examples on the web, it seems like it is just a double type or twice the size:
complex16* = double with double[0]=real part, double[1]=imaginary part. I have all
the other routines working because a double is obviously just a double in C++.

For example, the function zdotu_(int *N, complex16* X, int *incx, complex16* Y, int *incy),
[which takes the dot product of time complex numbers]
is supposed to return a type 'Complex16*', which I guess is a type in Fortran.
Does anybody know what this type is in C++? Is it a structure with 2 double pointers
with names 're' and 'im' or is it just a double[2]. From here, I would really like to know how to store the value of zdotu_. Do you write something like:
double *z;
z=zdotu_(..); ?

Gratefully appreciative for your time,
cheng70
 
Posts: 1
Joined: Sat Oct 22, 2005 11:54 am

Postby Julie » Mon Oct 24, 2005 11:07 am

Cheng,

The double complex does not exist in C or C++ and thus is defined by a structure with 2 double pointers.
Code: Select all
 struct doublecomplex
{   double re;
   double im;
};

Unfortunately, returning composite objects that occupy more than a single register, or an adjacent register pair, is fraught with peril. Older C and C++ compilers did not support this at all, and newer ones may do it differently than Fortran compilers do: thus, you should not expect to use Fortran functions that return types such as COMPLEX or COMPLEX*16. Write a SUBROUTINE interface to your Fortran function instead, and then invoke it as a void function from C or C++.
For example:
Code: Select all
/* Double Complex */ VOID zdotu_(doublecomplex * ret_val, integer *n,
   doublecomplex *zx, integer *incx, doublecomplex *zy, integer *incy)


Sincerely
Julie Langou
Julie
 
Posts: 299
Joined: Wed Feb 23, 2005 12:32 am
Location: ICL, Denver. Colorado


Return to User Discussion

Who is online

Users browsing this forum: Bing [Bot], JakeRasheed, Yahoo [Bot] and 1 guest