Question

I got stuck with calling the MKL Blas function cblas_zgemv

There are two coeffitiens alpha and beta which are complex numbers:

alpha

REAL for sgemv

DOUBLE PRECISION for dgemv

COMPLEX for cgemv, scgemv

DOUBLE COMPLEX for zgemv, dzgemv

. But in the definition of the function:

void cblas_zgemv (const CBLAS_ORDER order, const CBLAS_TRANSPOSE TransA, 
const MKL_INT M, const MKL_INT N, const void *alpha, const void *A,
 const MKL_INT lda, const void *X, const MKL_INT incX, const void *beta, 
void *Y, const MKL_INT incY);

I have tried to set the alpha = complex(1.0,0) but this return me an error:

error: no suitable conversion function from "complex<double>" to "const void *" exists

What can I do? I don't understand what this const void* is...

Was it helpful?

Solution

The function expects a pointer to the complex value, not the value itself. You'll need a variable to store the value in, and then pass the address of that:

std::complex<double> alpha(1,0);
cblas_zgemv(..., &alpha, ...);

I believe this is safe since lapack_complex_double is layout-compatible with (and, in C++, is an alias for) std::complex<double>. To be on the safe side, you might prefer to use lapack_complex_double when calling that library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top