6

Having two complex arrays of dimension 2 I want to calculate a point wise multiplication (Hadamard product):

complex(8) :: A(N,N), B(N,N), C(N,N)
...
do j = 1, N
  do i = 1, N
    C(i,j) = A(i,j)*B(i,j)
  enddo
enddo

Is there any BLAS routine to optimize that or is this actually already the most efficient way to write the Hadamard product? Or does the compiler do the job for me in such a simple case?

I code in Fortran so the first index is the fast index.

thyme
  • 388
  • 5
  • 18
  • 4
    By searching the net, it seems that some vendor extensions of BLAS/LAPACK are available (e.g., zhad in SGI? and [v?Mul in MKL](http://stackoverflow.com/questions/23794763/element-wise-multiplication-between-matrices-in-blas), and cuda), but not in the standard BLAS...? Some related page I found is [this](https://github.com/xianyi/OpenBLAS/issues/1083). According to this [page](http://stackoverflow.com/questions/7621520/element-wise-vector-vector-multiplication-in-blas), it might be an option to use "diag-matrix x vector" as a workaround... – roygvib Mar 07 '17 at 20:26

0 Answers0