Scopira
20080306
|
The scopira::basekit::narray template class is the core numerical data array class in Scopira. It can be used to make arrays of any dimention and with any data type.
Data access for multi-dimention arrays follow the x,y,z,etc style. In particular, matrices are x,y (rather than the mathematical convention of rows,cols). This is deliberate as to be consistant with higher dimention array.
STL-like begin()/end() iteration is supported.
You can always get at the raw data in an narray using the scopira::basekit::narray::c_array() method.
Use [] for 1-dimention (vector) access. Use () for 2-dimention (matrix) access. () is also used for 3+-dimention access via nindex objects.
When compiled in debug mode, all element access is tested via asserts(). This aids in debugging and development. Under release builds, these check is removed and all accesses are inlined – just like native arrays.
This is an example of some basic usage of narrays.
scopira::basekit::nslice is a template class that provides "slicing" for narrays. A slice is a small pointer into a subsection of a host-narray. A nslice has no data of it's own, it only knows where in the host narray it should be accessing. It is invalid to use a nslice after its hsot narray has been destroyed (or even simply resized).
A nslice has most of the same methods and access functions as an narray.
A nslice can have less dimentions that its host narray (but never more). For example, you can make a vector-like nslice out of a 2-dimention matrix narray.
An example: