Manual Reference Pages  - aimag (3fortran)

NAME

AIMAG(3) - [TYPE:CONVERSION] Imaginary part of complex number

SYNOPSIS

result = aimag(z)

         elemental function aimag(z)

complex(kind=KIND) aimag complex(kind=KIND),intent(in) :: z

CHARACTERISTICS

o The type of the argument Z is complex. It may be of any supported complex kind
o The return value is of type real with the kind type parameter of the argument Z.

DESCRIPTION

AIMAG(3) yields the imaginary part of the complex argument Z.

This is similar to the modern complex-part-designator %IM which also designates the imaginary part of a value, accept a designator is treated as a variable. This means it may appear on the left-hand side of an assignment as well, as in VAL%IM=10.0 or as an argument in a procedure call that will act as a typical variable passed by reference.

OPTIONS

o Z : The complex value to extract the imaginary component of.

RESULT

The return value is a real value with the magnitude and sign of the imaginary component of the argument Z.

That is, If Z has the value (X,Y), the result has the value Y.

EXAMPLES

Sample program:

    program demo_aimag
    use, intrinsic :: iso_fortran_env, only : real32, real64, real128
    implicit none
    character(len=*),parameter :: it=’(*(1x,g0))’
    integer              :: i
    complex              :: z4
    complex              :: arr(3)
    complex(kind=real64) :: z8

print it, ’basics:’

z4 = cmplx(1.e0, 2.e0) print *, ’value=’,z4 print it, ’imaginary part=’,aimag(z4),’or’, z4%im

print it, ’kinds other than the default may be supported’

z8 = cmplx(3.e0_real64, 4.e0_real64,kind=real64) print *, ’value=’,z8 print it, ’imaginary part=’,aimag(z8),’or’, z8%im

print it, ’an elemental function can be passed an array’ print it, ’given a complex array:’

arr=[z4,z4/2.0,z4+z4] print *, (arr(i),new_line(’a’),i=1,size(arr)) print it, ’the imaginary component is:’ print it, aimag( arr )

end program demo_aimag

Results:

     >  basics:
     >  value=             (1.00000000,2.00000000)
     >  imaginary part= 2.00000000 or 2.00000000
     >  kinds other than the default may be supported
     >  value=               (3.0000000000000000,4.0000000000000000)
     >  imaginary part= 4.0000000000000000 or 4.0000000000000000
     >  an elemental function can be passed an array
     >  given a complex array:
     >              (1.00000000,2.00000000)
     >             (0.500000000,1.00000000)
     >              (2.00000000,4.00000000)
     >
     >  the imaginary component is:
     >  2.00000000 1.00000000 4.00000000

STANDARD

FORTRAN 77

SEE ALSO

o CMPLX(3) - Complex conversion function
o CONJG(3) - Complex conjugate function
o REAL(3) - Convert to real type
Fortran has strong support for complex values, including many intrinsics that take or produce complex values in addition to algebraic and logical expressions:

ABS(3), ACOSH(3), ACOS(3), ASINH(3), ASIN(3), ATAN2(3), ATANH(3), ATAN(3), COSH(3), COS(3), CO_SUM(3), DBLE(3), DOT_PRODUCT(3), EXP(3), INT(3), IS_CONTIGUOUS(3), KIND(3), LOG(3), MATMUL(3), PRECISION(3), PRODUCT(3), RANGE(3), RANK(3), SINH(3), SIN(3), SQRT(3), STORAGE_SIZE(3), SUM(3), TANH(3), TAN(3), UNPACK(3),

Fortran intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 aimag (3fortran) February 19, 2025
Generated by manServer 1.08 from a424e88f-f155-4019-a3ae-0156b4cb7885 using man macros.