我正在使用MKL库使用对角线格式执行稀疏矩阵向量乘法,当我使用MKL mkl_sdiagemv函数时,我得到“MKL错误:参数4在进入MKL_SDIAGEMV时不正确。 “错误。
答案 0 :(得分:1)
请参阅下面的一个基本示例,说明如何使用几个MKL稀疏矩阵向量积例程。
enter code #include <stdio.h>
#include "mkl_spblas.h"
#include "mkl_types.h"
#define NJOB 6
#define NZMAX 8
#define INFO 0
#define NNZ 8
#define N 4
#define M 4
#define NMETHODS 3
int main()
{
double Acoo[NZMAX] = {5.0, 8.0, 9.0, 2.0, 3.0, 6.0, 1.0, 4.0};
int AJ[NZMAX] ;
int AI[M+1];
int ir[NZMAX] = {1, 1, 2, 2, 3, 3, 4, 4};
int jc[NZMAX] = {1, 2, 1, 2, 3, 4, 3, 4};
double Acsr[NZMAX] ;
int n=N, info=INFO, nnz = NNZ;
int i, j;
int job[NJOB]={2,1,1,0,NZMAX,0};
int job1[NJOB]={0,1,1,0,0,10};
double Adia[N][N];
int ndiag = N;
int idiag = N;
int distance[N];
double *Acsr_rem=NULL;
int *AJ_rem=NULL;
int *AI_rem=NULL;
double v[N]={1.0,1.0,1.0,1.0};
double answer[NMETHODS][N];
int lval;
char transa = 'N';
mkl_dcsrcoo (job, &n, Acsr, AJ, AI, &nnz, Acoo, ir, jc, &info);
mkl_dcsrdia (job1, &n, Acsr, AJ, AI, *Adia, &ndiag, distance, &idiag, Acsr_rem, AJ_rem, AI_rem, &info);
mkl_ddiagemv (&transa, &n, *Adia, &ndiag, distance, &ndiag, v, answer[0]);
mkl_dcoogemv(&transa, &n, Acoo, ir, jc, &nnz, v, answer[1]);
mkl_dcsrgemv(&transa, &n, Acsr, AI, AJ, v, answer[2]);
}