TCCMaths_Functions

Purpose

This module supports mathematics

Module Parameters

-

Module depends on

TCCMaths_GenericTypes

Summary
TCCMaths_Functions This module supports mathematics
Functions
f_maxIL Return an IntegerList with the highest number found at index 0 and the index of ilist where it’s found at index 1
f_maxFL Return an FloatList with the highest number found at index 0 and the index of flist where it’s fond at index 1
f_minIL Return an IntegerList with the lowest number found at index 0 and the index of ilist where it’s fond at index 1
f_minFL Return an FloatList with the highest number found at index 0 and the index of flist where it’s fond at index 1
f_averageFL Return the average of flist
f_averageIL Return the average of ilist
f_updateFL Append tail to the end of head (head return as inout)
f_updateIL Append tail to the end of head (head return as inout)
f_stdFL Return the normalized standard devILtion of float list (so the average square distance from the center of elements in the list)
f_stdFLL Return the normalized standard devILtion of float list using custom center (so it is the average square distance from a user defined central value)
f_stdIL Return the normalized standard devILtion of integer list (so the average square distance from the center of points)
f_stdILL Return the normalized standard devILtion of integer list using custom center (so it is the average square distance from a user defined central value)
f_sinVL Return the values of the sine function
f_cosVL Return the values of the cosine function
f_sin Return the sine of angle radILns
f_cos Return the cosine of angle radILns
f_asin Return the arc sine of value in [-pi/2, +pi/2]
f_acos Return the arc cosine of value in [0, pi]
f_powFF Raise to power (float to float power)
f_powII Raise to power (integer to integer power)
f_powIF Raise to power (integer to float power)
f_powFI Raise to power (float to integer power)
f_sqrF Raise a float value to square
f_sqrI Raise an integer value to square
f_sqrtF Square root of float value
f_sqrtI Square root of integer value
f_ceil Return the smallest integer value that is not less then value
f_floor Return the largest integer value that is not greater then value
f_exp Return the exponential value of the argument
f_log Return the natural logarithm of the argument
f_generate_poissonTable Returns with an initialized poisson table which is a cumulative probability distribution list for a given lambda.
f_getNext_poissonValue Returns with a random poisson value by the given poisson table and lambda poisson variance.
f_gen_Exponential_Distribution(in float p_lambda) return float Returns with the exponential random variable for a given lambda

Functions

f_maxIL

external function f_maxIL( in  IntegerList  ilist ) return IntegerList

Purpose

Return an IntegerList with the highest number found at index 0 and the index of ilist where it’s found at index 1

Parameters

ilist in IntegerList - integer array

Return Value

<IntegerList> integer array: { <max>, <max index> }

Errors

-

Detailed description

-

f_maxFL

external function f_maxFL( in  FloatList  flist ) return FloatList

Purpose

Return an FloatList with the highest number found at index 0 and the index of flist where it’s fond at index 1

Parameters

flist in FloatList - integer array

Return Value

<FloatList> float array: { <max>, <max index> }

Errors

-

Detailed description

-

f_minIL

external function f_minIL( in  IntegerList  ilist ) return IntegerList

Purpose

Return an IntegerList with the lowest number found at index 0 and the index of ilist where it’s fond at index 1

Parameters

ilist in IntegerList - integer array

Return Value

<IntegerList> integer array: { <min>, <min index> }

Errors

-

Detailed description

-

f_minFL

external function f_minFL( in  FloatList  flist ) return FloatList

Purpose

Return an FloatList with the highest number found at index 0 and the index of flist where it’s fond at index 1

Parameters

flist in FloatList - integer array

Return Value

<FloatList> float array: { <min>, <min index> }

Errors

-

Detailed description

-

f_averageFL

external function f_averageFL( in  FloatList  flist ) return float

Purpose

Return the average of flist

Parameters

flist in FloatList - integer array

Return Value

float average of float numbers

Errors

-

Detailed description

-

f_averageIL

external function f_averageIL( in  IntegerList  ilist ) return float

Purpose

Return the average of ilist

Parameters

ilist in IntegerList - integer array

Return Value

float average of integer numbers

Errors

-

Detailed description

-

f_updateFL

external function f_updateFL( inout  FloatList  head,
in  FloatList  tail )

Purpose

Append tail to the end of head (head return as inout)

Parameters

head in FloatList - first part of the float list
tail in FloatList - second part of the float list

Return Value

-

Errors

-

Detailed description

-

f_updateIL

external function f_updateIL( inout  IntegerList  head,
in  IntegerList  tail )

