Commit ddbeefcd authored by Ell's avatar Ell

matrix: add gegl_matrix_round_error()

... which rounds numerical errors in the matrix's coefficients to
the nearest integer.
parent a38fe125
......@@ -72,6 +72,26 @@ gegl_matrix3_identity (GeglMatrix3 *matrix)
matrix->coeff [2][0] = matrix->coeff [2][1] = 0.;
}
void
gegl_matrix3_round_error (GeglMatrix3 *matrix)
{
gint r;
for (r = 0; r < 3; r++)
{
gint c;
for (c = 0; c < 3; c++)
{
gdouble x = matrix->coeff[r][c];
gdouble i = floor (x + 0.5);
if (fabs (x - i) < EPSILON)
matrix->coeff[r][c] = i;
}
}
}
gboolean
gegl_matrix3_equal (GeglMatrix3 *matrix1,
GeglMatrix3 *matrix2)
......
......@@ -64,6 +64,14 @@ GeglMatrix3 * gegl_matrix3_new (void);
*/
void gegl_matrix3_identity (GeglMatrix3 *matrix);
/**
* gegl_matrix3_round_error:
* @matrix: a #GeglMatrix3
*
* Rounds numerical errors in @matrix to the nearest integer.
*/
void gegl_matrix3_round_error (GeglMatrix3 *matrix);
/**
* gegl_matrix3_equal:
* @matrix1: a #GeglMatrix3
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment