Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
6590 Discussions

mkl routines for upper triangular matrices

numerix1
Beginner
252 Views

Dear MKL users,

I am a bit confused with how to use mkl routines for upper triangular matrices. For example. I have the matrix:

1.000000  2.000000  3.000000  
0.000000  4.000000  5.000000  
0.000000  0.000000  8.000000

which I store row major format via:

the array data of size num_columns by num_rows with entry i,j stored as

data[i*num_cols + j] = value

I store the full matrix, even the zeros. Then I call the following to get the inverse:

LAPACKE_dtrtri( LAPACK_ROW_MAJOR, 'U', 'N', num_column, data, num_columns);

this Lapacke routine works fine and data is overwritten with the inverse matrix, as expected.

Now I would like to solve the system A x = b with

double b[3] = {1.,2.,3.}

cblas_dtrsv (CblasRowMajor, 'u', 'n', 'n', 3, data, 3, b, 1);

but the output is always:

Intel MKL ERROR: Parameter 2 was incorrect on entry to cblas_dtrsv

I tried to store only the nonzero elements in data, i.e. change the data array to be 

double data[6] = {1.,2.,3.,4.,5.,8.}

but I still get the same error. Can someone explain how I must define my matrix to be recognized as upper triangular for the cblas routine and how the cblas routines are different from the Lapacke ones?

thanks very much

0 Kudos
2 Replies
mecej4
Black Belt
252 Views

Please use the enum constants as named at https://software.intel.com/en-us/node/468386. The MKL documentation is, I think, misleading in that it seems to say that the values 'U' and 'N' are suitable for the Cblas_?trsv argument Uplo, just the same as for the Fortran BLAS routine ?trsv argument uplo. In your program, use

cblas_dtrsv(CblasRowMajor, CblasUpper, CblasNoTrans, CblasNonUnit, 3, A, 3, b, 1);

and you will not only get the correct behavior, but the source code will also have better readability.

numerix1
Beginner
252 Views

Replacing the characters by the enum constants fixed it. Thank you!

Reply