Zephyr Scientific Library (zscilib)
|
Go to the documentation of this file.
15 #if (CONFIG_ZSL_PLATFORM_OPT == 1 || CONFIG_ZSL_PLATFORM_OPT == 2)
16 #include <zsl/asm/arm/asm_arm_vectors.h>
45 #if CONFIG_ZSL_BOUNDS_CHECKS
47 if (offset >= v->
sz) {
51 if (offset + len >= v->
sz) {
73 #if CONFIG_ZSL_BOUNDS_CHECKS
75 if ((v->
sz != w->
sz) || (v->
sz != x->
sz)) {
80 for (
size_t i = 0; i < v->
sz; i++) {
90 #if CONFIG_ZSL_BOUNDS_CHECKS
92 if ((v->
sz != w->
sz) || (v->
sz != x->
sz)) {
97 for (
size_t i = 0; i < v->
sz; i++) {
106 for (
size_t i = 0; i < v->
sz; i++) {
123 #if CONFIG_ZSL_BOUNDS_CHECKS
125 for (
size_t i = 0; i < n; i++) {
126 if (sz_last != v[i]->sz) {
134 for (
size_t i = 0; i < n; i++) {
135 for (
size_t j = 0; j < w->
sz; j++) {
143 #if !asm_vec_scalar_add
146 for (
size_t i = 0; i < v->
sz; i++) {
154 #if !asm_vec_scalar_mult
157 for (
size_t i = 0; i < v->
sz; i++) {
165 #if !asm_vec_scalar_div
173 for (
size_t i = 0; i < v->
sz; i++) {
203 #if CONFIG_ZSL_BOUNDS_CHECKS
205 if (v->
sz != w->
sz) {
210 for (
size_t i = 0; i < v->
sz; i++) {
235 #if CONFIG_ZSL_BOUNDS_CHECKS
237 if ((v->
sz != w->
sz) || (v->
sz != u->
sz)) {
275 #if CONFIG_ZSL_BOUNDS_CHECKS
277 if ((v->
sz != 3) || (w->
sz != 3) || (c->
sz != 3)) {
316 #if CONFIG_ZSL_BOUNDS_CHECKS
318 if (m->
sz != v[0]->
sz) {
342 for (
size_t i = 0; i < v->
sz; i++) {
355 size_t end = v->
sz - 1;
357 while (start < end) {
373 for (
size_t g = 0; g < v->
sz; g++) {
374 if ((v->
data[g - x] >= 0.0 && v->
data[g - x] < epsilon) ||
375 (v->
data[g - x] <= 0.0 && v->
data[g - x] > epsilon)) {
376 for (
size_t p = g - x; p < (v->
sz - 1); p++) {
391 if (v->
sz != w->
sz) {
395 for (
size_t i = 0; i < v->
sz; i++) {
397 if (c >= eps || -c >= eps) {
407 for (
size_t i = 0; i < v->
sz; i++) {
408 if (v->
data[i] < 0.0) {
421 for (
size_t i = 0; i < v->
sz; i++) {
422 c = v->
data[i] - val;
423 if (c < eps && -c < eps) {
440 static int zsl_vec_quicksort(
struct zsl_vec *v,
size_t low,
size_t high)
451 while (v->
data[i] <= v->
data[p] && i <= high) {
454 while (v->
data[j] > v->
data[p] && j >= low) {
468 zsl_vec_quicksort(v, low, i - 1);
469 zsl_vec_quicksort(v, j + 1, high);
486 for (j = 0; j < v->
sz; j++) {
487 if (v->
data[j] >= 1E-5 || v->
data[j] <= 1E-5) {
489 u.data[count] = v->
data[j];
502 zsl_vec_quicksort(&u, 0, count - 1);
505 for (i = 0; i < count; i++) {
507 w->
data[count2] = u.data[i];
517 for (
size_t g = 0; g < v->
sz; g++) {
518 printf(
"%f ", v->
data[g]);
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.
API header file for vectors in zscilib.
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)....
#define ZSL_VECTOR_DEF(name, n)
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.