~coco/imscript

8f3c78ba8cd5b278b74dbfde77a7a2dc33d36962 — Enric Meinhardt-Llopis 2 months ago ce163cf
remove gcc-12 -Wall -Wextra warnings
M src/ftr/cpu.c => src/ftr/cpu.c +1 -0
@@ 136,6 136,7 @@ static void pixel(float *out, struct pan_state *e, double p, double q)
static void pixel_rgbf(float out[3], struct pan_state *e, double p, double q)
{
	float v[e->i->pd];
	v[e->i->pd-1] = 0; // remove an idiotic gcc warning
	pixel(v, e, p, q);
	get_rgb_from_vec(out, e, v);
}

M src/ftr/epiview.c => src/ftr/epiview.c +1 -1
@@ 149,7 149,7 @@ static bool cut_line_with_segment(double out[2], double line[3],
}

static bool cut_line_with_rectangle(double out_a[2], double out_b[2],
		double line[3], double rec_from[2], double rec_to[4])
		double line[3], double rec_from[2], double rec_to[2])
{
	// four vertices of the rectangle
	double v[4][2] = {

M src/ftr/fancy_rpcflip.c => src/ftr/fancy_rpcflip.c +2 -1
@@ 426,7 426,8 @@ static int obtain_octave(struct pan_state *e)
//}

// affine approximation of the projection function {{{1
static void window_to_image_exh(double*,struct pan_state*,double,double,double);
static void window_to_image_exh(double[2],struct pan_state*,
		double,double,double);

static void raster_to_image_exh(double out[2], struct pan_state *e,
		double x, double y, double h);

M src/ftr/rpcflip.c => src/ftr/rpcflip.c +2 -1
@@ 393,7 393,8 @@ static int obtain_octave(struct pan_state *e)


// affine approximation of the projection function {{{1
static void window_to_image_exh(double*,struct pan_state*,double,double,double);
static void window_to_image_exh(double[2],struct pan_state*,
		double,double,double);

static void raster_to_image_exh(double out[2], struct pan_state *e,
		double x, double y, double h);

M src/geomedian.c => src/geomedian.c +46 -9
@@ 282,8 282,8 @@ static double fdiste(double *x, double *y, int n, double e)
	return n ? hypot(*x - *y, fdiste(x + 1, y + 1, n - 1, e)) : e;
}

#include "smapa.h"
SMART_PARAMETER_SILENT(WEISZ_NITER,10)
//#include "smapa.h"
//SMART_PARAMETER_SILENT(WEISZ_NITER,10)

// y[k] = euclidean median of the vectors x[i][k]
static void double_weisz(double *y, double *x, int d, int n, int N, double ε)


@@ 506,12 506,12 @@ static void hessian_diag(double *h, int d, int n, double a[n][d], double *x)

#include "iio.h"

#include "smapa.h"
SMART_PARAMETER_SILENT(XMIN,-2)
SMART_PARAMETER_SILENT(XMAX,12)
SMART_PARAMETER_SILENT(YMIN,-2)
SMART_PARAMETER_SILENT(YMAX,12)
SMART_PARAMETER_SILENT(NUMIT,20)
//#include "smapa.h"
//SMART_PARAMETER_SILENT(XMIN,-2)
//SMART_PARAMETER_SILENT(XMAX,12)
//SMART_PARAMETER_SILENT(YMIN,-2)
//SMART_PARAMETER_SILENT(YMAX,12)
//SMART_PARAMETER_SILENT(NUMIT,20)

// fancier weiszfeld variands based on gradient descent
// (by default, plain weiszfeld)


@@ 787,6 787,7 @@ struct descent_options {
static void print_descent_options(FILE *f, struct descent_options *o)
{
	char const*const s_i[] = {
		[ZERO] = "ZERO",
		[GIVEN] = "GIVEN",
		[AVERAGE] = "AVERAGE",
		[GORNER_KANZOW] = "GORNER_KANZOW",


@@ 1165,6 1166,8 @@ int main_descent(int c, char *v[])
	fprintf(stderr, "energy at first point = %g\n", E);
	fprintf(stderr, "numit = %d\n", numit);

	if (d == 2)
		fprintf(stderr, "P\t%lf\t%lf\t%lf\n", x[0], x[1], E);

	//if (n < 10)
	//	for (int i = 0; i < n; i++)


@@ 1182,7 1185,8 @@ int main_descent(int c, char *v[])
			x[k] = x[k]  -  λ * p[k];

		E = objective_function(d, n, a, x);
		fprintf(stderr, "%lf\t%lf\t%lf\n", x[0], x[1], E);
		if (d == 2)
			fprintf(stderr, "P\t%lf\t%lf\t%lf\n", x[0], x[1], E);

		//if (*out_log && d > 1)
		//{


@@ 1212,6 1216,39 @@ int main_descent(int c, char *v[])
	return 0;
}

int main_descent_raw(int c, char *v[])
{
	struct descent_options o[1];
	grab_options(o, &c, &v);
	int numit = atoi(pick_option(&c, &v, "n", "100"));
	if (c != 1) return fprintf(stderr, "usage:\n\t%s [params] <in\n", *v);

	// read input point cloud
	int d; // dimension of the space
	int n; // total number of input points
	void *aa = iio_read_image_double("-", &d, &n);
	double (*a)[d] = aa; // point cloud

	double x[d]; // current position
	find_initial_point(d, n, a, x, o);

	double E = objective_function(d, n, a, x);

	for (int i = 0; i < numit; i++)
	{
		double p[d];
		find_descent_direction(d, n, p, a, x, o);

		double λ = find_descent_step(d, n, p, a, x, o);

		for (int k = 0; k < d; k++)
			x[k] = x[k]  -  λ * p[k];

	//	E = objective_function(d, n, a, x);
	}
	return 0;
}

#ifndef HIDE_ALL_MAINS
//int main(int c, char **v) { return main_clmps(c, v); }
//int main(int c, char **v) { return main_weisz(c, v); }

M src/iio.c => src/iio.c +3 -1
@@ 421,7 421,9 @@ static void xfclose(FILE *f)
	global_variable_containing_the_name_of_the_last_opened_file = NULL;
	if (f != stdout && f != stdin && f != stderr) {
		int r = fclose(f);
		IIO_DEBUG("fclose (%p) = %d\n", (void*)f, r);
		// cripple the following line to remove a wrong gcc Warning
		//IIO_DEBUG("fclose (%p) = %d\n", (void*)f, r);
		IIO_DEBUG("fclose (%p) = %d\n", (void*)0, r);
		if (r) fail("fclose error");// \"%s\"", strerror(errno));
	}
}

M src/misc/closeup.c => src/misc/closeup.c +1 -1
@@ 29,7 29,7 @@ static void error(const char *fmt, ...)
#ifdef NDEBUG
	exit(-1);
#else
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
#endif//NDEBUG
}


M src/misc/error.c => src/misc/error.c +1 -1
@@ 49,7 49,7 @@ static void error(const char *fmt, ...)
	exit(-1);
#else//NDEBUG
	//print_trace(stderr);
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
#endif//NDEBUG
}


