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
Débutant
2 602 Visites

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 Compliments
1 Solution
mecej4
Contributeur émérite III
2 602 Visites

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.

Voir la solution dans l'envoi d'origine

0 Compliments
6 Réponses
Steven_L_Intel1
Employé
2 602 Visites

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

0 Compliments
diedro
Débutant
2 602 Visites

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 Compliments
TimP
Contributeur émérite III
2 602 Visites

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

0 Compliments
mecej4
Contributeur émérite III
2 603 Visites

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 Compliments
JVanB
Précieux contributeur II
2 602 Visites

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 Compliments
diedro
Débutant
2 602 Visites

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 Compliments
Répondre