Robot Control Library
vector.h File Reference

Go to the source code of this file.

Data Structures

struct  rc_vector_t
 Struct containing the state of a vector and a pointer to dynamically allocated memory to hold its contents. More...
 

Macros

#define RC_VECTOR_INITIALIZER
 

Typedefs

typedef struct rc_vector_t rc_vector_t
 Struct containing the state of a vector and a pointer to dynamically allocated memory to hold its contents. More...
 

Functions

rc_vector_t rc_vector_empty (void)
 Returns an rc_vector_t with no allocated memory and the initialized flag set to 0. More...
 
int rc_vector_alloc (rc_vector_t *v, int length)
 Allocates memory for vector v to have specified length. More...
 
int rc_vector_free (rc_vector_t *v)
 Frees the memory allocated for vector v. More...
 
int rc_vector_zeros (rc_vector_t *v, int length)
 Resizes vector v and fills with zeros. More...
 
int rc_vector_ones (rc_vector_t *v, int length)
 Resizes vector v and fills with ones. More...
 
int rc_vector_random (rc_vector_t *v, int length)
 Resizes vector v and fills with random numbers between -1.0 and 1.0. More...
 
int rc_vector_fibonnaci (rc_vector_t *v, int length)
 Resizes vector v and fills with Fibonnaci sequence. More...
 
int rc_vector_from_array (rc_vector_t *v, double *ptr, int length)
 Resizes vector v and populates with values from specified array ptr. More...
 
int rc_vector_duplicate (rc_vector_t a, rc_vector_t *b)
 Duplicates the contents of vector a and into a new vector b. More...
 
int rc_vector_print (rc_vector_t v)
 Prints to stdout the contents of vector v in one line. More...
 
int rc_vector_print_sci (rc_vector_t v)
 Prints to stdout the contents of vector v in one line. More...
 
int rc_vector_zero_out (rc_vector_t *v)
 Sets all values of an already-allocated vector to 0. More...
 
int rc_vector_times_scalar (rc_vector_t *v, double s)
 Multiplies every entry in vector v by scalar s. More...
 
double rc_vector_norm (rc_vector_t v, double p)
 Returns the vector norm defined by sum(abs(v)^p)^(1/p), where p is any positive real value. More...
 
int rc_vector_max (rc_vector_t v)
 Returns the index of the maximum value in v. More...
 
int rc_vector_min (rc_vector_t v)
 Returns the index of the minimum value in v. More...
 
double rc_vector_std_dev (rc_vector_t v)
 Returns the standard deviation of the values in a vector. More...
 
double rc_vector_mean (rc_vector_t v)
 Returns the mean (average) of all values in vector v or -1.0f on error. More...
 
int rc_vector_projection (rc_vector_t v, rc_vector_t e, rc_vector_t *p)
 Populates vector p with the projection of vector v onto e. More...
 
double rc_vector_dot_product (rc_vector_t v1, rc_vector_t v2)
 Calculates the dot product of two equal-length vectors. More...
 
int rc_vector_cross_product (rc_vector_t v1, rc_vector_t v2, rc_vector_t *p)
 Computes the cross-product of two vectors, each of length 3. More...
 
int rc_vector_sum (rc_vector_t v1, rc_vector_t v2, rc_vector_t *s)
 Populates vector s with the sum of vectors v1 and v2. More...
 
int rc_vector_sum_inplace (rc_vector_t *v1, rc_vector_t v2)
 Adds vector v2 to v1 and leaves the result in v1. More...
 
int rc_vector_subtract (rc_vector_t v1, rc_vector_t v2, rc_vector_t *s)
 Populates vector s with the difference v1 - v2. More...
 

Variables

double zero_tolerance