Math Related Functions

Math Related Functions #

File position: /EMOC/src/core/utility.h and /EMOC/src/core/utility.cpp

In EMOC, some mathematic operations are also provided for convenience:

int Combination(int n, int k)

Return the combination number with the given parameters.

Parameter:
n: int, default=None
    The number of total things.

k: int, default=None
    The number of things taken from the total n things.
Returns:
combination: double
    Combination number.
double CalculateCos(double *a, double *b, int dimension)

Calculate the cosine value between two vectors.

Parameter:
a: double*, default=None
    The first vector. It's a 1D array of double.

b: double*, default=None
    The second vector. It's a 1D array of double.

dimension: int, default=None
    The dimension of given vectors.
Returns:
cos: double
    Cosine value between vector a and vector b.
double CalculateSin(double *a, double *b, int dimension)

Calculate the sine value between two vectors.

Parameter:
a: double*, default=None
    The first vector. It's a 1D array of double.

b: double*, default=None
    The second vector. It's a 1D array of double.

dimension: int, default=None
    The dimension of given vectors.
Returns:
sin: double
    Sine value between vector a and vector b.
double CalculateNorm(double *vector, int dimension)

Calculate the norm of given vector.

Parameter:
vector: double*, default=None
    The pointer to given vector. It's a 1D array of double.

dimension: int, default=None
    The dimension of given vector.
Returns:
norm: double
    The norm of given vector.
double CalculateDotProduct(double *vector1, double *vector2, int dimension)

Calculate the dot product between two vectors.

Parameter:
vector1: double*, default=None
    The first vector. It's a 1D array of double.

vector2: double*, default=None
    The second vector. It's a 1D array of double.

dimension: int, default=None
    The dimension of given vectors.
Returns:
sin: double
    Dot product between the two given vectors.
double CalEuclidianDistance(double* a, double* b, int dimension)

Calculate the euclidian distance between two vectors.

Parameter:
a: double*, default=None
    The first vector. It's a 1D array of double.

b: double*, default=None
    The second vector. It's a 1D array of double.

dimension: int, default=None
    The dimension of given vectors.
Returns:
distance: double
    The euclidian distance between two vectors.
double CalPerpendicularDistance(double* a, double* b, int dimension)

Calculate the perpendicular distance between two vectors.

Parameter:
a: double*, default=None
    The first vector. It's a 1D array of double.

b: double*, default=None
    The second vector. It's a 1D array of double.

dimension: int, default=None
    The dimension of given vectors.
Returns:
perpendicular: double
    The euclidian distance between two vectors.