我想要有兩個任意長度的向量(典型長度將是2048)並且乘以元素。所以對於所有n,Z [n] = X [n] * Y [n]。向量乘BLAS'catlas_saxpby不能正常工作
我所建立的測試代碼是相當簡單:
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.
我想我會卡住使用霓虹燈內部函數或for循環。我可能會嘗試兩種方法,看看更快。 –