The Lattices are a generalization of Arrays. They can handle memory- and disk-based arrays as well as other types of arrays (eg. expressions).
The module consists of various parts:
Vector, Matrix, and Cube are the one, two, and three dimensional specializations respectively of Array.
// Make a shape with three axes, x = 24, y = 48, z = 16;
IPosition threeSpace(3, 24, 48, 16);
// get the value of the ith axis (note: C++ is zero based!)
Int xShape = threeSpace(0);
Int zShape = threeSpace(2);
// construct another with all three axes values equal to 666;
IPosition threeSpaceAlso(3,666);
// do math with the IPositions...
threeSpace += threeSpaceAlso;
AlwaysAssert(threeSpace(1) == 714, AipsError);
// Define the shape of an array.
IPosition shape(2,20,30);
// Also define an origin.
IPosition origin(2,-5,15);
// Now define some Slicers, initially only specify the start
// Its length and stride will be 1.
Slicer ns0(IPosition(2,0,24));
// make some IPositions as holders for the rest of the information
IPosition blc,trc,inc;
// Use the shape and origin to fill our holders assuming we want to use
// as much of the Array as possible.
ns0.inferShapeFromSource (shape, origin, blc,trc,inc);
// print out the new info ie. blc=[5,9],trc=[5,9],inc=[1,1]
cout << blc << trc << inc << endl;
// Build a slicer with temporaries for arguments. The arguments are:
// start position, end position and step increment. The Slicer::endIsLast
// argument specifies that the end position is the trc. The alternative
// is Slicer::endIsLength which specifies that the end argument is the
// shape of the resulting subregion.
//
Slicer ns1(IPosition(2,3,5), IPosition(2,13,21), IPosition(2,3,2),
Slicer::endIsLast);
IPosition shp = ns1.inferShapeFromSource (shape, blc,trc,inc);
//
// print out the new info ie. shp=[4,9],blc=[3,5],trc=[12,21],inc=[3,2]
cout << shp << blc << trc << inc << endl;
The detailed discussions for the classes and global functions will describe how to use them.