math Module

This module contains some useful mathematical functions.

The following functions are provided:

  • norm - standard L2 norm of a vector
  • norm2 - standard L2 norm of a vector squared
  • cross_product - cross product in R3
  • outer_product - outer product
  • deg2rad - conversion from degrees to radians
  • rad2deg - conversion from radians to degrees
  • sind - sine of x in degrees
  • cosd - cosine of x in degrees
  • tand - tangents of x in degrees
  • asind - inverse sine of x, result in degrees
  • acosd - inverse cosine of x, result in degrees
  • atand - inverse tangents of x, result in degrees
  • atan2d - inverse tangents of y/x (see atan2), result in degrees

The following types are provided:


Uses


Variables

Type Visibility Attributes Name Initial
real(kind=rkind), public, parameter :: pi = 3.14159265358979323846_rkind

value of


Interfaces

public interface ramp_function_t

Create a new ramp function with given start, duration, y1 and y2

  • private function new_ramp_function_t(start, duration, y1, y2) result(f)

    Create a new ramp function with given start, duration, y1 and y2

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rkind), intent(in) :: start
    real(kind=rkind), intent(in) :: duration
    real(kind=rkind), intent(in) :: y1
    real(kind=rkind), intent(in) :: y2

    Return Value type(ramp_function_t)


Derived Types

type, public ::  function1_t

Abstract type for 1D functions

Read more…

Type-Bound Procedures

procedure(at), public, deferred :: at

evaluates the function at given x

type, public, extends(function1_t) ::  ramp_function_t

Ramp function linearly changes the value from y1 to y2.

Read more…

Components

Type Visibility Attributes Name Initial
real(kind=rkind), public :: duration
real(kind=rkind), public :: start
real(kind=rkind), public :: y1
real(kind=rkind), public :: y2

Constructor

Create a new ramp function with given start, duration, y1 and y2

private function new_ramp_function_t (start, duration, y1, y2)

Create a new ramp function with given start, duration, y1 and y2

Type-Bound Procedures

procedure, public :: at => ramp_function_at

Functions

public elemental function acosd(x) result(y)

Inverse cosine of x, result in degrees

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: x

Return Value real(kind=rkind)

public elemental function asind(x) result(y)

Inverse sine of x, result in degrees

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: x

Return Value real(kind=rkind)

public elemental function atan2d(y, x) result(a)

Inverse tangents of y/x (see atan2d), result in degrees

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: y
real(kind=rkind), intent(in) :: x

Return Value real(kind=rkind)

public elemental function atand(x) result(y)

Inverse tangents of x, result in degrees

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: x

Return Value real(kind=rkind)

public elemental function cosd(x) result(y)

Cosine of x in degrees

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: x

Return Value real(kind=rkind)

public pure function cross_product(u, v) result(c)

Cross product in R3

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: u(3)
real(kind=rkind), intent(in) :: v(3)

Return Value real(kind=rkind), (3)

public elemental function deg2rad(deg) result(rad)

Conversion from degrees to radians

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: deg

Return Value real(kind=rkind)

public pure function norm(x) result(d)

Standard L2 norm of a vector

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: x(:)

Return Value real(kind=rkind)

public pure function norm2(x) result(d)

Standard L2 norm of a vector squared

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: x(:)

Return Value real(kind=rkind)

public pure function outer_product(u, v) result(o)

Outer product

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: u(:)
real(kind=rkind), intent(in) :: v(:)

Return Value real(kind=rkind), (size(u),size(v))

public elemental function rad2deg(rad) result(deg)

Conversion from radians to degres

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: rad

Return Value real(kind=rkind)

public elemental function sind(x) result(y)

Sine of x in degrees

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: x

Return Value real(kind=rkind)

public elemental function tand(x) result(y)

Tangents of x in degrees

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rkind), intent(in) :: x

Return Value real(kind=rkind)