../../LIBS/libs-core/libgeo/argparser_geo.c 2008-12-22-rfvs-liv/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 2008-12-22-rfvs-liv/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 2008-12-22-rfvs-liv/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/qmin_simplex.c 2008-12-22-rfvs-liv/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/r2.c 2008-12-22-rfvs-liv/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 */ ============================================================== ../../LIBS/libs-core/libgeo/r2.h 2008-12-22-rfvs-liv/libgeo/r2.h ============================================================== ../../LIBS/libs-core/libgeo/rn.c 2008-12-22-rfvs-liv/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 2008-12-22-rfvs-liv/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/libimg/colorfield_wavy.c 2008-12-22-rfvs-liv/libimg/colorfield_wavy.c --- 2c2 ----------------------- < ** Last edited on 2008-07-19 20:42:59 by stolfi > ** Last edited on 2008-05-25 03:23:15 by stolfi --- 24c24 ----------------------- < #define TwoPi (2.0 * M_PI) > #define TwoPi (2.0 * 3.141592653589793) --- 102c102 ----------------------- < frgb_print(stderr, "orgColor = ( ", &(wfa->orgColor), " )\n"); > frgb_print_flt_pixel(stderr, "orgColor = ( ", &(wfa->orgColor), 3, " )\n"); --- 143,144c143,144 ----------------------- < frgb_print(stderr, "orgColor = ( ", orgColor, " )\n"); < frgb_print(stderr, "botColor = ( ", botColor, " )\n"); > frgb_print_flt_pixel(stderr, "orgColor = ( ", orgColor, 3, " )\n"); > frgb_print_flt_pixel(stderr, "botColor = ( ", botColor, 3, " )\n"); --- 174c174 ----------------------- < frgb_print(stderr, "( ", &tbi, " )\n"); > frgb_print_flt_pixel(stderr, "( ", &tbi, 3, " )\n"); ============================================================== ../../LIBS/libs-core/libimg/compute-ITU-R-BT709-params 2008-12-22-rfvs-liv/libimg/compute-ITU-R-BT709-params ============================================================== ../../LIBS/libs-core/libimg/float_image.c 2008-12-22-rfvs-liv/libimg/float_image.c --- 2c2 ----------------------- < /* Last edited on 2009-01-04 09:37:05 by stolfi */ > /* Last edited on 2008-05-25 03:34:05 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); < } < } < } < --- 326,342d307 ----------------------- < void float_image_log_scale(float_image_t *A, int c, double vref, double base) < { demand((isfinite(vref)) && (vref > 0), "invalid vref"); < demand((isfinite(base)) && (base != 1) && (base > 0), "invalid base"); < double logBase = (base == M_E ? 1.0 : log(base)); < int NC = A->sz[0]; < int NX = A->sz[1]; < int NY = A->sz[2]; < demand((c >= 0) && (c < NC), "invalid channel index"); < int x, y; < for (y = 0; y < NY; y++) < { for (x = 0; x < NX; x++) < { float *pA = float_image_get_sample_address(A, c, x, y); < (*pA) = sample_conv_log((*pA), vref, logBase); < } < } < } < --- 349d313 ----------------------- < demand(! isnan(scale), "scale factor is NaN"); --- 359,395d322 ----------------------- < void float_image_square_samples(float_image_t *A, int c) < { int NC = A->sz[0]; < int NX = A->sz[1]; < int NY = A->sz[2]; < demand((c >= 0) && (c < NC), "invalid channel index"); < int x, y; < for (y = 0; y < NY; y++) < { for (x = 0; x < NX; x++) < { float *smp = float_image_get_sample_address(A, c, x, y); < float v = *smp; < if (!isnan(v)) { (*smp) = v*v; } < } < } < } < < double float_image_compute_total_energy(float_image_t *A, int c, double avg) < { int NC = A->sz[0]; < int NX = A->sz[1]; < int NY = A->sz[2]; < if ((c < 0) || (c >= NC)) < { /* Invalid channel, all samples are zero (or there are no samples). */ < return 0.0; < } < < /* Compute the sum of squares {sum2}: */ < double sum2 = 0; < int x, y; < for (y = 0; y < NY; y++) < { for (x = 0; x < NX; x++) < { double v = float_image_get_sample(A, c, x, y); < if (isfinite(v)) < { /* Neither {ħINF} nor {NAN}: */ v -= avg; sum2 += v*v; } < } < } < return sum2; < } < --- 414,415c341,342 ----------------------- < if (isfinite(v)) < { /* Neither {ħINF} nor {NAN}: */ sum += v; tot++; } > if ((!isnan(v)) && (fabs(v) != INF)) > { sum += v; tot++; } --- 424,425c351,352 ----------------------- < if (isfinite(v)) < { /* Neither {ħINF} nor {NAN}: */ v -= sa; sum += v*v; } > if ((!isnan(v)) && (fabs(v) != INF)) > { v -= sa; sum += v*v; } --- 452,454c379,380 ----------------------- < if (isfinite(v)) < { /* Neither {ħINF} nor {NAN}: */ < if (v < (*vMin)) { (*vMin) = v; } > if (isnormal(v)) > { if (v < (*vMin)) { (*vMin) = v; } --- 462,539d387 ----------------------- < void float_image_flip_x(float_image_t *A, int c, int ix) < { int NC = A->sz[0]; < int NX = A->sz[1]; < int NY = A->sz[2]; < demand((c >= 0) && (c < NC), "invalid channel index"); < < /* Reduce the index {ix} to the range {0..NX-1}: */ < ix = (ix % NX); if (ix < 0) { ix += NX; } < < /* Compute the first and last indices for the X loop: */ < int fst_x = ix / 2 + 1; < int lst_x = (ix + NX - 1) / 2; < int x1, y; < for (y = 0; y < NY; y++) < { for (x1 = fst_x; x1 <= lst_x; x1++) < { /* Compute the partner: */ < int x2 = ix - x1; if (x2 < 0) { x2 += NX; } < assert(x2 != x1); < assert(x2 < NX); < float *smp1 = float_image_get_sample_address(A, c, x1, y); < float *smp2 = float_image_get_sample_address(A, c, x2, y); < float tmp = (*smp1); (*smp1) = (*smp2); (*smp2) = tmp; < } < } < } < < void float_image_flip_y(float_image_t *A, int c, int iy) < { int NC = A->sz[0]; < int NX = A->sz[1]; < int NY = A->sz[2]; < demand((c >= 0) && (c < NC), "invalid channel index"); < < /* Reduce the index {iy} to the range {0..NY-1}: */ < iy = (iy % NY); if (iy < 0) { iy += NY; } < < /* Compute the first and last indices for the Y loop: */ < int fst_y = iy / 2 + 1; < int lst_y = (iy + NY - 1) / 2; < int y1, x; < for (x = 0; x < NX; x++) < { for (y1 = fst_y; y1 <= lst_y; y1++) < { /* Compute the partner: */ < int y2 = iy - y1; if (y2 < 0) { y2 += NY; } < assert(y2 < NY); < assert(y2 != y1); < float *smp1 = float_image_get_sample_address(A, c, x, y1); < float *smp2 = float_image_get_sample_address(A, c, x, y2); < float tmp = (*smp1); (*smp1) = (*smp2); (*smp2) = tmp; < } < } < } < < void float_image_shift(float_image_t *A, int c, int dx, int dy) < { int NC = A->sz[0]; < int NX = A->sz[1]; < int NY = A->sz[2]; < demand((c >= 0) && (c < NC), "invalid channel index"); < < /* Reduce the shifts to the ranges {0..NX-1}, {0..NY-1}: */ < dx = (dx % NX); if (dx < 0) { dx += NX; } < dy = (dy % NY); if (dy < 0) { dy += NY; } < < /* Uses the two-flip method to obtain a shift. This may be faster < than decomposition, depending on cache size. */ < < if (dx != 0) < { /* Apply two flips in X: */ < float_image_flip_x(A, c, 0); < float_image_flip_x(A, c, dx); < } < < if (dy != 0) < { /* Apply two flips in Y: */ < float_image_flip_y(A, c, 0); < float_image_flip_y(A, c, dy); < } < } < ============================================================== ../../LIBS/libs-core/libimg/float_image.h 2008-12-22-rfvs-liv/libimg/float_image.h --- 5c5 ----------------------- < /* Last edited on 2009-01-04 09:43:33 by stolfi */ > /* Last edited on 2008-05-24 23:57:20 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 */ --- 153,157d144 ----------------------- < void float_image_log_scale(float_image_t *A, int c, double vref, double base); < /* Converts every sample {v} in channel {c} of image {A} from linear < to logarithmic scale, relative to value {vref} and the given < {base}, by calling {sample_conv_log(v, vref, log(base))}. */ < --- 169,180d155 ----------------------- < void float_image_square_samples(float_image_t *A, int c); < /* Replaces every sample in channel {c} of {A} by its square. < In particular, leaves {+INF} and {NAN} alone, and maps {-INF} to {+INF}. < Fails is {c} is not a valid channel index. */ < < double float_image_compute_total_energy(float_image_t *A, int c, double avg); < /* Computes the sum of {(s - avg)^2} over all samples {s} in channel {c} of {A}. < Ignores samples that are {ħINF} or {NAN}. If {c} is not a valid < channel index, returns 0. */ < < /* PIXEL STATISTICS */ < --- 202,231d176 ----------------------- < /* IN-PLACE PIXEL REARRANGEMENT */ < < void float_image_flip_x(float_image_t *A, int c, int ix); < /* Flips the contents of channel {c} of image {A} left-to-right, and < cyclically shifts it in the X direction so that the original < contents of column 0 ends up in column {ix}. Fails if {c} is an < invalid channel index. < < The index {ix} and all column indices are implicitly reduced < modulo the image width {nx}, to the range {0..nx-1}. Thus, < if {nx == 7} and {ix == 9}, a row that originally contained the < values {0 1 2 3 4 5 6} will contain {2 1 0 6 5 4 3}. */ < < void float_image_flip_y(float_image_t *A, int c, int ix); < /* Flips the contents of channel {c} of image {A} top-to-bottom, and < cyclically shifts it in the Y direction so that the original < contents of row 0 ends up in row {iy}. The effect is analogous to < {float_image_flip_x} with swapped coordinate axes. Fails if {c} is < an invalid channel index. */ < < void float_image_shift(float_image_t *A, int c, int dx, int dy); < /* Shifts the contents of channel {c} of image {A} by {dx} columns and < {dy} rows, cyclically. < < Namely, the sample value that was originally stored in column {x} < and row {y} will be moved to column {(x+dx) mod nx} and row < {(y+dy) mod ny}, for all {x} and {y}; where {nx,ny} are the image < dimensions, and {mod} means the mathematical remainder (always < non-negative). */ < ============================================================== ../../LIBS/libs-core/libimg/float_image_color.h 2008-12-22-rfvs-liv/libimg/float_image_color.h --- 5c5 ----------------------- < /* Last edited on 2008-07-29 20:35:32 by stolfi */ > /* Last edited on 2008-03-16 13:57:16 by stolfi */ ============================================================== ../../LIBS/libs-core/libimg/float_image_masked.c 2008-12-22-rfvs-liv/libimg/float_image_masked.c --- 54a55,108 ----------------------- > > > void float_image_masked_interpolate_exclusive > ( float_image_masked_t *im, > int c, > double x, > double y, > int degInter, > float *val, > float *wht > ) > { > assert(im->msk->sz[0] == 1); > int nx = im->img->sz[1]; > int ny = im->img->sz[2]; > int ix = (int)(floor(x)); /* First column of window. */ > int iy = (int)(floor(y)); > > int m = degInter+1; /* Number of data points needed along each axis. */ > > /* The inpterpolation acts on a window of size {m} by {m} approximately centered at {x,y}: */ > int delta = degInter/2; > if((x >= nx) || (x < 0) ){ > *val = 0; > *wht = 0; > return ; > } > if((y >= ny) || (y < 0) ){ > *val = 0; > *wht = 0; > return ; > } > int i,j; > for(i = -delta; i <= delta;i++){ > for(j = -delta; j <= delta; j++){ > int jx,jy; > jx = i + ix; > jy = j + iy; > if ((jx >= 0) && (jx < nx) && (jy >= 0) && (jy < ny)) { > double value = float_image_get_sample(im->msk, 0, jx, jy); > if(value ==0){ > *val = 0; > *wht = 0; > return ; > } > } > } > } > > float_image_masked_interpolate(im,c,x,y,degInter, val,wht ); > } > > > ============================================================== ../../LIBS/libs-core/libimg/float_image_masked.h 2008-12-22-rfvs-liv/libimg/float_image_masked.h --- 29,31c29,38 ----------------------- < /* 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}. */ > > void float_image_masked_interpolate_exclusive > ( float_image_masked_t *im, > int c, > double x, > double y, > int degInter, > float *val, > float *wht > ); ============================================================== ../../LIBS/libs-core/libimg/float_pnm_image.c 2008-12-22-rfvs-liv/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 2008-12-22-rfvs-liv/libimg/float_pnm_image.h --- 5c5 ----------------------- < /* Last edited on 2009-01-04 09:26:11 by stolfi */ > /* Last edited on 2007-10-10 13:23:42 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 --- 48c48 ----------------------- < {(0,1,2,...chns-1)}. > {(0,1,2,3,...chns-1)}. --- 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_io.c 2008-12-22-rfvs-liv/libimg/float_pnm_image_io.c --- 1,3d0 ----------------------- < /* See {float_pnm_image_io.h}. */ < /* Last edited on 2009-01-04 09:56:50 by stolfi */ < --- 7a5,6 ----------------------- > #include "float_image_color.h" > #include "frgb_ops.h" --- 11c10 ----------------------- < float_image_t *float_pnm_image_read(char *fname, double gamma, double bias) > float_image_t *float_pnm_image_read(char *filename, double gamma, double bias,bool_t gray) --- 13c12 ----------------------- < pnm_image_t *pim = pnm_image_read(fname); > pnm_image_t *pim = pnm_image_read(filename); --- 15,17d13 ----------------------- < int c; < for (c = 0; c < fim->sz[0]; c++) < { float_image_apply_gamma(fim, c, gamma, bias); } --- 18a15,30 ----------------------- > int c; > for (c = 0; c < fim->sz[0]; c++) { > float_image_apply_gamma(fim, c, gamma, bias); > } > > if(gray && (fim->sz[0] == 3)){ > int x,y; > for(x = 0; x < fim->sz[1]; x++){ > for(y = 0; y < fim->sz[2]; y++){ > 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++) { float_image_set_sample(fim,c,x,y,value); } > } > } > } > --- 22c34 ----------------------- < void float_pnm_image_write(char *fname, float_image_t *fim, double gamma, double bias) > void float_pnm_image_write(char *filename, float_image_t *fim, double gamma, double bias) --- 28,29c40,42 ----------------------- < for (c = 0; c < fim->sz[0]; c++) < { float_image_apply_gamma(gim, c, 1.0/gamma, bias); } > for (c = 0; c < fim->sz[0]; c++) { > float_image_apply_gamma(gim, c, 1.0/gamma, bias); > } --- 32c45 ----------------------- < pnm_image_write(fname, pim, FALSE); > pnm_image_write(filename, pim, FALSE); --- 36c49 ----------------------- < float_image_t **float_pnm_image_list_read(char* fname[], int n, double gamma, double bias) > float_image_t **float_pnm_image_list_read(char* nome[], int n, double gamma, double bias,bool_t gray) --- 38,41c51,57 ----------------------- < float_image_t **fim = (float_image_t **)notnull(malloc(n * sizeof(float_image_t *)), "no mem"); < int i; < for(i = 0; i < n; i++) < { fim[i] = float_pnm_image_read(fname[i], gamma, bias); } > float_image_t **fim; > int luz; > fim = (float_image_t **)malloc(n * sizeof(float_image_t *)); > for(luz = 0; luz < n; luz++){ > fprintf(stderr, " light %d = %s\n",luz, nome[luz]); > fim[luz] = float_pnm_image_read(nome[luz], gamma, bias,gray); > } --- 44,50d59 ----------------------- < < void float_pnm_image_list_write(char* fname[], float_image_t *fim[], int n, double gamma, double bias) < { < int i; < for(i = 0; i < n; i++) < { float_pnm_image_write(fname[i], fim[i], gamma, bias); } < } ============================================================== ../../LIBS/libs-core/libimg/float_pnm_image_io.h 2008-12-22-rfvs-liv/libimg/float_pnm_image_io.h --- 10,11c10,11 ----------------------- < float_image_t *float_pnm_image_read(char *fname, double gamma, double bias); < /* Reads the PGM or PPM image file with the given{fname}, and converts it > float_image_t *float_pnm_image_read(char *filename, double gamma, double bias, bool_t gray); > /* Reads the PGM or PPM image file with the given{filename}, and converts it --- 13c13,14 ----------------------- < exponent {gamma} and offset {bias}. */ > exponent {gamma} and offset {bias}. If the input is PPM and {gray} is TRUE, > converts it to a grayscale 3-channel image (with {frgb_Y}). */ --- 15,16c16,17 ----------------------- < void float_pnm_image_write(char *fname, float_image_t *fim, double gamma, double bias); < /* Writes the image as a PGM or PPM image file, depending on the number of channels. > void float_pnm_image_write(char *filename, float_image_t *fim, double gamma, double bias); > /* Writes the image as a PGM or PPM image file, depending on the number of channels. --- 20,21c21,22 ----------------------- < float_image_t **float_pnm_image_list_read(char* fname[], int n, double gamma, double bias); < /* Applies {float_pnm_image_read(fname[i],gamma,bias)} for {i} in {0..n-1} and > float_image_t **float_pnm_image_list_read(char* nome[], int n, double gamma, double bias, bool_t gray); > /* Applies {float_pnm_image_read(nome[i],gamma,bias,gray)} for {i} in {0..n-1} and --- 24,26d24 ----------------------- < void float_pnm_image_list_write(char* fname[], float_image_t *fim[], int n, double gamma, double bias); < /* Applies {float_pnm_image_write(fname[i],fim[i],gamma,bias)} for {i} in {0..n-1}. */ < ============================================================== ../../LIBS/libs-core/libimg/frgb_ops.c 2008-12-22-rfvs-liv/libimg/frgb_ops.c --- 2c2 ----------------------- < ** Last edited on 2009-01-04 10:48:41 by stolfi > ** Last edited on 2008-05-25 03:34:57 by stolfi --- 22c22,33 ----------------------- < #include > > /* 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 --- 70c81 ----------------------- < frgb_t frgb_parse(argparser_t *pp, double lo, double hi) > frgb_t frgb_parse( argparser_t *pp, double lo, double hi) --- 93,122d103 ----------------------- < 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; < } < < frgb_t frgb_read_color(FILE *rd) < { frgb_t p; < double scale; < int i; < for (i = 0; i < 3; i++) < { p.c[i] = fget_double(rd); } < fget_skip_spaces(rd); < if (fget_test_char(rd, '/')) < { scale = fget_double(rd); } < else < { scale = 1.0; } < for (i = 0; i < 3; i++) < { p.c[i] /= scale; } < return p; < } < --- 199,211c180,185 ----------------------- < { frgb_t q = (frgb_t){{ lum, lum, lum }}; < return frgb_clip_rgb_towards(p, &q); < } < } < < void frgb_clip_rgb_towards_grey(frgb_t *p) < { frgb_t q = (frgb_t){{ 0.5, 0.5, 0.5 }}; < return frgb_clip_rgb_towards(p, &q); < } < < void frgb_clip_rgb_towards(frgb_t *p, frgb_t *q) < { int i; < /* Compute the min {s >= 1} such that {q + (p - q)/s} is in the cube: */ > { /* 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: */ --- 215,222c189,194 ----------------------- < double qi = q->c[i]; < double qf = 1 - qi; < demand((qi > 0) && (qf > 0), "q is not in the cube's interior"); < double di = pi - qi; < if (s*qi < -di) < { s = -di/qi; } < else if (s*qf < +di) < { s = +di/qf; } > double xi = pi - lum; > if (s*lum < -xi) > { s = -xi/lum; } > else if (s*obs < +xi) > { s = +xi/obs; } > x.c[i] = xi; --- 225,231c197,198 ----------------------- < { /* Pull {p} towards {q} until inside the unit cube: */ < for (i = 0; i < 3; i++) < { double ri = q->c[i] + (p->c[i] - q->c[i])/s; < /* Guarding against roundoff: */ < if (ri < 0) { ri = 0; } < if (ri > 1) { ri = 1; } < p->c[i] = ri; > { /* Compute output pixel {p = x/s + lum*White}: */ > for (i = 0; i < 3; i++) { p->c[i] = x.c[i]/s + lum; } --- 235a203,217 ----------------------- > void frgb_clip_rgb_towards_grey(frgb_t *p) > { int c; > double d = 0.0; /* L-inf distance from {gv} to middle gray. */ > for (c = 0; c < 3; c++) > { double pc = p->c[c]; > double dc = fabs(pc - 0.5); > if (dc > d) { d = dc; } > } > if (d > 0.5) > { /* Shrink {fv} towards middle gray until inside the unit cube: */ > for (c = 0; c < 3; c++) > { p->c[c] = 0.5 + 0.5*(p->c[c] - 0.5)/d; } > } > } > --- 278,280c260,262 ----------------------- < { double pi = p->c[i]; < pi = pi - lumI; < if (satf < 1.0) { pi = pi * satf; } > { double pc = p->c[i]; > pc = pc - lumI; > if (satf < 1.0) { pc = pc * satf; } --- 282c264 ----------------------- < { if ((pi > +obsI) || (pi < -lumI)) > { if ((pc > +obsI) || (pc < -lumI)) --- 284,293c266,275 ----------------------- < else if (satI*lumI < -pi) < { satI = -pi/lumI; } < else if (satI*obsI < +pi) < { satI = +pi/obsI; } < } < if (satO*lumO < -pi) < { satO = -pi/lumO; } < else if (satO*obsO < +pi) < { satO = +pi/obsO; } < p->c[i] = pi; > else if (satI*lumI < -pc) > { satI = -pc/lumI; } > else if (satI*obsI < +pc) > { satI = +pc/obsI; } > } > if (satO*lumO < -pc) > { satO = -pc/lumO; } > else if (satO*obsO < +pc) > { satO = +pc/obsO; } > p->c[i] = pc; --- 342,343c324,326 ----------------------- < void frgb_print(FILE *f, char *pref, frgb_t *p, char *fmt, char *suff) < { int k; > void frgb_print_flt_pixel(FILE *f, char *pref, frgb_t *p, int chns, char *suff) > { > int k; --- 345,348c328,329 ----------------------- < for (k = 0; k < 3; k++) < { if (k > 0) { fputc(' ', f); } < fprintf(f, fmt, p->c[k]); < } > for (k = 0; k < chns; k++) > { fprintf(f, "%s%7.4f", (k == 0 ? "" : " "), p->c[k]); } --- 357c338 ----------------------- < { fprintf(f, "%s%5d", (k == 0 ? "" : " "), p[k]); } > { fprintf(f, "%s%3d", (k == 0 ? "" : " "), p[k]); } --- 361c342 ----------------------- < void frgb_debug(char *label, int col, int row, frgb_t *p, char *tail) > void frgb_debug_flt_pixel(char *label, int col, int row, frgb_t *p, int chns, char *tail) --- 363c344 ----------------------- < if (frgb_DEBUG) > if (debug) --- 365c346 ----------------------- < frgb_print(stderr, "( ", p, "%10.7f", " )"); > frgb_print_flt_pixel(stderr, "( ", p, chns, " )"); --- 372c353 ----------------------- < if (frgb_DEBUG) > if (debug) --- 564,573d544 ----------------------- < double frgb_Y_pbm(frgb_t *p) < { double R = (double)p->c[0]; < double G = (double)p->c[1]; < double B = (double)p->c[2]; < < double Y = +0.299*R +0.587*G +0.114*B; < < return Y; < } < ============================================================== ../../LIBS/libs-core/libimg/frgb_ops.h 2008-12-22-rfvs-liv/libimg/frgb_ops.h --- 2c2 ----------------------- < ** Last edited on 2009-01-04 10:47:47 by stolfi > ** Last edited on 2008-05-25 03:24:15 by stolfi --- 70c70 ----------------------- < /* Clips {p} to the unit interval. */ > /* Clips {p[0]} to the unit interval. */ --- 73,81c73,74 ----------------------- < /* Clips {*p} to the unit cube, preserving its luminosity (if < possible) and its hue. If the luminosity is greater than 1, the < result is white. If the luminosity is less than 0, the result is < black. */ < < void frgb_clip_rgb_towards(frgb_t *p, frgb_t *q); < /* Clips {*p} to the unit cube, by moving it towards < the color {*q} (which must be strictly inside the unit < cube) if necessary. */ > /* Clips {p[0..2]} to the unit cube, > preserving its luminosity (if possible) and its hue. */ --- 84c77 ----------------------- < /* Clips {*p} to the unit cube, by moving it towards > /* Clips {p[0..2]} to the unit cube, by moving it towards --- 116,125c109 ----------------------- < /* 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\"" > /* PARSING COLOR VALUES */ --- 129,149c113,114 ----------------------- < as described by {frgb_parse_INFO}. Checks whether each < component lies in {[lo _ hi]}. Increments {*argn}. */ < < frgb_t frgb_read(FILE *rd, double lo, double hi); < /* Parses three consecutive numbers from file {rd}, < checks whether each component lies in {[lo _ hi]}. */ < < /* PARSING COLOR VALUES */ < < #define frgb_parse_color_HELP \ < "{R_VALUE} {G_VALUE} {B_VALUE} [ / {DENOM} ]" < < #define frgb_parse_color_INFO \ < "three numbers, optionally" \ < " followed by a slash (\"/\") and a common denominator. All these" \ < " tokens (including the slash) should be separated by spaces. E.g.\n" \ < "\n" \ < " \"1 1 1\"\n" \ < " \"1.000 0.500 0.600\"\n" \ < " \"75.0 80.2 57.1 / 100\" (same as \"0.750 0.802 0.571\")\n" \ < " \"128 196 255 / 255\"" > checks whether each component lies in {[lo _ hi]}. > Increments {*argn}. */ --- 153,160c118,120 ----------------------- < 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}. */ < < frgb_t frgb_read_color(FILE *rd); < /* Parses a color specification from file {rd}, < as described by {frgb_parse_color_INFO}. < Returns the color as three doubles in {[0 _ 1]}. */ > which is three numbers optionally followed by "/" and a > common denominator. Returns the color as three doubles {[0 _ 1]}. > Increments {*argn}. */ --- 198,202d157 ----------------------- < double frgb_Y_pbm(frgb_t *p); < /* The luminance of the RGB triple {p} by the formula < used in the PBMplus package (almost, but not exactly, < the same as {frgb_Y}). */ < --- 206,208c161,163 ----------------------- < value) system used in computer graphics (A. R. Smith, < SIGGRAPH'78). Namely the hue H is a number in the range [0_1], < defined for the primary and secondary colors as follows > value) system used in computer graphics (A. R. Smith, SIGGRAPH'78). > Namely the hue H is a number in the range [0_1], defined for the primary and > secondary colors as follows --- 280,284c235 ----------------------- < 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_flt_pixel(FILE *f, char *pref, frgb_t *p, int chns, char *suff); --- 286,288c237,238 ----------------------- < /* Prints {p[0..chns-1]} to file {f}, surrounded by the < given {pref} and {suff} strings. (This function should be moved < to some other interface.) */ > /* Prints {p.c[0..chns-1]} to file {f}, surrounded by the > given {pref} and {suff} strings. */ --- 292,297c242 ----------------------- < extern int frgb_DEBUG; /* Set this variable to activate the following procs. */ < < void frgb_debug(char *label, int col, int row, frgb_t *p, char *tail); < /* Prints {col}, {row}, and {*p} to {stderr}, if the global flag < {frgb_DEBUG} is true. The printout is preceded by the string {label} < and followed by {tail}. */ > extern int debug; /* Set this variable to activate the following procs. */ --- 298a244 ----------------------- > void frgb_debug_flt_pixel(char *label, int col, int row, frgb_t *p, int chns, char *tail); --- 300,303c246,248 ----------------------- < /* Prints {col}, {row}, and {p[0..chns-1]} to {stderr}, if the global flag < {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.) */ > /* Prints {col}, {row}, and {p.c[0..chns-1]} to {stderr}, if the global flag > {debug} is true. The printout is preceded by the string {label} > and followed by {tail}. */ ============================================================== ../../LIBS/libs-core/libimg/image_coords.c 2008-12-22-rfvs-liv/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; } --- 43c43 ----------------------- < void imgc_parse_x_axis(argparser_t *pp, bool_t *xLeft) > void imgc_parse_haxis(argparser_t *pp, bool_t *hleft) --- 45,48c45 ----------------------- < if < ( (argparser_keyword_present(pp, "-xAxis")) || < (argparser_keyword_present(pp, "-hAxis")) < ) > if (argparser_keyword_present(pp, "-haxis")) --- 50c47 ----------------------- < { (*xLeft) = TRUE; } > { (*hleft) = TRUE; } --- 52c49 ----------------------- < { (*xLeft) = FALSE; } > { (*hleft) = FALSE; } --- 58c55 ----------------------- < void imgc_parse_y_axis(argparser_t *pp, bool_t *yDown) > void imgc_parse_vaxis(argparser_t *pp, bool_t *vdown) --- 60,63c57 ----------------------- < if < ( (argparser_keyword_present(pp, "-yAxis"))|| < (argparser_keyword_present(pp, "-vAxis")) < ) > if (argparser_keyword_present(pp, "-vaxis")) --- 65c59 ----------------------- < { (*yDown) = FALSE; } > { (*vdown) = FALSE; } --- 67c61 ----------------------- < { (*yDown) = TRUE; } > { (*vdown) = TRUE; } --- 73c67 ----------------------- < 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,80c69,74 ----------------------- < 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); --- 84c78 ----------------------- < 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,91c80,85 ----------------------- < 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); --- 95c89 ----------------------- < 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,99c91,93 ----------------------- < 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 2008-12-22-rfvs-liv/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/rename.sed 2008-12-22-rfvs-liv/libimg/rename.sed ============================================================== ../../LIBS/libs-core/libimg/sample_conv.c 2008-12-22-rfvs-liv/libimg/sample_conv.c --- 2c2,4 ----------------------- < /* Last edited on 2009-01-04 11:02:40 by stolfi */ > /* Last edited on 2008-05-25 03:24:26 by stolfi */ > > #include --- 4,5d5 ----------------------- < #define _GNU_SOURCE < #include --- 9a10 ----------------------- > #include --- 14,15d14 ----------------------- < #include < --- 68,78d66 ----------------------- < float sample_conv_log(float u, double uref, double logBase) < { < if ((! isfinite(logBase)) || (logBase == 0)) { return NAN; } < if ((! isfinite(uref)) || (uref <= 0)) { return NAN; } < if (u == +INFINITY) { return +INFINITY; } < if ((! isfinite(u)) || (u < 0)) { return NAN; } < if (u <= uref) { return 0.0; } < double ulog = log(u/uref)/logBase; < return (float)ulog; < } < --- 122,123c110,111 ----------------------- < { 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,127c114,115 ----------------------- < 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,162c148,149 ----------------------- < { 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,166c152,153 ----------------------- < 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)++; } --- 168c155 ----------------------- < demand((zv >= 0) && (zv <= (int)maxval), "bad {zv}"); > demand((zv >= 0) && (zv <= (int)maxval), "bad zv"); --- 170,171c157,158 ----------------------- < 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 2008-12-22-rfvs-liv/libimg/sample_conv.h --- 5c5 ----------------------- < /* Last edited on 2008-09-23 14:37:21 by stolfi */ > /* Last edited on 2007-11-11 02:27:15 by stolfi */ --- 52,63d51 ----------------------- < float sample_conv_log(float u, double uref, double logBase); < /* Converts {u} from linear to logarithmic scale, relative to the < reference value {uref} and the base {exp(logBase)}. In particular, < {logBase == 1} gives natural logarithms, {logBase == M_LOG2} gives < result in octaves, {logBase == M_LOG10} gives result in decades, etc. < < More precisely, returns {log(u/uref)/logBase} if {u > 0}, {+INF} < if {u == +INF}, {-INF} if {u} is zero, and {NAN} if {u} is < negative or {NAN}. Requires {uref} to be finite and positive, and < {logBase} to be finite and nonzero; otherwise returns {NAN} for < any {u}. */ < ============================================================== ../../LIBS/libs-core/libimg/test-yuv-mapping 2008-12-22-rfvs-liv/libimg/test-yuv-mapping ============================================================== ../../LIBS/libs-core/libjs/affirm.h 2008-12-22-rfvs-liv/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 2008-12-22-rfvs-liv/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 --- 227c222 ----------------------- < { double nv = argparser_get_next_double(pp, -DBL_MAX, +DBL_MAX); > { double nv = argparser_get_next_double(pp, -MAXDOUBLE, +MAXDOUBLE); ============================================================== ../../LIBS/libs-core/libjs/argparser.h 2008-12-22-rfvs-liv/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 */ --- 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/fget.c 2008-12-22-rfvs-liv/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 2008-12-22-rfvs-liv/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/interval.c 2008-12-22-rfvs-liv/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 --- 15,42c15,22 ----------------------- < #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] <= HUGE_VAL) || ((x).end[1] >= HUGE_VAL)) > #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); } --- 47,63c27 ----------------------- < /* 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,70c29 ----------------------- < } < } < < double interval_mid (interval_t *X) < { double m; < interval_mid_rad(X, &m, NULL); > affirm((m >= LO(*x)) && (m <= HI(*x)), "rounding failed"); --- 73,77d31 ----------------------- < < double interval_rad (interval_t *X) < { double r; < interval_mid_rad(X, NULL, &r); < return r; --- 80,101c34,38 ----------------------- < 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,104c40 ----------------------- < { /* Finite {mid} and finite, positive {rad}. */ < /* The result is a finite interval (except for possible overflows: */ > { double m, rlo, rhi; --- 106c42,43 ----------------------- < /* 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,109c45,46 ----------------------- < double nlo = rad - mid; /* {-LO}. */ < double phi = rad + mid; /* {+HI}. */ > rlo = m - LO(*x); > rhi = HI(*x) - m; --- 111c48,49 ----------------------- < return (interval_t){{ -nlo, +phi }}; > affirm((rlo >= 0.0) && (rhi >= 0.0), "rounding failed"); > return (rlo > rhi ? rlo: rhi); --- 115c53 ----------------------- < double interval_width (interval_t *X) > double interval_width (interval_t *x) --- 117,118c55,56 ----------------------- < fesetround(FE_UPWARD); < double w = HI(*X) - LO(*X); > fesetround(FE_TONEAREST); > double w = HI(*x) - LO(*x); --- 123c61 ----------------------- < interval_t interval_split(interval_t *X, interval_side_t dir) > interval_t interval_split(interval_t *x, interval_side_t dir) --- 125c63 ----------------------- < double mid = interval_mid(X); > double mid = interval_mid(x); --- 127c65 ----------------------- < { return (interval_t){{ LO(*X), mid }}; } > { return (interval_t){{ LO(*x), mid }}; } --- 129c67 ----------------------- < { return (interval_t){{ mid, HI(*X) }}; } > { return (interval_t){{ mid, HI(*x) }}; } --- 132,138c70,76 ----------------------- < 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,142c79,80 ----------------------- < 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,153c85,91 ----------------------- < 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,157c94,95 ----------------------- < 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,190c100,116 ----------------------- < 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; } < else < { LO(*X) = -nlo; HI(*X) = +phi; } < } < < 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; > 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; ============================================================== ../../LIBS/libs-core/libjs/interval.h 2008-12-22-rfvs-liv/libjs/interval.h --- 5c5 ----------------------- < /* Last edited on 2009-01-04 13:44:48 by stolfi */ > /* Last edited on 2008-03-30 17:19:40 by stolfi */ --- 13c13,15 ----------------------- < {HI(I) = I.end[1]}. The endpoints may be {ħINF} but not {NAN}. > {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. --- 15,26c17,18 ----------------------- < 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 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)}. */ --- 29c21 ----------------------- < /* A real interval. */ > /* A real interval, open or closed. */ --- 31,32c23,24 ----------------------- < #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,112c32,62 ----------------------- < 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}. */ ============================================================== ../../LIBS/libs-core/libjs/jsfile.c 2008-12-22-rfvs-liv/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/jsmath.c 2008-12-22-rfvs-liv/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 2008-12-22-rfvs-liv/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 2008-12-22-rfvs-liv/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/nget.c 2008-12-22-rfvs-liv/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 2008-12-22-rfvs-liv/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/vec.h 2008-12-22-rfvs-liv/libjs/vec.h --- 2c2 ----------------------- < /* Last edited on 2008-07-22 22:04:49 by stolfi */ > /* Last edited on 2008-03-29 14:51:46 by stolfi */ --- 59c59 ----------------------- < This macro will also declare prototypes for the functions > This macro will also declare the procedures --- 81,92d80 ----------------------- < #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. */ < --- 101,103c89,90 ----------------------- < 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]}. */ > A variable {v} of type {VEC_TYPE} is a descriptor for a vector with > {v.ne} elements of type {ELEM_TYPE}, namely {v.e[0..v.ne-1]}. */ --- 110,112c97,99 ----------------------- < 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. */ > The call {{PREFIX}_new(ne)} allocates a new vector of > type {VEC_TYPE}, with space for {ne} elements, and returns > its descriptor. */ --- 119,126c106,112 ----------------------- < 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. */ > 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. */ --- 133,136c119,121 ----------------------- < 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}. */ > 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}. */ --- 143,149c128,133 ----------------------- < 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}. */ > The call {{PREFIX}_make_desc(ne, e)} 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}. */ --- 152a137,148 ----------------------- > #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. */ > ============================================================== ../../LIBS/libs-core/libjspnm/jsdithers.h 2008-12-22-rfvs-liv/libjspnm/jsdithers.h --- 3d2 ----------------------- < ** Last edited on 2008-08-26 12:04:15 by stolfi ============================================================== ../../LIBS/libs-core/libjspnm/jspnm_image.c 2008-12-22-rfvs-liv/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, TRUE); --- 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, TRUE); ==============================================================