Scopira 20080306

scopira::basekit::narray< T, DIM > Class Template Reference

#include <narray.h>

Inheritance diagram for scopira::basekit::narray< T, DIM >:
scopira::basekit::narray_o< T, DIM >

List of all members.

Public Types

typedef T data_type
 the type of the elements in the narray
typedef nindex< DIM > index_type
 the index type that this narray likes (usually an nindex type)
typedef T * iterator
 the interator type
typedef const T * const_iterator
 the const_interator type
typedef T value_type
typedef T * pointer
typedef T & reference
typedef const T & const_reference
typedef size_t size_type
typedef ptrdiff_t difference_type

Public Member Functions

 narray (void)
 in direct mode? if non null, this will be the handler
 narray (const this_type &src)
 copy ctor
 narray (const index_type &sz)
 sizing
 narray (size_t width, size_t height)
 sizing
 ~narray (void)
 dtor
bool load (scopira::tool::itflow_i &in)
void save (scopira::tool::otflow_i &out) const
const T * c_array (void) const
 raw c-array style access
T * c_array (void)
 raw c-array style access
iterator begin (void)
 begin-stl like iterator
iterator end (void)
 end-stl like iterator
const_iterator begin (void) const
 begin-stl like iterator
const_iterator end (void) const
 end-stl like iterator
bool empty (void) const
 empty?
size_t size (void) const
 gets the size (1D)
size_t width (void) const
 width
size_t height (void) const
 height
size_t depth (void) const
 depth
const index_typedimen (void) const
 gets the size of this array
void resize (size_t len)
void resize (size_t neww, size_t newh)
void resize (size_t neww, size_t newh, size_t newd)
void resize (const index_type &news)
void resize_direct (index_type sz, T *direct_ary, scopira::basekit::narray_delete_i *delfunc=null_narray_delete)
scopira::basekit::narray_delete_iget_direct (void) const
 gets the direct status/handler. non-null for direct mode
template<int SIM>
nslice< T, SIM > slicer (index_type base, nindex< SIM > dimen, nindex< SIM > direction)
 main slicer
template<int SIM>
nslice< T, SIM > slicer (index_type base, nindex< SIM > dimen)
 default directions
nslice< T, 1 > slicer (index_type base, size_t len, size_t direction=x_axis_c)
 1D specialized slicer, just to be nice
nslice< T, 1 > diagonal_slice (void)
nslice< T, DIM > all_slice (void)
 all slice
size_t size_rows (void) const
 number of rows
nslice< T, DIM-1 > row_slice (size_t r)
 get a particular row
nslice< T, 1 > xslice (size_t basex, size_t len)
 vector to vector
nslice< T, 1 > xslice (size_t basex, size_t basey, size_t len)
 vector slice
nslice< T, 1 > yslice (size_t basex, size_t basey, size_t len)
 vector slice
nslice< T, 2 > xyslice (size_t basex, size_t basey, size_t width, size_t height)
 matrix slice
nslice< T, 1 > xslice (index_type base, size_t len)
 vector slice
nslice< T, 1 > yslice (index_type base, size_t len)
 vector slice
nslice< T, 1 > zslice (index_type base, size_t len)
 vector slice
nslice< T, 1 > tslice (index_type base, size_t len)
 vector slice
nslice< T, 2 > xyslice (index_type base, size_t width, size_t height)
 matrix slice
template<int SIM>
const_nslice< T, SIM > slicer (index_type base, nindex< SIM > dimen, nindex< SIM > direction) const
 main slicer
template<int SIM>
const_nslice< T, SIM > slicer (index_type base, nindex< SIM > dimen) const
 default directions
const_nslice< T, 1 > slicer (index_type base, size_t len, size_t direction=x_axis_c) const
 1D specialized slicer, just to be nice
const_nslice< T, 1 > diagonal_slice (void) const
 diagnol
const_nslice< T, DIM > all_slice (void) const
 all slice
const_nslice< T, DIM-1 > row_slice (size_t r) const
 number of rows
const_nslice< T, 1 > xslice (size_t basex, size_t len) const
 vector to vector
const_nslice< T, 1 > xslice (size_t basex, size_t basey, size_t len) const
 vector slice
const_nslice< T, 1 > yslice (size_t basex, size_t basey, size_t len) const
 vector slice
