Scopira  20080306
narray.h
1 
2 /*
3  * Copyright (c) 2002-2007 National Research Council
4  *
5  * All rights reserved.
6  *
7  * This material is confidential and proprietary information of
8  * National Research Council Canada ("Confidential Information").
9  * This Confidential Information may only be used and reproduced
10  * in accordance with the terms of the license agreement.
11  *
12  */
13 
14 #ifndef __INCLUDED_SCOPIRA_BASEKIT_NARRAY_H__
15 #define __INCLUDED_SCOPIRA_BASEKIT_NARRAY_H__
16 
17 #include <iostream>
18 #include <iomanip>
19 
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>
25 
26 //
27 // Super Fine N-dimensional data structures
28 //
29 // Has D = {1, 2, 3, 4) specializations
30 // Will have a runtime dynamic narray with dynamic (basic_array)
31 // based coords, perhaps
32 //
33 
34 namespace scopira
35 {
40  namespace basekit
41  {
42  enum {
43  x_axis_c = 0,
44  y_axis_c = 1,
45  z_axis_c = 2,
46  t_axis_c = 3,
47  };
48 
49  //template <class T, int DIM> class nslice;
50  template <int DIM = 1> class nindex;
51  template <> class nindex<1>;
52  template <> class nindex<2>;
53  template <> class nindex<3>;
54  template <> class nindex<4>;
55 
62  template <int DIM> bool is_flat_stride(const nindex<DIM> &stride, const nindex<DIM> &size);
63 
70  {
71  public:
72  virtual ~narray_delete_i() { }
81  virtual void narray_delete(void *mem, size_t len) = 0;
82  };
83 
88  SCOPIRA_EXPORT extern narray_delete_i *null_narray_delete;
94  SCOPIRA_EXPORT extern narray_delete_i *normal_narray_delete;
95 
96  template <class T, int DIM = 1> class narray;
97 
98  template <class T, int DIM = 1> class nslice;
99  template <class T, int DIM = 1> class niterator;
100 
101  template <class T, int DIM = 1> class const_nslice;
102  template <class T, int DIM = 1> class const_niterator;
103 
105  template <class E>
106  inline void print_element(scopira::tool::oflow_i &o, E el); // default uses <<
108  template <>
109  inline void print_element<long>(scopira::tool::oflow_i &o, long el);
111  template <>
112  inline void print_element<unsigned long>(scopira::tool::oflow_i &o, unsigned long el);
114  template <>
115  inline void print_element<int>(scopira::tool::oflow_i &o, int el);
117  template <>
118  inline void print_element<unsigned int>(scopira::tool::oflow_i &o, unsigned int el);
120  template <>
121  inline void print_element<short>(scopira::tool::oflow_i &o, short el);
123  template <>
124  inline void print_element<char>(scopira::tool::oflow_i &o, char el);
126  template <>
127  inline void print_element<double>(scopira::tool::oflow_i &o, double el);
129  template <>
130  inline void print_element<float>(scopira::tool::oflow_i &o, float el);
131 
133  template <class C>
136  template <class C>
138 
140  template <class C>
141  std::ostream & print_vector_slice(std::ostream &o, const const_nslice<C,1> &V);
143  template <class C>
144  std::ostream & print_matrix_slice(std::ostream &o, const const_nslice<C,2> &M);
145 
146  //
147  // In the future, a N-dimen base interface class could be put between
148  // narray_o and object so that people can do dimen independant stuff?
149  //class narray_i;
150 
151  template <class T, int DIM = 1> class narray_o;
152 
153  //
154  // many type defs, for convieinence...
155  //
160  typedef narray<bool,1> boolvec_t;
186 
217 
248 
279 
310 
341 
372 
403  }
404 }
405 
406 // NINDEX
407 
413 template <int DIM> class scopira::basekit::nindex : public scopira::tool::fixed_array<size_t, DIM>
414 {
415  private:
416  typedef nindex<DIM> this_type;
417 
418  public:
420  nindex(size_t val);
422  nindex(void) { }
423 
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;
430 
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;
441 };
442 
448 template <>
450 {
451  private:
453  typedef nindex<1> this_type;
454 
455  public:
457  nindex(size_t v=0) { dm_ary[0] = v; }
459  void clear(size_t v = 0) { dm_ary[0] = v; }
460 
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); }
470  nindex<1> shrink(void) const { return nindex<1>(); } // gotta return somethin', and definatly not a 0-array
471 
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; }
480 
482  size_t & x(void) { return dm_ary[0]; }
484  size_t x(void) const { return dm_ary[0]; }
485 
487  void set(size_t _x) { dm_ary[0] = _x; }
488 };
489 
495 template <>
497 {
498  private:
500  typedef nindex<2> this_type;
501 
502  public:
504  nindex(size_t _x, size_t _y) { dm_ary[0] = _x; dm_ary[1] = _y; }
506  nindex(size_t v=0) { clear(v); }
508  void clear(size_t v = 0)
509  { dm_ary[0] = v; dm_ary[1] = v; }
510 
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); }
520  nindex<1> shrink(void) const { return nindex<1>(dm_ary[0]); } // gotta return somethin'
521 
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; }
530 
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]; }
539 
541  void set_xy(size_t _x, size_t _y) { dm_ary[0] = _x; dm_ary[1] = _y; }
542 };
543 
549 template <>
551 {
552  private:
554  typedef nindex<3> this_type;
555 
556  public:
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);
564  void clear(size_t v = 0)
565  { dm_ary[0] = v; dm_ary[1] = v; dm_ary[2] = v; }
566 
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); }
576  nindex<2> shrink(void) const { return nindex<2>(dm_ary[0], dm_ary[1]); } // gotta return somethin'
577 
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; }
586 
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]; }
599 };
600 
606 template <>
608 {
609  private:
611  typedef nindex<4> this_type;
612 
613  public:
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);
621  void clear(size_t v = 0)
622  { dm_ary[0] = v; dm_ary[1] = v; dm_ary[2] = v; dm_ary[3] = v; }
623 
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); }
633  nindex<3> shrink(void) const { return nindex<3>(dm_ary[0], dm_ary[1], dm_ary[2]); } // gotta return somethin'
634 
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; }
643 
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]; }
660 };
661 
662 template <int DIM>
664 {
665  if (stride[0] != 1)
666  return false;
667  for (int x=1; x<stride.size(); ++x)
668  if (stride[x] != size[x-1])
669  return false;
670  return true;
671 }
672 
673 //
674 //
675 // nindex stuff
676 //
677 //
678 
679 template <int DIM> scopira::basekit::nindex<DIM>::nindex(size_t val)
680 {
681  for (typename this_type::iterator ii = scopira::tool::fixed_array<size_t,DIM>::begin(); ii != scopira::tool::fixed_array<size_t,DIM>::end(); ++ii)
682  *ii = val;
683 }
684 
685 template <int DIM>
687 {
688  for (size_t i=0; i<scopira::tool::fixed_array<size_t,DIM>::size_c; ++i)
690  return false;
691  return true;
692 }
693 
694 template <int DIM>
696 {
697  for (size_t i=0; i<scopira::tool::fixed_array<size_t,DIM>::size_c; ++i)
699  return false;
700  return true;
701 }
702 
703 template <int DIM>
705 {
706  size_t ret = 0;
707  for (size_t i=0; i<scopira::tool::fixed_array<size_t,DIM>::size_c; ++i)
708  ret += (*this)[i] * rhs[i];
709  return ret;
710 }
711 
712 template <int DIM>
714 {
715  size_t ret = 1;
716  for (typename this_type::const_iterator ii=scopira::tool::fixed_array<size_t,DIM>::begin(); ii != scopira::tool::fixed_array<size_t,DIM>::end(); ++ii)
717  ret *= *ii;
718  return ret;
719 }
720 
721 template <int DIM>
723 {
724  size_t ret = 0, val = 1, i;
725  for (i=0; i<scopira::tool::fixed_array<size_t,DIM>::size_c; ++i) {
726  ret += c[i] * val;
728  }
729  return ret;
730 }
731 
732 template <int DIM>
734 {
735  nindex<DIM> ret;
736 
737  ret[0] = 1;
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];
740 
741  return ret;
742 }
743 
744 template <int DIM>
746 {
747  nindex<DIM> ret;
748 
749  for (size_t i=0; i<scopira::tool::fixed_array<size_t,DIM>::size_c; ++i)
750  ret[i] = i;
751 
752  return ret;
753 }
754 
755 template <int DIM>
757 {
758  nindex<DIM-1> ret;
759 
760  for (size_t i=0; i<scopira::tool::fixed_array<size_t,DIM>::size_c-1; ++i)
762  return ret;
763 }
764 
765 // NARRAY
766 
787 template <class T, int DIM> class scopira::basekit::narray
788 {
789  private:
790  typedef narray<T, DIM> this_type;
791  public:
793  typedef T data_type;
797  typedef T* iterator;
799  typedef const T* const_iterator;
800 
801  // extra defines for STL-likeness
802  typedef T value_type;
803  typedef T* pointer;
804  typedef T& reference;
805  typedef const T& const_reference;
806  typedef size_t size_type;
807  typedef ptrdiff_t difference_type;
808 
809  private:
810  T* dm_ary;
811  size_t dm_len;
812  index_type dm_size;
813  narray_delete_i * dm_direct;
814 
815  public:
817  narray(void);
819  narray(const this_type &src);
821  explicit narray(const index_type &sz);
823  explicit narray(size_t width, size_t height);
825  ~narray(void) { resize(nindex<DIM>(0)); }
826 
833  bool load(scopira::tool::itflow_i &in);
840  void save(scopira::tool::otflow_i &out) const;
841 
843  const T * c_array(void) const { return dm_ary; }
845  T * c_array(void) { return dm_ary; }
846 
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(); }
855 
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; }
868 
877  void resize(size_t len) { resize(nindex<1>(len)); }
887  void resize(size_t neww, size_t newh) { resize(nindex<2>(neww, newh)); }
898  void resize(size_t neww, size_t newh, size_t newd) { resize(nindex<3>(neww, newh, newd)); }
906  void resize(const index_type &news);
907 
920  void resize_direct(index_type sz, T *direct_ary, scopira::basekit::narray_delete_i *delfunc = null_narray_delete);
921 
923  scopira::basekit::narray_delete_i * get_direct(void) const { return dm_direct; }
924 
925  //
926  // Slicer Stuff (non-const)
927  //
928 
930  template <int SIM>
931  nslice<T,SIM> slicer(index_type base, nindex<SIM> dimen, nindex<SIM> direction);
933  template <int SIM>
934  nslice<T,SIM> slicer(index_type base, nindex<SIM> dimen);
936  nslice<T,1> slicer(index_type base, size_t len, size_t direction = x_axis_c);
937 
945  nslice<T,1> diagonal_slice(void);
946 
947  // slice stuff
948 
950  nslice<T,DIM> all_slice(void);
952  size_t size_rows(void) const { return dm_size[DIM-1]; }
954  nslice<T,DIM-1> row_slice(size_t r);
955 
956  // specific slices
957 
958  // VECTOR
959 
961  nslice<T,1> xslice(size_t basex, size_t len)
962  { return slicer(nindex<1>(basex), nindex<1>(len), nindex<1>(x_axis_c)); }
963 
964  // MATRIX
965 
967  nslice<T,1> xslice(size_t basex, size_t basey, size_t len)
968  { return slicer(nindex<2>(basex, basey), nindex<1>(len), nindex<1>(x_axis_c)); }
970  nslice<T,1> yslice(size_t basex, size_t basey, size_t len)
971  { return slicer(nindex<2>(basex, basey), nindex<1>(len), nindex<1>(y_axis_c)); }
973  nslice<T,2> xyslice(size_t basex, size_t basey, size_t width, size_t height)
974  { return slicer(nindex<2>(basex, basey), nindex<2>(width, height)); }
975 
976  // N DIMENSIONAL
977 
979  nslice<T,1> xslice(index_type base, size_t len)
980  { return slicer(base, nindex<1>(len), nindex<1>(x_axis_c)); }
982  nslice<T,1> yslice(index_type base, size_t len)
983  { return slicer(base, nindex<1>(len), nindex<1>(y_axis_c)); }
985  nslice<T,1> zslice(index_type base, size_t len)
986  { return slicer(base, nindex<1>(len), nindex<1>(z_axis_c)); }
988  nslice<T,1> tslice(index_type base, size_t len)
989  { return slicer(base, nindex<1>(len), nindex<1>(t_axis_c)); }
990 
992  nslice<T,2> xyslice(index_type base, size_t width, size_t height)
993  { return slicer(base, nindex<2>(width, height)); }
994 
995  //
996  // Slicer Stuff (const)
997  //
998 
1000  template <int SIM>
1001  const_nslice<T,SIM> slicer(index_type base, nindex<SIM> dimen,
1002  nindex<SIM> direction) const;
1004  template <int SIM>
1005  const_nslice<T,SIM> slicer(index_type base, nindex<SIM> dimen) const;
1007  const_nslice<T,1> slicer(index_type base, size_t len, size_t direction = x_axis_c) const;
1008 
1010  const_nslice<T,1> diagonal_slice(void) const;
1011 
1012  // slice stuff
1013 
1015  const_nslice<T,DIM> all_slice(void) const;
1017  //size_t size_rows(void) const { return dm_size[DIM-1]; }
1019  const_nslice<T,DIM-1> row_slice(size_t r) const;
1020 
1021  // specific slices
1022 
1023  // VECTOR
1024 
1026  const_nslice<T,1> xslice(size_t basex, size_t len) const
1027  { return slicer(nindex<1>(basex), nindex<1>(len), nindex<1>(x_axis_c)); }
1028 
1029  // MATRIX
1030 
1032  const_nslice<T,1> xslice(size_t basex, size_t basey, size_t len) const
1033  { return slicer(nindex<2>(basex, basey), nindex<1>(len), nindex<1>(x_axis_c)); }
1035  const_nslice<T,1> yslice(size_t basex, size_t basey, size_t len) const
1036  { return slicer(nindex<2>(basex, basey), nindex<1>(len), nindex<1>(y_axis_c)); }
1038  const_nslice<T,2> xyslice(size_t basex, size_t basey, size_t width, size_t height) const
1039  { return slicer(nindex<2>(basex, basey), nindex<2>(width, height)); }
1040 
1041  // N DIMENSIONAL
1042 
1044  const_nslice<T,1> xslice(index_type base, size_t len) const
1045  { return slicer(base, nindex<1>(len), nindex<1>(x_axis_c)); }
1047  const_nslice<T,1> yslice(index_type base, size_t len) const
1048  { return slicer(base, nindex<1>(len), nindex<1>(y_axis_c)); }
1050  const_nslice<T,1> zslice(index_type base, size_t len) const
1051  { return slicer(base, nindex<1>(len), nindex<1>(z_axis_c)); }
1053  const_nslice<T,1> tslice(index_type base, size_t len) const
1054  { return slicer(base, nindex<1>(len), nindex<1>(t_axis_c)); }
1055 
1057  const_nslice<T,2> xyslice(index_type base, size_t width, size_t height) const
1058  { return slicer(base, nindex<2>(width, height)); }
1059 
1060  //
1061  // end of slice stuff
1062  //
1063 
1065  void clear(void) { set_all(T()); }
1067  void set_all(T v);
1069  void copy(const this_type &at);
1071  void copy(const nslice<T,DIM> &at);
1073  void copy(const const_nslice<T,DIM> &at);
1075  void operator=(const this_type &at) { copy(at); }
1076 
1077  // *** nindex access ***
1078 
1080  T operator()(index_type c) const {
1081  assert("[narray element access out of bounds]" && c<dm_size );
1082  return dm_ary[dm_size.offset(c)];
1083  }
1085  T& operator()(index_type c) {
1086  assert("[narray element access out of bounds]" && c<dm_size );
1087  return dm_ary[dm_size.offset(c)];
1088  }
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;
1093  }
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)];
1098  }
1099 
1100  // *** 1D vector like access ***
1101 
1103  const T operator[](size_t idx) const {
1104  assert("[narray element access out of bounds]" && (idx < dm_len) );
1105  return dm_ary[idx];
1106  }
1108  T& operator[](size_t idx) {
1109  assert("[narray element access out of bounds]" && (idx < dm_len) );
1110  return dm_ary[idx];
1111  }
1113  void set(size_t idx, T v) {
1114  assert("[narray element access out of bounds]" && (idx < dm_len) );
1115  dm_ary[idx] = v;
1116  }
1118  T get(size_t idx) const {
1119  assert("[narray element access out of bounds]" && (idx < dm_len) );
1120  return dm_ary[idx];
1121  }
1122 
1123  // *** 2D matrix like access ***
1124 
1134  const T operator()(size_t x, size_t y) const {
1135  assert("[narray element access out of bounds]" && (x<width()) && (y<height()) );
1136  return dm_ary[x+y*width()];
1137  }
1147  T& operator()(size_t x, size_t y) {
1148  assert("[narray element access out of bounds]" && (x<width()) && (y<height()) );
1149  return dm_ary[x+y*width()];
1150  }
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;
1163  }
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()];
1176  }
1177 
1178  // 3D
1179 
1190  T& operator()(size_t x, size_t y, size_t z) {
1191  assert("[narray element access out of bounds]" && (x<width()) && (y<height()) && (z<depth()));
1192  return dm_ary[x+y*width()+z*width()*height()];
1193  }
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;
1207  }
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()];
1221  }
1222 };
1223 
1224 //
1225 // narray<T>
1226 //
1227 
1228 template <class T, int DIM>
1230  : dm_ary(0), dm_len(0), dm_direct(0)
1231 {
1232 }
1233 
1234 template <class T, int DIM>
1236  : dm_ary(0), dm_len(0), dm_direct(0)
1237 {
1238  copy( src );
1239 }
1240 
1241 template <class T, int DIM>
1243  : dm_ary(0), dm_len(0), dm_direct(0)
1244 {
1245  resize(sz);
1246 }
1247 
1248 template <class T, int DIM>
1249 scopira::basekit::narray<T,DIM>::narray(size_t width, size_t height)
1250  : dm_ary(0), dm_len(0), dm_direct(0)
1251 {
1252  resize(nindex<2>(width, height));
1253 }
1254 
1255 
1256 template <class T, int DIM>
1258 {
1259  nindex<DIM> newsize;
1260  size_t j;
1261  int v;
1262  bool newver;
1263 
1264  if (!in.read_int(v)) // read TAG, possibly
1265  return false;
1266  if (v == -10 || v == -11) {
1267  newver = v == -11;
1268  // read new style
1269  if (!in.read_int(v))
1270  return false;
1271  assert(v == DIM);
1272  if (newver)
1273  for (j=0; j<DIM; ++j) {
1274  if (!in.read_size_t(newsize[j]))
1275  return false;
1276  }
1277  else
1278  for (j=0; j<DIM; ++j) {
1279  if (!in.read_int(v))
1280  return false;
1281  newsize[j] = v;
1282  }
1283 
1284  resize(newsize);
1285 
1286  if (!empty()) {
1287  if (!in.read_array(dm_ary, size()))
1288  return false;
1289 #ifdef PLATFORM_BYTESWAP
1290  // decode this thing
1291  scopira::tool::byte_swap_all(dm_ary, dm_ary + dm_len);
1292 #endif
1293  }
1294  } else {
1295  // read OLD STYLE, soon to be deprecated
1296  newsize[0] = v;
1297  iterator ii, endii;
1298 
1299  assert(v>=0);
1300  for (j=1; j<DIM; ++j) {
1301  if (!in.read_int(v))
1302  return false;
1303  assert(v>=0);
1304  newsize[j] = v;
1305  }
1306 
1307  resize(newsize);
1308 
1309  endii = end();
1310  for (ii=begin(); ii != endii; ++ii)
1312  return false;
1313  }
1314  return true;
1315 }
1316 
1317 template <class T, int DIM>
1319 {
1320  // this ONLY writes in NEW STYLE
1321  size_t j;
1322 
1323  out.write_int(-11); // my TAG (-10 == int sizes... -11 size_t sizes)
1324  out.write_int(DIM); // redudant, but whatever
1325  for (j=0; j<DIM; ++j)
1326  out.write_size_t(dm_size[j]);
1327  // write out payload
1328  if (!empty()) {
1329 #ifdef PLATFORM_BYTESWAP
1330  T *head, *tail;
1331  head = const_cast<T*>(dm_ary); // ugly, but a must
1332  tail = const_cast<T*>(dm_ary + dm_len);
1333  scopira::tool::byte_swap_all(head, tail);
1334 #endif
1335  out.write_array(dm_ary, size());
1336 #ifdef PLATFORM_BYTESWAP
1337  // undo the swappage
1338  // I'd rather do this one extra time, then use a temporary (and thus twice the memory)
1339  scopira::tool::byte_swap_all(head, tail);
1340 #endif
1341  }
1342 }
1343 
1344 template <class T, int DIM>
1346 {
1347  if (news == dm_size)
1348  return;
1349 
1350  if (dm_direct) {
1351  assert("[resize attempted on DIRECT mode narray]" && news.product() == 0);
1352  // call the handler to nuke this object, since we're in destruction mode
1353  dm_direct->narray_delete(dm_ary, dm_len);
1354  dm_direct = 0;
1355  dm_size = news;
1356  dm_ary = 0;
1357  dm_len = 0;
1358  return;
1359  }
1360 
1361  dm_size = news;
1362 
1363  if (dm_len > 0)
1364  delete []dm_ary;
1365  dm_len = dm_size.product();
1366  if (dm_len == 0)
1367  dm_ary = 0;
1368  else
1369  dm_ary = new T[dm_len];
1370 }
1371 
1372 template <class T, int DIM>
1374 {
1375  assert("[resize_direct may only be called on empty narrays]" && (dm_direct || empty()));
1376 
1377  if (dm_direct) {
1378  // nuke the previous version
1379  dm_direct->narray_delete(dm_ary, dm_len);
1380  }
1381 
1382  dm_size = sz;
1383  dm_len = dm_size.product();
1384  dm_direct = dm_len != 0 ? delfunc : 0;
1385 
1386  if (dm_direct) {
1387  assert(direct_ary);
1388  dm_ary = direct_ary;
1389  if (dm_direct == normal_narray_delete) // special case
1390  dm_direct = 0;
1391  } else {
1392  // clearing operation (it doesnt matter what direct_ary is in this case)
1393  dm_ary = 0;
1394  }
1395 }
1396 
1397 template <class T, int DIM>
1398  template <int SIM>
1400  index_type base, nindex<SIM> dimen, nindex<SIM> direction)
1401 {
1402  nindex<DIM> size_strides = dm_size.strides();
1403  nindex<SIM> strides;
1404 
1405  for (size_t i=0; i<strides.size_c; ++i)
1406  strides[i] = size_strides[direction[i]];
1407 
1408  return nslice<T,SIM>(dm_ary, dm_size.offset(base), dimen, strides);
1409 }
1410 
1411 template <class T, int DIM>
1412  template <int SIM>
1414  index_type base, nindex<SIM> dimen)
1415 {
1416  return slicer(base, dimen, nindex<SIM>::steps());
1417 }
1418 
1419 template <class T, int DIM>
1421  size_t direction)
1422 {
1423  return slicer(base, nindex<1>(len), nindex<1>(direction));
1424 }
1425 
1426 template <class T, int DIM>
1428 {
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);
1432 }
1433 
1434 template <class T, int DIM>
1436 {
1437  return slicer(index_type(0), dm_size, nindex<DIM>::steps());
1438 }
1439 
1440 template <class T, int DIM>
1442 {
1443  index_type base(0);
1444  base[DIM-1] = r;
1445  return slicer(base, dm_size.shrink(), nindex<DIM-1>::steps());
1446 }
1447 
1448 template <class T, int DIM>
1449  template <int SIM>
1451  index_type base, nindex<SIM> dimen, nindex<SIM> direction) const
1452 {
1453  nindex<DIM> size_strides = dm_size.strides();
1454  nindex<SIM> strides;
1455 
1456  for (size_t i=0; i<strides.size_c; ++i)
1457  strides[i] = size_strides[direction[i]];
1458 
1459  return const_nslice<T,SIM>(dm_ary, dm_size.offset(base), dimen, strides);
1460 }
1461 
1462 template <class T, int DIM>
1463  template <int SIM>
1465  index_type base, nindex<SIM> dimen) const
1466 {
1467  return slicer(base, dimen, nindex<SIM>::steps());
1468 }
1469 
1470 template <class T, int DIM>
1472  size_t direction) const
1473 {
1474  return slicer(base, nindex<1>(len), nindex<1>(direction));
1475 }
1476 
1477 template <class T, int DIM>
1479 {
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");
1482  return const_nslice<T,1>(dm_ary, 0, dm_size[0], dm_size[0]+1);
1483 }
1484 
1485 template <class T, int DIM>
1487 {
1488  return slicer(index_type(0), dm_size, nindex<DIM>::steps());
1489 }
1490 
1491 template <class T, int DIM>
1493 {
1494  index_type base(0);
1495  base[DIM-1] = r;
1496  return slicer(base, dm_size.shrink(), nindex<DIM-1>::steps());
1497 }
1498 
1499 template <class T, int DIM>
1501 {
1502  typedef typename this_type::iterator I;
1503  I ii, endii;
1504 
1505  endii = end();
1506  for (ii=begin(); ii != endii; ++ii)
1507  *ii = v;
1508 }
1509 
1510 template <class T, int DIM>
1512 {
1513  typedef typename this_type::iterator I;
1514  typedef typename this_type::const_iterator J;
1515 
1516  resize(at.dimen());
1517 
1518  I ii, endii;
1519  J kk;
1520 
1521  endii = end();
1522  kk = at.begin();
1523 
1524  for (ii=begin(); ii != endii; ++ii, ++kk)
1525  *ii = *kk;
1526 }
1527 
1528 template <class T, int DIM>
1530 {
1531  typedef typename this_type::iterator I;
1532  typedef typename nslice<T,DIM>::const_iterator J;
1533 
1534  resize(at.dimen());
1535 
1536  I ii, endii;
1537  J kk;
1538 
1539  endii = end();
1540  kk = at.begin();
1541 
1542  for (ii=begin(); ii != endii; ++ii, ++kk)
1543  *ii = *kk;
1544 }
1545 
1546 template <class T, int DIM>
1548 {
1549  typedef typename this_type::iterator I;
1550  typedef typename const_nslice<T,DIM>::const_iterator J;
1551 
1552  resize(at.dimen());
1553 
1554  I ii, endii;
1555  J kk;
1556 
1557  endii = end();
1558  kk = at.begin();
1559 
1560  for (ii=begin(); ii != endii; ++ii, ++kk)
1561  *ii = *kk;
1562 }
1563 
1564 // NSLICE
1565 
1585 template <class T, int DIM> class scopira::basekit::nslice
1586 {
1587  private:
1588  typedef nslice<T, DIM> this_type;
1589  friend class scopira::basekit::const_nslice<T,DIM>;
1590  public:
1591  typedef T data_type;
1592  typedef nindex<DIM> index_type;
1593  typedef niterator<T, DIM> iterator;
1595 
1596  // extra defines for STL-likeness
1597  typedef T value_type;
1598  typedef T* pointer;
1599  typedef T& reference;
1600  typedef const T& const_reference;
1601  typedef size_t size_type;
1602  typedef ptrdiff_t difference_type;
1603  private:
1604  T* dm_var;
1605  size_t dm_prime, dm_end_prime;
1606  // this is the size of each dimension
1607  index_type dm_size;
1608  // this is the striding factor
1609  // for each index, it contains the number of elements per-unit in that index
1610  // for example, dm_stride[0] is the number of elements per x (often 1)
1611  // for example, dm_stride[1] is the number of elements per y (often, this would be the width)
1612  // for example, dm_stride[2] is the number of elements per z (often, width()*height()
1613  index_type dm_stride;
1614  public:
1616  nslice(void);
1618  nslice(const this_type &rhs);
1620  nslice(narray<T,DIM> &rhs);
1622  nslice(narray<T,DIM> *rhs);
1624  nslice(T * _var, size_t _prime, index_type _size, index_type _stride);
1625 
1631  bool load(scopira::tool::itflow_i &in);
1637  void save(scopira::tool::otflow_i &out) const;
1638 
1646  T * c_array(void) const { assert(is_flat_stride()); return dm_var+dm_prime; }
1647 
1654  { return niterator<T,DIM>( dm_var+dm_prime, false, dm_size, dm_stride); }
1661  { return niterator<T,DIM>( dm_var+dm_end_prime, true, dm_size, dm_stride); }
1662 
1664  bool is_null(void) const { return !dm_var; }
1666  void set_null(void) { dm_var = 0; }
1667 
1669  bool empty(void) const { return dm_prime == dm_end_prime; }
1671  size_t size(void) const { return dm_size.product(); }
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; }
1680 
1689  void resize(size_t len) { resize(nindex<1>(len)); }
1699  void resize(size_t neww, size_t newh) { resize(nindex<2>(neww, newh)); }
1710  void resize(size_t neww, size_t newh, size_t newd) { resize(nindex<3>(neww, newh, newd)); }
1718  void resize(const index_type &news);
1719 
1722  template <int SIM>
1723  nslice<T,SIM> slicer(index_type base, nindex<SIM> dimen,
1724  nindex<SIM> direction) const;
1726  template <int SIM>
1727  nslice<T,SIM> slicer(index_type base, nindex<SIM> dimen) const;
1729  nslice<T,1> slicer(index_type base, size_t len, size_t direction = 0) const;
1730 
1731  // slice stuff
1732 
1741 
1743  nslice<T,DIM> all_slice(void) const;
1745  size_t size_rows(void) const { return dm_size[DIM-1]; }
1747  nslice<T,DIM-1> row_slice(size_t r) const;
1748 
1749  // specific slices
1750 
1751  // VECTOR
1752 
1754  nslice<T,1> xslice(size_t basex, size_t len) const
1755  { return slicer(nindex<1>(basex), nindex<1>(len), nindex<1>(x_axis_c)); }
1756 
1757  // MATRIX
1758 
1760  nslice<T,1> xslice(size_t basex, size_t basey, size_t len) const
1761  { return slicer(nindex<2>(basex, basey), nindex<1>(len), nindex<1>(x_axis_c)); }
1763  nslice<T,1> yslice(size_t basex, size_t basey, size_t len) const
1764  { return slicer(nindex<2>(basex, basey), nindex<1>(len), nindex<1>(y_axis_c)); }
1766  nslice<T,2> xyslice(size_t basex, size_t basey, size_t width, size_t height) const
1767  { return slicer(nindex<2>(basex, basey), nindex<2>(width, height)); }
1768 
1769  // N DIMENSIONAL
1770 
1772  nslice<T,1> xslice(index_type base, size_t len) const
1773  { return slicer(base, nindex<1>(len), nindex<1>(x_axis_c)); }
1775  nslice<T,1> yslice(index_type base, size_t len) const
1776  { return slicer(base, nindex<1>(len), nindex<1>(y_axis_c)); }
1778  nslice<T,1> zslice(index_type base, size_t len) const
1779  { return slicer(base, nindex<1>(len), nindex<1>(z_axis_c)); }
1781  nslice<T,1> tslice(index_type base, size_t len) const
1782  { return slicer(base, nindex<1>(len), nindex<1>(t_axis_c)); }
1783 
1785  nslice<T,2> xyslice(index_type base, size_t width, size_t height) const
1786  { return slicer(base, nindex<2>(width, height)); }
1787 
1789  void clear(void) { set_all(0); }
1791  void set_all(T v) const;
1793  void copy(const narray<T,DIM> &at);
1795  void copy(const nslice<T,DIM> &at);
1797  void copy(const const_nslice<T,DIM> &at);
1798 
1800  T& operator()(index_type idx) const {
1801  assert("[nslice element access out of bounds]" && idx < dm_size && dm_var);
1802  return dm_var[dm_prime + (idx*dm_stride)];
1803  }
1804 
1805  // *** 1D vector like access ***
1806 
1808  T& operator[](size_t idx) const {
1809  assert("[nslice element access out of bounds]" && idx < dm_size[0] && DIM==1);
1810  return dm_var[dm_prime+idx*dm_stride[0]];
1811  }
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;
1816  }
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]];
1821  }
1822 
1823  // *** 2D matrix like access ***
1824 
1834  T& operator()(size_t x, size_t y) const {
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]];
1837  }
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;
1850  }
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]];
1863  }
1864 
1865  // 3D
1866 
1877  T& operator()(size_t x, size_t y, size_t z) const {
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]];
1880  }
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;
1894  }
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]];
1908  }
1909 
1916  bool is_flat_stride(void) const { return scopira::basekit::is_flat_stride(dm_stride, dm_size); }
1917 };
1918 
1919 //
1920 //
1921 // nslice
1922 //
1923 //
1924 
1925 template <class T, int DIM>
1927  : dm_var(0)
1928 {
1929 }
1930 
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)
1935 {
1936 }
1937 
1938 template <class T, int DIM>
1940 {
1941  *this = rhs.all_slice();
1942 }
1943 
1944 template <class T, int DIM>
1946 {
1947  *this = rhs->all_slice();
1948 }
1949 
1950 template <class T, int DIM>
1951 scopira::basekit::nslice<T,DIM>::nslice(T * _var, size_t _prime, index_type _size, index_type _stride)
1952  : dm_var(_var), dm_prime(_prime),
1953  dm_size(_size), dm_stride(_stride)
1954 {
1955  dm_end_prime = dm_prime + dm_stride[DIM-1]*dm_size[DIM-1];
1956 }
1957 
1958 template <class T, int DIM>
1960 {
1961  // this ONLY reads in NEW STYLE
1962  int i, j;
1963  size_t left;
1964 
1965  // read tag
1966  if (!in.read_int(i) || i != -11)
1967  return false;
1968 
1969  // read DIM
1970  if (!in.read_int(i) || i != DIM)
1971  return false;
1972  for (i=0; i<DIM; ++i)
1973  if (!in.read_size_t(left) || left != dm_size[i])
1974  return false;
1975 
1976  // check for super fast case when stride == 1
1977 #ifndef PLATFORM_BYTESWAP
1978  if (is_flat_stride()) {
1979  size_t sz = size();
1980  return in.read_array(c_array(), sz) == sz;
1981  }
1982 #endif
1983 
1984  // read in the payload
1986  const_iterator ii=begin(), endii=end();
1987  T *jj, *endjj;
1988 
1989  left = size();
1990  while (left>0) {
1991  if (left>buf.size())
1992  j = buf.size();
1993  else
1994  j = left;
1995  jj = buf.begin();
1996  endjj = jj + j;
1997 
1998  if (!in.read_array(jj, j))
1999  return false;
2000 #ifdef PLATFORM_BYTESWAP
2001  scopira::tool::byte_swap_all(jj, endjj);
2002 #endif
2003 
2004  for (; jj != endjj; ++jj, ++ii)
2005  *ii = *jj;
2006 
2007  left -= j;
2008  }
2009  return true;
2010 }
2011 
2012 template <class T, int DIM>
2014 {
2015  // this ONLY writes in NEW STYLE
2016  int j;
2017 
2018  out.write_int(-11); // my TAG (-10 == int sizes... -11 size_t sizes)
2019  out.write_int(DIM); // redudant, but whatever
2020  for (j=0; j<DIM; ++j)
2021  out.write_size_t(dm_size[j]);
2022  if (empty())
2023  return;
2024 
2025  // check for super fast case when stride == 1
2026 #ifndef PLATFORM_BYTESWAP
2027  if (is_flat_stride()) {
2028  out.write_array(c_array(), size());
2029  return;
2030  }
2031 #endif
2032 
2033  // write out payload
2035  const_iterator ii=begin(), endii=end();
2036  T *jj, *endjj;
2037 
2038  while (ii != endii) {
2039  for (jj=buf.begin(), endjj=buf.end(); jj != endjj && ii != endii; ++jj, ++ii)
2040  *jj = *ii;
2041 #ifdef PLATFORM_BYTESWAP
2042  scopira::tool::byte_swap_all(jj, endjj);
2043 #endif
2044  out.write_array(buf.begin(), (jj-buf.begin()));
2045  }
2046 }
2047 
2048 template <class T, int DIM>
2050 {
2051  dm_size = news;
2052  dm_end_prime = dm_prime + dm_stride[DIM-1]*dm_size[DIM-1];
2053 }
2054 
2055 template <class T, int DIM>
2056  template <int SIM>
2058  index_type base, nindex<SIM> dimen, nindex<SIM> direction) const
2059 {
2060  nindex<SIM> strides;
2061 
2062  for (size_t i=0; i<strides.size_c; ++i)
2063  strides[i] = dm_stride[direction[i]];
2064 
2065  return nslice<T,SIM>(dm_var, dm_prime+(base*dm_stride), dimen, strides);
2066 }
2067 
2068 template <class T, int DIM>
2069  template <int SIM>
2071  index_type base, nindex<SIM> dimen) const
2072 {
2073  return slicer(base, dimen, nindex<SIM>::steps());
2074 }
2075 
2076 template <class T, int DIM>
2078  size_t direction) const
2079 {
2080  return slicer(base, nindex<1>(len), nindex<1>(direction));
2081 }
2082 
2083 template <class T, int DIM>
2085 {
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");
2088  return nslice<T,1>(dm_var, dm_prime, nindex<1>(dm_size[0]), nindex<1>(dm_stride[1]+1));
2089 }
2090 
2091 template <class T, int DIM>
2093 {
2094  return slicer(index_type(0), dm_size, nindex<DIM>::steps());
2095 }
2096 
2097 template <class T, int DIM>
2099 {
2100  index_type base(0);
2101  base[DIM-1] = r;
2102  return slicer(base, dm_size.shrink(), nindex<DIM-1>::steps());
2103 }
2104 
2105 template <class T, int DIM>
2107 {
2108  typedef typename this_type::iterator I;
2109  I ii, endii;
2110 
2111  endii = end();
2112  for (ii=begin(); ii != endii; ++ii)
2113  *ii = v;
2114 }
2115 
2116 template <class T, int DIM>
2118 {
2119  typedef typename this_type::iterator I;
2120  typedef typename narray<T,DIM>::const_iterator J;
2121 
2122  resize(at.dimen());
2123 
2124  I ii, endii;
2125  J kk;
2126 
2127  endii = end();
2128  kk = at.begin();
2129 
2130  for (ii=begin(); ii != endii; ++ii, ++kk)
2131  *ii = *kk;
2132 }
2133 
2134 template <class T, int DIM>
2136 {
2137  typedef typename this_type::iterator I;
2138  typedef typename nslice<T,DIM>::iterator J;
2139 
2140  resize(at.dimen());
2141 
2142  I ii, endii;
2143  J kk;
2144 
2145  endii = end();
2146  kk = at.begin();
2147 
2148  for (ii=begin(); ii != endii; ++ii, ++kk)
2149  *ii = *kk;
2150 }
2151 
2152 template <class T, int DIM>
2154 {
2155  typedef typename this_type::iterator I;
2156  typedef typename const_nslice<T,DIM>::iterator J;
2157 
2158  resize(at.dimen());
2159 
2160  I ii, endii;
2161  J kk;
2162 
2163  endii = end();
2164  kk = at.begin();
2165 
2166  for (ii=begin(); ii != endii; ++ii, ++kk)
2167  *ii = *kk;
2168 }
2169 
2170 // *1niterator********************************************************************
2171 
2176 template <class T, int DIM>
2178 {
2179  public:
2181  typedef T data_type;
2182  private:
2183  typedef niterator<T, DIM> this_type;
2184  T *dm_ptr;
2185  nindex<DIM> dm_cur, dm_size, dm_stride;
2186  public:
2188  niterator(void);
2190  niterator(T *ptr, bool endptr, nindex<DIM> _size, nindex<DIM> _stride);
2191 
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); }
2198 
2200  this_type operator++(void);
2202  this_type operator--(void);
2203 
2204  // for random iterators
2206  ptrdiff_t operator-(const this_type & rhs) const {
2207  assert(DIM == 1);
2208  return (dm_cur[0] - rhs.dm_cur[0]) / dm_stride[0]; }
2210  this_type operator+(ptrdiff_t idx) const {
2211  assert(DIM == 1);
2212  this_type ret;
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;
2217  return ret;
2218  }
2220  this_type operator-(ptrdiff_t idx) const {
2221  assert(DIM == 1);
2222  this_type ret;
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;
2227  return ret;
2228  }
2230  bool operator<(const this_type &rhs) const {
2231  assert(DIM == 1);
2232  return dm_cur[0] < rhs.dm_cur[0]; }
2233 };
2234 
2235 template <class T, int DIM>
2237 {
2238 }
2239 
2240 template <class T, int DIM>
2242  : dm_ptr(ptr), dm_cur(0), dm_size(_size), dm_stride(_stride)
2243 {
2244  if (endptr)
2245  dm_cur[DIM-1] = dm_size[DIM-1];
2246 }
2247 
2248 template <class T, int DIM>
2250 {
2251  dm_ptr += dm_stride[0];
2252  ++dm_cur[0];
2253  for (size_t j=0; dm_cur[j] >= dm_size[j] && j+1<DIM; ++j) {
2254  // carry over the cur digits while doing some stride magic
2255  dm_ptr += -1 * dm_stride[j]*dm_cur[j] + dm_stride[j + 1];
2256  dm_cur[j] = 0; // reset this digit
2257  ++dm_cur[j+1]; // carry over the next
2258  }
2259  return *this;
2260 }
2261 
2262 template <class T, int DIM>
2264 {
2265  for (size_t j=0; j<DIM; ++j) {
2266  // decrement the current digit
2267  if (dm_cur[j] > 0) {
2268  // done... no need to borrow futher
2269  --dm_cur[j];
2270  dm_ptr -= dm_stride[j];
2271  return *this;
2272  }
2273  // dm_cur[j] == 0, so well need to borrow
2274  // carry over the cur digits while doing some stride magic
2275  dm_cur[j] = dm_size[j]-1; // reset this digit
2276  dm_ptr += dm_stride[j]*dm_cur[j];
2277  }
2278  return *this;
2279 }
2280 
2281 
2282 // CONST_NSLICE
2283 
2293 template <class T, int DIM> class scopira::basekit::const_nslice
2294 {
2295  private:
2297  public:
2298  typedef T data_type;
2299  typedef nindex<DIM> index_type;
2300  typedef const_niterator<T, DIM> iterator;
2301  typedef const_niterator<T, DIM> const_iterator;
2302 
2303  // extra defines for STL-likeness
2304  typedef T value_type;
2305  typedef T* pointer;
2306  typedef T& reference;
2307  typedef const T& const_reference;
2308  typedef size_t size_type;
2309  typedef ptrdiff_t difference_type;
2310  private:
2311  const T * dm_var;
2312  size_t dm_prime, dm_end_prime;
2313  index_type dm_size, dm_stride;
2314  public:
2316  const_nslice(void);
2318  const_nslice(const this_type &rhs);
2320  const_nslice(const narray<T,DIM> &rhs);
2322  const_nslice(const narray<T,DIM> *rhs);
2324  const_nslice(const T * _var, size_t _prime, index_type _size, index_type _stride);
2330  const_nslice(const nslice<T, DIM> &rhs);
2331 
2337  void save(scopira::tool::otflow_i &out) const;
2338 
2340  const T * c_array(void) const { assert(is_flat_stride()); return dm_var+dm_prime; }
2341 
2348  { return const_niterator<T,DIM>( dm_var+dm_prime, false, dm_size, dm_stride); }
2355  { return const_niterator<T,DIM>( dm_var+dm_end_prime, true, dm_size, dm_stride); }
2356 
2358  bool is_null(void) const { return !dm_var; }
2360  void set_null(void) { dm_var = 0; }
2361 
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; }
2374 
2383  void resize(size_t len) { resize(nindex<1>(len)); }
2393  void resize(size_t neww, size_t newh) { resize(nindex<2>(neww, newh)); }
2404  void resize(size_t neww, size_t newh, size_t newd) { resize(nindex<3>(neww, newh, newd)); }
2412  void resize(const index_type &news);
2413 
2416  template <int SIM>
2417  const_nslice<T,SIM> slicer(index_type base, nindex<SIM> dimen,
2418  nindex<SIM> direction) const;
2420  template <int SIM>
2421  const_nslice<T,SIM> slicer(index_type base, nindex<SIM> dimen) const;
2423  const_nslice<T,1> slicer(index_type base, size_t len, size_t direction = 0) const;
2424 
2425  // slice stuff
2426 
2434  const_nslice<T,1> diagonal_slice(void);
2435 
2437  const_nslice<T,DIM> all_slice(void) const;
2439  size_t size_rows(void) const { return dm_size[DIM-1]; }
2441  const_nslice<T,DIM-1> row_slice(size_t r) const;
2442 
2443  // specific slices
2444 
2445  // VECTOR
2446 
2448  const_nslice<T,1> xslice(size_t basex, size_t len) const
2449  { return slicer(nindex<1>(basex), nindex<1>(len), nindex<1>(x_axis_c)); }
2450 
2451  // MATRIX
2452 
2454  const_nslice<T,1> xslice(size_t basex, size_t basey, size_t len) const
2455  { return slicer(nindex<2>(basex, basey), nindex<1>(len), nindex<1>(x_axis_c)); }
2457  const_nslice<T,1> yslice(size_t basex, size_t basey, size_t len) const
2458  { return slicer(nindex<2>(basex, basey), nindex<1>(len), nindex<1>(y_axis_c)); }
2460  const_nslice<T,2> xyslice(size_t basex, size_t basey, size_t width, size_t height) const
2461  { return slicer(nindex<2>(basex, basey), nindex<2>(width, height)); }
2462 
2463  // N DIMENSIONAL
2464 
2466  const_nslice<T,1> xslice(index_type base, size_t len) const
2467  { return slicer(base, nindex<1>(len), nindex<1>(x_axis_c)); }
2469  const_nslice<T,1> yslice(index_type base, size_t len) const
2470  { return slicer(base, nindex<1>(len), nindex<1>(y_axis_c)); }
2472  const_nslice<T,1> zslice(index_type base, size_t len) const
2473  { return slicer(base, nindex<1>(len), nindex<1>(z_axis_c)); }
2475  const_nslice<T,1> tslice(index_type base, size_t len) const
2476  { return slicer(base, nindex<1>(len), nindex<1>(t_axis_c)); }
2477 
2479  const_nslice<T,2> xyslice(index_type base, size_t width, size_t height) const
2480  { return slicer(base, nindex<2>(width, height)); }
2481 
2483  T operator()(index_type idx) const {
2484  assert("[const_nslice element access out of bounds]" && idx < dm_size && dm_var);
2485  return dm_var[dm_prime + (idx*dm_stride)];
2486  }
2487 
2488  // *** 1D vector like access ***
2489 
2491  T operator[](size_t idx) const {
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]];
2494  }
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]];
2499  }
2500 
2501  // *** 2D matrix like access ***
2502 
2512  T operator()(size_t x, size_t y) const {
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]];
2515  }
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]];
2528  }
2529 
2530  // 3D
2531 
2542  T& operator()(size_t x, size_t y, size_t z) const {
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]];
2545  }
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]];
2559  }
2560 
2567  bool is_flat_stride(void) const { return scopira::basekit::is_flat_stride(dm_stride, dm_size); }
2568 };
2569 
2570 //
2571 //
2572 // const_nslice
2573 //
2574 //
2575 
2576 template <class T, int DIM>
2578  : dm_var(0)
2579 {
2580 }
2581 
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)
2586 {
2587 }
2588 
2589 template <class T, int DIM>
2591 {
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");
2594  return const_nslice<T,1>(dm_var, dm_prime, nindex<1>(dm_size[0]), nindex<1>(dm_stride[1]+1));
2595 }
2596 
2597 template <class T, int DIM>
2599 {
2600  *this = rhs.all_slice();
2601 }
2602 
2603 template <class T, int DIM>
2605 {
2606  *this = rhs->all_slice();
2607 }
2608 
2609 template <class T, int DIM>
2610 scopira::basekit::const_nslice<T,DIM>::const_nslice(const T * _var, size_t _prime, index_type _size, index_type _stride)
2611  : dm_var(_var), dm_prime(_prime),
2612  dm_size(_size), dm_stride(_stride)
2613 {
2614  dm_end_prime = dm_prime + dm_stride[DIM-1]*dm_size[DIM-1];
2615 }
2616 
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)
2621 {
2622 }
2623 
2624 template <class T, int DIM>
2626 {
2627  // this ONLY writes in NEW STYLE
2628  int j;
2629 
2630  out.write_int(-11); // my TAG (-10 == int sizes... -11 size_t sizes)
2631  out.write_int(DIM); // redudant, but whatever
2632  for (j=0; j<DIM; ++j)
2633  out.write_size_t(dm_size[j]);
2634  if (empty())
2635  return;
2636 
2637  // check for super fast case when stride == 1
2638 #ifndef PLATFORM_BYTESWAP
2639  if (is_flat_stride()) {
2640  out.write_array(c_array(), size());
2641  return;
2642  }
2643 #endif
2644 
2645  // write out payload
2647  const_iterator ii=begin(), endii=end();
2648  T *jj, *endjj;
2649 
2650  while (ii != endii) {
2651  for (jj=buf.begin(), endjj=buf.end(); jj != endjj && ii != endii; ++jj, ++ii)
2652  *jj = *ii;
2653 #ifdef PLATFORM_BYTESWAP
2654  scopira::tool::byte_swap_all(jj, endjj);
2655 #endif
2656  out.write_array(buf.begin(), (jj-buf.begin()));
2657  }
2658 }
2659 
2660 template <class T, int DIM>
2662 {
2663  dm_size = news;
2664  dm_end_prime = dm_prime + dm_stride[DIM-1]*dm_size[DIM-1];
2665 }
2666 
2667 template <class T, int DIM>
2668  template <int SIM>
2670  index_type base, nindex<SIM> dimen, nindex<SIM> direction) const
2671 {
2672  nindex<SIM> strides;
2673 
2674  for (size_t i=0; i<strides.size_c; ++i)
2675  strides[i] = dm_stride[direction[i]];
2676 
2677  return const_nslice<T,SIM>(dm_var, dm_prime+(base*dm_stride), dimen, strides);
2678 }
2679 
2680 template <class T, int DIM>
2681  template <int SIM>
2683  index_type base, nindex<SIM> dimen) const
2684 {
2685  return slicer(base, dimen, nindex<SIM>::steps());
2686 }
2687 
2688 template <class T, int DIM>
2690  size_t direction) const
2691 {
2692  return slicer(base, nindex<1>(len), nindex<1>(direction));
2693 }
2694 
2695 template <class T, int DIM>
2697 {
2698  return slicer(index_type(0), dm_size, nindex<DIM>::steps());
2699 }
2700 
2701 template <class T, int DIM>
2703 {
2704  index_type base(0);
2705  base[DIM-1] = r;
2706  return slicer(base, dm_size.shrink(), nindex<DIM-1>::steps());
2707 }
2708 
2709 // *1const_niterator********************************************************************
2710 
2715 template <class T, int DIM>
2717 {
2718  public:
2720  typedef T data_type;
2721  private:
2723  const T *dm_ptr;
2724  nindex<DIM> dm_cur, dm_size, dm_stride;
2725  public:
2727  const_niterator(void);
2729  const_niterator(const T *ptr, bool endptr, nindex<DIM> _size, nindex<DIM> _stride);
2730 
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); }
2737 
2739  void operator++(void);
2741  void operator--(void);
2742 
2743  // for random iterators
2745  ptrdiff_t operator-(const this_type & rhs) const {
2746  assert(DIM == 1);
2747  return (dm_cur[0] - rhs.dm_cur[0]) / dm_stride[0]; }
2749  this_type operator+(ptrdiff_t idx) const {
2750  assert(DIM == 1);
2751  this_type ret;
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;
2756  return ret;
2757  }
2759  this_type operator-(ptrdiff_t idx) const {
2760  assert(DIM == 1);
2761  this_type ret;
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;
2766  return ret;
2767  }
2769  bool operator<(const this_type &rhs) const {
2770  assert(DIM == 1);
2771  return dm_cur[0] < rhs.dm_cur[0]; }
2772 };
2773 
2774 template <class T, int DIM>
2776 {
2777 }
2778 
2779 template <class T, int DIM>
2781  : dm_ptr(ptr), dm_cur(0), dm_size(_size), dm_stride(_stride)
2782 {
2783  if (endptr)
2784  dm_cur[DIM-1] = dm_size[DIM-1];
2785 }
2786 
2787 template <class T, int DIM>
2789 {
2790  dm_ptr += dm_stride[0];
2791  ++dm_cur[0];
2792  for (size_t j=0; dm_cur[j] >= dm_size[j] && j+1<DIM; ++j) {
2793  // carry over the cur digits while doing some stride magic
2794  dm_ptr += -1*dm_stride[j]*dm_cur[j] + dm_stride[j + 1];
2795  dm_cur[j] = 0; // reset this digit
2796  ++dm_cur[j+1]; // carry over the next
2797  }
2798 }
2799 
2800 template <class T, int DIM>
2802 {
2803  for (size_t j=0; j<DIM; ++j) {
2804  // decrement the current digit
2805  if (dm_cur[j] > 0) {
2806  // done... no need to borrow futher
2807  --dm_cur[j];
2808  dm_ptr -= dm_stride[j];
2809  return;
2810  }
2811  // dm_cur[j] == 0, so well need to borrow
2812  // carry over the cur digits while doing some stride magic
2813  dm_cur[j] = dm_size[j]-1; // reset this digit
2814  dm_ptr += dm_stride[j]*dm_cur[j];
2815  }
2816 }
2817 
2818 // *1narray_o*********************************************************************
2819 
2828 template <class T, int DIM> class scopira::basekit::narray_o : public scopira::basekit::narray<T,DIM>,
2829  public scopira::tool::object
2830 {
2831  private:
2833  typedef scopira::basekit::narray<T,DIM> narray_parent_type;
2834  typedef scopira::tool::object object_parent_type;
2835  public:
2836  // ctors
2837 
2839  narray_o(void) { }
2841  narray_o(const this_type &src)
2842  : narray_parent_type(src) { }
2844  narray_o(const narray_parent_type &src)
2845  : narray_parent_type(src) { }
2847  explicit narray_o(const nindex<DIM> &sz)
2848  : narray_parent_type(sz) { }
2850  explicit narray_o(size_t width, size_t height)
2851  : narray_parent_type(width, height) { }
2852 
2853  // object stuff
2854 
2855  virtual bool load(scopira::tool::iobjflow_i &in) { return narray_parent_type::load(in); }
2856  virtual void save(scopira::tool::oobjflow_i &out) const { narray_parent_type::save(out); }
2857 
2859  void operator=(const this_type &at) { copy(at); }
2860 };
2861 
2862 //
2863 //
2864 // misc funcs
2865 //
2866 //
2867 
2868 namespace std {
2874 template <typename T> struct iterator_traits<scopira::basekit::niterator<T,1> >
2875 {
2876  public:
2877  typedef std::random_access_iterator_tag iterator_category;
2878  typedef T value_type;
2879  typedef ptrdiff_t difference_type;
2880  typedef T* pointer;
2881  typedef T& reference;
2882 };
2883 }//namespace std
2884 
2885 template <class E>
2887 {
2888  o << ' ' << el;
2889 }
2890 
2892 template <>
2894 {
2895  flow_printf(o, " %8ld", el);
2896 }
2897 
2899 template <>
2901 {
2902  flow_printf(o, " %8lu", el);
2903 }
2904 
2906 template <>
2908 {
2909  flow_printf(o, " %8d", el);
2910 }
2911 
2913 template <>
2915 {
2916  flow_printf(o, " %8u", el);
2917 }
2918 
2920 template <>
2922 {
2923  flow_printf(o, " %8d", el);
2924 }
2925 
2927 template <>
2929 {
2930  flow_printf(o, " %4d", el);
2931 }
2932 
2934 template <>
2936 {
2937  flow_printf(o, " %8.2f", el);
2938 }
2939 
2941 template <>
2943 {
2944  flow_printf(o, " %8.2f", el);
2945 }
2946 
2948 template <class C>
2951 {
2952  size_t i, mx;
2953 
2954  mx = V.size();
2955  o << "Vector, len=" << mx << ":";
2956  for (i=0; i<mx; i++) {
2957  if (i % 10 == 0)
2958  flow_printf(o, "\n %4d:", i);
2959  print_element(o, V[i]);
2960  }
2961 
2962  return o << '\n';
2963 }
2964 
2966 template <class C>
2969 {
2970  size_t x, y, w, h;
2971 
2972  w = M.width();
2973  h = M.height();
2974 
2975  flow_printf(o, "Matrix, w=%d h=%d:\n ", w, h);
2976  for (x=0; x<w; x++)
2977  flow_printf(o, " %7d:", x);
2978  o << '\n';
2979  for (y=0; y<h; y++) {
2980  flow_printf(o, " %4d: ", y);
2981  for (x=0; x<w; x++)
2982  print_element(o, M(x,y));
2983  o << '\n';
2984  }
2985  return o;
2986 }
2987 
2992 template <class T, int DIM> scopira::tool::oflow_i & operator << (scopira::tool::oflow_i &o,
2994 {
2995  size_t k, kmax;
2996  for (k=0, kmax=A.size_rows(); k<kmax; ++k) {
2997  o << "Sub Slice (depth=" << DIM << ") " << k << ":\n";
2998  o << A.row_slice(k) << '\n';
2999  }
3000 
3001  return o;
3002 }
3003 
3008 template <class T> inline scopira::tool::oflow_i & operator << (scopira::tool::oflow_i &o,
3010 {
3011  return print_vector_slice(o, A);
3012 }
3013 
3018 template <class T> inline scopira::tool::oflow_i & operator << (scopira::tool::oflow_i &o,
3020 {
3021  return print_matrix_slice(o, A);
3022 }
3023 
3028 template <class T, int DIM> inline scopira::tool::oflow_i & operator << (scopira::tool::oflow_i &o,
3030 {
3031  return o << scopira::basekit::const_nslice<T, DIM>(A);
3032 }
3033 
3038 template <class T, int DIM>
3039 inline
3042 {
3043  return o << A.all_slice();
3044 }
3045 
3050 template <class T, int DIM>
3051 inline
3054 {
3055  return o << A.all_slice();
3056 }
3057 
3062 template <int DIM>
3065 {
3066  o << '(' << d[0];
3067  for (size_t x=1; x<DIM; ++x)
3068  o << ',' << d[x];
3069  return o << ')';
3070 }
3071 
3073 template <class C>
3074  std::ostream & scopira::basekit::print_vector_slice(std::ostream &o, const const_nslice<C,1> &V)
3075 {
3076  size_t i, mx;
3077 
3078  mx = V.size();
3079  o << "Vector, len=" << mx << ":";
3080  for (i=0; i<mx; i++) {
3081  if (i % 5 == 0)
3082  o << "\n " << std::setw(4) << i << ":";
3083  o.width(8);
3084  o << std::setw(14) << V[i];
3085  }
3086 
3087  return o << '\n';
3088 }
3089 
3091 template <class C>
3093  (std::ostream &o, const const_nslice<C,2> &M)
3094 {
3095  size_t x, y, w, h;
3096 
3097  w = M.width();
3098  h = M.height();
3099 
3100  o << "Matrix, w=" << w << " h=" << h << ":\n ";
3101  for (x=0; x<w; x++)
3102  o << std::setw(13) << x << ':';
3103  o << '\n';
3104  for (y=0; y<h; y++) {
3105  o << std::setw(4) << y << ':';
3106  for (x=0; x<w; x++)
3107  o << std::setw(14) << M(x,y);
3108  o << '\n';
3109  }
3110  return o;
3111 }
3112 
3117 template <class T, int DIM> std::ostream & operator << (std::ostream &o,
3119 {
3120  size_t k, kmax;
3121  for (k=0, kmax=A.size_rows(); k<kmax; ++k) {
3122  o << "Sub Slice (depth=" << DIM << ") " << k << ":\n";
3123  o << A.row_slice(k) << '\n';
3124  }
3125 
3126  return o;
3127 }
3128 
3133 template <class T> inline std::ostream & operator << (std::ostream &o,
3135 {
3136  return print_vector_slice(o, A);
3137 }
3138 
3143 template <class T> inline std::ostream & operator << (std::ostream &o,
3145 {
3146  return print_matrix_slice(o, A);
3147 }
3148 
3153 template <class T, int DIM> inline std::ostream & operator << (std::ostream &o,
3155 {
3156  return o << scopira::basekit::const_nslice<T, DIM>(A);
3157 }
3158 
3163 template <class T, int DIM>
3164 inline
3165 std::ostream & operator << (std::ostream &o,
3167 {
3168  return o << A.all_slice();
3169 }
3170 
3175 template <class T, int DIM>
3176 inline
3177 std::ostream & operator << (std::ostream &o,
3179 {
3180  return o << A.all_slice();
3181 }
3182 
3187 template <int DIM>
3188 std::ostream & operator << (std::ostream &o,
3190 {
3191  o << '(' << d[0];
3192  for (size_t x=1; x<DIM; ++x)
3193  o << ',' << d[x];
3194  return o << ')';
3195 }
3196 
3350 #endif
3351 
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
Definition: narray.h:550
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
Definition: narray.h:69
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 bool read_size_t(size_t &)=0
const T & get(size_t idx) const
Definition: array.h:688
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
Definition: flow.h:212
nindex< 1 > shrink(void) const
returns the same, but one less
Definition: narray.h:520
Definition: narray.h:496
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
Definition: flow.h:281
virtual void write_int(int)=0
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
Definition: flow.h:352
Definition: traits.h:30
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
size_t write_array(const TT *_buf, size_t _numelem)
Definition: flow.h:190
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
size_t size(void) const
Definition: array.h:669
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
STL namespace.
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
Definition: object.h:71
size_t y(void) const
ref access
Definition: narray.h:651
iterator end(void)
Definition: array.h:647
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
Definition: narray.h:96
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
Definition: uuid.h:183
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
void byte_swap_all(ITER head, ITER tail)
Definition: util.h:554
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
Definition: narray.h:98
virtual void write_size_t(size_t)=0
Definition: narray.h:607
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
size_t read_array(TT *_buf, size_t _numelem)
Definition: flow.h:139
narray< float, 1 > floatvec_t
Definition: narray.h:180
narray< char, 1 > charvec_t
Definition: narray.h:165
Definition: narray.h:102
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
Definition: narray.h:50
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
Definition: narray.h:151
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
Definition: flow.h:421
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
virtual bool read_int(int &)=0
Definition: array.h:32
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
Definition: narray.h:449
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
Definition: narray.h:101
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
Definition: narray.h:99
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
iterator begin(void)
Definition: array.h:642
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
Definition: flow.h:159
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