我试图有两个任意长度的向量(典型长度为 2048)并逐个元素相乘。所以 Z[n] = X[n] * Y[n] 对于所有 n。
我设置要测试的代码是相当基本的:
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.