// // cartiter.cc // // Copyright (C) 1996 Limit Point Systems, Inc. // // Author: Curtis Janssen // Maintainer: LPS // // This file is part of the SC Toolkit. // // The SC Toolkit is free software; you can redistribute it and/or modify // it under the terms of the GNU Library General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // The SC Toolkit is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with the SC Toolkit; see the file COPYING.LIB. If not, write to // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. // // The U.S. Government is granted a limited license as per AL 91-7. // #ifdef __GNUC__ #pragma implementation #endif #include #include #include #include #include using namespace sc; //////////////////////////////////////////////////////////////////////// // CartianIter CartesianIter::CartesianIter(int l) : l_(l) { } CartesianIter::~CartesianIter() { } //////////////////////////////////////////////////////////////////////// // RedundantCartianIter RedundantCartesianIter::RedundantCartesianIter(int l) { l_ = l; axis_ = new int[l_]; } RedundantCartesianIter::~RedundantCartesianIter() { delete[] axis_; } //////////////////////////////////////////////////////////////////////// // RedundantCartianIter RedundantCartesianSubIter::RedundantCartesianSubIter(int l) { l_ = l; axis_ = new int[l_]; zloc_ = new int[l_]; yloc_ = new int[l_]; } RedundantCartesianSubIter::~RedundantCartesianSubIter() { delete[] axis_; delete[] zloc_; delete[] yloc_; } void RedundantCartesianSubIter::start(int a, int b, int c) { if (l_ != a + b + c) { ExEnv::err0() << indent << "RedundantCartesianSubIter::start: bad args\n"; abort(); } if (l_==0) { done_ = 1; return; } else { done_ = 0; } e_[0] = a; e_[1] = b; e_[2] = c; int ii=0; for (int i=0; i=0; j--) loc[j] = loc[j+1] + 1; return true; } else { maxloc = loc[i]-1; } } return false; } // This loops through all unique axis vectors that have a // given total a, b, and c. It is done by looping through // all possible positions for z, then y, leaving x to be // filled in. void RedundantCartesianSubIter::next() { int currentz = 0; int currenty = 0; int nz = c(); int ny = b(); if (!::advance(l(),zloc_,nz)) { if (!::advance(l()-nz,yloc_,ny)) { done_ = 1; return; } else { for (int i=0; i=0; i--) { if (currentz