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

norm2 for complex vectors

diedro
Beginner
2,596 Views

dear all,

I usually use NORM2 to compute the error in a while cycle.

However, I have complex vector now and NORM2 does not work.

Is there any norm2 function for complex vectors?

Thanks 

0 Kudos
1 Solution
mecej4
Honored Contributor III
2,596 Views

There is a routine NRM2 in MKL, of which the flavors SCNRM2 and DZNRM2  pertain to complex vectors. There is an overloaded routine NRM2 available through the F95 interface.

View solution in original post

0 Kudos
6 Replies
Steven_L_Intel1
Employee
2,596 Views

Not in the Fortran standard - NORM2 is defined for REAL only.

0 Kudos
diedro
Beginner
2,596 Views

Dear all, Dear Steve,

Ok. Do you have some suggestion to overcome this?

this is my code, I use norm2 to compute the error:

 DO WHILE(NORM(R1)>=eps*NORM(BBg))
        !
        P1 = R1 + beta0*P0
       !
       ........
       ........
      .........
   ENDDO
    

where R1 and BBg are complex vectors

Thanks for any help

0 Kudos
TimP
Honored Contributor III
2,596 Views

You'd have to specify explicitly how you want NORM calculated.
 

0 Kudos
mecej4
Honored Contributor III
2,597 Views

There is a routine NRM2 in MKL, of which the flavors SCNRM2 and DZNRM2  pertain to complex vectors. There is an overloaded routine NRM2 available through the F95 interface.

0 Kudos
JVanB
Valued Contributor II
2,596 Views

I can't understand at all why NORM2 for complex input isn't in the standard. Stuff like NORM2(transfer(x,[real(kind(x))::])) or NORM2([NORM2(real(x)),NORM2(aimag(x))]) is possible.

0 Kudos
diedro
Beginner
2,596 Views

Dear all,

thanks a lot. 

NRM2 and NORM2([NORM2(real(x)),NORM2(aimag(x))]) work for me.

I have only to compute the difference between two complex vectors

thanks again

0 Kudos
Reply