Robot Control Library
rc_test_vector.c
/**
* @example rc_test_vector.c
*
* @brief Tests the functions in rc_vector.h
*
*
* @author James Strawson
* @date 1/29/2018
*/
#include <stdio.h>
#include <rc/math.h>
#define LEN 4 // length of vector to test
int main()
{
int i;
printf("Testing vector functions\n\n");
// create ones vector
rc_vector_ones(&a, LEN);
printf("\nVector of ones:\n");
// create zero vector
rc_vector_zeros(&a, LEN);
printf("\nVector of Zeros:\n");
// create random vector
rc_vector_random(&a, LEN);
printf("\nRandom Vector:\n");
// duplicate vector
printf("\nDuplicate vector:\n");
// times scalar
printf("\nVector Times 2\n");
// sum
printf("\nsum a+2a\n");
// vector from array
double fib[] = {1,1,2,3,5,8};
printf("\nFibonacci vector from array:\n");
// fibonnaci vector
printf("\nFibonacci vector built-in function:\n");
// vector norm
printf("\n%7f Vector 1-norm\n", rc_vector_norm(a,1.0f));
printf("%7f Vector 2-norm\n", rc_vector_norm(a,2.0f));
printf("%7f Vector 3-norm\n", rc_vector_norm(a,3.0f));
// vector max min
i = rc_vector_max(a);
printf("%7f Vector Max at position %d\n", a.d[i],i);
i = rc_vector_min(a);
printf("%7f Vector Min at position %d\n", a.d[i],i);
// standard deviation
printf("%7f standard deviation\n", rc_vector_std_dev(a));
// mean
printf("%7f mean\n", rc_vector_mean(a));
// cleanup
printf("\nDONE\n");
return 0;
}