当前位置: 首页>>代码示例>>C++>>正文


C++ VectorOf::append方法代码示例

本文整理汇总了C++中VectorOf::append方法的典型用法代码示例。如果您正苦于以下问题:C++ VectorOf::append方法的具体用法?C++ VectorOf::append怎么用?C++ VectorOf::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VectorOf的用法示例。


在下文中一共展示了VectorOf::append方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main( )
{
  FPGroup G;
  cout << "Enter nilpotentcy class first then group ";
  int NilpotentcyClass;
  cin >> NilpotentcyClass;
  Chars errMsg = cin >> G;
  if (errMsg.length()>0) 
    return 1;
 
  NilpotentGroup ng(G.namesOfGenerators(),
		    NilpotentcyClass,makeVectorOf(G.getRelators()));
  ng.initialize();
  VectorOf<Word> vw;
  Word w;
  for (int i=1;true;i++){
    cout << endl << "Enter the "<<i<<" generator of subgroup"<< endl;
    cout << "Empty word to finish: ";
    w = G.readWord(cin,errMsg);
    if (w.length()==0)
      break;
    if (errMsg.length()>0) 
      return 1;
    vw.append(w);
  }
  SGOfNilpotentGroup sg(ng,vw);
  sg.initBasis();
  sg.printBasis(cout);
  cout << "The Hirsch number :" << sg.theHirschNumber() << endl;
  cout << "Index in parent group :" << sg.index() << endl;
  cout << "Is Trivial :" << sg.isTrivial() << endl;
  cout << "Is Central :" << sg.isCentral() << endl;
  cout << "Is normal :" << sg.isNormal() << endl;
  cout << "Is abelian :" << sg.isAbelian() << endl;
  cout << "Subgroup class :" << sg.subgroupClass() << endl;
  cout << "Generators of normal closure :" << endl;
  vw = sg.normalClosureGens();
  for (int i=0;i<vw.length();i++){
    G.printWord(cout,vw[i]);
    cout << endl;
  }
  PresentationForSNG sgp = sg.makePresentation();
  cout << "Presentation of subgroup :" << endl;
  sgp.print(cout);
  cout << endl << "Enter the word :";
  errMsg = "";
  w = G.readWord(cin,errMsg);
  if (errMsg.length()>0){ 
    cout << errMsg;
    return 1; 
  }
  cout << endl << "Does subgroup contain the word :" << sg.contains(w) << endl;
  PolyWord result;
  if (sg.decompose(ng.decompose(w),result))
    cout << "Decomposition in sg basis :" << sg.asDecomposition(result);
  else
    cout << "Subgroup does not contain this word";

}
开发者ID:koudonojinchuu,项目名称:magnus,代码行数:59,代码来源:test_NilpotentSubgroup.C

示例2: name

VectorOf<Chars> PresentationParser::parseGeneratorList( Chars& errMesg )
{
  VectorOf<Chars> result;

  if ( curToken == INIT ) getToken();

  while ( curToken == GENERATOR ) {

	 Chars name(tokenName);

    // Check for duplication and presence of inverses.
	 if ( result.indexOf(name) >= 0 ) {
		parseError("Duplicate generator");
		errMesg = parseErrorMessage;
		return result;
	 } else {
		invertName(tokenName);
		if ( result.indexOf(Chars(tokenName)) >= 0 ) {
		  parseError("Duplicate generator: formal inverse");
		  errMesg = parseErrorMessage;
		  return result;
		}
	 }

	 result.append(name); // Ok, it's inefficient, but time is $$

	 getToken();

	 if ( curToken == COMMA ) {
	   getToken();
	   if ( curToken == DOT ) {
	     if (!getGeneratorRange(name,result,errMesg))
	       return result;
	   } else {
	     if ( curToken != GENERATOR ) {
	       parseError("Expected a generator here");
	       errMesg = parseErrorMessage;
	       return result;
	     }
	   }
	 }
  }

  return result;
}
开发者ID:koudonojinchuu,项目名称:magnus,代码行数:45,代码来源:PresentationParser.C

示例3: findSolutions


