Code Search for Developers
 
 
  

test-rewrite.C from Magnus at Krugle


Show test-rewrite.C syntax highlighted

// Copyright (C) 1994 The New York Group Theory Cooperative
// See magnus/doc/COPYRIGHT for the full notice.

// Contents: test-Diff.
//
// Principal Author: Sarah Rees
//
// Status: in progress
//
// Revision History:
//

#include "RKBPackage.h"
#include "DiffMachine.h"
#include "FPGroup.h"
#include "Set.h"
#include "Word.h"

//This runs the rkbp for a bit on a  given group and builds the associated 
//difference machine,and prints it out.
// The input is simply a presentation.
main()
{
  do {
    FPGroup G;
    cin >> G;
    if (G.numberOfGenerators()==0) break;
    cout << G << endl;
    VectorOf<int> order;
    VectorOf<int> weight;
    char ch;

    while (((ch = cin.peek()) != EOF) && isspace(ch)) ch = cin.get();

    if (ch == '[') { 
      ch = cin.get();
      do {
        int i;
        cin >> i;
        order.append(i);
        cin>> ch;
        if (ch==']') break;
        else if (ch!=','){ cerr << "Unexpected input, aborted"<<endl; exit(1);}
      } while (ch==',');
    
      while (((ch = cin.peek()) != EOF) && isspace(ch)) ch = cin.get();
      if (ch == '[') {
        ch = cin.get();
        do {
          int i;
          cin >> i;
          weight.append(i);
          cin>> ch;
          if (ch==']') break;
          else if (ch!=','){ cerr << "Unexpected input, aborted"<<endl; exit(1);}
        } while (ch==',');
      }
    }
    WordOrder word_order("WtLex",order,weight);
    DiffMachine D;
    D.readFrom();
    D.printOn(cout);
    while (0!=1){
      Chars errmesg;
      cout << "Enter word to be reduced (terminated with a comma)." << endl;
      Word u = G.readWord(cin, errmesg);
      Word v = u;
      G.printWord(cout, u);
      if (u.length()==0) { cout << endl; break;}
      cout << " rewrites as ";
      D.rewrite(u,word_order);
      G.printWord(cout, u);
      cout << endl;
    }
  } while (0!=1);
}





See more files for this project here

Magnus

Magnus is a special purpose mathematical package for Infinite Group Theory computations

Project homepage: http://sourceforge.net/projects/magnus
Programming language(s): C,C++
License: other

  test-Diff.C
  test-Diff.data
  test-Diff.mastertestout
  test-GenMult.C
  test-GenMult.data
  test-GenMult.mastertestout
  test-KBM.C
  test-KBM.data
  test-KBM.mastertestout
  test-KBmag.C
  test-KBmag.data
  test-KBmag.mastertestout
  test-RKBP.C
  test-RKBP.data
  test-RKBP.mastertestout
  test-finiteness.C
  test-finiteness.data
  test-finiteness.mastertestout
  test-rewrite.C
  test-rewrite.data
  test-rewrite.mastertestout
  test-weighedLex.mastertestout
  test-weightedLex.C
  test-weightedLex.data
  test-weightedLex.mastertestout
  test-weightedSL.C
  test-weightedSL.data
  test-weightedSL.mastertestout
  test-wordAcceptor.C
  test-wordAcceptor.data
  test-wordAcceptor.mastertestout