Robot Control Library
rc_test_polynomial.c
/**
* @example rc_test_polynomial.c
*
* @brief Tests the functions in rc_polynomial.h
*
* @author James Strawson
* @date 1/29/2018
*/
#include <stdio.h>
#include <rc/math.h>
#define LEN 4 // length of polynomial to test
int main()
{
int i;
printf("\nRandom polynomials of orders 0-9\n");
for(i=1;i<=10;i++){
}
printf("\npolynomial of ones a:\n");
printf("polynomial of ones b:\n");
printf("Polynomial convolution a*b:\n");
rc_poly_conv(a,b,&c);
// test powers
printf("\na to the power of 0-5:\n");
for(i=0;i<=5;i++){
rc_poly_power(a,i,&c);
}
// test subtract
printf("\nrc_poly_subtract c=b-a\n");
// test subtract
printf("\nrc_poly_subtract_inplace c=c-a\n");
// test add
printf("\nrc_poly_add a+b=c\n");
rc_poly_add(a,b,&c);
// test add
printf("\nrc_poly_add_inplace c=c+a\n");
// differentiate
printf("0st-3rd derivative of b\n");
for(i=0;i<=3;i++){
}
// divide
printf("\nNew polynomial a:\n");
printf("\nNew polynomial b:\n");
printf("\ndivide a into b\n");
rc_poly_divide(b,a,&c,&d);
printf("remainder:\n");
// confirm
printf("\nConfirm by multiplying the result and adding remainder\n");
rc_poly_conv(c,a,&e);
// butterworth
printf("\nfirst 4 butterworth polynomials\n");
for(i=1;i<=4;i++){
rc_poly_butter(i,1,&a);
}
printf("\nDONE\n");
return 0;
}