//.........这里部分代码省略.........
	  haveSol = 0;
	  
	  if( out )
	    if( system.length() > 1 )
	      file << "while computing the canonical form of the system it was found that this system has all group as a set of solutions." << endl;
	    else
	      file << "while computing the canonical form of the equation it was found that this equation has all group as a set of solutions." << endl;
	  
	  return;
	  
	}
      
      int *tmp = matrix[i];
      matrix[i] = matrix[j];
      matrix[j] = tmp;
      
      Word r = b[i];
      b[i] = b[j];
      b[j] = r;
      
      for( j = 0 ; j < system.length() ; j++ )
	{
	  int t = matrix[j][i];
	  matrix[j][i] = matrix[j][k];
	  matrix[j][k] = t;
	}
      
      if( i != k )
      {
	trans[0] = i;
	trans[1] = k;
	trans[2] = 0;
	
	transform.append( trans );
      }
      
      while( true )
	{
	  bool check;
	  bool flag;
	  int z;
	  bool done = false;
	  int count = i + 1;
	  
	  while( !done )
	    {
	      for( j = count ; j < system.length() ; j++ )
		if( matrix[j][i] && abs(matrix[i][i]) != abs(matrix[j][i]) )
		  break;
	      
	      if( j == system.length() )
		break;
	      
	      count = j + 1;
	      
	      flag = false;
	      
	      while( !flag )
		{
		  if( abs(matrix[i][i]) > abs(matrix[j][i]) )
		    {
		      z = matrix[i][i] / matrix[j][i];
		      for( k = i ; k < numberOfVariables ; k++ )
			matrix[i][k] = matrix[i][k] - matrix[j][k] * z;
		      b[i] = b[i] * A.getFPGroup().raiseToPower(b[j],-z);
		    }
开发者ID:koudonojinchuu,项目名称:magnus,代码行数:67,代码来源:AbelianEquations.C

示例4: if

main()
{
  FPGroup G;
  VectorOf<int> order;
  cin >> G;
  char ch;
  cin >> ch;
  if (ch != '[') { cerr << "Unexpected input, aborted"<<endl; exit(1);}
  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==',');
  WordOrder word_order("ShortLex",order);
  KBmagPackage kbmag(G.namesOfGenerators(),G.getRelators(),word_order,20);
  if ( !kbmag.sanityCheck() ) {
    error("kbmag failed sanity check.\n");
  }
  if (kbmag.autgroup()==yes){
    cout << "Group "<< G << " is proved shortlex automatic"<<endl;
    GroupDFSA WA = kbmag.wordAcceptor();
    WA.setName("Word_acceptor");
    WA.printOn();
    GenMult GM = kbmag.generalMultiplier();
    GM.setName("General_multiplier");
    GM.printOn();
    DiffMachine D1 = kbmag.differenceMachine(1);
    D1.setName("1stDiffMachine");
    D1.printOn();
    DiffMachine D2 = kbmag.differenceMachine(2);
    D2.setName("2ndDiffMachine");
    D2.printOn();
  }
  else 
    cout << "Group "<< G << " is not proved shortlex automatic"<<endl;
  cout << endl;
  
  FPGroup G2;
  cin >> G2;
  KBmagPackage kbmag2(G2.namesOfGenerators(),G2.getRelators());
  if ( !kbmag2.sanityCheck() ) {
    error("kbmag2 failed sanity check.\n");
  }
  if (kbmag2.kbprog()==yes && kbmag2.gpmakefsa()==yes && kbmag2.gpaxioms()==yes){
    cout << "Group "<< G2 << " is proved shortlex automatic"<<endl;
    GroupDFSA WA = kbmag2.wordAcceptor();
    WA.setName("Word_acceptor");
    WA.printOn();
    GenMult GM = kbmag2.generalMultiplier();
    GM.setName("General_multiplier");
    GM.printOn();
    DiffMachine D1 = kbmag2.differenceMachine(1);
    D1.setName("1stDiffMachine");
    D1.printOn();
    DiffMachine D2 = kbmag2.differenceMachine(2);
    D2.setName("2ndDiffMachine");
    D2.printOn();
  }
  else 
    cout << "Group "<< G2 << " is not proved shortlex automatic"<<endl;
  cout << endl;
  FPGroup G3;
  cin >> G3;
  KBmagPackage kbmag3(G3.namesOfGenerators(),G3.getRelators());
  if ( !kbmag3.sanityCheck() ) {
    error("kbmag3 failed sanity check.\n");
  }
  if (kbmag3.kbprog()>0){
    Bool abort=NO;
    int loop=0;
    do {
      loop++;
      cout << "Trying to built automata."<< endl;
      if (loop>1) cout << "Pass no. " << loop <<" though loop."<< endl; 
      if (kbmag3.gpwa()!=yes || kbmag3.gpgenmult()!=yes) abort=YES; 
      if (abort){ cout << "Failed, giving up!"<< endl; break;}
      GroupDFSA WA = kbmag3.wordAcceptor();
      WA.setName("Word_acceptor");
      WA.printOn();
      GenMult GM = kbmag3.generalMultiplier();
      GM.setName("GeneralMultiplier");
      GM.printOn();
      DiffMachine D1 = kbmag3.differenceMachine(1);
      D1.setName("1stDiffMachine");
      D1.printOn();
      DiffMachineRep D2 = kbmag3.differenceMachineRep(2);
      D2.setName("2ndDiffMachine");
      D2.printOn();
    } while (kbmag3.gpcheckmult()==no);
    if (abort==NO && kbmag3.gpaxioms()==yes)
      cout << "Group "<< G3 << " is proved shortlex automatic"<<endl;
    else 
      cout << "Group "<< G3 << " is not proved shortlex automatic"<<endl;
   }
   GroupDFSARep WA2 = kbmag3.wordAcceptorRep();
   DiffMachineRep D3 = kbmag3.differenceMachineRep(2);
   KBmagPackage kbmag4(G3.namesOfGenerators(),G3.getRelators());
//.........这里部分代码省略.........
开发者ID:koudonojinchuu,项目名称:magnus,代码行数:101,代码来源:test-KBmag.C


注:本文中的VectorOf::append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。