../../../LIBS/libs-core/libgeo/argparser_geo.c affine_tracker/libgeo/argparser_geo.c --- 2c2 ----------------------- < /* Last edited on 2009-01-04 08:45:09 by stolfi */ > /* Last edited on 2007-01-04 00:14:51 by stolfi */ --- 6c6,9 ----------------------- < #define _GNU_SOURCE > #include > #include > #include > #include --- 10,30c13 ----------------------- < #include < #include < < #include < #include < #include < #include < < #include < < void argparser_get_next_rn(argparser_t *pp, double p[], int n, double min, double max) < { r2_t p; < argparser_get_next_rn(pp, p.c, 2, min, max); < return p;int i; < } < < r2_t argparser_get_next_r2(argparser_t *pp, double min, double max) < { r2_t p; < argparser_get_next_rn(pp, p.c, 2, min, max); < return p; < } > #include --- 33,34c16,19 ----------------------- < { r3_t p; < argparser_get_next_rn(pp, p.c, 3, min, max); > { int i; > r3_t p; > for (i = 0; i < 3; i++) > { p.c[i] = argparser_get_next_double(pp, min, max); } --- 39,46c24,27 ----------------------- < { r4_t p; < argparser_get_next_rn(pp, p.c, 4, min, max); < return p; < } < < r6_t argparser_get_next_r6(argparser_t *pp, double min, double max) < { r6_t p; < argparser_get_next_rn(pp, p.c, 6, min, max); > { int i; > r4_t p; > for (i = 0; i < 4; i++) > { p.c[i] = argparser_get_next_double(pp, min, max); } --- 50,52c31,35 ----------------------- < r3_t argparser_get_next_r3_dir(argparser_t *pp) < { r3_t d; < argparser_get_next_rn(pp, d.c, 3, -DBL_MAX, +DBL_MAX); > r3_t argparser_get_next_dir(argparser_t *pp) > { int i; > r3_t d; > for (i = 0; i < 3; i++) > { d.c[i] = argparser_get_next_double(pp, -MAXDOUBLE, MAXDOUBLE); } ============================================================== ../../../LIBS/libs-core/libgeo/argparser_geo.h affine_tracker/libgeo/argparser_geo.h --- 2c2 ----------------------- < /* Last edited on 2008-07-14 22:27:36 by stolfi */ > /* Last edited on 2003-12-21 13:51:18 by stolfi */ --- 12d11 ----------------------- < #include --- 15d13 ----------------------- < #include --- 18d15 ----------------------- < r2_t argparser_get_next_r2(argparser_t *pp, double min, double max); --- 21,29c18,19 ----------------------- < r6_t argparser_get_next_r6(argparser_t *pp, double min, double max); < /* Parses with {argparser_get_next_double} next {N} arguments, which < must be in the range {[min.. max]}, as the coordinates of a point; < where {N} is 2,3,4, or 6. */ < < void argparser_get_next_rn(argparser_t *pp, double p[], int n, double min, double max); < /* Parses with {argparser_get_next_double} the next {n} arguments, < which must be in the range {[min .. max]}, and stores them in < {p[0.n-1]}. */ > /* Parses with {argparser_get_next_double} the next {N} arguments, > ({N=3} or {N=4}), which must be in the range {[min .. max]}. */ --- 31c21 ----------------------- < r3_t argparser_get_next_r3_dir(argparser_t *pp); > r3_t argparser_get_next_dir(argparser_t *pp); ============================================================== ../../../LIBS/libs-core/libgeo/gauss_elim.c affine_tracker/libgeo/gauss_elim.c --- 2c2 ----------------------- < /* Last edited on 2008-05-25 03:21:46 by stolfi */ > /* Last edited on 2007-02-09 22:31:07 by stolfi */ --- 5c5 ----------------------- < #include > #include ============================================================== ../../../LIBS/libs-core/libgeo/gauss_elim.h affine_tracker/libgeo/gauss_elim.h ============================================================== ../../../LIBS/libs-core/libgeo/hr2.c affine_tracker/libgeo/hr2.c ============================================================== ../../../LIBS/libs-core/libgeo/hr2.h affine_tracker/libgeo/hr2.h ============================================================== ../../../LIBS/libs-core/libgeo/hr3.c affine_tracker/libgeo/hr3.c ============================================================== ../../../LIBS/libs-core/libgeo/hr3.h affine_tracker/libgeo/hr3.h ============================================================== ../../../LIBS/libs-core/libgeo/hrn.c affine_tracker/libgeo/hrn.c ============================================================== ../../../LIBS/libs-core/libgeo/hrn.h affine_tracker/libgeo/hrn.h ============================================================== ../../../LIBS/libs-core/libgeo/i2.c affine_tracker/libgeo/i2.c ============================================================== ../../../LIBS/libs-core/libgeo/i2.h affine_tracker/libgeo/i2.h ============================================================== ../../../LIBS/libs-core/libgeo/lsq.c affine_tracker/libgeo/lsq.c ============================================================== ../../../LIBS/libs-core/libgeo/lsq.h affine_tracker/libgeo/lsq.h ============================================================== ../../../LIBS/libs-core/libgeo/qmin_simplex.c affine_tracker/libgeo/qmin_simplex.c --- 2c2 ----------------------- < /* Last edited on 2008-05-25 03:21:53 by stolfi */ > /* Last edited on 2007-01-04 11:39:37 by stolfi */ --- 4d3 ----------------------- < #define _GNU_SOURCE --- 14c13 ----------------------- < #include > #include --- 280c279 ----------------------- < { (*sob) = +INFINITY; > { (*sob) = +MAXDOUBLE; ============================================================== ../../../LIBS/libs-core/libgeo/qmin_simplex.h affine_tracker/libgeo/qmin_simplex.h ============================================================== ../../../LIBS/libs-core/libgeo/r2.c affine_tracker/libgeo/r2.c --- 2c2 ----------------------- < /* Last edited on 2008-05-24 23:54:00 by stolfi */ > /* Last edited on 2007-12-27 02:30:45 by stolfi */ --- 234c234 ----------------------- < { int np = p.ne; > { int np = p.nel; --- 239c239 ----------------------- < { r2_t *pi = &(p.e[ip]); > { r2_t *pi = &(p.el[ip]); ============================================================== ../../../LIBS/libs-core/libgeo/r2.h affine_tracker/libgeo/r2.h ============================================================== ../../../LIBS/libs-core/libgeo/r2x2.c affine_tracker/libgeo/r2x2.c --- 2c2 ----------------------- < /* Last edited on 2009-01-05 16:35:10 by stolfi */ > /* Last edited on 2007-10-28 11:30:24 by stolfi */ --- 54,60d53 ----------------------- < void r2x2_scale (double s, r2x2_t *A, r2x2_t *M) < { M->c[0][0] = s * A->c[0][0]; < M->c[0][1] = s * A->c[0][1]; < M->c[1][0] = s * A->c[1][0]; < M->c[1][1] = s * A->c[1][1]; < } < --- 69a63,70 ----------------------- > void r2x2_scalar_mul (r2x2_t *A, double s, r2x2_t *M) > { > M->c[0][0] = A->c[0][0]*s; > M->c[0][1] = A->c[0][1]*s; > M->c[1][0] = A->c[1][0]*s; > M->c[1][1] = A->c[1][1]*s; > } > ============================================================== ../../../LIBS/libs-core/libgeo/r2x2.h affine_tracker/libgeo/r2x2.h --- 2c2 ----------------------- < /* Last edited on 2009-01-05 16:33:26 by stolfi */ > /* Last edited on 2007-10-28 11:26:29 by stolfi */ --- 21c21 ----------------------- < /* Sets {M} to the transpose {A^t} of matrix {A}. */ > /* Sets {M} to the transpose {A^t} of matrix {A} */ --- 24c24 ----------------------- < /* Sets {r} to the product of row vector {x} by matrix {A}. */ > /* Sets {r} to the product of row vector {x} by matrix {A} */ --- 27,30c27 ----------------------- < /* Sets {r} to the product of matrix {A} by column vector {x}. */ < < void r2x2_scale (double s, r2x2_t *A, r2x2_t *M); < /* Sets {M} to the product of scalar {s} and matrix {A}. */ > /* Sets {r} to the product of matrix {A} by column vector {x} */ --- 33c30,33 ----------------------- < /* Sets {M} to the product of matrices {A} and {B}. */ > /* Sets {M} to the product of matrices {A} and {B} */ > > void r2x2_scalar_mul (r2x2_t *A, double s, r2x2_t *M); > /* Sets {M} to the product of matrix {A} and a scalar {s} */ --- 40c40 ----------------------- < /* Returns the determinant of matrix {A}. */ > /* Returns the determinant of matrix {A} */ --- 43c43 ----------------------- < /* Sets {M} to the adjoint of matrix {A}. */ > /* Sets {M} to the adjoint of matrix {A} */ --- 46c46 ----------------------- < /* Sets {M} to the inverse of matrix {A}. */ > /* Sets {M} to the inverse of matrix {A} */ ============================================================== ../../../LIBS/libs-core/libgeo/r3.c affine_tracker/libgeo/r3.c ============================================================== ../../../LIBS/libs-core/libgeo/r3.h affine_tracker/libgeo/r3.h ============================================================== ../../../LIBS/libs-core/libgeo/r3x3.c affine_tracker/libgeo/r3x3.c --- 2c2 ----------------------- < /* Last edited on 2009-01-05 16:38:39 by stolfi */ > /* Last edited on 2008-02-08 14:46:15 by stolfi */ --- 61,67d60 ----------------------- < void r3x3_scale (double s, r3x3_t *A, r3x3_t *M) < { int i, j, k; < for (i = 0; i < N; i++) < for (j = 0; j < N; j++) < { M->c[i][j] = s * A->c[i][j]; } < } < --- 100a94,113 ----------------------- > double r3x3_mag_sqr (r3x3_t *A) > { > double D00 = A->c[0][0] - 1.0; > double D01 = A->c[0][1]; > double D02 = A->c[0][2]; > > double D10 = A->c[1][0]; > double D11 = A->c[1][1] - 1.0; > double D12 = A->c[1][2]; > > double D20 = A->c[2][0]; > double D21 = A->c[2][1]; > double D22 = A->c[2][2] - 1.0; > > return > D00*D00 + D01*D01 + D02*D02 + > D10*D10 + D11*D11 + D12*D12 + > D20*D20 + D21*D21 + D22*D22; > } > ============================================================== ../../../LIBS/libs-core/libgeo/r3x3.h affine_tracker/libgeo/r3x3.h --- 2c2 ----------------------- < /* Last edited on 2009-01-05 16:35:36 by stolfi */ > /* Last edited on 2008-02-08 14:34:51 by stolfi */ --- 29,31d28 ----------------------- < void r3x3_scale (double s, r3x3_t *A, r3x3_t *M); < /* Sets {M} to the product of scalar {s} and matrix {A}. */ < --- 41a39,41 ----------------------- > double r3x3_mag_sqr (r3x3_t *A); > /* Returns the square of the Frobenius norm of {A-I} */ > ============================================================== ../../../LIBS/libs-core/libgeo/r4.c affine_tracker/libgeo/r4.c ============================================================== ../../../LIBS/libs-core/libgeo/r4.h affine_tracker/libgeo/r4.h ============================================================== ../../../LIBS/libs-core/libgeo/r4x4.c affine_tracker/libgeo/r4x4.c --- 2c2 ----------------------- < /* Last edited on 2009-01-05 16:38:59 by stolfi */ > /* Last edited on 2007-10-28 11:31:04 by stolfi */ --- 65,71d64 ----------------------- < void r4x4_scale (double s, r4x4_t *A, r4x4_t *M) < { int i, j, k; < for (i = 0; i < N; i++) < for (j = 0; j < N; j++) < { M->c[i][j] = s * A->c[i][j]; } < } < --- 138a132,162 ----------------------- > double r4x4_mag_sqr (r4x4_t *A) > { > double D00 = A->c[0][0] - 1.0; > double D01 = A->c[0][1]; > double D02 = A->c[0][2]; > double D03 = A->c[0][3]; > > double D10 = A->c[1][0]; > double D11 = A->c[1][1] - 1.0; > double D12 = A->c[1][2]; > double D13 = A->c[1][3]; > > double D20 = A->c[2][0]; > double D21 = A->c[2][1]; > double D22 = A->c[2][2] - 1.0; > double D23 = A->c[2][3]; > > double D30 = A->c[3][0]; > double D31 = A->c[3][1]; > double D32 = A->c[3][2]; > double D33 = A->c[3][3] - 1.0; > > return > D00*D00 + D01*D01 + D02*D02 + D03*D03 + > D10*D10 + D11*D11 + D12*D12 + D13*D13 + > D20*D20 + D21*D21 + D22*D22 + D23*D23 + > D30*D30 + D31*D31 + D32*D32 + D33*D33; > > } > > ============================================================== ../../../LIBS/libs-core/libgeo/r4x4.h affine_tracker/libgeo/r4x4.h --- 2c2 ----------------------- < /* Last edited on 2009-01-05 16:35:59 by stolfi */ > /* Last edited on 2007-10-28 11:27:47 by stolfi */ --- 29,31d28 ----------------------- < void r4x4_scale (double s, r4x4_t *A, r4x4_t *M); < /* Sets {M} to the product of scalar {s} and matrix {A}. */ < --- 41a39,41 ----------------------- > double r4x4_mag_sqr (r4x4_t *A); > /* Returns the square of the Frobenius norm of {A-I} */ > ============================================================== ../../../LIBS/libs-core/libgeo/r6.c affine_tracker/libgeo/r6.c ============================================================== ../../../LIBS/libs-core/libgeo/r6.h affine_tracker/libgeo/r6.h ============================================================== ../../../LIBS/libs-core/libgeo/r6x6.c affine_tracker/libgeo/r6x6.c --- 2c2 ----------------------- < /* Last edited on 2009-01-05 16:39:31 by stolfi */ > /* Last edited on 2007-10-28 11:30:53 by stolfi */ --- 62,68d61 ----------------------- < void r6x6_scale (double s, r6x6_t *A, r6x6_t *M) < { int i, j, k; < for (i = 0; i < N; i++) < for (j = 0; j < N; j++) < { M->c[i][j] = s * A->c[i][j]; } < } < ============================================================== ../../../LIBS/libs-core/libgeo/r6x6.h affine_tracker/libgeo/r6x6.h --- 2c2 ----------------------- < /* Last edited on 2009-01-05 16:36:23 by stolfi */ > /* Last edited on 2007-10-28 11:27:23 by stolfi */ --- 29,31d28 ----------------------- < void r6x6_scale (double s, r6x6_t *A, r6x6_t *M); < /* Sets {M} to the product of scalar {s} and matrix {A}. */ < ============================================================== ../../../LIBS/libs-core/libgeo/rmxn.c affine_tracker/libgeo/rmxn.c --- 2c2 ----------------------- < /* Last edited on 2009-01-05 17:32:43 by stolfi */ > /* Last edited on 2007-10-28 18:10:42 by stolfi */ --- 141c141 ----------------------- < double det = 1.0; > double d = 1.0; --- 144c144 ----------------------- < for (t = 0; t < n2; t += n+1) { det *= C[t]; } > for (t = 0; t < n2; t += n+1) { d *= C[t]; } --- 146c146 ----------------------- < return det; > return d; --- 153d152 ----------------------- < /* Copy {A} into the left half of {C}, fill the right half with the identity: */ --- 162c161 ----------------------- < for (i = 0; i < n2; i += n+1) { det *= C[i]; } > for (i = 0; i < n; i += n+1) { det *= C[i]; } --- 174,274d172 ----------------------- < double rmxn_inv_full (int n, double *A, double *M) < { < int i, j, t; < int n2 = n*n; < /* Copy {A} into {M}: */ < t = 0; < for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { M[t] = A[t]; t++; } } < < double det = 1.0; /* Accumulates the determinant. */ < < int prow[n], pcol[n]; < int k; < < for (k = 0; k < n; k++) < { /* Process the remaining {n-k}x{n-k} submatrix starting at {A[k][k]}. */ < < /* Find the element with largest abs value in the submatrix. */ < /* Store its value in {biga}, its indices in {prow[k],pcol[k]}: */ < prow[k] = k; < pcol[k] = k; < double biga = M[k*n+k]; < for (i = k; i < n; i++) < { for (j = k; j < n; j++) < { if (fabs (M[i*n+j]) > fabs (biga)) < { biga = M[i*n+j]; prow[k] = i; pcol[k] = j; } < } < } < < /* Swap rows {k} and {prow[k]}: */ < i = prow[k]; < if (i > k) < { for (j = 0; j < n; j++) < { double hold = -M[k*n+j]; < M[k*n+j] = M[i*n+j]; < M[i*n+j] = hold; < } < } < < /* Swap columns {k} and {pcol[k]}: */ < j = pcol[k]; < if (j > k) < { for (i = 0; i < n; i++) < { double hold = -M[i*n+k]; < M[i*n+k] = M[i*n+j]; < M[i*n+j] = hold; < } < } < < /* If the submatrix is all zeros, we failed: */ < if (biga == 0.0) { return 0.0; } < < /* Accumulate the determinant: */ < det *= biga; /* Product of pivots */ < < /* Negate column {k} and divide by minus the pivot {biga}. */ < for (i = 0; i < n; i++) { if (i != k) { M[i*n+k] /= -biga; } } < < /* Reduce the matrix: */ < for (i = 0; i < n; i++) < { if (i != k) < { double hold = M[i*n+k]; < for (j = 0; j < n; j++) < { if (j != k) { M[i*n+j] += hold * M[k*n+j]; } } < } < } < < /* Divide row {k} by pivot {biga}: */ < for (j = 0; j < n; j++) { if (j != k) { M[k*n+j] /= biga; } } < < /* Set the diagonal element to its reciprocal: */ < M[k*n+k] = 1.0 / biga; < } < < /* Undo the row and column interchanges, transposed: */ < for (k = n-2; k >= 0; k--) < { /* Swap column {k} with column {prow[k]}: */ < i = prow[k]; < if (i > k) < { for (j = 0; j < n; j++) < { double hold = M[j*n+k]; < M[j*n+k] = -M[j*n+i]; < M[j*n+i] = hold; < } < } < < /* Swap row {k} with row {pcol[k]}: */ < j = pcol[k]; < if (j > k) < { for (i = 0; i < n; i++) < { double hold = M[k*n+i]; < M[k*n+i] = -M[j*n+i]; < M[j*n+i] = hold; < } < } < } < < /* Return the determinant: */ < return det; < } < < --- 475a374,468 ----------------------- > void rmxn_inv2 (int n, double *A, double *M) > { > int i, j, k, t; > > double det, biga; > > t = 0; > for (i = 0; i < n; i++) > for (j = 0; j < n; j++) > { M[t] = A[t]; t++; } > int prow[n], pcol[n]; > > det = 1.0; > for (k = 0; k < n; k++) { > prow[k] = k; > pcol[k] = k; > biga = M[k*n+k]; > > /* Find the biggest element in the submatrix */ > for (i = k; i < n; i++) > for (j = k; j < n; j++) > if (fabs (M[i*n+j]) > fabs (biga)) { > biga = M[i*n+j]; > prow[k] = i; > pcol[k] = j; > } > > /* Interchange rows */ > i = prow[k]; > if (i > k) > for (j = 0; j < n; j++) { > double hold = -M[k*n+j]; > M[k*n+j] = M[i*n+j]; > M[i*n+j] = hold; > } > > /* Interchange columns */ > j = pcol[k]; > if (j > k) > for (i = 0; i < n; i++) { > double hold = -M[i*n+k]; > M[i*n+k] = M[i*n+j]; > M[i*n+j] = hold; > } > > /* Divide column by minus pivot (value of pivot element is contained in biga). */ > if (biga == 0.0) > return; > > for (i = 0; i < n; i++) > if (i != k) > M[i*n+k] /= -biga; > > /* Reduce matrix */ > for (i = 0; i < n; i++) > if (i != k) { > double hold = M[i*n+k]; > for (j = 0; j < n; j++) > if (j != k) > M[i*n+j] += hold * M[k*n+j]; > } > > /* Divide row by pivot */ > for (j = 0; j < n; j++) > if (j != k) { > M[k*n+j] /= biga; > } > > > det *= biga; /* Product of pivots */ > M[k*n+k] = 1.0 / biga; > } /* K loop */ > > /* Final row & column interchanges */ > for (k = (n-2); k >= 0; k--) { > i = prow[k]; > if (i > k) > for (j = 0; j < n; j++) { > double hold = M[j*n+k]; > M[j*n+k] = -M[j*n+i]; > M[j*n+i] = hold; > } > > j = pcol[k]; > if (j > k) > for (i = 0; i < n; i++) { > double hold = M[k*n+i]; > M[k*n+i] = -M[j*n+i]; > M[j*n+i] = hold; > } > } > } > > > ============================================================== ../../../LIBS/libs-core/libgeo/rmxn.h affine_tracker/libgeo/rmxn.h --- 2c2 ----------------------- < /* Last edited on 2009-01-05 17:14:39 by stolfi */ > /* Last edited on 2007-10-28 17:43:57 by stolfi */ --- 86,95c86,94 ----------------------- < double rmxn_inf_full (int n, double *A, double *M); < /* Sets {M} to the inverse of the {n x n} matrix {A}. The matrix {M} < may be the same as {A}. Returns the determinant of {A}. < < If the returned determinant is zero, the contents of {M} should be < considered garbage. Note that if {A} is singular or nearly so the < procedure may still return a nonzero value, but the contents of < {M} will probably be garbage all the same. The version < {rmxn_inf_full} uses full pivoting and therefore may be more < robust and/or accurate in these cases. */ > /* Sets {M} to the inverse of the {n x n} matrix {A}. > The matrix {M} may be the same as {A}. Returns the > determinant of {A}. If {A} is singular, the inverse > may contain infinities or {NaN}s. */ > > void rmxn_inv2 (int n, double *A, double *M); > /* Sets {M} to the inverse of the {n x n} matrix {A}. > The matrix {M} may be the same as {A}. > Another version using full pivoting. */ ============================================================== ../../../LIBS/libs-core/libgeo/rmxn_extra.c affine_tracker/libgeo/rmxn_extra.c ============================================================== ../../../LIBS/libs-core/libgeo/rmxn_extra.h affine_tracker/libgeo/rmxn_extra.h ============================================================== ../../../LIBS/libs-core/libgeo/rn.c affine_tracker/libgeo/rn.c --- 2c2 ----------------------- < Last edited on 2008-08-17 21:56:57 by stolfi > Last edited on 2007-10-28 21:36:54 by stolfi --- 13d12 ----------------------- < #include --- 363,372d361 ----------------------- < double rn_abs_rel_diff(int n, double *a, double *b, double abs_tol, double rel_tol) < { double max_error = 0.0; < int i; < for (i = 0; i < n; i++) < { double error = abs_rel_diff(a[i], b[i], abs_tol, rel_tol); < if (fabs(error) > max_error) { max_error = fabs(error); } < } < return max_error; < } < ============================================================== ../../../LIBS/libs-core/libgeo/rn.h affine_tracker/libgeo/rn.h --- 3c3 ----------------------- < Last edited on 2008-08-17 21:48:49 by stolfi > Last edited on 2007-10-28 21:36:28 by stolfi --- 124,128d123 ----------------------- < double rn_abs_rel_diff(int n, double *a, double *b, double abs_tol, double rel_tol); < /* Computes the maximum difference between each pair {a[i],b[i]}, < divided by {abs_tol} or {rel_tol} times the largest of the two < elements. See {abs_rel_diff} in {jsmath.h} for details. */ < ============================================================== ../../../LIBS/libs-core/libgeo/rn_test_tools.c affine_tracker/libgeo/rn_test_tools.c ============================================================== ../../../LIBS/libs-core/libgeo/rn_test_tools.h affine_tracker/libgeo/rn_test_tools.h ============================================================== ../../../LIBS/libs-core/libgeo/sym_eigen.c affine_tracker/libgeo/sym_eigen.c ============================================================== ../../../LIBS/libs-core/libgeo/sym_eigen.h affine_tracker/libgeo/sym_eigen.h ============================================================== ../../../LIBS/libs-core/libgeo/tests/gauss_elim/gauss_elim_test.c affine_tracker/libgeo/tests/gauss_elim/gauss_elim_test.c --- 2c2 ----------------------- < /* Last edited on 2008-05-25 03:32:49 by stolfi */ > /* Last edited on 2007-02-09 22:31:18 by stolfi */ --- 4d3 ----------------------- < #define _GNU_SOURCE --- 19c18 ----------------------- < #include > #include --- 377c376 ----------------------- < if (j >= n) { j = INT_MAX; } > if (j >= n) { j = MAXINT; } --- 381c380 ----------------------- < { ok = (j > jr) || ((jr == INT_MAX) && (j == INT_MAX)); > { ok = (j > jr) || ((jr == MAXINT) && (j == MAXINT)); --- 411c410 ----------------------- < if (j >= n) { j = INT_MAX; } > if (j >= n) { j = MAXINT; } --- 415c414 ----------------------- < j = ((i < n) && (M[i*n + i] != 0.0) ? i : INT_MAX); > j = ((i < n) && (M[i*n + i] != 0.0) ? i : MAXINT); --- 417c416 ----------------------- < if (j < INT_MAX) > if (j < MAXINT) --- 453c452 ----------------------- < if (j >= n) { j = INT_MAX; } > if (j >= n) { j = MAXINT; } --- 457c456 ----------------------- < j = ((i >= n) || (M[i*n + i] == 0.0) ? INT_MAX : i); > j = ((i >= n) || (M[i*n + i] == 0.0) ? MAXINT : i); --- 459c458 ----------------------- < if (j < INT_MAX) > if (j < MAXINT) --- 502c501 ----------------------- < if (jr >= q) { jr = INT_MAX; Mij = 0.0; } > if (jr >= q) { jr = MAXINT; Mij = 0.0; } --- 526c525 ----------------------- < if (jr < INT_MAX) { jr++; } > if (jr < MAXINT) { jr++; } ============================================================== ../../../LIBS/libs-core/libgeo/tests/hr2/hr2test.c affine_tracker/libgeo/tests/hr2/hr2test.c ============================================================== ../../../LIBS/libs-core/libgeo/tests/hr3/hr3test.c affine_tracker/libgeo/tests/hr3/hr3test.c ============================================================== ../../../LIBS/libs-core/libgeo/tests/lsq/lsq_test.c affine_tracker/libgeo/tests/lsq/lsq_test.c --- 2c2 ----------------------- < /* Last edited on 2008-05-25 03:22:08 by stolfi */ > /* Last edited on 2008-01-15 04:50:35 by stolfi */ --- 17c17 ----------------------- < #include > #include ============================================================== ../../../LIBS/libs-core/libgeo/tests/r2/r2test.c affine_tracker/libgeo/tests/r2/r2test.c --- 2c2 ----------------------- < /* Last edited on 2009-01-05 17:37:14 by stolfi */ > /* Last edited on 2007-10-28 11:07:13 by stolfi */ --- 367,379d366 ----------------------- < /* r2x2_scale: */ < throw_matrix(&A); < r = drandom(); < r2x2_scale(r, &A, &C); < for (i = 0; i < N; i++) < { for (j = 0; j < N; j++) < { double sel = r * A->c[i][j]; < rn_check_eps(C.c[i][j],sel,0.000000001 * fabs(sel), NO, NO, < "r2x2_scale error" < ); < } < } < ============================================================== ../../../LIBS/libs-core/libgeo/tests/r3/r3test.c affine_tracker/libgeo/tests/r3/r3test.c --- 2c2 ----------------------- < /* Last edited on 2009-01-05 17:38:27 by stolfi */ > /* Last edited on 2008-02-08 17:02:31 by stolfi */ --- 370,382d369 ----------------------- < /* r3x3_scale: */ < throw_matrix(&A); < r = drandom(); < r3x3_scale(r, &A, &C); < for (i = 0; i < N; i++) < { for (j = 0; j < N; j++) < { double sel = r * A->c[i][j]; < rn_check_eps(C.c[i][j],sel,0.000000001 * fabs(sel), NO, NO, < "r3x3_scale error" < ); < } < } < ============================================================== ../../../LIBS/libs-core/libgeo/tests/r4/r4test.c affine_tracker/libgeo/tests/r4/r4test.c --- 2c2 ----------------------- < /* Last edited on 2009-01-05 17:38:54 by stolfi */ > /* Last edited on 2007-10-28 11:08:42 by stolfi */ --- 379,391d378 ----------------------- < /* r4x4_scale: */ < throw_matrix(&A); < r = drandom(); < r4x4_scale(r, &A, &C); < for (i = 0; i < N; i++) < { for (j = 0; j < N; j++) < { double sel = r * A->c[i][j]; < rn_check_eps(C.c[i][j],sel,0.000000001 * fabs(sel), NO, NO, < "r4x4_scale error" < ); < } < } < ============================================================== ../../../LIBS/libs-core/libgeo/tests/r6/r6test.c affine_tracker/libgeo/tests/r6/r6test.c --- 2c2 ----------------------- < /* Last edited on 2009-01-05 17:39:25 by stolfi */ > /* Last edited on 2007-10-28 11:09:17 by stolfi */ --- 395,407d394 ----------------------- < /* r6x6_scale: */ < throw_matrix(&A); < r = drandom(); < r6x6_scale(r, &A, &C); < for (i = 0; i < N; i++) < { for (j = 0; j < N; j++) < { double sel = r * A->c[i][j]; < rn_check_eps(C.c[i][j],sel,0.000000001 * fabs(sel), NO, NO, < "r6x6_scale error" < ); < } < } < ============================================================== ../../../LIBS/libs-core/libgeo/tests/rn/rntest.c affine_tracker/libgeo/tests/rn/rntest.c --- 2,4c2 ----------------------- < /* Last edited on 2009-01-05 17:34:25 by stolfi */ < < #define _GNU_SOURCE > /* Last edited on 2007-10-28 21:37:40 by stolfi */ --- 20c18 ----------------------- < #include > #include --- 634,643d631 ----------------------- < /* rmxn_inv_full: */ < rmxn_inv_full(m, Amm, Bmm); < rmxn_mul(m, m, m, Amm, Bmm, Cmm); < for (i = 0; i < m; i++) < { for (j = 0; j < m; j++) < { double val = (i == j ? 1.0 : 0.0); < rn_check_eps(Cmm[m*i + j],val,0.000000001, NO, NO, "rmxn_inv_full error"); < } < } < --- 824,827c812,815 ----------------------- < double dMax = -INFINITY; < double dMin = +INFINITY; < double rMax = -INFINITY; < double rMin = +INFINITY; > double dMax = -MAXDOUBLE; > double dMin = +MAXDOUBLE; > double rMax = -MAXDOUBLE; > double rMin = +MAXDOUBLE; ============================================================== ../../../LIBS/libs-core/libgeo/tests/sym_eigen/c/testc.c affine_tracker/libgeo/tests/sym_eigen/c/testc.c ============================================================== ../../../LIBS/libs-core/libimg/colorfield.c affine_tracker/libimg/colorfield.c ============================================================== ../../../LIBS/libs-core/libimg/colorfield.h affine_tracker/libimg/colorfield.h ============================================================== ../../../LIBS/libs-core/libimg/colorfield_ramp.c affine_tracker/libimg/colorfield_ramp.c ============================================================== ../../../LIBS/libs-core/libimg/colorfield_ramp.h affine_tracker/libimg/colorfield_ramp.h ============================================================== ../../../LIBS/libs-core/libimg/colorfield_unif.c affine_tracker/libimg/colorfield_unif.c ============================================================== ../../../LIBS/libs-core/libimg/colorfield_unif.h affine_tracker/libimg/colorfield_unif.h ============================================================== ../../../LIBS/libs-core/libimg/colorfield_wavy.c affine_tracker/libimg/colorfield_wavy.c ============================================================== ../../../LIBS/libs-core/libimg/colorfield_wavy.h affine_tracker/libimg/colorfield_wavy.h ============================================================== ../../../LIBS/libs-core/libimg/float_image.c affine_tracker/libimg/float_image.c --- 2c2 ----------------------- < /* Last edited on 2009-01-04 09:37:05 by stolfi */ > /* Last edited on 2008-09-24 15:16:45 by stolfi */ --- 292,309d291 ----------------------- < void float_image_make_grayscale(float_image_t *A) < { < int NC = A->sz[0]; < int NX = A->sz[1]; < int NY = A->sz[2]; < if (NC == 1) { return; } < demand(NC == 3, "channel count must be 1 or 3"); < int x, y; < for (y = 0; y < NY; y++) < { for (x = 0; x < NX; x++) < { frgb_t pix = fic_get_frgb_pixel(fim, 0, 1, 2, x, y); < double value = frgb_Y(&pix); < for (c = 0; c < fim->sz[0]; c++) { pix.c[c] = value; } < fic_set_frgb_pixel(fim, 0, 1, 2, x, y, &pix); < } < } < } < --- 349d330 ----------------------- < demand(! isnan(scale), "scale factor is NaN"); --- 389,390c370,371 ----------------------- < if (isfinite(v)) < { /* Neither {ħINF} nor {NAN}: */ v -= avg; sum2 += v*v; } > if ((!isnan(v)) && (fabs(v) != INF)) > { v -= avg; sum2 += v*v; } --- 424,425c405,406 ----------------------- < if (isfinite(v)) < { /* Neither {ħINF} nor {NAN}: */ v -= sa; sum += v*v; } > if ((!isnan(v)) && (fabs(v) != INF)) > { v -= sa; sum += v*v; } --- 472,473c453,454 ----------------------- < int fst_x = ix / 2 + 1; < int lst_x = (ix + NX - 1) / 2; > int fst_x = (ix + 1) / 2; > int lst_x = (NX - 1 - ix) / 2; --- 478c459 ----------------------- < int x2 = ix - x1; if (x2 < 0) { x2 += NX; } > int x2 = ix - x1; if (ix < 0) { ix += NX; } --- 498,499c479,480 ----------------------- < int fst_y = iy / 2 + 1; < int lst_y = (iy + NY - 1) / 2; > int fst_y = (iy + 1) / 2; > int lst_y = (NY - 1 - iy) / 2; --- 504c485 ----------------------- < int y2 = iy - y1; if (y2 < 0) { y2 += NY; } > int y2 = iy - y1; if (iy < 0) { iy += NY; } ============================================================== ../../../LIBS/libs-core/libimg/float_image.h affine_tracker/libimg/float_image.h --- 5c5 ----------------------- < /* Last edited on 2009-01-04 09:43:33 by stolfi */ > /* Last edited on 2008-09-24 15:16:00 by stolfi */ --- 139,147c139 ----------------------- < /* PIXEL-WISE TRANSFORMATIONS */ < < void float_image_make_grayscale(float_image_t *A) < /* Converts the image {A} to grayscale. If {A} has a single channel, < does nothing. If {A} has three channels, assumes that they are < the red, green and blue channels of the RGB model with linear < enconding, and replaces all samples of each pixel by its brightness, < computed with {frgb_Y}. If the number of channels is not 1 or 3, < the procedure fails. */ > /* SAMPLE ENCODING AND RANGE */ --- 179,180d170 ----------------------- < /* PIXEL STATISTICS */ < --- 202,203d191 ----------------------- < /* IN-PLACE PIXEL REARRANGEMENT */ < ============================================================== ../../../LIBS/libs-core/libimg/float_image_color.c affine_tracker/libimg/float_image_color.c ============================================================== ../../../LIBS/libs-core/libimg/float_image_color.h affine_tracker/libimg/float_image_color.h ============================================================== ../../../LIBS/libs-core/libimg/float_image_filter.c affine_tracker/libimg/float_image_filter.c ============================================================== ../../../LIBS/libs-core/libimg/float_image_filter.h affine_tracker/libimg/float_image_filter.h ============================================================== ../../../LIBS/libs-core/libimg/float_image_geostereo.c affine_tracker/libimg/float_image_geostereo.c ============================================================== ../../../LIBS/libs-core/libimg/float_image_geostereo.h affine_tracker/libimg/float_image_geostereo.h ============================================================== ../../../LIBS/libs-core/libimg/float_image_hartley.c affine_tracker/libimg/float_image_hartley.c ============================================================== ../../../LIBS/libs-core/libimg/float_image_hartley.h affine_tracker/libimg/float_image_hartley.h --- 5c5 ----------------------- < /* Last edited on 2008-10-05 10:01:15 by stolfi */ > /* Last edited on 2008-09-23 13:43:21 by stolfi */ --- 59,63c59,62 ----------------------- < " number, measured in pixels, ranges between {sqrt(2)} (for a checkerboard)" \ < " and {+oo} (for the constant component). The /pixel frequency/" \ < " (in waves per pixel) is therefore {F = 1/W}, and varies" \ < " from 0 (for the constant component) to {sqrt(0.5)} for" \ < " the checkerboard. Apart from the constant component," \ > " number, measured in pixels, ranges between {sqrt(2)} (for a checkerboard) and {+oo} (for the" \ > " constant component). The /pixel frequency/ (in waves per pixel) is" \ > " therefore {F = 1/W}, and varies from 0 (for the constant component) to" \ > " {sqrt(0.5)} for the checkerboard. Apart from the constant component," \ ============================================================== ../../../LIBS/libs-core/libimg/float_image_masked.c affine_tracker/libimg/float_image_masked.c ============================================================== ../../../LIBS/libs-core/libimg/float_image_masked.h affine_tracker/libimg/float_image_masked.h --- 29,31d28 ----------------------- < /* Interpolates channel {c} of the masked image {im} at point {(x,y)}, < using an interpolator of degree {deginter}. Returns the interpolated < value in {val} and the corresponding weight in {*wht}. */ ============================================================== ../../../LIBS/libs-core/libimg/float_image_mismatch.c affine_tracker/libimg/float_image_mismatch.c ============================================================== ../../../LIBS/libs-core/libimg/float_image_mismatch.h affine_tracker/libimg/float_image_mismatch.h ============================================================== ../../../LIBS/libs-core/libimg/float_image_paint.c affine_tracker/libimg/float_image_paint.c --- 2c2 ----------------------- < /* Last edited on 2008-10-05 13:18:52 by stolfi */ > /* Last edited on 2008-07-30 01:47:46 by stolfi */ --- 13d12 ----------------------- < #include --- 17,25c16 ----------------------- < void float_image_paint_sample < ( float_image_t *A, < int c, < int ix, < int iy, < float_image_func_t *func, < float_image_func_t *mask, < int m < ) > void float_image_paint_sample(float_image_t *A, int c, int ix, int iy, float_image_func_t func, int m) --- 41,42c32,33 ----------------------- < double sum_wp = 0.0; /* Sum of antialias weights times mask values. */ < double sum_wpv = 0.0; /* Sum of antialias weights times mask values times paint value. */ > double sum_wc = 0.0; /* Sum of antialias weights of opaque subsamples. */ > double sum_wcv = 0.0; /* Sum of antialias weights times value of opaque subsamples. */ --- 55,61c46,48 ----------------------- < /* Get the overlay's opacity {p} at the sample point: */ < double p = (isnan(v) ? 0.0 : (mask == NULL ? 1.0 : mask(xp + xs, yp + ys))); < assert(! isnan(p)); < p = fmax(0.0, fmin(1.0, p)); < if (p != 0.0) < { sum_wp += w*p; < sum_wpv += w*p*v; > if (! isnan(v)) > { sum_wc += w; > sum_wcv += w*v; --- 67,68c54,55 ----------------------- < if (sum_wp > 0) < { /* Overlay is not totally transparent, mix it into the image sample: */ > if (sum_wc > 0) > { /* Mix the image sample: */ --- 70c57 ----------------------- < double w_old = 1.0 - sum_wp/sum_w; > double w_old = 1.0 - sum_wc/sum_w; --- 73c60 ----------------------- < (*sp) = w_old * v_old + sum_wpv/sum_w; > (*sp) = w_old * v_old + sum_wcv/sum_w; --- 84,85c71 ----------------------- < float_image_func_t *func, < float_image_func_t *mask, > float func (double x, double y), --- 101c87 ----------------------- < { float_image_paint_sample(A, c, ix, iy, func, mask, m); } > { float_image_paint_sample(A, c, ix, iy, func, m); } --- 136,137c122,123 ----------------------- < int xLo, xHi; float_image_paint_get_index_range(xctr, rMax, nx, &xLo, &xHi); < int yLo, yHi; float_image_paint_get_index_range(yctr, rMax, ny, &yLo, &yHi); > int xLo, xHi; float_image_get_index_range(xctr, rMax, nx, &xLo, &xHi); > int yLo, yHi; float_image_get_index_range(yctr, rMax, ny, &yLo, &yHi); --- 160c146 ----------------------- < float_image_paint_samples(A, c, xLo, xHi, yLo, yHi, &func_round, NULL, m); > float_image_paint_samples(A, c, xLo, xHi, yLo, yHi, func_round, m); --- 199,235c185 ----------------------- < float_image_paint_samples(A, c, xLo, xHi, yLo, yHi, &func_square, NULL, m); < } < } < < void float_image_paint_smudge < ( float_image_t *A, < int c, /* Channel. */ < double xctr, /* Center's X coordinate. */ < double yctr, /* Center's Y coordinate. */ < double xdev, /* Standard deviation in X direction. */ < double ydev, /* Standard deviation in Y direction. */ < bool_t fold, /* TRUE to fold over at image boundaries. */ < float vctr, /* Ink value at center. */ < int m /* Subsampling parameter. */ < ) < { < int nx = A->sz[1]; < int ny = A->sz[2]; < < /* Determine the affected ranges : */ < int max_devs = gauss_table_BIG_ARG; /* Max devs that is worth considering. */ < int xLo, xHi; float_image_paint_get_index_range(xctr, max_devs*xdev, nx, &xLo, &xHi); < int yLo, yHi; float_image_paint_get_index_range(yctr, max_devs*ydev, ny, &yLo, &yHi); < < auto float func_unif(double x, double y); < /* Procedural image with uniform color {vctr}. */ < < float func_unif(double x, double y) < { return vctr; } < < auto float mask_bell(double x, double y); < /* Procedural mask with gaussian bell shape. */ < < float mask_bell(double x, double y) < { double gx = gauss_table_folded_bell(x - xctr, xdev, (fold ? nx : 0)); < double gy = gauss_table_folded_bell(y - yctr, ydev, (fold ? ny : 0)); < return gx*gy; > float_image_paint_samples(A, c, xLo, xHi, yLo, yHi, func_square, m); --- 237,238d186 ----------------------- < < float_image_paint_samples(A, c, xLo, xHi, yLo, yHi, &func_unif, &mask_bell, m); --- 241c189 ----------------------- < void float_image_paint_get_index_range(double z, double r, int n, int *iLo, int *iHi) > void float_image_get_index_range(double z, double r, int n, int *iLo, int *iHi) --- 279,280c227,228 ----------------------- < int xLo, xHi; float_image_paint_get_index_range(xctr, rMax, nx, &xLo, &xHi); < int yLo, yHi; float_image_paint_get_index_range(yctr, rMax, ny, &yLo, &yHi); > int xLo, xHi; float_image_get_index_range(xctr, rMax, nx, &xLo, &xHi); > int yLo, yHi; float_image_get_index_range(yctr, rMax, ny, &yLo, &yHi); --- 314c262 ----------------------- < float_image_paint_samples(A, c, xLo, xHi, yLo, yHi, &func_cross, NULL, m); > float_image_paint_samples(A, c, xLo, xHi, yLo, yHi, func_cross, m); ============================================================== ../../../LIBS/libs-core/libimg/float_image_paint.h affine_tracker/libimg/float_image_paint.h --- 5c5 ----------------------- < /* Last edited on 2008-10-05 11:14:54 by stolfi */ > /* Last edited on 2008-07-30 00:59:30 by stolfi */ --- 29,37c29 ----------------------- < void float_image_paint_sample < ( float_image_t *A, < int c, < int ix, < int iy, < float_image_func_t *func, < float_image_func_t *mask, < int m < ); > void float_image_paint_sample(float_image_t *A, int c, int ix, int iy, float_image_func_t func, int m); --- 39,40c31 ----------------------- < procedural image {func}, whose opacity is defined < by the procedural image {mask}. > procedural image {func}. --- 42,51c33,34 ----------------------- < The opacity {mask(x,y)} is interpreted as the local fraction of < the background that is covered by the overlay. Thus, < {mask(x,y)<=0} means that the overlay is transparent (preserving < the underlying image), {mask(x,y)>=1} means it is fully opaque, < and {mask(x,y)} between 0 and 1 means it is semi-transparent. < < As special cases,assumes that the overlay is fully transparent if < {func(x,y) == NAN}, irrespective of {mask}; otherise, if {mask} is < NULL, assumes {mask(x,y) == 1} for all {x,y}. Fails if {mask(x,y)} < is {NAN}. > Assumes that the procedural image is transparent where {func(x,y)} > is {NAN}; at those points, it preserves the original image value. --- 53c36 ----------------------- < The result image is filtered by averaging it over a grid of > The overlaid image is filtered by averaging it over a grid of --- 65,66c48 ----------------------- < float_image_func_t *func, < float_image_func_t *mask, > float_image_func_t func, --- 111,129d92 ----------------------- < void float_image_paint_smudge < ( float_image_t *A, < int c, /* Channel. */ < double xctr, /* Center's X coordinate. */ < double yctr, /* Center's Y coordinate. */ < double xdev, /* Standard deviation in X direction. */ < double ydev, /* Standard deviation in Y direction. */ < bool_t fold, /* TRUE to fold over at image boundaries. */ < float vctr, /* Ink value at center. */ < int m /* Subsampling parameter. */ < ); < /* Paints onto channel {c} of image {A} a fuzzy dot centered at {xctr,yctr}. < < The dot will have color {vfill}; it will be fully opaque at its < center, fading out to transparency according to an axis-aligned < Gaussian bell fuction with deviations {xdev,ydev} along each axis. < If {fold} is true, the smudge will fold over at the image < boundaries. */ < --- 149c112 ----------------------- < void float_image_paint_get_index_range(double z, double r, int n, int *iLo, int *iHi); > void float_image_get_index_range(double z, double r, int n, int *iLo, int *iHi); ============================================================== ../../../LIBS/libs-core/libimg/float_image_transform.c affine_tracker/libimg/float_image_transform.c ============================================================== ../../../LIBS/libs-core/libimg/float_image_transform.h affine_tracker/libimg/float_image_transform.h ============================================================== ../../../LIBS/libs-core/libimg/float_image_trim.c affine_tracker/libimg/float_image_trim.c ============================================================== ../../../LIBS/libs-core/libimg/float_image_trim.h affine_tracker/libimg/float_image_trim.h ============================================================== ../../../LIBS/libs-core/libimg/float_pnm_image.c affine_tracker/libimg/float_pnm_image.c --- 2c2 ----------------------- < /* Last edited on 2008-11-11 01:21:12 by stolfi */ > /* Last edited on 2008-05-25 01:52:58 by stolfi */ --- 89a90 ----------------------- > int ch[], --- 92d92 ----------------------- < int ch[], --- 134,136c134 ----------------------- < { double lok = (lo == NULL ? 0.0 : lo[k]); < double hik = (hi == NULL ? 1.0 : hi[k]); < c = (ch == NULL ? k : ch[k]); > { c = (ch == NULL ? k : ch[k]); --- 137a136,137 ----------------------- > double loc = (lo == NULL ? 0.0 : lo[c]); > double hic = (hi == NULL ? 1.0 : hi[c]); --- 139c139 ----------------------- < ( v, maxval, lok, hik, > ( v, maxval, loc, hic, --- 153,155c153,155 ----------------------- < { double lok = (lo == NULL ? 0.0 : lo[k]); < double hik = (hi == NULL ? 1.0 : hi[k]); < c = (ch == NULL ? k : ch[k]); > { c = (ch == NULL ? k : ch[k]); > double loc = (lo == NULL ? 0.0 : lo[c]); > double hic = (hi == NULL ? 1.0 : hi[c]); --- 157c157 ----------------------- < ( c, k, vmin[k], vmax[k], lok, hik, clo[k], chi[k], maxval, imin[k], imax[k]); > ( c, k, vmin[k], vmax[k], loc, hic, clo[k], chi[k], maxval, imin[k], imax[k]); ============================================================== ../../../LIBS/libs-core/libimg/float_pnm_image.h affine_tracker/libimg/float_pnm_image.h --- 5c5 ----------------------- < /* Last edited on 2009-01-04 09:26:11 by stolfi */ > /* Last edited on 2008-07-14 05:11:58 by stolfi */ --- 37,39c37,39 ----------------------- < double lo[], /* Parameter order AND MEANING changed on 2008-11-10. */ < double hi[], /* Parameter order AND MEANING changed on 2008-11-10. */ < int ch[], /* Parameter order AND MEANING changed on 2008-11-10. */ > int ch[], > double lo[], > double hi[], --- 44c44 ----------------------- < number of channels of {pim} will be {chns}, and the samples of > number of channels of {pim} with be {chns}, and the samples of --- 52c52 ----------------------- < maxval, lo[k], hi[k], ...)}. If {lo} is NULL, it defaults to a > maxval, lo[c], hi[c], ...)}. If {lo} is NULL, it defaults to a --- 60,64c60 ----------------------- < conversion to {stderr}. < < NOTE: the indexing of {lo} and {hi} changed from {c} < to {k} on 2008-11-10. The order of the parameters < {lo,hi,ch} was changed to make old uses stand out. */ > conversion to {stderr}. */ ============================================================== ../../../LIBS/libs-core/libimg/float_pnm_image_buffer.c affine_tracker/libimg/float_pnm_image_buffer.c ============================================================== ../../../LIBS/libs-core/libimg/float_pnm_image_buffer.h affine_tracker/libimg/float_pnm_image_buffer.h ============================================================== ../../../LIBS/libs-core/libimg/frgb.c affine_tracker/libimg/frgb.c ============================================================== ../../../LIBS/libs-core/libimg/frgb.h affine_tracker/libimg/frgb.h ============================================================== ../../../LIBS/libs-core/libimg/frgb_inksep.c affine_tracker/libimg/frgb_inksep.c ============================================================== ../../../LIBS/libs-core/libimg/frgb_inksep.h affine_tracker/libimg/frgb_inksep.h ============================================================== ../../../LIBS/libs-core/libimg/frgb_ops.c affine_tracker/libimg/frgb_ops.c --- 2c2 ----------------------- < ** Last edited on 2009-01-04 10:48:41 by stolfi > ** Last edited on 2008-07-19 21:12:31 by stolfi --- 23a24,35 ----------------------- > /* Test for NaN - in case it is not defined in */ > #ifdef isnan > #else > int __isnanf(float x); > int __isnan(double x); > int __isnanl(long double x); > #define isnan(x) \ > ( sizeof(x) == sizeof(float) ? __isnanf(x) : \ > sizeof(x) == sizeof(double) ? __isnan(x) : \ > __isnanl(x) ) > #endif > --- 77a90,103 ----------------------- > frgb_t frgb_read(FILE *rd, double lo, double hi) > { frgb_t p; > int i; > for (i = 0; i < 3; i++) > { double pi = fget_double(rd); > if ((pi < lo) || (pi > hi)) > { fprintf(stderr, " component [%d] = %25.16e\n", i, pi); > demand(FALSE, "bad {frgb_t} component value"); > } > p.c[i] = pi; > } > return p; > } > --- 93,106d118 ----------------------- < frgb_t frgb_read(FILE *rd, double lo, double hi) < { frgb_t p; < int i; < for (i = 0; i < 3; i++) < { double pi = fget_double(rd); < if ((pi < lo) || (pi > hi)) < { fprintf(stderr, " component [%d] = %25.16e\n", i, pi); < demand(FALSE, "bad {frgb_t} component value"); < } < p.c[i] = pi; < } < return p; < } < --- 199,200c211,236 ----------------------- < { frgb_t q = (frgb_t){{ lum, lum, lum }}; < return frgb_clip_rgb_towards(p, &q); > { /* Clip {p} to the unit cube, preserving hue: */ > frgb_t x; > int i; > /* Compute chrominance {x = lum*White - p}, > and the minimum scale factor {s \geq 1} that leaves > {x/s + lum*White} inside the unit cube: */ > double s = 1.0; > for (i = 0; i < 3; i++) > { double pi = p->c[i]; > double xi = pi - lum; > if (s*lum < -xi) > { s = -xi/lum; } > else if (s*obs < +xi) > { s = +xi/obs; } > x.c[i] = xi; > } > if (s > 1.0) > { /* Compute output pixel {p = x/s + lum*White}: */ > for (i = 0; i < 3; i++) > { double ri = x.c[i]/s + lum; > /* Guarding against roundoff: */ > if (ri < 0) { ri = 0; } > if (ri > 1) { ri = 1; } > p->c[i] = ri; > } > } --- 212c248 ----------------------- < double s = 1.0; > double s = 1.0; /* L-inf distance from {gv} to middle gray. */ --- 342c378 ----------------------- < void frgb_print(FILE *f, char *pref, frgb_t *p, char *fmt, char *suff) > void frgb_print(FILE *f, char *pref, frgb_t *p, char *suff) --- 346,347c382,383 ----------------------- < { if (k > 0) { fputc(' ', f); } < fprintf(f, fmt, p->c[k]); > { /* For 16-bit samples, 5 decimals are are nec. & suff. (1/65536 = 0.0000152+): */ > fprintf(f, "%s%8.5f", (k == 0 ? "" : " "), p->c[k]); --- 357c393 ----------------------- < { fprintf(f, "%s%5d", (k == 0 ? "" : " "), p[k]); } > { fprintf(f, "%s%3d", (k == 0 ? "" : " "), p[k]); } --- 363c399 ----------------------- < if (frgb_DEBUG) > if (debug) --- 365c401 ----------------------- < frgb_print(stderr, "( ", p, "%10.7f", " )"); > frgb_print(stderr, "( ", p, " )"); --- 372c408 ----------------------- < if (frgb_DEBUG) > if (debug) ============================================================== ../../../LIBS/libs-core/libimg/frgb_ops.h affine_tracker/libimg/frgb_ops.h --- 2c2 ----------------------- < ** Last edited on 2009-01-04 10:47:47 by stolfi > ** Last edited on 2008-08-11 14:20:39 by stolfi --- 116,130c116 ----------------------- < /* PARSING TRIPLETS */ < < #define frgb_parse_HELP \ < "{R_VALUE} {G_VALUE} {B_VALUE}" < < #define frgb_parse_INFO \ < "three real numbers. E.g.\n" \ < "\n" \ < " \"1 1 1\"\n" \ < " \"1.000 0.500 0.600\"" < < frgb_t frgb_parse(argparser_t *pp, double lo, double hi); < /* Parses three consecutive numbers from the command line, < as described by {frgb_parse_INFO}. Checks whether each < component lies in {[lo _ hi]}. Increments {*argn}. */ > /* PARSING COLOR VALUES */ --- 136,137d121 ----------------------- < /* PARSING COLOR VALUES */ < --- 153,155c137,138 ----------------------- < as described by {frgb_parse_color_INFO}. If a denominator < is present, divides it into all three components. Returns the color < as three floats. Increments {*argn}. */ > as described by {frgb_parse_color_INFO}. Returns the color > as three doubles in {[0 _ 1]}. Increments {*argn}. */ --- 161a145,149 ----------------------- > frgb_t frgb_parse(argparser_t *pp, double lo, double hi); > /* Parses three consecutive numbers from the command line, > checks whether each component lies in {[lo _ hi]}. > Increments {*argn}. */ > --- 280,283c268,270 ----------------------- < void frgb_print(FILE *f, char *pref, frgb_t *p, char *fmt, char *suff); < /* Prints {*p} to file {f}, surrounded by the given {pref} and < {suff} strings. Each component is printed with the format {fmt}, < which should be suitable for a float value. */ > void frgb_print(FILE *f, char *pref, frgb_t *p, char *suff); > /* Prints {*p} to file {f}, surrounded by the > given {pref} and {suff} strings. */ --- 287,288c274 ----------------------- < given {pref} and {suff} strings. (This function should be moved < to some other interface.) */ > given {pref} and {suff} strings. */ --- 292c278 ----------------------- < extern int frgb_DEBUG; /* Set this variable to activate the following procs. */ > extern int debug; /* Set this variable to activate the following procs. */ --- 296c282 ----------------------- < {frgb_DEBUG} is true. The printout is preceded by the string {label} > {debug} is true. The printout is preceded by the string {label} --- 301,303c287,288 ----------------------- < {frgb_DEBUG} is true. The printout is preceded by the string {label} < and followed by {tail}. (This function should be moved < to some other interface.) */ > {debug} is true. The printout is preceded by the string {label} > and followed by {tail}. */ ============================================================== ../../../LIBS/libs-core/libimg/frgb_path.c affine_tracker/libimg/frgb_path.c ============================================================== ../../../LIBS/libs-core/libimg/frgb_path.h affine_tracker/libimg/frgb_path.h ============================================================== ../../../LIBS/libs-core/libimg/image_coords.c affine_tracker/libimg/image_coords.c --- 2c2 ----------------------- < /* Last edited on 2009-01-04 10:58:48 by stolfi */ > /* Last edited on 2007-09-06 18:25:47 by stolfi */ --- 15,16c15,16 ----------------------- < ( bool_t xRev, < bool_t yRev, > ( bool_t hrev, > bool_t vrev, --- 28,29c28,29 ----------------------- < if (xRev) { A.c[1][1] = -w; A.c[0][1] = w*cols; } < if (yRev) { A.c[2][2] = -w; A.c[0][2] = w*rows; } > if (hrev) { A.c[1][1] = -w; A.c[0][1] = w*cols; } > if (vrev) { A.c[2][2] = -w; A.c[0][2] = w*rows; } --- 35a36,37 ----------------------- > fprintf(stderr, "center = %d cols = %d rows = %d\n", center, cols, rows); > fprintf(stderr, "A = \n"); r3x3_print(stderr, &A); --- 43c45 ----------------------- < void imgc_parse_x_axis(argparser_t *pp, bool_t *xLeft) > void imgc_parse_haxis(argparser_t *pp, bool_t *hleft) --- 45,48c47 ----------------------- < if < ( (argparser_keyword_present(pp, "-xAxis")) || < (argparser_keyword_present(pp, "-hAxis")) < ) > if (argparser_keyword_present(pp, "-haxis")) --- 50c49 ----------------------- < { (*xLeft) = TRUE; } > { (*hleft) = TRUE; } --- 52c51 ----------------------- < { (*xLeft) = FALSE; } > { (*hleft) = FALSE; } --- 58c57 ----------------------- < void imgc_parse_y_axis(argparser_t *pp, bool_t *yDown) > void imgc_parse_vaxis(argparser_t *pp, bool_t *vdown) --- 60,63c59 ----------------------- < if < ( (argparser_keyword_present(pp, "-yAxis"))|| < (argparser_keyword_present(pp, "-vAxis")) < ) > if (argparser_keyword_present(pp, "-vaxis")) --- 65c61 ----------------------- < { (*yDown) = FALSE; } > { (*vdown) = FALSE; } --- 67c63 ----------------------- < { (*yDown) = TRUE; } > { (*vdown) = TRUE; } --- 73c69 ----------------------- < void imgc_parse_input_center_org(argparser_t *pp, bool_t *iCenter, r2_t *iOrg) > void imgc_parse_icenter_iorg(argparser_t *pp, bool_t *icenter, r2_t *iorg) --- 75,80c71,76 ----------------------- < if (argparser_keyword_present(pp, "-iCenter")) < { (*iCenter) = TRUE; } < else if (argparser_keyword_present(pp, "-iOrg")) < { (*iCenter) = FALSE; < iOrg->c[0] = argparser_get_next_double(pp, -BIG, +BIG); < iOrg->c[1] = argparser_get_next_double(pp, -BIG, +BIG); > if (argparser_keyword_present(pp, "-icenter")) > { (*icenter) = TRUE; } > else if (argparser_keyword_present(pp, "-iorg")) > { (*icenter) = FALSE; > iorg->c[0] = argparser_get_next_double(pp, -BIG, +BIG); > iorg->c[1] = argparser_get_next_double(pp, -BIG, +BIG); --- 84c80 ----------------------- < void imgc_parse_output_center_org(argparser_t *pp, bool_t *oCenter, r2_t *oOrg) > void imgc_parse_ocenter_oorg(argparser_t *pp, bool_t *ocenter, r2_t *oorg) --- 86,91c82,87 ----------------------- < if (argparser_keyword_present(pp, "-oCenter")) < { (*oCenter) = TRUE; } < else if (argparser_keyword_present(pp, "-oOrg")) < { (*oCenter) = FALSE; < oOrg->c[0] = argparser_get_next_double(pp, -BIG, +BIG); < oOrg->c[1] = argparser_get_next_double(pp, -BIG, +BIG); > if (argparser_keyword_present(pp, "-ocenter")) > { (*ocenter) = TRUE; } > else if (argparser_keyword_present(pp, "-oorg")) > { (*ocenter) = FALSE; > oorg->c[0] = argparser_get_next_double(pp, -BIG, +BIG); > oorg->c[1] = argparser_get_next_double(pp, -BIG, +BIG); --- 95c91 ----------------------- < void imgc_parse_output_size(argparser_t *pp, int *oCols, int *oRows, int max_size) > void imgc_parse_osize(argparser_t *pp, int *ocols, int *orows, int max_size) --- 97,99c93,95 ----------------------- < if (argparser_keyword_present(pp, "-oSize")) < { (*oCols) = argparser_get_next_int(pp, 1, max_size); < (*oRows) = argparser_get_next_int(pp, 1, max_size); > if (argparser_keyword_present(pp, "-osize")) > { (*ocols) = argparser_get_next_int(pp, 1, max_size); > (*orows) = argparser_get_next_int(pp, 1, max_size); ============================================================== ../../../LIBS/libs-core/libimg/image_coords.h affine_tracker/libimg/image_coords.h --- 2c2 ----------------------- < /* Last edited on 2009-01-04 10:57:51 by stolfi */ > /* Last edited on 2007-09-06 18:26:59 by stolfi */ --- 14,15c14,15 ----------------------- < ( bool_t xRev, < bool_t yRev, > ( bool_t hrev, > bool_t vrev, --- 29,31c29,31 ----------------------- < The US has the X axis pointing to the right if {xRev} is FALSE, < and to the left if {xRev} is TRUE; and the Y axis pointing up if {yRev} < is FALSE, and down if {yRev} is true. The US origin is located at > The US has the X axis pointing to the right if {hrev} is FALSE, > and to the left if {hrev} is TRUE; the Y axis pointin up if {vrev} > is FALSE, and down if {vrev} is true. The US origin is located at --- 36,37c36,37 ----------------------- < {xRev} is FALSE, the right edge if {xRev} is true; the bottom edge < if {yRev} is FALSE, the top edge if {yRev} is TRUE). > {hrev} is FALSE, the right edge if {hrev} is true; the bottom edge > if {vrev} is FALSE, the top edge if {vrev} is TRUE). --- 54c54 ----------------------- < " the \"-xAxis\" and \"-yAxis\" command line arguments. These" \ > " the \"-haxis\" and \"-vaxis\" command line arguments. These" \ --- 65,69c65,69 ----------------------- < void imgc_parse_x_axis(argparser_t *pp, bool_t *xLeft); < /* Parses the "-xAxis" command line option, according to < {imgc_parse_x_axis_HELP}. Sets {*xLeft} to TRUE if "-xAxis left" is < present, to FALSE if "-xAxis right" is present. If the option is < not present, leaves {*xLeft} unchanged. */ > void imgc_parse_haxis(argparser_t *pp, bool_t *hleft); > /* Parses the "-haxis" command line option, according to > {imgc_parse_haxis_HELP}. Sets {*hleft} to TRUE if "-haxis left" is > present, to FALSE if "-haxis right" is present. If the option is > not present, leaves {*hleft} unchanged. */ --- 71,72c71,72 ----------------------- < #define imgc_parse_x_axis_HELP \ < "[ -xAxis { right | left } ]" > #define imgc_parse_haxis_HELP \ > "[ -haxis { right | left } ]" --- 74,75c74,75 ----------------------- < #define imgc_parse_x_axis_HELP_INFO \ < " -xAxis { right | left }\n" \ > #define imgc_parse_haxis_HELP_INFO \ > " -haxis { right | left }\n" \ --- 78,80c78,80 ----------------------- < " default horizontal position of the origin: at the left edge" \ < " of the image if \"right\", or at the right edge" \ < " if \"left\". The keyword \"-hAxis\" is accepted as synonymous of \"-xAxis\"." > " default horizontal position of the origin: the left edge" \ > " of the image if \"right\", or the right edge" \ > " if \"left\"." --- 82,83c82,83 ----------------------- < #define imgc_parse_x_axis_pbm_default_INFO \ < "The default is \"-xAxis right\" as in most image processing tools." > #define imgc_parse_haxis_pbm_default_INFO \ > "The default is \"-haxis right\" as in most image processing tools." --- 85,86c85,86 ----------------------- < #define imgc_parse_x_axis_math_default_INFO \ < "The default is \"-xAxis right\" as in mathematical tradition." > #define imgc_parse_haxis_math_default_INFO \ > "The default is \"-haxis right\" as in mathematical tradition." --- 90,94c90,94 ----------------------- < void imgc_parse_y_axis(argparser_t *pp, bool_t *yDown); < /* Parses the "-yAxis" command line option, according to < {imgc_parse_y_axis_HELP}. Sets {*yDown} to TRUE if the "-yAxis < down" is present, to FALSE if "-yAxis up" is present. If the < option is not present, leaves {*yDown} unchanged. */ > void imgc_parse_vaxis(argparser_t *pp, bool_t *vdown); > /* Parses the "-vaxis" command line option, according to > {imgc_parse_vaxis_HELP}. Sets {*vdown} to TRUE if the "-vaxis > down" is present, to FALSE if "-vaxis up" is present. If the > option is not present, leaves {*vdown} unchanged. */ --- 96,97c96,97 ----------------------- < #define imgc_parse_y_axis_HELP_INFO \ < " -yAxis { down | up }\n" \ > #define imgc_parse_vaxis_HELP_INFO \ > " -vaxis { down | up }\n" \ --- 99,102c99,101 ----------------------- < " the vertical axis of image coordinate systems. It also defines the" \ < " default vertical position of the origin: at the top edge of the" \ < " image if \"down\", or at the bottom edge if \"up\". The" \ < " keyword \"-vAxis\" is accepted as synonymous of \"-yAxis\"." > " the vertical axis for both images. It also defines the" \ > " default vertical position of the origin: the top edge of the" \ > " image if \"down\", or the bottom edge if \"up\"." --- 104,105c103,104 ----------------------- < #define imgc_parse_y_axis_pbm_default_INFO \ < "The default is \"-yAxis down\" as in most image processing tools." \ > #define imgc_parse_vaxis_pbm_default_INFO \ > "The default is \"-yaxis down\" as in most image processing tools." \ --- 107,108c106,107 ----------------------- < #define imgc_parse_y_axis_math_default_INFO \ < "The default is \"-yAxis up\", in the mathematical tradition." \ > #define imgc_parse_vaxis_math_default_INFO \ > "The default is \"-yaxis up\", in the mathematical tradition." \ --- 110,111c109,110 ----------------------- < #define imgc_parse_y_axis_HELP \ < "[ -yAxis { down | up } ]" > #define imgc_parse_vaxis_HELP \ > "[ -vaxis { down | up } ]" --- 115,116c114,115 ----------------------- < void imgc_parse_input_center_org(argparser_t *pp, bool_t *iCenter, r2_t *iOrg); < /* Parses the mutually exclusive arguments "-iCenter" and "-iOrg", > void imgc_parse_icenter_iorg(argparser_t *pp, bool_t *icenter, r2_t *iorg); > /* Parses the mutually exclusive arguments "-icenter" and "-iorg", --- 118,122c117,121 ----------------------- < according to the syntax specs {imgc_parse_input_center_org_HELP}. If < "-iCenter"is preent, sets {*iCenter} to TRUE and leaves {*iOrg} < unchanged. If "-iOrg" is present, sets {*iCenter} to FALSE, and sets < {*iOrg} to the given point. If neither is present, leaves {*iCenter} < and {*iOrg} unchanged. */ > according to the syntax specs {imgc_parse_icenter_iorg_HELP}. If > "-icenter"is preent, sets {*icenter} to TRUE and leaves {*iorg} > unchanged. If "-iorg" is present, sets {*icenter} to FALSE, and sets > {*iorg} to the given point. If neither is present, leaves {*icenter} > and {*iorg} unchanged. */ --- 124,125c123,124 ----------------------- < #define imgc_parse_input_center_org_HELP \ < "[ -iCenter | -iOrg {CX_IN} {CY_IN} ]" \ > #define imgc_parse_icenter_iorg_HELP \ > "[ -icenter | -iorg {CX_IN} {CY_IN} ] \\\n" \ --- 129c128 ----------------------- < " can be overriden by the \"-iOrg\" or \"-iCenter\" argument." > " can be overriden by the \"-iorg\" or \"-icenter\" argument." --- 131,133c130,132 ----------------------- < #define imgc_parse_input_center_org_HELP_INFO \ < " -iCenter\n" \ < " -iOrg {CX_IN} {CY_IN}\n" \ > #define imgc_parse_icenter_iorg_HELP_INFO \ > " -icenter\n" \ > " -iorg {CX_IN} {CY_IN}\n" \ --- 136,137c135,136 ----------------------- < " images. The \"-iCenter\" option sets the origin" \ < " at the center of the image domain. The \"-iOrg\" option sets" \ > " images. The \"-icenter\" option sets the origin" \ > " at the center of the image domain. The \"-iorg\" option sets" \ --- 140c139 ----------------------- < " assumes \"-iOrg 0 0\" (which means the default origin)." > " assumes \"-iorg 0 0\" (which means the default origin)." --- 144c143 ----------------------- < void imgc_parse_output_center_org(argparser_t *pp, bool_t *oCenter, r2_t *oOrg); > void imgc_parse_ocenter_oorg(argparser_t *pp, bool_t *ocenter, r2_t *oorg); --- 146,147c145,146 ----------------------- < images, according to {imgc_parse_output_center_org_HELP_INFO}. < Looks for the keywords "-oCenter" and "-oOrg". */ > images, according to {imgc_parse_ocenter_oorg_HELP_INFO}. > Looks for the keywords "-ocenter" and "-oorg". */ --- 149,150c148,149 ----------------------- < #define imgc_parse_output_center_org_HELP \ < "[ -oCenter | -oOrg {CX_OUT} {CY_OUT} ]" \ > #define imgc_parse_ocenter_oorg_HELP \ > "[ -ocenter | -oorg {CX_OUT} {CY_OUT} ] \\\n" \ --- 154c153 ----------------------- < " can be overriden by the \"-oOrg\" or \"-oCenter\" argument." > " can be overriden by the \"-oorg\" or \"-ocenter\" argument." --- 156,158c155,157 ----------------------- < #define imgc_parse_output_center_org_HELP_INFO \ < " -oCenter\n" \ < " -oOrg {CX_OUT} {CY_OUT}\n" \ > #define imgc_parse_ocenter_oorg_HELP_INFO \ > " -ocenter\n" \ > " -oorg {CX_OUT} {CY_OUT}\n" \ --- 161,162c160,161 ----------------------- < " images. The \"-oCenter\" option sets the origin" \ < " at the center of the image domain. The \"-oOrg\" option sets" \ > " images. The \"-ocenter\" option sets the origin" \ > " at the center of the image domain. The \"-oorg\" option sets" \ --- 165c164 ----------------------- < " assumes \"-oOrg 0 0\" (which means the default origin).\n" > " assumes \"-oorg 0 0\" (which means the default origin).\n" --- 169,172c168,171 ----------------------- < void imgc_parse_output_size(argparser_t *pp, int *oCols, int *oRows, int max_size); < /* Parses the output image size option "-oSize", according to {imgc_parse_output_size_HELP}. If < "-oSize" is present, sets {*oCols} and {*oRows} to the next two < arguments. Otherwise leaves {*oCols} and {*oRows} unchanged. > void imgc_parse_osize(argparser_t *pp, int *ocols, int *orows, int max_size); > /* Parses the output image size option "-osize", according to {imgc_parse_osize_HELP}. If > "-osize" is present, sets {*ocols} and {*orows} to the next two > arguments. Otherwise leaves {*ocols} and {*orows} unchanged. --- 175,176c174,175 ----------------------- < #define imgc_parse_output_size_HELP \ < "[ -oSize {NX} {NY} ]" > #define imgc_parse_osize_HELP \ > "[ -osize {NX} {NY} ]" --- 178,179c177,178 ----------------------- < #define imgc_parse_output_size_HELP_INFO \ < " -oSize {NX} {NY}\n" \ > #define imgc_parse_osize_HELP_INFO \ > " -osize {NX} {NY}\n" \ ============================================================== ../../../LIBS/libs-core/libimg/interval_pixel.c affine_tracker/libimg/interval_pixel.c ============================================================== ../../../LIBS/libs-core/libimg/interval_pixel.h affine_tracker/libimg/interval_pixel.h ============================================================== ../../../LIBS/libs-core/libimg/sample_conv.c affine_tracker/libimg/sample_conv.c --- 2c2 ----------------------- < /* Last edited on 2009-01-04 11:02:40 by stolfi */ > /* Last edited on 2008-09-23 14:42:57 by stolfi */ --- 10a11,12 ----------------------- > #include > --- 14,15d15 ----------------------- < #include < --- 122,123c122,123 ----------------------- < { if ((imin != NULL) && (iv < (*imin))) { (*imin) = iv; } < if ((imax != NULL) && (iv > (*imax))) { (*imax) = iv; } > { if (iv < (*imin)) { (*imin) = iv; } > if (iv > (*imax)) { (*imax) = iv; } --- 126,127c126,127 ----------------------- < if ((vmin != NULL) && (fv < (*vmin))) { (*vmin) = fv; } < if ((vmax != NULL) && (fv > (*vmax))) { (*vmax) = fv; } > if (fv < (*vmin)) { (*vmin) = fv; } > if (fv > (*vmax)) { (*vmax) = fv; } --- 160,162c160,161 ----------------------- < { demand(! isnan(fv), "{fv} is NaN"); < if ((vmin != NULL) && (fv < (*vmin))) { (*vmin) = fv; } < if ((vmax != NULL) && (fv > (*vmax))) { (*vmax) = fv; } > { if (fv < (*vmin)) { (*vmin) = fv; } > if (fv > (*vmax)) { (*vmax) = fv; } --- 165,166c164,165 ----------------------- < if (rv < 0.0) { rv = 0.0; if (clo != NULL) { (*clo)++; } } < if (rv > 1.0) { rv = 1.0; if (chi != NULL) { (*chi)++; } } > if (rv < 0.0) { rv = 0.0; (*clo)++; } > if (rv > 1.0) { rv = 1.0; (*chi)++; } --- 168c167 ----------------------- < demand((zv >= 0) && (zv <= (int)maxval), "bad {zv}"); > demand((zv >= 0) && (zv <= (int)maxval), "bad zv"); --- 170,171c169,170 ----------------------- < if ((imin != NULL) && (iv < (*imin))) { (*imin) = iv; } < if ((imax != NULL) && (iv > (*imax))) { (*imax) = iv; } > if (iv < (*imin)) { (*imin) = iv; } > if (iv > (*imax)) { (*imax) = iv; } ============================================================== ../../../LIBS/libs-core/libimg/sample_conv.h affine_tracker/libimg/sample_conv.h ============================================================== ../../../LIBS/libs-core/libimg/test-yuv-mapping affine_tracker/libimg/test-yuv-mapping ============================================================== ../../../LIBS/libs-core/libimg/tests/encode_gamma/show-sample-map affine_tracker/libimg/tests/encode_gamma/show-sample-map ============================================================== ../../../LIBS/libs-core/libimg/tests/encode_gamma/test_encode_gamma.c affine_tracker/libimg/tests/encode_gamma/test_encode_gamma.c ============================================================== ../../../LIBS/libs-core/libimg/tests/show-sample-map affine_tracker/libimg/tests/show-sample-map ============================================================== ../../../LIBS/libs-core/libimg/tests/transform/test_transform.c affine_tracker/libimg/tests/transform/test_transform.c ============================================================== ../../../LIBS/libs-core/libimg/yuvhacks.c affine_tracker/libimg/yuvhacks.c ============================================================== ../../../LIBS/libs-core/libimg/yuvhacks.h affine_tracker/libimg/yuvhacks.h ============================================================== ../../../LIBS/libs-core/libjs/affirm.c affine_tracker/libjs/affirm.c ============================================================== ../../../LIBS/libs-core/libjs/affirm.h affine_tracker/libjs/affirm.h --- 5c5 ----------------------- < /* Last edited on 2008-05-25 13:45:25 by stolfi */ > /* Last edited on 2007-10-07 09:51:04 by stolfi */ --- 46,47c46 ----------------------- < void programerror (const char *msg, const char *file, unsigned int line, const char* proc) < __attribute__ ((noreturn)); > void programerror (const char *msg, const char *file, unsigned int line, const char* proc); --- 49c48 ----------------------- < Meant for use by {affirm}. */ > Meant for {affirm} below. */ ============================================================== ../../../LIBS/libs-core/libjs/argparser.c affine_tracker/libjs/argparser.c --- 2c2 ----------------------- < /* Last edited on 2008-05-25 03:29:38 by stolfi */ > /* Last edited on 2008-02-12 01:18:59 by stolfi */ --- 7,10c7,9 ----------------------- < #define _GNU_SOURCE < #include < #include < #include > #include > #include > #include --- 15,19c14 ----------------------- < < #include < #include < #include < > #include --- 58,59c53,54 ----------------------- < pp->arg.ne = argc; < pp->arg.e = argv; > pp->arg.nel = argc; > pp->arg.el = argv; --- 62,63c57,58 ----------------------- < pp->parsed.e[0] = TRUE; < { int i; for (i = 1; i < argc; i++) { pp->parsed.e[i] = FALSE; } } > pp->parsed.el[0] = TRUE; > { int i; for (i = 1; i < argc; i++) { pp->parsed.el[i] = FALSE; } } --- 74c69 ----------------------- < pp->help.e[pp->nhelp] = help; > pp->help.el[pp->nhelp] = help; --- 80c75 ----------------------- < pp->info.e[pp->ninfo] = info; > pp->info.el[pp->ninfo] = info; --- 99c94 ----------------------- < { fprintf(pp->wr, "%s", pp->help.e[i]); } > { fprintf(pp->wr, "%s", pp->help.el[i]); } --- 107c102 ----------------------- < { argparser_print_info_text(pp->wr, pp->info.e[i], wd); } > { argparser_print_info_text(pp->wr, pp->info.el[i], wd); } --- 112,114c107,109 ----------------------- < { fprintf(pp->wr, "%s: %s", pp->arg.e[0], msg1); < if ((index > 0) && (index < pp->arg.ne)) < { fprintf(pp->wr, "parameter %d = \"%s\"", index, pp->arg.e[index]); } > { fprintf(pp->wr, "%s: %s", pp->arg.el[0], msg1); > if ((index > 0) && (index < pp->arg.nel)) > { fprintf(pp->wr, "parameter %d = \"%s\"", index, pp->arg.el[index]); } --- 119,120c114,115 ----------------------- < { char **a = pp->arg.e; < bool_t *p = pp->parsed.e; > { char **a = pp->arg.el; > bool_t *p = pp->parsed.el; --- 122c117 ----------------------- < for (i = 0; i < pp->arg.ne; i++) > for (i = 0; i < pp->arg.nel; i++) --- 140,142c135,137 ----------------------- < { char **a = pp->arg.e; < bool_t *p = pp->parsed.e; < if ((pp->next >= pp->arg.ne) || (p[pp->next])) > { char **a = pp->arg.el; > bool_t *p = pp->parsed.el; > if ((pp->next >= pp->arg.nel) || (p[pp->next])) --- 162c157 ----------------------- < { bool_t *p = pp->parsed.e; > { bool_t *p = pp->parsed.el; --- 227c222 ----------------------- < { double nv = argparser_get_next_double(pp, -DBL_MAX, +DBL_MAX); > { double nv = argparser_get_next_double(pp, -MAXDOUBLE, +MAXDOUBLE); --- 263c258 ----------------------- < a.e[nInts] = argparser_get_next_int(pp, min, max); > a.el[nInts] = argparser_get_next_int(pp, min, max); --- 271,273c266,268 ----------------------- < { char **a = pp->arg.e; < bool_t *p = pp->parsed.e; < if ((pp->next >= pp->arg.ne) || (p[pp->next])) > { char **a = pp->arg.el; > bool_t *p = pp->parsed.el; > if ((pp->next >= pp->arg.nel) || (p[pp->next])) --- 280,282c275,277 ----------------------- < { char **a = pp->arg.e; < bool_t *p = pp->parsed.e; < if (pp->next >= pp->arg.ne) { return FALSE; } > { char **a = pp->arg.el; > bool_t *p = pp->parsed.el; > if (pp->next >= pp->arg.nel) { return FALSE; } --- 287,289c282,284 ----------------------- < { char **a = pp->arg.e; < bool_t *p = pp->parsed.e; < if ((pp->next >= pp->arg.ne) || (p[pp->next])) { return FALSE; } > { char **a = pp->arg.el; > bool_t *p = pp->parsed.el; > if ((pp->next >= pp->arg.nel) || (p[pp->next])) { return FALSE; } --- 297,299c292,294 ----------------------- < { char **a = pp->arg.e; < bool_t *p = pp->parsed.e; < if ((pp->next >= pp->arg.ne) || (p[pp->next])) { return FALSE; } > { char **a = pp->arg.el; > bool_t *p = pp->parsed.el; > if ((pp->next >= pp->arg.nel) || (p[pp->next])) { return FALSE; } --- 306c301 ----------------------- < { bool_t *p = pp->parsed.e; > { bool_t *p = pp->parsed.el; --- 321c316 ----------------------- < bool_t *p = pp->parsed.e; > bool_t *p = pp->parsed.el; --- 336,337c331,332 ----------------------- < { bool_t *p = pp->parsed.e; < pp->next = pp->arg.ne; > { bool_t *p = pp->parsed.el; > pp->next = pp->arg.nel; --- 344,346c339,341 ----------------------- < { argparser_check_all_parsed(pp, pp->arg.ne); < free(pp->parsed.e); < free(pp->help.e); > { argparser_check_all_parsed(pp, pp->arg.nel); > free(pp->parsed.el); > free(pp->help.el); ============================================================== ../../../LIBS/libs-core/libjs/argparser.h affine_tracker/libjs/argparser.h --- 2c2 ----------------------- < /* Last edited on 2008-07-14 03:58:49 by stolfi */ > /* Last edited on 2008-02-12 01:19:17 by stolfi */ --- 27c27 ----------------------- < string_vec_t help; /* {help.e[0..nhelp-1]} is the help text for errors. */ > string_vec_t help; /* {help.el[0..nhelp-1]} is the help text for errors. */ --- 29c29 ----------------------- < string_vec_t info; /* {info.e[0..ninfo-1]} is the program info text. */ > string_vec_t info; /* {info.el[0..ninfo-1]} is the program info text. */ --- 50,55c50,52 ----------------------- < /* Appends {help} to the help text stored in {pp}. < < The help text will be used by < {argparser_process_help_info_options} below. Also, if a syntax < error is found later during argument parsing, the stored help text < will be written to {pp->wr}, just before halting the program. */ > /* Appends {help} to the help text stored in {pp}. If a syntax error > is found later during argument parsing, the stored help text will > be written to {pp->wr}, just before halting the program. */ --- 58,65c55,63 ----------------------- < /* Appends {info} to the info text stored in {pp}. < < The info text will be used by {argparser_process_help_info_options} < below. If and when the info text is printed, it is reformatted < by breaking every line that is longer than 72 characters at < internal blanks. Any blanks around the break points (or at the end < of each line) are discarded, but the initial indentation of the < line is preserved on each piece. */ > /* Appends {info} to the documentation text stored in {pp}. If a > documentation request keyword ("-info" or "--info") is present > prints the info text and exits with status 0. > > If and when the text is printed, it is reformatted by breaking > every line that is longer than 72 characters at internal blanks. > Any blanks around the break points (or at the end of each line) > are discarded, but the initial indentation of the line is > preserved on each piece. */ --- 69,72c67,69 ----------------------- < present, the function prints the info text stored in {pp}. Else, < if a help request keyword ("-help" or "--help") is present, it < prints the stored help text. In either case, exits the program < with status 0. */ > present, prints the info text stored in {pp}. Else, if a help > request keyword ("-help" or "--help") is present, prints the > stored help text. In either case, exits the program with status 0. */ ============================================================== ../../../LIBS/libs-core/libjs/bool.c affine_tracker/libjs/bool.c ============================================================== ../../../LIBS/libs-core/libjs/bool.h affine_tracker/libjs/bool.h ============================================================== ../../../LIBS/libs-core/libjs/box.c affine_tracker/libjs/box.c ============================================================== ../../../LIBS/libs-core/libjs/box.h affine_tracker/libjs/box.h --- 5c5 ----------------------- < /* Last edited on 2008-03-30 17:22:19 by stolfi */ > /* Last edited on 2007-12-26 23:06:27 by stolfi */ --- 35c35 ----------------------- < /* Stores in {p[0..d-1]} the /inferior corner/ of the box {B[0..d-1]}, > /* Stores in {p[0..d-1]} the inferior corner of the box {B[0..d-1]}, --- 39c39 ----------------------- < /* Stores in {p[0..d-1] the /superior corner/ of box {B[0..d-1]}. */ > /* Stores in {p[0..d-1] the superior corner of box {B[0..d-1]}. */ --- 74,80c74,82 ----------------------- < and stabbing axes {t[0..d-m-1]} defines a mapping from {R^m} to < {R^d}, whereby each coordinate {z[j]} of the argument is scaled and < shifted so that the interval [0_1] becomes the interval {x[s[j]] = < B[s[j]]}, and {x[t[j]]} is set to the singleton {B[t[j]}. < < We will denote this transformation by {x = S_B(z)}. The numbers < {z[0..m-1]} are the /coordinates of {x} relative to {B}/. */ > and stabbing axes {t[0..d-m-1]} > defines a mapping from {R^m} to {R^d}, whereby each coordinate > {z[j]} of the argument is scaled and shifted so that the > interval [0_1] becomes the interval {x[s[j]] = B[s[j]]}, > and {x[t[j]]} is set to the singleton {B[t[j]}. > > We will denote this transformation by {x = S_B(z)}. > The numbers {z[0..m-1]} are the /coordinates of {x} relative > to {B}/. */ --- 105,108c107,110 ----------------------- < A box {B} is/parallel/ to a coordinate axis {i} if its projection on < that axis is a non-trivial interval; otherwise {B} is < /perpendicular/ to axis {i}. We also say that axis {i} is /spanning/ < or /normal/ to the box, respectively. > A box {B} is/parallel/ to a coordinate axis {i} if > its projection on that axis is a non-trivial interval; otherwise > {B} is /perpendicular/ to axis {i}. We also say that axis {i} > is /spanning/ or /normal/ to the box, respectively. --- 195,196c197,198 ----------------------- < The coordinates are relative to the box {B}, i.e. 0 means the inferior < side of the box, 1 means the superior side. Thus, {F[j]} will be > The coordinates are relative to the box {B}, i.e. 0 means the low > side of the box, 1 means the high side. Thus, {F[j]} will be ============================================================== ../../../LIBS/libs-core/libjs/cmp.c affine_tracker/libjs/cmp.c ============================================================== ../../../LIBS/libs-core/libjs/cmp.h affine_tracker/libjs/cmp.h ============================================================== ../../../LIBS/libs-core/libjs/enum_orbits.c affine_tracker/libjs/enum_orbits.c ============================================================== ../../../LIBS/libs-core/libjs/enum_orbits.h affine_tracker/libjs/enum_orbits.h ============================================================== ../../../LIBS/libs-core/libjs/fget.c affine_tracker/libjs/fget.c --- 2c2 ----------------------- < /* Last edited on 2009-01-04 11:40:42 by stolfi */ > /* Last edited on 2007-02-04 18:08:51 by stolfi */ --- 15,24c15,16 ----------------------- < bool_t fget_is_formatting_char(int c); < /* Returns TRUE iff {c} is a formatting character, namely < a space (SPACE, TAB, NUL, NBSP) line break (CR, LF) or page < break (FF, VT). */ < < bool_t fget_is_space(int c); < /* Returns TRUE iff {c} is a space char (SPACE, TAB, NUL, NBSP). */ < < void fget_skip_spaces_to_something(FILE *f); < /* Skips spaces, then requires that the next character is not > void fget_skip_to_non_blank(FILE *f); > /* Skips spaces and requires that the next character is not --- 37,59c29 ----------------------- < bool_t fget_is_formatting_char(int c) < { < return (c == '\000') || (c == ' ') || (c == '\240') || ((c >= '\011') && (c <= '\015')); < } < < bool_t fget_is_space(int c) < { < return (c == '\000') || (c == ' ') || (c == '\240') || (c == '\011'); < } < < bool_t fget_test_char(FILE *f, char c) < { int r; < fget_skip_spaces(f); < r = fgetc(f); < if (r == c) < { return TRUE; } < else if (r == EOF) < { return FALSE; } < else < { ungetc(r, f); return FALSE; } < } < < void fget_skip_spaces(FILE *f) > void fget_skip_formatting_chars(FILE *f) --- 65,66c35,37 ----------------------- < while (fget_is_space(c)); < ungetc(c, f); return; > while ((c == '\000') || (c == ' ') || ((c >= '\011') && (c <= '\015'))); > ungetc(c, f); > return; --- 69c40 ----------------------- < void fget_skip_formatting_chars(FILE *f) > void fget_skip_spaces(FILE *f) --- 75,77c46,47 ----------------------- < while (fget_is_formatting_char(c)); < ungetc(c, f); < return; > while ((c=='\000')||(c==' ')||(c=='\011')); > ungetc(c, f); return; --- 98c68 ----------------------- < void fget_skip_spaces_to_something(FILE *f) > void fget_skip_to_non_blank(FILE *f) --- 102c72 ----------------------- < demand((c != EOF) && (! fget_is_formatting_char(c)), "item not found"); > demand((c!=EOF)&&((c<'\012')||(c>'\015')), "item not found"); --- 108c78 ----------------------- < fget_skip_spaces_to_something(f); > fget_skip_to_non_blank(f); --- 116c86 ----------------------- < fget_skip_spaces_to_something(f); > fget_skip_to_non_blank(f); --- 118c88 ----------------------- < if ((c == 't') || (c == 'T') || (c == '1')) > if ((c == 't') || (c == 'T') || (c == '1' )) --- 120c90 ----------------------- < else if ((c == 'f') || (c == 'F') || (c == '0')) > else if ((c == 'f') || (c == 'F') || (c == '0' )) --- 136c106 ----------------------- < fget_skip_spaces_to_something(f); > fget_skip_to_non_blank(f); --- 138c108 ----------------------- < while ((c != EOF) && (! fget_is_formatting_char(c))) > while ((c!=EOF)&&(c!='\000')&&(c!=' ')&&(c!='\011')&&((c<'\012')||(c>'\015'))) --- 161,175d130 ----------------------- < int fget_digit(FILE *f, bool_t alpha) < { int c = fgetc(f); < if ((c >= '0') && (c <= '9')) < { return c - '0'; } < else if (alpha) < { if ((c >= 'a') && (c <= 'z')) < { return 10 + (c - 'a'); } < else if ((c >= 'A') && (c <= 'Z')) < { return 10 + (c - 'A'); } < } < /* No digit found: */ < if (c != EOF) { ungetc(c, f); } < return -1; < } < --- 178c133 ----------------------- < demand((x >= INT_MIN) && (x < INT_MAX), "integer does not fit in {int} type"); > demand((x >= INT_MIN) && (x < INT_MAX), "integer too big for int type"); --- 182,185c137,140 ----------------------- < int fget_int32(FILE *f) < { int64_t x = fget_int64(f); < demand((x >= INT32_MIN) && (x < INT32_MAX), "integer does not fit in {int32_t} type"); < return (int)x; > unsigned int fget_uint(FILE *f, int base) > { uint64_t x = fget_uint64(f, base); > demand(x < UINT_MAX, "integer too big for unsigned int type"); > return (unsigned int)x; --- 191c146 ----------------------- < fget_skip_spaces_to_something(f); > fget_skip_to_non_blank(f); --- 200c155 ----------------------- < { demand (x <= ((uint64_t)INT64_MAX), "integer does not fit in {int64_t} type"); > { demand (x <= ((uint64_t)INT64_MAX), "integer does not fit in int64_t type"); --- 204c159 ----------------------- < { demand (x <= ((uint64_t)INT64_MAX) + 1, "integer does not fit in {int64_t} type"); > { demand (x <= ((uint64_t)INT64_MAX) + 1, "integer does not fit in int64_t type"); --- 209,212c164,172 ----------------------- < unsigned int fget_uint(FILE *f, int base) < { uint64_t x = fget_uint64(f, base); < demand(x < UINT_MAX, "integer does not fit in {unsigned int} type"); < return (unsigned int)x; > int fget_digit(FILE *f, bool_t alpha) > { int c = fgetc(f); > if ((c >= '0') && (c <= '9')) > { return c - '0'; } > else if (alpha) > { if ((c >= 'a') && (c <= 'z')) > { return 10 + (c - 'a'); } > else if ((c >= 'A') && (c <= 'Z')) > { return 10 + (c - 'A'); } --- 214,218c174,176 ----------------------- < < unsigned int fget_uint32(FILE *f, int base) < { uint64_t x = fget_uint64(f, base); < demand(x < UINT32_MAX, "integer does not fit in {uint32_t} type"); < return (unsigned int)x; > /* No digit found: */ > if (c != EOF) { ungetc(c, f); } > return -1; --- 224c182 ----------------------- < fget_skip_spaces_to_something(f); > fget_skip_to_non_blank(f); --- 245c203 ----------------------- < fget_skip_spaces_to_something(f); > fget_skip_to_non_blank(f); --- 270,274d227 ----------------------- < void fget_skip_and_match(FILE *f, char *t) < { fget_skip_spaces(f); < fget_match(f, t); < } < --- 279a233,244 ----------------------- > bool_t fget_test_char(FILE *f, char c) > { int r; > fget_skip_spaces(f); > r = fgetc(f); > if (r == (unsigned char)c) > { return TRUE; } > else if (r == EOF) > { return FALSE; } > else > { ungetc(r, f); return FALSE; } > } > ============================================================== ../../../LIBS/libs-core/libjs/fget.h affine_tracker/libjs/fget.h --- 2c2 ----------------------- < /* Last edited on 2009-01-04 11:39:57 by stolfi */ > /* Last edited on 2008-01-09 00:27:23 by stolfi */ --- 21,22c21,22 ----------------------- < /* Skips spaces (SPACE, NBSP, TAB, NUL) until the first non-space < character or end-of-file. Will NOT skip line-breaks or page-breaks. */ > /* Skips spaces (SPACE, TAB, NUL) until the first non-space > character or end-of-file. Will NOT skip line or page breaks. */ --- 25,26c25,26 ----------------------- < /* Skips all blank `formatting' characters --- namely spaces (SPACE, NBSP, < TAB, NUL), line-breaks (CR, LF), and page-breaks (FF, VT) --- > /* Skips all blank `formatting' characters --- namely spaces (SPACE, > TAB, NUL), line breaks (CR, LF), and page breaks (FF, VT) --- --- 33,37c33,36 ----------------------- < bool_t fget_test_char(FILE *f, int c); < /* Checks whether the next character is {c} (which may be < a space, line-break, page-break, or even EOF). If it is, consumes that < character and returns TRUE. If it is something else (even if it is a < space, line-break or page-break, or end-of-file), returns FALSE and > bool_t fget_test_char(FILE *f, char c); > /* Checks whether the next character is {c}. If it is, consumes that > character and returns TRUE. If it is something else (including > space, line or page break, or end-of-file), returns FALSE and --- 40,41c39,40 ----------------------- < /* The following procedures will skip spaces (SPACEs, NBSPs, TABs and NULs) < before the desired input. They will NOT skip line-breaks or page-breaks. */ > /* The following procedures will skip (SPACEs, TABs and NULs; but not > line or page breaks) before the desired input. */ --- 45,52c44,45 ----------------------- < not be a space, line break, or page break. Fails < if a line break, page break, or end-of-file occurs before the character. */ < < bool_t fget_bool(FILE *f); < /* The procedure {fget_bool_t} will skip spaces, then read a single < character: 'T','t','1' for TRUE, 'F','f','0' for FALSE. Anything < else is an error. Note that, if the file contains "TRUE" or < "FALSE", only the first letter will be consumed. */ > not be a space, line break, or page break. A fatal error > ocurrs if end-of-file occurs before the character. */ --- 59a53,58 ----------------------- > bool_t fget_bool(FILE *f); > /* The procedure {fget_bool_t} will skip spaces, then read a single > character: 'T','t','1' for TRUE, 'F','f','0' for FALSE. Anything > else is an error. In particular, if the file contains "TRUE" or > "FALSE", only the first letter will be consumed. */ > --- 61d59 ----------------------- < int32_t fget_int32(FILE *f); --- 69d66 ----------------------- < uint32_t fget_uint32(FILE *f, int base); --- 98,100d94 ----------------------- < void fget_skip_and_match(FILE *f, char *t); < /* Equivalent to {fget_skip_spaces(f); fget_match(f, t)}. */ < --- 102c96 ----------------------- < /* Equivalent to {fget_skip_spaces(f); fget_test_char(f, c)}. */ > /* Equivalent to {fget_skip_spaces(f); fget_test_char(rc, c)}. */ ============================================================== ../../../LIBS/libs-core/libjs/filefmt.c affine_tracker/libjs/filefmt.c --- 96c96 ----------------------- < cmt.e[ncmt] = c; > cmt.el[ncmt] = c; --- 102c102 ----------------------- < cmt.e[ncmt] = '\000'; > cmt.el[ncmt] = '\000'; --- 105c105 ----------------------- < return cmt.e; > return cmt.el; ============================================================== ../../../LIBS/libs-core/libjs/filefmt.h affine_tracker/libjs/filefmt.h ============================================================== ../../../LIBS/libs-core/libjs/gauss_table.c affine_tracker/libjs/gauss_table.c --- 2c2 ----------------------- < /* Last edited on 2008-10-05 11:11:52 by stolfi */ > /* Last edited on 2008-09-20 12:26:44 by stolfi */ --- 47c47 ----------------------- < assert(n >= 0); > assert(n > 0); --- 51d50 ----------------------- < { if (n > 0) --- 57d55 ----------------------- < } --- 65c63 ----------------------- < int kmax = (n == 0 ? 0 : (int)floor((z + gauss_table_BIG_ARG*dev)/n)); > int kmax = (int)floor((z + gauss_table_BIG_ARG*dev)/n); ============================================================== ../../../LIBS/libs-core/libjs/gauss_table.h affine_tracker/libjs/gauss_table.h --- 5c5 ----------------------- < /* Last edited on 2008-10-05 11:10:32 by stolfi */ > /* Last edited on 2008-09-20 12:25:24 by stolfi */ --- 45,46c45 ----------------------- < returns 1. If {n} is zero, assumes {n = +oo}, meaning < no fold-over. */ > returns 1. */ ============================================================== ../../../LIBS/libs-core/libjs/indexing.c affine_tracker/libjs/indexing.c ============================================================== ../../../LIBS/libs-core/libjs/indexing.h affine_tracker/libjs/indexing.h ============================================================== ../../../LIBS/libs-core/libjs/indexing_io.c affine_tracker/libjs/indexing_io.c ============================================================== ../../../LIBS/libs-core/libjs/indexing_io.h affine_tracker/libjs/indexing_io.h ============================================================== ../../../LIBS/libs-core/libjs/interval.c affine_tracker/libjs/interval.c --- 2c2 ----------------------- < /* Last edited on 2009-01-04 13:45:11 by stolfi */ > /* Last edited on 2007-12-26 23:19:42 by stolfi */ --- 6c6 ----------------------- < #include > #include --- 9a10 ----------------------- > #include --- 15,42c16,23 ----------------------- < #define interval_IS_EMPTY(X) ((X).end[0] > (X).end[1]) < #define interval_IS_FULL(X) (((X).end[0] == -INF) || ((X).end[1] == +INF)) < #define interval_IS_FINITE(X) (((X).end[0] > -INF) && ((X).end[1] < +INF)) < #define interval_IS_TRIVIAL(X) ((X).end[0] == (X).end[1]) < < double interval_is_empty(interval_t *X) < { return interval_IS_EMPTY(*X); } < < double interval_is_full(interval_t *X) < { return interval_IS_FULL(*X); } < < double interval_is_finite(interval_t *X) < { return interval_IS_FINITE(*X); } < < double interval_is_trivial(interval_t *X) < { return interval_IS_TRIVIAL(*X); } < < void interval_mid_rad (interval_t *X, double *mid, double *rad) < { if (interval_IS_FULL(*X)) < { if (mid != NULL) { (*mid) = 0; } if (rad != NULL) { (rad) = +INF; } } < else if (interval_IS_EMPTY(*X)) < { if (mid != NULL) { (*mid) = 0; } if (rad != NULL) { (*rad) = -INF; } } < else if (interval_IS_TRIVIAL(*X)) < { if (mid != NULL) { (*mid) = LO(*X); } if (rad != NULL) { (*rad) = 0; } } < else if (LO(*X) == -INF) < { if (mid != NULL) { (*mid) = -INF; } if (rad != NULL) { (*rad) = +INF; } } < else if (HI(*X) == +INF) < { if (mid != NULL) { (*mid) = +INF; } if (rad != NULL) { (*rad) = +INF; } } > #define interval_ISFULL(x) (((x).end[0] <= -INFINITY) || ((x).end[1] >= +INFINITY)) > #define interval_NORMFULL(x) if (ia_ISFULL(x)) (x) = ia_FULL > > double interval_mid (interval_t *x) > { if (interval_ISFULL(*x)) > { return 0; } > else if (LO(*x) == HI(*x)) > { return LO(*x); } --- 44c25,26 ----------------------- < { double m; > { > double m; --- 47,63c29 ----------------------- < /* We divide before adding, to avoid overflow: */ < m = (LO(*X) * 0.5) + (HI(*X) * 0.5); < if ((m < LO(*X)) || (m > HI(*X))) < { /* Underflow must have occurred at both ends, which must have the same sign. */ < /* Adding before dividing should not overflow and give a middling value: */ < m = 0.5 * (LO(*X) + HI(*X)); < affirm((m >= LO(*X)) && (m <= HI(*X)), "rounding failed"); < } < fesetround(oround); < if (mid != NULL) { (*mid) = m; } < if (rad != NULL) < { fesetround(FE_UPWARD); < double rlo = m - LO(*X); < double rhi = HI(*X) - m; < affirm((rlo >= 0.0) && (rhi >= 0.0), "rounding failed"); < (*rad) = (rlo > rhi ? rlo: rhi); < } > m = (LO(*x) * 0.5) + (HI(*x) * 0.5); --- 65,70c31,32 ----------------------- < } < } < < double interval_mid (interval_t *X) < { double m; < interval_mid_rad(X, &m, NULL); > if ((m < LO(*x)) || (m > HI(*x))) { fprintf(stderr, "%24.16e %24.16e %24.16e\n", LO(*x), HI(*x), m); } > affirm((m >= LO(*x)) && (m <= HI(*x)), "rounding failed"); --- 73,77d34 ----------------------- < < double interval_rad (interval_t *X) < { double r; < interval_mid_rad(X, NULL, &r); < return r; --- 80,101c37,41 ----------------------- < interval_t interval_from_mid_rad (double mid, double rad) < { < if (rad < 0) < { /* Empty interval: */ < return (interval_t) {{ +INF, -INF }}; < } < else if (rad == 0) < { /* Trivial interval: */ < return (interval_t) {{ mid, mid }}; < } < else if (rad == +INF) < { /* Even if {mid} is {ħINF}, the only safe answer is the full interval: */ < return (interval_t) {{ -INF, +INF }}; < } < else if (mid == -INF) < { /* Since {rad} is finite, the interval must be the singleton {-INF}: */ < return (interval_t) {{ -INF, -INF }}; < } < else if (mid == +INF) < { /* Since {rad} is finite, the interval must be the singleton {+INF}: */ < return (interval_t) {{ +INF, +INF }}; < } > double interval_rad (interval_t *x) > { if (interval_ISFULL(*x)) > { return HUGE_VAL; } > else if (LO(*x) == HI(*x)) > { return 0.0; } --- 103,104c43 ----------------------- < { /* Finite {mid} and finite, positive {rad}. */ < /* The result is a finite interval (except for possible overflows: */ > { double m, rlo, rhi; --- 106c45,46 ----------------------- < /* We must round {LO = mid - rad} down and {HI = mid + rad} up, so: */ > fesetround(FE_TONEAREST); > m = (LO(*x) * 0.5) + (HI(*x) * 0.5); --- 108,109c48,49 ----------------------- < double nlo = rad - mid; /* {-LO}. */ < double phi = rad + mid; /* {+HI}. */ > rlo = m - LO(*x); > rhi = HI(*x) - m; --- 111c51,52 ----------------------- < return (interval_t){{ -nlo, +phi }}; > affirm((rlo >= 0.0) && (rhi >= 0.0), "rounding failed"); > return (rlo > rhi ? rlo: rhi); --- 115c56 ----------------------- < double interval_width (interval_t *X) > double interval_width (interval_t *x) --- 117,118c58,59 ----------------------- < fesetround(FE_UPWARD); < double w = HI(*X) - LO(*X); > fesetround(FE_TONEAREST); > double w = HI(*x) - LO(*x); --- 123c64 ----------------------- < interval_t interval_split(interval_t *X, interval_side_t dir) > interval_t interval_split(interval_t *x, interval_side_t dir) --- 125c66 ----------------------- < double mid = interval_mid(X); > double mid = interval_mid(x); --- 127c68 ----------------------- < { return (interval_t){{ LO(*X), mid }}; } > { return (interval_t){{ LO(*x), mid }}; } --- 129c70 ----------------------- < { return (interval_t){{ mid, HI(*X) }}; } > { return (interval_t){{ mid, HI(*x) }}; } --- 132,138c73,79 ----------------------- < interval_t interval_join(interval_t *X, interval_t *Y) < { double Xlo = LO(*X), Xhi = HI(*X); < double Ylo = LO(*Y), Yhi = HI(*Y); < if (Xlo > Xhi) < { return *Y; } < else if (Ylo > Yhi) < { return *X; } > interval_t interval_join(interval_t *u, interval_t *v) > { double ulo = LO(*u), uhi = HI(*u); > double vlo = LO(*v), vhi = HI(*v); > if (ulo > uhi) > { return *v; } > else if (vlo > vhi) > { return *u; } --- 141,142c82,83 ----------------------- < LO(w) = (Xlo < Ylo ? Xlo : Ylo); < HI(w) = (Xhi > Yhi ? Xhi : Yhi); > LO(w) = (ulo < vlo ? ulo : vlo); > HI(w) = (uhi > vhi ? uhi : vhi); --- 147,153c88,94 ----------------------- < interval_t interval_meet(interval_t *X, interval_t *Y) < { double Xlo = LO(*X), Xhi = HI(*X); < double Ylo = LO(*Y), Yhi = HI(*Y); < if (Xlo > Xhi) < { return *X; } < if (Ylo > Yhi) < { return *Y; } > interval_t interval_meet(interval_t *u, interval_t *v) > { double ulo = LO(*u), uhi = HI(*u); > double vlo = LO(*v), vhi = HI(*v); > if (ulo > uhi) > { return *u; } > if (vlo > vhi) > { return *v; } --- 156,157c97,98 ----------------------- < LO(w) = (Xlo > Ylo ? Xlo : Ylo); < HI(w) = (Xhi < Yhi ? Xhi : Yhi); > LO(w) = (ulo > vlo ? ulo : vlo); > HI(w) = (uhi < vhi ? uhi : vhi); --- 162,170c103,129 ----------------------- < void interval_widen(interval_t *X, double margin) < { if (interval_IS_EMPTY(*X)) { return *X; } < int oround = fegetround(); < fesetround(FE_UPWARD); < double nlo = margin - LO(*X); < double phi = margin + HI(*X); < fesetround(oround); < if (-nlo > +phi) < { LO(*X) = +INF; HI(*X) = -INF; } > void interval_widen(interval_t *x, double margin) > { LO(*x) = LO(*x) - margin; > HI(*x) = HI(*x) + margin; > } > > void interval_adjust_ratio(interval_t *xr, interval_t *yr, double tx, double ty) > { double dx = HI(*xr) - LO(*xr); > double dy = HI(*yr) - LO(*yr); > if (ty*dx > tx*dy) > { double ey = (ty*dx/tx - dy)/2.0; > LO(*yr) = LO(*yr) - ey; > HI(*yr) = HI(*yr) + ey; > } > else if (ty*dx < tx*dy) > { double ex = (tx*dy/ty - dx)/2.0; > LO(*xr) = LO(*xr) - ex; > HI(*xr) = HI(*xr) + ex; > } > } > > double interval_project(interval_t *xr, double x) > { > demand(LO(*xr) <= HI(*xr), "empty interval"); > if (x < LO(*xr)) > { return LO(*xr); } > else if (x > HI(*xr)) > { return HI(*xr); } --- 172c131,141 ----------------------- < { LO(*X) = -nlo; HI(*X) = +phi; } > { return x; } > } > > bool_t interval_is_trivial (interval_t *x) > { > if (LO(*x) == HI(*x)) { > return TRUE; > } > else { > return FALSE; > } --- 175,190c144,150 ----------------------- < void interval_adjust_ratio(interval_t *X, interval_t *Y, double tx, double ty) < { demand(! interval_IS_EMPTY(*X), "interval {X} must be non-empty"); < demand(! interval_IS_EMPTY(*Y), "interval {Y} must be non-empty"); < demand(tx > 0, "ratio {tx} must be positive"); < demand(ty > 0, "ratio {ty} must be positive"); < double wx = HI(*X) - LO(*X); < double wy = HI(*Y) - LO(*Y); < if (ty*wx > tx*wy) < { double ey = ((ty/tx)*wx - wy)/2; < LO(*Y) = LO(*Y) - ey; < HI(*Y) = HI(*Y) + ey; < } < else if (ty*wx < tx*wy) < { double ex = ((tx/ty)*wy - wx)/2; < LO(*X) = LO(*X) - ex; < HI(*X) = HI(*X) + ex; > bool_t interval_is_full (interval_t *x) > { > if ( ( (x)->end[0] <= -INFINITY ) || ( (x)->end[1] >= +INFINITY ) ) { > return TRUE; > } > else { > return FALSE; --- 193a154,166 ----------------------- > bool_t interval_is_finite (interval_t *x) > { > if ( ( (x)->end[0] >= -INFINITY ) && ( (x)->end[1] <= +INFINITY ) ) { > return TRUE; > } > else { > return FALSE; > } > } > > > > ============================================================== ../../../LIBS/libs-core/libjs/interval.h affine_tracker/libjs/interval.h --- 3a4,5 ----------------------- > #include > --- 5c7 ----------------------- < /* Last edited on 2009-01-04 13:44:48 by stolfi */ > /* Last edited on 2007-12-26 23:18:04 by stolfi */ --- 11,26c13,19 ----------------------- < An {interval_t} {I} is a pair of {double}s, the /inferior/ or /low < endpoint/ {LO(I) = I.end[0]} and the /superior/ or /high endpoint/ < {HI(I) = I.end[1]}. The endpoints may be {ħINF} but not {NAN}. < < The procedures in this interface generally assume that the intervals < are closed, that is, that they represent the set of all extended < real numbers {z} (all the real numbers of mathematics, plus the < infinities {-INF} and {+INF}) such that {LO(X) <= z <= HI(X)}. < < Clients that assume other conventions for the endpoints (open or < half-open) or that interpret intervals as sets of other numbers < (finite reals, rationals, floats, etc.) should check carefully the < procedure specs. Thus, for example, the function {interval_is_empty} < below returns TRUE iff the closed interval is empty, that is, < {LO(X) > HI(X)}; whereas an open or half-open interval is empty < iff {LO(X) >= HI(X)}. */ > An {interval_t} {I} is a pair of {double}s {LO(I) = I.end[0]} and > {HI(I) = I.end[1]}. It usually stands for all real numbers {x} > such that {LO(I) < x < HI(I)}. Depending on the context, > the endpoints {LO(I)} and/or {HI(I)} may be included too. > > An open or half-open interval {I} is empty iff {LO(I) \geq HI(I)}. > A closed interval {I} is empty iff {LO(I) > HI(I)}. */ --- 29c22 ----------------------- < /* A real interval. */ > /* A real interval, open or closed. */ --- 31,32c24,25 ----------------------- < #define LO(X) ((X).end[0]) < #define HI(X) ((X).end[1]) > #define LO(x) ((x).end[0]) > #define HI(x) ((x).end[1]) --- 40,112c33,74 ----------------------- < double interval_is_empty(interval_t *X); < /* Returns TRUE iff the (closed) interval {X} is empty, that is, < iff {LO(X) > HI(X)}. */ < < double interval_is_full(interval_t *X); < /* Returns TRUE iff the (closed) interval {X} contains all extended reals, that is, < iff {LO(X) == -INF} and {HI(X) == +INF}. */ < < double interval_is_finite(interval_t *X); < /* Returns TRUE iff the (closed) interval {X} contains only finite reals < (or is empty), that is, iff {LO(X) > -INF} and {HI(X) < +INF}. */ < < double interval_is_trivial(interval_t *X); < /* Returns TRUE iff the (closed) interval {X} contains only one extended < real number, that is, iff {LO(X) == HI(X)}. */ < < void interval_mid_rad (interval_t *X, double *mid, double *rad); < /* If the closed interval {X} is not empty, returns the approximate < midlpoint {mid} of {X} (which is guaranteed to be in {X}), and a < non-negative value {rad} such that {X} is tightly contained in < {[mid-rad _ mid+rad]}, that is, {mid-rad <= LO(X)} and {mid+rad >= < HI(X)}. If the closed interval {X} is empty, returns {mid = 0, rad < = -INF}. < < In particular, if {X} is full, returns {mid = 0, rad = +INF}. If < {X} is trivial returns {mid = LO(X) = HI(X), rad = 0}. If {X} is < not full but infinite, returns {mid = -INF} or {mid = +INF}, and < {rad = +INF}. Finally, if {X} is finite, non-empty, and < non-trivial, returns a finite {mid} inside {X}, and a strictly < positive (perhaps infinite) {rad}. */ < < double interval_mid (interval_t *X); < /* If the closed interval {X} is finite and not empty, < returns the approximate midpoint of {X}, guaranteed to be < finite and inside {X}. If {X} is empty or full, returns 0. < Otherwise, if {X} is finite. */ < < double interval_rad (interval_t *X); < /* If {X} is not empty, the radius of {X} from its midpoint {m = < interval_mid(X)}. I.e. a value {r} such that {[m-r _ m+r]} < contains {X}. Negative if {X} is empty. Finite as long as {X} is < finite. */ < < interval_t interval_from_mid_rad (double mid, double rad); < /* If {rad} is negative, returns an empty interval. If {rad} is < {+INF}, returns the full interval {-INF,+INF} (even if {mid} is < {ħINF}. Otherwise returns an interval that includes {[mid-rad, < mid+rad]}. If either endpoint overflows, sets it to infinity.*/ < < double interval_width (interval_t *X); < /* The width of {X}, i.e. {HI(X) - LO(X)}, rounded up. Returns < {+INF} if the subtraction overflows. */ < < interval_t interval_split(interval_t *X, interval_side_t dir); < /* Returns the lower or upper half of the closed interval {X}, < depending on {dir}. The splitting point is {interval_mid(X)}, and < is included in both halves. */ < < interval_t interval_join(interval_t *X, interval_t *Y); < /* Returns the smallest interval enclosing both {X} and {Y}. */ < < interval_t interval_meet(interval_t *X, interval_t *Y); < /* Returns the intersection of {X} and {Y}. */ < < void interval_widen(interval_t *X, double margin); < /* Widens {*X} by the specified {margin} on both sides. < The {margin} may be negative, in which case the interval < is narrowed (and may become empty). */ < < void interval_adjust_ratio(interval_t *X, interval_t *Y, double tx, double ty); < /* Widens either {*X} or {*Y}, as needed, to ensure that < their widths are in the ratio {tx:ty} (except from roundoff < errors). */ > double interval_mid (interval_t *x); > /* Approximate midpoint of {x}, guaranteed to be in {x}. > Finite as long as {x} is finite. */ > > double interval_rad (interval_t *x); > /* Radius of {x} from its midpoint {m = ia_mid(x)}. > I.e. a value {r} such that {[m-r _ m+r]} contains {x}. > Finite as long as {x} is finite. */ > > double interval_width (interval_t *x); > /* Width of {x}, i.e. {HI(x) - LO(x)}, rounded up. Returns {HUGE_VAL} > if the subtraction overflows. */ > > interval_t interval_split(interval_t *x, interval_side_t dir); > /* Returns the lower or upper half of {x}, depending on {dir}. > The splitting point is {interval_mid(x)}, and is included > in both halves. */ > > interval_t interval_join(interval_t *u, interval_t *v); > /* Returns the smallest interval enclosing both {u} and {v}. */ > > interval_t interval_meet(interval_t *u, interval_t *v); > /* Returns the intersection of {u} and {v}. */ > > void interval_widen(interval_t *x, double margin); > /* Widens {*x} by the specified {margin} on both sides. > The {margin} may be negative. */ > > void interval_adjust_ratio(interval_t *xr, interval_t *yr, double tx, double ty); > /* Widens either {*xr} or {*yr}, as needed, to ensure that > their widths are in the ratio {tx:ty}. */ > > double interval_project(interval_t *xr, double x); > /* Returns the value {y} in the interval {*xr} which is closest to {x} > (which is {x} istelf if {x} is inside {*xr}, otherwise it is the neaerst > endpoint). Fails if {*xr} is empty. */ > > bool_t interval_is_trivial (interval_t *x); > > bool_t interval_is_full (interval_t *x); > > bool_t interval_is_finite (interval_t *x); ============================================================== ../../../LIBS/libs-core/libjs/intheap.c affine_tracker/libjs/intheap.c ============================================================== ../../../LIBS/libs-core/libjs/intheap.h affine_tracker/libjs/intheap.h ============================================================== ../../../LIBS/libs-core/libjs/intmerge.c affine_tracker/libjs/intmerge.c ============================================================== ../../../LIBS/libs-core/libjs/intmerge.h affine_tracker/libjs/intmerge.h ============================================================== ../../../LIBS/libs-core/libjs/intmerge_extra.c affine_tracker/libjs/intmerge_extra.c ============================================================== ../../../LIBS/libs-core/libjs/intmerge_extra.h affine_tracker/libjs/intmerge_extra.h ============================================================== ../../../LIBS/libs-core/libjs/intsort.h affine_tracker/libjs/intsort.h ============================================================== ../../../LIBS/libs-core/libjs/intsort_bins.c affine_tracker/libjs/intsort_bins.c ============================================================== ../../../LIBS/libs-core/libjs/intsort_extra.c affine_tracker/libjs/intsort_extra.c ============================================================== ../../../LIBS/libs-core/libjs/intsort_extra.h affine_tracker/libjs/intsort_extra.h ============================================================== ../../../LIBS/libs-core/libjs/intsort_heap.c affine_tracker/libjs/intsort_heap.c ============================================================== ../../../LIBS/libs-core/libjs/intsort_ins.c affine_tracker/libjs/intsort_ins.c ============================================================== ../../../LIBS/libs-core/libjs/intsort_merge.c affine_tracker/libjs/intsort_merge.c ============================================================== ../../../LIBS/libs-core/libjs/irange.c affine_tracker/libjs/irange.c ============================================================== ../../../LIBS/libs-core/libjs/irange.h affine_tracker/libjs/irange.h ============================================================== ../../../LIBS/libs-core/libjs/js.c affine_tracker/libjs/js.c ============================================================== ../../../LIBS/libs-core/libjs/js.h affine_tracker/libjs/js.h ============================================================== ../../../LIBS/libs-core/libjs/jsfile.c affine_tracker/libjs/jsfile.c --- 2c2 ----------------------- < /* Last edited on 2008-05-14 15:48:21 by stolfi */ > /* Last edited on 2006-03-19 12:56:00 by stolfi */ ============================================================== ../../../LIBS/libs-core/libjs/jsfile.h affine_tracker/libjs/jsfile.h ============================================================== ../../../LIBS/libs-core/libjs/jsmath.c affine_tracker/libjs/jsmath.c --- 2c2,4 ----------------------- < /* Last edited on 2009-01-04 13:50:17 by stolfi */ > /* Last edited on 2008-01-12 00:49:13 by stolfi */ > > #include --- 4d5 ----------------------- < #define _GNU_SOURCE --- 7,9c8 ----------------------- < #include < < #include > #include --- 12,19c11,13 ----------------------- < { if (y == 0) { return 1; } < if (x == 0) { return 0; } < if (x == 1) { return 1; } < if (y == 1) { return x; } < /* Find largest power of 2 {b} not exceeding {y}: */ < unsigned int h = y/2; < unsigned int b = 1; < while (b <= h) { b += b; } > { /* Find largest power of 2 {b} not exceeding {y}: */ > unsigned int b = UINT_MAX/2 + 1; > while (b > y) { b /= 2; } --- 21,22c15 ----------------------- < int64_t p = x; < y -= b; b /= 2; > int64_t p = 1; --- 79,99d71 ----------------------- < #define LO32(x) (((uint64_t)(x)) & ((1LLU << 32) - 1LLU)) < /* The lowest 32 bits of an integer, as the lowest 32 bits of a 64-bit uint. */ < < #define HI32(x) (((uint64_t)(x)) >> 32) < /* The highest 32 bits of an integer, as the lowest 32 bits of a 64-bit uint. */ < < void uint64_mul(uint64_t x, uint64_t y, uint64_t Z[]) < { < uint32_t x0 = LO32(x), x1 = HI32(x); < uint32_t y0 = LO32(y), y1 = HI32(y); < < uint64_t A00 = ((uint64_t)x0)*y0; < uint64_t A01 = ((uint64_t)x0)*y1; < uint64_t A10 = ((uint64_t)x1)*y0; < uint64_t A11 = ((uint64_t)x1)*y1; < < Z[0] = A00 + ((A01 + A10) << 32); < uint64_t P = HI32(A00) + LO32(A10) + LO32(A01); < Z[1] = (P >> 32) + HI32(A10) + HI32(A01) + A11; /* Should not overflow */ < } < --- 117,123d88 ----------------------- < double abs_rel_diff(double x, double y, double abs_tol, double rel_tol) < { double x2 = x*x; < double y2 = y*y; < double D2 = abs_tol*abs_tol + rel_tol*rel_tol*(x2+y2)/2 + 1.0e-300; < return (x - y)/sqrt(D2); < } < ============================================================== ../../../LIBS/libs-core/libjs/jsmath.h affine_tracker/libjs/jsmath.h --- 7,11c7 ----------------------- < /* Last edited on 2009-01-04 13:51:14 by stolfi */ < < #ifndef INF < #define INF INFINITY < #endif > /* Last edited on 2008-02-09 09:17:00 by stolfi */ --- 14c10 ----------------------- < /* Returns {x^y}. Does not check for overflow. */ > /* Returns {x^y}. Beware of overflow. */ --- 46,50d41 ----------------------- < void uint64_mul(uint64_t x, uint64_t y, uint64_t Z[]); < /* Multiplies two 64-bit unsigned integers {x,y} to give a < 128-bit unsiged int. The result is stored into {Z[0],Z[1]} < and should be interpreted as the integer {Z[0] + Z[1]*2^64}. */ < --- 59,75c50 ----------------------- < and +1 when {x} and {y} are equal and opposite). It is {NaN} < when both {x} and {y} are zero. */ < < double abs_rel_diff(double x, double y, double abs_tol, double rel_tol); < /* Returns the difference {d = x - y} divided by < {D = hypot(abs_tol, rel_tol*hypot(x,y)/sqrt(2))}. < < If {fabs(x),fabs(y)} are both very small, the denominator {D} is < approximately {abs_tol}. In that case, if the result {d/D} is 1.0 in < absolute value, then {fabs(d)} is approximately {abs_tol}. < < If either of {fabs(x),fabs(y)} is large compared to {abs_tol}, {D} < is between {0.7*M} and {M}, where {M = max{fabs(x),fabs(y)}}; < thus, if the result is less that 1.0 in absolute value, then < {fabs(d) < rel_tol*fabs(x)} and {fabs(d) < rel_tol*fabs(y)}; if < the result is greater than 1 in absolute value, then {fabs(d) > < 0.7*rel_tol*fabs(x)} and {fabs(d) > 0.7*rel_tol*fabs(y)}. */ > and +1 when {x} and {y} are equal and opposite). */ ============================================================== ../../../LIBS/libs-core/libjs/jsrandom.c affine_tracker/libjs/jsrandom.c --- 2c2 ----------------------- < /* Last edited on 2008-05-25 03:30:28 by stolfi */ > /* Last edited on 2007-01-03 11:42:28 by stolfi */ --- 4,9c4 ----------------------- < #define _GNU_SOURCE < #include < #include < #include < #include < #include > #include --- 13c8,12 ----------------------- < #include > #include > #include > #include > #include > #include --- 60c59 ----------------------- < { js_min_gauss_R = sqrt(log(DBL_MAX))/DBL_MAX; } > { js_min_gauss_R = sqrt(log(MAXDOUBLE))/MAXDOUBLE; } ============================================================== ../../../LIBS/libs-core/libjs/jsrandom.h affine_tracker/libjs/jsrandom.h ============================================================== ../../../LIBS/libs-core/libjs/jsstring.c affine_tracker/libjs/jsstring.c ============================================================== ../../../LIBS/libs-core/libjs/jsstring.h affine_tracker/libjs/jsstring.h ============================================================== ../../../LIBS/libs-core/libjs/jstime.c affine_tracker/libjs/jstime.c ============================================================== ../../../LIBS/libs-core/libjs/jstime.h affine_tracker/libjs/jstime.h ============================================================== ../../../LIBS/libs-core/libjs/nat.c affine_tracker/libjs/nat.c ============================================================== ../../../LIBS/libs-core/libjs/nat.h affine_tracker/libjs/nat.h ============================================================== ../../../LIBS/libs-core/libjs/nget.c affine_tracker/libjs/nget.c --- 2c2 ----------------------- < /* Last edited on 2008-07-24 17:49:52 by stolfi */ > /* Last edited on 2007-01-16 03:04:37 by stolfi */ --- 37,41d36 ----------------------- < int32_t nget_int32(FILE *f, char *name) < { nget_name_eq(f, name); < return fget_int32(f); < } < --- 47,51d41 ----------------------- < uint32_t nget_uint32(FILE *f, char *name, int base) < { nget_name_eq(f, name); < return fget_uint32(f, base); < } < ============================================================== ../../../LIBS/libs-core/libjs/nget.h affine_tracker/libjs/nget.h --- 2c2 ----------------------- < /* Last edited on 2008-07-24 17:45:11 by stolfi */ > /* Last edited on 2007-01-16 03:04:28 by stolfi */ --- 28,29d27 ----------------------- < int32_t nget_int32(FILE *f, char *name); < int64_t nget_int64(FILE *f, char *name); --- 31c29 ----------------------- < uint32_t nget_uint32(FILE *f, char *name, int base); > int64_t nget_int64(FILE *f, char *name); ============================================================== ../../../LIBS/libs-core/libjs/pqueue.c affine_tracker/libjs/pqueue.c ============================================================== ../../../LIBS/libs-core/libjs/pqueue.h affine_tracker/libjs/pqueue.h ============================================================== ../../../LIBS/libs-core/libjs/pqueue_rep.h affine_tracker/libjs/pqueue_rep.h ============================================================== ../../../LIBS/libs-core/libjs/ref.h affine_tracker/libjs/ref.h ============================================================== ../../../LIBS/libs-core/libjs/set32.c affine_tracker/libjs/set32.c ============================================================== ../../../LIBS/libs-core/libjs/set32.h affine_tracker/libjs/set32.h ============================================================== ../../../LIBS/libs-core/libjs/sign.h affine_tracker/libjs/sign.h ============================================================== ../../../LIBS/libs-core/libjs/sign_get.c affine_tracker/libjs/sign_get.c ============================================================== ../../../LIBS/libs-core/libjs/sign_get.h affine_tracker/libjs/sign_get.h ============================================================== ../../../LIBS/libs-core/libjs/tbfind.c affine_tracker/libjs/tbfind.c ============================================================== ../../../LIBS/libs-core/libjs/tbfind.h affine_tracker/libjs/tbfind.h ============================================================== ../../../LIBS/libs-core/libjs/tests/testenumorb/testenumorb.c affine_tracker/libjs/tests/testenumorb/testenumorb.c ============================================================== ../../../LIBS/libs-core/libjs/tests/testindexing/testindexing.c affine_tracker/libjs/tests/testindexing/testindexing.c --- 5c5 ----------------------- < /* Last edited on 2008-02-21 12:12:41 by stolfi */ > /* Last edited on 2007-10-10 21:03:33 by stolfi */ --- 67,69d66 ----------------------- < /* General limit and data type tests: */ < demand((ix_pos_NONE < 0) || (ix_pos_NONE > ix_MAX_POS), "invalid ix_pos_NONE"); < --- 185,187d181 ----------------------- < ix_pos_t addr_safe = ix_position_safe(A->d, ixA, A->z, A->b, A->s); < if (addr != addr_safe) < { bug("ix_position_safe mismatch addr = %llu addr_safe = %llu", addr, addr_safe); } ============================================================== ../../../LIBS/libs-core/libjs/tests/testjsmath/testjsmath.c affine_tracker/libjs/tests/testjsmath/testjsmath.c --- 5c5 ----------------------- < /* Last edited on 2008-09-29 06:00:55 by stolfi */ > /* Last edited on 2008-01-16 16:23:51 by stolfi */ --- 11c11,14 ----------------------- < #define _GNU_SOURCE > #include > #include > #include > --- 16,22d18 ----------------------- < #include < #include < < #include < #include < #include < #include --- 32c28,29 ----------------------- < double zrandom(void); /* A random double with random magnitude. */ > uint64_t uint64_random(); > int64_t int64_random(); --- 39,73d35 ----------------------- < void test_uint64_mul(int nt); < < // #define N_double_nice 10 < // < // static double double_nice[N_double_nice] = < // { < // 4.45014771701440277e-308, /* 8/DBL_MAX. */ < // 7.45834073120020674e-155, /* 1/sqrt(DBL_MAX). */ < // 5.00000000000000000e-001, < // 9.99999999999999889e-001, < // 1.00000000000000000e+000, < // 1.00000000000000022e+000, < // 2.00000000000000000e+000, < // 1.34078079299425971e+154, /* sqrt(DBL_MAX). */ < // 2.24711641857789464e+307, /* DBL_MAX/8. */ < // 0 < // }; < < #define N_uint32_nice 13 < < static uint32_t uint32_nice[N_uint32_nice] = < { 1, < 2, < 3, < 4, < 12, < 1023, < 1024, < 1025, < 2147483647UL, /* 2^31-1 */ < 2147483648UL, /* 2^31 */ < 2147483649UL, /* 2^31+1 */ < 4294967295UL, /* 2^32-1 */ < 0 < }; --- 119d80 ----------------------- < test_uint64_mul(200); --- 190,275c151 ----------------------- < int iy,ix; < for (iy = 0; iy < N_uint32_nice + nt; iy++) < { uint32_t y = (iy < N_uint32_nice ? uint32_nice[iy] : (uint32_t)int64_random()); < for (ix = 0; ix < N_int64_nice + nt; ix++) < { int64_t x = (ix < N_int64_nice ? int64_nice[ix] : int64_random()); < if ((y > 1) && ((x > +1) || (x < -1))) < { /* Reduce {y} if needed so that the power will not overflow: */ < uint32_t ymax; < if ((x > 0) || (y % 2 == 0)) < { int64_t pmax = +9223372036854775807LL; /* 2^63-1 */ < ymax = 0; do { pmax /= x; ymax++; } while ((pmax/x) != 0); < < } < else < { int64_t pmax = ((int64_t)-9223372036854775807LL)-1; /* -2^63 */ < ymax = 0; do { pmax /= x; ymax++; } while ((pmax/x) != 0); < } < if (y > ymax) { y = ymax; } < } < /* Compute the power {z}: */ < int64_t z = ipow(x, y); < /* Check whether {x} divides {z} {y} times exactly, leaving 1: */ < if (y == 0) < { affirm(z == 1, "x^0 is not 1"); } < else if (x == 0) < { affirm(z == 0, "0^y is not 0"); } < else if (x == +1) < { affirm(z == +1, "1^y is not 1"); } < else if (x == -1) < { affirm(z == (y % 2 == 0 ? +1 : -1), "(-1)^y is not (-1)^(y%2)"); } < else if (y == 1) < { affirm(z == x, "x^1 is not x"); } < else < { int64_t p = z; < while ((p > 1) || (p < -1)) < { int64_t q = p/x; < affirm(p - q*x == 0, "x^y is not a power of x"); < p = q; < } < if (p != 1) { fprintf(stderr, "x = %lld y = %u z = %lld p = %lld\n", x, y, z, p); } < affirm(p == 1, "power is not divisible y times by x"); < } < } < } < } < < void test_uint64_mul(int nt) < { fprintf(stderr, "Checking {uint64_mul}...\n"); < int i,j; < for (i = 0; i < N_uint64_nice + nt; i++) < { uint64_t x = (i < N_uint64_nice ? uint64_nice[i] : uint64_random()); < for (j = 0; j < N_uint64_nice + nt; j++) < { uint64_t y = (j < N_uint64_nice ? uint64_nice[j] : uint64_random()); < uint64_t Z[2]; < uint64_mul(x, y, Z); < /* Slow multiplication: */ < int i; < uint64_t P[2] = { 0, 0 }; < uint64_t M = 1; < for (i = 0; i < 64; i++) < { if ((M & x) != 0) < { /* Add {y} shifted by {i} onto {P}: */ < uint64_t Q = P[0] + (y << i); < if (Q < P[0]) { /* carry happened: */ P[1] += 1; } < P[0] = Q; < if (i > 0) { P[1] += (y >> (64 - i)); } < } < M = (M << 1); < } < < if ((P[0] != Z[0]) || (P[1] != Z[1])) < { < fprintf(stderr, "x = %llu y = %llu", x, y); < fprintf(stderr, " Z = %llu ×2^64 + %llu", Z[1], Z[0]); < fprintf(stderr, " P = %llu ×2^64 + %llu\n", P[1], P[0]); < affirm(FALSE, "bug"); < } < } < } < } < < #define LOG_DBL_MAX (709.78271289338397) < < double zrandom(void) < { < return drandom()*exp(LOG_DBL_MAX*(2*drandom() - 1)); > fprintf(stderr, "*** test not implemented yet! ***\n"); ============================================================== ../../../LIBS/libs-core/libjs/tests/testnow/testnow-out.gpl affine_tracker/libjs/tests/testnow/testnow-out.gpl ============================================================== ../../../LIBS/libs-core/libjs/tests/testnow/testnow.c affine_tracker/libjs/tests/testnow/testnow.c ============================================================== ../../../LIBS/libs-core/libjs/tests/testsleep/testsleep.c affine_tracker/libjs/tests/testsleep/testsleep.c ============================================================== ../../../LIBS/libs-core/libjs/tests/testsort/testsort.c affine_tracker/libjs/tests/testsort/testsort.c --- 97,99c97,99 ----------------------- < { affirm((i >= 0) && (i < c.ne), "bad i"); < affirm((j >= 0) && (j < c.ne), "bad j"); < double ci = c.e[i], cj = c.e[j]; > { affirm((i >= 0) && (i < c.nel), "bad i"); > affirm((j >= 0) && (j < c.nel), "bad j"); > double ci = c.el[i], cj = c.el[j]; --- 179c179 ----------------------- < { fprintf(stderr, "%5d %5d %6.3f", i, h[i], c.e[h[i]]); > { fprintf(stderr, "%5d %5d %6.3f", i, h[i], c.el[h[i]]); --- 221c221 ----------------------- < c.e[i] = (i < (9*n + 9)/10 ? (1.0 + sin(22.2*i*i))/2 : c.e[n-i-1]); > c.el[i] = (i < (9*n + 9)/10 ? (1.0 + sin(22.2*i*i))/2 : c.el[n-i-1]); --- 227c227 ----------------------- < { fprintf(stderr, "%5d %5d %6.3f\n", i, h[i], c.e[h[i]]); } > { fprintf(stderr, "%5d %5d %6.3f\n", i, h[i], c.el[h[i]]); } --- 249c249 ----------------------- < { fprintf(stderr, "%5d %5d %6.3f\n", i, h[i], c.e[h[i]]); } > { fprintf(stderr, "%5d %5d %6.3f\n", i, h[i], c.el[h[i]]); } --- 256c256 ----------------------- < { fprintf(stderr, "%5d %5d %6.3f\n", i, h[i], c.e[h[i]]); } > { fprintf(stderr, "%5d %5d %6.3f\n", i, h[i], c.el[h[i]]); } ============================================================== ../../../LIBS/libs-core/libjs/tests/testsortspeed/testsortspeed.c affine_tracker/libjs/tests/testsortspeed/testsortspeed.c ============================================================== ../../../LIBS/libs-core/libjs/tests/testtbfind/testtbfind.c affine_tracker/libjs/tests/testtbfind/testtbfind.c --- 5c5 ----------------------- < /* Last edited on 2008-05-25 03:25:09 by stolfi */ > /* Last edited on 2007-01-13 04:15:31 by stolfi */ --- 20c20 ----------------------- < #include > #include ============================================================== ../../../LIBS/libs-core/libjs/tests/testulist/testulist.c affine_tracker/libjs/tests/testulist/testulist.c ============================================================== ../../../LIBS/libs-core/libjs/timefunc.c affine_tracker/libjs/timefunc.c ============================================================== ../../../LIBS/libs-core/libjs/timefunc.h affine_tracker/libjs/timefunc.h ============================================================== ../../../LIBS/libs-core/libjs/ulist.c affine_tracker/libjs/ulist.c ============================================================== ../../../LIBS/libs-core/libjs/ulist.h affine_tracker/libjs/ulist.h ============================================================== ../../../LIBS/libs-core/libjs/vec.c affine_tracker/libjs/vec.c --- 2c2 ----------------------- < /* Last edited on 2008-03-29 14:33:12 by stolfi */ > /* Last edited on 2008-01-06 23:40:18 by stolfi */ --- 9,21c9,23 ----------------------- < void *vec_alloc(uint32_t ne, size_t esz) < { void *e = (ne == 0 ? NULL : malloc(ne*esz)); < affirm((ne == 0) || (e != NULL), "out of mem"); < return e; < } < < void vec_expand(uint32_t *nep, void **ep, uint32_t index, size_t esz) < { if (index >= (*nep)) < { int ne = (*nep) + index + 1; < if ((*nep) == 0) { affirm((*ep) == NULL, "bad elem pointer"); } < (*ep) = realloc((*ep), ne*esz); < affirm((*ep) != NULL, "out of mem"); < (*nep) = ne; > vec_t vec_new(int nel, size_t elsz) > { vec_t v; > v.nel = nel; > v.el = (nel == 0 ? NULL : malloc(nel*elsz)); > affirm((nel == 0) || (v.el != NULL), "out of mem"); > return v; > } > > void vec_expand(vec_t *v, unsigned int index, size_t elsz) > { if (index >= v->nel) > { int nel = v->nel + index + 1; > if (v->nel == 0) { affirm(v->el == NULL, "bad elem pointer"); } > v->el = realloc(v->el, nel*elsz); > affirm(v->el != NULL, "out of mem"); > v->nel = nel; --- 25,28c27,30 ----------------------- < void vec_trim(uint32_t *nep, void **ep, uint32_t ne, size_t esz) < { if (ne != (*nep)) < { if (ne == 0) < { free((*ep)); (*ep) = NULL; } > void vec_trim(vec_t *v, unsigned int nel, size_t elsz) > { if (nel != v->nel) > { if (nel == 0) > { free(v->el); v->el = NULL; } --- 30,31c32,33 ----------------------- < { (*ep) = realloc((*ep), ne*esz); < affirm((*ep) != NULL, "out of mem"); > { v->el = realloc(v->el, nel*elsz); > affirm(v->el != NULL, "out of mem"); --- 33c35 ----------------------- < (*nep) = ne; > v->nel = nel; --- 36a39,65 ----------------------- > vec_t *vec_cast_ref(void *v) > { return (vec_t *)v; } > > vec_sub_t vec_as_sub(vec_t *v) > { vec_sub_t vs; > vs.nel = v->nel; vs.el = v->el; vs.step = 1; > return vs; > } > > vec_sub_t vec_sub(vec_sub_t *vs, unsigned int start, int step, unsigned int nel, size_t elsz) > { vec_sub_t rs; > demand(step != 0, "step cannot be zero"); > if (start >= vs->nel) > { rs.nel = 0; } > else > { int maxnel = (step > 0 ? (vs->nel - start)/step : (start-1)/(-step) + 1); > rs.nel = (nel <= maxnel ? nel : maxnel); > } > if (rs.nel == 0) > { rs.el = NULL; rs.step = 1; } > else > { rs.el = (void *)((char *)vs->el + elsz*(start*vs->step)); > rs.step = step*vs->step; > } > return rs; > } > --- 41,42d69 ----------------------- < vec_typeimpl(char_vec_t, char_vec, char); < vec_typeimpl(bool_vec_t, bool_vec, bool_t); --- 45c72,75 ----------------------- < vec_typeimpl(ref_vec_t, ref_vec, void*); > vec_typeimpl(bool_vec_t, bool_vec, bool_t); > vec_typeimpl(char_vec_t, char_vec, char); > vec_typeimpl(ubyte_vec_t, ubyte_vec, uint8_t); > vec_typeimpl(sbyte_vec_t, sbyte_vec, int8_t); --- 46a77 ----------------------- > vec_typeimpl(ref_vec_t, ref_vec, void*); --- 49,56d79 ----------------------- < vec_typeimpl(int8_vec_t, int8_vec, int8_t); < vec_typeimpl(int16_vec_t, int16_vec, int16_t); < vec_typeimpl(int32_vec_t, int32_vec, int32_t); < vec_typeimpl(int64_vec_t, int64_vec, int64_t); < vec_typeimpl(uint8_vec_t, uint8_vec, uint8_t); < vec_typeimpl(uint16_vec_t, uint16_vec, uint16_t); < vec_typeimpl(uint32_vec_t, uint32_vec, uint32_t); < vec_typeimpl(uint64_vec_t, uint64_vec, uint64_t); ============================================================== ../../../LIBS/libs-core/libjs/vec.h affine_tracker/libjs/vec.h --- 1,2c1,2 ----------------------- < /* Self-bounded vectors (one-dimensional arrays) of things */ < /* Last edited on 2008-07-22 22:04:49 by stolfi */ > /* vec.h -- self-bounded vectors (one-dimensional arrays) of things */ > /* Last edited on 2008-01-06 23:48:52 by stolfi */ --- 4,13c4,8 ----------------------- < #ifndef vec_H < #define vec_H < < #include < #include < < #include < #include < < /* SELF-BOUNDED VECTORS > /* This module defines tools for handling generic vectors > (unidimensional arrays) of things, where, unlike standard C vectors, > the number of elements is stored as part of the representation. > Thus, when passing a {vec_t} to a procedure, there is no need to > pass its size as as a separate parameter. --- 15,21c10 ----------------------- < This interface defines self-bounded vectors (unidimensional arrays) < with elements of any specified type. Unlike standard C vectors, the < number of elements is part of the vector's representation. Thus, < when passing a self-bounded vector to a procedure, there is no need < to pass its size as as a separate parameter. < < This interface also defines efficient and convenient procedures for > This module also defines efficient and convenient procedures for --- 27,29c16 ----------------------- < advantages. For example, consider this bit of code that generates an < undetermined number of {double} values, one value at a time, and < saves them into a self-bounded vector (a {double_vec_t}): > advantages. A typical example would be --- 31c18 ----------------------- < double_vec_t x = double_vec_new(100); > double_vec_t x = double_vec_new(initsize); --- 33,34c20,21 ----------------------- < while(! finished(...)) < { double z = generate_next_value(...); > for ... > { ... --- 36c23 ----------------------- < x.e[nx] = z; nx++; > x.el[nx] = ...; nx++; --- 39a27 ----------------------- > for (i = 0; i < x.nel; i++) { print(x.el[i]); } --- 41c29 ----------------------- < The saved values can then be printed with > */ --- 43c31,32 ----------------------- < for (i = 0; i < x.ne; i++) { printf("%f\n", x.e[i]); } > #ifndef vec_H > #define vec_H --- 45c34,37 ----------------------- < */ > #include > #include > #include > #include --- 47c39 ----------------------- < /* DECLARING A NEW SPARSE VECTOR TYPE */ > /* TYPED VECTOR DESCRIPTORS --- 49,157c41,42 ----------------------- < #define vec_typedef(VEC_TYPE,PREFIX,ELEM_TYPE) \ < vec_DEFINE_VEC_TYPE(VEC_TYPE,PREFIX,ELEM_TYPE); \ < vec_DECLARE_NEW(VEC_TYPE,PREFIX,ELEM_TYPE); \ < vec_DECLARE_EXPAND(VEC_TYPE,PREFIX,ELEM_TYPE); \ < vec_DECLARE_TRIM(VEC_TYPE,PREFIX,ELEM_TYPE); \ < vec_DECLARE_MAKE_DESC(VEC_TYPE,PREFIX,ELEM_TYPE) < /* < This macro defines a new vector type called {VEC_TYPE}, whose < elements are of type {ELEM_TYPE}. < < This macro will also declare prototypes for the functions < < { {PREFIX}_new < {PREFIX}_expand < {PREFIX}_trim < {PREFIX}_make_desc } < < which are described below. < < For example, the macro call < < { vec_typedef(string_vec_t, string_vec, char *); } < < will declare the type {string_vec_t}, a self-bounded vector with < elements of type {char *}; and will also declare the procedures < {string_vec_new}, {string_vec_expand}, etc. < < The names {VEC_TYPE} and {PREFIX} can be chosen quite arbitrarily. < However, if {ELEM_TYPE} is some previously defined type named < {{XXX}_t} or {XXX}, it is recommended to use {XXX}_vec_t} < as the {VEC_TYPE}, and {{XXX}_vec} as the {PREFIX}. */ < < #define vec_typeimpl(VEC_TYPE,PREFIX,ELEM_TYPE) \ < vec_IMPLEMENT_NEW(VEC_TYPE,PREFIX,ELEM_TYPE) \ < vec_IMPLEMENT_EXPAND(VEC_TYPE,PREFIX,ELEM_TYPE) \ < vec_IMPLEMENT_TRIM(VEC_TYPE,PREFIX,ELEM_TYPE) \ < vec_IMPLEMENT_MAKE_DESC(VEC_TYPE,PREFIX,ELEM_TYPE) \ < extern void PREFIX##_bOgUs /* To eat the semicolon. */ < /* < This macro expands into the implementation of the sparse vector < operations {{PREFIX}_new}, {PREFIX}_expand}, etc. It should be < called after the corresponding call to {vec_typedef}, which < declares the prototypes for those procedures. */ < < /* VECTOR DESCRIPTOR */ < < #define vec_DEFINE_VEC_TYPE(VEC_TYPE,PREFIX,ELEM_TYPE) \ < typedef struct VEC_TYPE \ < { uint32_t ne; \ < ELEM_TYPE *e; \ < } VEC_TYPE < /* < Defines the type {VEC_TYPE}. A variable {v} of that type is a < descriptor for a vector with {v.ne} elements of type {ELEM_TYPE}, < namely {v.e[0..v.ne-1]}. */ < < /* ALLOCATION */ < < #define vec_DECLARE_NEW(VEC_TYPE,PREFIX,ELEM_TYPE) \ < VEC_TYPE PREFIX##_new(uint32_t ne) < /* < This macro declares the function {{PREFIX}_new}. The call < {{PREFIX}_new(ne)} allocates a new vector of type {VEC_TYPE}, with < space for {ne} elements, and returns its descriptor. */ < < /* STORAGE EXPANSION */ < < #define vec_DECLARE_EXPAND(VEC_TYPE,PREFIX,ELEM_TYPE) \ < void PREFIX##_expand(VEC_TYPE *vp, int index) < /* < This macro declares the function {{PREFIX}_expand}. The call < {{PREFIX}_expand(&v,pos)} makes sure that the element {v.e[pos]} < exists. If necessary, it allocates a larger area from the heap, < copies the old elements of {v} into it, reclaims the old area {v.e}, < and finally sets {v.e} to the new area and {v.ne} to its size (which < will be strictly greater than {pos}). The element count {v.ne} is < approximately doubled at each reallocation, to ensure total {O(N)} < time for adding {N} elements. */ < < /* STORAGE TRIMMING */ < < #define vec_DECLARE_TRIM(VEC_TYPE,PREFIX,ELEM_TYPE) \ < void PREFIX##_trim(VEC_TYPE *vp, uint32_t ne) < /* < This macro declares the function {{PREFIX}_trim}. The call < {{PREFIX}_trim(&v,size)} reallocates the element area {v.e} if < necessary so that it has exactly {size} elements. It preserves the < elements {v.e[0..size-1]} and sets {v.ne = size}. */ < < /* DESCRIPTOR ASSEMBLY */ < < #define vec_DECLARE_MAKE_DESC(VEC_TYPE,PREFIX,ELEM_TYPE) \ < VEC_TYPE PREFIX##_make_desc(ELEM_TYPE *e, uint32_t ne) < /* < This macro declares the function {{PREFIX}_make_desc}. The call < {{PREFIX}_make_desc(e, ne)} assembles a vector descriptor from the < given element count {ne} and the address {e} of the first explicit < entry. The client must ensure that the variables {e[0..ne-1]} < actually exist. The procedures {{PREFIX}_expand} and {{PREFIX}_trim} < can be applied to the resulting descriptor only if the address {e} < was obtained through {malloc}. */ < < /* PROCEDURE IMPLEMENTATIONS */ < < #define vec_IMPLEMENT_NEW(VEC_TYPE,PREFIX,ELEM_TYPE) \ < VEC_TYPE PREFIX##_new(uint32_t ne) \ < { void *e = vec_alloc(ne, sizeof(ELEM_TYPE)); \ < return (VEC_TYPE){ne, (ELEM_TYPE *)e}; \ < } > To define a new vector type called, e.g., {myvec_t}, with elements > of type {myelem_t}, write --- 159,163c44,137 ----------------------- < #define vec_IMPLEMENT_EXPAND(VEC_TYPE,PREFIX,ELEM_TYPE) \ < void PREFIX##_expand(VEC_TYPE *vp, int index) \ < { if (index >= vp->ne) \ < { vec_expand(&(vp->ne), (void**)&(vp->e), index, sizeof(ELEM_TYPE)); } \ < } > { vec_typedef(myvec_t,myvec,myelem_t); } > > in the proper ".h" file, and > > { vec_typeimpl(myvec_t,myvec,myelem_t); } > > in the corresponding ".c" file. These macros will declare the type > {myvec_t} and the four associated procedures: > > { myvec_t myvec_new(unsigned int nel); } > > { void myvec_expand(myvec_t *v, unsigned int index); } > > { void myvec_trim(myvec_t *v, unsigned int size); } > > { myvec_t myvec_desc(unsigned int nel, myelem_t *el); } > > A variable {v} of type {myvec_t} is a descriptor to a > vector of {myelem_t} elements. The field {v.el} points to a heap > area with space for {v.nel} such elements, namely {v.el[0..v.nel-1]}. > > The call {myvec_new(nel)} allocates a new {myvec_t} with > space for {nel} elements, and returns its {myvec_t} descriptor. > > The call {myvec_expand(&v,index)} makes sure that element > {v.el[index]} exists. If necessary, it reallocates the area > referenced by {v.el}, copies the old elements into it, and updates > {v.nel} to the new size (which will be strictly greater than > {index}). Size is doubled at each reallocation, to ensure total > {O(N)} time for {N} calls. > > The call {myvec_trim(&v,size)} reallocates {v.el} if necessary > so that it has exactly {size} elements. It preserves the elements > {v.el[0..size-1]} and sets {v.nel = size}. > > The call {myvec_desc(el, nel)} assembles a {myvec_t} descriptor from > a given element count {nel} and the address {el} of the first > element. The client must ensure that {el[0..nel-1]} are valid. The > procedures {myvec_expand} and {myvec_trim} can be applied to the > resulting descriptor only if the address {el} was provided by > {malloc}. > > The macros {vec_typedef} and {vec_typeimpl} are defined with three > separate parameters for greater flexibility and back-compatibility. > However, it is suggested that the parameters be of the form > {XXX_vec_t}, {XXX_vec}, and {XXX_t}, for some {XXX}, whenever > possible. > > */ > > #define vec_typedef(VECTYPE,VECNAME,ELEMTYPE) \ > typedef struct VECTYPE { unsigned int nel; ELEMTYPE *el; } VECTYPE; \ > VECTYPE VECNAME##_new(unsigned int nel); \ > void VECNAME##_expand(VECTYPE *nv, int index); \ > void VECNAME##_trim(VECTYPE *nv, unsigned int nel); \ > VECTYPE VECNAME##_desc(ELEMTYPE *el, unsigned int nel) > > #define vec_typeimpl(VECTYPE,VECNAME,ELEMTYPE) \ > VECTYPE VECNAME##_new(unsigned int nel) \ > { vec_t v = vec_new(nel, sizeof(ELEMTYPE)); \ > return (VECTYPE){v.nel, (ELEMTYPE *)v.el}; \ > } \ > void VECNAME##_expand(VECTYPE *nv, int index) \ > { if (index >= nv->nel) \ > { vec_expand((vec_t *)nv, index, sizeof(ELEMTYPE)); } \ > } \ > void VECNAME##_trim(VECTYPE *nv, unsigned int nel) \ > { vec_trim((vec_t *)nv, nel, sizeof(ELEMTYPE)); } \ > VECTYPE VECNAME##_desc(ELEMTYPE *el, unsigned int nel) \ > { return (VECTYPE){nel, el}; } \ > extern void VECNAME##_bOgUs /* To eat the semicolon. */ > > /* GENERIC VECTOR DESCRIPTORS */ > > typedef struct vec_t /* General vector descriptor. */ > { unsigned int nel; /* Number of elements. */ > void *el; /* Pointer to element zero. */ > } vec_t; > /* A {vec_t} {v} describes a uni-dimensional array of {v.nel} elements > of the same size and type, stored in consecutive memory locations, > starting at address {v.el}. > > The size of each element is not part of the structure, and must be > provided separately. Usually, {vec_t}s are used to implement > vectors of a specific type, such as {int} or {unsigned int}, where the size > can be provided by macros. See the examples of {int_vec_t} and > {char_vec_t} below. */ > > /* GENERIC VECTOR FUNCTIONS > > The functions in this section may be called directly by clients, > but their main purpose is to implement the > functions {myvec_new}, {myvec_expand}, and {myvec_trim} > defined by {vec_typedef} and {vec_typeimpl}. */ --- 165,171c139,179 ----------------------- < #define vec_IMPLEMENT_TRIM(VEC_TYPE,PREFIX,ELEM_TYPE)\ < void PREFIX##_trim(VEC_TYPE *vp, uint32_t ne) \ < { vec_trim(&(vp->ne), (void**)&(vp->e), ne, sizeof(ELEM_TYPE)); } < < #define vec_IMPLEMENT_MAKE_DESC(VEC_TYPE,PREFIX,ELEM_TYPE)\ < VEC_TYPE PREFIX##_make_desc(ELEM_TYPE *e, uint32_t ne) \ < { return (VEC_TYPE){ne, e}; } > vec_t vec_new(int nel, size_t elsz); > /* Allocates a new vector with {nel} elements of size {elsz}. > Bombs out if there is no space for the request. > If {nel == 0}, the result has {el == NULL}. */ > > void vec_expand(vec_t *v, unsigned int index, size_t elsz); > /* Makes sure that element {v->el[index]} exists, reallocating and > copying the array {*v->el} if {index >= v->nel}. If that happens, > the new {v->nel} will be about twice as big as the old one. */ > > void vec_trim(vec_t *v, unsigned int nel, size_t elsz); > /* Makes sure that {v.nel == nel}, reallocating and copying > the array {*v->el} if {v.nel != nel}. If {nel == 0}, the > result will have {el == NULL}. */ > > vec_t *vec_cast_ref(void *v); > /* Casts the argument as an address to a {vec_t}. Can be used to > apply vec_expand or vec_trim to vectors of specific types. > We define it as a function in order to trigger type warnings > when {v} is not an address (a common mistake). */ > > /* SUB-VECTOR DESCRIPTORS */ > > typedef struct vec_sub_t /* Regular sub-sequence of a {vec_t}. */ > { unsigned int nel; /* Number of elements in sub-vector. */ > void *el; /* Pointer to element zero of sub-vector. */ > int step; /* Increment between consecutive elements (in elements). */ > } vec_sub_t; > > vec_sub_t vec_as_sub(vec_t *v); > /* Returns a sub-vector descriptor for the entire vector > {v} (with {step == 1}). */ > > vec_sub_t vec_sub(vec_sub_t *vs, unsigned int start, int step, unsigned int nel, size_t elsz); > /* Returns a descriptor {r} for the specified subsequence of elements > of {vs}, namely {r[i] = vs[start + i*step]}, for {i = 0..r.nel-1}. > The {step} cannot be zero. > > The result size {r.nel} is the largest integer in {0..nel} such > that all those elements exist. In particular, if {start} is not in > {0..vs.nel-1}, then {m} is zero. */ --- 181,186d188 ----------------------- < vec_typedef(char_vec_t, char_vec, char); < /* Vectors of {char}s. */ < < vec_typedef(bool_vec_t, bool_vec, bool_t); < /* Vectors of {bool_t}s. */ < --- 193,212c195,196 ----------------------- < vec_typedef(ref_vec_t, ref_vec, ref_t); < /* Vectors of arbitrary addresses. */ < < vec_typedef(string_vec_t, string_vec, char*); < /* Vectors of strings ({char*}s). */ < < vec_typedef(int8_vec_t, int8_vec, int8_t); < /* Vectors of {int8_t}s (signed bytes, {signed char}s). */ < < vec_typedef(int16_vec_t, int16_vec, int16_t); < /* Vectors of {int16_t}s (signed half-words, {signed short int}s). */ < < vec_typedef(int32_vec_t, int32_vec, int32_t); < /* Vectors of {int32_t}s. */ < < vec_typedef(int64_vec_t, int64_vec, int64_t); < /* Vectors of {int64_t}s. */ < < vec_typedef(uint8_vec_t, uint8_vec, uint8_t); < /* Vectors of {unit8_t}s (unsigned bytes, {unsigned char}s). */ > vec_typedef(bool_vec_t, bool_vec, bool_t); > /* Vectors of {bool_t}s. */ --- 214,215c198,199 ----------------------- < vec_typedef(uint16_vec_t, uint16_vec, uint16_t); < /* Vectors of {unit16_t}s (unsigned half-words, {unsigned short int}s. */ > vec_typedef(char_vec_t, char_vec, char); > /* Vectors of {char}s. */ --- 217,218c201,202 ----------------------- < vec_typedef(uint32_vec_t, uint32_vec, uint32_t); < /* Vectors of {uint32_t}s. */ > vec_typedef(ubyte_vec_t, ubyte_vec, uint8_t); > /* Vectors of {unsigned char}s. */ --- 220,222c204,205 ----------------------- < vec_typedef(uint64_vec_t, uint64_vec, uint64_t); < /* Vectors of {uint64_t}s. */ < /* GENERIC PROCEDURES FOR SELF-BOUNDED VECTORS > vec_typedef(sbyte_vec_t, sbyte_vec, int8_t); > /* Vectors of {signed char}s. */ --- 224,227c207,208 ----------------------- < The functions in this section may be called directly by clients, < but their main purpose is to implement the < functions {my_vec_new}, {my_vec_expand}, and {my_vec_trim} < defined by {vec_typedef} and {vec_typeimpl}. */ > vec_typedef(string_vec_t, string_vec, char*); > /* Vectors of strings ({char*}s). */ --- 229,244c210,211 ----------------------- < void *vec_alloc(uint32_t ne, size_t esz); < /* Allocates a new storage area with space for {ne} elements of < size {esz}. Bombs out if there is no space for the request. If < {ne == 0}, the result is {NULL}. */ < < void vec_expand(uint32_t *nep, void **ep, uint32_t index, size_t esz); < /* Makes sure that element {(*ep)[index]} exists, reallocating and < copying the array {**ep} if {index >= (*nep)}. If that happens, < sets {(*nep) to the new element count; which will be strictly < greater than {index}, and about twice as big as the old < {(*nep)}. */ < < void vec_trim(uint32_t *nep, void **ep, uint32_t ne, size_t esz); < /* Makes sure that {(*nep) == ne}, reallocating and copying < the array {**ep} if {(*nep) != ne}. If {ne == 0}, sets < {*ep} to {NULL}. */ > vec_typedef(ref_vec_t, ref_vec, ref_t); > /* Vectors of arbitrary addresses. */ ============================================================== ../../../LIBS/libs-core/libjspnm/jsdithers.h affine_tracker/libjspnm/jsdithers.h --- 3d2 ----------------------- < ** Last edited on 2008-08-26 12:04:15 by stolfi --- 14,21c13,20 ----------------------- < { 1, 59, 15, 55, 2, 56, 12, 52 }, < { 33, 17, 47, 31, 34, 18, 44, 28 }, < { 9, 49, 5, 63, 10, 50, 6, 60 }, < { 41, 25, 37, 21, 42, 26, 38, 22 }, < { 3, 57, 13, 53, 0, 58, 14, 54 }, < { 35, 19, 45, 29, 32, 16, 46, 30 }, < { 11, 51, 7, 61, 8, 48, 4, 62 }, < { 43, 27, 39, 23, 40, 24, 36, 20 } }; > 1, 59, 15, 55, 2, 56, 12, 52, > 33, 17, 47, 31, 34, 18, 44, 28, > 9, 49, 5, 63, 10, 50, 6, 60, > 41, 25, 37, 21, 42, 26, 38, 22, > 3, 57, 13, 53, 0, 58, 14, 54, > 35, 19, 45, 29, 32, 16, 46, 30, > 11, 51, 7, 61, 8, 48, 4, 62, > 43, 27, 39, 23, 40, 24, 36, 20 }; --- 25,40c24,39 ----------------------- < { 1,235, 59,219, 15,231, 55,215, 2,232, 56,216, 12,228, 52,212 }, < { 129, 65,187,123,143, 79,183,119,130, 66,184,120,140, 76,180,116 }, < { 33,193, 17,251, 47,207, 31,247, 34,194, 18,248, 44,204, 28,244 }, < { 161, 97,145, 81,175,111,159, 95,162, 98,146, 82,172,108,156, 92 }, < { 9,225, 49,209, 5,239, 63,223, 10,226, 50,210, 6,236, 60,220 }, < { 137, 73,177,113,133, 69,191,127,138, 74,178,114,134, 70,188,124 }, < { 41,201, 25,241, 37,197, 21,255, 42,202, 26,242, 38,198, 22,252 }, < { 169,105,153, 89,165,101,149, 85,170,106,154, 90,166,102,150, 86 }, < { 3,233, 57,217, 13,229, 53,213, 0,234, 58,218, 14,230, 54,214 }, < { 131, 67,185,121,141, 77,181,117,128, 64,186,122,142, 78,182,118 }, < { 35,195, 19,249, 45,205, 29,245, 32,192, 16,250, 46,206, 30,246 }, < { 163, 99,147, 83,173,109,157, 93,160, 96,144, 80,174,110,158, 94 }, < { 11,227, 51,211, 7,237, 61,221, 8,224, 48,208, 4,238, 62,222 }, < { 139, 75,179,115,135, 71,189,125,136, 72,176,112,132, 68,190,126 }, < { 43,203, 27,243, 39,199, 23,253, 40,200, 24,240, 36,196, 20,254 }, < { 171,107,155, 91,167,103,151, 87,168,104,152, 88,164,100,148, 84 } }; > 1,235, 59,219, 15,231, 55,215, 2,232, 56,216, 12,228, 52,212, > 129, 65,187,123,143, 79,183,119,130, 66,184,120,140, 76,180,116, > 33,193, 17,251, 47,207, 31,247, 34,194, 18,248, 44,204, 28,244, > 161, 97,145, 81,175,111,159, 95,162, 98,146, 82,172,108,156, 92, > 9,225, 49,209, 5,239, 63,223, 10,226, 50,210, 6,236, 60,220, > 137, 73,177,113,133, 69,191,127,138, 74,178,114,134, 70,188,124, > 41,201, 25,241, 37,197, 21,255, 42,202, 26,242, 38,198, 22,252, > 169,105,153, 89,165,101,149, 85,170,106,154, 90,166,102,150, 86, > 3,233, 57,217, 13,229, 53,213, 0,234, 58,218, 14,230, 54,214, > 131, 67,185,121,141, 77,181,117,128, 64,186,122,142, 78,182,118, > 35,195, 19,249, 45,205, 29,245, 32,192, 16,250, 46,206, 30,246, > 163, 99,147, 83,173,109,157, 93,160, 96,144, 80,174,110,158, 94, > 11,227, 51,211, 7,237, 61,221, 8,224, 48,208, 4,238, 62,222, > 139, 75,179,115,135, 71,189,125,136, 72,176,112,132, 68,190,126, > 43,203, 27,243, 39,199, 23,253, 40,200, 24,240, 36,196, 20,254, > 171,107,155, 91,167,103,151, 87,168,104,152, 88,164,100,148, 84 }; --- 44,49c43,48 ----------------------- < { 9,11,10, 8, 6, 7 }, < { 12,17,16, 5, 0, 1 }, < { 13,14,15, 4, 3, 2 }, < { 8, 6, 7, 9,11,10 }, < { 5, 0, 1,12,17,16 }, < { 4, 3, 2,13,14,15 } }; > 9,11,10, 8, 6, 7, > 12,17,16, 5, 0, 1, > 13,14,15, 4, 3, 2, > 8, 6, 7, 9,11,10, > 5, 0, 1,12,17,16, > 4, 3, 2,13,14,15 }; --- 53,60c52,59 ----------------------- < { 18,20,19,16,13,11,12,15 }, < { 27,28,29,22, 4, 3, 2, 9 }, < { 26,31,30,21, 5, 0, 1,10 }, < { 23,25,24,17, 8, 6, 7,14 }, < { 13,11,12,15,18,20,19,16 }, < { 4, 3, 2, 9,27,28,29,22 }, < { 5, 0, 1,10,26,31,30,21 }, < { 8, 6, 7,14,23,25,24,17 } }; > 18,20,19,16,13,11,12,15, > 27,28,29,22, 4, 3, 2, 9, > 26,31,30,21, 5, 0, 1,10, > 23,25,24,17, 8, 6, 7,14, > 13,11,12,15,18,20,19,16, > 4, 3, 2, 9,27,28,29,22, > 5, 0, 1,10,26,31,30,21, > 8, 6, 7,14,23,25,24,17 }; --- 64,79c63,78 ----------------------- < { 64, 69, 77, 87, 86, 76, 68, 67, 63, 58, 50, 40, 41, 51, 59, 60 }, < { 70, 94,100,109,108, 99, 93, 75, 57, 33, 27, 18, 19, 28, 34, 52 }, < { 78,101,114,116,115,112, 98, 83, 49, 26, 13, 11, 12, 15, 29, 44 }, < { 88,110,123,124,125,118,107, 85, 39, 17, 4, 3, 2, 9, 20, 42 }, < { 89,111,122,127,126,117,106, 84, 38, 16, 5, 0, 1, 10, 21, 43 }, < { 79,102,119,121,120,113, 97, 82, 48, 25, 8, 6, 7, 14, 30, 45 }, < { 71, 95,103,104,105, 96, 92, 74, 56, 32, 24, 23, 22, 31, 35, 53 }, < { 65, 72, 80, 90, 91, 81, 73, 66, 62, 55, 47, 37, 36, 46, 54, 61 }, < { 63, 58, 50, 40, 41, 51, 59, 60, 64, 69, 77, 87, 86, 76, 68, 67 }, < { 57, 33, 27, 18, 19, 28, 34, 52, 70, 94,100,109,108, 99, 93, 75 }, < { 49, 26, 13, 11, 12, 15, 29, 44, 78,101,114,116,115,112, 98, 83 }, < { 39, 17, 4, 3, 2, 9, 20, 42, 88,110,123,124,125,118,107, 85 }, < { 38, 16, 5, 0, 1, 10, 21, 43, 89,111,122,127,126,117,106, 84 }, < { 48, 25, 8, 6, 7, 14, 30, 45, 79,102,119,121,120,113, 97, 82 }, < { 56, 32, 24, 23, 22, 31, 35, 53, 71, 95,103,104,105, 96, 92, 74 }, < { 62, 55, 47, 37, 36, 46, 54, 61, 65, 72, 80, 90, 91, 81, 73, 66 } }; > 64, 69, 77, 87, 86, 76, 68, 67, 63, 58, 50, 40, 41, 51, 59, 60, > 70, 94,100,109,108, 99, 93, 75, 57, 33, 27, 18, 19, 28, 34, 52, > 78,101,114,116,115,112, 98, 83, 49, 26, 13, 11, 12, 15, 29, 44, > 88,110,123,124,125,118,107, 85, 39, 17, 4, 3, 2, 9, 20, 42, > 89,111,122,127,126,117,106, 84, 38, 16, 5, 0, 1, 10, 21, 43, > 79,102,119,121,120,113, 97, 82, 48, 25, 8, 6, 7, 14, 30, 45, > 71, 95,103,104,105, 96, 92, 74, 56, 32, 24, 23, 22, 31, 35, 53, > 65, 72, 80, 90, 91, 81, 73, 66, 62, 55, 47, 37, 36, 46, 54, 61, > 63, 58, 50, 40, 41, 51, 59, 60, 64, 69, 77, 87, 86, 76, 68, 67, > 57, 33, 27, 18, 19, 28, 34, 52, 70, 94,100,109,108, 99, 93, 75, > 49, 26, 13, 11, 12, 15, 29, 44, 78,101,114,116,115,112, 98, 83, > 39, 17, 4, 3, 2, 9, 20, 42, 88,110,123,124,125,118,107, 85, > 38, 16, 5, 0, 1, 10, 21, 43, 89,111,122,127,126,117,106, 84, > 48, 25, 8, 6, 7, 14, 30, 45, 79,102,119,121,120,113, 97, 82, > 56, 32, 24, 23, 22, 31, 35, 53, 71, 95,103,104,105, 96, 92, 74, > 62, 55, 47, 37, 36, 46, 54, 61, 65, 72, 80, 90, 91, 81, 73, 66 }; ============================================================== ../../../LIBS/libs-core/libjspnm/jspgm_medcutx.c affine_tracker/libjspnm/jspgm_medcutx.c ============================================================== ../../../LIBS/libs-core/libjspnm/jspgm_medcutx.h affine_tracker/libjspnm/jspgm_medcutx.h ============================================================== ../../../LIBS/libs-core/libjspnm/jspnm.c affine_tracker/libjspnm/jspnm.c ============================================================== ../../../LIBS/libs-core/libjspnm/jspnm.h affine_tracker/libjspnm/jspnm.h ============================================================== ../../../LIBS/libs-core/libjspnm/jspnm_image.c affine_tracker/libjspnm/jspnm_image.c --- 2c2 ----------------------- < /* Last edited on 2009-01-04 13:58:32 by stolfi */ > /* Last edited on 2008-01-06 22:22:20 by stolfi */ --- 88,89c88,89 ----------------------- < pnm_image_t *pnm_image_read(char *name, bool_t verbose) < { FILE *rd = open_read(name, verbose); > pnm_image_t *pnm_image_read(char *name) > { FILE *rd = open_read(name, FALSE); --- 113,114c113,114 ----------------------- < void pnm_image_write(char *name, pnm_image_t *img, bool_t forceplain, bool_t verbose) < { FILE *wr = open_write(name, verbose); > void pnm_image_write(char *name, pnm_image_t *img, bool_t forceplain) > { FILE *wr = open_write(name, FALSE); ============================================================== ../../../LIBS/libs-core/libjspnm/jspnm_image.h affine_tracker/libjspnm/jspnm_image.h --- 2c2 ----------------------- < /* Last edited on 2009-01-04 14:00:04 by stolfi */ > /* Last edited on 2008-01-06 22:17:04 by stolfi */ --- 54c54 ----------------------- < pnm_image_t *pnm_image_read(char *name, bool_t verbose); > pnm_image_t *pnm_image_read(char *name); --- 60,61c60 ----------------------- < The {maxval} field is set as specified in the file. < If {verbose} is TRUE, prints a notice to {stderr}. */ > The {maxval} field is set as specified in the file. */ --- 63c62 ----------------------- < void pnm_image_write(char *name, pnm_image_t *img, bool_t forceplain, bool_t verbose); > void pnm_image_write(char *name, pnm_image_t *img, bool_t forceplain); --- 71,72c70 ----------------------- < variant ("P5" or "P6"). If {name} is "-", writes to {stdout}. < If {verbose} is TRUE, prints a notice to {stderr}. */ > variant ("P5" or "P6"). If {name} is "-", writes to {stdout}. */ --- 77c75 ----------------------- < but from/to a previously opened file handle. */ > from/to previously opened file handle. */ ============================================================== ../../../LIBS/libs-core/libjspnm/jsppm_medcutx.c affine_tracker/libjspnm/jsppm_medcutx.c ============================================================== ../../../LIBS/libs-core/libjspnm/jsppm_medcutx.h affine_tracker/libjspnm/jsppm_medcutx.h ============================================================== ../../../LIBS/libs-core/libjspnm/jsppm_xhist.c affine_tracker/libjspnm/jsppm_xhist.c ============================================================== ../../../LIBS/libs-core/libjspnm/jsppm_xhist.h affine_tracker/libjspnm/jsppm_xhist.h ============================================================== ../../../LIBS/libs-core/libjspnm/jsppm_xtable.c affine_tracker/libjspnm/jsppm_xtable.c ============================================================== ../../../LIBS/libs-core/libjspnm/jsppm_xtable.h affine_tracker/libjspnm/jsppm_xtable.h ============================================================== ../../../LIBS/libs-core/libjspnm/tests/test_pnm/test_pnm.c affine_tracker/libjspnm/tests/test_pnm/test_pnm.c ============================================================== ../../../LIBS/libs-core/libps/ps.c affine_tracker/libps/ps.c ============================================================== ../../../LIBS/libs-core/libps/ps.h affine_tracker/libps/ps.h ============================================================== ../../../LIBS/libs-core/libps/ps_compat.h affine_tracker/libps/ps_compat.h ============================================================== ../../../LIBS/libs-core/libps/pswr.c affine_tracker/libps/pswr.c --- 2c2 ----------------------- < /* Last edited on 2009-01-05 21:14:42 by stolfi */ > /* Last edited on 2008-07-14 20:27:02 by stolfi */ --- 30c30,31 ----------------------- < ( char *prefix, /* Output filename prefix. */ > ( bool_t eps, /* TRUE for EPS figures, FALSE for PS document. */ > char *name, /* File name or prefix. */ --- 32,33d32 ----------------------- < bool_t eps, /* TRUE for EPS figures, FALSE for PS document. */ < char *docName, /* Document name for PS output. */ --- 43,44c42 ----------------------- < /* Make a fresh private copy of the {prefix}, or of an empty string: */ < ps->prefix = txtcat((prefix == NULL ? "" : prefix), ""); > ps->name = txtcat((name == NULL ? "" : name), ""); --- 52c50 ----------------------- < { /* Make a fresh private copy of the {paperSize} string: */ > { /* Get page dimensions from the {paperSize} string: */ --- 54d51 ----------------------- < /* Get page dimensions from the {paperSize} string: */ --- 74,75c71 ----------------------- < { char *fileName = NULL; < asprintf(&(ps->prefix), "%s%s.ps", ps->prefix, docName); > { char *fileName = txtcat(ps->name, ".ps"); --- 100c96 ----------------------- < free(ps->prefix); > free(ps->name); ============================================================== ../../../LIBS/libs-core/libps/pswr.h affine_tracker/libps/pswr.h --- 2c2 ----------------------- < /* Last edited on 2009-01-05 21:29:44 by stolfi */ > /* Last edited on 2008-05-25 03:46:39 by stolfi */ --- 99,102c99,101 ----------------------- < ( char *prefix, /* Output filename prefix. [Changed on 2009-01-05] */ < FILE *file, /* Optional open file handle. [Changed on 2009-01-05] */ < bool_t eps, /* TRUE for EPS figures, FALSE for PS document. [Changed on 2009-01-05] */ < char *docName, /* Document name for PS output. [Changed on 2009-01-05] */ > ( bool_t eps, /* TRUE for EPS figures, FALSE for PS document. */ > char *name, /* Document name or figure name prefix. */ > FILE *file, /* Optional open file handle. */ --- 110c109 ----------------------- < {file}, or, if {file} is NULL, to new file called "{prefix}{docName}.ps". > {file}, or, if {file} is NULL, to new file called "{name}.ps". --- 119,121c118,119 ----------------------- < sequence of files called "{prefix}{page}.eps", where {page} is a < six-digit sequential figure number or a client-given page name < (see {pswr_new_canves}). However, if the {file} argument is not > sequence of files called "{name}{NNNNNN}.eps", where {NNNNNN} is > a six-digit figure number. However, if the {file} argument is not --- 131,138c129 ----------------------- < and there is no extra space for caption. < < NOTE: The meaning of {prefix} was slightly changed on 2009-01-05. < For ".ps" output, the name now is "{prefix}{docName}.ps" instead < of just "{prefix}.ps". For ".eps" output, the figure names are now < "{prefix}{page}.eps" instead of {prefix}-{page}.eps". The order of < the first parameters was changed to make the old uses stand < out. */ > and there is no extra space for caption. */ --- 291,293c282,285 ----------------------- < "{prefix}{pageName}.eps", where {prefix} is the argument given to < {pswr_new_stream}. If {pageName} is NULL or empty, it defaults to < a six-digit sequential canvas number (starting from "000000"). */ > "{streamName}{pageName}.eps", where {streamName} is the {name} > argument given to {pswr_new_stream}. If {pageName} is NULL or > empty, it defaults to a six-digit sequential canvas number > (starting from "000000"). */ --- 454,456c446,447 ----------------------- < /* Fills and/or draws a square with center {xc,yc} and half-side < (in-radius) {rad}. The half-side is in millimeters, irrespective < of the current scale. */ > /* Fills and/or draws a square with center {xc,yc} and half-side {rad}. > The half-side is in millimeters, irrespective of the current scale. */ ============================================================== ../../../LIBS/libs-core/libps/pswr_aux.c affine_tracker/libps/pswr_aux.c --- 2c2 ----------------------- < /* Last edited on 2009-01-05 21:19:03 by stolfi */ > /* Last edited on 2008-05-25 03:26:13 by stolfi */ --- 47,48c47,49 ----------------------- < char *fileName = NULL; < asprintf(&fileName, "%s%s.eps", ps->prefix, pageName); > int nameSz = strlen(ps->name) + strlen(pageName) + 6; > char fileName[nameSz]; > snprintf(fileName, nameSz, "%s%s.eps", ps->name, pageName); --- 50d50 ----------------------- < free(fileName); ============================================================== ../../../LIBS/libs-core/libps/pswr_aux.h affine_tracker/libps/pswr_aux.h ============================================================== ../../../LIBS/libs-core/libps/pswr_color.c affine_tracker/libps/pswr_color.c ============================================================== ../../../LIBS/libs-core/libps/pswr_color.h affine_tracker/libps/pswr_color.h ============================================================== ../../../LIBS/libs-core/libps/pswr_def.h affine_tracker/libps/pswr_def.h --- 2c2 ----------------------- < /* Last edited on 2009-01-05 21:21:49 by stolfi */ > /* Last edited on 2007-12-27 01:09:47 by stolfi */ --- 13c13 ----------------------- < char *prefix; /* File name prefix. */ > char *name; /* File name prefix (no extension). */ --- 15c15 ----------------------- < char *paperSize; /* Paper size ("letter", "a3", etc.) or NULL. */ > char *paperSize; /* Paper size ({letter}, {a3}, etc.) or NULL. */ ============================================================== ../../../LIBS/libs-core/libps/pswr_iso.c affine_tracker/libps/pswr_iso.c ============================================================== ../../../LIBS/libs-core/libps/pswr_iso.h affine_tracker/libps/pswr_iso.h ============================================================== ../../../LIBS/libs-core/libps/pswr_vis.c affine_tracker/libps/pswr_vis.c --- 14,17c14,17 ----------------------- < double xMin = ps->hMin - 3.0; \ < double xMax = ps->hMax + 3.0; \ < double yMin = ps->vMin - 3.0; \ < double yMax = ps->vMax + 3.0 > double xBoxMin = ps->hMin - 3.0; \ > double xBoxMax = ps->hMax + 3.0; \ > double yBoxMin = ps->vMin - 3.0; \ > double yBoxMax = ps->vMax + 3.0 --- 20,23c20,23 ----------------------- < double xlo = +INFINITY; \ < double xhi = -INFINITY; \ < double ylo = +INFINITY; \ < double yhi = -INFINITY > double xBoxLo = +INFINITY; \ > double xBoxHi = -INFINITY; \ > double yBoxLo = +INFINITY; \ > double yBoxHi = -INFINITY --- 25,26c25,26 ----------------------- < #define XBOX(x) { if ((x) < xlo) { xlo = (x); } if ((x) > xhi) { xhi = (x); } } < #define YBOX(y) { if ((y) < ylo) { ylo = (y); } if ((y) > yhi) { yhi = (y); } } > #define XBOX(x) { if ((x) < xBoxLo) { xBoxLo = (x); } if ((x) > xBoxHi) { xBoxHi = (x); } } > #define YBOX(y) { if ((y) < yBoxLo) { yBoxLo = (y); } if ((y) > yBoxHi) { yBoxHi = (y); } } --- 29c29 ----------------------- < return ((xlo > xMax) || (xhi < xMin) || (ylo > yMax) || (yhi < yMin)) > return ((xBoxLo > xBoxMax) || (xBoxHi < xBoxMin) || (yBoxLo > yBoxMax) || (yBoxHi < yBoxMin)) --- 64a65,67 ----------------------- > INITBBOX; > XBOX(xlo); YBOX(ylo); > XBOX(xhi); YBOX(yhi); --- 103a107,116 ----------------------- > bool_t pswr_square_is_invisible > ( PSStream *ps, > double xlo, double xhi, double ylo, double yhi > ) > { DEFWINDOW; > INITBBOX; > XBOX(xlo); YBOX(ylo); > XBOX(xhi); YBOX(yhi); > CHECKBOX; > } ============================================================== ../../../LIBS/libs-core/libps/pswr_vis.h affine_tracker/libps/pswr_vis.h --- 55a56,60 ----------------------- > bool_t pswr_square_is_invisible > ( PSStream *ps, > double xlo, double xhi, double ylo, double yhi > ); > ============================================================== ../../../LIBS/libs-core/libps/tests/testiso/testiso.c affine_tracker/libps/tests/testiso/testiso.c ============================================================== ../../../LIBS/libs-core/libps/tests/testplot/testplot.c affine_tracker/libps/tests/testplot/testplot.c ============================================================== ../../../LIBS/libs-core/libps/tests/teststream/teststream.c affine_tracker/libps/tests/teststream/teststream.c ============================================================== ../../../IMG/pnmxarith/pnmxarith.c affine_tracker/programs/pnmxarith/pnmxarith.c ============================================================== ../../../IMG/pnmgtran/pnmgtran.c affine_tracker/programs/pnmgtran/pnmgtran.c --- 7c7 ----------------------- < ** Last edited on 2008-12-11 17:21:28 by stolfi > ** Last edited on 2007-09-06 18:35:59 by stolfi --- 11c11 ----------------------- < " " PROG_NAME " \\\n" \ > PROG_NAME " \\\n" \ --- 13,15c13,15 ----------------------- < " " imgc_parse_x_axis_HELP " \\\n" \ < " " imgc_parse_y_axis_HELP " \\\n" \ < " " imgc_parse_input_center_org_HELP " \\\n" \ > " " imgc_parse_haxis_HELP " \\\n" \ > " " imgc_parse_vaxis_HELP " \\\n" \ > " " imgc_parse_icenter_iorg_HELP " \\\n" \ --- 29,31c29,32 ----------------------- < " " imgc_parse_output_size_HELP " \\\n" \ < " " imgc_parse_output_center_org_HELP " \\\n" \ < " [ -maxval {MV_OUT} ] \\\n" \ > " ] \\\n" \ > " " imgc_parse_osize_HELP " \\\n" \ > " " imgc_parse_ocenter_oorg_HELP " \\\n" \ > " [ -omaxval {MV_OUT} ] \\\n" \ --- 81c82 ----------------------- < imgc_parse_x_axis_HELP_INFO "" \ > imgc_parse_haxis_HELP_INFO "" \ --- 86c87 ----------------------- < " " imgc_parse_x_axis_pbm_default_INFO "\n" \ > " " imgc_parse_haxis_pbm_default_INFO "\n" \ --- 88c89 ----------------------- < imgc_parse_y_axis_HELP_INFO "" \ > imgc_parse_vaxis_HELP_INFO "" \ --- 93c94 ----------------------- < " " imgc_parse_y_axis_pbm_default_INFO "\n" \ > " " imgc_parse_vaxis_pbm_default_INFO "\n" \ --- 95c96 ----------------------- < imgc_parse_input_center_org_HELP_INFO "\n" \ > imgc_parse_icenter_iorg_HELP_INFO "\n" \ --- 97c98 ----------------------- < imgc_parse_output_center_org_HELP_INFO "\n" \ > imgc_parse_ocenter_oorg_HELP_INFO "\n" \ --- 127c128 ----------------------- < imgc_parse_output_size_HELP_INFO " If omitted, the output image" \ > imgc_parse_osize_HELP_INFO " If omitted, the output image" \ --- 130c131 ----------------------- < " -maxval {MV_OUT}\n" \ > " -omaxval {MV_OUT}\n" \ --- 172c173 ----------------------- < " jul/2007 Added \"-xAxis\", \"-yAxis\" options. J. Stolfi, IC-UNICAMP.\n" \ > " jul/2007 Added \"-haxis\", \"-vaxis\" options. J. Stolfi, IC-UNICAMP.\n" \ --- 228,229c230,231 ----------------------- < bool_t yDown; /* TRUE if the vertical axis points down, FALSE otherwise. */ < bool_t xLeft; /* TRUE if the horizontal axis points left, FALSE otherwise. */ > bool_t vdown; /* TRUE if the vertical axis points down, FALSE otherwise. */ > bool_t hleft; /* TRUE if the horizontal axis points left, FALSE otherwise. */ --- 231,234c233,236 ----------------------- < bool_t iCenter; /* If TRUE, input origin is center; if FALSE, use {iOrg}. */ < r2_t iOrg; /* Input origin relative to default origin, if {!iCenter}. */ < bool_t oCenter; /* If TRUE, output origin is center; if FALSE, use {oOrg}. */ < r2_t oOrg; /* Output origin relative to default origin, if {!oCenter}. */ > bool_t icenter; /* If TRUE, input origin is center; if FALSE, use {iorg}. */ > r2_t iorg; /* Input origin relative to default origin, if {!icenter}. */ > bool_t ocenter; /* If TRUE, output origin is center; if FALSE, use {oorg}. */ > r2_t oorg; /* Output origin relative to default origin, if {!ocenter}. */ --- 236,237c238,239 ----------------------- < int oCols; /* X size of output image, or -1 if not given. */ < int oRows; /* Y size of output image, or -1 if not given. */ > int ocols; /* X size of output image, or -1 if not given. */ > int orows; /* Y size of output image, or -1 if not given. */ --- 311c313 ----------------------- < int chns, iCols, iRows; > int chns, icols, irows; --- 314c316 ----------------------- < float_image_t *im_in = read_image(rd, &iCols, &iRows, &chns, &maxval_in, o->verbose); > float_image_t *im_in = read_image(rd, &icols, &irows, &chns, &maxval_in, o->verbose); --- 317,318c319,324 ----------------------- < int oCols = (o->oCols < 0 ? iCols : o->oCols); < int oRows = (o->oRows < 0 ? iRows : o->oRows); > int ocols = (o->ocols < 0 ? icols : o->ocols); > int orows = (o->orows < 0 ? irows : o->orows); > > /* Make {o->iorg,o->oorg} consistent with {o->icenter,o->ocenter}: */ > if (o->icenter) { o->iorg = (r2_t){{ 0.5*icols, 0.5*irows }}; } > if (o->ocenter) { o->oorg = (r2_t){{ 0.5*ocols, 0.5*orows }}; } --- 321,324c327,330 ----------------------- < hr2_pmap_t isys = imgc_coord_sys_map(o->xLeft, o->yDown, o->iCenter, &(o->iOrg), iCols, iRows); < if (o->verbose) { print_pmap(stderr, "input coord system", &(o->T.pmap)); } < hr2_pmap_t osys = imgc_coord_sys_map(o->xLeft, o->yDown, o->oCenter, &(o->oOrg), oCols, oRows); < if (o->verbose) { print_pmap(stderr, "output coord system", &(o->T.pmap)); } > hr2_pmap_t isys = imgc_coord_sys_map(o->hleft, o->vdown, o->icenter, &(o->iorg), icols, irows); > if (o->verbose) { print_pmap(stderr, "input coord system", &isys); } > hr2_pmap_t osys = imgc_coord_sys_map(o->hleft, o->vdown, o->ocenter, &(o->oorg), ocols, orows); > if (o->verbose) { print_pmap(stderr, "output coord system", &osys); } --- 332c338 ----------------------- < float_image_t *im_ot = float_image_new(chns, oCols, oRows); > float_image_t *im_ot = float_image_new(chns, ocols, orows); --- 342c348 ----------------------- < pnm_sample_t maxval_ot = (o->maxval > 0 ? o->maxval :(maxval_in < 255 ? 255 : maxval_in)); > pnm_sample_t maxval_ot = (maxval_in < 255 ? 255 : maxval_in); --- 376c382,385 ----------------------- < { fitr_apply_radial_map(&p, -(o->T.R), J, invalid); > { r2_t dp; > r2_sub(&p, &(o->iorg), &dp); > fitr_apply_radial_map(&dp, -(o->T.R), J, invalid); > r2_add(&dp, &(o->iorg), &p); --- 444,445c453,454 ----------------------- < o->xLeft = FALSE; < imgc_parse_x_axis(pp, &(o->xLeft)); > o->hleft = FALSE; > imgc_parse_haxis(pp, &(o->hleft)); --- 447,448c456,457 ----------------------- < o->yDown = TRUE; < imgc_parse_y_axis(pp, &(o->yDown)); > o->vdown = TRUE; > imgc_parse_vaxis(pp, &(o->vdown)); --- 450,453c459,462 ----------------------- < o->iCenter = FALSE; < o->iOrg.c[0] = 0.0; < o->iOrg.c[1] = 0.0; < imgc_parse_input_center_org(pp, &(o->iCenter), &(o->iOrg)); > o->icenter = FALSE; > o->iorg.c[0] = 0.0; > o->iorg.c[1] = 0.0; > imgc_parse_icenter_iorg(pp, &(o->icenter), &(o->iorg)); --- 495,502c504,511 ----------------------- < o->oCols = -1; < o->oRows = -1; < imgc_parse_output_size(pp, &(o->oCols), &(o->oRows), MAX_SIZE); < < o->oCenter = FALSE; < o->oOrg.c[0] = 0.0; < o->oOrg.c[1] = 0.0; < imgc_parse_output_center_org(pp, &(o->oCenter), &(o->oOrg)); > o->ocols = -1; > o->orows = -1; > imgc_parse_osize(pp, &(o->ocols), &(o->orows), MAX_SIZE); > > o->ocenter = FALSE; > o->oorg.c[0] = 0.0; > o->oorg.c[1] = 0.0; > imgc_parse_ocenter_oorg(pp, &(o->ocenter), &(o->oorg)); ============================================================== ../../../IMG/pnmfftfilter/pnmfftfilter.c affine_tracker/programs/pnmfftfilter/pnmfftfilter.c ============================================================== ../../../IMG/pnmtopsx/pnmtopsx.c affine_tracker/programs/pnmtopsx/pnmtopsx.c ==============================================================