| Top |
| #define | ROUND() |
| #define | GWY_ROUND() |
| gdouble | gwy_math_humanize_numbers () |
| gboolean | gwy_math_is_in_polygon () |
| gint | gwy_math_find_nearest_line () |
| gint | gwy_math_find_nearest_point () |
| gdouble * | gwy_math_lin_solve () |
| gdouble * | gwy_math_lin_solve_rewrite () |
| gboolean | gwy_math_tridiag_solve_rewrite () |
| gdouble * | gwy_math_fit_polynom () |
| gboolean | gwy_math_choleski_decompose () |
| void | gwy_math_choleski_solve () |
| guint | gwy_math_curvature () |
| gboolean | gwy_math_refine_maximum () |
| gdouble | gwy_math_median () |
| void | gwy_math_sort () |
| gdouble | gwy_math_median_uncertainty () |
| gdouble | gwy_xlnx_int () |
Functions gwy_math_SI_prefix() and gwy_math_humanize_numbers() deal with
number representation.
Nearest object finding functions gwy_math_find_nearest_line() and
gwy_math_find_nearest_point() can be useful in widget and vector layer
implementation.
And gwy_math_lin_solve(), gwy_math_lin_solve_rewrite(), and
gwy_math_fit_polynom() are general purpose numeric methods.
#define ROUND(x) ((gint)floor((x) + 0.5))
ROUND is deprecated and should not be used in newly-written code.
Rounds a number to nearest integer. Use GWY_ROUND instead.
#define GWY_ROUND(x) ((gint)floor((x) + 0.5))
Rounds a number to nearest integer.
Since: 2.5
gdouble gwy_math_humanize_numbers (gdouble unit,gdouble maximum,gint *precision);
Finds a human-friendly representation for a range of numbers.
unit |
The smallest possible step. |
|
maximum |
The maximum possible value. |
|
precision |
A location to store |
gboolean gwy_math_is_in_polygon (gdouble x,gdouble y,const gdouble *poly,guint n);
Establishes wether the test point x
, y
is inside the polygon poly
.
The polygon can be defined either clockwise or anti-clockwise and
can be a concave, convex or self-intersecting polygon.
x |
The x coordinate of the test point. |
|
y |
The y coordinate of the test point. |
|
poly |
An array of coordinate pairs (points) that define a polygon. |
|
n |
The number of corners of the polygon. |
Since: 2.7
gint gwy_math_find_nearest_line (gdouble x,gdouble y,gdouble *d2min,gint n,const gdouble *coords,const gdouble *metric);
Finds the line from coords
nearest to the point (x
, y
).
x |
X-coordinate of the point to search. |
|
y |
Y-coordinate of the point to search. |
|
d2min |
Where to store the squared minimal distance, or |
|
n |
The number of lines (i.e. |
|
coords |
Line coordinates stored as x00, y00, x01, y01, x10, y10, etc. |
|
metric |
Metric matrix (2x2, but stored sequentially by rows: m11, m12,
m21, m22), it must be positive definite. Vector norm is then
calculated as m11*x*x + (m12 + m21)*x*y + m22*y*y.
It can be |
gint gwy_math_find_nearest_point (gdouble x,gdouble y,gdouble *d2min,gint n,const gdouble *coords,const gdouble *metric);
Finds the point from coords
nearest to the point (x
, y
).
x |
X-coordinate of the point to search. |
|
y |
Y-coordinate of the point to search. |
|
d2min |
Location to store the squared minimal distance to, or |
|
n |
The number of points (i.e. |
|
coords |
Point coordinates stored as x0, y0, x1, y1, x2, y2, etc. |
|
metric |
Metric matrix (2x2, but stored sequentially by rows: m11, m12,
m21, m22). Vector norm is then calculated as
m11*x*x + (m12 + m21)*x*y + m22*y*y.
It can be |
gdouble * gwy_math_lin_solve (gint n,const gdouble *matrix,const gdouble *rhs,gdouble *result);
Solve a regular system of linear equations.
n |
The size of the system. |
|
matrix |
The matrix of the system ( |
|
rhs |
The right hand side of the sytem. |
|
result |
Where the result should be stored. May be |
gdouble * gwy_math_lin_solve_rewrite (gint n,gdouble *matrix,gdouble *rhs,gdouble *result);
Solves a regular system of linear equations.
This is a memory-conservative version of gwy_math_lin_solve() overwriting
matrix
and rhs
with intermediate results.
n |
The size of the system. |
|
matrix |
The matrix of the system ( |
|
rhs |
The right hand side of the sytem. |
|
result |
Where the result should be stored. May be |
gboolean gwy_math_tridiag_solve_rewrite (gint n,gdouble *d,const gdouble *a,const gdouble *b,gdouble *rhs);
Solves a tridiagonal system of linear equations.
gdouble * gwy_math_fit_polynom (gint ndata,const gdouble *xdata,const gdouble *ydata,gint n,gdouble *coeffs);
Fits a polynom through a general (x, y) data set.
ndata |
The number of items in |
|
xdata |
Independent variable data (of size |
|
ydata |
Dependent variable data (of size |
|
n |
The degree of polynom to fit. |
|
coeffs |
An array of size |
The coefficients of the polynom (coeffs
when it was not NULL,
otherwise a newly allocated array).
gboolean gwy_math_choleski_decompose (gint n,gdouble *matrix);
Decomposes a symmetric positive definite matrix in place.
n |
The dimension of |
|
matrix |
Lower triangular part of a symmetric matrix, stored by rows, i.e., matrix = [a_00 a_10 a_11 a_20 a_21 a_22 a_30 ...]. |
Whether the matrix was really positive definite. If FALSE,
the decomposition failed and a
does not contain any meaningful
values.
void gwy_math_choleski_solve (gint n,const gdouble *decomp,gdouble *rhs);
Solves a system of linear equations with predecomposed symmetric positive
definite matrix a
and right hand side b
.
n |
The dimension of |
|
decomp |
Lower triangular part of Choleski decomposition as computed
by |
|
rhs |
Right hand side vector. Is is modified in place, on return it contains the solution. |
guint gwy_math_curvature (const gdouble *coeffs,gdouble *kappa1,gdouble *kappa2,gdouble *phi1,gdouble *phi2,gdouble *xc,gdouble *yc,gdouble *zc);
gboolean gwy_math_refine_maximum (const gdouble *z,gdouble *x,gdouble *y);
Performs subpixel refinement of parabolic a two-dimensional maximum.
The central value corresponds to coordinates (0,0), distances between values
are unity. The refinement is based by fitting a two-dimensional parabola
through the maximum. If it fails or the calculated maximum lies farther
than the surrounding values the function sets the refined maximum to the
origin and returns FALSE.
z |
Array of length 9, containing the square 3x3 neighbourhood values in matrix order and with the maximum in the centre. |
|
x |
Location to store the refined |
|
y |
Location to store the refined |
TRUE if the refinement succeeded, FALSE if it failed. The values
of x
and y
are usable regardless of the return value.
Since: 2.42
gdouble gwy_math_median (gsize n,gdouble *array);
Finds median of an array of values using Quick select algorithm.
void gwy_math_sort (gsize n,gdouble *array);
Sorts an array of doubles using a quicksort algorithm.
This is usually about twice as fast as the generic quicksort function thanks to specialization for doubles.
gdouble gwy_math_median_uncertainty (gsize n,gdouble *array,gdouble *uarray);
gdouble
gwy_xlnx_int (guint x);
Calculates natural logarithm multiplied by the argument for integers.
The value for zero x
is taken as the limit, i.e. zero.
This function is useful for entropy calculations where values of n
*log(n
)
can be evaulated a lot for small n
. Therefore, values for small arguments
are tabulated. For large arguments the function is evaluated using the
standard log() function which is of course slower.
Since: 2.44
#define GWY_SQRT3 1.73205080756887729352744634150587236694280525381038
The square root of 3.
GwyNLFitter, non-linear least square fitter;
Math Fallback,fallback mathematical functions