Evaluates a polynomial (either a poly or a vector) at a number
//------------------------------------------------------------
// Function: evalpoly - evalutes a polynomial at a given value
//
// Input: p - a polynomial or a vector with coeff (a0, a1, a2,..)
// x - a number
// Output: r - the value of the polynomial evaluated at x
//------------------------------------------------------------