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
Principiante
3.483 Vistas

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 Solución
mecej4
Colaborador Distinguido III
3.483 Vistas

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.

Ver la solución en mensaje original publicado

6 Respuestas
Steven_L_Intel1
Empleados
3.483 Vistas

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

diedro
Principiante
3.483 Vistas

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

TimP
Colaborador Distinguido III
3.483 Vistas

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

mecej4
Colaborador Distinguido III
3.484 Vistas

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.

JVanB
Colaborador Valioso II
3.483 Vistas

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.

diedro
Principiante
3.483 Vistas

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

Responder