48 #define RC_VECTOR_INITIALIZER {\ 394 #endif // RC_VECTOR_H int rc_vector_free(rc_vector_t *v)
Frees the memory allocated for vector v.
int rc_vector_ones(rc_vector_t *v, int length)
Resizes vector v and fills with ones.
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.
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.
int rc_vector_print_sci(rc_vector_t v)
Prints to stdout the contents of vector v in one line.
double rc_vector_std_dev(rc_vector_t v)
Returns the standard deviation of the values in a vector.
int rc_vector_zero_out(rc_vector_t *v)
Sets all values of an already-allocated vector to 0.
int rc_vector_alloc(rc_vector_t *v, int length)
Allocates memory for vector v to have specified length.
int initialized
initialization flag
Definition: vector.h:44
int rc_vector_zeros(rc_vector_t *v, int length)
Resizes vector v and fills with zeros.
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...
int rc_vector_min(rc_vector_t v)
Returns the index of the minimum value in v.
struct rc_vector_t rc_vector_t
Struct containing the state of a vector and a pointer to dynamically allocated memory to hold its con...
double * d
pointer to dynamically allocated data
Definition: vector.h:43
int rc_vector_random(rc_vector_t *v, int length)
Resizes vector v and fills with random numbers between -1.0 and 1.0.
int rc_vector_fibonnaci(rc_vector_t *v, int length)
Resizes vector v and fills with Fibonnaci sequence.
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.
int rc_vector_max(rc_vector_t v)
Returns the index of the maximum value in v.
Struct containing the state of a vector and a pointer to dynamically allocated memory to hold its con...
Definition: vector.h:41
int rc_vector_duplicate(rc_vector_t a, rc_vector_t *b)
Duplicates the contents of vector a and into a new vector b.
double rc_vector_mean(rc_vector_t v)
Returns the mean (average) of all values in vector v or -1.0f on error.
int rc_vector_print(rc_vector_t v)
Prints to stdout the contents of vector v in one line.
int rc_vector_from_array(rc_vector_t *v, double *ptr, int length)
Resizes vector v and populates with values from specified array ptr.
int len
number of elements in the vector
Definition: vector.h:42
rc_vector_t rc_vector_empty(void)
Returns an rc_vector_t with no allocated memory and the initialized flag set to 0.
int rc_vector_sum_inplace(rc_vector_t *v1, rc_vector_t v2)
Adds vector v2 to v1 and leaves the result in v1.
int rc_vector_subtract(rc_vector_t v1, rc_vector_t v2, rc_vector_t *s)
Populates vector s with the difference v1 - v2.
double rc_vector_dot_product(rc_vector_t v1, rc_vector_t v2)
Calculates the dot product of two equal-length vectors.
int rc_vector_times_scalar(rc_vector_t *v, double s)
Multiplies every entry in vector v by scalar s.