#ifndef BZ_DOMAIN_H #define BZ_DOMAIN_H #ifndef BZ_TINYVEC_H #include #endif #ifndef BZ_RANGE_H #include #endif /* * Portions of this class were inspired by the "RectDomain" class * provided by the Titanium language (UC Berkeley). */ BZ_NAMESPACE(blitz) template class RectDomain { public: RectDomain(const TinyVector& lbound, const TinyVector& ubound) : lbound_(lbound), ubound_(ubound) { } // NEEDS_WORK: better constructors // RectDomain(Range, Range, ...) // RectDomain with any combination of Range and int const TinyVector& lbound() const { return lbound_; } int lbound(int i) const { return lbound_(i); } const TinyVector& ubound() const { return ubound_; } int ubound(int i) const { return ubound_(i); } Range operator[](int rank) const { return Range(lbound_(rank), ubound_(rank)); } void shrink(int amount) { lbound_ += amount; ubound_ -= amount; } void shrink(int dim, int amount) { lbound_(dim) += amount; ubound_(dim) -= amount; } void expand(int amount) { lbound_ -= amount; ubound_ += amount; } void expand(int dim, int amount) { lbound_(dim) -= amount; ubound_(dim) += amount; } private: TinyVector lbound_, ubound_; }; template inline RectDomain strip(const TinyVector& startPosition, int stripDimension, int ubound) { BZPRECONDITION((stripDimension >= 0) && (stripDimension < N_rank)); BZPRECONDITION(ubound >= startPosition(stripDimension)); TinyVector endPosition = startPosition; endPosition(stripDimension) = ubound; return RectDomain(startPosition, endPosition); } BZ_NAMESPACE_END #endif // BZ_DOMAIN_H