Zephyr Scientific Library (zscilib)
Functions
Comparison

Functions used to compare or verify vectors. More...

Functions

bool zsl_vec_is_equal (struct zsl_vec *v, struct zsl_vec *w, zsl_real_t eps)
 Checks if two vectors are identical in size and content. More...
 
bool zsl_vec_is_nonneg (struct zsl_vec *v)
 Checks if all elements in vector v are >= zero. More...
 
int zsl_vec_contains (struct zsl_vec *v, zsl_real_t val, zsl_real_t eps)
 Checks if vector v contains val, returning the number of occurences. More...
 
int zsl_vec_sort (struct zsl_vec *v, struct zsl_vec *w)
 Sorts the values in vector v from smallest to largest using quicksort, and assigns the sorted output to vector w. More...
 

Detailed Description

Functions used to compare or verify vectors.

Function Documentation

◆ zsl_vec_contains()

int zsl_vec_contains ( struct zsl_vec v,
zsl_real_t  val,
zsl_real_t  eps 
)

Checks if vector v contains val, returning the number of occurences.

Parameters
vThe vector to check.
valThe value to check all coefficients for.
epsThe margin for floating-point equality (ex. '1E-5').
Returns
The number of occurences of val withing range eps, 0 if no matching occurences were found, or a negative error code.

Definition at line 416 of file vectors.c.

Referenced by zsl_mtx_eigenvectors(), zsl_sta_mode(), zsl_sta_time_weighted_mean(), and zsl_vec_sort().

◆ zsl_vec_is_equal()

bool zsl_vec_is_equal ( struct zsl_vec v,
struct zsl_vec w,
zsl_real_t  eps 
)

Checks if two vectors are identical in size and content.

Parameters
vThe first vector.
wThe second vector.
epsThe margin for floating-point equality (ex. '1E-5').
Returns
true if the two vectors have the same size and the same values, otherwise false.

Definition at line 387 of file vectors.c.

◆ zsl_vec_is_nonneg()

bool zsl_vec_is_nonneg ( struct zsl_vec v)

Checks if all elements in vector v are >= zero.

Parameters
vThe vector to check.
Returns
true if all elements in 'v' are zero or positive, otherwise false.

Definition at line 405 of file vectors.c.

◆ zsl_vec_sort()

int zsl_vec_sort ( struct zsl_vec v,
struct zsl_vec w 
)

Sorts the values in vector v from smallest to largest using quicksort, and assigns the sorted output to vector w.

Parameters
vThe unsorted, input vector.
wThe sorted, output vector.
Returns
0 if everything executed properly, otherwise a negative error code.

Definition at line 475 of file vectors.c.

Referenced by zsl_sta_data_range(), zsl_sta_percentile(), zsl_sta_time_weighted_mean(), zsl_sta_trim_mean(), and zsl_sta_weighted_median().