Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 ディスカッション

norm2 for complex vectors

diedro
ビギナー
2,619件の閲覧回数

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 件の賞賛
1 解決策
mecej4
名誉コントリビューター III
2,619件の閲覧回数

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.

元の投稿で解決策を見る

6 返答(返信)
Steven_L_Intel1
従業員
2,619件の閲覧回数

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

diedro
ビギナー
2,619件の閲覧回数

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
名誉コントリビューター III
2,619件の閲覧回数

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

mecej4
名誉コントリビューター III
2,620件の閲覧回数

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
高評価コントリビューター II
2,619件の閲覧回数

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
ビギナー
2,619件の閲覧回数

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

返信