Scopira
20080306
|
#include <narray.h>
Public Types | |
typedef T | data_type |
typedef nindex< DIM > | index_type |
typedef niterator< T, DIM > | iterator |
typedef niterator< T, DIM > | const_iterator |
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 | |
nslice (void) | |
default ctor, makes a null slice | |
nslice (const this_type &rhs) | |
(light) copy ctor | |
nslice (narray< T, DIM > &rhs) | |
does an all_slice on the source narray | |
nslice (narray< T, DIM > *rhs) | |
does an all_slice on the source narray | |
nslice (T *_var, size_t _prime, index_type _size, index_type _stride) | |
init, ctor | |
bool | load (scopira::tool::itflow_i &in) |
void | save (scopira::tool::otflow_i &out) const |
T * | c_array (void) const |
niterator< T, DIM > | begin (void) const |
niterator< T, DIM > | end (void) const |
bool | is_null (void) const |
is the slice "null", ie not pointing to ANYTHING | |
void | set_null (void) |
sets thte slice to null | |
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_type & | dimen (void) const |
gets the width | |
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) |
template<int SIM> | |
nslice< T, SIM > | slicer (index_type base, nindex< SIM > dimen, nindex< SIM > direction) const |
template<int SIM> | |
nslice< T, SIM > | slicer (index_type base, nindex< SIM > dimen) const |
default directions | |
nslice< T, 1 > | slicer (index_type base, size_t len, size_t direction=0) const |
1D specialized slicer, just to be nice | |
nslice< T, 1 > | diagonal_slice (void) |
nslice< T, DIM > | all_slice (void) const |
all slice | |
size_t | size_rows (void) const |
number of rows | |
nslice< T, DIM-1 > | row_slice (size_t r) const |
get a particular row | |
nslice< T, 1 > | xslice (size_t basex, size_t len) const |
vector to vector | |
nslice< T, 1 > | xslice (size_t basex, size_t basey, size_t len) const |
vector slice | |
nslice< T, 1 > | yslice (size_t basex, size_t basey, size_t len) const |
vector slice | |
nslice< T, 2 > | xyslice (size_t basex, size_t basey, size_t width, size_t height) const |
matrix slice | |
nslice< T, 1 > | xslice (index_type base, size_t len) const |
vector slice | |
nslice< T, 1 > | yslice (index_type base, size_t len) const |
vector slice | |
nslice< T, 1 > | zslice (index_type base, size_t len) const |
vector slice | |
nslice< T, 1 > | tslice (index_type base, size_t len) const |
vector slice | |
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) const |
set all elements | |
void | copy (const narray< T, DIM > &at) |
copy | |
void | copy (const nslice< T, DIM > &at) |
deep copy | |
void | copy (const const_nslice< T, DIM > &at) |
deep copy | |
T & | operator() (index_type idx) const |
access, by index | |
T & | operator[] (size_t idx) const |
Nice, referece-based element access. | |
void | set (size_t idx, T v) const |
Sets the value of an element. | |
T | get (size_t idx) const |
Gets the value of an element. | |
T & | operator() (size_t x, size_t y) const |
void | set (size_t x, size_t y, T v) const |
T | get (size_t x, size_t y) const |
T & | operator() (size_t x, size_t y, size_t z) const |
void | set (size_t x, size_t y, size_t z, T v) const |
T | get (size_t x, size_t y, size_t z) const |
bool | is_flat_stride (void) const |
template<int SIM> | |
scopira::basekit::nslice< T, SIM > | slicer (index_type base, nindex< SIM > dimen, nindex< SIM > direction) const |
template<int SIM> | |
scopira::basekit::nslice< T, SIM > | slicer (index_type base, nindex< SIM > dimen) const |
Friends | |
class | scopira::basekit::const_nslice< T, DIM > |
The nslice class is a lightweight array-like class that lets you view a subset of an narray. You can thing of them as a pointer to the contents of a narray.
Some other notes:
See Numeric arrays for a introduction.
|
inline |
Returns the start of the nslice, as an STL-style iterator
Referenced by scopira::basekit::narray< scopira::tool::uuid >::copy(), scopira::basekit::nslice< T, DIM >::copy(), scopira::basekit::nslice< T, DIM >::load(), scopira::basekit::nslice< T, DIM >::save(), and scopira::basekit::nslice< T, DIM >::set_all().
|
inline |
Gets the contents of the slice as a ray C array.
This is only valid if the X stride is 1.
References scopira::basekit::const_nslice< T, DIM >::is_flat_stride().
Referenced by scopira::basekit::nslice< T, DIM >::load(), and scopira::basekit::nslice< T, DIM >::save().
scopira::basekit::nslice< T, 1 > scopira::basekit::nslice< T, DIM >::diagonal_slice | ( | void | ) |
This returns a slice vector that goes across the diagonal.
This only works on matrix nslices (for now).
|
inline |
Returns the end of the nslice, as an STL-style iterator
Referenced by scopira::basekit::nslice< T, DIM >::copy(), scopira::basekit::nslice< T, DIM >::load(), scopira::basekit::nslice< T, DIM >::save(), and scopira::basekit::nslice< T, DIM >::set_all().
|
inline |
Gets an individual element out of a matrix. This is only valid on two dimentional arrays.
x | the x value of the element to reference |
y | the y value of the element to reference |
References scopira::basekit::const_nslice< T, DIM >::height(), and scopira::basekit::const_nslice< T, DIM >::width().
|
inline |
Gets an individual element out of a cube. This is only valid on three dimentional arrays.
x | the x value of the element to reference |
y | the y value of the element to reference |
z | the z value of the element to reference |
References scopira::basekit::const_nslice< T, DIM >::depth(), scopira::basekit::const_nslice< T, DIM >::height(), and scopira::basekit::const_nslice< T, DIM >::width().
|
inline |
Returns true if this slice has a "flat" stride. See scopira::basekit::is_flat_stride.
References scopira::basekit::is_flat_stride().
Referenced by scopira::basekit::nslice< T, DIM >::load(), and scopira::basekit::nslice< T, DIM >::save().
bool scopira::basekit::nslice< T, DIM >::load | ( | scopira::tool::itflow_i & | in | ) |
Implements serilization via trait classes. Wire-compatible with narray!
References scopira::tool::fixed_array< T, N >::begin(), scopira::basekit::nslice< T, DIM >::begin(), scopira::tool::byte_swap_all(), scopira::basekit::nslice< T, DIM >::c_array(), scopira::basekit::nslice< T, DIM >::end(), scopira::basekit::nslice< T, DIM >::is_flat_stride(), scopira::tool::iflow_i::read_array(), scopira::tool::itflow_i::read_int(), scopira::tool::itflow_i::read_size_t(), scopira::tool::fixed_array< T, N >::size(), and scopira::basekit::nslice< T, DIM >::size().
|
inline |
2-dimensional (matrix) array access operator. This is only valid on two dimentional arrays.
x | the x value of the element to reference |
y | the y value of the element to reference |
References scopira::basekit::const_nslice< T, DIM >::height(), and scopira::basekit::const_nslice< T, DIM >::width().
|
inline |
3-dimensional (cube) array access operator. This is only valid on three dimentional arrays.
x | the x value of the element to reference |
y | the y value of the element to reference |
z | the z value of the element to reference |
References scopira::basekit::const_nslice< T, DIM >::depth(), scopira::basekit::const_nslice< T, DIM >::height(), and scopira::basekit::const_nslice< T, DIM >::width().
|
inline |
Resize the vector to the new length.
This destroys the previous contents.
len | the length of the vector (x dimension) |
References scopira::basekit::nslice< T, DIM >::resize().
Referenced by scopira::basekit::nslice< T, DIM >::copy(), and scopira::basekit::nslice< T, DIM >::resize().
|
inline |
Resize the matrix to the new dimensions.
This destroys the previous contents.
neww | the new width (x dimension) |
newh | the new width (y dimension) |
References scopira::basekit::nslice< T, DIM >::resize().
Referenced by scopira::basekit::nslice< T, DIM >::resize().
|
inline |
Resize the cube (3 dimensional array) to the new dimensions.
This destroys the previous contents.
neww | the new width (x dimension) |
newh | the new width (y dimension) |
newd | the new depth (z dimension) |
References scopira::basekit::const_nslice< T, DIM >::all_slice(), scopira::basekit::const_nslice< T, DIM >::diagonal_slice(), scopira::basekit::nslice< T, DIM >::resize(), scopira::basekit::const_nslice< T, DIM >::resize(), and scopira::basekit::const_nslice< T, DIM >::slicer().
Referenced by scopira::basekit::nslice< T, DIM >::resize().
void scopira::basekit::nslice< T, DIM >::resize | ( | const index_type & | news | ) |
Generic resize function that takes a index_type.
This destroys the previous contents.
References scopira::basekit::nslice< T, DIM >::slicer().
void scopira::basekit::nslice< T, DIM >::save | ( | scopira::tool::otflow_i & | out | ) | const |
Implements serilization via trait classes. Wire-compatible with narray!
References scopira::tool::fixed_array< T, N >::begin(), scopira::basekit::nslice< T, DIM >::begin(), scopira::tool::byte_swap_all(), scopira::basekit::nslice< T, DIM >::c_array(), scopira::basekit::nslice< T, DIM >::empty(), scopira::tool::fixed_array< T, N >::end(), scopira::basekit::nslice< T, DIM >::end(), scopira::basekit::nslice< T, DIM >::is_flat_stride(), scopira::basekit::nslice< T, DIM >::size(), scopira::tool::oflow_i::write_array(), scopira::tool::otflow_i::write_int(), and scopira::tool::otflow_i::write_size_t().
|
inline |
Sets an individual element out of a matrix. This is only valid on two dimentional arrays.
x | the x value of the element to reference |
y | the y value of the element to reference |
v | the new value |
References scopira::basekit::const_nslice< T, DIM >::height(), and scopira::basekit::const_nslice< T, DIM >::width().
|
inline |
Sets an individual element out of a cube. This is only valid on three dimentional arrays.
x | the x value of the element to reference |
y | the y value of the element to reference |
z | the z value of the element to reference |
v | the new value |
References scopira::basekit::const_nslice< T, DIM >::depth(), scopira::basekit::const_nslice< T, DIM >::height(), and scopira::basekit::const_nslice< T, DIM >::width().
nslice<T,SIM> scopira::basekit::nslice< T, DIM >::slicer | ( | index_type | base, |
nindex< SIM > | dimen, | ||
nindex< SIM > | direction | ||
) | const |
slicer cire main slicer
Referenced by scopira::basekit::nslice< T, DIM >::all_slice(), scopira::basekit::nslice< T, DIM >::resize(), scopira::basekit::nslice< T, DIM >::row_slice(), and scopira::basekit::nslice< T, DIM >::slicer().