Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7287 Discussions

Question: 2d array in C language for Lapack fortran library.

kimjoonshikgmail_com
1,314 Views
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.
0 Kudos
3 Replies
ArturGuzik
Valued Contributor I
1,314 Views
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.
Joon,

this example should help.

A.
0 Kudos
kimjoonshikgmail_com
1,314 Views
Quoting - ArturGuzik
Joon,

this example should help.

A.

Thank you A.
0 Kudos
Dmitry_B_Intel
Employee
1,314 Views


The example relates to statically allocated arrays, it won't work for malloc()ed data. Similar question was asked with respect to 2D Fourier transforms.

Thanks
Dima

0 Kudos
Reply