blas daxpy dcopy函数的使用
来源:互联网 发布:手机编程用什么软件 编辑:程序博客网 时间:2024/06/05 02:07
关于blas和cblas的安装见CBLAS的安装使用。
daxpy函数的作用是将一个向量加上另一个向量的值,即:dy[i]=da*dx[i],其中da为常数,
函数的完整声明可以在cblas.h中看到,如下: void cblas_daxpy(const int N, const double alpha, const double *X, const int incX, double *Y, const int incY);
各个参数含义为:
int n; // array size double da; // double constant double *dx; // input double array int incx; // input stride double *dy; // output double array int incy; // output stride
dcopy函数的作为将一个向量赋值给另一个向量即:dy[i]=dx[i];函数的声明跟daxpy一致,只是少了常量da。
下面一个程序是这两个函数的一个举例:
#include <stdio.h>#include <stdlib.h>#include "cblas.h"int main(){ int n; /*! array size */ double da; /*! double constant */ double *dx; /*! input double array */ int incx; /*! input stride */ double *dy; /*! output double array */ int incy; /*! output stride */ int i; n = 10; da = 10; dx = (double*)malloc(sizeof(double)*n); incx = 1; dy = (double*)malloc(sizeof(double)*n); incy = 1; for(i=0;i<n;i++){ dx[i] = 9-i; dy[i] = i; printf("%f ",dy[i]); //输出原来的dy } printf("\n"); cblas_daxpy(n, da, dx,incx, dy, incy); //运行daxpy程序 // cblas_dcopy(n, dx,incx, dy, incy); //运行dcopy程序 for(i=0;i<n;i++){ printf("%f ",dy[i]); //输出计算后的dy } printf("\n"); return 0; }
参考:
http://www.netlib.org/blas/
http://www.netlib.org/blas/cblas.h
http://www.noao.edu/staff/mighell/mx/mx/src/sbin/mxsl_na/docs/html/daxpy_8c-source.html
注:
The benchmarks allowed us to vary the size of the vector used during execution, the number of iterations, and allowed us to control the throughput by sleeping between iterations.
0 0
- blas daxpy dcopy函数的使用
- daxpy dcopy计算
- Caffe BLAS Reference 对函数blas函数的说明
- Linux下BLAS的使用
- Blas 基本函数功能
- 常用 blas 函数
- 常用 blas 函数
- 常用 blas 函数
- Blas 基本函数功能
- spark1.2 使用breeze 的 netlib.BLAS 异常
- cafffe中常用 blas 函数
- BLAS
- BLAS CBLAS LAPACK编译使用
- 使用blas做矩阵乘法
- CUDA的BLAS数学库
- CUDA的BLAS数学库
- blas和lapack的安装
- blas和lapack的安装
- 一维、二维数组传参
- oracle中 connect by prior 递归算法
- CentOS 6.0 系统 LAMP(Apache+MySQL+PHP)安装步骤
- 笔记二ACProtect
- struts2国际化开发详细过程
- blas daxpy dcopy函数的使用
- iOS的UITableView的基础数据使用
- CodeForces 318D Ants
- 虚拟化技术
- Linux进程间通信——使用共享内存
- MTK 编译错误,perl 找不到 WIN32/OLE.pm
- TFTP协议的实现
- Linux进程间通信——使用消息队列
- CSU1204 Rectangles(二分)