Manual Reference Pages  - dprod (3fortran)

NAME

DPROD(3) - [NUMERIC] Double precision real product

SYNOPSIS

result = dprod(x,y)

         elemental function dprod(x,y)

real,intent(in) :: x real,intent(in) :: y doubleprecision :: dprod

CHARACTERISTICS

o X is a default real.
o Y is a default real.
o the result is a doubleprecision real.
The setting of compiler options specifying the size of a default real can affect this function.

DESCRIPTION

DPROD(3) produces a doubleprecision product of default real values X and Y.

That is, it is expected to convert the arguments to double precision before multiplying, which a simple expression X*Y would not be required to do. This can be significant in specialized computations requiring high precision.

The result has a value equal to a processor-dependent approximation to the product of X and Y. Note it is recommended in the standard that the processor compute the product in double precision, rather than in single precision then converted to double precision; but is only a recommendation.

OPTIONS

o X : the multiplier
o Y : the multiplicand

RESULT

The returned value of the product should have the same value as DBLE(X)*DBLE(Y).

EXAMPLES

Sample program:

    program demo_dprod
    implicit none
    integer,parameter :: dp=kind(0.0d0)
    real :: x = 5.2
    real :: y = 2.3
    doubleprecision :: xx
    real(kind=dp)   :: dd

print *,’algebraically 5.2 x 2.3 is exactly 11.96’ print *,’as floating point values results may differ slightly:’ ! basic usage dd = dprod(x,y) print *, ’compare dprod(xy)=’,dd, & & ’to x*y=’,x*y, & & ’to dble(x)*dble(y)=’,dble(x)*dble(y)

print *,’test if an expected result is produced’ xx=-6.0d0 write(*,*)DPROD(-3.0, 2.0),xx write(*,*)merge(’PASSED’,’FAILED’,DPROD(-3.0, 2.0) == xx)

print *,’elemental’ print *, dprod( [2.3,3.4,4.5], 10.0 ) print *, dprod( [2.3,3.4,4.5], [9.8,7.6,5.4] )

end program demo_dprod

Results: (this can vary between programming environments):

     >  algebraically 5.2 x 2.3 is exactly 11.96
     >  as floating point values results may differ slightly:
     >  compare dprod(xy)=   11.9599993133545      to x*y=   11.96000
     >  to dble(x)*dble(y)=   11.9599993133545
     >  test if an expected result is produced
     >   -6.00000000000000       -6.00000000000000
     >  PASSED
     >  elemental
     >    22.9999995231628     34.0000009536743     45.0000000000000
     >    22.5399999713898     25.8400004005432     24.3000004291534

STANDARD

FORTRAN 77

SEE ALSO

DBLE(3) REAL(3)

Fortran intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 dprod (3fortran) November 02, 2024
Generated by manServer 1.08 from e9d43dfd-543b-4606-91e4-d847a5f2076b using man macros.