Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Dot product of complex and real

iswandi
Beginner
1,290 Views

I had some strange result when I compiled my program that contains the dot product of complex matrix and real matrix. Below the example of the program PROGRAM test_dotproduct IMPLICIT NONE REAL :: c(3) COMPLEX :: a(3),b a(1) = CMPLX(1,1) a(2) = CMPLX(2,2) a(3) = CMPLX(4,4) c(1) = 1 c(2) = 0 c(3) = 0 b = DOT_PRODUCT(a,c) write(*,*) 'b = DOT_PRODUCT(a,c)' and the result was: Result of b: (1.000000,-1.000000) The imaginary part of the result should be positif, but I dont know why I got negative ones. is there any body have the similar problems...? As information, I compiled my program on Intel Fortran under linux with non commercial version. regards Iswandi

0 Kudos
1 Reply
Intel_C_Intel
Employee
1,290 Views

Dear Iswandi,

Note that the DOT_PRODUCT on complex data is defined as follows:

SUM( CONJG(VECTOR_A) * VECTOR_B)

(and not simply as sumof pair-wise products).So, in your example:

CONJG(a(1)) *c(1) + 0 + 0 = (1,-1)

Hope this makes more sense now.

Aart Bik
http://www.aartbik.com/

Message Edited by abik on 04-18-2005 10:56 AM

0 Kudos
Reply