Quantcast
Channel: Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 2652

Problem with mkl_ddnscsr

$
0
0

Hello

I’ve been having some problems using the “mkl_ddnscsr” function. I’ve followed the example that comes with the library but it’s not working properly. I can retrieve the non-zero elements in the dense matrix but the row and column vectors are returned empty (all elements are zeros). Below you can find my code; it’s a simplified version of the example in “dconverters.c”. I also have another doubt, what would be the most efficient way to use this function when working with large matrices and the number of non-zero elements is unknown; one way could be to set the a really high number for the maximum number of non-zero elements but that could lead to pre-allocating large vectors. Any help would be much appreciated.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "mkl_types.h"
#include "mkl_spblas.h"

int main (void)
{

#define M      4
#define N      4
#define LDA    4
#define NZMAX  8
#define NNZ    8
#define MBLK   2
#define NN     2
#define INFO   0
#define MN     16
#define IBASE1 1
#define IBASE2 1
#define LOCAT  2
#define IDIAG 3
#define NDIAG 4
#define INDIA 12
int		m = M, n=N, lda=LDA, nzmax=NZMAX, nnz = NNZ, mblk=MBLK, nn=NN, info=INFO ,mn=MN;
int	    ibase1 = IBASE1, ibase2 = IBASE2, locat = LOCAT, idiag = IDIAG, ndiag = NDIAG;
double	Adns[MN];
double	Acsr[NZMAX];
int		AI[M+1];
int		AJ[NZMAX];
int		i, j;
int		job[8];

job[0]=0;
job[1]=0;
job[2]=1;
job[3]=2;
job[4]=NZMAX;
job[5]=3;

for ( j=0; j<n; j++)
         for ( i=0; i<m; i++)
               Adns[i + lda*j]=0.0;

      Adns[0]=5.0;
      Adns[1]=9.0;
      Adns[4]=8.0;
      Adns[5]=2.0;
      Adns[10]=3.0;
      Adns[11]=1.0;
      Adns[14]=6.0;
      Adns[15]=4.0;

mkl_ddnscsr(job,&m,&n,Adns,&lda,Acsr,AJ,AI,&info);

return 0;
}

 

Regards

lggs


Viewing all articles
Browse latest Browse all 2652

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>