Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- sparse matrix dense matrix multiplication question

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

utab

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-25-2011
02:18 AM

43 Views

sparse matrix dense matrix multiplication question

I am trying to do a sparse matrix - dense matrix multiplication operation, however the below code does not give me what I want,

I use the sparse matrix that is used in the intel manual and examples and a dense matrix of

1 5

1 4

1 3

1 2

1 1

I guess my representation is correct in the code, however there is still sth wrong since I can not find the right answer. Could you please help me?

Best regards,

Umut

My code

#include

#include "mkl_types.h"

#include "mkl_spblas.h"

int main()

{

MKL_INT M = 5;

double values[] = {1.0, -1.0, -3.0, -2.0, 5.0, 4.0, 6.0, 4.0, -4.0, 2.0, 7.0, 8.0, -5.0};

MKL_INT columns[] = {0, 1, 3, 0, 1, 2, 3, 4, 0, 2, 3, 1, 4};

MKL_INT rowIndex[] = {0, 3, 5, 8, 11, 13};

MKL_INT pntrb[] = {0, 3, 5, 8, 11};

MKL_INT pntre[] = {3, 5, 8, 11, 13;

MKL_INT N = 2;

double b[] = {1.0, 5.0, 1.0, 4.0, 1.0, 3.0, 1.0, 2.0, 1.0,1.0};

double c[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,0.0};

char transa = 'N';

double alpha = 1.0;

double beta = 0.0;

char matdescra[6] = {'G','U','N','C',' ',' '};

mkl_dcsrmm(&transa, &M, &N, &M, α, matdescra, values, columns, pntrb, pntre, b, &N, β, c, &N);

// can not get the right result however.

for (int j = 0; j < M*N; j++) {

std::cout << c

}

return 0;

}

Link Copied

0 Replies

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.