/* Strips all the points containing NaN values from the function, and returns the number of points stripped. */ static VALUE function_strip_nan(VALUE self) { long size = function_sanity_check(self); long nb_stripped = 0; long i; double *x = Dvector_Data_for_Write(get_x_vector(self),NULL); double *y = Dvector_Data_for_Write(get_y_vector(self),NULL); for( i = 0; i < size; i++) { if(isnan(x[i]) || isnan(y[i])) nb_stripped ++; else { x[i - nb_stripped] = x[i]; y[i - nb_stripped] = y[i]; } } if(nb_stripped) { Dvector_Data_Resize(get_x_vector(self), size - nb_stripped); Dvector_Data_Resize(get_y_vector(self), size - nb_stripped); } return INT2NUM(nb_stripped); }