// Shifts all values in A left by 1, shifting
// in value x on the far right, and returning
// the original A[0] value, which gets shifted out
double shiftleft(double *A, int N, double x)
{
  double first = A[0];
  for(int i = 0; i < N - 1; i++)
    A[i] = A[i+1];
  A[N-1] = x;
  return first;
}