BLAS中是否包含稀疏BLAS? [英] Is sparse BLAS not included in BLAS?

查看:253
本文介绍了BLAS中是否包含稀疏BLAS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作的LAPACK实现,就我所读,包含BLAS。

I have a working LAPACK implementation and that, as far as I read, contains BLAS.

我想使用SPARSE BLAS,而且据我理解这个网站,SPARSE BLAS是BLAS的一部分。

I want to use SPARSE BLAS and as far as I understand this website, SPARSE BLAS is part of BLAS.

但是当我试图运行下面的代码从稀疏blas手册使用

But when I tried to run the code below from the sparse blas manual using


g ++ -o sparse.x sparse_blas_example.c -L / usr / local / lib -lblas&& ./sparse_ex.x

g++ -o sparse.x sparse_blas_example.c -L/usr/local/lib -lblas && ./sparse_ex.x

编译器(或链接器?)要求blas_sparse.h。当我把这个文件放在工作目录中时:

the compiler (or linker?) asked for blas_sparse.h. When I put that file in the working directory I got:

ludi@ludi-M17xR4:~/Desktop/tests$ g++  -o sparse.x sparse_blas_example.c -L/usr/local/lib -lblas && ./sparse_ex.x
In file included from sparse_blas_example.c:3:0:
blas_sparse.h:4:23: fatal error: blas_enum.h: No such file or directory
 #include "blas_enum.h"

使用SPAPSE BLAS和LAPACK必须做什么? / strong>我可以开始移动很多头文件到工作目录,但我收集我已经有他们与lapack!

What must I do to use SPARSE BLAS with LAPACK? I could start moving a lot of header files to the working directory, but I gathered I already have them with lapack!

/* C example: sparse matrix/vector multiplication */

#include "blas_sparse.h"
int main()
{
const int n = 4;
const int nz = 6;
double val[] = { 1.1, 2.2, 2.4, 3.3, 4.1, 4.4 };
int indx[] = { 0, 1, 1, 2, 3, 3};
int jndx[] = { 0, 1, 4, 2, 0, 3};
double x[] = { 1.0, 1.0, 1.0, 1.0 };
double y[] = { 0.0, 0.0, 0.0, 0.0 };
blas_sparse_matrix A;
double alpha = 1.0;
int i;

/*------------------------------------*/
/* Step 1: Create Sparse BLAS Handle */
/*------------------------------------*/

A = BLAS_duscr_begin( n, n );

/*------------------------------------*/
/* Step 2: insert entries one-by-one */
/*------------------------------------*/

for (i=0; i< nz; i++)
{
BLAS_duscr_insert_entry(A, val[i], indx[i], jndx[i]);
}

/*-------------------------------------------------*/
/* Step 3: Complete construction of sparse matrix */
/*-------------------------------------------------*/
BLAS_uscr_end(A);

/*------------------------------------------------*/
/* Step 4: Compute Matrix vector product y = A*x */
/*------------------------------------------------*/

BLAS_dusmv( blas_no_trans, alpha, A, x, 1, y, 1 );

/*---------------------------------*/
/* Step 5: Release Matrix Handle */
/*---------------------------------*/

BLAS_usds(A);

/*---------------------------*/
/* Step 6: Output Solution */
/*---------------------------*/

for (i=0; i<n; i++) printf("%12.4g ",y[i]);
printf("\n");
return 0;
}


推荐答案

,而不是LAPACK参考。除了处理一些带状矩阵,LAPACK不包含稀疏矩阵的例程。还有其他实现,如 spblas 稀疏,遵循技术标准和实现稀疏BLAS。通常,稀疏运算不被视为BLAS的一部分,而是一个扩展。

You quote the Blas Technical Standard, not the LAPACK reference. LAPACK does not contain routines for sparse matrices, other than handling some banded matrices. There are other implementations such as spblas and sparse which follow the techincal standard and implement sparse BLAS. Typically, sparse operations are not considered part of BLAS, but an extension.

我建议使用更高级的库,例如 eigen ,因为它将为您节省大量的开发时间,通常是小的性能成本。还有 ublas 这是boost的一部分,所以如果你使用boost作为项目的一部分,你可以试试,虽然它不是真正的性能优化。您可以在此处找到完整列表(再次请注意,LAPACK未列为支持稀疏操作)。

I would recommend using a higher level library, such as eigen because it will save you a significant amount of development time, with usually small performance costs. There is also ublas which is part of boost, so if you are using boost as part of your project, you could give it a try, though it's not really optimised for performance. You can find a comprehensive list here (again, note that LAPACK is not listed as having support for sparse operations).

这篇关于BLAS中是否包含稀疏BLAS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