Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiplying real matrix with a complex vector using BLAS

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> *"
like image 223
Tarek Avatar asked Oct 01 '11 09:10

Tarek


People also ask

What is the complexity of matrix-vector multiplication?

In terms of serial complexity, the matrix-vector multiplication is qualified as a quadratic complexity algorithm (or a bilinear complexity algorithm if the matrix is rectangular).

How do you multiply a vector times a matrix?

First, multiply Row 1 of the matrix by Column 1 of the vector. Next, multiply Row 2 of the matrix by Column 1 of the vector. Finally multiply Row 3 of the matrix by Column 1 of the vector.

What happens when a matrix is multiplied with a vector?

Matrix-vector product So, if A is an m×n matrix (i.e., with n columns), then the product Ax is defined for n×1 column vectors x. If we let Ax=b, then b is an m×1 column vector. In other words, the number of rows in A (which can be anything) determines the number of rows in the product b.


1 Answers

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.

like image 78
Alexandre C. Avatar answered Sep 17 '22 13:09

Alexandre C.