Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qFVector

Floating-point vector(1D-Array) operations. More...

Data Structures

struct  qVFloat_Moment_t
 Metrics returned by qVFloat_Moment() More...
 
struct  qVFloat_MinMax_t
 Metrics returned by qVFloat_MinMax() More...
 

Enumerations

enum  qVFloat_Operation_t { VFLOAT_ADD , VFLOAT_MUL , VFLOAT_DIV }
 Supported operators on vectors. More...
 

Functions

float qVFloat_Operate (float *const dst, qVFloat_Operation_t o, const float a, const float *const x, const float b, const float *const y, const size_t n)
 Computes one of the following 1D-vector operation :
 
float qVFloat_ApplyFx (float *dst, float(*fx1)(float), float(*fx2)(float, float), float *const x, float *const y, const float a, const float b, const size_t n)
 Apply one the supplied function ( fx1 or fx2 ) to the input vector(s).
 
int qVFloat_Moment (qVFloat_Moment_t *const m, const float *const x, const size_t n)
 Computes the moment of a distribution for a given set of data including : Mean, Variance, Average deviation, standard deviation, skewness and kurtosis.
 
float * qVFloat_Set (float *const x, const float c, const size_t n)
 Set the value given on c to all the elements of the vector pointed by x.
 
float * qVFloat_Copy (float *const dst, const float *const src, const size_t n)
 Copies all the values on vector pointed by src to the vector pointed by dst.
 
float qVFloat_PolyVal (const float *const p, const float x, size_t n)
 Takes the input vector p as a polynomial p and evaluates it for x. The argument p is a vector of length n+1 whose elements are the coefficients (in descending powers) of an nth-degree polynomial.
 
float * qVFloat_LinSpace (float *const dst, const float x1, const float x2, const size_t n)
 Generate linearly spaced vector of
points. The spacing between the points is (x2-x1)/(n-1)
 
float qVFloat_Distance (const float *const x, const float *const y, const size_t n)
 Returns the Euclidean distance between vectors x and y.
 
float * qVFloat_Reverse (float *const dst, float *const src, const size_t init, const size_t end)
 Reverse the given vector pointed by src. Operation takes place on the portion of the vector that starts at position init to position end.
 
float * qVFloat_Rotate (float *const dst, float *const src, const int k, const size_t n)
 Rotates the elements of vector pointed by src the number of places and in the direction indicated by k.
 
int qVFloat_MinMax (qVFloat_MinMax_t *const o, const float *const x, const size_t n)
 Find the smallest and largest elements of vector pointed by x.
 
float * qVFloat_Sort (float *const dst, float *const src, const bool dir, size_t n)
 Returns a sorted version of unsorted vector pointed by src with the elements arranged in ascending or descending order according the value or dir.
 

Detailed Description

Floating-point vector(1D-Array) operations.

Enumeration Type Documentation

◆ qVFloat_Operation_t

Supported operators on vectors.

Enumerator
VFLOAT_ADD 

Addition operator

VFLOAT_MUL 

Multiplication operator

VFLOAT_DIV 

Division operator

Function Documentation

◆ qVFloat_ApplyFx()

float qVFloat_ApplyFx ( float * dst,
float(* fx1 )(float),
float(* fx2 )(float, float),
float *const x,
float *const y,
const float a,
const float b,
const size_t n )

Apply one the supplied function ( fx1 or fx2 ) to the input vector(s).

  • dst = a*fx1( x ) if fx2 is NULL
  • dst = a*fx2( x, y ) if fx1 is NULL
  • dst = a*fx2( x, b ) if fx1 and y are NULL
    Note
    If y or dst are used, they must have the same length as x.
    Remarks
    If both function are supplied, only fx1 will be applied
    Parameters
    [out]dstThe pointer to the destination vector where the result will be stored. To ignore pass NULL as argument.
    [in]fx1Function that will be applied to each element of x. This function should take one parameter following this signature:
    float fx1( float p );
    To ignore pass NULL as argument.
    [in]fx2Function that will be applied to each element of x. This function should take 2 parameters following this signature:
    float fx1( float p1, float p2 );
    To ignore pass NULL as argument.
    [in]xA vector as an 1D float array
    [in]yA vector as an 1D float array. To ignore pass NULL as argument.
    [in]aA value to scale the result of fx1 and fx2.
    [in]bAn scalar value used as second argument on fx2 if y is ignored.
    [in]nThe number of elements of vectors x and y
    Returns
    The sum of all elements on dst after the operation.

◆ qVFloat_Copy()

float * qVFloat_Copy ( float *const dst,
const float *const src,
const size_t n )

Copies all the values on vector pointed by src to the vector pointed by dst.

Parameters
[in]dstPointer to the destination vector
[in]srcPointer to the source vector
[in]nNumber of elements of the vector
Returns
A pointer to the vector, same as dst.

◆ qVFloat_Distance()

float qVFloat_Distance ( const float *const x,
const float *const y,
const size_t n )

Returns the Euclidean distance between vectors x and y.

