Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Full matrix storage in MKL LAPACK

topol555
Beginner
554 Views
Please, help me. I'm using dgels function (declared in mkl_lapack.h) from MKL LAPACK package in my program on C++. I can't understand how should I store my full matrix in one-dimensional array - in column-major or row-major format.

For example, if matrix A=
(1.0 2.0)
(3.0 4.0)
(5.0 6.0)
then the array should be
1.1) [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] (row-major format) or
1.2) [1.0, 3.0, 5.0, 2.0, 4.0, 6.0] (column-major format).

And if Ax=b, where b is a vector (7.0, 8.0, 9.0), then b will be overwritten by the solution vector like
2.1) [x1, x2, 9.0] or
2.2) [x1, 8.0, x2].

0 Kudos
3 Replies
TimP
Honored Contributor III
554 Views
In case you didn't find answers in MKL docs,
http://www.netlib.org/clapack/readme
describes the storage from the C point of view (column-major)
I think you would have to specify more about your usage to understand the second part of your question. However, in the cases where the result doesn't use all the entries of b, it is the leading entries which are over-written.
0 Kudos
Gennady_F_Intel
Moderator
554 Views
Quoting - topol555
Please, help me. I'm using dgels function (declared in mkl_lapack.h) from MKL LAPACK package in my program on C++. I can't understand how should I store my full matrix in one-dimensional array - in column-major or row-major format.

For example, if matrix A=
(1.0 2.0)
(3.0 4.0)
(5.0 6.0)
then the array should be
1.1) [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] (row-major format) or
1.2) [1.0, 3.0, 5.0, 2.0, 4.0, 6.0] (column-major format).

And if Ax=b, where b is a vector (7.0, 8.0, 9.0), then b will be overwritten by the solution vector like
2.1) [x1, x2, 9.0] or
2.2) [x1, 8.0, x2].


Please look at the following link:
ttp://software.intel.com/sites/products/documentation/hpc/mkl/lapack/mkl_lapack_examples/index.htm

you can find there the C example of DGELS routine.

/* Solve the equations A*X = B */
dgels( "No transpose", &m, &n, &nrhs, a, &lda, b, &ldb, work, &lwork, &info );
--Gennady
0 Kudos
topol555
Beginner
554 Views
Thank you!
0 Kudos
Reply