M src/misc/flowback.c => src/misc/flowback.c +1 -1
@@ 28,7 28,7 @@ static void fail(const char *fmt, ...)
	exit(-1);
#else//NDEBUG
	//print_trace(stderr);
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
#endif//NDEBUG
}


M src/misc/fragments.c => src/misc/fragments.c +1 -1
@@ 49,7 49,7 @@ static void error(const char *fmt, ...)
	exit(-1);
#else//NDEBUG
	//print_trace(stderr);
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
#endif//NDEBUG
}


M src/misc/gblur_core.c => src/misc/gblur_core.c +1 -1
@@ 30,7 30,7 @@ static void error(const char *fmt, ...)
#ifdef NDEBUG
	exit(-1);
#else
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
#endif
}


M src/misc/hs_new.c => src/misc/hs_new.c +1 -1
@@ 20,7 20,7 @@ static void abort_with_message(const char *fmt, ...)
#ifdef NDEBUG
	exit(-1);
#else//NDEBUG
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
#endif//NDEBUG
}


M src/misc/ihough2.c => src/misc/ihough2.c +1 -1
@@ 122,7 122,7 @@ static bool cut_line_with_segment(double out[2], double line[3],
}

static bool cut_line_with_rectangle(double out_a[2], double out_b[2],
		double line[3], double rec_from[2], double rec_to[4])
		double line[3], double rec_from[2], double rec_to[2])
{
	// four vertices of the rectangle
	double v[4][2] = {

M src/misc/imdim.c => src/misc/imdim.c +1 -1
@@ 46,7 46,7 @@ static void error(const char *fmt, ...)
	exit(-1);
#else//NDEBUG
	//print_trace(stderr);
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
#endif//NDEBUG
}


M src/misc/rgbcube.c => src/misc/rgbcube.c +1 -1
@@ 122,7 122,7 @@ void error(const char *fmt, ...)
	exit(-1);
#else
	//print_trace(stderr);
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
#endif
}