Purpose

Append tail to the end of head (head return as inout)

Parameters

head in IntegerList - first part of the integer list
tail in IntegerList - second part of the integer list

Return Value

-

Errors

-

Detailed description

-

f_stdFL

external function f_stdFL( in  FloatList  flist ) return float

Purpose

Return the normalized standard devILtion of float list (so the average square distance from the center of elements in the list)

Parameters

flist in FloatList - float list

Return Value

float normalized, standard derivate

Errors

-

Detailed description

E.g.  list = {2.0, 4.0}

u = (2.0 + 4.0) / 2 <- center of elements in the list

len = sizeof(list)

[ ( (2.0-u)^2 + (4.0-u)^2 ) / len ] ^ (0.5)

f_stdFLL

external function f_stdFLL( in  FloatList  flist,
in  float  u ) return float

Purpose

Return the normalized standard devILtion of float list using custom center (so it is the average square distance from a user defined central value)

Parameters

u in float - user defined central value
flist in FloatList - float list

Return Value

float normalized, standard derivate

Errors

-

Detailed description

Note: u is the average value of flist and has to be calculated before a call to this function

E.g.  list = {2.0, 4.0}

u <- user input

len = sizeof(list)

[ ( (2.0-u)^2 + (4.0-u)^2 ) / len ] ^ (0.5)

f_stdIL

external function f_stdIL( in  IntegerList  ilist ) return float

Purpose

Return the normalized standard devILtion of integer list (so the average square distance from the center of points)

Parameters

ilist in IntegerList - integer list

Return Value

float normalized, standard derivate

Errors

-

Detailed description

E.g.  list = {2.0, 4.0}

u = (2.0 + 4.0) / 2 <- center of elements in the list

len = sizeof(list)

[ ( (2.0-u)^2 + (4.0-u)^2 ) / len ] ^ (0.5)

f_stdILL

external function f_stdILL( in  IntegerList  ilist,
in  float  u ) return float

Purpose

Return the normalized standard devILtion of integer list using custom center (so it is the average square distance from a user defined central value)

Parameters

u in float - user defined central value
ilist in IntegerList - integer list

Return Value

float normalized, standard derivate

Errors

-

Detailed description

Note: u is a user defined value

E.g.  list = {2.0, 4.0}

u <- user input

len = sizeof(list)

[ ( (2.0-u)^2 + (4.0-u)^2 ) / len ] ^ (0.5)

f_sinVL

external function f_sinVL( in  float  freq,
in  float  altitude,
in  float  start_val,
in  integer  len,
in  float  step ) return FloatList

Purpose

Return the values of the sine function

Parameters

freq in float - the frequency of the sine curve
altitude in float - the altitude of the sine curve
start_val in float - the starting value passed to the sine function
len in integer - the wanted number of points of the sine curve
step in float - the length between the points on the sine curve

Return Value

<FloatList> the wanted points in a float list

Errors

-

Detailed description

Generation of one sin value:

altitude * sin(2 * pi * freq * start_val)

start_val := start_val + step

f_cosVL

external function f_cosVL( in  float  freq,
in  float  altitude,
in  float  start_val,
in  integer  len,
in  float  step ) return FloatList

Purpose

Return the values of the cosine function

Parameters

freq in float - the frequency of the sine curve
altitude in float - the altitude of the sine curve
start_val in float - the starting value passed to the sine function
len in integer - the wanted number of points of the sine curve
step in float - the length between the points on the sine curve

Return Value

<FloatList> the wanted points in a float list

Errors

-

Detailed description

Generation of one cos value:

altitude * cos(2 * pi * freq * start_val)

start_val := start_val + step

f_sin

external function f_sin( in  float  angle ) return float

Purpose

Return the sine of angle radILns

Parameters

angle in float - angle in radILns

Return Value

float the sine value of angle radILns

Errors

-

Detailed description

-

f_cos

external function f_cos( in  float  angle ) return float

Purpose

Return the cosine of angle radILns

Parameters

angle in float - angle in radILns

Return Value

float the cosine value of angle radILns

Errors

-

Detailed description

-

f_asin

external function f_asin( in  float  val ) return float

Purpose

Return the arc sine of value in [-pi/2, +pi/2]

Parameters

val in float - value

Return Value

float the arc sine value of val

Errors

-

Detailed description

-

f_acos

external function f_acos( in  float  val ) return float

Purpose

Return the arc cosine of value in [0, pi]

Parameters

val in float - value

Return Value

float the arc cosine value of val

Errors

-

