首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BLAS的catlas_saxpby不能正常工作的向量乘法

BLAS的catlas_saxpby不能正常工作的向量乘法
EN

Stack Overflow用户
提问于 2011-07-05 12:11:35
回答 1查看 1K关注 0票数 1

我正在尝试使用两个任意长度的向量(典型长度为2048),并将元素与元素相乘。因此,对于所有n,Zn = Xn * Yn。

我设置用来测试的代码非常基本:

代码语言:javascript
复制
float inputX[4] = { 2, 4, 8, 16 };
float inputY[4] = { 2, 4, 8, 16 };

catlas_saxpby(4, 1, inputX, 1, 1, inputY, 1);

结果进入inputY,结果是

代码语言:javascript
复制
4.000000, 8.000000, 16.000000, 32.000000

如果是乘法,应该是4,16,64,256。但它看起来像是在添加。

因此,这并不是我所期望的,并且文档没有给我足够的信息来弄清楚它在做什么。

有什么想法吗?

代码语言:javascript
复制
Apple's documentation for BLAS says this: 

Computes the product of two vectors, scaling each one separately (single-precision).

void catlas_saxpby (
   const int N,
   const float alpha,
   const float *X,
   const int incX,
   const float beta,
   float *Y,
   const int incY
);
Parameters
N
Number of elements in the vector.
alpha
Scaling factor for X.
X
Input vector X.
incX
Stride within X. For example, if incX is 7, every 7th element is used.
beta
Scaling factor for Y.
Y
Input vector Y.
incY
Stride within Y. For example, if incY is 7, every 7th element is used.
Discussion
On return, the contents of vector Y are replaced with the result.
EN

回答 1

Stack Overflow用户

发布于 2011-07-05 17:56:13

正如Adam Rosenfield所说,文档是不正确的。请提交bug。

抛开这一点,对他其余的回答有一些更正。首先,saxpby计算alpha * X + beta * Y。其次,也是对您更有用的: BLAS中没有做您想要的事情的函数,但在vDSP中确实有这样一个函数,它也是Accelerate.framework:vDSP_vmul的一部分。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6577899

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档