您当前的位置: 首页 >  矩阵

稀疏矩阵CSR存储的C++实现

FPGA硅农 发布时间:2020-10-16 20:53:11 ,浏览量:3

实现了稀疏矩阵的生成(指定稀疏程度)、稀疏矩阵转换为CSR、从CSR中恢复出矩阵、稀疏矩阵和向量的乘法等功能。从运行结果来看,稀疏矩阵存储为CSR格式和向量相乘的运行速度快于普通矩阵向量乘法,而且稀疏程度越高,优势越明显。

#include
#include
#include
#include
typedef int dtype;
using namespace std;
void csr_to_matrix(dtype *value,dtype *colindex,dtype *rowptr,int n,int a,dtype** & M){
   M=new int*[n];
   for(int i=0;i            
关注
打赏
1688896170
查看更多评论
0.0514s