- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
For years I have used DIMAG to extract the imaginary part of a double precision complex number and store it into a double precision real.
I am trying nowtocode with keeping portability in mind (using parameterized real kinds, for instance).
For the real part, one can write the following:
INTEGER,PARAMETER :: DP = SELECTED_REAL_KIND(15,100) ! (This definition can go into a module...)
REAL(DP) R
COMPLEX(DP) C
R = REAL(C,KIND=DP)
But what about the same kind of construct for the imaginary part? There is no IMAG generic function that can be used with the same syntax, only type specific functions such as DIMAG and so on...
Is there another way to do this, without resorting to type specific functions such as AIMAG, DIMAG ... a solution which defeats the portability purpose?
Thanks!!
- Balises:
- Intel® Fortran Compiler
Lien copié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
AIMAG is the generic name.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Consider creating a GENERIC INTERFACE which returns the imaginary part of the complex number in the same precision of the complex number
FUNCTION IMAGINARY_SP(C)
REAL(SP) :: IMAGINARY_SP
COMPLEX(SP) :: C
IMAGINARY_SP = REAL(C,KIND=SP)
END FUNCTION IMAGINARY_SP
FUNCTION IMAGINARY_DP(C)
REAL(DP) :: IMAGINARY_DP
COMPLEX(DP) :: C
IMAGINARY_DP = REAL(C,KIND=DP)
END FUNCTION IMAGINARY_DP
...
INTERFACE IMAGINARY
FUNCTION IMAGINARY_SP(C)
REAL(SP) :: IMAGINARY_SP
COMPLEX(SP) :: C
END FUNCTION IMAGINARY_SP
FUNCTION IMAGINARY_DP(C)
REAL(DP) :: IMAGINARY_DP
COMPLEX(DP) :: C
END FUNCTION IMAGINARY_DP
END INTERFACE IMAGINARY
Jim Dempsey

- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable