我正在尝试使用两个任意长度的向量(典型长度为2048),并将元素与元素相乘。因此,对于所有n,Zn = Xn * Yn。
我设置用来测试的代码非常基本:
float inputX[4] = { 2, 4, 8, 16 };
float inputY[4] = { 2, 4, 8, 16 };
catlas_saxpby(4, 1, inputX, 1, 1, inputY, 1);结果进入inputY,结果是
4.000000, 8.000000, 16.000000, 32.000000如果是乘法,应该是4,16,64,256。但它看起来像是在添加。
因此,这并不是我所期望的,并且文档没有给我足够的信息来弄清楚它在做什么。
有什么想法吗?
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.发布于 2011-07-05 17:56:13
正如Adam Rosenfield所说,文档是不正确的。请提交bug。
抛开这一点,对他其余的回答有一些更正。首先,saxpby计算alpha * X + beta * Y。其次,也是对您更有用的: BLAS中没有做您想要的事情的函数,但在vDSP中确实有这样一个函数,它也是Accelerate.framework:vDSP_vmul的一部分。
https://stackoverflow.com/questions/6577899
复制相似问题