Changeset d675c7 in git for factory


Ignore:
Timestamp:
Jul 8, 1996, 10:18:49 AM (28 years ago)
Author:
Rüdiger Stobbe <stobbe@…>
Branches:
(u'spielwiese', '82fc009ea2b0098c1a4896c841bb70860976bdfc')
Children:
f63dbca24fdad0fc65e8496a781d6830dafded8e
Parents:
cc3e5eb035f7602ac7563d30a082c4b4bc9debf6
Message:
"IteratedFor now handles the cases in which the mainvariable is not of
level 1.
"


git-svn-id: file:///usr/local/Singular/svn/trunk@38 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
factory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • factory/fac_iterfor.cc

    rcc3e5e rd675c7  
    11// emacs edit mode for this file is -*- C++ -*-
    2 // $Id: fac_iterfor.cc,v 1.0 1996-05-17 10:59:45 stobbe Exp $
     2// $Id: fac_iterfor.cc,v 1.1 1996-07-08 08:18:49 stobbe Exp $
    33
    44/*
    55$Log: not supported by cvs2svn $
     6Revision 1.0  1996/05/17 10:59:45  stobbe
     7Initial revision
     8
    69*/
    710
     
    2124}
    2225
    23 IteratedFor::IteratedFor( int n, int max ) : MAX( max ), N( n ), last( false )
     26IteratedFor::IteratedFor( int from, int to, int max ) : MAX( max ), FROM( from ), TO( to ), N( TO-FROM ), last( false )
    2427{
    25     ASSERT( n > 1 && max >= 0, "illegal iterated for" );
    26     index = new int[n+1];
    27     imax = new int[n+1];
    28     fill( 2, max );
     28    ASSERT( n >= 0 && max >= 0, "illegal iterated for" );
     29    index = new int[N+1];
     30    imax = new int[N+1];
     31    fill( 0, max );
    2932}
    3033
    31 IteratedFor::IteratedFor( const IteratedFor & I ) : MAX( I.MAX ), N( I.N ), last( I.last )
     34IteratedFor::IteratedFor( const IteratedFor & I ) : MAX( I.MAX ), FROM( I.FROM ), TO( I.TO ), N( I.N ), last( I.last )
    3235{
    3336    index = new int[N+1];
    3437    imax = new int[N+1];
    35     for ( int i = 2; i<= N; i++ ) {
     38    for ( int i = 0; i <= N; i++ ) {
    3639        index[i] = I.index[i];
    3740        imax[i] = I.imax[i];
     
    5659            imax = new int[N+1];
    5760        }
     61        FROM = I.FROM;
     62        TO = I.TO;
    5863        MAX = I.MAX;
    5964        last = I.last;
    60         for ( int i = 2; i<= N; i++ ) {
     65        for ( int i = 0; i<= N; i++ ) {
    6166            index[i] = I.index[i];
    6267            imax[i] = I.imax[i];
     
    7075{
    7176    ASSERT( ! last, "no more iterations" );
    72     if ( index[2] == MAX )
     77    if ( index[0] == MAX )
    7378        last = true;
    7479    else {
     
    7984        else {
    8085            int i = N-1, m = index[N];
    81             while ( i > 1 && index[i] == imax[i] ) {
     86            while ( i > 0 && index[i] == imax[i] ) {
    8287                m += imax[i];
    8388                i--;
     
    9297IteratedFor::operator[] ( int i ) const
    9398{
    94     ASSERT( i >= 2 && i <= N, "illegal index" );
    95     return index[i];
     99    ASSERT( i >= FROM && i <= TO, "illegal index" );
     100    return index[i-FROM];
    96101}
    97102
    98103ostream& operator<< ( ostream& os, const IteratedFor & I )
    99104{
    100     os << "( " << I[2];
    101     for ( int i = 3; i <= I.n(); i++ )
     105    os << "( " << I[I.from()];
     106    for ( int i = I.from()+1; i <= I.to(); i++ )
    102107        os << ", " << I[i];
    103108    os << " )";
  • factory/fac_iterfor.h

    rcc3e5e rd675c7  
    11// emacs edit mode for this file is -*- C++ -*-
    2 // $Id: fac_iterfor.h,v 1.0 1996-05-17 10:59:40 stobbe Exp $
     2// $Id: fac_iterfor.h,v 1.1 1996-07-08 08:18:49 stobbe Exp $
    33
    44#ifndef INCL_ITERFOR_H
     
    77/*
    88$Log: not supported by cvs2svn $
     9Revision 1.0  1996/05/17 10:59:40  stobbe
     10Initial revision
     11
    912*/
    1013
     
    1518private:
    1619    int MAX;
     20    int FROM;
     21    int TO;
    1722    int N;
    1823    bool last;
     
    2126    void fill ( int from, int n );
    2227public:
    23     IteratedFor( int n, int max );
     28    IteratedFor( int from, int to, int max );
    2429    IteratedFor( const IteratedFor & );
    2530    ~IteratedFor();
    2631    IteratedFor& operator= ( const IteratedFor & );
    27     int n() const { return N; }
     32    int from() const { return FROM; }
     33    int to() const { return TO; }
     34    int n() const { return N; };
    2835    int max() const { return MAX; }
    2936    void nextiteration();
Note: See TracChangeset for help on using the changeset viewer.