public static double[] trimZeroTail(final double[] data){
  return Arrays.copyOfRange(data,0,countNonZeroBeginning(data));
}

public static double [ ] trimZeroTail ( final double [ ] data ) { return Arrays . copyOfRange ( data , 0 , countNonZeroBeginning ( data ) ) ; }
trims zeros at the end of an array .
