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

The LAPACKE_dtfsm() function

Malc
Beginner
468 Views

I'm trying to use the LAPACKE_dtfsm(..) function to give me a result using these two matrices

 

double a[4] = { 590.96819903509447, 0.0,
0.0, 72662.562467553944 };

 

double b[8] = { -174621.706135389, -1305297.25336182, -174621.706135394, 1305297.25336182,
1305297.25336182, -2620409798.2378, -1305297.25336182, -2620409798.23788 };

I've used LAPACKE_dtrttf(LAPACK_ROW_MAJOR, 'N', 'U', 2, a, 2, arp) to convert 'a' into a rectangular full format matrix, arp

then called 

LAPACKE_dtfsm(LAPACK_ROW_MAJOR, 
'N', 
'L', 
'U', 
'T', 
'N', 
2, 
4, 
1.0, 
arp, 
b,
4);

 

but it doesn't give the correct answer.

 

Using matrices the full matrix a and b and calling 

 

cblas_dtrsm(CblasRowMajor, CblasLeft, CblasUpper, CblasTrans, CblasNonUnit, 2, 4, 1.0, a, 2, b, 4);

 

gives me the expected answer.

 

Could anyone help me get the call to the LAPACKE_dtfsm(..) function correct?

0 Kudos
1 Solution
Fengrui
Moderator
325 Views

Hi Malc,


The results of trsm and tfsm are the same in my test.

Please try the following test code:

------------------------------------------------------

#include <iostream>

#include "mkl.h"


int main()

{

  double a[4] = { 590.96819903509447, 0.0, 0.0, 72662.562467553944 };

  double b[12] = {-174621.706135389, 1305297.25336182, -1305297.25336182, -2620409798.2378, -174621.706135394, -1305297.25336182, 1305297.25336182, -2620409798.2378};

  double b_trsm[12] = {-174621.706135389, 1305297.25336182, -1305297.25336182, -2620409798.2378, -174621.706135394, -1305297.25336182, 1305297.25336182, -2620409798.2378};

  double arp[3];


  cblas_dtrsm(CblasColMajor, CblasLeft, CblasUpper, CblasTrans, CblasNonUnit, 2, 4, 1.0, a, 2, b_trsm, 2);


  for(int i=0; i<8; i++)

    std::cout << "b_trsm[" << i << "] = " << b_trsm[i] << std::endl;


  std::cout << "Using compact format" << std::endl;


  lapack_int info = 1;

  info = LAPACKE_dtrttf(LAPACK_COL_MAJOR, 'N', 'U', 2, a, 2, arp);


  for(int i=0; i<3; i++)

    std::cout << "arp[" << i << "] = " << arp[i] << std::endl;


  std::cout << "DTRTTF info = " << info << std::endl;

  info = 1;

  info = LAPACKE_dtfsm(LAPACK_COL_MAJOR, 'N', 'L', 'U', 'N', 'N', 2, 4, 1.0, arp, b, 2);

  std::cout << "DTFSM info = " << info << std::endl;


  for(int i=0; i<8; i++)

    std::cout << "b[" << i << "] = " << b[i] << std::endl;


  return 0;

}

------------------------------------------------------

The input has been transposed to be consistent with the original row-major layout.


Thanks,

Fengrui


View solution in original post

0 Kudos
4 Replies
Fengrui
Moderator
387 Views

Hello, it looks that there is a product issue with dtfsm when using the row-major layout, while the column-major layout gives the same results as dtrsm. I will escalate this issue to the product team. At the same time, could you please try the column-major layout?


Thanks,

Fengrui


0 Kudos
Malc
Beginner
338 Views

Hi Fengrui

 

Thanks for looking into this for me. I've tried using column major layout and while it calculates all the correct values they don't come back in the same order as the cblas_dtrsm(...) function call. 

 

For the 8 values in matrix b

dtrsm order [0, 1, 2, 3, 4, 5, 6, 7]

dtfsm order [0, 6, 2, 4, 3, 5, 1, 7]

 

1 and 6 and 3 and 4 have been swapped around. Did the values come back in the same order for you?

 

Thanks again

 

Malc

0 Kudos
Fengrui
Moderator
326 Views

Hi Malc,


The results of trsm and tfsm are the same in my test.

Please try the following test code:

------------------------------------------------------

#include <iostream>

#include "mkl.h"


int main()

{

  double a[4] = { 590.96819903509447, 0.0, 0.0, 72662.562467553944 };

  double b[12] = {-174621.706135389, 1305297.25336182, -1305297.25336182, -2620409798.2378, -174621.706135394, -1305297.25336182, 1305297.25336182, -2620409798.2378};

  double b_trsm[12] = {-174621.706135389, 1305297.25336182, -1305297.25336182, -2620409798.2378, -174621.706135394, -1305297.25336182, 1305297.25336182, -2620409798.2378};

  double arp[3];


  cblas_dtrsm(CblasColMajor, CblasLeft, CblasUpper, CblasTrans, CblasNonUnit, 2, 4, 1.0, a, 2, b_trsm, 2);


  for(int i=0; i<8; i++)

    std::cout << "b_trsm[" << i << "] = " << b_trsm[i] << std::endl;


  std::cout << "Using compact format" << std::endl;


  lapack_int info = 1;

  info = LAPACKE_dtrttf(LAPACK_COL_MAJOR, 'N', 'U', 2, a, 2, arp);


  for(int i=0; i<3; i++)

    std::cout << "arp[" << i << "] = " << arp[i] << std::endl;


  std::cout << "DTRTTF info = " << info << std::endl;

  info = 1;

  info = LAPACKE_dtfsm(LAPACK_COL_MAJOR, 'N', 'L', 'U', 'N', 'N', 2, 4, 1.0, arp, b, 2);

  std::cout << "DTFSM info = " << info << std::endl;


  for(int i=0; i<8; i++)

    std::cout << "b[" << i << "] = " << b[i] << std::endl;


  return 0;

}

------------------------------------------------------

The input has been transposed to be consistent with the original row-major layout.


Thanks,

Fengrui


0 Kudos
Malc
Beginner
291 Views

Hi Fengrui

 

I can confirm that the results match with the transposed input.

 

Thanks again,

 

Malc

0 Kudos
Reply