6

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> *"
Tarek
  • 1,060
  • 4
  • 17
  • 38

1 Answers1

5

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.

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.

Alexandre C.
  • 55,948
  • 11
  • 128
  • 197
  • If I were to multiply a transpose of a complex dense vector with a dense real matrix (q = c^T * A), I'd use `sgemm()`/`dgemm()` routine: `call SGEMM('N', 'N', 2, N, N, 1.0, c, 2, A, N, 0.0, q, 2)` (in Fortran). – Alexander Pozdneev Dec 01 '16 at 20:50