Zephyr Scientific Library (zscilib)
|
#include <errno.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <zsl/vectors.h>
#include <zsl/zsl.h>
Go to the source code of this file.
Functions | |
int | zsl_vec_init (struct zsl_vec *v) |
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 of elements in vector 'v'. As such, 'v' should be previously initialised with an appropriate value assigned to v.sz. More... | |
int | zsl_vec_copy (struct zsl_vec *vdest, struct zsl_vec *vsrc) |
Copies the contents of vector 'vsrc' into vector 'vdest'. More... | |
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'.. More... | |
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'. More... | |
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'. More... | |
int | zsl_vec_neg (struct zsl_vec *v) |
Negates the elements in vector 'v'. More... | |
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. More... | |
int | zsl_vec_scalar_add (struct zsl_vec *v, zsl_real_t s) |
Adds a scalar to each element in a vector. More... | |
int | zsl_vec_scalar_mult (struct zsl_vec *v, zsl_real_t s) |
Multiply a vector by a scalar. More... | |
int | zsl_vec_scalar_div (struct zsl_vec *v, zsl_real_t s) |
Divide a vector by a scalar. More... | |
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. More... | |
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 products). The dot product is an indicator of the "agreement" between two vectors, or can be used to determine how far vector w deviates from vector v. More... | |
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). More... | |
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'. More... | |
int | zsl_vec_to_unit (struct zsl_vec *v) |
Converts (normalises) vector 'v' to a unit vector (a vector of magnitude or length 1). This is accomploished by dividing each element by the it's norm. More... | |
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. More... | |
zsl_real_t | zsl_vec_sum_of_sqrs (struct zsl_vec *v) |
Computes the vector's sum of squares. More... | |
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. More... | |
int | zsl_vec_ar_mean (struct zsl_vec *v, zsl_real_t *m) |
Computes the arithmetic mean of a vector. More... | |
int | zsl_vec_rev (struct zsl_vec *v) |
Reverses the order of the entries in vector 'v'. More... | |
int | zsl_vec_zte (struct zsl_vec *v) |
Rearranges the input vector to place any zero-values at the end. More... | |
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... | |
int | zsl_vec_print (struct zsl_vec *v) |
Print the supplied vector using printf in a human-readable manner. More... | |