使用 BLAS 将实数矩阵与复数向量相乘 [英] Multiplying real matrix with a complex vector using BLAS
问题描述
如何使用 Blas 将实矩阵与复向量相乘?当我使用 ccsrgemv() 之类的函数时,会出现类型不匹配错误?
How can I use Blas to multiply a real matrix with a complex vector ? When I use functions like ccsrgemv() I get type mismatch errors?
error: argument of type "float *" is incompatible with parameter of type "std::complex<float> *"
推荐答案
使用两个矩阵向量乘法 (A * (x + iy) = A * x + i A * y).更准确地说,将您的复向量视为步长为 2 的两个纠缠实向量.BLAS 可让您做到这一点.
Use two matrix-vector multiplications (A * (x + iy) = A * x + i A * y). More precisely, consider your complex vector as two entangled real vectors with stride 2. BLAS lets you do this.
更新:实际上,我没有注意到你在做 Sparse BLAS.对于 dgemv
我的技巧有效,但对于 csrgemv
则无效.恐怕你必须分别维护实部和虚部.
UPDATE: actually, I did not notice that you were doing Sparse BLAS. For dgemv
my trick works, but for csrgemv
it doesn't. I'm afraid you have to maintain real and imaginary part separately.
这篇关于使用 BLAS 将实数矩阵与复数向量相乘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!