By specifying a region it is possible to apply the function object to a subset of the lattice. Of course, the shape of the output lattice(s) have to match the shape of the region.
The iteration is done in an optimal way. To keep memory usage down, it caches as few tiles as possible. There are 2 ways to iterate.
The class is Doubly templated. Ths first template type is for the data type you are processing. The second type is for what type you want the results of the processing assigned to. For example, if you are computing sums of squares for statistical purposes, you might use higher precision (Float->Double) for this. No check is made that the template types are self-consistent.
MyLineCollapser collapser; PagedArray<Float> latticeIn("lattice.file"); IPosition shape = latticeIn.shape(); shape(1) = 1; ArrayLattice<Double> latticeOut(shape); LatticeApply<Float,Double>::lineApply (latticeOut, latticeIn, collapser, 1);
This function iterates line by line through an input lattice and applies a user supplied function object to each line along the specified axis. The vector result of the function object is written into the output lattices at the location of the collapsed line (1 value per lattice). The output lattices must be supplied with the correct shape (the shape of the supplied region). The default region is the entire input lattice.
This function iterates tile by tile through an input lattice and applies a user supplied function object to each chunk along the specified axes. A chunk can be a line, plane, etc. which is determined by the argument collapseAxes. E.g. IPosition(2,1,2) means planes along axes 1 and 2 (thus y,z planes). The result of the function object is written into the output lattice at the location of the collapsed chunk. The output lattice must be supplied with the correct shape (the shape of the supplied region plus the number of values resulting from the collapse). The default region is the entire input lattice.
This function iterates tile by tile through an input lattice and applies a user supplied function object to each chunk along the specified axes. A chunk can be a line, plane, etc. which is determined by the argument collapseAxes. E.g. IPosition(2,1,2) means planes along axes 1 and 2 (thus y,z planes). The result of the function object is written into the output lattices at the location of the collapsed chunk. The output lattices must be supplied with the correct shape (the shape of the supplied region). The default region is the entire input lattice.
These functions are only declared, but not implemented yet. Thus they cannot be used yet.