matrix polyval( vector b, matrix x)
/*
   evaluate a monic polynomial: x^n + b1 x^(n-1) + ... + bn

   x can be a scalar, vector, or matrix
*/
{
  int i, n = prod(sizeof(b));  matrix r = ones(rows(x),cols(x));

  for( i = 1; i <= n; ++i) r = r.*x + b(i);

  return r;
}
