14 #ifndef __INCLUDED_SCOPIRA_BASEKIT_NARRAY_H__ 15 #define __INCLUDED_SCOPIRA_BASEKIT_NARRAY_H__ 20 #include <scopira/tool/platform.h> 21 #include <scopira/tool/flow.h> 22 #include <scopira/tool/traits.h> 23 #include <scopira/tool/printflow.h> 24 #include <scopira/tool/export.h> 51 template <>
class nindex<1>;
52 template <>
class nindex<2>;
53 template <>
class nindex<3>;
54 template <>
class nindex<4>;
96 template <
class T,
int DIM = 1>
class narray;
98 template <
class T,
int DIM = 1>
class nslice;
425 bool operator < (
const this_type &rhs)
const;
427 bool operator == (
const this_type &rhs)
const;
429 size_t operator* (
const this_type &rhs)
const;
432 size_t product(
void)
const;
434 size_t offset(
const this_type &c)
const;
436 this_type strides(
void)
const;
438 static this_type steps(
void);
440 nindex<DIM-1> shrink(
void)
const;
459 void clear(
size_t v = 0) { dm_ary[0] = v; }
462 size_t product(
void)
const {
return dm_ary[0]; }
464 size_t offset(
const this_type &c)
const {
return c.dm_ary[0]; }
466 this_type
strides(
void)
const {
return this_type(1); }
468 static this_type
steps(
void) {
return this_type(0); }
473 bool operator < (
const this_type &rhs)
const {
return dm_ary[0]<rhs.dm_ary[0]; }
475 bool operator == (
const this_type &rhs)
const {
return dm_ary[0]==rhs.dm_ary[0]; }
477 size_t operator *(
const this_type &rhs)
const {
return dm_ary[0]*rhs.dm_ary[0]; }
479 const this_type & operator = (
const this_type &rhs) { dm_ary[0] = rhs.dm_ary[0];
return *
this; }
482 size_t &
x(
void) {
return dm_ary[0]; }
484 size_t x(
void)
const {
return dm_ary[0]; }
487 void set(
size_t _x) { dm_ary[0] = _x; }
504 nindex(
size_t _x,
size_t _y) { dm_ary[0] = _x; dm_ary[1] = _y; }
509 { dm_ary[0] = v; dm_ary[1] = v; }
512 size_t product(
void)
const {
return dm_ary[0]*dm_ary[1]; }
514 size_t offset(
const this_type &c)
const {
return c.dm_ary[1]*dm_ary[0] + c.dm_ary[0]; }
516 this_type
strides(
void)
const {
return this_type(1, dm_ary[0]); }
518 static this_type
steps(
void) {
return this_type(0,1); }
523 bool operator < (
const this_type &rhs)
const {
return dm_ary[0]<rhs.dm_ary[0] && dm_ary[1]<rhs.dm_ary[1]; }
525 bool operator == (
const this_type &rhs)
const {
return dm_ary[0]==rhs.dm_ary[0] && dm_ary[1]==rhs.dm_ary[1]; }
527 size_t operator *(
const this_type &rhs)
const {
return dm_ary[0]*rhs.dm_ary[0] + dm_ary[1]*rhs.dm_ary[1]; }
529 const this_type & operator = (
const this_type &rhs) { dm_ary[0] = rhs.dm_ary[0]; dm_ary[1] = rhs.dm_ary[1];
return *
this; }
532 size_t &
x(
void) {
return dm_ary[0]; }
534 size_t x(
void)
const {
return dm_ary[0]; }
536 size_t &
y(
void) {
return dm_ary[1]; }
538 size_t y(
void)
const {
return dm_ary[1]; }
541 void set_xy(
size_t _x,
size_t _y) { dm_ary[0] = _x; dm_ary[1] = _y; }
558 SCOPIRA_EXPORT
nindex(
size_t _x,
size_t _y,
size_t _z=0);
560 SCOPIRA_EXPORT nindex(
size_t v=0);
562 SCOPIRA_EXPORT nindex(
const this_type &rhs);
565 { dm_ary[0] = v; dm_ary[1] = v; dm_ary[2] = v; }
568 size_t product(
void)
const {
return dm_ary[0]*dm_ary[1]*dm_ary[2]; }
570 size_t offset(
const this_type &c)
const {
return c.dm_ary[2]*dm_ary[1]*dm_ary[0] + c.dm_ary[1]*dm_ary[0] + c.dm_ary[0]; }
572 this_type
strides(
void)
const {
return this_type(1, dm_ary[0], dm_ary[0]*dm_ary[1]); }
574 static this_type
steps(
void) {
return this_type(0,1,2); }
579 bool operator < (
const this_type &rhs)
const {
return dm_ary[0]<rhs.dm_ary[0] && dm_ary[1]<rhs.dm_ary[1] && dm_ary[2]<rhs.dm_ary[2]; }
581 bool operator == (
const this_type &rhs)
const {
return dm_ary[0]==rhs.dm_ary[0] && dm_ary[1]==rhs.dm_ary[1] && dm_ary[2]==rhs.dm_ary[2]; }
583 size_t operator *(
const this_type &rhs)
const {
return dm_ary[0]*rhs.dm_ary[0] + dm_ary[1]*rhs.dm_ary[1] + dm_ary[2]*rhs.dm_ary[2]; }
585 const this_type & operator = (
const this_type &rhs) { dm_ary[0] = rhs.dm_ary[0]; dm_ary[1] = rhs.dm_ary[1]; dm_ary[2] = rhs.dm_ary[2];
return *
this; }
588 size_t &
x(
void) {
return dm_ary[0]; }
590 size_t x(
void)
const {
return dm_ary[0]; }
592 size_t &
y(
void) {
return dm_ary[1]; }
594 size_t y(
void)
const {
return dm_ary[1]; }
596 size_t &
z(
void) {
return dm_ary[2]; }
598 size_t z(
void)
const {
return dm_ary[2]; }
615 SCOPIRA_EXPORT
nindex(
size_t _x,
size_t _y,
size_t _z=0,
size_t _t=0);
617 SCOPIRA_EXPORT nindex(
size_t v=0);
619 SCOPIRA_EXPORT nindex(
const this_type &rhs);
622 { dm_ary[0] = v; dm_ary[1] = v; dm_ary[2] = v; dm_ary[3] = v; }
625 size_t product(
void)
const {
return dm_ary[0]*dm_ary[1]*dm_ary[2]*dm_ary[3]; }
627 size_t offset(
const this_type &c)
const {
return c.dm_ary[3]*dm_ary[2]*dm_ary[1]*dm_ary[0] + c.dm_ary[2]*dm_ary[1]*dm_ary[0] + c.dm_ary[1]*dm_ary[0] + c.dm_ary[0]; }
629 this_type
strides(
void)
const {
return this_type(1, dm_ary[0], dm_ary[0]*dm_ary[1], dm_ary[0]*dm_ary[1]*dm_ary[2]); }
631 static this_type
steps(
void) {
return this_type(0,1,2,3); }
636 bool operator < (
const this_type &rhs)
const {
return dm_ary[0]<rhs.dm_ary[0] && dm_ary[1]<rhs.dm_ary[1] && dm_ary[2]<rhs.dm_ary[2] && dm_ary[3]<rhs.dm_ary[3]; }
638 bool operator == (
const this_type &rhs)
const {
return dm_ary[0]==rhs.dm_ary[0] && dm_ary[1]==rhs.dm_ary[1] && dm_ary[2]==rhs.dm_ary[2] && dm_ary[3]==rhs.dm_ary[3]; }
640 size_t operator *(
const this_type &rhs)
const {
return dm_ary[0]*rhs.dm_ary[0] + dm_ary[1]*rhs.dm_ary[1] + dm_ary[2]*rhs.dm_ary[2] + dm_ary[3]*rhs.dm_ary[3]; }
642 const this_type & operator = (
const this_type &rhs) { dm_ary[0] = rhs.dm_ary[0]; dm_ary[1] = rhs.dm_ary[1]; dm_ary[2] = rhs.dm_ary[2]; dm_ary[3] = rhs.dm_ary[3];
return *
this; }
645 size_t &
x(
void) {
return dm_ary[0]; }
647 size_t x(
void)
const {
return dm_ary[0]; }
649 size_t &
y(
void) {
return dm_ary[1]; }
651 size_t y(
void)
const {
return dm_ary[1]; }
653 size_t &
z(
void) {
return dm_ary[2]; }
655 size_t z(
void)
const {
return dm_ary[2]; }
657 size_t &
t(
void) {
return dm_ary[3]; }
659 size_t t(
void)
const {
return dm_ary[3]; }
667 for (
int x=1; x<stride.
size(); ++x)
668 if (stride[x] != size[x-1])
688 for (
size_t i=0; i<scopira::tool::fixed_array<size_t,DIM>::size_c; ++i)
697 for (
size_t i=0; i<scopira::tool::fixed_array<size_t,DIM>::size_c; ++i)
707 for (
size_t i=0; i<scopira::tool::fixed_array<size_t,DIM>::size_c; ++i)
708 ret += (*
this)[i] * rhs[i];
724 size_t ret = 0, val = 1, i;
725 for (i=0; i<scopira::tool::fixed_array<size_t,DIM>::size_c; ++i) {
738 for (
size_t i=1; i<scopira::tool::fixed_array<size_t,DIM>::size_c; ++i)
739 ret[i] = ret[i-1] * (*
this)[i];
749 for (
size_t i=0; i<scopira::tool::fixed_array<size_t,DIM>::size_c; ++i)
760 for (
size_t i=0; i<scopira::tool::fixed_array<size_t,DIM>::size_c-1; ++i)
806 typedef size_t size_type;
807 typedef ptrdiff_t difference_type;
819 narray(
const this_type &src);
821 explicit narray(
const index_type &sz);
823 explicit narray(
size_t width,
size_t height);
843 const T *
c_array(
void)
const {
return dm_ary; }
848 iterator
begin(
void) {
return c_array(); }
850 iterator
end(
void) {
return c_array()+size(); }
852 const_iterator
begin(
void)
const {
return c_array(); }
854 const_iterator
end(
void)
const {
return c_array()+size(); }
857 bool empty(
void)
const {
return dm_len == 0; }
859 size_t size(
void)
const {
return dm_len; }
861 size_t width(
void)
const {
return dm_size[0]; }
863 size_t height(
void)
const {
return dm_size[1]; }
865 size_t depth(
void)
const {
return dm_size[2]; }
867 const index_type &
dimen(
void)
const {
return dm_size; }
906 void resize(
const index_type &news);
936 nslice<T,1> slicer(index_type base,
size_t len,
size_t direction = x_axis_c);
954 nslice<T,DIM-1> row_slice(
size_t r);
993 {
return slicer(base,
nindex<2>(width, height)); }
1007 const_nslice<T,1> slicer(index_type base,
size_t len,
size_t direction = x_axis_c)
const;
1058 {
return slicer(base,
nindex<2>(width, height)); }
1069 void copy(
const this_type &at);
1081 assert(
"[narray element access out of bounds]" && c<dm_size );
1082 return dm_ary[dm_size.
offset(c)];
1086 assert(
"[narray element access out of bounds]" && c<dm_size );
1087 return dm_ary[dm_size.
offset(c)];
1090 void set(index_type c, T v) {
1091 assert(
"[narray element access out of bounds]" && c<dm_size );
1092 dm_ary[dm_size.
offset(c)] = v;
1095 T
get(index_type c)
const {
1096 assert(
"[narray element access out of bounds]" && c<dm_size );
1097 return dm_ary[dm_size.
offset(c)];
1104 assert(
"[narray element access out of bounds]" && (idx < dm_len) );
1109 assert(
"[narray element access out of bounds]" && (idx < dm_len) );
1113 void set(
size_t idx, T v) {
1114 assert(
"[narray element access out of bounds]" && (idx < dm_len) );
1118 T
get(
size_t idx)
const {
1119 assert(
"[narray element access out of bounds]" && (idx < dm_len) );
1135 assert(
"[narray element access out of bounds]" && (x<width()) && (y<height()) );
1136 return dm_ary[x+y*width()];
1148 assert(
"[narray element access out of bounds]" && (x<width()) && (y<height()) );
1149 return dm_ary[x+y*width()];
1160 void set(
size_t x,
size_t y, T v) {
1161 assert(
"[narray element access out of bounds]" && (x<width()) && (y<height()) );
1162 dm_ary[x+y*width()] = v;
1173 T
get(
size_t x,
size_t y)
const {
1174 assert(
"[narray element access out of bounds]" && (x<width()) && (y<height()));
1175 return dm_ary[x+y*width()];
1191 assert(
"[narray element access out of bounds]" && (x<width()) && (y<height()) && (z<depth()));
1192 return dm_ary[x+y*width()+z*width()*height()];
1204 void set(
size_t x,
size_t y,
size_t z, T v) {
1205 assert(
"[narray element access out of bounds]" && (x<width()) && (y<height()) && (z<depth()));
1206 dm_ary[x+y*width()+z*width()*height()] = v;
1218 T
get(
size_t x,
size_t y,
size_t z)
const {
1219 assert(
"[narray element access out of bounds]" && (x<width()) && (y<height()) && (z<depth()));
1220 return dm_ary[x+y*width()+z*width()*height()];
1228 template <
class T,
int DIM>
1230 : dm_ary(0), dm_len(0), dm_direct(0)
1234 template <
class T,
int DIM>
1236 : dm_ary(0), dm_len(0), dm_direct(0)
1241 template <
class T,
int DIM>
1243 : dm_ary(0), dm_len(0), dm_direct(0)
1248 template <
class T,
int DIM>
1250 : dm_ary(0), dm_len(0), dm_direct(0)
1256 template <
class T,
int DIM>
1266 if (v == -10 || v == -11) {
1273 for (j=0; j<DIM; ++j) {
1278 for (j=0; j<DIM; ++j) {
1289 #ifdef PLATFORM_BYTESWAP 1300 for (j=1; j<DIM; ++j) {
1310 for (ii=begin(); ii != endii; ++ii)
1317 template <
class T,
int DIM>
1325 for (j=0; j<DIM; ++j)
1329 #ifdef PLATFORM_BYTESWAP 1331 head =
const_cast<T*
>(dm_ary);
1332 tail =
const_cast<T*
>(dm_ary + dm_len);
1336 #ifdef PLATFORM_BYTESWAP 1344 template <
class T,
int DIM>
1347 if (news == dm_size)
1351 assert(
"[resize attempted on DIRECT mode narray]" && news.
product() == 0);
1353 dm_direct->narray_delete(dm_ary, dm_len);
1369 dm_ary =
new T[dm_len];
1372 template <
class T,
int DIM>
1375 assert(
"[resize_direct may only be called on empty narrays]" && (dm_direct || empty()));
1379 dm_direct->narray_delete(dm_ary, dm_len);
1384 dm_direct = dm_len != 0 ? delfunc : 0;
1388 dm_ary = direct_ary;
1397 template <
class T,
int DIM>
1405 for (
size_t i=0; i<strides.size_c; ++i)
1406 strides[i] = size_strides[direction[i]];
1408 return nslice<T,SIM>(dm_ary, dm_size.offset(base), dimen, strides);
1411 template <
class T,
int DIM>
1419 template <
class T,
int DIM>
1426 template <
class T,
int DIM>
1429 assert(DIM == 2 &&
"[called diagonal_slice() on a non-matrix]\n");
1430 assert(dm_size[0] == dm_size[1] &&
"[diagonal_slice() matrix must be square]\n");
1431 return nslice<T,1>(dm_ary, 0, dm_size[0], dm_size[0]+1);
1434 template <
class T,
int DIM>
1440 template <
class T,
int DIM>
1448 template <
class T,
int DIM>
1456 for (
size_t i=0; i<strides.size_c; ++i)
1457 strides[i] = size_strides[direction[i]];
1462 template <
class T,
int DIM>
1470 template <
class T,
int DIM>
1472 size_t direction)
const 1477 template <
class T,
int DIM>
1480 assert(DIM == 2 &&
"[called diagonal_slice() on a non-matrix]\n");
1481 assert(dm_size[0] == dm_size[1] &&
"[diagonal_slice() matrix must be square]\n");
1485 template <
class T,
int DIM>
1491 template <
class T,
int DIM>
1499 template <
class T,
int DIM>
1506 for (ii=begin(); ii != endii; ++ii)
1510 template <
class T,
int DIM>
1524 for (ii=begin(); ii != endii; ++ii, ++kk)
1528 template <
class T,
int DIM>
1542 for (ii=begin(); ii != endii; ++ii, ++kk)
1546 template <
class T,
int DIM>
1560 for (ii=begin(); ii != endii; ++ii, ++kk)
1601 typedef size_t size_type;
1602 typedef ptrdiff_t difference_type;
1605 size_t dm_prime, dm_end_prime;
1613 index_type dm_stride;
1618 nslice(
const this_type &rhs);
1624 nslice(T * _var,
size_t _prime, index_type _size, index_type _stride);
1661 {
return niterator<T,DIM>( dm_var+dm_end_prime,
true, dm_size, dm_stride); }
1669 bool empty(
void)
const {
return dm_prime == dm_end_prime; }
1673 size_t width(
void)
const {
return dm_size[0]; }
1675 size_t height(
void)
const {
return dm_size[1]; }
1677 size_t depth(
void)
const {
return dm_size[2]; }
1679 const index_type &
dimen(
void)
const {
return dm_size; }
1718 void resize(
const index_type &news);
1791 void set_all(T v)
const;
1801 assert(
"[nslice element access out of bounds]" && idx < dm_size && dm_var);
1802 return dm_var[dm_prime + (idx*dm_stride)];
1809 assert(
"[nslice element access out of bounds]" && idx < dm_size[0] && DIM==1);
1810 return dm_var[dm_prime+idx*dm_stride[0]];
1813 void set(
size_t idx, T v)
const {
1814 assert(
"[nslice element access out of bounds]" && idx < dm_size[0] && DIM==1);
1815 dm_var[dm_prime+idx*dm_stride[0]] = v;
1818 T
get(
size_t idx)
const {
1819 assert(
"[nslice element access out of bounds]" && idx < dm_size[0] && DIM==1);
1820 return dm_var[dm_prime+idx*dm_stride[0]];
1835 assert(
"[nslice element access out of bounds]" && (x<
width()) && (y<
height()) );
1836 return dm_var[dm_prime+x*dm_stride[0]+y*dm_stride[1]];
1847 void set(
size_t x,
size_t y, T v)
const {
1848 assert(
"[nslice element access out of bounds]" && (x<
width()) && (y<
height()) );
1849 dm_var[dm_prime+x*dm_stride[0]+y*dm_stride[1]] = v;
1860 T
get(
size_t x,
size_t y)
const {
1861 assert(
"[nslice element access out of bounds]" && (x<
width()) && (y<
height()));
1862 return dm_var[dm_prime+x*dm_stride[0]+y*dm_stride[1]];
1878 assert(
"[nslice element access out of bounds]" && (x<
width()) && (y<
height()) && (z<
depth()));
1879 return dm_var[dm_prime+x*dm_stride[0]+y*dm_stride[1]+z*dm_stride[2]];
1891 void set(
size_t x,
size_t y,
size_t z, T v)
const {
1892 assert(
"[nslice element access out of bounds]" && (x<
width()) && (y<
height()) && (z<
depth()));
1893 dm_var[dm_prime+x*dm_stride[0]+y*dm_stride[1]+z*dm_stride[2]] = v;
1905 T
get(
size_t x,
size_t y,
size_t z)
const {
1906 assert(
"[nslice element access out of bounds]" && (x<
width()) && (y<
height()) && (z<
depth()));
1907 return dm_var[dm_prime+x*dm_stride[0]+y*dm_stride[1]+z*dm_stride[2]];
1925 template <
class T,
int DIM>
1931 template <
class T,
int DIM>
1933 : dm_var(rhs.dm_var), dm_prime(rhs.dm_prime), dm_end_prime(rhs.dm_end_prime),
1934 dm_size(rhs.dm_size), dm_stride(rhs.dm_stride)
1938 template <
class T,
int DIM>
1944 template <
class T,
int DIM>
1950 template <
class T,
int DIM>
1952 : dm_var(_var), dm_prime(_prime),
1953 dm_size(_size), dm_stride(_stride)
1955 dm_end_prime = dm_prime + dm_stride[DIM-1]*dm_size[DIM-1];
1958 template <
class T,
int DIM>
1972 for (i=0; i<DIM; ++i)
1977 #ifndef PLATFORM_BYTESWAP 1991 if (left>buf.
size())
2000 #ifdef PLATFORM_BYTESWAP 2004 for (; jj != endjj; ++jj, ++ii)
2012 template <
class T,
int DIM>
2020 for (j=0; j<DIM; ++j)
2026 #ifndef PLATFORM_BYTESWAP 2038 while (ii != endii) {
2039 for (jj=buf.
begin(), endjj=buf.
end(); jj != endjj && ii != endii; ++jj, ++ii)
2041 #ifdef PLATFORM_BYTESWAP 2048 template <
class T,
int DIM>
2052 dm_end_prime = dm_prime + dm_stride[DIM-1]*dm_size[DIM-1];
2055 template <
class T,
int DIM>
2062 for (
size_t i=0; i<strides.size_c; ++i)
2063 strides[i] = dm_stride[direction[i]];
2065 return nslice<T,SIM>(dm_var, dm_prime+(base*dm_stride), dimen, strides);
2068 template <
class T,
int DIM>
2076 template <
class T,
int DIM>
2078 size_t direction)
const 2083 template <
class T,
int DIM>
2086 assert(DIM == 2 &&
"[called diagonal_slice() on a non-matrix]\n");
2087 assert(dm_size[0] == dm_size[1] &&
"[diagonal_slice() matrix must be square]\n");
2091 template <
class T,
int DIM>
2097 template <
class T,
int DIM>
2105 template <
class T,
int DIM>
2112 for (ii=
begin(); ii != endii; ++ii)
2116 template <
class T,
int DIM>
2130 for (ii=
begin(); ii != endii; ++ii, ++kk)
2134 template <
class T,
int DIM>
2148 for (ii=
begin(); ii != endii; ++ii, ++kk)
2152 template <
class T,
int DIM>
2166 for (ii=
begin(); ii != endii; ++ii, ++kk)
2176 template <
class T,
int DIM>
2193 T& operator *(
void) {
return *dm_ptr; }
2195 bool operator ==(
const this_type &rhs)
const {
return dm_cur == rhs.dm_cur; }
2197 bool operator !=(
const this_type &rhs)
const {
return !(dm_cur == rhs.dm_cur); }
2200 this_type operator++(
void);
2202 this_type operator--(
void);
2208 return (dm_cur[0] - rhs.dm_cur[0]) / dm_stride[0]; }
2213 ret.dm_ptr = dm_ptr + idx;
2214 ret.dm_cur[0] = dm_cur[0] + idx * dm_stride[0];
2215 ret.dm_size = dm_size;
2216 ret.dm_stride = dm_stride;
2223 ret.dm_ptr = dm_ptr - idx;
2224 ret.dm_cur[0] = dm_cur[0] - idx * dm_stride[0];
2225 ret.dm_size = dm_size;
2226 ret.dm_stride = dm_stride;
2232 return dm_cur[0] < rhs.dm_cur[0]; }
2235 template <
class T,
int DIM>
2240 template <
class T,
int DIM>
2242 : dm_ptr(ptr), dm_cur(0), dm_size(_size), dm_stride(_stride)
2245 dm_cur[DIM-1] = dm_size[DIM-1];
2248 template <
class T,
int DIM>
2251 dm_ptr += dm_stride[0];
2253 for (
size_t j=0; dm_cur[j] >= dm_size[j] && j+1<DIM; ++j) {
2255 dm_ptr += -1 * dm_stride[j]*dm_cur[j] + dm_stride[j + 1];
2262 template <
class T,
int DIM>
2265 for (
size_t j=0; j<DIM; ++j) {
2267 if (dm_cur[j] > 0) {
2270 dm_ptr -= dm_stride[j];
2275 dm_cur[j] = dm_size[j]-1;
2276 dm_ptr += dm_stride[j]*dm_cur[j];
2304 typedef T value_type;
2306 typedef T& reference;
2307 typedef const T& const_reference;
2308 typedef size_t size_type;
2309 typedef ptrdiff_t difference_type;
2312 size_t dm_prime, dm_end_prime;
2313 index_type dm_size, dm_stride;
2324 const_nslice(
const T * _var,
size_t _prime, index_type _size, index_type _stride);
2363 bool empty(
void)
const {
return dm_prime == dm_end_prime; }
2365 size_t size(
void)
const {
return dm_size.product(); }
2367 size_t width(
void)
const {
return dm_size[0]; }
2369 size_t height(
void)
const {
return dm_size[1]; }
2371 size_t depth(
void)
const {
return dm_size[2]; }
2373 const index_type &
dimen(
void)
const {
return dm_size; }
2412 void resize(
const index_type &news);
2423 const_nslice<T,1> slicer(index_type base,
size_t len,
size_t direction = 0)
const;
2480 {
return slicer(base,
nindex<2>(width, height)); }
2484 assert(
"[const_nslice element access out of bounds]" && idx < dm_size && dm_var);
2485 return dm_var[dm_prime + (idx*dm_stride)];
2492 assert(
"[const_nslice element access out of bounds]" && idx < dm_size[0] && DIM==1);
2493 return dm_var[dm_prime+idx*dm_stride[0]];
2496 T
get(
size_t idx)
const {
2497 assert(
"[const_nslice element access out of bounds]" && idx < dm_size[0] && DIM==1);
2498 return dm_var[dm_prime+idx*dm_stride[0]];
2513 assert(
"[const_nslice element access out of bounds]" && (x<width()) && (y<height()) );
2514 return dm_var[dm_prime+x*dm_stride[0]+y*dm_stride[1]];
2525 T
get(
size_t x,
size_t y)
const {
2526 assert(
"[const_nslice element access out of bounds]" && (x<width()) && (y<height()) );
2527 return dm_var[dm_prime+x*dm_stride[0]+y*dm_stride[1]];
2543 assert(
"[nslice element access out of bounds]" && (x<width()) && (y<height()) && (z<depth()));
2544 return dm_var[dm_prime+x*dm_stride[0]+y*dm_stride[1]+z*dm_stride[2]];
2556 T
get(
size_t x,
size_t y,
size_t z)
const {
2557 assert(
"[nslice element access out of bounds]" && (x<width()) && (y<height()) && (z<depth()));
2558 return dm_var[dm_prime+x*dm_stride[0]+y*dm_stride[1]+z*dm_stride[2]];
2576 template <
class T,
int DIM>
2582 template <
class T,
int DIM>
2584 : dm_var(rhs.dm_var), dm_prime(rhs.dm_prime), dm_end_prime(rhs.dm_end_prime),
2585 dm_size(rhs.dm_size), dm_stride(rhs.dm_stride)
2589 template <
class T,
int DIM>
2592 assert(DIM == 2 &&
"[called diagonal_slice() on a non-matrix]\n");
2593 assert(dm_size[0] == dm_size[1] &&
"[diagonal_slice() matrix must be square]\n");
2597 template <
class T,
int DIM>
2603 template <
class T,
int DIM>
2609 template <
class T,
int DIM>
2611 : dm_var(_var), dm_prime(_prime),
2612 dm_size(_size), dm_stride(_stride)
2614 dm_end_prime = dm_prime + dm_stride[DIM-1]*dm_size[DIM-1];
2617 template <
class T,
int DIM>
2619 : dm_var(rhs.dm_var), dm_prime(rhs.dm_prime), dm_end_prime(rhs.dm_end_prime),
2620 dm_size(rhs.dm_size), dm_stride(rhs.dm_stride)
2624 template <
class T,
int DIM>
2632 for (j=0; j<DIM; ++j)
2638 #ifndef PLATFORM_BYTESWAP 2650 while (ii != endii) {
2651 for (jj=buf.
begin(), endjj=buf.
end(); jj != endjj && ii != endii; ++jj, ++ii)
2653 #ifdef PLATFORM_BYTESWAP 2660 template <
class T,
int DIM>
2664 dm_end_prime = dm_prime + dm_stride[DIM-1]*dm_size[DIM-1];
2667 template <
class T,
int DIM>
2674 for (
size_t i=0; i<strides.size_c; ++i)
2675 strides[i] = dm_stride[direction[i]];
2680 template <
class T,
int DIM>
2688 template <
class T,
int DIM>
2690 size_t direction)
const 2695 template <
class T,
int DIM>
2701 template <
class T,
int DIM>
2715 template <
class T,
int DIM>
2732 const T& operator *(
void) {
return *dm_ptr; }
2734 bool operator ==(
const this_type &rhs)
const {
return dm_cur == rhs.dm_cur; }
2736 bool operator !=(
const this_type &rhs)
const {
return !(dm_cur == rhs.dm_cur); }
2739 void operator++(
void);
2741 void operator--(
void);
2747 return (dm_cur[0] - rhs.dm_cur[0]) / dm_stride[0]; }
2752 ret.dm_ptr = dm_ptr + idx;
2753 ret.dm_cur[0] = dm_cur[0] + idx * dm_stride[0];
2754 ret.dm_size = dm_size;
2755 ret.dm_stride = dm_stride;
2762 ret.dm_ptr = dm_ptr - idx;
2763 ret.dm_cur[0] = dm_cur[0] - idx * dm_stride[0];
2764 ret.dm_size = dm_size;
2765 ret.dm_stride = dm_stride;
2771 return dm_cur[0] < rhs.dm_cur[0]; }
2774 template <
class T,
int DIM>
2779 template <
class T,
int DIM>
2781 : dm_ptr(ptr), dm_cur(0), dm_size(_size), dm_stride(_stride)
2784 dm_cur[DIM-1] = dm_size[DIM-1];
2787 template <
class T,
int DIM>
2790 dm_ptr += dm_stride[0];
2792 for (
size_t j=0; dm_cur[j] >= dm_size[j] && j+1<DIM; ++j) {
2794 dm_ptr += -1*dm_stride[j]*dm_cur[j] + dm_stride[j + 1];
2800 template <
class T,
int DIM>
2803 for (
size_t j=0; j<DIM; ++j) {
2805 if (dm_cur[j] > 0) {
2808 dm_ptr -= dm_stride[j];
2813 dm_cur[j] = dm_size[j]-1;
2814 dm_ptr += dm_stride[j]*dm_cur[j];
2842 : narray_parent_type(src) { }
2845 : narray_parent_type(src) { }
2848 : narray_parent_type(sz) { }
2851 : narray_parent_type(width, height) { }
2874 template <
typename T>
struct iterator_traits<
scopira::basekit::niterator<T,1> >
2877 typedef std::random_access_iterator_tag iterator_category;
2878 typedef T value_type;
2879 typedef ptrdiff_t difference_type;
2881 typedef T& reference;
2895 flow_printf(o,
" %8ld", el);
2902 flow_printf(o,
" %8lu", el);
2909 flow_printf(o,
" %8d", el);
2916 flow_printf(o,
" %8u", el);
2923 flow_printf(o,
" %8d", el);
2930 flow_printf(o,
" %4d", el);
2937 flow_printf(o,
" %8.2f", el);
2944 flow_printf(o,
" %8.2f", el);
2955 o <<
"Vector, len=" << mx <<
":";
2956 for (i=0; i<mx; i++) {
2958 flow_printf(o,
"\n %4d:", i);
2975 flow_printf(o,
"Matrix, w=%d h=%d:\n ", w, h);
2977 flow_printf(o,
" %7d:", x);
2979 for (y=0; y<h; y++) {
2980 flow_printf(o,
" %4d: ", y);
2996 for (k=0, kmax=A.
size_rows(); k<kmax; ++k) {
2997 o <<
"Sub Slice (depth=" << DIM <<
") " << k <<
":\n";
3031 return o << scopira::basekit::const_nslice<T, DIM>(A);
3038 template <
class T,
int DIM>
3050 template <
class T,
int DIM>
3067 for (
size_t x=1; x<DIM; ++x)
3079 o <<
"Vector, len=" << mx <<
":";
3080 for (i=0; i<mx; i++) {
3082 o <<
"\n " << std::setw(4) << i <<
":";
3084 o << std::setw(14) << V[i];
3100 o <<
"Matrix, w=" << w <<
" h=" << h <<
":\n ";
3102 o << std::setw(13) << x <<
':';
3104 for (y=0; y<h; y++) {
3105 o << std::setw(4) << y <<
':';
3107 o << std::setw(14) << M(x,y);
3117 template <
class T,
int DIM> std::ostream & operator << (std::ostream &o,
3121 for (k=0, kmax=A.
size_rows(); k<kmax; ++k) {
3122 o <<
"Sub Slice (depth=" << DIM <<
") " << k <<
":\n";
3133 template <
class T>
inline std::ostream & operator << (std::ostream &o,
3143 template <
class T>
inline std::ostream & operator << (std::ostream &o,
3153 template <
class T,
int DIM>
inline std::ostream & operator << (std::ostream &o,
3156 return o << scopira::basekit::const_nslice<T, DIM>(A);
3163 template <
class T,
int DIM>
3165 std::ostream & operator << (std::ostream &o,
3175 template <
class T,
int DIM>
3177 std::ostream & operator << (std::ostream &o,
3188 std::ostream & operator << (std::ostream &o,
3192 for (
size_t x=1; x<DIM; ++x)
size_t product(void) const
gets it multed
Definition: narray.h:625
bool is_flat_stride(void) const
Definition: narray.h:1916
nindex(void)
ctor, that does nothing
Definition: narray.h:422
narray< float, 4 > floatquad_t
Definition: narray.h:273
narray_o< double, 4 > doublequad_o
Definition: narray.h:402
const index_type & dimen(void) const
gets the width
Definition: narray.h:1679
T & operator()(size_t x, size_t y, size_t z)
Definition: narray.h:1190
const_niterator< T, DIM > begin(void) const
Definition: narray.h:2347
void clear(void)
set all to 0
Definition: narray.h:1789
this_type operator+(ptrdiff_t idx) const
Random iteration support method.
Definition: narray.h:2749
void operator--(void)
Decrement.
Definition: narray.h:2801
T operator()(index_type c) const
[] ref
Definition: narray.h:1080
narray< double, 1 > doublevec_t
Definition: narray.h:185
void print_element< long >(scopira::tool::oflow_i &o, long el)
element printing helper (specialization)
Definition: narray.h:2893
narray< short, 2 > shortmatrix_t
Definition: narray.h:201
void clear(size_t v=0)
clear
Definition: narray.h:508
size_t x(void) const
ref access
Definition: narray.h:484
this_type operator-(ptrdiff_t idx) const
Random iteration support method.
Definition: narray.h:2759
narray< double, 2 > doublematrix_t
Definition: narray.h:216
size_t operator*(const this_type &rhs) const
multiplication
Definition: narray.h:704
size_t width(void) const
width
Definition: narray.h:2367
narray_o< int, 1 > intvec_o
Definition: narray.h:299
size_t offset(const this_type &c) const
calc ofset, using this as the size
Definition: narray.h:464
T & operator()(size_t x, size_t y, size_t z) const
Definition: narray.h:2542
virtual void narray_delete(void *mem, size_t len)=0
static this_type steps(void)
returns [0,1]
Definition: narray.h:518
bool operator==(const this_type &rhs) const
equality
Definition: narray.h:695
const_niterator(void)
ctor
Definition: narray.h:2775
Definition: archiveflow.h:20
const_nslice< T, 2 > xyslice(size_t basex, size_t basey, size_t width, size_t height) const
matrix slice
Definition: narray.h:2460
virtual void save(scopira::tool::oobjflow_i &out) const
Definition: narray.h:2856
nslice< T, DIM > all_slice(void) const
all slice
Definition: narray.h:2092
nindex< 1 > shrink(void) const
returns the same, but one less
Definition: narray.h:520
nslice< T, SIM > slicer(index_type base, nindex< SIM > dimen, nindex< SIM > direction) const
nindex< 2 > shrink(void) const
returns the same, but one less
Definition: narray.h:576
nslice< T, 2 > xyslice(index_type base, size_t width, size_t height) const
matrix slice
Definition: narray.h:1785
void print_element(scopira::tool::oflow_i &o, E el)
element printing helper
Definition: narray.h:2886
size_t x(void) const
ref access
Definition: narray.h:647
void clear(size_t v=0)
clear
Definition: narray.h:621
void clear(size_t v=0)
clear
Definition: narray.h:459
const_nslice< T, 1 > tslice(index_type base, size_t len) const
vector slice
Definition: narray.h:1053
nslice< T, 1 > diagonal_slice(void)
Definition: narray.h:2084
nindex(size_t v=0)
ctor (implicit)
Definition: narray.h:457
nslice< T, DIM-1 > row_slice(size_t r)
get a particular row
Definition: narray.h:1441
size_t y(void) const
ref access
Definition: narray.h:538
const_nslice< T, 1 > xslice(size_t basex, size_t basey, size_t len) const
vector slice
Definition: narray.h:1032
size_t height(void) const
height
Definition: narray.h:863
~narray(void)
dtor
Definition: narray.h:825
const T operator[](size_t idx) const
Nice, referece-based element access.
Definition: narray.h:1103
bool is_null(void) const
is the slice "null", ie not pointing to ANYTHING
Definition: narray.h:2358
narray_o< double, 2 > doublematrix_o
Definition: narray.h:340
bool operator<(const this_type &rhs) const
Random iteration support method.
Definition: narray.h:2769
size_t product(void) const
gets it multed
Definition: narray.h:568
size_t offset(const this_type &c) const
calc ofset, using this as the size
Definition: narray.h:627
const_nslice< T, 1 > xslice(index_type base, size_t len) const
vector slice
Definition: narray.h:2466
void resize(size_t neww, size_t newh, size_t newd)
Definition: narray.h:898
const_nslice< T, 1 > yslice(size_t basex, size_t basey, size_t len) const
vector slice
Definition: narray.h:1035
this_type strides(void) const
stride offset array
Definition: narray.h:516
nslice< T, 1 > zslice(index_type base, size_t len)
vector slice
Definition: narray.h:985
const_nslice< T, 2 > xyslice(size_t basex, size_t basey, size_t width, size_t height) const
matrix slice
Definition: narray.h:1038
niterator(void)
ctor
Definition: narray.h:2236
scopira::tool::oflow_i & print_vector_slice(scopira::tool::oflow_i &o, const const_nslice< C, 1 > &V)
internal
Definition: narray.h:2950
narray_o< double, 1 > doublevec_o
Definition: narray.h:309
const T * c_array(void) const
gets the slice as a raw C array. only valid if the X stride is 1
Definition: narray.h:2340
bool is_flat_stride(void) const
Definition: narray.h:2567
void set_null(void)
sets thte slice to null
Definition: narray.h:1666
T data_type
the element type this const_niterator
Definition: narray.h:2720
ptrdiff_t operator-(const this_type &rhs) const
Random iteration support method.
Definition: narray.h:2206
narray_o< int, 2 > intmatrix_o
Definition: narray.h:330
size_t y(void) const
ref access
Definition: narray.h:651
const index_type & dimen(void) const
gets the size of this array
Definition: narray.h:867
size_t size(void) const
gets the size (1D)
Definition: narray.h:859
bool load(scopira::tool::itflow_i &in)
Definition: narray.h:1257
static this_type steps(void)
returns [0,1,2,3]
Definition: narray.h:631
T & operator()(index_type idx) const
access, by index
Definition: narray.h:1800
this_type strides(void) const
stride offset array
Definition: narray.h:572
void print_element< unsigned long >(scopira::tool::oflow_i &o, unsigned long el)
element printing helper (specialization)
Definition: narray.h:2900
T operator[](size_t idx) const
Nice, referece-based element access.
Definition: narray.h:2491
narray_o< char, 4 > charquad_o
Definition: narray.h:382
T & operator[](size_t idx) const
Nice, referece-based element access.
Definition: narray.h:1808
this_type strides(void) const
calc a stride value array, using this as the size
Definition: narray.h:733
narray< float, 3 > floatcube_t
Definition: narray.h:242
const_nslice< T, DIM > all_slice(void) const
all slice
Definition: narray.h:2696
void resize(size_t len)
Definition: narray.h:1689
niterator< T, DIM > begin(void) const
Definition: narray.h:1653
void resize(size_t len)
Definition: narray.h:2383
const_nslice< T, 1 > xslice(index_type base, size_t len) const
vector slice
Definition: narray.h:1044
nslice< T, 1 > xslice(index_type base, size_t len)
vector slice
Definition: narray.h:979
narray< bool, 3 > boolcube_t
Definition: narray.h:222
nslice< T, 1 > yslice(index_type base, size_t len) const
vector slice
Definition: narray.h:1775
narray< short, 4 > shortquad_t
Definition: narray.h:263
nindex(size_t _x, size_t _y)
ctor
Definition: narray.h:504
narray_o< double, 3 > doublecube_o
Definition: narray.h:371
narray_delete_i * normal_narray_delete
void operator++(void)
Increment.
Definition: narray.h:2788
this_type operator++(void)
Increment.
Definition: narray.h:2249
void print_element< double >(scopira::tool::oflow_i &o, double el)
element printing helper (specialization)
Definition: narray.h:2935
const_nslice< T, 2 > xyslice(index_type base, size_t width, size_t height) const
matrix slice
Definition: narray.h:2479
iterator begin(void)
begin-stl like iterator
Definition: narray.h:848
nindex< DIM-1 > shrink(void) const
returns the same, but one less
Definition: narray.h:756
narray< char, 4 > charquad_t
Definition: narray.h:258
void resize_direct(index_type sz, T *direct_ary, scopira::basekit::narray_delete_i *delfunc=null_narray_delete)
Definition: narray.h:1373
const_nslice< T, SIM > slicer(index_type base, nindex< SIM > dimen, nindex< SIM > direction) const
size_t & t(void)
ref access
Definition: narray.h:657
this_type operator+(ptrdiff_t idx) const
Random iteration support method.
Definition: narray.h:2210
size_t product(void) const
Return the product of this coord.
Definition: narray.h:713
size_t & y(void)
ref access
Definition: narray.h:536
this_type strides(void) const
stride offset array
Definition: narray.h:466
size_t depth(void) const
depth
Definition: narray.h:865
ptrdiff_t operator-(const this_type &rhs) const
Random iteration support method.
Definition: narray.h:2745
nslice< T, 1 > yslice(size_t basex, size_t basey, size_t len)
vector slice
Definition: narray.h:970
void save(scopira::tool::otflow_i &out) const
Definition: narray.h:2013
nslice< T, SIM > slicer(index_type base, nindex< SIM > dimen, nindex< SIM > direction)
main slicer
void resize(size_t neww, size_t newh)
Definition: narray.h:887
narray_o< char, 3 > charcube_o
Definition: narray.h:351
bool operator<(const this_type &rhs) const
comparison
Definition: narray.h:686
T operator()(size_t x, size_t y) const
Definition: narray.h:2512
narray_o< int, 4 > intquad_o
Definition: narray.h:392
nindex< DIM > index_type
the index type that this narray likes (usually an nindex type)
Definition: narray.h:795
nslice< T, 1 > yslice(size_t basex, size_t basey, size_t len) const
vector slice
Definition: narray.h:1763
T & operator[](size_t idx)
Nice, referece-based element access.
Definition: narray.h:1108
size_t & y(void)
ref access
Definition: narray.h:592
narray_o< float, 3 > floatcube_o
Definition: narray.h:366
nslice< T, 1 > xslice(size_t basex, size_t len)
vector to vector
Definition: narray.h:961
narray< int, 3 > intcube_t
Definition: narray.h:237
narray(void)
in direct mode? if non null, this will be the handler
Definition: narray.h:1229
size_t product(void) const
gets it multed
Definition: narray.h:462
T & operator()(size_t x, size_t y) const
Definition: narray.h:1834
T & operator()(size_t x, size_t y)
Definition: narray.h:1147
size_t offset(const this_type &c) const
calc ofset, using this as the size
Definition: narray.h:514
narray< int, 4 > intquad_t
Definition: narray.h:268
void print_element< unsigned int >(scopira::tool::oflow_i &o, unsigned int el)
element printing helper (specialization)
Definition: narray.h:2914
nindex(size_t v=0)
ctor (implicit)
Definition: narray.h:506
narray< char, 2 > charmatrix_t
Definition: narray.h:196
narray_o(const this_type &src)
copy ctor
Definition: narray.h:2841
size_t y(void) const
ref access
Definition: narray.h:594
const_nslice< T, 1 > zslice(index_type base, size_t len) const
vector slice
Definition: narray.h:1050
size_t height(void) const
height
Definition: narray.h:2369
nslice< T, 1 > diagonal_slice(void)
Definition: narray.h:1427
void operator=(const this_type &at)
this turns out to be very handy
Definition: narray.h:1075
scopira::tool::oflow_i & print_matrix_slice(scopira::tool::oflow_i &o, const const_nslice< C, 2 > &M)
internal
Definition: narray.h:2968
size_t & x(void)
ref access
Definition: narray.h:482
narray< float, 1 > floatvec_t
Definition: narray.h:180
narray< char, 1 > charvec_t
Definition: narray.h:165
narray< double, 3 > doublecube_t
Definition: narray.h:247
size_t t(void) const
ref access
Definition: narray.h:659
size_t width(void) const
width
Definition: narray.h:1673
const_nslice< T, 1 > yslice(index_type base, size_t len) const
vector slice
Definition: narray.h:2469
narray< double, 4 > doublequad_t
Definition: narray.h:278
const_nslice< T, 2 > xyslice(index_type base, size_t width, size_t height) const
matrix slice
Definition: narray.h:1057
nslice(void)
default ctor, makes a null slice
Definition: narray.h:1926
narray_o< bool, 1 > boolvec_o
Definition: narray.h:284
size_t size(void) const
gets the size (1D)
Definition: narray.h:2365
bool empty(void) const
empty?
Definition: narray.h:2363
size_t & x(void)
ref access
Definition: narray.h:588
narray< int, 1 > intvec_t
Definition: narray.h:175
T & operator()(size_t x, size_t y, size_t z) const
Definition: narray.h:1877
size_t & x(void)
ref access
Definition: narray.h:532
static this_type steps(void)
returns [0,1,2]
Definition: narray.h:574
T * c_array(void) const
Definition: narray.h:1646
nslice< T, DIM-1 > row_slice(size_t r) const
get a particular row
Definition: narray.h:2098
scopira::basekit::narray_delete_i * get_direct(void) const
gets the direct status/handler. non-null for direct mode
Definition: narray.h:923
size_t & x(void)
ref access
Definition: narray.h:645
size_t height(void) const
height
Definition: narray.h:1675
nslice< T, 1 > xslice(size_t basex, size_t basey, size_t len) const
vector slice
Definition: narray.h:1760
narray_o< char, 1 > charvec_o
Definition: narray.h:289
narray< char, 3 > charcube_t
Definition: narray.h:227
iterator end(void)
end-stl like iterator
Definition: narray.h:850
virtual bool load(scopira::tool::iobjflow_i &in)
Definition: narray.h:2855
void set_all(T v)
set all the elements
Definition: narray.h:1500
T data_type
the element data type of this iterator
Definition: narray.h:2181
const T operator()(size_t x, size_t y) const
Definition: narray.h:1134
nslice< T, 1 > tslice(index_type base, size_t len)
vector slice
Definition: narray.h:988
void set_xy(size_t _x, size_t _y)
2-set
Definition: narray.h:541
narray< bool, 2 > boolmatrix_t
Definition: narray.h:191
void print_element< char >(scopira::tool::oflow_i &o, char el)
element printing helper (specialization)
Definition: narray.h:2928
const_iterator begin(void) const
begin-stl like iterator
Definition: narray.h:852
bool operator<(const this_type &rhs) const
Random iteration support method.
Definition: narray.h:2230
narray< short, 3 > shortcube_t
Definition: narray.h:232
size_t & y(void)
ref access
Definition: narray.h:649
nslice< T, 1 > zslice(index_type base, size_t len) const
vector slice
Definition: narray.h:1778
nindex< 1 > shrink(void) const
returns the same, but one less
Definition: narray.h:470
void resize(size_t neww, size_t newh, size_t newd)
Definition: narray.h:2404
const T * c_array(void) const
raw c-array style access
Definition: narray.h:843
bool is_null(void) const
is the slice "null", ie not pointing to ANYTHING
Definition: narray.h:1664
const_nslice< T, 1 > zslice(index_type base, size_t len) const
vector slice
Definition: narray.h:2472
narray< bool, 1 > boolvec_t
Definition: narray.h:151
narray< float, 2 > floatmatrix_t
Definition: narray.h:211
const_nslice< T, DIM-1 > row_slice(size_t r) const
get a particular row
Definition: narray.h:2702
nslice< T, 1 > tslice(index_type base, size_t len) const
vector slice
Definition: narray.h:1781
size_t product(void) const
gets it multed
Definition: narray.h:512
narray_o< short, 3 > shortcube_o
Definition: narray.h:356
size_t & z(void)
ref access
Definition: narray.h:596
void resize(size_t neww, size_t newh, size_t newd)
Definition: narray.h:1710
void copy(const narray< T, DIM > &at)
copy
Definition: narray.h:2117
this_type strides(void) const
stride offset array
Definition: narray.h:629
size_t width(void) const
width
Definition: narray.h:861
narray_o(const nindex< DIM > &sz)
sizing
Definition: narray.h:2847
const index_type & dimen(void) const
gets the size of this array
Definition: narray.h:2373
narray_delete_i * null_narray_delete
narray_o< bool, 3 > boolcube_o
Definition: narray.h:346
T & operator()(index_type c)
[] ref
Definition: narray.h:1085
nindex< 3 > shrink(void) const
returns the same, but one less
Definition: narray.h:633
narray_o(size_t width, size_t height)
sizing
Definition: narray.h:2850
size_t size_rows(void) const
number of rows
Definition: narray.h:2439
const_nslice< T, 1 > xslice(size_t basex, size_t len) const
vector to vector
Definition: narray.h:1026
this_type operator-(ptrdiff_t idx) const
Random iteration support method.
Definition: narray.h:2220
const_nslice< T, 1 > yslice(index_type base, size_t len) const
vector slice
Definition: narray.h:1047
void save(scopira::tool::otflow_i &out) const
Definition: narray.h:1318
bool empty(void) const
empty?
Definition: narray.h:857
size_t x(void) const
ref access
Definition: narray.h:534
const_nslice(void)
default ctor, makes a null slice
Definition: narray.h:2577
void copy(const this_type &at)
deep copy
Definition: narray.h:1511
size_t z(void) const
ref access
Definition: narray.h:655
const_nslice< T, 1 > yslice(size_t basex, size_t basey, size_t len) const
vector slice
Definition: narray.h:2457
void save(scopira::tool::otflow_i &out) const
Definition: narray.h:2625
narray_o< short, 2 > shortmatrix_o
Definition: narray.h:325
nslice< T, 2 > xyslice(size_t basex, size_t basey, size_t width, size_t height) const
matrix slice
Definition: narray.h:1766
void clear(void)
set all to 0
Definition: narray.h:1065
narray_o< float, 4 > floatquad_o
Definition: narray.h:397
nslice< T, 1 > xslice(size_t basex, size_t len) const
vector to vector
Definition: narray.h:1754
void resize(size_t neww, size_t newh)
Definition: narray.h:2393
size_t offset(const this_type &c) const
calc ofset, using this as the size
Definition: narray.h:722
narray< short, 1 > shortvec_t
Definition: narray.h:170
size_t x(void) const
ref access
Definition: narray.h:590
void clear(size_t v=0)
clear
Definition: narray.h:564
const_nslice< T, 1 > xslice(size_t basex, size_t len) const
vector to vector
Definition: narray.h:2448
static this_type steps(void)
make a stair case step wise style 0, 1, 2, 3 etc
Definition: narray.h:745
narray_o(void)
default
Definition: narray.h:2839
const_niterator< T, DIM > end(void) const
Definition: narray.h:2354
narray< bool, 4 > boolquad_t
Definition: narray.h:253
T data_type
the type of the elements in the narray
Definition: narray.h:793
niterator< T, DIM > end(void) const
Definition: narray.h:1660
T operator()(index_type idx) const
access, by index
Definition: narray.h:2483
nslice< T, 2 > xyslice(index_type base, size_t width, size_t height)
matrix slice
Definition: narray.h:992
const_nslice< T, 1 > diagonal_slice(void)
Definition: narray.h:2590
this_type operator--(void)
Decrement.
Definition: narray.h:2263
narray_o< float, 1 > floatvec_o
Definition: narray.h:304
static this_type steps(void)
returns [0]
Definition: narray.h:468
size_t offset(const this_type &c) const
calc ofset, using this as the size
Definition: narray.h:570
size_t size_rows(void) const
number of rows
Definition: narray.h:952
size_t size(void) const
gets the size (1D)
Definition: narray.h:1671
narray_o< float, 2 > floatmatrix_o
Definition: narray.h:335
const_nslice< T, 1 > xslice(size_t basex, size_t basey, size_t len) const
vector slice
Definition: narray.h:2454
const_nslice< T, 1 > tslice(index_type base, size_t len) const
vector slice
Definition: narray.h:2475
void print_element< short >(scopira::tool::oflow_i &o, short el)
element printing helper (specialization)
Definition: narray.h:2921
size_t size_rows(void) const
number of rows
Definition: narray.h:1745
nslice< T, 2 > xyslice(size_t basex, size_t basey, size_t width, size_t height)
matrix slice
Definition: narray.h:973
narray_o< bool, 2 > boolmatrix_o
Definition: narray.h:315
nslice< T, 1 > xslice(index_type base, size_t len) const
vector slice
Definition: narray.h:1772
T * iterator
the interator type
Definition: narray.h:797
nslice< T, DIM > all_slice(void)
all slice
Definition: narray.h:1435
nslice< T, 1 > xslice(size_t basex, size_t basey, size_t len)
vector slice
Definition: narray.h:967
narray_o(const narray_parent_type &src)
copy ctor
Definition: narray.h:2844
narray_o< bool, 4 > boolquad_o
Definition: narray.h:377
narray_o< char, 2 > charmatrix_o
Definition: narray.h:320
nslice< T, 1 > yslice(index_type base, size_t len)
vector slice
Definition: narray.h:982
T * c_array(void)
raw c-array style access
Definition: narray.h:845
narray< int, 2 > intmatrix_t
Definition: narray.h:206
size_t depth(void) const
depth
Definition: narray.h:2371
narray_o< int, 3 > intcube_o
Definition: narray.h:361
size_t & z(void)
ref access
Definition: narray.h:653
void resize(size_t neww, size_t newh)
Definition: narray.h:1699
bool is_flat_stride(const nindex< DIM > &stride, const nindex< DIM > &size)
Definition: narray.h:663
const_iterator end(void) const
end-stl like iterator
Definition: narray.h:854
void set_null(void)
sets thte slice to null
Definition: narray.h:2360
size_t depth(void) const
depth
Definition: narray.h:1677
narray_o< short, 1 > shortvec_o
Definition: narray.h:294
void operator=(const this_type &at)
this turns out to be very handy
Definition: narray.h:2859
void resize(size_t len)
Definition: narray.h:877
bool empty(void) const
empty?
Definition: narray.h:1669
narray_o< short, 4 > shortquad_o
Definition: narray.h:387
void set_all(T v) const
set all elements
Definition: narray.h:2106
void print_element< float >(scopira::tool::oflow_i &o, float el)
element printing helper (specialization)
Definition: narray.h:2942
bool load(scopira::tool::itflow_i &in)
Definition: narray.h:1959
const T * const_iterator
the const_interator type
Definition: narray.h:799
void print_element< int >(scopira::tool::oflow_i &o, int el)
element printing helper (specialization)
Definition: narray.h:2907
size_t z(void) const
ref access
Definition: narray.h:598