[GRASS-SVN] r38715 - grass/trunk/lib/rst/interp_float
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Aug 13 23:03:10 EDT 2009
Author: glynn
Date: 2009-08-13 23:03:09 -0400 (Thu, 13 Aug 2009)
New Revision: 38715
Modified:
grass/trunk/lib/rst/interp_float/init2d.c
grass/trunk/lib/rst/interp_float/interp2d.c
grass/trunk/lib/rst/interp_float/interpf.h
grass/trunk/lib/rst/interp_float/ressegm2d.c
grass/trunk/lib/rst/interp_float/segmen2d.c
grass/trunk/lib/rst/interp_float/write2d.c
Log:
lib/rst/interp_float clean-up:
Use off_t for offsets
Fully type function pointers
Fix type of check_points field in struct interp_params to match
IL_check_at_points_2d()
Modified: grass/trunk/lib/rst/interp_float/init2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/init2d.c 2009-08-13 16:31:30 UTC (rev 38714)
+++ grass/trunk/lib/rst/interp_float/init2d.c 2009-08-14 03:03:09 UTC (rev 38715)
@@ -17,33 +17,40 @@
#include <grass/interpf.h>
void IL_init_params_2d(
- /* initialize parameters */
- struct interp_params *params, FILE * inp, /* input stream */
- int elatt, /* which fp att in sites file? 1 = first */
- int smatt, /* which fp att in sites file to use for
- * smoothing? (if zero use sm) 1 = first */
- double zm, /* multiplier for z-values */
- int k1, /* min number of points per segment for
- * interpolation */
- int k2, /* max number of points per segment */
- char *msk, /* name of mask */
- int rows, int cols, /* number of rows and columns */
- DCELL * ar1, DCELL * ar2, DCELL * ar3, DCELL * ar4, DCELL * ar5, DCELL * ar6, /* arrays for interpolated
- * values */
- double tension, /* tension */
- int k3, /* max num. of points for interp. */
- int sc1, int sc2, int sc3, /* multipliers for interp. values */
- double sm, /* smoothing */
- char *f1, char *f2, char *f3, char *f4, char *f5, char *f6, /* output files */
- double dm, /* min distance between points */
- double x_or, double y_or, /* origin */
- int der, /* 1 if compute partial derivs */
- double tet, /* anisotropy angle, 0=East,counter-clockwise */
- double scl, /* anisotropy scaling factor */
- FILE * t1, FILE * t2, FILE * t3, FILE * t4, FILE * t5, FILE * t6, /* temp files for writing interp. values */
- FILE * dev, /* pointer to deviations file */
- struct TimeStamp *ts, int c, /* cross validation */
- const char *wheresql /* SQL WHERE */
+ /* initialize parameters */
+ struct interp_params *params,
+ FILE * inp, /* input stream */
+ int elatt, /* which fp att in sites file? 1 = first */
+ int smatt, /* which fp att in sites file to use for
+ * smoothing? (if zero use sm) 1 = first */
+ double zm, /* multiplier for z-values */
+ int k1, /* min number of points per segment for
+ * interpolation */
+ int k2, /* max number of points per segment */
+ char *msk, /* name of mask */
+ int rows, int cols, /* number of rows and columns */
+ DCELL * ar1, DCELL * ar2,
+ DCELL * ar3, DCELL * ar4,
+ DCELL * ar5, DCELL * ar6, /* arrays for interpolated values */
+ double tension, /* tension */
+ int k3, /* max num. of points for interp. */
+ int sc1, int sc2, int sc3, /* multipliers for interp. values */
+ double sm, /* smoothing */
+ char *f1, char *f2,
+ char *f3, char *f4,
+ char *f5, char *f6, /* output files */
+ double dm, /* min distance between points */
+ double x_or, double y_or, /* origin */
+ int der, /* 1 if compute partial derivs */
+ double tet, /* anisotropy angle, 0=East,counter-clockwise */
+ double scl, /* anisotropy scaling factor */
+ FILE * t1, FILE * t2,
+ FILE * t3, FILE * t4,
+ FILE * t5, FILE * t6, /* temp files for writing interp. values */
+ FILE * dev, /* pointer to deviations file */
+ struct TimeStamp *ts,
+ int c, /* cross validation */
+ const char *wheresql /* SQL WHERE */
)
{
params->fdinp = inp;
@@ -61,7 +68,8 @@
params->adxx = ar4;
params->adyy = ar5;
params->adxy = ar6;
- params->fi = tension, params->KMAX2 = k3;
+ params->fi = tension;
+ params->KMAX2 = k3;
params->scik1 = sc1;
params->scik2 = sc2;
params->scik3 = sc3;
@@ -90,15 +98,15 @@
params->wheresql = wheresql;
}
-void IL_init_func_2d(struct interp_params *params, int (*grid_f) (void), /* calculates grid for given segm */
- int (*matr_f) (void), /* creates matrix for a given segm */
- int (*point_f) (void), /* checks interp. func. at points */
- int (*secp_f) (void), /* calculates aspect,slope,curv. */
- double (*interp_f) (void), /* radial basis function */
- int (*interpder_f) (void), /* derivatives of radial basis func. */
- int (*temp_f) (void) /* writes temp files */
+void IL_init_func_2d(struct interp_params *params,
+ grid_calc_fn *grid_f, /* calculates grid for given segm */
+ matrix_create_fn *matr_f, /* creates matrix for a given segm */
+ check_points_fn *point_f, /* checks interp. func. at points */
+ secpar_fn *secp_f, /* calculates aspect,slope,curv. */
+ interp_fn *interp_f, /* radial basis function */
+ interpder_fn *interpder_f, /* derivatives of radial basis func. */
+ wr_temp_fn *temp_f /* writes temp files */
)
-
/* initialize functions */
{
params->grid_calc = grid_f;
@@ -110,3 +118,5 @@
params->wr_temp = temp_f;
}
+
+
Modified: grass/trunk/lib/rst/interp_float/interp2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/interp2d.c 2009-08-13 16:31:30 UTC (rev 38714)
+++ grass/trunk/lib/rst/interp_float/interp2d.c 2009-08-14 03:03:09 UTC (rev 38715)
@@ -45,7 +45,7 @@
double *c1min, double *c1max, double *c2min, double *c2max, /* min and max interp. curv. val. */
double *ertot, /* total interplating func. error */
double *b, /* solutions of linear equations */
- int offset1, /* offset for temp file writing */
+ off_t offset1, /* offset for temp file writing */
double dnorm)
/*
@@ -80,7 +80,7 @@
double zz;
int bmask = 1;
static int first_time_z = 1;
- int offset, offset2;
+ off_t offset, offset2;
double fstar2 = params->fi * params->fi / 4.;
double tfsta2, tfstad;
double ns_res, ew_res;
Modified: grass/trunk/lib/rst/interp_float/interpf.h
===================================================================
--- grass/trunk/lib/rst/interp_float/interpf.h 2009-08-13 16:31:30 UTC (rev 38714)
+++ grass/trunk/lib/rst/interp_float/interpf.h 2009-08-14 03:03:09 UTC (rev 38715)
@@ -39,6 +39,32 @@
extern int count;
#endif
+struct interp_params;
+
+typedef int grid_calc_fn(
+ struct interp_params *, struct quaddata *, struct BM *,
+ double, double, double *, double *, double *, double *,
+ double *, double *, double *, double *, double *,
+ double *, off_t, double);
+
+typedef int matrix_create_fn(
+ struct interp_params *, struct triple *, int, double **, int *);
+
+typedef int check_points_fn(
+ struct interp_params *, struct quaddata *, double *,
+ double *, double, double, struct triple);
+
+typedef int secpar_fn(
+ struct interp_params *, int, int, int, struct BM *,
+ double *, double *, double *, double *, double *,
+ double *, int, int);
+
+typedef double interp_fn(double, double);
+
+typedef int interpder_fn(double, double, double *, double *);
+
+typedef int wr_temp_fn(struct interp_params *, int, int, off_t);
+
struct interp_params
{
double zmult; /* multiplier for z-values */
@@ -49,30 +75,33 @@
int kmax; /* max number of points per segment */
char *maskmap; /* name of mask */
int nsizr, nsizc; /* number of rows and columns */
- DCELL *az, *adx, *ady, *adxx, *adyy, *adxy; /* array for interpolated values */
+ DCELL *az, *adx, *ady,
+ *adxx, *adyy, *adxy; /* array for interpolated values */
double fi; /* tension */
int KMAX2; /* max num. of points for interp. */
int scik1, scik2, scik3; /* multipliers for interp. values */
double rsm; /* smoothing */
- char *elev, *slope, *aspect, *pcurv, *tcurv, *mcurv; /* output files */
+ char *elev, *slope, *aspect,
+ *pcurv, *tcurv, *mcurv; /* output files */
double dmin; /* min distance between points */
double x_orig, y_orig; /* origin */
int deriv, cv; /* 1 if compute partial derivs */
double theta; /* anisotropy angle, 0=East,counter-clockwise */
double scalex; /* anisotropy scaling factor */
struct TimeStamp *ts; /* timestamp for raster files */
- FILE *Tmp_fd_z, *Tmp_fd_dx, *Tmp_fd_dy, /* temp files for writing interp. */
- *Tmp_fd_xx, *Tmp_fd_yy, *Tmp_fd_xy; /* values */
+ FILE *Tmp_fd_z, *Tmp_fd_dx,
+ *Tmp_fd_dy, *Tmp_fd_xx,
+ *Tmp_fd_yy, *Tmp_fd_xy; /* temp files for writing interp. values */
FILE *fddevi; /* pointer to deviations file */
- int (*grid_calc) (); /*calculates grid for given segm */
- int (*matrix_create) (); /*creates matrix for a given segm */
- int (*check_points) (); /*checks interp. func. at points */
- int (*secpar) (); /* calculates aspect,slope,curv. */
- double (*interp) (); /* radial based interp. function */
- int (*interpder) (); /* interp. func. for derivatives */
- int (*wr_temp) (); /* writes temp files */
- char *wheresql; /* SQL statement to select input points */
+ grid_calc_fn *grid_calc; /*calculates grid for given segm */
+ matrix_create_fn *matrix_create; /*creates matrix for a given segm */
+ check_points_fn *check_points; /*checks interp. func. at points */
+ secpar_fn *secpar; /* calculates aspect,slope,curv. */
+ interp_fn *interp; /* radial based interp. function */
+ interpder_fn *interpder; /* interp. func. for derivatives */
+ wr_temp_fn *wr_temp; /* writes temp files */
+ const char *wheresql; /* SQL statement to select input points */
};
/* distance.c */
@@ -92,8 +121,9 @@
FILE *, FILE *, FILE *, FILE *, FILE *, FILE *, FILE *,
struct TimeStamp *, int, const char *);
-void IL_init_func_2d(struct interp_params *, int (*)(), int (*)(), int (*)(),
- int (*)(), double (*)(), int (*)(), int (*)());
+void IL_init_func_2d(struct interp_params *, grid_calc_fn *,
+ matrix_create_fn *, check_points_fn *, secpar_fn *,
+ interp_fn *, interpder_fn *, wr_temp_fn *);
/* input2d.c */
int IL_input_data_2d(struct interp_params *, struct tree_info *, double *,
double *, double *, double *, double *, double *, int *);
@@ -104,7 +134,7 @@
int IL_grid_calc_2d(struct interp_params *, struct quaddata *, struct BM *,
double, double, double *, double *, double *, double *,
double *, double *, double *, double *, double *,
- double *, int, double);
+ double *, off_t, double);
/* matrix.c */
int IL_matrix_create(struct interp_params *, struct triple *, int, double **,
int *);
@@ -138,7 +168,7 @@
int IL_resample_interp_segments_2d(struct interp_params *, struct BM *,
double, double, double *, double *,
double *, double *, double *, double *,
- double *, double *, double *, int,
+ double *, double *, double *, off_t,
double *, int, int, int, int, int, double,
double, double, double, int);
/* secpar2d.c */
@@ -149,7 +179,7 @@
int IL_interp_segments_2d(struct interp_params *, struct tree_info *,
struct multtree *, struct BM *, double, double,
double *, double *, double *, double *, double *,
- double *, double *, double *, double *, int, int,
+ double *, double *, double *, double *, int, off_t,
double);
/* vinput2d.c */
int IL_vector_input_data_2d(struct interp_params *, struct Map_info *, int,
@@ -160,4 +190,4 @@
double *, double *, double *, double *, double *, double *,
int *, int *, int *);
/* write2d.c */
-int IL_write_temp_2d(struct interp_params *, int, int, int);
+int IL_write_temp_2d(struct interp_params *, int, int, off_t);
Modified: grass/trunk/lib/rst/interp_float/ressegm2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/ressegm2d.c 2009-08-13 16:31:30 UTC (rev 38714)
+++ grass/trunk/lib/rst/interp_float/ressegm2d.c 2009-08-14 03:03:09 UTC (rev 38715)
@@ -30,7 +30,7 @@
static int input_data(struct interp_params *,
int, int, struct fcell_triple *, int, int, int, int,
double, double, double);
-static int write_zeros(struct interp_params *, struct quaddata *, int);
+static int write_zeros(struct interp_params *, struct quaddata *, off_t);
int IL_resample_interp_segments_2d(struct interp_params *params, struct BM *bitmask, /* bitmask */
double zmin, double zmax, /* min and max input z-values */
@@ -38,7 +38,7 @@
double *gmin, double *gmax, /* min and max inperp. slope val. */
double *c1min, double *c1max, double *c2min, double *c2max, /* min and max interp. curv. val. */
double *ertot, /* total interplating func. error */
- int offset1, /* offset for temp file writing */
+ off_t offset1, /* offset for temp file writing */
double *dnorm,
int overlap,
int inp_rows,
@@ -81,6 +81,7 @@
double xmax, xmin, ymax, ymin;
int totsegm; /* total number of segments */
int total_points = 0;
+ struct triple triple; /* contains garbage */
xmin = params->x_orig;
@@ -202,7 +203,7 @@
b[0] = 0.;
G_lubksb(matrix, m1 + 1, indx, b);
- params->check_points(params, data, b, ertot, zmin, *dnorm);
+ params->check_points(params, data, b, ertot, zmin, *dnorm, triple);
if (params->grid_calc(params, data, bitmask,
zmin, zmax, zminac, zmaxac, gmin, gmax,
@@ -399,7 +400,7 @@
G_lubksb(new_matrix, data->n_points + 1, new_indx, b);
params->check_points(params, data, b, ertot, zmin,
- *dnorm);
+ *dnorm, triple);
if (params->grid_calc(params, data, bitmask,
zmin, zmax, zminac, zmaxac, gmin,
@@ -445,7 +446,7 @@
G_lubksb(matrix, data->n_points + 1, indx, b);
params->check_points(params, data, b, ertot, zmin,
- *dnorm);
+ *dnorm, triple);
if (params->grid_calc(params, data, bitmask,
zmin, zmax, zminac, zmaxac, gmin,
@@ -548,8 +549,9 @@
return 1;
}
-static int write_zeros(struct interp_params *params, struct quaddata *data, /* given segment */
- int offset1 /* offset for temp file writing */
+static int write_zeros(struct interp_params *params,
+ struct quaddata *data, /* given segment */
+ off_t offset1 /* offset for temp file writing */
)
{
@@ -564,7 +566,7 @@
int cond1, cond2;
int k, l;
int ngstc, nszc, ngstr, nszr;
- int offset, offset2;
+ off_t offset, offset2;
double ns_res, ew_res;
ns_res = (((struct quaddata *)(data))->ymax -
Modified: grass/trunk/lib/rst/interp_float/segmen2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/segmen2d.c 2009-08-13 16:31:30 UTC (rev 38714)
+++ grass/trunk/lib/rst/interp_float/segmen2d.c 2009-08-14 03:03:09 UTC (rev 38715)
@@ -21,8 +21,8 @@
double *gmin, double *gmax, /* min and max inperp. slope val. */
double *c1min, double *c1max, double *c2min, double *c2max, /* min and max interp. curv. val. */
double *ertot, /* total interplating func. error */
- int totsegm, /* total number of segments */
- int offset1, /* offset for temp file writing */
+ int totsegm, /* total number of segments */
+ off_t offset1, /* offset for temp file writing */
double dnorm)
/*
Recursively processes each segment in a tree by
Modified: grass/trunk/lib/rst/interp_float/write2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/write2d.c 2009-08-13 16:31:30 UTC (rev 38714)
+++ grass/trunk/lib/rst/interp_float/write2d.c 2009-08-14 03:03:09 UTC (rev 38715)
@@ -24,7 +24,7 @@
* Writes az,adx,...,adxy into appropriate place (depending on ngstc, nszc
* and offset) in corresponding temp file
*/
-int IL_write_temp_2d(struct interp_params *params, int ngstc, int nszc, int offset2) /* begin. and end. column, offset */
+int IL_write_temp_2d(struct interp_params *params, int ngstc, int nszc, off_t offset2) /* begin. and end. column, offset */
{
int j;
static FCELL *array_cell = NULL;
More information about the grass-commit
mailing list