Nonstationarity: patching |
The -th patch is denoted by the scalar counter ipatch. Typical patch extraction begins by taking ipatch, a C linear index, and converting it to a multidimensional subscript jj each component of which is less than npatch. The patches cover all edges and corners of the given data plane (actually the hypervolume) even where nwall/npatch is not an integer, even for axes whose length is not an integer number of the patch length. Where there are noninteger ratios, the spacing of patches is slightly uneven, but we'll see later that it is easy to reassemble seamlessly the full plane from the patches, so the unevenness does not matter. You might wish to review the utilities line2cart and cart2line which convert between multidimensional array subscripts and the linear memory subscript before looking at the patch extraction-putback code:
void patch_lop (bool adj, bool add, int nx, int ny, float* wall, float* wind) /*< patch operator >*/ { int i, j, shift; sf_adjnull (adj, add, nx, ny, wall, wind); sf_line2cart(dim, npatch, ipatch, jj); for(i = 0; i < dim; i++) { if(npatch[i] == 1) { jj[i] = 0; } else if (jj[i] == npatch[i]-1) { jj[i] = nwall[i] - nwind[i]; } else { jj[i] = jj[i]*(nwall[i] - nwind[i])/(npatch[i] - 1.0); } } /* shift till the patch start */ shift = sf_cart2line(dim, nwall, jj); for(i = 0; i < ny; i++) { sf_line2cart(dim, nwind, i, ii); j = sf_cart2line(dim, nwall, ii) + shift; if (adj) wall[j] += wind[i]; else wind[i] += wall[j]; } } |
Figure 2 shows an example with five nonoverlapping patches on the 1-axis and many overlapping patches on the 2-axis.
parcel
Figure 2. A plane of identical values after patches have been cut and then added back. Results are shown for nwall=(100,30), nwind=(17,6), npatch=(5,11). For these parameters, there is gapping on the horizontal axis and overlap on the depth axis. | |
---|---|
Nonstationarity: patching |