Detailed description

-

f_powFF

external function f_powFF( in  float  base,
in  float  expo ) return float

Purpose

Raise to power (float to float power)

Parameters

base in float - base value
expo in float - exponent value

Return Value

float base raised to power expo

Errors

-

Detailed description

-

f_powII

external function f_powII( in  integer  base,
in  integer  expo ) return integer

Purpose

Raise to power (integer to integer power)

Parameters

base in integer - base value
expo in integer - exponent value

Return Value

integer base raised to power expo

Errors

-

Detailed description

-

f_powIF

external function f_powIF( in  integer  base,
in  float  expo ) return float

Purpose

Raise to power (integer to float power)

Parameters

base in integer - base value
expo in float - exponent value

Return Value

float base raised to power expo

Errors

-

Detailed description

-

f_powFI

external function f_powFI( in  float  base,
in  integer  expo ) return float

Purpose

Raise to power (float to integer power)

Parameters

base in float - base value
expo in integer - exponent value

Return Value

float base raised to power expo

Errors

-

Detailed description

-

f_sqrF

external function f_sqrF( in  float  base ) return float

Purpose

Raise a float value to square

Parameters

base in float - base value

Return Value

float square of base

Errors

-

Detailed description

-

f_sqrI

external function f_sqrI( in  integer  base ) return integer

Purpose

Raise an integer value to square

Parameters

base in integer - base value

Return Value

integer square of base

Errors

-

Detailed description

-

f_sqrtF

external function f_sqrtF( in  float  base ) return float

Purpose

Square root of float value

Parameters

base in float - base value

Return Value

float square root of base

Errors

-

Detailed description

-

f_sqrtI

external function f_sqrtI( in  integer  base ) return float

Purpose

Square root of integer value

Parameters

base in integer - base value

Return Value

float square root of base

Errors

-

Detailed description

-

f_ceil

external function f_ceil( in  float  val ) return integer

Purpose

Return the smallest integer value that is not less then value

Parameters

val in float - float value

Return Value

integer ceil value of val

Errors

-

Detailed description

-

f_floor

external function f_floor( in  float  val ) return integer

Purpose

Return the largest integer value that is not greater then value

Parameters

val in float - float value

Return Value

integer floor value of val

Errors

-

Detailed description

-

f_exp

external function f_exp( in  float  val ) return float

Purpose

Return the exponential value of the argument

Parameters

val in float - float value

Return Value

float exp value of val

Errors

-

Detailed description

-

f_log

external function f_log( in  float  val ) return float

Purpose

Return the natural logarithm of the argument

Parameters

val in float - float value

Return Value

float ln value of val

Errors

-

Detailed description

-

f_generate_poissonTable

function f_generate_poissonTable( in  float  p_lambda,
out  t_Poisson_Table  p_pTable ) return boolean

Purpose

Returns with an initialized poisson table which is a cumulative probability distribution list for a given lambda.

Parameters

p_lambda in float - the lambda variance of the poisson distribution
p_pTable out t_Poisson_Table - the generated poisson table

Return Value

*boolean* true if the generation was success

Errors

If exp(-lambda) is zero than the table generation fails

Detailed description

The table used to get a poisson value by a random number indicates the next poisson value that should be use.  See f_getNext_poissonValue function for more details.  The size of the table will be lambda * 2.  Note: With this method we can only generate correct values for lambda-s smaller than about 100-110 This is due to f_powFF(p_lambda, j) is rounded to infinity above lambda-s bigger than about 150

f_getNext_poissonValue

function f_getNext_poissonValue( in  float  p_lambda,
inout  t_Poisson_Table  p_pTable,
out  boolean  p_sucess ) return integer

Purpose

Returns with a random poisson value by the given poisson table and lambda poisson variance.

Parameters

p_lambda in float - the lambda variance of the poisson distribution
p_pTable inout t_Poisson_Table - the poisson table
p_sucess out boolean - indicates if the returned value is from a successfully generated poisson table or not If false, an extremly rare error happened under the table generation and this need to be regenerate!

Return Value

*integer* the selected random poisson value between 0 and sizeof(p_pTable)

Errors

-

Detailed description

The function checks the input table if it is initialized or not and if not first of all generates it by the f_generate_poissonTable function.  If the table was initialized checks the given lambda if it was used to generate the table.  If it is different, regenerates the table.  After these checks we have the correct initialized poisson table for the given p_lambda.  Finally it returns with a random poisson value by the table.

f_gen_Exponential_Distribution(in float p_lambda) return float

