| Class | Dobjects::Function |
| In: |
split/Dvector/dvector.c
split/Function/lib/Function_extras.rb |
| Parent: | Object |
Function is a class that embeds two Dvectors, one for X data and one for Y data. It provides
And getting bigger everyday…
Sorts x, while ensuring that the corresponding y values keep matching. Should be pretty fast, as it is derived from glibc’s quicksort.
a = Dvector[3,2,1] b = a * 2 -> [6,4,2] Function.joint_sort(a,b) -> [[1,2,3], [2,4,6]]
Interpolates the value of the function at the points given. Returns a brand new Dvector. The X values must be sorted !
Computes spline data and caches it inside the object. Both X and Y vectors are cleared (see Dvector#clear) to make sure the cache is kept up-to-date. If the function is not sorted, sorts it.
Returns the distance of the function to the given point. Optionnal xscale and yscale says by how much we should divide the x and y coordinates before computing the distance. Use it if the distance is not homogeneous.
Iterates over all the points in the Function, yielding X and Y for each point.
: Returns the value of the integral of the function between the two indexes given, or over the whole function if no indexes are specified.
Computes interpolated values of the data contained in f and returns a Function object holding both x_values and the computed Y values. x_values will be sorted if necessary.
With the second form, specify only the number of points, and the function will construct the appropriate vector with equally spaced points within the function range.
Returns an interpolant that can be fed to Special_Paths#append_interpolant_to_path to make nice splines.
Can be used this way:
f = Function.new(x,y) t.append_interpolant_to_path(f.make_interpolant) t.stroke
Splits the function into monotonic sub-functions. Returns the array of the subfunctions. The returned values are necessarily new values.