Exemplo n.º 1
0
AbelianEquationsSolver::AbelianEquationsSolver( const AbelianGroup& a , 
						const VectorOf<Word>& v ,
						int numOfVar )
  : rawA( a ),
    A( FPGroup() ),
    rawSystem( v ),
    system( v.length() ),
    b( v.length() ),
    x( numOfVar ),
    torsion( numOfVar ),
    params( numOfVar ),
    numberOfVariables( numOfVar ),
    sysRank( 0 ),
    haveSol( -1 )
{
  FPGroup G( a.getFPGroup() );
  VectorOf<Chars> q( G.numberOfGenerators() - numberOfVariables );
  
  for( int i = numberOfVariables ; i < G.numberOfGenerators() ; i++ )
    q[ i - numberOfVariables ] = (G.namesOfGenerators())[i];
  
  if( G.getRelators().cardinality() )
    {
      SetOf<Word> s = G.getRelators();
      SetIterator<Word> I(s);
      SetOf<Word> news;
      
      while( !I.done() )
	{
	  Word w = I.value();
	  for( int j = 0 ; j < w.length() ; j++ )
	    {
	      int p = Generator( w[j] ).hash();
	      if( p > 0 )
		w[j] = Generator( p - numberOfVariables );
	      else
		w[j] = Generator( p + numberOfVariables );
	    }
	  
	  news.adjoinElement( w );
	  I.next();
	}
      
      FPGroup G1( q , news );
      
      A = AbelianGroup( G1 );
    }
  else
    A = AbelianGroup( FPGroup(q) );
  
}
TEST(GroupSequence, GetMatrix)
{
  GroupSequence seq(2, AbelianGroup(2, 0));
  EXPECT_THROW(seq.get_matrix(1), std::logic_error);
  EXPECT_THROW(seq.get_matrix(3), std::logic_error);
  EXPECT_EQ(MatrixQ::identity(2), seq.get_matrix(2));
}
TEST(GroupSequence, GetGroup)
{
  GroupSequence seq(2, AbelianGroup(2, 0));
  EXPECT_THROW(seq.get_group(1), std::logic_error);
  EXPECT_THROW(seq.get_group(3), std::logic_error);
  EXPECT_EQ(2, seq.get_group(2).free_rank());
  EXPECT_EQ(0, seq.get_group(2).tor_rank());
}