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

[CLOSED]zgels_ call from C++ don't works parameter

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

[CLOSED]zgels_ call from C++ don't works parameter

Postby pep_gentoo » Thu Sep 20, 2007 11:40 am

Hi,
I'm trying to use lapack routines with C++, and I'm stuck to a very boring problem
Here is my code:
Code: Select all
#include <blitz/array.h>
extern "C" {
#include "f2c.h"

   
//#include "clapack.h"
}

extern "C" {
   int zgels_(char *trans, integer *m, integer *n, integer *nrhs,
            doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb,
            doublecomplex *work, integer *lwork, integer *info);
}

typedef char            c8;

typedef unsigned int   u8;
typedef unsigned short  u16;
typedef unsigned long   u32;

typedef signed int      s8;
typedef signed short     s16;
typedef signed long      s32;

typedef float         f32;
typedef double         f64;
typedef long double    f80;

BZ_USING_NAMESPACE(blitz)

int main()
{
   Array<blitz::complex<double>,2> A(3,2,FortranArray<2>()),
                               B(3,1,FortranArray<2>()),
                        X(2,1,FortranArray<2>());
   A =   1 + 1i , 3 + 2i, 2 + 3i,
      2 + 1i , 1 + 2i, 2 + 1i;
   B =   2 + 2i,
      1 + 3i,
      3 + 1i;
   
   char  type   = 'N';
   integer m  = 3;
   integer n      = 2;
   integer nrhs   = 1;
   integer lda    = 3;
   integer ldb    = 3;

   integer lwork = n + max(m,nrhs);
   integer result = 0;

   zgels_( &type,&m,&n,&nrhs,
         reinterpret_cast<doublecomplex*>(&A),&lda,
         reinterpret_cast<doublecomplex*>(&B),&ldb,
         reinterpret_cast<doublecomplex*>(&X),&lwork,&result);
   
   cout << "result of fgels = " << result << endl;
   
   
   cout    << "A = " << A << endl
         << "B = " << B << endl
         << "X = " << X << endl;
   return 0;
}


To compile it I use:
Code: Select all
g++ -ftemplate-depth-30 -g -DBZ_DEBUG  -c blitz_test.cpp
g++  blitz_test.o -o blitz_test -lblitz -llapack -lm

(this one use direct call to fortran obj library)
and here is the error:
Code: Select all
 ** On entry to ZUNMQR parameter number  5 had an illegal


I've tried also with clapack:

Code: Select all
** On entry to ZUNMQR, parameter number  5 had an illegal value
ldb must be >= MAX(M,1): ldb=3 M=2147483644Parameter 12 to routine cblas_ztrsm was incorrect


What I don't undersatnd is M value in ZUNMQR I first thought that my clapack was wrong compiled that's why I ended with fortran direct call, but it was the same message...

Do I do something realllly stupid?
Any idea to solve this????

using
g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --enable-targets=all --disable-werror --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.1 (Debian 4.2.1-3)

g77 -v
Lecture des spécification à partir de /usr/lib/gcc/i486-linux-gnu/3.4.6/specs
Configuré avec: ../src/configure -v --enable-languages=c,c++,f77,pascal --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --with-tune=i686 i486-linux-gnu
Modèle de thread: posix
version gcc 3.4.6 (Debian 3.4.6-6)

lapack 3.0.2

Thanks a lot for any help!
pep_gentoo
 
Posts: 3
Joined: Thu Sep 20, 2007 11:25 am

Return to User Discussion

Who is online

Users browsing this forum: No registered users and 4 guests