basic_m Module

This file defines a module containing the machine size of single-precision, double-precision, and quadruple-precision floating point numbers; to declare the floating point precision of a variable, use real(sp), real(dp), or real(qp) as the type of the variable. It also defines the working-precision, which will be the default kind for module procedures. As for module procedures, this library defines some common utility functions for working with e.g. complex numbers.



Contents


Variables

TypeVisibility AttributesNameInitial
integer, public, parameter:: sp =real32

Single precision

integer, public, parameter:: dp =real64

Double precision

integer, public, parameter:: qp =real128

Quadruple precision

integer, public, parameter:: wp =dp

Working precision

real(kind=wp), public, parameter:: inf =huge(1.0_wp)

Numerical infinity

real(kind=wp), public, parameter:: eps =epsilon(1.0_wp)

Numerical infinitesimal

real(kind=wp), public, parameter:: pi =atan(1.0_wp)*4.0_wp

Circle constant


Functions

public pure elemental function re(z) result(x)

Returns the real part of a complex number z=x+iy.

Read more…

Arguments

Type IntentOptional AttributesName
complex(kind=wp), intent(in) :: z

Complex number

Return Value real(kind=wp)

Real part

public pure elemental function im(z) result(y)

Returns the imaginary part of a complex number z=x+iy.

Read more…

Arguments

Type IntentOptional AttributesName
complex(kind=wp), intent(in) :: z

Complex number

Return Value real(kind=wp)

Imaginary part

public pure elemental function cx(x, y) result(z)

Returns the complex number z=x+iy.

Arguments

Type IntentOptional AttributesName
real(kind=wp), intent(in) :: x

Real part

real(kind=wp), intent(in), optional :: y

Imaginary part

Return Value complex(kind=wp)

Complex number

public pure elemental function arg(z) result(t)

Returns the complex argument θ of a complex number z=r·exp(iθ).

Arguments

Type IntentOptional AttributesName
complex(kind=wp), intent(in) :: z

Complex number

Return Value real(kind=wp)

Complex argument

public pure function unitvector(v) result(r)

If the argument has a finite norm, then it will be rescaled to a unit vector. If that norm is zero, then a zero vector is returned instead.

Arguments

Type IntentOptional AttributesName
real(kind=wp), intent(in), dimension(3):: v

Vector

Return Value real(kind=wp), dimension(3)

Unit vector

public pure function nonzero(v) result(r)

Checks whether or not the argument has a finite norm.

Arguments

Type IntentOptional AttributesName
real(kind=wp), intent(in), dimension(:):: v

Vector

Return Value logical

Finite