Parameters
[in]xPointer to the input vector.
[in]yPointer to the input vector
[in]nNumber of elements of the vector
Returns
The Euclidean distance value.

◆ qVFloat_LinSpace()

float * qVFloat_LinSpace ( float *const dst,
const float x1,
const float x2,
const size_t n )

Generate linearly spaced vector of
points. The spacing between the points is (x2-x1)/(n-1)

Parameters
[out]dstThe pointer to the destination vector where the result will be stored.
[in]x1Point interval
[in]x2Point interval
[in]nNumber of points
Returns
A pointer to dst.

◆ qVFloat_MinMax()

int qVFloat_MinMax ( qVFloat_MinMax_t *const o,
const float *const x,
const size_t n )

Find the smallest and largest elements of vector pointed by x.

Parameters
[out]oThe pointer where the outcome of this function will be stored
[in]xThe input vector to.
[in]nNumber of places to rotate
Returns
1 on success, otherwise return 0.

◆ qVFloat_Moment()

int qVFloat_Moment ( qVFloat_Moment_t *const m,
const float *const x,
const size_t n )

Computes the moment of a distribution for a given set of data including : Mean, Variance, Average deviation, standard deviation, skewness and kurtosis.

Parameters
[out]mA structure of type qVFloat_Moment_t where the metrics will be stored.
[in]xA vector of data as an 1D float array
[in]nThe number of elements of vectors x and y
Returns
1 on success, otherwise returns 0.

◆ qVFloat_Operate()

float qVFloat_Operate ( float *const dst,
qVFloat_Operation_t o,
const float a,
const float *const x,
const float b,
const float *const y,
const size_t n )

Computes one of the following 1D-vector operation :

  • dst = a*x [o] b*y if both x and y are supplied.
  • dst = a*x [o] b if the y argument is NULL.

Here, [o] corresponds to the operator that will be applied

Note
If y or dst are used, they must have the same length as x.
Parameters
[out]dstThe pointer to the destination array where the result will be stored. To ignore pass NULL as argument.
[in]oThe desired operator, should be one of the following:
[in]aValue to scale the vector x.
[in]xA vector as an 1D float array
[in]bValue to scale the vector y.
[in]yA vector as an 1D float array. To ignore pass NULL as argument.
[in]nThe number of elements of vector x and y
Returns
The sum of all elements on dst after the operation.

◆ qVFloat_PolyVal()

float qVFloat_PolyVal ( const float *const p,
const float x,
size_t n )

Takes the input vector p as a polynomial p and evaluates it for x. The argument p is a vector of length n+1 whose elements are the coefficients (in descending powers) of an nth-degree polynomial.

Parameters
[in]pThe polynomial coefficients, specified as a vector.
[in]xValue to evaluate the polynomial
[in]nNumber of coefficients on polynomial p
Returns
A pointer to dst.

◆ qVFloat_Reverse()

float * qVFloat_Reverse ( float *const dst,
float *const src,
const size_t init,
const size_t end )

Reverse the given vector pointed by src. Operation takes place on the portion of the vector that starts at position init to position end.

Remarks
If the dst argument is ignored, the operation will take place over the src argument itself.
Parameters
[out]dstThe pointer to the destination vector where the result will be stored. To ignore pass NULL as argument.
[in,out]srcThe input vector to reverse.
[in]initPosition of the first element.
[in]endPosition of the last element.
Returns
A pointer to the reversed vector.

◆ qVFloat_Rotate()

float * qVFloat_Rotate ( float *const dst,
float *const src,
const int k,
const size_t n )

Rotates the elements of vector pointed by src the number of places and in the direction indicated by k.

Remarks
If the dst argument is ignored, the operation will take place over the src argument itself.
Parameters
[out]dstThe pointer to the destination vector where the result will be stored. To ignore pass NULL as argument.
[in,out]srcThe input vector to rotate.
[in]kPosition of the first element.
[in]nNumber of elements of the vector
Returns
A pointer to the rotated vector.

◆ qVFloat_Set()

float * qVFloat_Set ( float *const x,
const float c,
const size_t n )

Set the value given on c to all the elements of the vector pointed by x.

Parameters
[in]xA pointer to the input vector
[in]cThe value to set
[in]nNumber of elements of the vector
Returns
A pointer to the vector, same as x on success.

◆ qVFloat_Sort()

float * qVFloat_Sort ( float *const dst,
float *const src,
const bool dir,
size_t n )

Returns a sorted version of unsorted vector pointed by src with the elements arranged in ascending or descending order according the value or dir.

Note
This function is a wrapper to qTypeGeneric_Sort()
Remarks
If the dst argument is ignored, the operation will take place over the src argument itself.
Parameters
[out]dstThe pointer to the destination vector where the result will be stored. To ignore pass NULL as argument.
[in,out]srcThe input vector to rotate.
[in]dirPass false to sort in ascending order, otherwise pass true.
[in]nNumber of elements of the vector
Returns
A pointer to the sorted vector.