public static void truncate(double[] x, double maxVal) {
		for (int index = 0; index < x.length; index++) {
			if (x[index] > maxVal) 
				x[index]=maxVal;
			else if (x[index]<-maxVal)
				x[index]=-maxVal;
		}
	}