Zephyr Scientific Library (zscilib)
|
Go to the documentation of this file.
22 #ifndef ZEPHYR_INCLUDE_ZSL_VECTORS_H_
23 #define ZEPHYR_INCLUDE_ZSL_VECTORS_H_
52 #define ZSL_VECTOR_DEF(name, n) \
53 zsl_real_t name ## _vec[n]; \
54 struct zsl_vec name = { \
56 .data = name ## _vec \
int zsl_vec_get_subset(struct zsl_vec *v, size_t offset, size_t len, struct zsl_vec *vsub)
Returns a subset of source vector 'v' in 'vsub'..
int zsl_vec_mean(struct zsl_vec **v, size_t n, struct zsl_vec *m)
Computes the component-wise mean of a set of identically-sized vectors.
int zsl_vec_ar_mean(struct zsl_vec *v, zsl_real_t *m)
Computes the arithmetic mean of a vector.
int zsl_vec_init(struct zsl_vec *v)
zsl_real_t zsl_vec_sum_of_sqrs(struct zsl_vec *v)
Computes the vector's sum of squares.
zsl_real_t zsl_vec_norm(struct zsl_vec *v)
Calculates the norm or absolute value of vector 'v' (the square root of the vector's dot product).
int zsl_vec_dot(struct zsl_vec *v, struct zsl_vec *w, zsl_real_t *d)
Computes the dot (aka scalar) product of two equal-length vectors (the sum of their component-wise pr...
int zsl_vec_project(struct zsl_vec *u, struct zsl_vec *v, struct zsl_vec *w)
Calculates the projection of vector 'u' over vector 'v', placing the results in vector 'w'.
int zsl_vec_print(struct zsl_vec *v)
Print the supplied vector using printf in a human-readable manner.
int zsl_vec_sub(struct zsl_vec *v, struct zsl_vec *w, struct zsl_vec *x)
Subtracts corresponding vector elements in 'v' and 'w', saving to 'x'.
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.
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 ...
int zsl_vec_from_arr(struct zsl_vec *v, zsl_real_t *a)
Converts an array of values into a vector. The number of elements in array 'a' must match the number ...
int zsl_vec_rev(struct zsl_vec *v)
Reverses the order of the entries in vector 'v'.
int zsl_vec_sum(struct zsl_vec **v, size_t n, struct zsl_vec *w)
Component-wise sum of a set of equal-length vectors.
int zsl_vec_neg(struct zsl_vec *v)
Negates the elements in vector 'v'.
int zsl_vec_copy(struct zsl_vec *vdest, struct zsl_vec *vsrc)
Copies the contents of vector 'vsrc' into vector 'vdest'.
int zsl_vec_cross(struct zsl_vec *v, struct zsl_vec *w, struct zsl_vec *c)
Computes the cross (or vector) product of two 3-vectors.
zsl_real_t zsl_vec_dist(struct zsl_vec *v, struct zsl_vec *w)
Calculates the distance between two vectors, which is equal to the norm of vector v - vector w.
int zsl_vec_to_unit(struct zsl_vec *v)
Converts (normalises) vector 'v' to a unit vector (a vector of magnitude or length 1)....
API header file for zscilib.
int zsl_vec_zte(struct zsl_vec *v)
Rearranges the input vector to place any zero-values at the end.
int zsl_vec_add(struct zsl_vec *v, struct zsl_vec *w, struct zsl_vec *x)
Adds corresponding vector elements in 'v' and 'w', saving to 'x'.
int zsl_vec_scalar_div(struct zsl_vec *v, zsl_real_t s)
Divide a vector by a scalar.
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.
int zsl_vec_scalar_mult(struct zsl_vec *v, zsl_real_t s)
Multiply a vector by a scalar.
int zsl_vec_scalar_add(struct zsl_vec *v, zsl_real_t s)
Adds a scalar to each element in a vector.
bool zsl_vec_is_nonneg(struct zsl_vec *v)
Checks if all elements in vector v are >= zero.