Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Sunny_Beast
Beginner
69 Views

ERROR WITH ZGELSS PARA METERS

Hi
I ma trying following code on Mac Ox 10.6 using MKL 10.3 and C++ composer Xe update 5


#include
#include
#include
using namespace std;

/* Complex datatype */
struct _dcomplex { double re, im; };
typedef struct _dcomplex dcomplex;

/* ZGELSS prototype */
extern "C" { // LAPACK routines
void zgelss_(int*m, int* n, int* nrhs, dcomplex* a, int* lda, dcomplex* b, int* ldb, double* s, double* rcond, int* rank, dcomplex* work, int* lwork, double* rwork, int* info );}
/* Auxiliary routines prototypes */
extern void print_matrix( char* desc, int m, int n, dcomplex* a, int lda );
extern void print_double_vector( char* desc, int n, double* a );

/* Parameters */
#define N 4
#define NRHS 2
#define LDA N
#define LDB N

/* Main program */
int main() {
/* Locals */
int m = N, n = N, nrhs = NRHS, lda = LDA, ldb = 4, info, lwork = -1, rank;
double rcond = 0, rwork[20];
/* Local arrays */
double s[4];
dcomplex work[264];
dcomplex a[LDA*N] = {
{ 1.23, -5.50}, {-2.14, -1.12}, {-4.30, -7.10}, { 1.27, 7.29},
{ 7.91, -5.38}, {-9.92, -0.79}, {-6.47, 2.52}, { 8.90, 6.92},
{-9.80, -4.86}, {-9.18, -1.12}, {-6.51, -2.67}, {-8.82, 1.25},
{-7.32, 7.57}, { 1.37, 0.43}, {-5.86, 7.38}, { 5.41, 5.37}
};
dcomplex b[LDB*NRHS] = {
{ 8.33, -7.32}, {-6.18, -4.80}, {-5.71, -2.80}, {-1.60, 3.08},
{-6.11, -3.81}, { 0.14, -7.71}, { 1.41, 3.40}, { 8.54, -4.05}
};
/* Executable statements */
printf( " ZGELSS Example Program Results\\n" );
/* Solve the equations A*X = B */

zgelss_( &m, &n, &nrhs, a, &lda, b, &ldb, s, &rcond, &rank, work, &lwork, rwork, &info );


/* Check for the exact singularity */
if( info != 0 ) {
printf( "The diagonal element of the triangular factor of A,\\n" );
printf( "U(%i,%i) is zero, so that A is singular;\\n", info, info );
printf( "the solution could not be computed.\\n" );
exit( 1 );
}
/* Print solution */
print_matrix( "Solution", n, nrhs, b, ldb );
/* Print details of sv decomposition */
print_matrix( "Details of LU factorization", n, n, a, lda );
/* Print singular values */
print_double_vector( "Pivot indices", n, s );

cout << "work = " < exit( 0 );
} /* End of ZGESV Example */

/* Auxiliary routine: printing a matrix */
void print_matrix( char* desc, int m, int n, dcomplex* a, int lda ) {
int i, j;
printf( "\\n %s\\n", desc );
for( i = 0; i < m; i++ ) {
for( j = 0; j < n; j++ )
printf( " (%6.2f,%6.2f)", a[i+j*lda].re, a[i+j*lda].im );
printf( "\\n" );
}
}

/* Auxiliary routine: printing a vector of integers */
void print_double_vector( char* desc, int n, double* a ) {
int j;
printf( "\\n %s\\n", desc );
for( j = 0; j < n; j++ ) printf( " %6.2f", a );
printf( "\\n" );
}


compiler statement

icpc main.cpp -o result_t -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -openmp -lpthread -DMKL_ILP64

but this is giving error for para meter 7 i.e. LDB

Output:

MKL ERROR: Parameter 7 was incorrect on entry to ZGELSS
The diagonal element of the triangular factor of A,
U(-7,-7) is zero, so that A is singular;
the solution could not be computed.

Although the code gives perfect result when used with GCC and Lapack provided by Apple

please help:
0 Kudos
2 Replies
barragan_villanueva_
Valued Contributor I
69 Views

Hi,

Your program doesn't use mkl.h (and MKL_INT type) using LP64-model for m, n, lda, .... for zgelss
void zgelss_(int*m, int* n, int* nrhs, dcomplex* a, int* lda, ....
but linked with ILP64 MKL interface.
Please try -lmkl_intel_lp64 instead of -lmkl_intel_ilp64.
Sunny_Beast
Beginner
69 Views

Thanks alot Victor
Reply