const_nslice< T, 2 > xyslice (size_t basex, size_t basey, size_t width, size_t height) const
 matrix slice
const_nslice< T, 1 > xslice (index_type base, size_t len) const
 vector slice
const_nslice< T, 1 > yslice (index_type base, size_t len) const
 vector slice
const_nslice< T, 1 > zslice (index_type base, size_t len) const
 vector slice
const_nslice< T, 1 > tslice (index_type base, size_t len) const
 vector slice
const_nslice< T, 2 > xyslice (index_type base, size_t width, size_t height) const
 matrix slice
void clear (void)
 set all to 0
void set_all (T v)
 set all the elements
void copy (const this_type &at)
 deep copy
void copy (const nslice< T, DIM > &at)
 deep copy
void copy (const const_nslice< T, DIM > &at)
 deep copy
void operator= (const this_type &at)
 this turns out to be very handy
operator() (index_type c) const
 [] ref
T & operator() (index_type c)
 [] ref
void set (index_type c, T v)
 setter
get (index_type c) const
 getter
const T operator[] (size_t idx) const
 Nice, referece-based element access.
T & operator[] (size_t idx)
 Nice, referece-based element access.
void set (size_t idx, T v)
 Sets the value of an element.
get (size_t idx) const
 Gets the value of an element.
const T operator() (size_t x, size_t y) const
T & operator() (size_t x, size_t y)
void set (size_t x, size_t y, T v)
get (size_t x, size_t y) const
T & operator() (size_t x, size_t y, size_t z)
void set (size_t x, size_t y, size_t z, T v)
get (size_t x, size_t y, size_t z) const

Detailed Description

template<class T, int DIM>
class scopira::basekit::narray< T, DIM >

The is the core N-dimension numerical array class.

It a templated class that allows you to build N-dimensional arrays of any type.

See Numeric arrays for a introduction.

Arrays contains the elements in a C-like fasion. You can use the access methods to access the elements, STL style iteration or the c_array() function to get at the data.

The nslice class allow you to create subset views within narrays. The nindex class is a tiny array class that lets you do N-dimensional coordinate referencing.

See also:
Numeric arrays
scopira::basekit::nslice
scopira::basekit::nindex
Author:
Aleksander Demko

Constructor & Destructor Documentation

template<class T , int DIM>
scopira::basekit::narray< T, DIM >::narray ( void  )

in direct mode? if non null, this will be the handler

default


Member Function Documentation

template<class T , int DIM>
scopira::basekit::nslice< T, 1 > scopira::basekit::narray< T, DIM >::diagonal_slice ( void  )

This returns a slice vector that goes across the diagonal.

This only works on matrix narrays (for now).

Author:
Aleksander Demko
template<class T, int DIM>
T scopira::basekit::narray< T, DIM >::get ( size_t  x,
size_t  y 
) const [inline]

Gets an individual element out of a matrix. This is only valid on two dimentional arrays.

Parameters:
xthe x value of the element to reference
ythe y value of the element to reference
Returns:
the value of the specified element
Author:
Aleksander Demko
template<class T, int DIM>
T scopira::basekit::narray< T, DIM >::get ( size_t  x,
size_t  y,
size_t  z 
) const [inline]

Gets an individual element out of a cube. This is only valid on three dimentional arrays.

Parameters:
xthe x value of the element to reference
ythe y value of the element to reference
zthe z value of the element to reference
Returns:
the value of the specified element
Author:
Aleksander Demko
template<class T , int DIM>
bool scopira::basekit::narray< T, DIM >::load ( scopira::tool::itflow_i in)

Implements serilization via trait classes. Turbo charged with binary throttling! Non virtual, on purpose. Uses a slightly different flow type, on purpose.

Author:
Aleksander Demko

References scopira::tool::byte_swap_all(), scopira::tool::iflow_i::read_array(), scopira::tool::itflow_i::read_int(), and scopira::tool::itflow_i::read_size_t().

template<class T, int DIM>
const T scopira::basekit::narray< T, DIM >::operator() ( size_t  x,
size_t  y 
) const [inline]

2-dimensional (matrix) array access operator. This is only valid on two dimentional arrays.

