- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
can someone help me ?
I need to use lapack functions is C.
for example,
dgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy) for matrix vector multiplication or
dgels(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info) for LS solution using QR factorization,
Can someone inform me
how to define the 2 D array and 1 D array correctly ?formatrix a and vector b in above functions ?
I was using one - d array instead of 2 -d like
a[100] instead of a[10][10] and put the elements in a[100] as column based format and used for above functions,
dgemv worked but dgels give me segmentation faults error.
Thank you.
Joon.
I need to use lapack functions is C.
for example,
dgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy) for matrix vector multiplication or
dgels(trans, m, n, nrhs, a, lda, b, ldb, work, lwork, info) for LS solution using QR factorization,
Can someone inform me
how to define the 2 D array and 1 D array correctly ?formatrix a and vector b in above functions ?
I was using one - d array instead of 2 -d like
a[100] instead of a[10][10] and put the elements in a[100] as column based format and used for above functions,
dgemv worked but dgels give me segmentation faults error.
Thank you.
Joon.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, Joon.
MKL will publish LAPACK C examples soon, there will be dgels example, illustrating 1-d arrays usage. For instance, if you needto solve the problem with the matrix 4-by-4:
1.44 -7.84 -4.39 4.53
-9.96 -0.28 -3.24 3.83
-7.55 3.24 6.27 -6.64
8.34 8.09 5.28 2.06
and right-hand side:
8.58
8.26
8.48
-5.28
you need to initialize the arrays as follows:
int n = 4, nrhs = 1, info, lwork = 100; // Use lwork no less than minimal recommended, or query it
double work[100];
double a[4*4] = {
1.44, -9.96, -7.55, 8.34,
-7.84, -0.28, 3.24, 8.09,
-4.39, -3.24, 6.27, 5.28,
4.53, 3.83, -6.64, 2.06
};
double b[4*1] = {
8.58, 8.26, 8.48, -5.28
};
to call dgels:
dgels( "No transpose", &n, &n, &nrhs, a, &n, b, &n, work, &lwork, &info );
You may want to put the data into 2-d array instead1-dwith absoluetely the same order of elements:
double a2d[4][4] = {
1.44, -9.96, -7.55, 8.34,
-7.84, -0.28, 3.24, 8.09,
-4.39, -3.24, 6.27, 5.28,
4.53, 3.83, -6.64, 2.06
};
but in this case you need to specify input data differently to pass the pointer to the first element of the array:
dgels( "No transpose", &n, &n, &nrhs, *a2d, &n, b, &n, work, &lwork, &info );
or
dgels( "No transpose", &n, &n, &nrhs, a2d[0], &n, b, &n, work, &lwork, &info );
Michael.
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