function f_gen_Exponential_Distribution( in  float  p_lambda ) return float

Purpose

Returns with the exponential random variable for a given lambda

Parameters

p_lambda in float - the lambda variance of the exponential distribution

Return Value

*float* the exponential random variable for the given lambda

Errors

-

Detailed description

The function works as the following:

  • generate a random number U~U(0,1)
  • since U is uniform in (0,1) then so is U-1
  • X = - Log(1-U)/lambda = - Log(U)/lambda
  • return with X Note: Log means natural logarithm in this case
external function f_maxIL( in  IntegerList  ilist ) return IntegerList
Return an IntegerList with the highest number found at index 0 and the index of ilist where it’s found at index 1
external function f_maxFL( in  FloatList  flist ) return FloatList
Return an FloatList with the highest number found at index 0 and the index of flist where it’s fond at index 1
external function f_minIL( in  IntegerList  ilist ) return IntegerList
Return an IntegerList with the lowest number found at index 0 and the index of ilist where it’s fond at index 1
external function f_minFL( in  FloatList  flist ) return FloatList
Return an FloatList with the highest number found at index 0 and the index of flist where it’s fond at index 1
external function f_averageFL( in  FloatList  flist ) return float
Return the average of flist
external function f_averageIL( in  IntegerList  ilist ) return float
Return the average of ilist
external function f_updateFL( inout  FloatList  head,
in  FloatList  tail )
Append tail to the end of head (head return as inout)
external function f_updateIL( inout  IntegerList  head,
in  IntegerList  tail )
Append tail to the end of head (head return as inout)
external function f_stdFL( in  FloatList  flist ) return float
Return the normalized standard devILtion of float list (so the average square distance from the center of elements in the list)
external function f_stdFLL( in  FloatList  flist,
in  float  u ) return float
Return the normalized standard devILtion of float list using custom center (so it is the average square distance from a user defined central value)
external function f_stdIL( in  IntegerList  ilist ) return float
Return the normalized standard devILtion of integer list (so the average square distance from the center of points)
external function f_stdILL( in  IntegerList  ilist,
in  float  u ) return float
Return the normalized standard devILtion of integer list using custom center (so it is the average square distance from a user defined central value)
external function f_sinVL( in  float  freq,
in  float  altitude,
in  float  start_val,
in  integer  len,
in  float  step ) return FloatList
Return the values of the sine function
external function f_cosVL( in  float  freq,
in  float  altitude,
in  float  start_val,
in  integer  len,
in  float  step ) return FloatList
Return the values of the cosine function
external function f_sin( in  float  angle ) return float
Return the sine of angle radILns
external function f_cos( in  float  angle ) return float
Return the cosine of angle radILns
external function f_asin( in  float  val ) return float
Return the arc sine of value in [-pi/2, +pi/2]
external function f_acos( in  float  val ) return float
Return the arc cosine of value in [0, pi]
external function f_powFF( in  float  base,
in  float  expo ) return float
Raise to power (float to float power)
external function f_powII( in  integer  base,
in  integer  expo ) return integer
Raise to power (integer to integer power)
external function f_powIF( in  integer  base,
in  float  expo ) return float
Raise to power (integer to float power)
external function f_powFI( in  float  base,
in  integer  expo ) return float
Raise to power (float to integer power)
external function f_sqrF( in  float  base ) return float
Raise a float value to square
external function f_sqrI( in  integer  base ) return integer
Raise an integer value to square
external function f_sqrtF( in  float  base ) return float
Square root of float value
external function f_sqrtI( in  integer  base ) return float
Square root of integer value
external function f_ceil( in  float  val ) return integer
Return the smallest integer value that is not less then value
external function f_floor( in  float  val ) return integer
Return the largest integer value that is not greater then value
external function f_exp( in  float  val ) return float
Return the exponential value of the argument
external function f_log( in  float  val ) return float
Return the natural logarithm of the argument
function f_generate_poissonTable( in  float  p_lambda,
out  t_Poisson_Table  p_pTable ) return boolean
Returns with an initialized poisson table which is a cumulative probability distribution list for a given lambda.
function f_getNext_poissonValue( in  float  p_lambda,
inout  t_Poisson_Table  p_pTable,
out  boolean  p_sucess ) return integer
Returns with a random poisson value by the given poisson table and lambda poisson variance.
function f_gen_Exponential_Distribution( in  float  p_lambda ) return float
Returns with the exponential random variable for a given lambda
This module stores generic types for math functions
type record of integer IntegerList
List of integer
type record of float FloatList
List of float