From 60d1383db4d9f646ce5504edc9b2c437836696db Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 29 Jun 2019 10:23:40 +0200 Subject: transfer: implement and use 1D interpolation Stop abusing "2D of y size 1" for this. --- transfer.h | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'transfer.h') diff --git a/transfer.h b/transfer.h index 2ed4aea..5c434e3 100644 --- a/transfer.h +++ b/transfer.h @@ -36,25 +36,26 @@ enum GridTransferOperator { }; /** - * A 2-dimensional grid with regular spacing. + * An N-dimensional grid with regular spacing. */ -typedef struct RegularGrid2D { +typedef struct RegularGrid { /** * Indices of the grid origin, relative to coordinate origin. - * (o0, o1) = (start[0] * step[0], start[1] * step[1]) + * For each dimension i=0..N-1: + * o_i = start[i] * step[i] */ - ptrdiff_t start[2]; + ptrdiff_t *start; /** * Number of points in the domain. */ - size_t size[2]; + size_t *size; /** * Size of the step between neighbouring grid points. */ - double step[2]; -} RegularGrid2D; + double *step; +} RegularGrid; typedef struct GridTransferContext { /** @@ -76,15 +77,20 @@ typedef struct GridTransferContext { */ enum GridTransferOperator op; + /** + * Number of dimensions. + */ + unsigned int nb_dims; + /** * Source grid geometry, must be filled by the caller. */ - RegularGrid2D src; + RegularGrid src; /** * Destination grid geometry, must be filled by the caller. */ - RegularGrid2D dst; + RegularGrid dst; /** * Allow extrapolating this many points beyond the source rectangle. @@ -98,7 +104,7 @@ typedef struct GridTransferContext { * * @return newly allocated transfer context on success, NULL on failure */ -GridTransferContext *mg2di_gt_alloc(enum GridTransferOperator op); +GridTransferContext *mg2di_gt_alloc(unsigned int dims, enum GridTransferOperator op); /** * Initialize the tranfer context after all the parameters have been set. -- cgit v1.2.3