- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello there
So I am trying to solve a sparse linear least squares min||Ax - b|| where the matrix A is sparse.
The MKL 2019 introduced QR solver with the documentation available at
https://software.intel.com/en-us/mkl-developer-reference-c-mkl-sparse-qr
Now I cannot utilize such function and my guess is that I have not fully understood the parameters specially ldx & ldb since once I call the function nothing happens or the program crashes!
Specifically assuming
- Matrix A is is "m x n" & specified in CSR (since only CSR is supported at the moment)
- b is an aligned array (so 1 column only for b) and the length is m
- The solution array x is aligned (allocated) & has a length of "n"
I call (apologies for pseudo code!)
success_solve = mkl_sparse_s_qr(
operation = SPARSE_OPERATION_NON_TRANSPOSE,
A = CSR description,
descr = SPARSE_MATRIX_TYPE_GENERAL,
layout = SPARSE_LAYOUT_ROW_MAJOR,
columns = 1,
x,
ldx = 1, //I have tried with both 0 & 1 and I failed at both
b,
ldb = 1 ); //again tried with both 0 & 1 and failed at both
Appreciate any help && cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
First of all, I believe we have an example for Sparse QR functionality (look in examples/spblasc). In the example sparse_d_qr.c you can find an example of the usage. As it follows from there, when solving Ax = b with x and b being vectors, the call looks like this:
mkl_sparse_d_qr( SPARSE_OPERATION_NON_TRANSPOSE, csrA, descrA, SPARSE_LAYOUT_COLUMN_MAJOR, 1, x, ncols, b, nrows )
Hence, you need to set ldx = number of columns in the matrix, and ldb = number of rows in the matrix.
I hope this helps!
Best,
Kirill
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I find the documentation confusing, but I am able to view the MKL-Fortran documentation for the same routine (mkl_sparse_d_qr) and infer what the arguments are supposed to be.
The arguments ldA and ldX should be assigned proper values when the solver is being called with X and B containing more than one column. Those matrices are held in dense storage format, and the declared sizes may be larger than needed for the specific matrices in the call (because, at least in Fortran 77, you could not allocate matrices dynamically). In your case, however, X and B have only one column, so the values passed for ldA and ldX will never be used, but the arguments are needed as place-holders.
MKL comes with an example, "sparse_d_qr.c" (unzip the C examples Zip file to obtain it).
If your program is crashing or, as you wrote, "nothing happens" (I don't know what you expected to happen), the problem lies elsewhere. Please post the complete source code (zip and attach the zip to your reply), and describe how you compiled and linked the program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
First of all, I believe we have an example for Sparse QR functionality (look in examples/spblasc). In the example sparse_d_qr.c you can find an example of the usage. As it follows from there, when solving Ax = b with x and b being vectors, the call looks like this:
mkl_sparse_d_qr( SPARSE_OPERATION_NON_TRANSPOSE, csrA, descrA, SPARSE_LAYOUT_COLUMN_MAJOR, 1, x, ncols, b, nrows )
Hence, you need to set ldx = number of columns in the matrix, and ldb = number of rows in the matrix.
I hope this helps!
Best,
Kirill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page