offsets.h File Reference

Functions for extraction of offset lists of subarrays. More...

#include "utils.h"

Go to the source code of this file.

Functions

int get_array_offsets (off_t **offs, size_t *noffs, int dim, const IPNT gs, const IPNT gn, const IPNT ls, const IPNT ln)
 computes offsets into a subarray.


Detailed Description

Functions for extraction of offset lists of subarrays.

Compute offsets for a subarray with starts ls and lengths ln of a global array with starts gs and lengths gn. Dimension of both assumed to be dim.

number of offsets = product of ln[1]*...*ln[dim-1].

For each offset j,

Example: suppose dim=2, gs=[0,0], gn=[4,4], ls=[1,1], ln=[2,2]. The subarray consists of the four points [1,1],[2,1],[1,2], and [2,2]. The offsets are clearly 5 and 9, noffs=2 = ln[1]*...*ln[dim-1].

To work out the 2nd offset (j=1), product of ln[dim-2]*...*ln[1]=1 (empty products are by default = 1). 1/1=1, remainder is 0. So idx=[0,1].

2nd offset = (idx[0]+ls[0]-gs[0]) (idx[1]+ls[1]-gs[1])*gn[0] = (0+1-0)+(1+1-0)*4=9

Definition in file offsets.h.


Function Documentation

get_array_offsets ( off_t **  offs,
size_t *  noffs,
int  dim,
const IPNT  gs,
const IPNT  gn,
const IPNT  ls,
const IPNT  ln 
)

computes offsets into a subarray.

same as

See also:
get_array_offsets,
but uses off_t, size_t instead of explicit types.


Generated on 5 Jan 2017 for IWAVEGRID by  doxygen 1.4.7