Parameters:
xthe x value of the element to reference
ythe y value of the element to reference
Returns:
a reference to the specified value
Author:
Aleksander Demko
template<class T, int DIM>
T& scopira::basekit::narray< T, DIM >::operator() ( size_t  x,
size_t  y 
) [inline]

2-dimensional (matrix) array access operator. This is only valid on two dimentional arrays.

Parameters:
xthe x value of the element to reference
ythe y value of the element to reference
Returns:
a reference to the specified value
Author:
Aleksander Demko
template<class T, int DIM>
T& scopira::basekit::narray< T, DIM >::operator() ( size_t  x,
size_t  y,
size_t  z 
) [inline]

3-dimensional (cube) array access operator. This is only valid on three dimentional arrays.

Parameters:
xthe x value of the element to reference
ythe y value of the element to reference
zthe z value of the element to reference
Returns:
a reference to the specified value
Author:
Aleksander Demko
template<class T, int DIM>
void scopira::basekit::narray< T, DIM >::resize ( size_t  neww,
size_t  newh,
size_t  newd 
) [inline]

Resize the cube (3 dimensional array) to the new dimensions.

This destroys the previous contents.

Parameters:
newwthe new width (x dimension)
newhthe new width (y dimension)
newdthe new depth (z dimension)
Author:
Aleksander Demko

Referenced by scopira::basekit::narray< scopira::tool::uuid >::resize().

template<class T , int DIM>
void scopira::basekit::narray< T, DIM >::resize ( const index_type news)

Generic resize function that takes a index_type.

This destroys the previous contents.

Author:
Aleksander Demko

References scopira::basekit::nindex< DIM >::product().

template<class T, int DIM>
void scopira::basekit::narray< T, DIM >::resize ( size_t  neww,
size_t  newh 
) [inline]

Resize the matrix to the new dimensions.

This destroys the previous contents.

Parameters:
newwthe new width (x dimension)
newhthe new width (y dimension)
Author:
Aleksander Demko

Referenced by scopira::basekit::narray< scopira::tool::uuid >::resize().

template<class T, int DIM>
void scopira::basekit::narray< T, DIM >::resize_direct ( index_type  sz,
T *  direct_ary,
scopira::basekit::narray_delete_i delfunc = null_narray_delete 
)

Sets this narray to be a "direct" array. That is, the array will utilize an externally managed C array.

The current size of the narry must be empty, or another direct array. An empty new direct array will revert this narray back to normal memory managment.

In direct mode, only resize(0) and resize(current_size) will be accepted - all others trigger asserts.

Author:
Aleksander Demko

References scopira::basekit::normal_narray_delete, and scopira::basekit::nindex< DIM >::product().

Referenced by scopira::basekit::bind_direct_file(), scopira::basekit::bind_directio_file(), and scopira::basekit::load_directio_file().

template<class T , int DIM>
scopira::basekit::const_nslice< T, DIM-1 > scopira::basekit::narray< T, DIM >::row_slice ( size_t  r) const

number of rows

get a particular row

References scopira::basekit::nindex< DIM >::shrink(), and scopira::basekit::nindex< DIM >::steps().

template<class T , int DIM>
void scopira::basekit::narray< T, DIM >::save ( scopira::tool::otflow_i out) const

Implements serilization via trait classes. Turbo charged with binary throttling! Non virtual, on purpose. Uses a slightly different flow type, on purpose.

Author:
Aleksander Demko

References scopira::tool::byte_swap_all(), scopira::tool::oflow_i::write_array(), scopira::tool::otflow_i::write_int(), and scopira::tool::otflow_i::write_size_t().

template<class T, int DIM>
void scopira::basekit::narray< T, DIM >::set ( size_t  x,
size_t  y,
size_t  z,
v 
) [inline]

Sets an individual element out of a cube. This is only valid on three dimentional arrays.

Parameters:
xthe x value of the element to reference
ythe y value of the element to reference
zthe z value of the element to reference
vthe new value
Author:
Aleksander Demko
template<class T, int DIM>
void scopira::basekit::narray< T, DIM >::set ( size_t  x,
size_t  y,
v 
) [inline]

Sets an individual element out of a matrix. This is only valid on two dimentional arrays.

Parameters:
xthe x value of the element to reference
ythe y value of the element to reference
vthe new value
Author:
Aleksander Demko

The documentation for this class was generated from the following file: