- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I exercise LAPACK in c language. I want to factorize a matrix(2X2) but it doesn't work.
I don't have any idea what is the problem.
The simple code is like this. The error message says there is a problem in 4th parameter(lda).
#include
#include
#include "mkl.h"
#define NRANSI
#include "NRUTIL.h"
#define PI (3.141592653589793)
int main(int argc, char* argv[])
{
int m, n, lda, info;
double **A, d;
int *ipiv;
A = dmatrix(1,2,1,2);
ipiv = ivector(1,2);
m = 2;
n = 2;
lda = 2;
A[1][1] = 4.0;
A[1][2] = 1.0;
A[2][1] = 3.0;
A[2][2] = -1.0;
printf("This is TEST!!!\n");
dgetrf(&m, &n, &A[1][1], &lda, &ipiv[1], &info);
printf("info = %d\n",info);
free_dmatrix(A,1,2,1,2);
free_ivector(ipiv,1,2);
return 1;
}
#include
#include "mkl.h"
#define NRANSI
#include "NRUTIL.h"
#define PI (3.141592653589793)
int main(int argc, char* argv[])
{
int m, n, lda, info;
double **A, d;
int *ipiv;
A = dmatrix(1,2,1,2);
ipiv = ivector(1,2);
m = 2;
n = 2;
lda = 2;
A[1][1] = 4.0;
A[1][2] = 1.0;
A[2][1] = 3.0;
A[2][2] = -1.0;
printf("This is TEST!!!\n");
dgetrf(&m, &n, &A[1][1], &lda, &ipiv[1], &info);
printf("info = %d\n",info);
free_dmatrix(A,1,2,1,2);
free_ivector(ipiv,1,2);
return 1;
}
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - phaser75
I exercise LAPACK in c language. I want to factorize a matrix(2X2) but it doesn't work.
I don't have any idea what is the problem.
The simple code is like this. The error message says there is a problem in 4th parameter(lda).
#include
#include
#include "mkl.h"
#define NRANSI
#include "NRUTIL.h"
#define PI (3.141592653589793)
int main(int argc, char* argv[])
{
int m, n, lda, info;
double **A, d;
int *ipiv;
A = dmatrix(1,2,1,2);
ipiv = ivector(1,2);
m = 2;
n = 2;
lda = 2;
A[1][1] = 4.0;
A[1][2] = 1.0;
A[2][1] = 3.0;
A[2][2] = -1.0;
printf("This is TEST!!!n");
dgetrf(&m, &n, &A[1][1], &lda, &ipiv[1], &info);
printf("info = %dn",info);
free_dmatrix(A,1,2,1,2);
free_ivector(ipiv,1,2);
return 1;
}
#include
#include "mkl.h"
#define NRANSI
#include "NRUTIL.h"
#define PI (3.141592653589793)
int main(int argc, char* argv[])
{
int m, n, lda, info;
double **A, d;
int *ipiv;
A = dmatrix(1,2,1,2);
ipiv = ivector(1,2);
m = 2;
n = 2;
lda = 2;
A[1][1] = 4.0;
A[1][2] = 1.0;
A[2][1] = 3.0;
A[2][2] = -1.0;
printf("This is TEST!!!n");
dgetrf(&m, &n, &A[1][1], &lda, &ipiv[1], &info);
printf("info = %dn",info);
free_dmatrix(A,1,2,1,2);
free_ivector(ipiv,1,2);
return 1;
}
please try in that way:
A[0][0] = 4.0;
A[0][1] = 1.0;
A[1][0] = 3.0;
A[1][1] = -1.0;
dgetrf(&m, &n, &A[0][0], &lda, &ipiv[1], &info);
it should work.
--Gennady
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - phaser75
I still have the error.
The message is "MKL ERROR : Parameter 4 was incorrect on entry to DGETRF
info = -4".
info = -4".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Gennady Fedorov (Intel)
Quoting - phaser75
I exercise LAPACK in c language. I want to factorize a matrix(2X2) but it doesn't work.
I don't have any idea what is the problem.
The simple code is like this. The error message says there is a problem in 4th parameter(lda).
#include
#include
#include "mkl.h"
#define NRANSI
#include "NRUTIL.h"
#define PI (3.141592653589793)
int main(int argc, char* argv[])
{
int m, n, lda, info;
double **A, d;
int *ipiv;
A = dmatrix(1,2,1,2);
ipiv = ivector(1,2);
m = 2;
n = 2;
lda = 2;
A[1][1] = 4.0;
A[1][2] = 1.0;
A[2][1] = 3.0;
A[2][2] = -1.0;
printf("This is TEST!!!n");
dgetrf(&m, &n, &A[1][1], &lda, &ipiv[1], &info);
printf("info = %dn",info);
free_dmatrix(A,1,2,1,2);
free_ivector(ipiv,1,2);
return 1;
}
#include
#include "mkl.h"
#define NRANSI
#include "NRUTIL.h"
#define PI (3.141592653589793)
int main(int argc, char* argv[])
{
int m, n, lda, info;
double **A, d;
int *ipiv;
A = dmatrix(1,2,1,2);
ipiv = ivector(1,2);
m = 2;
n = 2;
lda = 2;
A[1][1] = 4.0;
A[1][2] = 1.0;
A[2][1] = 3.0;
A[2][2] = -1.0;
printf("This is TEST!!!n");
dgetrf(&m, &n, &A[1][1], &lda, &ipiv[1], &info);
printf("info = %dn",info);
free_dmatrix(A,1,2,1,2);
free_ivector(ipiv,1,2);
return 1;
}
please try in that way:
A[0][0] = 4.0;
A[0][1] = 1.0;
A[1][0] = 3.0;
A[1][1] = -1.0;
dgetrf(&m, &n, &A[0][0], &lda, &ipiv[1], &info);
it should work.
--Gennady
the same with &ipiv[0] not &ipiv[1]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Gennady Fedorov (Intel)
the same with &ipiv[0] not &ipiv[1]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - phaser75
Thank you for replying but it still doesn't work. Error message is same.
Hi,
check this thread. You have double indexed matrices here.
for statically allocated matrices example of using LAPACK is here.
A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - ArturGuzik
Hi,
check this thread. You have double indexed matrices here.
for statically allocated matrices example of using LAPACK is here.
A.
I tried static allocation and one dimensional array as well. But the same error occurred.
What's the problem?
phaser.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - phaser75
Thank you. But it is the same.
I tried static allocation and one dimensional array as well. But the same error occurred.
What's the problem?
phaser.
[cpp]//
#include
#include "mkl_lapack.h"
#define MAX 2
int main(){
// data
int n, m;
int nrhs = 1;
double A[MAX][MAX];
double b[1][MAX];
int lda = MAX;
int ldb = MAX;
int ipiv[MAX];
int info;
// Other values
int i,j;
// dimension(s)
m=2;
n=2;
// value(s)
A[0][0] = 2.0;
A[0][1] = 0.0;
A[1][0] = 0.0;
A[1][1] = -2.0;
b[0][0]=1.0;
b[0][1]=2.0;
// factorize
dgetrf(&m, &n, &A[0][0], &lda, &ipiv[0], &info);
// solve
dgetrs("N", &n, &nrhs, &A[0][0], &lda, &ipiv[0], &b[0][0], &ldb, &info);
// Check for success
if(info == 0)
{
// Write the answer
std::cout << "The answer isn";
for(i = 0; i < n; i++)
std::cout << "b[" << i << "]t" << b[0] << "n";
}
else
{
// Write an error message
std::cerr << "dgetrf returned error " << info << "n";
}
return info;
}
[/cpp]
A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've got the same problem with using the MKL library.
I've just found out that the problem lies in the parameters' data type.
Actually there's some incompatibility between Int32 and Int64.
Declared as MKL_INT, variables were interpreted as Int32 at compile time.
Nevertheless it was linked with the mkl_intel_ilp64, hence when I pass the address of an "int" instead of a "long int", the function might get a zero value. In this case the matrix leading. It leads to this error.
The problem is solved by simply changing the type of lda, m and n to long int.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page