vtf-logo

GridData1.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #ifndef _included_GridData_1_h
00004 #define _included_GridData_1_h
00005 
00011 #include "DAGHParams.h"
00012 
00013 #ifdef DEBUG_PRINT_GD_MEMORY
00014 #include "DAGHMemoryTrace.h"
00015 #endif
00016 
00017 #include "BBox.h"
00018 #include "Coords.h"
00019 #include "PackedGridDataBucket.h"
00020 
00021 #ifdef DEBUG_PRINT
00022 #include "CommServer.h"
00023 #endif
00024 
00025 #include "IndexGridData1.h"
00026 #include "generic.h"
00027 
00028 #ifndef gd_OperateRegion
00029 #define gd_OperateRegion(op)    name2(gd_OperateRegion,op)
00030 #endif
00031 
00032 // #include "GDIterator.h"
00033 
00034 #include <iosfwd>
00035 #include <iostream>
00036 #include <fstream>
00037 #include <sstream>
00038 #include <cstdlib>
00039 #include <cassert>
00040 
00041 template <class Type, int dim> class GridData;
00042 template <class Type>
00043 std::ostream& operator<<(std::ostream&, const GridData<Type,1>&);
00044 template <class Type>
00045 std::ofstream& operator<<(std::ofstream&, const GridData<Type,1>&);
00046 template <class Type>
00047 std::ifstream& operator>>(std::ifstream&, GridData<Type,1>&);
00048 template <class Type>
00049 std::stringstream& operator<<(std::stringstream&, const GridData<Type,1>&);
00050 template <class Type>
00051 std::stringstream& operator>>(std::stringstream&, GridData<Type,1>&);
00052 
00062 template <class Type> class GridData<Type,1> { 
00063   BBox _bbox;
00064   Coords _extents;
00065   Coords _step;
00066   int _size;
00067   int _bottom;
00068   Type *_data;
00069 
00070 public:
00071   GridData(void) : _bbox(), _extents(0,0), _step(1,1),
00072                    _size(0), _bottom(0), _data((Type *) 0) {}
00073 
00074   GridData(const BBox& bb)  : _bbox(bb) {
00075     _bbox.rank = 1; 
00076     _bbox.lower().rank = 1;
00077     _bbox.upper().rank = 1;
00078     _bbox.stepsize().rank = 1;
00079     _extents = _bbox.extents();
00080     _step = _bbox.stepsize();
00081     _bottom = _bbox.bottom();
00082     _size = _bbox.size();
00083     _data = _size ? new Type[_size] : ((Type *) 0);
00084 #ifdef DEBUG_PRINT_GD
00085     assert (_data!=0);
00086     fill(9999);
00087     ( comm_service::log() << "Data Check"
00088       << _bbox 
00089       << ": " << _data[_size-1]
00090       << std::endl ).flush();
00091 #endif
00092 #ifdef DEBUG_PRINT_GD_MEMORY
00093     DAGHMemoryTrace::alloc(sizeof(Type)*_size); 
00094 #endif
00095   }
00096 
00097   GridData(const int i, const int ii)  : 
00098     _bbox(1,i,ii,1), _extents(_bbox.extents()), _step(_bbox.stepsize()),
00099     _size(_bbox.size()), _bottom(_bbox.bottom()),
00100     _data(_size ? new Type[_size] : ((Type *) 0)) {
00101 #ifdef DEBUG_PRINT_GD
00102     assert (_data!=0);
00103     fill(9999);
00104     ( comm_service::log() << "Data Check"
00105       << _bbox 
00106       << ": " << _data[_size-1]
00107       << std::endl ).flush();
00108 #endif
00109 #ifdef DEBUG_PRINT_GD_MEMORY
00110     DAGHMemoryTrace::alloc(sizeof(Type)*_size); 
00111 #endif
00112   }
00113 
00114   GridData(const int i, const int ii,  const int s)  : 
00115     _bbox(1,i,ii,s), _extents(_bbox.extents()), _step(_bbox.stepsize()),
00116     _size(_bbox.size()), _bottom(_bbox.bottom()),
00117     _data(_size ? new Type[_size] : ((Type *) 0)) {
00118 #ifdef DEBUG_PRINT_GD
00119     assert (_data!=0);
00120     fill(9999);
00121     ( comm_service::log() << "Data Check"
00122       << _bbox 
00123       << ": " << _data[_size-1]
00124       << std::endl ).flush();
00125 #endif
00126 #ifdef DEBUG_PRINT_GD_MEMORY
00127     DAGHMemoryTrace::alloc(sizeof(Type)*_size); 
00128 #endif
00129   }
00130 
00131   GridData(const BBox& bb, Type *databuf) : 
00132     _bbox(bb), _data(databuf) {
00133     _bbox.rank = 1; 
00134     _bbox.lower().rank = 1;
00135     _bbox.upper().rank = 1;
00136     _bbox.stepsize().rank = 1;
00137     _extents = _bbox.extents();
00138     _step = _bbox.stepsize();
00139     _bottom = _bbox.bottom();
00140     _size = _bbox.size();
00141 #ifdef DEBUG_PRINT_GD
00142     assert (_data!=0);
00143     fill(9999);
00144     ( comm_service::log() << "Data Check"
00145       << _bbox 
00146       << ": " << _data[_size-1]
00147       << std::endl ).flush();
00148 #endif
00149 #ifdef DEBUG_PRINT_GD_MEMORY
00150     DAGHMemoryTrace::alloc(sizeof(Type)*_size); 
00151 #endif
00152   }
00153 
00154   GridData(GridDataBucket<Type> &gdbkt) : 
00155     _bbox(gdbkt.bbox()), _data(gdbkt.data()) {
00156     _bbox.rank = 1; 
00157     _bbox.lower().rank = 1;
00158     _bbox.upper().rank = 1;
00159     _bbox.stepsize().rank = 1;
00160     _extents = _bbox.extents();
00161     _step = _bbox.stepsize();
00162     _bottom = _bbox.bottom();
00163     _size = _bbox.size();
00164 #ifdef DEBUG_PRINT_GD
00165     assert (_data!=0);
00166     fill(9999);
00167     ( comm_service::log() << "Data Check"
00168       << _bbox 
00169       << ": " << _data[_size-1]
00170       << std::endl ).flush();
00171 #endif
00172 #ifdef DEBUG_PRINT_GD_MEMORY
00173     DAGHMemoryTrace::alloc(sizeof(Type)*_size); 
00174 #endif
00175   }
00176 
00177    GridData(GridDataBucket<Type> &gdbkt, const int n): _bbox(gdbkt.bbox(n)),
00178     _data(gdbkt.data(n))
00179     {
00180       _bbox.rank = 1; 
00181       _bbox.lower().rank = 1;
00182       _bbox.upper().rank = 1;
00183       _bbox.stepsize().rank = 1;
00184       _extents = _bbox.extents();
00185       _step = _bbox.stepsize();
00186       _bottom = _bbox.bottom();
00187       _size = _bbox.size();
00188 #ifdef DEBUG_PRINT_GD
00189     assert (_data!=0);
00190     fill(9999);
00191     ( comm_service::log() << "Data Check"
00192                           << _bbox 
00193                           << ": " << _data[_size-1]
00194                           << std::endl ).flush();
00195 #endif
00196 #ifdef DEBUG_PRINT_GD_MEMORY
00197     DAGHMemoryTrace::alloc(sizeof(Type)*_size); 
00198 #endif
00199     }
00200 
00201   /* A "pseudo" copy-constructor */
00202   GridData (const GridData<Type,1> &other) : 
00203     _bbox(other._bbox), _extents(other._extents), _step(other._step),
00204     _size(other._size), _bottom(other._bottom),
00205     _data(_size ? new Type[_size] : ((Type *) 0)) {
00206 #ifdef DEBUG_PRINT_GD
00207     assert (_data!=0);
00208     fill(9999);
00209     ( comm_service::log() << "Data Check"
00210       << _bbox 
00211       << ": " << _data[_size-1]
00212       << std::endl ).flush();
00213 #endif
00214 #ifdef DEBUG_PRINT_GD_MEMORY
00215     DAGHMemoryTrace::alloc(sizeof(Type)*_size); 
00216 #endif
00217   }
00218 
00219    inline ~GridData(void) { 
00220      if (_data) {
00221        delete [] _data; 
00222 #ifdef DEBUG_PRINT_GD_MEMORY
00223        DAGHMemoryTrace::free(sizeof(Type)*_size);
00224 #endif
00225      }
00226    }
00227 
00228   void allocate(const BBox &bb) {
00229     _bbox = bb;
00230     _bbox.rank = 1; 
00231     _bbox.lower().rank = 1;
00232     _bbox.upper().rank = 1;
00233     _bbox.stepsize().rank = 1;
00234     _extents = _bbox.extents();
00235     _step = _bbox.stepsize();
00236     _bottom = _bbox.bottom();
00237     _size = _bbox.size();
00238     _data = _size ? new Type[_size] : (Type *) 0;
00239 #ifdef DEBUG_PRINT_GD
00240     assert (_data!=0);
00241     fill(9999);
00242     ( comm_service::log() << "Data Check"
00243       << _bbox 
00244       << ": " << _data[_size-1]
00245       << std::endl ).flush();
00246 #endif
00247 #ifdef DEBUG_PRINT_GD_MEMORY
00248     DAGHMemoryTrace::alloc(sizeof(Type)*_size); 
00249 #endif
00250   }
00251 
00252    void allocate(const BBox &bb, Type *databuf) {
00253      _bbox = bb;
00254      _bbox.rank = 1; 
00255      _bbox.lower().rank = 1;
00256      _bbox.upper().rank = 1;
00257      _bbox.stepsize().rank = 1;
00258      _extents = _bbox.extents();
00259      _step = _bbox.stepsize();
00260      _bottom = _bbox.bottom();
00261      _size = _bbox.size();
00262 #ifdef DEBUG_PRINT_GD
00263      assert(_data==0);
00264 #endif
00265      _data = databuf;
00266 #ifdef DEBUG_PRINT_GD
00267      assert (_data!=0);
00268      fill(9999);
00269      ( comm_service::log() << "Data Check"
00270        << _bbox 
00271        << ": " << _data[_size-1]
00272        << std::endl ).flush();
00273 #endif
00274    }
00275 
00276    inline void allocate(Type *databuf) {
00277      if (_data) {
00278        delete [] _data; _data = (Type*)0;
00279 #ifdef DEBUG_PRINT_GD_MEMORY
00280        DAGHMemoryTrace::free(sizeof(Type)*_size);
00281 #endif
00282      }
00283      _data = databuf;
00284    }
00285   
00286   inline void deallocate() {
00287     if (_data) {
00288       delete [] _data; _data = (Type*)0;
00289 #ifdef DEBUG_PRINT_GD_MEMORY
00290       DAGHMemoryTrace::free(sizeof(Type)*_size);
00291 #endif
00292     }
00293   }
00294   inline void deallocate(Type*& databuf)
00295   { databuf = _data; _data = (Type*) 0; }
00296   
00297   void* databuffer() { return ((void*) _data); }
00298 
00299   /* Query funtions */
00300   /* Define some inline functions for getting at region extents */
00301   
00302   inline const Coords& lower() const { return(_bbox.lower()); }
00303   inline const Coords& upper() const { return(_bbox.upper()); }
00304   inline const Coords& extents() const { return(_extents); }
00305   inline const Coords& stepsize() const { return(_step); }
00306   inline Coords lower() { return(_bbox.lower()); }
00307   inline Coords upper() { return(_bbox.upper()); }
00308   inline Coords extents() { return(_extents); }
00309   inline Coords stepsize() { return(_step); }
00310   inline int bottom() const { return(_bottom); }
00311   inline int lower(const int i) const { return(_bbox.lower(i)); }
00312   inline int upper(const int i) const { return(_bbox.upper(i)); }
00313   inline int extents(const int i) const { return(_extents(i)); }
00314   inline int stepsize(const int i) const { return(_step(i)); }
00315   inline const BBox& bbox() const { return(_bbox); }
00316 
00317   /* Define the inline functions for indexing the GridData object */
00318 
00319   inline int ok_to_index() { return(_data != (Type *) 0); }
00320   inline int size() const { return(_size); }
00321   
00322   inline int idx(const int i) const
00323   { return( _bottom+(i/_step(0)) ); }
00324   
00325   inline const Type& operator () (const int i) const
00326   { assert(idx(i) >= 0 && idx(i) < _size); return(_data[idx(i)]); }
00327   inline Type& operator () (const int i)
00328   { assert(idx(i) >= 0 && idx(i) < _size); return(_data[idx(i)]); }
00329   
00330   inline const Type& operator () (const Coords& c) const
00331   { assert(idx(c(0)) >= 0 && idx(c(0)) < _size); return(_data[idx(c(0))]); }
00332   inline Type& operator () (const Coords& c)
00333   { assert(idx(c(0)) >= 0 && idx(c(0)) < _size); return(_data[idx(c(0))]); }
00334   
00335   inline const Type *ptr(const int i) const
00336   { assert(idx(i) >= 0 && idx(i) < _size); return(_data + idx(i)); }
00337   inline Type *ptr(const int i)
00338   { assert(idx(i) >= 0 && idx(i) < _size); return(_data + idx(i)); }
00339   
00340   inline const Type *ptr(const Coords& c) const
00341   { assert(idx(c(0)) >= 0 && idx(c(0)) < _size); return(_data + idx(c(0))); }
00342   inline Type *ptr(const Coords& c)
00343   { assert(idx(c(0)) >= 0 && idx(c(0)) < _size); return(_data + idx(c(0))); }
00344   
00345   inline const Type *data() const { return(_data); }
00346   inline Type *data() { return(_data); }
00347 
00348    void fill(const Type &val)
00349   { register int i; for (i = 0; i < _size; i++) _data[i] = val; }
00350 
00351   /* Define the copy functions for communication between objects */
00352   void copy(const GridData<Type,1> &gd) {
00353     if (&gd != this) {
00354       BBox intersection = _bbox * gd._bbox;
00355       if (!intersection.empty()) { 
00356         Coords max_step = _step.getmax(gd._step);
00357         BBox to(intersection); to.setstepsize(_step); 
00358         BBox from(intersection); from.setstepsize(gd._step);
00359         gd_CopyRegion(gd, to, from, max_step); 
00360       }
00361     }
00362   }
00363 
00364   void copy(const GridData<Type,1> &gd, const BBox &where) {
00365     if (&gd != this) {
00366       BBox intersection = _bbox * gd._bbox * where;
00367       if (!intersection.empty()) { 
00368         Coords max_step = _step.getmax(gd._step);
00369         BBox to(intersection); to.setstepsize(_step); 
00370         BBox from(intersection); from.setstepsize(gd._step);
00371          gd_CopyRegion(gd, to, from, max_step); 
00372       }
00373     }
00374   }
00375 
00376   void copy(const GridData<Type,1> &gd, const BBox &to, const BBox &from) {
00377     const Coords  toshift = from.lower() - to.lower();
00378     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00379     if (!newfrom.empty()) {
00380       BBox newto = shiftabs(newfrom, -toshift);
00381       Coords max_step = _step.getmax(gd._step);
00382       newto.setstepsize(_step);
00383       newfrom.setstepsize(gd._step);
00384       gd_CopyRegion(gd, newto, newfrom, max_step);
00385     }
00386   }
00387 
00388   void copy(const GridDataBucket<Type> &gdbkt)  {
00389     BBox const &gdbktbb = gdbkt.bbox();
00390     BBox intersection = _bbox * gdbktbb;
00391     if (!intersection.empty()) { 
00392       Coords max_step = _step.getmax(gdbktbb.stepsize());
00393       BBox to(intersection); to.setstepsize(_step); 
00394       BBox from(intersection); from.setstepsize(gdbktbb.stepsize());
00395       gdb_CopyRegion(gdbkt, to, from, max_step); 
00396     }
00397   }
00398 
00399   void copy(const GridDataBucket<Type> &gdbkt, const BBox &where) {
00400     BBox const &gdbktbb = gdbkt.bbox();
00401     BBox intersection = _bbox * gdbktbb * where;
00402     if (!intersection.empty()) { 
00403       Coords max_step = _step.getmax(gdbktbb.stepsize());
00404       BBox to(intersection); to.setstepsize(_step); 
00405       BBox from(intersection); from.setstepsize(gdbktbb.stepsize());
00406       gdb_CopyRegion(gdbkt, to, from, max_step); 
00407     }
00408   }
00409 
00410   void copy(const GridDataBucket<Type> &gdbkt, const BBox &to, 
00411             const BBox &from) {
00412     BBox const &gdbktbb = gdbkt.bbox();
00413     const Coords  toshift = from.lower() - to.lower();
00414     BBox newfrom = gdbktbb * from * shiftabs(_bbox * to, toshift);
00415     if (!newfrom.empty()) {
00416       BBox newto = shiftabs(newfrom, -toshift);
00417       Coords max_step = _step.getmax(gdbktbb.stepsize());
00418       newto.setstepsize(_step);
00419       newfrom.setstepsize(gdbktbb.stepsize());
00420       gdb_CopyRegion(gdbkt, newto, newfrom, max_step);
00421     }
00422   }
00423   
00424   void copy(const GridDataBucket<Type> &gdbkt, const int n) {
00425     BBox const &gdbktbb = gdbkt.bbox(n);
00426     BBox intersection = _bbox * gdbktbb;
00427     if (!intersection.empty()) { 
00428       Coords max_step = _step.getmax(gdbktbb.stepsize());
00429       BBox to(intersection); to.setstepsize(_step); 
00430       BBox from(intersection); from.setstepsize(gdbktbb.stepsize());
00431       gdb_CopyRegion(gdbkt, n, to, from, max_step); 
00432     }
00433   }
00434   
00435   void copy(const GridDataBucket<Type> &gdbkt, const int n, const BBox &where) {
00436     BBox const &gdbktbb = gdbkt.bbox(n);
00437     BBox intersection = _bbox * gdbktbb * where;
00438     if (!intersection.empty()) { 
00439       Coords max_step = _step.getmax(gdbktbb.stepsize());
00440       BBox to(intersection); to.setstepsize(_step); 
00441       BBox from(intersection); from.setstepsize(gdbktbb.stepsize());
00442       gdb_CopyRegion(gdbkt, n, to, from, max_step); 
00443     }
00444   }
00445 
00446   void copy(const GridDataBucket<Type> &gdbkt, const int n, const BBox &to, 
00447             const BBox &from) {
00448     BBox const &gdbktbb = gdbkt.bbox(n);
00449     const Coords  toshift = from.lower() - to.lower();
00450     BBox newfrom = gdbktbb * from * shiftabs(_bbox * to, toshift);
00451     if (!newfrom.empty()) {
00452       BBox newto = shiftabs(newfrom, -toshift);
00453       Coords max_step = _step.getmax(gdbktbb.stepsize());
00454       newto.setstepsize(_step);
00455       newfrom.setstepsize(gdbktbb.stepsize());
00456       gdb_CopyRegion(gdbkt, n, newto, newfrom, max_step);
00457     }
00458   }
00459 
00460   /* Linear interpolation */
00461   void lin_interp(const GridData<Type,1> &gd1, const double frac1,
00462                   const GridData<Type,1> &gd2, const double frac2,
00463                   const BBox &where) {
00464     BBox intersection = _bbox * gd1._bbox * gd2._bbox * where;
00465     if (!intersection.empty()) {
00466 
00467       Coords max_step = _step.getmax(gd1._step);
00468       max_step.max(gd2._step);
00469 
00470       GridData<Type,1> &dst = *this;
00471 
00472       BeginFastIndex1(src1, gd1._bbox, gd1._data, const Type);
00473       BeginFastIndex1(src2, gd2._bbox, gd2._data, const Type);
00474       BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00475 
00476       for_1(i, intersection, max_step)
00477         FastIndex1(dst,i) = (Type) ((FastIndex1(src1,i) * frac1)
00478                                     + (FastIndex1(src2,i) * frac2));
00479       end_for
00480 
00481       EndFastIndex1(dst);
00482       EndFastIndex1(src1);
00483       EndFastIndex1(src2);
00484     }
00485   }
00486     
00487   inline void lin_interp(const GridData<Type,1> &gd1, const double frac1,
00488                          const GridData<Type,1> &gd2, const double frac2)
00489   { GridData<Type,1>::lin_interp(gd1,frac1,gd2,frac2,_bbox); }
00490 
00491   /* first moment (i think) sum(q(i)*i) */
00492   Type moment1(const int axis, const BBox &where) {
00493     Type m1 = (Type) 0;
00494     BBox intersection = _bbox * where;
00495     if (!intersection.empty()) {
00496       Coords max_step = _step.getmax(where.stepsize());
00497       intersection.setstepsize(_step);
00498       
00499       GridData<Type,1> &dst = *this;
00500 
00501       BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00502 
00503       if (axis == DAGH_X) {
00504         for_1(i, intersection, max_step)
00505           m1 += FastIndex1(dst,i) * i;
00506         end_for
00507       }
00508 
00509       EndFastIndex1(dst);
00510     }
00511     return (m1);
00512   }
00513 
00514   inline Type moment1(const int axis)
00515   { return (GridData<Type,1>::moment1(axis,_bbox)); }
00516 
00517   /* sum of squares - for calculating L2-norm */
00518   double sumsqrd(const BBox &where) {
00519     double s = 0.0;
00520     BBox intersection = _bbox * where;
00521     if (!intersection.empty()) {
00522       Coords max_step = _step.getmax(where.stepsize());
00523       intersection.setstepsize(_step);
00524       
00525       GridData<Type,1> &dst = *this;
00526       
00527       BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00528 
00529       for_1(i, intersection, max_step)
00530         s += Abs(FastIndex1(dst,i)) * Abs(FastIndex1(dst,i));
00531       end_for
00532 
00533       EndFastIndex1(dst);
00534 
00535     }
00536     return s;
00537   }
00538 
00539   inline double sumsqrd()
00540   { return (GridData<Type,1>::sumsqrd(_bbox)); }
00541 
00542   /* sum of absolute values - for calculating L1-norm */
00543   double sumabs(const BBox &where) {
00544     double s = 0.0;
00545     BBox intersection = _bbox * where;
00546     if (!intersection.empty()) {
00547       Coords max_step = _step.getmax(where.stepsize());
00548       intersection.setstepsize(_step);
00549       
00550       GridData<Type,1> &dst = *this;
00551       
00552       BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00553 
00554       for_1(i, intersection, max_step)
00555         s += Abs(FastIndex1(dst,i));
00556       end_for
00557 
00558       EndFastIndex1(dst);
00559 
00560     }
00561     return s;
00562   }
00563 
00564   inline double sumabs()
00565   { return (GridData<Type,1>::sumabs(_bbox)); }
00566 
00567   /* Maximum of absolute values - for calculating Loo-norm */
00568   double maxabs(const BBox &where) {
00569     double m = 0.0;
00570     BBox intersection = _bbox * where;
00571     if (!intersection.empty()) {
00572       Coords max_step = _step.getmax(where.stepsize());
00573       intersection.setstepsize(_step);
00574       
00575       GridData<Type,1> &dst = *this;
00576 
00577       BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00578 
00579       for_1(i, intersection, max_step)
00580         double t = Abs(FastIndex1(dst,i));
00581         m = Max(m,t);
00582       end_for
00583 
00584       EndFastIndex1(dst);
00585 
00586     }
00587     return m;
00588   }
00589 
00590   inline double maxabs()
00591   { return (GridData<Type,1>::maxabs(_bbox)); }
00592 
00593   /* operator == */
00594   BBox is_eq(const Type &val, const BBox &where)  {
00595     BBox intersection = _bbox * where;
00596     if (!intersection.empty()) {
00597       Coords max_step = _step.getmax(where.stepsize());
00598       BBox to(intersection); to.setstepsize(_step);
00599       BBox bb(1,max_step);
00600       gd_OperateRegion(is_eq)(val, to, max_step, bb);
00601       return (bb);
00602     }
00603     else 
00604       { BBox bb(1,1); return (bb); }
00605   }
00606 
00607   inline BBox is_eq(const Type &val) 
00608   { return (GridData<Type,1>::is_eq(val, _bbox)); }
00609 
00610   BBox is_eq(const GridData<Type,1> &gd, const BBox &to, const BBox &from)  {
00611     const Coords  toshift = from.lower() - to.lower();
00612     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00613     if (!newfrom.empty()) {
00614       BBox newto = shiftabs(newfrom, -toshift);
00615       Coords max_step = _step.getmax(gd._step);
00616       newto.setstepsize(_step);
00617       newfrom.setstepsize(gd._step);
00618       BBox bb(1,max_step);
00619       gd_OperateRegion(is_eq)(gd, newto, newfrom, max_step, bb);
00620       return (bb);
00621     }
00622     else 
00623       { BBox bb(1,1); return (bb); }
00624   }
00625 
00626   inline BBox is_eq(const GridData<Type,1> &gd)
00627   { return (GridData<Type,1>::is_eq(gd, gd._bbox, gd._bbox)); }
00628   inline BBox is_eq(const GridData<Type,1> &gd, const BBox &where)
00629   { return (GridData<Type,1>::is_eq(gd, where, where)); }
00630 
00631   /* operator != */
00632   BBox is_neq(const Type &val, const BBox &where) {
00633     BBox intersection = _bbox * where;
00634     if (!intersection.empty()) {
00635       Coords max_step = _step.getmax(where.stepsize());
00636       BBox to(intersection); to.setstepsize(_step);
00637       BBox bb(1,max_step);
00638       gd_OperateRegion(is_neq)(val, to, max_step, bb);
00639       return (bb);
00640     }
00641     else 
00642       { BBox bb(1,1); return (bb); }
00643   }
00644 
00645   inline BBox is_neq(const Type &val) 
00646   { return (GridData<Type,1>::is_neq(val, _bbox)); }
00647 
00648   BBox is_neq(const GridData<Type,1> &gd, const BBox &to, const BBox &from)  {
00649     const Coords  toshift = from.lower() - to.lower();
00650     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00651     if (!newfrom.empty()) {
00652       BBox newto = shiftabs(newfrom, -toshift);
00653       Coords max_step = _step.getmax(gd._step);
00654       newto.setstepsize(_step);
00655       newfrom.setstepsize(gd._step);
00656       BBox bb(1,max_step);
00657       gd_OperateRegion(is_neq)(gd, newto, newfrom, max_step, bb);
00658       return (bb);
00659     }
00660     else 
00661       { BBox bb(1,1); return (bb); }
00662   }
00663 
00664   inline BBox is_neq(const GridData<Type,1> &gd)
00665   { return (GridData<Type,1>::is_neq(gd, gd._bbox, gd._bbox)); }
00666   inline BBox is_neq(const GridData<Type,1> &gd, const BBox &where)
00667   { return (GridData<Type,1>::is_neq(gd, where, where)); }
00668 
00669   /* operator > */
00670   BBox is_gt(const Type &val, const BBox &where)  {
00671     BBox intersection = _bbox * where;
00672     if (!intersection.empty()) {
00673       Coords max_step = _step.getmax(where.stepsize());
00674       BBox to(intersection); to.setstepsize(_step);
00675       BBox bb(1,max_step);
00676       gd_OperateRegion(is_gt)(val, to, max_step, bb);
00677       return (bb);
00678     }
00679     else 
00680       { BBox bb(1,1); return (bb); }
00681   }
00682 
00683   inline BBox is_gt(const Type &val) 
00684   { return (GridData<Type,1>::is_gt(val, _bbox)); }
00685   
00686   BBox is_gt(const GridData<Type,1> &gd, const BBox &to, const BBox &from) {
00687     const Coords  toshift = from.lower() - to.lower();
00688     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00689     if (!newfrom.empty()) {
00690       BBox newto = shiftabs(newfrom, -toshift);
00691       Coords max_step = _step.getmax(gd._step);
00692       newto.setstepsize(_step);
00693       newfrom.setstepsize(gd._step);
00694       BBox bb(1,max_step);
00695       gd_OperateRegion(is_gt)(gd, newto, newfrom, max_step, bb);
00696       return (bb);
00697     }
00698     else 
00699       { BBox bb(1,1); return (bb); }
00700   }
00701 
00702   inline BBox is_gt(const GridData<Type,1> &gd)
00703   { return (GridData<Type,1>::is_gt(gd, gd._bbox, gd._bbox)); }
00704   inline BBox is_gt(const GridData<Type,1> &gd, const BBox &where)
00705   { return (GridData<Type,1>::is_gt(gd, where, where)); }
00706 
00707   /* operator >= */
00708   BBox is_ge(const Type &val, const BBox &where) {
00709     BBox intersection = _bbox * where;
00710     if (!intersection.empty()) {
00711       Coords max_step = _step.getmax(where.stepsize());
00712       BBox to(intersection); to.setstepsize(_step);
00713       BBox bb(1,max_step);
00714       gd_OperateRegion(is_ge)(val, to, max_step, bb);
00715       return (bb);
00716     }
00717     else 
00718       { BBox bb(1,1); return (bb); }
00719   }
00720 
00721   inline BBox is_ge(const Type &val) 
00722   { return (GridData<Type,1>::is_ge(val, _bbox)); }
00723 
00724   BBox is_ge(const GridData<Type,1> &gd, const BBox &to, const BBox &from) {
00725     const Coords  toshift = from.lower() - to.lower();
00726     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00727     if (!newfrom.empty()) {
00728       BBox newto = shiftabs(newfrom, -toshift);
00729       Coords max_step = _step.getmax(gd._step);
00730       newto.setstepsize(_step);
00731       newfrom.setstepsize(gd._step);
00732       BBox bb(1,max_step);
00733       gd_OperateRegion(is_ge)(gd, newto, newfrom, max_step, bb);
00734       return (bb);
00735     }
00736     else 
00737      { BBox bb(1,1); return (bb); }
00738   }
00739 
00740   inline BBox is_ge(const GridData<Type,1> &gd)
00741   { return (GridData<Type,1>::is_ge(gd, gd._bbox, gd._bbox)); }
00742   inline BBox is_ge(const GridData<Type,1> &gd, const BBox &where)
00743   { return (GridData<Type,1>::is_ge(gd, where, where)); }
00744 
00745   /* operator < */
00746   BBox is_lt(const Type &val, const BBox &where) {
00747     BBox intersection = _bbox * where;
00748     if (!intersection.empty()) {
00749       Coords max_step = _step.getmax(where.stepsize());
00750       BBox to(intersection); to.setstepsize(_step);
00751       BBox bb(1,max_step);
00752       gd_OperateRegion(is_lt)(val, to, max_step, bb);
00753       return (bb);
00754     }
00755     else 
00756       { BBox bb(1,1); return (bb); }
00757   }
00758 
00759   inline BBox is_lt(const Type &val) 
00760   { return (GridData<Type,1>::is_lt(val, _bbox)); }
00761 
00762   BBox is_lt(const GridData<Type,1> &gd, const BBox &to, const BBox &from) {
00763     const Coords  toshift = from.lower() - to.lower();
00764     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00765     if (!newfrom.empty()) {
00766       BBox newto = shiftabs(newfrom, -toshift);
00767       Coords max_step = _step.getmax(gd._step);
00768       newto.setstepsize(_step);
00769       newfrom.setstepsize(gd._step);
00770       BBox bb(1,max_step);
00771       gd_OperateRegion(is_lt)(gd, newto, newfrom, max_step, bb);
00772       return (bb);
00773     }
00774     else 
00775       { BBox bb(1,1); return (bb); }
00776   }
00777 
00778   inline BBox is_lt(const GridData<Type,1> &gd)
00779   { return (GridData<Type,1>::is_lt(gd, gd._bbox, gd._bbox)); }
00780   inline BBox is_lt(const GridData<Type,1> &gd, const BBox &where)
00781   { return (GridData<Type,1>::is_lt(gd, where, where)); }
00782 
00783   /* operator <= */
00784   BBox is_le(const Type &val, const BBox &where) {
00785     BBox intersection = _bbox * where;
00786     if (!intersection.empty()) {
00787       Coords max_step = _step.getmax(where.stepsize());
00788       BBox to(intersection); to.setstepsize(_step);
00789       BBox bb(1,max_step);
00790       gd_OperateRegion(is_le)(val, to, max_step, bb);
00791       return (bb);
00792     }
00793     else 
00794       { BBox bb(1,1); return (bb); }
00795   }
00796 
00797   inline BBox is_le(const Type &val) 
00798   { return (GridData<Type,1>::is_le(val, _bbox)); }
00799 
00800   BBox is_le(const GridData<Type,1> &gd, const BBox &to, const BBox &from) {
00801    const Coords  toshift = from.lower() - to.lower();
00802    BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00803    if (!newfrom.empty()) {
00804      BBox newto = shiftabs(newfrom, -toshift);
00805      Coords max_step = _step.getmax(gd._step);
00806      newto.setstepsize(_step);
00807      newfrom.setstepsize(gd._step);
00808      BBox bb(1,max_step);
00809      gd_OperateRegion(is_le)(gd, newto, newfrom, max_step, bb);
00810      return (bb);
00811    }
00812    else 
00813      { BBox bb(1,1); return (bb); }
00814   }
00815 
00816   inline BBox is_le(const GridData<Type,1> &gd)
00817   { return (GridData<Type,1>::is_le(gd, gd._bbox, gd._bbox)); }
00818   inline BBox is_le(const GridData<Type,1> &gd, const BBox &where)
00819   { return (GridData<Type,1>::is_le(gd, where, where)); }
00820 
00821   /* operator = */
00822   void equals(const Type &val, const BBox &where) {
00823     BBox intersection = _bbox * where;
00824     if (!intersection.empty()) {
00825       Coords max_step = _step.getmax(where.stepsize());
00826       BBox to(intersection); to.setstepsize(_step);
00827       gd_OperateRegion(equal)(val, to, max_step);
00828     }
00829   }
00830 
00831   inline void equals(const Type &val) 
00832   { GridData<Type,1>::equals(val, _bbox); }
00833 
00834   void equals(const GridData<Type,1> &gd, const BBox &to, const BBox &from) {
00835     const Coords  toshift = from.lower() - to.lower();
00836     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00837     if (!newfrom.empty()) {
00838       BBox newto = shiftabs(newfrom, -toshift);
00839       Coords max_step = _step.getmax(gd._step);
00840       newto.setstepsize(_step);
00841       newfrom.setstepsize(gd._step);
00842       gd_OperateRegion(equal)(gd, newto, newfrom, max_step);
00843     }
00844   }
00845     
00846   inline void equals(const GridData<Type,1> &gd)
00847   { GridData<Type,1>::equals(gd, gd._bbox, gd._bbox); }
00848   inline void equals(const GridData<Type,1> &gd, const BBox &where)
00849   { GridData<Type,1>::equals(gd, where, where); }
00850 
00851   /* operator += */
00852   void plus (const Type &val, const BBox &where) {
00853     BBox intersection = _bbox * where;
00854     if (!intersection.empty()) {
00855       Coords max_step = _step.getmax(where.stepsize());
00856       BBox to(intersection); to.setstepsize(_step);
00857       gd_OperateRegion(plus)(val, to, max_step);
00858     }
00859   }
00860     
00861   inline void plus (const Type &val) 
00862   { GridData<Type,1>::plus(val, _bbox); }
00863 
00864   void plus (const GridData<Type,1> &gd, const BBox &to, const BBox &from) {
00865     const Coords  toshift = from.lower() - to.lower();
00866     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00867     if (!newfrom.empty()) {
00868       BBox newto = shiftabs(newfrom, -toshift);
00869       Coords max_step = _step.getmax(gd._step);
00870       newto.setstepsize(_step);
00871       newfrom.setstepsize(gd._step);
00872       gd_OperateRegion(plus)(gd, newto, newfrom, max_step);
00873     }
00874   }
00875 
00876   inline void plus (const GridData<Type,1> &gd)
00877   { GridData<Type,1>::plus(gd, gd._bbox, gd._bbox); }
00878   inline void plus (const GridData<Type,1> &gd, const BBox &where)
00879   { GridData<Type,1>::plus(gd, where, where); }
00880 
00881   /* operator -= */
00882   void minus (const Type &val, const BBox &where) {
00883     BBox intersection = _bbox * where;
00884     if (!intersection.empty()) {
00885       Coords max_step = _step.getmax(where.stepsize());
00886       BBox to(intersection); to.setstepsize(_step);
00887       gd_OperateRegion(minus)(val, to, max_step);
00888     }
00889   }
00890 
00891   inline void minus (const Type &val) 
00892   { GridData<Type,1>::minus(val, _bbox); }
00893 
00894   void minus (const GridData<Type,1> &gd, const BBox &to, const BBox &from) {
00895     const Coords  toshift = from.lower() - to.lower();
00896     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00897     if (!newfrom.empty()) {
00898       BBox newto = shiftabs(newfrom, -toshift);
00899       Coords max_step = _step.getmax(gd._step);
00900       newto.setstepsize(_step);
00901       newfrom.setstepsize(gd._step);
00902       gd_OperateRegion(minus)(gd, newto, newfrom, max_step);
00903     }
00904   }
00905 
00906   inline void minus (const GridData<Type,1> &gd)
00907   { GridData<Type,1>::minus(gd, gd._bbox, gd._bbox); }
00908   inline void minus (const GridData<Type,1> &gd, const BBox &where)
00909   { GridData<Type,1>::minus(gd, where, where); }
00910 
00911   /* operator *= */
00912   void multiply(const Type &val, const BBox &where) {
00913     BBox intersection = _bbox * where;
00914     if (!intersection.empty()) {
00915       Coords max_step = _step.getmax(where.stepsize());
00916       BBox to(intersection); to.setstepsize(_step);
00917       gd_OperateRegion(mult)(val, to, max_step);
00918     }
00919   }
00920 
00921   inline void multiply(const Type &val) 
00922   { GridData<Type,1>::multiply(val, _bbox); }
00923 
00924   void multiply (const GridData<Type,1> &gd, const BBox &to, const BBox &from) {
00925     const Coords  toshift = from.lower() - to.lower();
00926     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00927     if (!newfrom.empty()) {
00928       BBox newto = shiftabs(newfrom, -toshift);
00929       Coords max_step = _step.getmax(gd._step);
00930       newto.setstepsize(_step);
00931       newfrom.setstepsize(gd._step);
00932       gd_OperateRegion(mult)(gd, newto, newfrom, max_step);
00933     }
00934   }
00935 
00936   inline void multiply (const GridData<Type,1> &gd)
00937   { GridData<Type,1>::multiply(gd, gd._bbox, gd._bbox); }
00938   inline void multiply (const GridData<Type,1> &gd, const BBox &where)
00939   { GridData<Type,1>::multiply(gd, where, where); }
00940 
00941   /* operator /= */
00942   void divide (const Type &val, const BBox &where) {
00943     BBox intersection = _bbox * where;
00944     if (!intersection.empty()) {
00945       Coords max_step = _step.getmax(where.stepsize());
00946       BBox to(intersection); to.setstepsize(_step);
00947       gd_OperateRegion(div)(val, to, max_step);
00948     }
00949   }
00950 
00951   inline void divide (const Type &val) 
00952   { GridData<Type,1>::divide(val, _bbox); }
00953 
00954   void divide (const GridData<Type,1> &gd, const BBox &to, const BBox &from) {
00955     const Coords  toshift = from.lower() - to.lower();
00956     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00957     if (!newfrom.empty()) {
00958       BBox newto = shiftabs(newfrom, -toshift);
00959       Coords max_step = _step.getmax(gd._step);
00960       newto.setstepsize(_step);
00961       newfrom.setstepsize(gd._step);
00962       gd_OperateRegion(div)(gd, newto, newfrom, max_step);
00963     }
00964   }
00965 
00966   inline void divide (const GridData<Type,1> &gd)
00967   { GridData<Type,1>::divide(gd, gd._bbox, gd._bbox); }
00968   inline void divide (const GridData<Type,1> &gd, const BBox &where)
00969   { GridData<Type,1>::divide(gd, where, where); }
00970 
00971   /* point-wise minimum */
00972   void minimum (const Type &val, const BBox &where) {
00973     BBox intersection = _bbox * where;
00974     if (!intersection.empty()) {
00975       Coords max_step = _step.getmax(where.stepsize());
00976       BBox to(intersection); to.setstepsize(_step);
00977       gd_OperateRegion(min)(val, to, max_step);
00978     }
00979   }
00980 
00981   inline void minimum (const Type &val) 
00982   { GridData<Type,1>::minimum(val, _bbox); }
00983 
00984   void minimum (const GridData<Type,1> &gd, const BBox &to, const BBox &from) {
00985     const Coords  toshift = from.lower() - to.lower();
00986     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
00987     if (!newfrom.empty()) {
00988       BBox newto = shiftabs(newfrom, -toshift);
00989       Coords max_step = _step.getmax(gd._step);
00990       newto.setstepsize(_step);
00991       newfrom.setstepsize(gd._step);
00992       gd_OperateRegion(min)(gd, newto, newfrom, max_step);
00993     }
00994   }
00995 
00996   inline void minimum (const GridData<Type,1> &gd)
00997   { GridData<Type,1>::minimum(gd, gd._bbox, gd._bbox); }
00998   inline void minimum (const GridData<Type,1> &gd, const BBox &where)
00999   { GridData<Type,1>::minimum(gd, where, where); }
01000 
01001   /* point-wise maximum */
01002   void maximum (const Type &val, const BBox &where) {
01003     BBox intersection = _bbox * where;
01004     if (!intersection.empty()) {
01005       Coords max_step = _step.getmax(where.stepsize());
01006       BBox to(intersection); to.setstepsize(_step);
01007       gd_OperateRegion(max)(val, to, max_step);
01008     }
01009   }
01010 
01011   inline void maximum (const Type &val) 
01012   { GridData<Type,1>::maximum(val, _bbox); }
01013 
01014   void maximum (const GridData<Type,1> &gd, const BBox &to, const BBox &from) {
01015     const Coords  toshift = from.lower() - to.lower();
01016     BBox newfrom = gd._bbox * from * shiftabs(_bbox * to, toshift);
01017     if (!newfrom.empty()) {
01018       BBox newto = shiftabs(newfrom, -toshift);
01019       Coords max_step = _step.getmax(gd._step);
01020       newto.setstepsize(_step);
01021       newfrom.setstepsize(gd._step);
01022       gd_OperateRegion(max)(gd, newto, newfrom, max_step);
01023     }
01024   }
01025 
01026   inline void maximum (const GridData<Type,1> &gd)
01027   { GridData<Type,1>::maximum(gd, gd._bbox, gd._bbox); }
01028   inline void maximum (const GridData<Type,1> &gd, const BBox &where)
01029   { GridData<Type,1>::maximum(gd, where, where); }
01030 
01031   /**********************************************************************/
01032   inline BBox operator == (const Type &val)
01033   { return (GridData<Type,1>::is_eq(val, _bbox)); }
01034   inline BBox operator == (const GridData<Type,1> &gd)
01035   { return (GridData<Type,1>::is_eq(gd, gd._bbox, gd._bbox)); }
01036   
01037   inline BBox operator != (const Type &val)
01038   { return (GridData<Type,1>::is_neq(val, _bbox)); }
01039   inline BBox operator != (const GridData<Type,1> &gd)
01040   { return (GridData<Type,1>::is_neq(gd, gd._bbox, gd._bbox)); }
01041   
01042   inline BBox operator > (const Type &val)
01043   { return (GridData<Type,1>::is_gt(val, _bbox)); }
01044   inline BBox operator > (const GridData<Type,1> &gd)
01045   { return (GridData<Type,1>::is_gt(gd, gd._bbox, gd._bbox)); }
01046 
01047   inline BBox operator >= (const Type &val)
01048   { return (GridData<Type,1>::is_ge(val, _bbox)); }
01049   inline BBox operator >= (const GridData<Type,1> &gd)
01050   { return (GridData<Type,1>::is_ge(gd, gd._bbox, gd._bbox)); }
01051 
01052   inline BBox operator < (const Type &val)
01053   { return (GridData<Type,1>::is_lt(val, _bbox)); }
01054   inline BBox operator < (const GridData<Type,1> &gd)
01055   { return (GridData<Type,1>::is_lt(gd, gd._bbox, gd._bbox)); }
01056   
01057   inline BBox operator <= (const Type &val)
01058   { return (GridData<Type,1>::is_le(val, _bbox)); }
01059   inline BBox operator <= (const GridData<Type,1> &gd)
01060   { return (GridData<Type,1>::is_le(gd, gd._bbox, gd._bbox)); }
01061   
01062   inline void operator = (const Type &val)
01063   { GridData<Type,1>::equals(val, _bbox); }
01064   inline void operator = (const GridData<Type,1> &gd)
01065   { GridData<Type,1>::equals(gd, gd._bbox, gd._bbox); }
01066   
01067   inline void operator += (const Type &val)
01068   { GridData<Type,1>::plus(val, _bbox); }
01069   inline void operator += (const GridData<Type,1> &gd)
01070   { GridData<Type,1>::plus(gd, gd._bbox, gd._bbox); }
01071   
01072   inline void operator -= (const Type &val)
01073   { GridData<Type,1>::minus(val, _bbox); }
01074   inline void operator -= (const GridData<Type,1> &gd)
01075   { GridData<Type,1>::minus(gd, gd._bbox, gd._bbox); }
01076   
01077   inline void operator *= (const Type &val)
01078   { GridData<Type,1>::multiply(val, _bbox); }
01079   inline void operator *= (const GridData<Type,1> &gd)
01080   { GridData<Type,1>::multiply(gd, gd._bbox, gd._bbox); }
01081   
01082   inline void operator /= (const Type &val)
01083   { GridData<Type,1>::divide(val, _bbox); }
01084   inline void operator /= (const GridData<Type,1> &gd)
01085   { GridData<Type,1>::divide(gd, gd._bbox, gd._bbox); }
01086   /**********************************************************************/
01087 
01088   /**********************************************************************/
01089   // Reduction Operations
01090   /**********************************************************************/
01091   
01092   /****************************** maxval ***************************************/
01093   Type maxval (const BBox &where) {
01094     Type max_val = (Type) 0;  
01095     short flag = DAGHTrue;
01096     BBox intersection = _bbox * where;
01097     if (!intersection.empty()) {
01098       Coords max_step = _step.getmax(where.stepsize());
01099       intersection.setstepsize(_step);
01100       
01101       GridData<Type,1> &dst = *this;
01102       
01103       BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01104       
01105       for_1(i, intersection, max_step)
01106         if (flag == DAGHTrue) 
01107           { max_val = FastIndex1(dst,i); flag = DAGHFalse; }
01108         else 
01109           max_val = Max(max_val,FastIndex1(dst,i));
01110       end_for
01111 
01112       EndFastIndex1(dst);
01113 
01114     }
01115     return (max_val);
01116   }
01117 
01118   inline Type maxval (void)
01119   { return (GridData<Type,1>::maxval(_bbox)); }
01120   /************************************************************************/
01121 
01122   /****************************** minval ***************************************/
01123   Type minval (const BBox &where) {
01124     Type min_val = (Type) 0;
01125     short flag = DAGHTrue;
01126     BBox intersection = _bbox * where;
01127     if (!intersection.empty()) {
01128       Coords max_step = _step.getmax(where.stepsize());
01129       intersection.setstepsize(_step);
01130       
01131       GridData<Type,1> &dst = *this;
01132       
01133       BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01134 
01135       for_1(i, intersection, max_step)
01136         if (flag == DAGHTrue) 
01137           { min_val = FastIndex1(dst,i); flag = DAGHFalse; }
01138         else 
01139           min_val = Min(min_val,FastIndex1(dst,i));
01140       end_for
01141 
01142       EndFastIndex1(dst);
01143 
01144     }
01145     return (min_val);
01146   }
01147 
01148   inline Type minval (void)
01149   { return (GridData<Type,1>::minval(_bbox)); }
01150   /************************************************************************/
01151 
01152   /****************************** sum ***************************************/
01153   Type sum (const BBox &where) {
01154     Type sum_val = (Type) 0;
01155     BBox intersection = _bbox * where;
01156     if (!intersection.empty()) {
01157       Coords max_step = _step.getmax(where.stepsize());
01158       intersection.setstepsize(_step);
01159       
01160       GridData<Type,1> &dst = *this;
01161 
01162       BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01163 
01164       for_1(i, intersection, max_step)
01165         sum_val += FastIndex1(dst,i);
01166       end_for
01167 
01168       EndFastIndex1(dst);
01169 
01170     }
01171     return (sum_val);
01172   }
01173 
01174   inline Type sum (void)
01175   { return (GridData<Type,1>::sum(_bbox)); }
01176   /************************************************************************/
01177   
01178   /****************************** product ***************************************/
01179   Type product (const BBox &where) {
01180     Type prod_val = (Type) 1;
01181     BBox intersection = _bbox * where;
01182     if (!intersection.empty()) {
01183       Coords max_step = _step.getmax(where.stepsize());
01184       intersection.setstepsize(_step);
01185 
01186       GridData<Type,1> &dst = *this;
01187 
01188       BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01189 
01190       for_1(i, intersection, max_step)
01191         prod_val *= FastIndex1(dst,i);
01192       end_for
01193 
01194       EndFastIndex1(dst);
01195 
01196     }
01197     return (prod_val);
01198   }
01199 
01200   inline Type product (void)
01201   { return (GridData<Type,1>::product(_bbox)); }
01202   /**********************************************************************/
01203 
01204 private:
01205    void gd_CopyRegion(const GridData<Type,1> &src, const BBox &to,
01206                       const BBox &from, const Coords &step) {
01207      GridData<Type,1> &dst = *this;
01208      
01209      if (dst._bbox==src._bbox && to==from && to==dst._bbox) 
01210        std::memcpy((void *) dst._data, (void *) src._data, sizeof(Type)*to.size());
01211      else {
01212        const int di = from.lower(0)-to.lower(0);
01213        
01214        BeginFastIndex1(src, src._bbox, src._data, const Type);
01215        BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01216        
01217        for_1(i, to, step)
01218          FastIndex1(dst,i) = FastIndex1(src,i+di);
01219        end_for
01220 
01221        EndFastIndex1(dst);
01222        EndFastIndex1(src);
01223      }
01224    }
01225 
01226    void gdb_CopyRegion(const GridDataBucket<Type> &gdbkt, const BBox &to,
01227                        const BBox &from, const Coords &step) {
01228      GridData<Type,1> &dst = *this;
01229 
01230      if (dst._bbox==gdbkt.bbox() && to==from && to==dst._bbox) 
01231        std::memcpy((void *) dst._data, (void *) gdbkt.data(), sizeof(Type)*to.size());
01232      else {
01233        const int di = from.lower(0)-to.lower(0);
01234 
01235        BeginFastIndex1(src, gdbkt.bbox(), gdbkt.data(), const Type);
01236        BeginFastIndex1(dst, dst.bbox(), dst.data(), Type);
01237        for_1(i, to, step)
01238          FastIndex1(dst,i) = FastIndex1(src,i+di);
01239        end_for
01240        EndFastIndex1(dst);
01241        EndFastIndex1(src);
01242      }
01243    }
01244 
01245   void gdb_CopyRegion(const GridDataBucket<Type> &gdbkt, const int n, const BBox &to,
01246                       const BBox &from, const Coords &step) {
01247     GridData<Type,1> &dst = *this;
01248 
01249     if (dst._bbox==gdbkt.bbox(n) && to==from && to==dst._bbox) 
01250       std::memcpy((void *) dst._data, (void *) gdbkt.data(n), sizeof(Type)*to.size());
01251     else {
01252       const int di = from.lower(0)-to.lower(0);
01253       
01254       BeginFastIndex1(src, gdbkt.bbox(n), gdbkt.data(n), const Type);
01255       BeginFastIndex1(dst, dst.bbox(), dst.data(), Type);
01256       for_1(i, to, step)
01257         FastIndex1(dst,i) = FastIndex1(src,i+di);
01258       end_for
01259       EndFastIndex1(dst);
01260       EndFastIndex1(src);
01261     }
01262   }
01263 
01264   /****************************** == ***************************************/
01265   void gd_OperateRegion(is_eq)(const Type &val, const BBox &to,
01266                                const Coords &step, BBox &bb) {
01267     GridData<Type,1> &dst = *this;
01268     
01269     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01270    
01271     for_1(i, to, step)
01272       if (FastIndex1(dst,i) == val) bb += Coords(1,i);
01273     end_for
01274 
01275     EndFastIndex1(dst);
01276   }
01277     
01278   void gd_OperateRegion(is_eq)(const GridData<Type,1> &src, const BBox &to,
01279                                const BBox &from, const Coords &step, BBox &bb) {
01280     GridData<Type,1> &dst = *this;
01281     const int di = from.lower(0)-to.lower(0);
01282     
01283     BeginFastIndex1(src, src._bbox, src._data, const Type);
01284     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01285 
01286     for_1(i, to, step)
01287       if (FastIndex1(dst,i) == FastIndex1(src,i+di))
01288         bb += Coords(1,i);
01289     end_for
01290 
01291     EndFastIndex1(dst);
01292     EndFastIndex1(src);
01293   }
01294   /************************************************************************/
01295   
01296   /****************************** != ***************************************/
01297   void gd_OperateRegion(is_neq)(const Type &val, const BBox &to,
01298                                 const Coords &step, BBox &bb) {
01299     GridData<Type,1> &dst = *this;
01300 
01301     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01302     
01303     for_1(i, to, step)
01304      if (FastIndex1(dst,i) != val) bb += Coords(1,i);
01305     end_for
01306 
01307     EndFastIndex1(dst);
01308   }
01309 
01310   void gd_OperateRegion(is_neq)(const GridData<Type,1> &src, const BBox &to,
01311                                 const BBox &from, const Coords &step, BBox &bb)  {
01312     GridData<Type,1> &dst = *this;
01313     const int di = from.lower(0)-to.lower(0);
01314     
01315     BeginFastIndex1(src, src._bbox, src._data, const Type);
01316     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01317 
01318     for_1(i, to, step)
01319       if (FastIndex1(dst,i) != FastIndex1(src,i+di))
01320         bb += Coords(1,i);
01321     end_for
01322 
01323     EndFastIndex1(dst);
01324     EndFastIndex1(src);
01325   }
01326   /************************************************************************/
01327 
01328   /****************************** > ***************************************/
01329   void gd_OperateRegion(is_gt)(const Type &val, const BBox &to,
01330                                const Coords &step, BBox &bb)  {
01331     GridData<Type,1> &dst = *this;
01332 
01333     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01334 
01335     for_1(i, to, step)
01336       if (FastIndex1(dst,i) > val) bb += Coords(1,i);
01337     end_for
01338 
01339     EndFastIndex1(dst);
01340   }
01341 
01342   void gd_OperateRegion(is_gt)(const GridData<Type,1> &src, const BBox &to,
01343                                const BBox &from, const Coords &step, BBox &bb)  {
01344     GridData<Type,1> &dst = *this;
01345     const int di = from.lower(0)-to.lower(0);
01346 
01347     BeginFastIndex1(src, src._bbox, src._data, const Type);
01348     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01349 
01350     for_1(i, to, step)
01351       if (FastIndex1(dst,i) > FastIndex1(src,i+di))
01352         bb += Coords(1,i);
01353     end_for
01354 
01355     EndFastIndex1(dst);
01356     EndFastIndex1(src);
01357   }
01358   /************************************************************************/
01359 
01360   /****************************** >= ***************************************/
01361   void gd_OperateRegion(is_ge)(const Type &val, const BBox &to,
01362                                const Coords &step, BBox &bb) {
01363     GridData<Type,1> &dst = *this;
01364     
01365     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01366 
01367     for_1(i, to, step)
01368       if (FastIndex1(dst,i) >= val) bb += Coords(1,i);
01369     end_for
01370 
01371     EndFastIndex1(dst);
01372   }
01373 
01374   void gd_OperateRegion(is_ge)(const GridData<Type,1> &src, const BBox &to,
01375                                const BBox &from, const Coords &step, BBox &bb)  {
01376     GridData<Type,1> &dst = *this;
01377     const int di = from.lower(0)-to.lower(0);
01378     
01379     BeginFastIndex1(src, src._bbox, src._data, const Type);
01380     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01381 
01382     for_1(i, to, step)
01383       if (FastIndex1(dst,i) >= FastIndex1(src,i+di))
01384         bb += Coords(1,i);
01385     end_for
01386 
01387     EndFastIndex1(dst);
01388     EndFastIndex1(src);
01389   }
01390   /************************************************************************/
01391 
01392   /****************************** < ***************************************/
01393   void gd_OperateRegion(is_lt)(const Type &val, const BBox &to,
01394                                const Coords &step, BBox &bb) {
01395     GridData<Type,1> &dst = *this;
01396 
01397     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01398     
01399     for_1(i, to, step)
01400       if (FastIndex1(dst,i) < val) bb += Coords(1,i);
01401     end_for
01402 
01403     EndFastIndex1(dst);
01404   }
01405 
01406   void gd_OperateRegion(is_lt)(const GridData<Type,1> &src, const BBox &to,
01407                                const BBox &from, const Coords &step, BBox &bb)  {
01408     GridData<Type,1> &dst = *this;
01409     const int di = from.lower(0)-to.lower(0);
01410     
01411     BeginFastIndex1(src, src._bbox, src._data, const Type);
01412     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01413    
01414     for_1(i, to, step)
01415       if (FastIndex1(dst,i) < FastIndex1(src,i+di))
01416         bb += Coords(1,i);
01417     end_for
01418 
01419     EndFastIndex1(dst);
01420     EndFastIndex1(src);
01421   }
01422   /************************************************************************/
01423 
01424   /****************************** <= ***************************************/
01425   void gd_OperateRegion(is_le)(const Type &val, const BBox &to,
01426                                const Coords &step, BBox &bb)  {
01427     GridData<Type,1> &dst = *this;
01428 
01429     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01430     
01431     for_1(i, to, step)
01432       if (FastIndex1(dst,i) <= val) bb += Coords(1,i);
01433     end_for
01434 
01435     EndFastIndex1(dst);
01436   }
01437 
01438   void gd_OperateRegion(is_le)(const GridData<Type,1> &src, const BBox &to,
01439                                const BBox &from, const Coords &step, BBox &bb)  {
01440     GridData<Type,1> &dst = *this;
01441     const int di = from.lower(0)-to.lower(0);
01442 
01443     BeginFastIndex1(src, src._bbox, src._data, const Type);
01444     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01445 
01446     for_1(i, to, step)
01447       if (FastIndex1(dst,i) <= FastIndex1(src,i+di))
01448         bb += Coords(1,i);
01449     end_for
01450 
01451     EndFastIndex1(dst);
01452     EndFastIndex1(src);
01453   }
01454 
01455   /****************************** = ***************************************/
01456   void gd_OperateRegion(equal)(const Type &val, const BBox &to, const Coords &step) {
01457     GridData<Type,1> &dst = *this;
01458 
01459     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01460     
01461     for_1(i, to, step)
01462       FastIndex1(dst,i) = val;
01463     end_for
01464       
01465     EndFastIndex1(dst);
01466   }
01467 
01468   void gd_OperateRegion(equal)(const GridData<Type,1> &src, const BBox &to,
01469                                const BBox &from, const Coords &step) {
01470     GridData<Type,1> &dst = *this;
01471     const int di = from.lower(0)-to.lower(0);
01472 
01473     BeginFastIndex1(src, src._bbox, src._data, const Type);
01474     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01475 
01476     for_1(i, to, step)
01477       FastIndex1(dst,i) = FastIndex1(src,i+di);
01478     end_for
01479 
01480     EndFastIndex1(dst);
01481     EndFastIndex1(src);
01482   }
01483   /************************************************************************/
01484     
01485   /****************************** + ***************************************/
01486   void gd_OperateRegion(plus)(const Type &val, const BBox &to, const Coords &step) {
01487     GridData<Type,1> &dst = *this;
01488 
01489     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01490 
01491     for_1(i, to, step)
01492       FastIndex1(dst,i) += val;
01493     end_for
01494 
01495     EndFastIndex1(dst);
01496   }
01497 
01498   void gd_OperateRegion(plus)(const GridData<Type,1> &src, const BBox &to,
01499                               const BBox &from, const Coords &step) {
01500     GridData<Type,1> &dst = *this;
01501     const int di = from.lower(0)-to.lower(0);
01502     
01503     BeginFastIndex1(src, src._bbox, src._data, const Type);
01504     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01505 
01506     for_1(i, to, step)
01507       FastIndex1(dst,i) += FastIndex1(src,i+di);
01508     end_for
01509 
01510     EndFastIndex1(dst);
01511     EndFastIndex1(src);
01512   }
01513   /************************************************************************/
01514 
01515   /****************************** - ***************************************/
01516   void gd_OperateRegion(minus)(const Type &val, const BBox &to, const Coords &step) {
01517     GridData<Type,1> &dst = *this;
01518     
01519     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01520     
01521     for_1(i, to, step)
01522       FastIndex1(dst,i) -= val;
01523     end_for
01524 
01525     EndFastIndex1(dst);
01526   }
01527 
01528   void gd_OperateRegion(minus)(const GridData<Type,1> &src, const BBox &to,
01529                                const BBox &from, const Coords &step) {
01530     GridData<Type,1> &dst = *this;
01531     const int di = from.lower(0)-to.lower(0);
01532     
01533     BeginFastIndex1(src, src._bbox, src._data, const Type);
01534     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01535 
01536     for_1(i, to, step)
01537       FastIndex1(dst,i) -= FastIndex1(src,i+di);
01538     end_for
01539 
01540     EndFastIndex1(dst);
01541     EndFastIndex1(src);
01542   }
01543   /************************************************************************/
01544 
01545   /****************************** * ***************************************/
01546   void gd_OperateRegion(mult)(const Type &val, const BBox &to, const Coords &step) {
01547     GridData<Type,1> &dst = *this;
01548 
01549    BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01550 
01551    for_1(i, to, step)
01552      FastIndex1(dst,i) *= val;
01553    end_for
01554      
01555    EndFastIndex1(dst);
01556   }
01557 
01558   void gd_OperateRegion(mult)(const GridData<Type,1> &src, const BBox &to,
01559                               const BBox &from, const Coords &step) {
01560     GridData<Type,1> &dst = *this;
01561     const int di = from.lower(0)-to.lower(0);
01562     
01563     BeginFastIndex1(src, src._bbox, src._data, const Type);
01564     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01565 
01566     for_1(i, to, step)
01567       FastIndex1(dst,i) *= FastIndex1(src,i+di);
01568     end_for
01569 
01570     EndFastIndex1(dst);
01571     EndFastIndex1(src);
01572   }
01573   /************************************************************************/
01574 
01575   /****************************** / ***************************************/
01576   void gd_OperateRegion(div)(const Type &val, const BBox &to, const Coords &step) {
01577     assert (val != (Type)0);
01578     GridData<Type,1> &dst = *this;
01579     
01580     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01581    
01582     for_1(i, to, step)
01583       FastIndex1(dst,i) /= val;
01584     end_for
01585 
01586     EndFastIndex1(dst);
01587   }
01588 
01589   void gd_OperateRegion(div)(const GridData<Type,1> &src, const BBox &to,
01590                              const BBox &from, const Coords &step) {
01591     GridData<Type,1> &dst = *this;
01592     const int di = from.lower(0)-to.lower(0);
01593     
01594     BeginFastIndex1(src, src._bbox, src._data, const Type);
01595     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01596 
01597     for_1(i, to, step)
01598       FastIndex1(dst,i) /= FastIndex1(src,i+di);
01599     end_for
01600 
01601     EndFastIndex1(dst);
01602     EndFastIndex1(src);
01603   }
01604   /************************************************************************/
01605   
01606   /****************************** min ***************************************/
01607   void gd_OperateRegion(min)(const Type &val, const BBox &to, Coords const &step) {
01608     GridData<Type,1> &dst = *this;
01609 
01610     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01611 
01612     for_1(i, to, step)
01613       FastIndex1(dst,i) = Min(val, FastIndex1(dst,i));
01614     end_for
01615 
01616     EndFastIndex1(dst);
01617   }
01618 
01619   void gd_OperateRegion(min)(const GridData<Type,1> &src, const BBox &to,
01620                              const BBox &from, Coords const &step) {
01621     GridData<Type,1> &dst = *this;
01622     const int di = from.lower(0)-to.lower(0);
01623     
01624     BeginFastIndex1(src, src._bbox, src._data, const Type);
01625     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01626 
01627     for_1(i, to, step)
01628       FastIndex1(dst,i) = Min(FastIndex1(dst,i), FastIndex1(src,i+di));
01629     end_for
01630 
01631     EndFastIndex1(dst);
01632     EndFastIndex1(src);
01633   }
01634   /************************************************************************/
01635 
01636   /****************************** max ***************************************/
01637   void gd_OperateRegion(max)(const Type &val, const BBox &to, Coords const &step) {
01638     GridData<Type,1> &dst = *this;
01639 
01640     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01641 
01642     for_1(i, to, step)
01643       FastIndex1(dst,i) = Max(val, FastIndex1(dst,i));
01644     end_for
01645 
01646     EndFastIndex1(dst);
01647   }
01648 
01649   void gd_OperateRegion(max)(const GridData<Type,1> &src, const BBox &to,
01650                              const BBox &from, Coords const &step) {
01651     GridData<Type,1> &dst = *this;
01652     const int di = from.lower(0)-to.lower(0);
01653     
01654     BeginFastIndex1(src, src._bbox, src._data, const Type);
01655     BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01656 
01657     for_1(i, to, step)
01658       FastIndex1(dst,i) = Max(FastIndex1(dst,i), FastIndex1(src,i+di));
01659     end_for
01660 
01661     EndFastIndex1(dst);
01662     EndFastIndex1(src);
01663   }
01664   /************************************************************************/
01665 
01666 public:
01667   /* Perform efficient buffer packing/unpacking and data movement */
01668   void PackRegion(Type *sendbuf, const BBox &from) const {
01669     const GridData<Type,1> &src = *this;
01670 
01671     if (from==src._bbox) 
01672       std::memcpy((void *) sendbuf, (void *) src._data, sizeof(Type)*from.size());
01673     else {
01674       register int p = 0;
01675       
01676       BeginFastIndex1(src, src._bbox, src._data, const Type);
01677       
01678       for_1(i, from, _step)
01679         sendbuf[p++] = FastIndex1(src,i);
01680       end_for
01681         
01682       EndFastIndex1(src);
01683     }
01684   } 
01685 
01686   void UnPackRegion(const Type *recvbuf, const BBox &to) {
01687     GridData<Type,1> &dst = *this;
01688 
01689     if (to==dst._bbox) 
01690       std::memcpy((void *) dst._data, (void *) recvbuf, sizeof(Type)*to.size());
01691     else {
01692       register int p = 0;
01693 
01694       BeginFastIndex1(dst, dst._bbox, dst._data, Type);
01695 
01696       for_1(i, to, _step)
01697         FastIndex1(dst,i) = recvbuf[p++];
01698       end_for
01699 
01700       EndFastIndex1(dst);
01701     }
01702   }
01703 
01704   friend std::ostream& operator<< <>(std::ostream &os, 
01705                                      const GridData<Type,1> &gd);
01706   friend std::ofstream& operator<< <>(std::ofstream &ofs, 
01707                                       const GridData<Type,1> &gd);
01708   friend std::ifstream& operator>> <>(std::ifstream &ifs, 
01709                                       GridData<Type,1> &gd);  
01710   friend std::stringstream& operator<< <>(std::stringstream &ofs, 
01711                                           const GridData<Type,1> &gd);
01712   friend std::stringstream& operator>> <>(std::stringstream &ifs, 
01713                                           GridData<Type,1> &gd);
01714 };
01715 
01716 template <class Type>
01717 std::ostream&  operator << (std::ostream& os, const GridData<Type,1> &gd) {
01718   if (&gd == (const GridData<Type,1> *)0) return os;
01719 
01720   os << "BBox: " << gd.bbox() << " " << "Extents: " << gd.extents() << " ";
01721   os << "Step: " << gd.stepsize() << " ";
01722   os << "Size: " << gd.size() << " " << "Bottom: " << gd.bottom() << " ";
01723   
01724   os << "\n";
01725   
01726   if (gd.bbox().empty()) return os;
01727 
01728   const Coords &l = gd.lower();
01729   const Coords &u = gd.upper();
01730   const Coords &step = gd.stepsize();
01731   for (register int i=l(0);i<=u(0);i+=step(0)) 
01732     { os << "[" << i << "]=" << gd(i) << " "; }
01733   os << "\n";
01734 
01735   return os;
01736 }
01737 
01738 template <class Type>
01739 std::ofstream&  operator << (std::ofstream& ofs, const GridData<Type,1> &gd) {
01740   if (&gd == (GridData<Type,1> *)0) return ofs;
01741   
01742   ofs.write((char*)&gd.bbox(),sizeof(BBox));
01743   ofs.write((char*)gd.data(),gd.size()*sizeof(Type));
01744 
01745   return ofs;
01746 }
01747 
01748 template <class Type>
01749 std::ifstream&  operator >> (std::ifstream& ifs, GridData<Type,1> &gd) {
01750   if (&gd == (GridData<Type,1> *)0) return ifs;
01751   
01752   BBox bb;
01753   ifs.read((char*)&bb,sizeof(BBox));
01754   
01755   if (!gd.ok_to_index())
01756     { gd.allocate(bb); }
01757   
01758   if (bb == gd.bbox()) {
01759     ifs.read((char*)gd.data(),gd.size()*sizeof(Type));
01760   }
01761   else {
01762     GridData<Type,1> tmpgd(bb);
01763     ifs.read((char*)tmpgd.data(),tmpgd.size()*sizeof(Type));
01764     gd.copy(tmpgd);  
01765   } 
01766   
01767   return ifs;
01768 }
01769 
01770 template <class Type>
01771 std::stringstream& operator<<(std::stringstream& ofs, const GridData<Type,1> &gd) {
01772   if (&gd == (GridData<Type,1> *)0) return ofs;
01773   
01774   ofs.write((char*)&gd.bbox(),sizeof(BBox));
01775   ofs.write((char*)gd.data(),gd.size()*sizeof(Type));
01776   
01777   return ofs;
01778 }
01779 
01780 template <class Type>
01781 std::stringstream& operator>>(std::stringstream& ifs, GridData<Type,1> &gd) {
01782   if (&gd == (GridData<Type,1> *)0) return ifs;
01783   
01784   BBox bb;
01785   ifs.read((char*)&bb,sizeof(BBox));
01786   
01787   if (!gd.ok_to_index())
01788     { gd.allocate(bb); }
01789   
01790   if (bb == gd.bbox()) {
01791     ifs.read((char*)gd.data(),gd.size()*sizeof(Type));
01792   }
01793   else {
01794     GridData<Type,1> tmpgd(bb);
01795     ifs.read((char*)tmpgd.data(),tmpgd.size()*sizeof(Type));
01796     gd.copy(tmpgd);  
01797   } 
01798 
01799   return ifs;
01800 }
01801 
01802 /*********************************************************************/
01803 template <class Type, int dim>
01804 inline Coords lower(GridData<Type,1> &gd) { return(gd.lower()); }
01805 template <class Type, int dim>
01806 inline Coords upper(GridData<Type,1> &gd) { return(gd.upper()); }
01807 template <class Type, int dim>
01808 inline Coords extents(GridData<Type,1> &gd) { return(gd.extents()); }
01809 template <class Type, int dim>
01810 inline int lower(GridData<Type,1> &gd, const int i) { return(gd.lower(i)); }
01811 template <class Type, int dim>
01812 inline int upper(GridData<Type,1> &gd, const int i) { return(gd.upper(i)); }
01813 template <class Type, int dim>
01814 inline int extents(GridData<Type,1> &gd, const int i) { return(gd.extents(i)); }
01815 template <class Type, int dim>
01816 inline BBox bbox(GridData<Type,1> &gd) { return(gd.bbox()); }
01817 template <class Type, int dim>
01818 inline int size(GridData<Type,1> &gd) { return(gd.size()); }
01819 template <class Type, int dim>
01820 inline Coords stepsize(GridData<Type,1> &gd) { return(gd.stepsize()); }
01821 
01822 #endif

Generated on Fri Aug 24 13:00:29 2007 for AMROC's Hierachical Data Structures - by  doxygen 1.4.7