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

mkl_dcsrmv() gives wierd result

agnonchik
Beginner
360 Views
Hi,
Could you check the following example?

void test_mkl_dcsrmv()
{
// |1 1||0|=|1|
// |0 1||1| |1|

int size = 2;
double one = 1.0;
double entries[] = {1.0, 1.0, 1.0};
int adjncy[] = {0, 1, 1};
int pntrb[] = {0, 2};
int pntre[] = {1, 2};
double x[] = {0.0, 1.0};
double y[] = {0.0, 0.0};
// y = alpha*A*x + beta*y
mkl_dcsrmv("N", &size, &size, &one, "G**C", entries, adjncy, pntrb, pntre,
x, &one, y);
std::cout << "y=[" << y[0] << "," << y[1] << "]\n";
// Should print "y=[1,1]". Right?
}

As a matter of fact, it prints "y=[0,0]". Why????

Thanks!
0 Kudos
2 Replies
Sergey_K_Intel1
Employee
360 Views
Quoting - agnonchik
Hi,
Could you check the following example?

void test_mkl_dcsrmv()
{
// |1 1||0|=|1|
// |0 1||1| |1|

int size = 2;
double one = 1.0;
double entries[] = {1.0, 1.0, 1.0};
int adjncy[] = {0, 1, 1};
int pntrb[] = {0, 2};
int pntre[] = {1, 2};
double x[] = {0.0, 1.0};
double y[] = {0.0, 0.0};
// y = alpha*A*x + beta*y
mkl_dcsrmv("N", &size, &size, &one, "G**C", entries, adjncy, pntrb, pntre,
x, &one, y);
std::cout << "y=[" << y[0] << "," << y[1] << "]n";
// Should print "y=[1,1]". Right?
}

As a matter of fact, it prints "y=[0,0]". Why????

Thanks!
Hello,

The representation ofyour matrix in CSR fromat is not correct in your program. In your case, the values of thearray pntre must be

int pntre[] = {2, 3};

intead of your setting

int pntre[] = {1, 2};

If we replace the values of pntre by {2, 3 }, we get y=[1,1] as it should be.

All the best
Sergey
0 Kudos
agnonchik
Beginner
360 Views
Thanks, Sergey!
Now it works.
0 Kudos
Reply