M src/misc/satproj.c => src/misc/satproj.c +2 -2
@@ 160,8 160,8 @@ double objective_height_side(double h, void *ee)
static void raytrace(double out[3],
		double L[8], float *heights, int w, int h, double ij[2])
{
	double base[3] = {ij[0], ij[1], 0};
	apply_projection(base, L, ij);
	double base[3], ij0[3] = {ij[0], ij[1], 0};
	apply_projection(base, L, ij0);
	double bh = bicubic_interpolation(heights, w, h, base[0], base[1]);

	struct bisection_state e[1];

M src/misc/setdim.c => src/misc/setdim.c +1 -1
@@ 45,7 45,7 @@ static void error(const char *fmt, ...)
	exit(-1);
#else//NDEBUG
	//print_trace(stderr);
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
#endif//NDEBUG
}


M src/misc/tdip.c => src/misc/tdip.c +1 -1
@@ 58,7 58,7 @@ static bool cut_line_with_segment(double out[2], double line[3],
}

static bool cut_line_with_rectangle(double out_a[2], double out_b[2],
		double line[3], double rec_from[2], double rec_to[4])
		double line[3], double rec_from[2], double rec_to[2])
{
	// four vertices of the rectangle
	double v[4][2] = {

M src/misc/tiff_octaves.c => src/misc/tiff_octaves.c +1 -1
@@ 58,7 58,7 @@ static void fail(const char *fmt, ...)
#  ifdef NDEBUG
	exit(-1);
#  else//NDEBUG
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
#  endif//NDEBUG
}
#endif//_FAIL_C

M src/misc/xmalloc_stats.c => src/misc/xmalloc_stats.c +1 -1
@@ 34,7 34,7 @@ void bad_fail(const char *fmt, ...)
	fprintf(stderr, "\n\n");
	fflush(NULL);
	print_trace(stderr);
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
}



M src/moistiv_epipolar.c => src/moistiv_epipolar.c +3 -0
@@ 449,6 449,9 @@ int moistiv_epipolar(float *m1, float *m2, int *k, float *z,
  float **c  = matrix(1,9,1,9);
  float *w  = vector(1,9);
  float **v  = matrix(1,9,1,9);
  //float c[9][9];
  //float w[9];
  //float v[9][9];
  float a[4];

  /* build 9xn matrix from point matches */

M src/siftie.c => src/siftie.c +2 -2
@@ 1330,7 1330,7 @@ struct ann_trip *siftlike_get_tripletsrad(
	struct ann_trip *p = xmalloc(na * sizeof * p);
	int np = 0;
	FORI(na) {
		float db, dc;
		float db = INFINITY, dc = INFINITY;
		int jb = fancynearestt_rad(ka + i, kb, nb, &db, t, rx, ry);
		int jc = fancynearestt_rad(ka + i, kc, nc, &dc, t, rx, ry);
		if (jb >= 0 && jc >= 0) {


@@ 1568,7 1568,7 @@ static void homographic_mapf(float y[2], float H[9], float x[2])
}

static
void siftaff(struct sift_keypoint *t, int n, float A[9])
void siftaff(struct sift_keypoint *t, int n, float A[6])
{
	float det = A[0]*A[4] - A[1]*A[3];
	//fprintf(stderr, "det = %g\n", det);

M src/tiff_octaves_rw.c => src/tiff_octaves_rw.c +1 -1
@@ 59,7 59,7 @@ static void fail(const char *fmt, ...)
#  ifdef NDEBUG
	exit(-1);
#  else//NDEBUG
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
#  endif//NDEBUG
}
#endif//_FAIL_C

M src/tiffu.c => src/tiffu.c +2 -1
@@ 84,7 84,7 @@ static void fail(const char *fmt, ...)
#  ifdef NDEBUG
	exit(-1);
#  else//NDEBUG
	exit(*(int *)0x43);
	exit(*(volatile int *)0);
#  endif//NDEBUG
}
#endif//_FAIL_C


@@ 244,6 244,7 @@ static void get_tiff_info_filename(struct tiff_info *t, char *fname)
	TIFF *tif = tiffopen_fancy(fname, "r");
	if (!tif)
		fail("could not open TIFF file \"%s\" for reading", fname);
	t->ntiles = 0;
	get_tiff_info(t, tif);
	TIFFClose(tif);
}