学习OpenBlas
来源:互联网 发布:js原型和原型链 面试题 编辑:程序博客网 时间:2024/06/07 00:45
编译
从OpenBlas Home Page 上下载源码,make, make install
使用
level 1 向量-向量 操作
#include <iostream>#include "cblas.h"#include <vector>int main(){ blasint n = 10; blasint in_x =1; blasint in_y =1; std::vector<double> x(n); std::vector<double> y(n); double alpha = 10; std::fill(x.begin(),x.end(),1.0); std::fill(y.begin(),y.end(),2.0); cblas_daxpy( n, alpha, &x[0], in_x, &y[0], in_y); //Print y for(int j=0;j<n;j++) std::cout << y[j] << "\t"; std::cout << std::endl;}
cblas_daxpy实现了求数乘和
level 2 矩阵-向量 操作
int i=0; double x[2] = {1.0,2.0}; double y[2] = {2.0,1.0}; double A[4] = {2.0,4.0,6.0,8.0}; cblas_dger(CblasColMajor,2,2,10,x,1,y,1,A,2); for(i=0; i<4; i++) std::cout << A[i] << " "; std::cout << std::endl;
cblas_dger实现了
level 3 矩阵-矩阵 操作
int i=0; double A[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0}; double B[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0}; double C[9] = {.5,.5,.5,.5,.5,.5,.5,.5,.5}; cblas_dgemm(CblasColMajor, //列优先 CblasNoTrans, CblasTrans,3,3,2,1,A, 3, B, 3,2,C,3); for(i=0; i<9; i++) std::cout << C[i] << " "; std::cout << std::endl;
cblas_dgemm 执行
附一张blas函数表
参考
-stanford·using OpenBlas
-OpenBlas User Manual
0 0
- 学习OpenBlas
- openblas
- openblas windows
- openblas windows
- 编译OpenBLAS
- caffe + openblas
- ubuntu openblas
- 【神经网络与深度学习】【C/C++】比较OpenBLAS,Intel MKL和Eigen的矩阵相乘性能
- openblas+lapack numpy scipy
- OpenBlas编译方法
- OpenBlas编译方法
- windows下Armadillo+openBlas
- 安装OpenBlas (ubuntu 14.04)
- OpenBLAS安装手册
- OpenBlas库----cblas_dgemm()函数
- OpenBlas, Neon & VFP
- Link OpenBLAS to armadillo
- 安装OpenBlas(ubuntu 14.04)
- java根据图片的URL下载图片
- Android Studio 系列文章(1)—开发环境的安装
- STL总结
- Myeclipse:Could not create the view:An unexpected exception was thrown问题
- hdu3251 最小割
- 学习OpenBlas
- STL vector按多字段值排序
- windows cmd
- 经典SQL学习笔记 (六)-用户管理、视图、序列、索引、权限
- videobuf处理流程
- 类和动态内存管理注意的几个问题
- iOS上使用自定义ttf字体
- git常用回滚命令
- 字符串过滤C++实现