예제 #1
0
void TestBandDiv_B2(tmv::DivType dt)
{
    const int N = 10;

    std::vector<tmv::BandMatrixView<T> > b;
    std::vector<tmv::BandMatrixView<std::complex<T> > > cb;
    MakeBandList(b,cb);

    tmv::Matrix<T> a1(N,N);
    for (int i=0; i<N; ++i) for (int j=0; j<N; ++j) a1(i,j) = T(3+i-2*j);
    a1.diag().addToAll(T(10)*N);
    a1 /= T(10);
    tmv::Matrix<std::complex<T> > ca1 = a1 * std::complex<T>(3,-4);
    a1.diag().addToAll(T(10)*N);
    ca1.diag().addToAll(T(10)*N);

    tmv::MatrixView<T> a1v = a1.view();
    tmv::MatrixView<std::complex<T> > ca1v = ca1.view();

#if (XTEST & 2)
    tmv::Matrix<T> a3 = a1.colRange(0,N/2);
    tmv::Matrix<std::complex<T> > ca3 = ca1.colRange(0,N/2);
    tmv::Matrix<T> a4 = a1.rowRange(0,N/2);
    tmv::Matrix<std::complex<T> > ca4 = ca1.rowRange(0,N/2);
    tmv::Matrix<T> a5(2*N,N);
    a5.rowRange(0,N) = a1;
    a5.rowRange(N,2*N) = a1;
    tmv::Matrix<std::complex<T> > ca5(2*N,N);
    ca5.rowRange(0,N) = ca1;
    ca5.rowRange(N,2*N) = ca1;
    tmv::Matrix<T> a6 = a5.transpose();
    tmv::Matrix<std::complex<T> > ca6 = ca5.transpose();

    tmv::MatrixView<T> a3v = a3.view();
    tmv::MatrixView<T> a4v = a4.view();
    tmv::MatrixView<T> a5v = a5.view();
    tmv::MatrixView<T> a6v = a6.view();
    tmv::MatrixView<std::complex<T> > ca3v = ca3.view();
    tmv::MatrixView<std::complex<T> > ca4v = ca4.view();
    tmv::MatrixView<std::complex<T> > ca5v = ca5.view();
    tmv::MatrixView<std::complex<T> > ca6v = ca6.view();
#endif

    for(size_t i=START;i<b.size();i++) {
        if (showstartdone) 
            std::cout<<"Start B2 loop: i = "<<i<<"\nbi = "<<tmv::TMV_Text(b[i])<<
                "  "<<b[i]<<std::endl;
        tmv::BandMatrixView<T> bi = b[i];
        tmv::BandMatrixView<std::complex<T> > cbi = cb[i];

        TestMatrixDivArith1(dt,a1v,bi,ca1v,cbi,"Band/SquareMatrix");
        if (dt == tmv::LU) continue;
#if (XTEST & 2)
        TestMatrixDivArith1(dt,a3v,bi,ca3v,cbi,"Band/NonSquareMatrix");
        TestMatrixDivArith1(dt,a4v,bi,ca4v,cbi,"Band/NonSquareMatrix");
        TestMatrixDivArith1(dt,a5v,bi,ca5v,cbi,"Band/NonSquareMatrix");
        TestMatrixDivArith1(dt,a6v,bi,ca6v,cbi,"Band/NonSquareMatrix");
#endif
    }
}
예제 #2
0
DEF_TEST(GrAllocator, reporter) {

    // Test combinations of allocators with and without stack storage and with different block
    // sizes.
    SkTArray<GrTAllocator<C>*> allocators;
    GrTAllocator<C> a1(1);
    allocators.push_back(&a1);
    GrTAllocator<C> a2(2);
    allocators.push_back(&a2);
    GrTAllocator<C> a5(5);
    allocators.push_back(&a5);

    GrSTAllocator<1, C> sa1;
    allocators.push_back(&a1);
    GrSTAllocator<3, C> sa3;
    allocators.push_back(&sa3);
    GrSTAllocator<4, C> sa4;
    allocators.push_back(&sa4);

    for (int i = 0; i < allocators.count(); ++i) {
        check_allocator(allocators[i], 0, 0, reporter);
        check_allocator(allocators[i], 1, 1, reporter);
        check_allocator(allocators[i], 2, 2, reporter);
        check_allocator(allocators[i], 10, 1, reporter);
        check_allocator(allocators[i], 10, 5, reporter);
        check_allocator(allocators[i], 10, 10, reporter);
        check_allocator(allocators[i], 100, 10, reporter);
    }
}
예제 #3
0
int main() {
    Matrix a(2,3);
    a.print();
    printf("printing diagonal parts:\n");
    print_diagonal(a);
    
    Matrix a2(3,3);
    a2.print();
    printf("printing diagonal parts:\n");
    print_diagonal(a2);
    
    Matrix a3(1,3);
    a3.print();
    printf("printing diagonal parts:\n");
    print_diagonal(a3);
    
    Matrix a4(4,1);
    a4.print();
    printf("printing diagonal parts:\n");
    print_diagonal(a4);

    Matrix a5(4,3);
    a5.print();
    printf("printing diagonal parts:\n");
    print_diagonal(a5);    
}
예제 #4
0
    TEST(ExpressionAlgoIsSubsetOf, Compare_EQ) {
        ParsedMatchExpression a5("{a: 5}");
        ParsedMatchExpression a6("{a: 6}");
        ParsedMatchExpression b5("{b: 5}");

        ASSERT_TRUE(expression::isSubsetOf(a5.get(), a5.get()));
        ASSERT_FALSE(expression::isSubsetOf(a5.get(), a6.get()));
        ASSERT_FALSE(expression::isSubsetOf(a5.get(), b5.get()));
    }
예제 #5
0
void drive_get_misc_functions()
{

    try {
        // Get function tests
        CQLValue a1(Uint64(123));
        CQLValue a2(Sint64(-123));
        CQLValue a3(Real64(25.24));
        CQLValue a4(String("Hellow"));
        CQLValue a5(Boolean(true));

        String _date("20040811105625.000000-360");
        CIMDateTime date(_date);
        CQLValue a6(date);
        String _date1("20040811105626.000000-360");
        CIMDateTime date1(_date1);
        CQLValue a61(date1);

        String opStr("MyClass.z=true,y=1234,x=\"Hello World\"");
        CIMObjectPath op(opStr);
        CQLValue a7(op);

        const CIMName _cimName(String("CIM_OperatingSystem"));
        CIMInstance _i1(_cimName);

        CQLValue a8(_i1);

        PEGASUS_TEST_ASSERT(a1.getUint() == Uint64(123));
        PEGASUS_TEST_ASSERT(a2.getSint() == Sint64(-123));
        PEGASUS_TEST_ASSERT(a3.getReal() == Real64(25.24));
        PEGASUS_TEST_ASSERT(a4.getString() == String("Hellow"));
        PEGASUS_TEST_ASSERT(a5.getBool() == Boolean(true));
        PEGASUS_TEST_ASSERT(a6.getDateTime() == CIMDateTime(_date));
        PEGASUS_TEST_ASSERT(a6 != a61);
        PEGASUS_TEST_ASSERT(a6 < a61);
        PEGASUS_TEST_ASSERT(a7.getReference() ==
                            CIMObjectPath(opStr));

        try
        {
            a1.getSint();
            PEGASUS_TEST_ASSERT(0);
        }
        catch(...)
        {
            PEGASUS_TEST_ASSERT(1);
        }
    }
    catch(Exception & e)
    {
        cout << e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(0);
    }

    return;
}
exprt string_constraint_generatort::add_axioms_for_last_index_of(
  const string_exprt &str, const exprt &c, const exprt &from_index)
{
  const refined_string_typet &ref_type=to_refined_string_type(str.type());
  const typet &index_type=ref_type.get_index_type();
  symbol_exprt index=fresh_exist_index("last_index_of", index_type);
  symbol_exprt contains=fresh_boolean("contains_in_last_index_of");

  // We add axioms:
  // a1 : -1 <= i <= from_index
  // a2 : (i=-1 <=> !contains)
  // a3 : (contains => i <= from_index &&s[i]=c)
  // a4 : forall n. i+1 <= n < from_index +1 &&contains => s[n]!=c
  // a5 : forall m. 0 <= m < from_index +1 &&!contains => s[m]!=c

  exprt index1=from_integer(1, index_type);
  exprt minus1=from_integer(-1, index_type);
  exprt from_index_plus_one=plus_exprt(from_index, index1);
  and_exprt a1(
    binary_relation_exprt(index, ID_ge, minus1),
    binary_relation_exprt(index, ID_lt, from_index_plus_one));
  axioms.push_back(a1);

  equal_exprt a2(not_exprt(contains), equal_exprt(index, minus1));
  axioms.push_back(a2);

  implies_exprt a3(
    contains,
    and_exprt(
      binary_relation_exprt(from_index, ID_ge, index),
      equal_exprt(str[index], c)));
  axioms.push_back(a3);

  symbol_exprt n=fresh_univ_index("QA_last_index_of", index_type);
  string_constraintt a4(
    n,
    plus_exprt(index, index1),
    from_index_plus_one,
    contains,
    not_exprt(equal_exprt(str[n], c)));
  axioms.push_back(a4);

  symbol_exprt m=fresh_univ_index("QA_last_index_of", index_type);
  string_constraintt a5(
    m,
    from_index_plus_one,
    not_exprt(contains),
    not_exprt(equal_exprt(str[m], c)));
  axioms.push_back(a5);

  return index;
}
예제 #7
0
파일: analex3.c 프로젝트: magsilva/poketool
void yylex()
{

/* Declaracao de Variaveis Locais */

int l,s;               /* Variaveis de controle do AF */

/* Inicializacao de Variaveis Locais */

l=0;s=0;

saida.classe[0]=EOF;
saida.classe[1]='\0';

/* AUTOMATO FINITO (AF) */
peg_ch();
while(ch != EOF && s!= FINAL_STATE)
   {
    if(compara_simbolo(ch,tab_trans[l])==TRUE)
       {
          s=tab_trans[l]->proximo_estado;
          switch(tab_trans[l]->acao_semantica)
            {
	     case 1: a1();break;
	     case 2: a2();break;
	     case 3: a3();break;
	     case 4: a4();break;
	     case 5: a5();break;
	     case 6: a6();break;
	     case 7: a7();break;
	     case 8: a8();break;
	     case 9: a9();break;
	     case 10: a10();break;
	     case 11: a11();break;
	     default:;
	    }
	  if(s!=FINAL_STATE) {
		  peg_ch();
		  l=tab_trans[l]->proxima_transicao;
		  }
        }
        else
            {
             ++l;
             if(s==tab_trans[l]->estado_atual) continue;
             else
		  error("* * Erro Fatal: transicao errada no ANALISADOR LEXICO * *\n");
            }
    }
return;
}
예제 #8
0
void level_three()
{
	vector<DPipe> DirectPipes(13);
		vector<DoublePipe> DoublePipes(13);
		vector<CrossPipe> CrossPipes(2);
				DPipe a0(50,SCREEN_HEIGHT-50,100,40);
				DoublePipe b0(150,SCREEN_HEIGHT-50,70,40);
				DPipe a1(150,SCREEN_HEIGHT-150,100,40);
				DoublePipe b1(150,SCREEN_HEIGHT-250,70,40);
				DPipe a2(250,SCREEN_HEIGHT-350,100,40);
				DoublePipe b2(350,SCREEN_HEIGHT-250,70,40);
				DPipe a3(350,SCREEN_HEIGHT-350,100,40);
				DPipe a4(350,SCREEN_HEIGHT-150,100,40);
				DoublePipe b3(250,SCREEN_HEIGHT-450,70,40);
				DoublePipe b4(350,SCREEN_HEIGHT-450,70,40);
				CrossPipe c0(250,SCREEN_HEIGHT-250,100,40);
				DPipe a5(550,SCREEN_HEIGHT-50,100,40);
				DoublePipe b5(250,SCREEN_HEIGHT-150,70,40);
				DoublePipe b6(450,SCREEN_HEIGHT-50,70,40);
				DoublePipe b7(650,SCREEN_HEIGHT-150,70,40);
				DPipe a6(550,SCREEN_HEIGHT-50,100,40);
				DPipe a7(550,SCREEN_HEIGHT-150,100,40);
				DoublePipe b8(750,SCREEN_HEIGHT-50,70,40);
				DPipe a8(550,SCREEN_HEIGHT-250,100,40);
				DoublePipe b9(750,SCREEN_HEIGHT-350,70,40);
				CrossPipe c1(450,SCREEN_HEIGHT-150,100,40);
				DoublePipe b10(350,SCREEN_HEIGHT-450,70,40);
				DPipe a9(750,SCREEN_HEIGHT-150,100,40);
				DPipe a10(750,SCREEN_HEIGHT-250,100,40);
				DoublePipe b11(450,SCREEN_HEIGHT-250,70,40);
				DoublePipe b12(650,SCREEN_HEIGHT-250,70,40);
				DPipe a11(650,SCREEN_HEIGHT-50,100,40);
				DPipe a12(850,SCREEN_HEIGHT-350,100,40);

				DirectPipes[0] = a0; DoublePipes[0] = b0;
				DirectPipes[1] = a1; DoublePipes[1] = b1;
				DirectPipes[2] = a2; DoublePipes[2] = b2;
				DirectPipes[3] = a3; DoublePipes[3] = b3;
				DirectPipes[4] = a4; DoublePipes[4] = b4;
				DirectPipes[5] = a5; DoublePipes[5] = b5;
				DirectPipes[6] = a6; DoublePipes[6] = b6;
				DirectPipes[7] = a7; DoublePipes[7] = b7;
				DirectPipes[8] = a8; DoublePipes[8] = b8;
				DirectPipes[9] = a9; DoublePipes[9] = b9;
				DirectPipes[10] = a10; DoublePipes[10] = b10;
				DirectPipes[11] = a11; DoublePipes[11] = b11;
				DirectPipes[12] = a12; DoublePipes[12] = b12;
				CrossPipes[0] = c0; CrossPipes[1] = c1;
				Water a(20,SCREEN_HEIGHT-50,40,40);
}
예제 #9
0
IMPATOM_BEGIN_NAMESPACE

HelixRestraint::HelixRestraint(Residues rs, bool ideal)
    : Restraint(rs[0]->get_model(), "HelixRestraint%1%") {
  //dihedral info
  //Float dih1,std1,dih2,std2,distON,kON;
  Float dih1  = -1.117010721276371; //mean = -64deg, std = 6deg
  Float std1  = 0.10471975511965977;
  Float dih2  = -0.715584993317675; //mean = -41deg, std = 8deg
  Float std2  = 0.13962634015954636;
  Float corr = -0.25;
  Float weight = 0.5;
  core::BinormalTerm bt;
  bt.set_means(std::make_pair(dih1,dih2));
  bt.set_standard_deviations(std::make_pair(std1,std2));
  bt.set_correlation(corr);
  bt.set_weight(weight);

  //bond info
  Float distON = 2.96;
  Float kON = core::Harmonic::get_k_from_standard_deviation(0.11);

  //will expand to more bonds and residue types
  bond_ON_score_ = new core::HarmonicDistancePairScore(distON,kON);

  if (rs.size()>=3){
    for(size_t nr=0;nr<rs.size()-2;nr++){
      core::XYZ a1(get_atom(rs[nr],AT_C));
      core::XYZ a2(get_atom(rs[nr+1],AT_N));
      core::XYZ a3(get_atom(rs[nr+1],AT_CA));
      core::XYZ a4(get_atom(rs[nr+1],AT_C));
      core::XYZ a5(get_atom(rs[nr+2],AT_N));
      IMP_NEW(core::MultipleBinormalRestraint,
              mbr,(get_model(),
                   ParticleIndexQuad(a1,a2,a3,a4),
                   ParticleIndexQuad(a2,a3,a4,a5)));
      mbr->add_term(bt);
      dihedral_rs_.push_back(mbr);
    }
  }

  if (rs.size()>=5){
    for(size_t nr=0;nr<rs.size()-4;nr++){
      bonds_ON_.push_back(ParticleIndexPair(
                                            get_atom(rs[nr],AT_O).get_particle_index(),
                                            get_atom(rs[nr+4],AT_N).get_particle_index()));
    }
  }
}
예제 #10
0
void 
driver_actividade(){
//    Actividade a1( "chave3","trabalho3", 13, MES);
//    Actividade *ptr_a = &a1;
//    Actividade a2( *ptr_a );
//    std::cout << a2.getIdentificador() <<
//        std::endl << a2.getDescricao() <<
//        std::endl << a2.getDuracao() << 
//        std::endl << a2.getUnidadeDuracao() << 
//    std::endl;
//    std::cout << ((a1 == a2) ? "a1 == a2\n" : "a1 <> a2\n");
//    Actividade a3;
//    a3.setIdentificador( "key1" );
//    a3.setDescricao("encomenda");
//    a3.setDuracao(8);
//    a3.setUnidadeDuracao(MES);
//    std::cout << a3;
//    std::cout << ((a1 < a3) ? "a1 < a3\n" : "falso\n");
//    std::cout << ((a1 > a3) ? "a1 > a3\n" : "falso\n");
//    std::cout << ((a3 > a1) ? "a3 > a1\n" : "falso\n");
//    a3 = a1;
//    std::cout << ((a1 == a3) ? "a1 == a3\n" : "falso\n");
//    Actividade a4( "chave4","trabalho4", 34, DIA);
    Lista<Actividade*> l1;
    Actividade a1( "chave1","trabalho 1", 134, MES, l1);
    Lista<Actividade*> l2;
    Actividade a2( "chave2","trabalho 2", 10, MES, l2);
    Lista<Actividade*> l3;
    Actividade a3( "chave3","trabalho 3", 95, MES, l3);
    Lista<Actividade*> l4;
    l4.insere(1,&a2);
    l4.insere(1,&a3);
    Actividade a4( "chave4","trabalho 4", 813, HORA, l4);
    Lista<Actividade*> l5;
    Actividade a5( "chave5","trabalho 5", 87, DIA, l5);
    Lista<Actividade*> l6;
    Actividade a6( "chave6","trabalho 6", 934, MES, l6);

    std::cout << a4;
    std::cout << a5;
//Actividade:  
//    id:      chave4
//    desc:    trabalho 4
//    durac:   813
//    unidade: 0
//    precedentes: 0xbffff938 0xbffff954 

}
exprt string_constraint_generatort::add_axioms_for_index_of(
  const string_exprt &str, const exprt &c, const exprt &from_index)
{
  const typet &index_type=str.length().type();
  symbol_exprt index=fresh_exist_index("index_of", index_type);
  symbol_exprt contains=fresh_boolean("contains_in_index_of");

  // We add axioms:
  // a1 : -1 <= index<|str|
  // a2 : !contains <=> index=-1
  // a3 : contains => from_index<=index&&str[index]=c
  // a4 : forall n, from_index<=n<index. contains => str[n]!=c
  // a5 : forall m, from_index<=n<|str|. !contains => str[m]!=c

  exprt minus1=from_integer(-1, index_type);
  and_exprt a1(
    binary_relation_exprt(index, ID_ge, minus1),
    binary_relation_exprt(index, ID_lt, str.length()));
  axioms.push_back(a1);

  equal_exprt a2(not_exprt(contains), equal_exprt(index, minus1));
  axioms.push_back(a2);

  implies_exprt a3(
    contains,
    and_exprt(
      binary_relation_exprt(from_index, ID_le, index),
      equal_exprt(str[index], c)));
  axioms.push_back(a3);

  symbol_exprt n=fresh_univ_index("QA_index_of", index_type);
  string_constraintt a4(
    n, from_index, index, contains, not_exprt(equal_exprt(str[n], c)));
  axioms.push_back(a4);

  symbol_exprt m=fresh_univ_index("QA_index_of", index_type);
  string_constraintt a5(
    m,
    from_index,
    str.length(),
    not_exprt(contains),
    not_exprt(equal_exprt(str[m], c)));
  axioms.push_back(a5);

  return index;
}
예제 #12
0
static void TestSmallNonSquareDiv_B4a()
{
    tmv::SmallMatrix<T,6,N,stor> m;

    for(int i=0;i<6;++i) for(int j=0;j<N;++j) m(i,j) = T(2+4*i-5*j);
    m.diag() *= T(11);
    m /= T(7);
    if (N > 1) m(1,0) = -2;
    if (N > 2) m(2,0) = 7;
    if (N > 3) m(3,0) = -10;
    if (N > 2) m(2,2) = 30;

    tmv::SmallMatrix<T,6,N,stor> a1 = m;
    tmv::SmallMatrix<std::complex<T>,6,N,stor> c1 = a1 * std::complex<T>(1,2);

    tmv::SmallMatrix<T,N,7,stor> a5;
    for(int i=0;i<N;++i) for(int j=0;j<7;++j) a5(i,j) = T(1-3*i+2*j);
    a5.subMatrix(0,N,1,7) -= a1.transpose();
    tmv::SmallMatrix<std::complex<T>,N,7,stor> c5 = a5 * std::complex<T>(2,-2);
    c5.subMatrix(0,N,1,7) -= c1.transpose();
    c5.col(3) *= std::complex<T>(-1,3);
    c5.row(0).addToAll(std::complex<T>(1,9));

    tmv::SmallMatrix<T,6,7,stor> a7;
    for(int i=0;i<6;++i) for(int j=0;j<7;++j) a7(i,j) = T(5+2*i-2*j);
    a7.subMatrix(0,6,1,1+N) -= T(2)*a1;
    tmv::SmallMatrix<std::complex<T>,6,7,stor> c7 = a7 * std::complex<T>(-1,-3);
    c7.subMatrix(0,6,1,1+N) -= T(2)*c1;
    c7.col(3) *= std::complex<T>(-1,3);
    c7.row(4).addToAll(std::complex<T>(1,9));

    TestMatrixDivArith3b(tmv::QR,a1,a7,a5,c1,c7,c5,"NonSquare/NonSquare"); 
#if (XTEST & 32)
    tmv::SmallMatrix<T,6,N,stor|tmv::FortranStyle> a1f = a1;
    tmv::SmallMatrix<std::complex<T>,6,N,stor|tmv::FortranStyle> c1f = c1;
    tmv::SmallMatrix<T,N,7,stor|tmv::FortranStyle> a5f = a5;
    tmv::SmallMatrix<std::complex<T>,N,7,stor|tmv::FortranStyle> c5f = c5;
    tmv::SmallMatrix<T,6,7,stor|tmv::FortranStyle> a7f = a7;
    tmv::SmallMatrix<std::complex<T>,6,7,stor|tmv::FortranStyle> c7f = c7;

    TestMatrixDivArith3b(tmv::QR,a1f,a7,a5,c1f,c7,c5,"NonSquare/NonSquare"); 
    TestMatrixDivArith3b(tmv::QR,a1f,a7f,a5,c1f,c7f,c5,"NonSquare/NonSquare"); 
    TestMatrixDivArith3b(tmv::QR,a1f,a7f,a5f,c1f,c7f,c5f,"NonSquare/NonSquare"); 
#endif
}
예제 #13
0
    TEST(ExpressionAlgoIsSubsetOf, PointInUnboundedRange) {
        ParsedMatchExpression a4("{a: 4}");
        ParsedMatchExpression a5("{a: 5}");
        ParsedMatchExpression a6("{a: 6}");
        ParsedMatchExpression b5("{b: 5}");

        ParsedMatchExpression lt5("{a: {$lt: 5}}");
        ParsedMatchExpression lte5("{a: {$lte: 5}}");
        ParsedMatchExpression gte5("{a: {$gte: 5}}");
        ParsedMatchExpression gt5("{a: {$gt: 5}}");

        ASSERT_TRUE(expression::isSubsetOf(a4.get(), lte5.get()));
        ASSERT_TRUE(expression::isSubsetOf(a5.get(), lte5.get()));
        ASSERT_FALSE(expression::isSubsetOf(a6.get(), lte5.get()));

        ASSERT_TRUE(expression::isSubsetOf(a4.get(), lt5.get()));
        ASSERT_FALSE(expression::isSubsetOf(a5.get(), lt5.get()));
        ASSERT_FALSE(expression::isSubsetOf(a6.get(), lt5.get()));

        ASSERT_FALSE(expression::isSubsetOf(a4.get(), gte5.get()));
        ASSERT_TRUE(expression::isSubsetOf(a5.get(), gte5.get()));
        ASSERT_TRUE(expression::isSubsetOf(a6.get(), gte5.get()));

        ASSERT_FALSE(expression::isSubsetOf(a4.get(), gt5.get()));
        ASSERT_FALSE(expression::isSubsetOf(a5.get(), gt5.get()));
        ASSERT_TRUE(expression::isSubsetOf(a6.get(), gt5.get()));

        // An unbounded range query does not match a subset of documents of a point query.
        ASSERT_FALSE(expression::isSubsetOf(lt5.get(), a5.get()));
        ASSERT_FALSE(expression::isSubsetOf(lte5.get(), a5.get()));
        ASSERT_FALSE(expression::isSubsetOf(gte5.get(), a5.get()));
        ASSERT_FALSE(expression::isSubsetOf(gt5.get(), a5.get()));

        // Cannot be a subset if comparing different field names.
        ASSERT_FALSE(expression::isSubsetOf(b5.get(), lt5.get()));
        ASSERT_FALSE(expression::isSubsetOf(b5.get(), lte5.get()));
        ASSERT_FALSE(expression::isSubsetOf(b5.get(), gte5.get()));
        ASSERT_FALSE(expression::isSubsetOf(b5.get(), gt5.get()));
    }
예제 #14
0
    void testAddress()
    {
        smpl::Address a("user@group/567257247245275");
        assert(a.user == "user");
        assert(a.group == "group");
        assert(a.id == "567257247245275");
        assert(a.valid());

        smpl::Address a1("user@group");
        assert(a1.user == "user");
        assert(a1.group == "group");
        assert(a1.id == "");
        assert(a1.valid());

        smpl::Address a2("group");
        assert(a2.user == "");
        assert(a2.group == "group");
        assert(a2.id == "");
        assert(a2.valid());

        smpl::Address a3("");
        assert(a3.user == "");
        assert(a3.group == "");
        assert(a3.id == "");
        assert(!a3.valid());

        smpl::Address a4("/567257247245275");
        assert(a4.user == "");
        assert(a4.group == "");
        assert(a4.id == "567257247245275");
        assert(a4.valid());

        smpl::Address a5("group/567257247245275");
        assert(a5.user == "");
        assert(a5.group == "group");
        assert(a5.id == "567257247245275");
        assert(a5.valid());
    }
예제 #15
0
파일: Polyhedra.cpp 프로젝트: mew-cx/osgtoy
osgToy::RhombicDodecahedron::RhombicDodecahedron()
{
    setOverallColor( osg::Vec4(0,1,0,1) );

    osg::Vec3 a0(  1,  1,  1 );
    osg::Vec3 a1(  1,  1, -1 );
    osg::Vec3 a2(  1, -1,  1 );
    osg::Vec3 a3(  1, -1, -1 );
    osg::Vec3 a4( -1,  1,  1 );
    osg::Vec3 a5( -1,  1, -1 );
    osg::Vec3 a6( -1, -1,  1 );
    osg::Vec3 a7( -1, -1, -1 );

    osg::Vec3 xp(  2,  0,  0 );
    osg::Vec3 xn( -2,  0,  0 );
    osg::Vec3 yp(  0,  2,  0 );
    osg::Vec3 yn(  0, -2,  0 );
    osg::Vec3 zp(  0,  0,  2 );
    osg::Vec3 zn(  0,  0, -2 );

    addTristrip( yp, a0, a1, xp );
    addTristrip( xp, a2, a3, yn );
    addTristrip( yn, a6, a7, xn );
    addTristrip( xn, a4, a5, yp );

    addTristrip( zp, a0, a4, yp );
    addTristrip( yp, a1, a5, zn );
    addTristrip( zn, a3, a7, yn );
    addTristrip( yn, a2, a6, zp );

    addTristrip( xp, a0, a2, zp );
    addTristrip( zp, a4, a6, xn );
    addTristrip( xn, a5, a7, zn );
    addTristrip( zn, a1, a3, xp );

    osgToy::FacetingVisitor::facet( *this );
}
예제 #16
0
int main(int argc,char **argv)
{
	setlocale(LC_ALL,"RUSSIAN");

	SDL_DisplayMode displayMode;

	if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
	{
    cout << "SDL_Init Error: " << SDL_GetError() << endl;
    return 1;
	}

	int request = SDL_GetDesktopDisplayMode(0,&displayMode); 

	SDL_Window *win = SDL_CreateWindow("Trubi", 300, 300,800, 800, SDL_WINDOW_SHOWN);
	if (win == nullptr)
	{
		cout << "SDL_CreateWindow Error: " << SDL_GetError() << endl;
	    return 1;
	}

	SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
	if (ren == nullptr)
	{
		cout << "SDL_CreateRenderer Error: " << SDL_GetError() << endl;
	    return 1;
	}

	vector<DPipe> DPIPES(13);
	vector<DoublePipe> DOUBPIPES(6);

	DPipe background(400,400,800,800);
	DPipe a0(70,300,100,40);
	DPipe a1(170,300,100,40);
	DPipe a2(270,300,100,40);
	DPipe a3(370,400,100,40);
	DPipe a4(370,500,100,40);
	DPipe a5(470,600,100,40);
	DPipe a6(570,600,100,40);
	DPipe a7(670,500,100,40);
	DPipe a8(670,400,100,40);
	
	DPipe a9(370,200,100,40);
	DPipe a10(470,100,100,40);
	DPipe a11(570,100,100,40);
	DPipe a12(670,200,100,40);
	DPipe kletka(370,300,100,100);

	DoublePipe b0(370,300,70,40);
	DoublePipe b1(370,600,70,40);
	DoublePipe b2(670,600,70,40);
	DoublePipe b3(670,300,70,40);
	DoublePipe b4(370,100,70,40);
	DoublePipe b5(670,100,70,40);

	DPIPES[0]=a0;
	DPIPES[1]=a1;
	DPIPES[2]=a2;
	DPIPES[3]=a3;
	DPIPES[4]=a4;
	DPIPES[5]=a5;
	DPIPES[6]=a6;
	DPIPES[7]=a7;
	DPIPES[8]=a8;
	DPIPES[9]=a9;
	DPIPES[10]=a10;
	DPIPES[11]=a11;
	DPIPES[12]=a12;
	
	DOUBPIPES[0]=b0;
	DOUBPIPES[1]=b1;
	DOUBPIPES[2]=b2;
	DOUBPIPES[3]=b3;
	DOUBPIPES[4]=b4;
	DOUBPIPES[5]=b5;

	SDL_RenderClear(ren);
	background.default_create(ren,"newbackground.bmp");
	for(int i=0;i<DPIPES.size();++i)
	{
		DPIPES[i].default_create(ren,"text1.bmp");
	}
	for(int i=0;i<DOUBPIPES.size();++i)
	{
		DOUBPIPES[i].default_create1(ren,"double1.bmp","double2.bmp");
	}
	SDL_RenderPresent(ren); 

	bool quit=false;
	while(!quit)
	{
		 while(SDL_PollEvent(&event))
		 {
			SDL_PumpEvents(); 

			if(event.type == SDL_QUIT)
				quit=true;
			else if(event.type==SDL_MOUSEBUTTONDOWN &&  event.button.button==SDL_BUTTON_LEFT)
			{
				for(int i=0;i<DPIPES.size();++i)
				{
					if(DPIPES[i].ismouse())
					{
						SDL_RenderClear(ren);
						background.default_create(ren,"newbackground.bmp");
						nochangesDoub(ren,DOUBPIPES);
						somechanges(ren,DPIPES,i);
					}
				}
				for(int i=0;i<DOUBPIPES.size();++i)
				{
					if(DOUBPIPES[i].ismouse())
					{
						SDL_RenderClear(ren);
						background.default_create(ren,"newbackground.bmp");
						nochanges(ren,DPIPES);
						somechangesDoub(ren,DOUBPIPES,i);
					}
				}
			}
		 }
	}
	return 1;
}
예제 #17
0
Extractor::Extractor(int _n, int _k, int _d, int _l, float _epsilon) {
    n = _n;
    k = _k;
    d = _d;
    l = _l;
    epsilon = _epsilon;


    // Polinomio irredutivel 2^32 (x^32 + x^15 + x^9 +x^7 + x^4 + x^3 + 1) ???
    ZZ p;
    p=2;
    ZZ_p::init(p);
    ZZ_p one;
    one=1;
    ZZ_pX a1(0,one),a2(3,one),a3(4,one), a4(7,one), a5(9,one), a6(15,one), a7(32,one);
    ZZ_pX mod32;
    mod32 = a1 + a2 + a3 + a4 + a5 + a6 + a7;

    ZZ_pE::init(mod32);


    // Polinomio irredutivel 2^32^32

    string c[32];
    ZZ_pE wp[32];

    // (X^30 + X^28 + X^27 + X^26 + X^21 + X^20 + X^19 + X^18 + X^15 + X^14 + X^11 + X^4 + X^3 + X^2 + X) +
    c[0] 	= "[0 1 0 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 0 0 0 0 0 0 1 1 1 1 0]";
    // (X^30 + X^27 + X^26 + X^24 + X^22 + X^21 + X^20 + X^18 + X^17 + X^16 + X^13 + X^12 + X^11 + X^10 + X^7 + X^6 + X^3 + X^2)*Y +
    c[1] 	= "[0 1 0 0 1 1 0 1 0 1 1 1 0 1 1 1 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0]";
    // (X^31 + X^30 + X^29 + X^28 + X^27 + X^25 + X^22 + X^18 + X^16 + X^14 + X^13 + X^11 + X^9 + X^7 + X^3 + X^2 + X + 1)*Y^2 +
    c[2] 	= "[1 1 1 1 1 0 1 0 0 1 0 0 0 1 0 1 0 1 1 0 1 0 1 0 1 0 0 0 1 1 1 1]";
    // (X^31 + X^28 + X^22 + X^21 + X^19 + X^18 + X^15 + X^13 + X^10 + X^9 + X^8 + X^7 + X^5 + X^4 + X^2 + 1)*Y^3 +
    c[3] 	= "[1 0 0 1 0 0 0 0 0 1 1 0 1 1 0 0 1 0 1 0 0 1 1 1 1 0 1 1 0 1 0 1]";
    // (X^31 + X^30 + X^27 + X^26 + X^25 + X^24 + X^23 + X^21 + X^16 + X^12 + X^9 + X^8 + X^6 + X^3 + X^2)*Y^4 +
    c[4] 	= "[1 1 0 0 1 1 1 1 1 0 1 0 0 0 0 1 0 0 0 1 0 0 1 1 0 1 0 0 1 1 0 0]";
    // (X^31 + X^30 + X^29 + X^28 + X^27 + X^26 + X^24 + X^23 + X^22 + X^21 + X^20 + X^18 + X^15 + X^12 + X^9 + X^7 + X^6 + X^5 + X^4 + X^3)*Y^5 +
    c[5] 	= "[1 1 1 1 1 1 0 1 1 1 1 1 0 1 0 0 1 0 0 1 0 0 1 0 1 1 1 1 1 0 0 0]";
    // (X^31 + X^29 + X^25 + X^21 + X^20 + X^19 + X^17 + X^16 + X^14 + X^13 + X^11 + X^10 + X^9 + X^5 + X^4 + X^3 + X + 1)*Y^6 +
    c[6] 	= "[1 0 1 0 0 0 1 0 0 0 1 1 1 0 1 1 0 1 1 0 1 1 1 0 0 0 1 1 1 0 1 1]";
    // (X^31 + X^30 + X^29 + X^28 + X^24 + X^22 + X^19 + X^17 + X^16 + X^10 + X^8 + X^7 + X^6 + X^5 + X^3 + X^2)*Y^7 +
    c[7] 	= "[1 1 1 1 0 0 0 1 0 1 0 0 1 0 1 1 0 0 0 0 0 1 0 1 1 1 1 0 1 1 0 0]";
    // (X^31 + X^30 + X^29 + X^25 + X^21 + X^20 + X^18 + X^16 + X^14 + X^13 + X^12 + X^10 + X^9 + X^8 + X^7 + X^6 + X^3)*Y^8 +
    c[8] 	= "[1 1 1 0 0 0 1 0 0 0 1 1 0 1 0 1 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0 0]";
    // (X^27 + X^26 + X^23 + X^18 + X^17 + X^16 + X^14 + X^13 + X^12 + X^10 + X^8 + X^7 + X^4 + X^3 + X^2)*Y^9 +
    c[9] 	= "[0 0 0 0 1 1 0 0 1 0 0 0 0 1 1 1 0 1 1 1 0 1 0 1 1 0 0 1 1 1 0 0]";
    // (X^28 + X^25 + X^24 + X^23 + X^20 + X^19 + X^18 + X^17 + X^16 + X^14 + X^13 + X^12 + X^11 + X^10 + X^7 + X^4 + X^3 + X)*Y^10 +
    c[10] 	= "[0 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0 1 0 0 1 1 0 1 0]";
    // (X^31 + X^29 + X^28 + X^27 + X^23 + X^22 + X^17 + X^16 + X^10 + X^9 + X^7 + X^5 + X^4 + X^3 + X^2)*Y^11 +
    c[11] 	= "[1 0 1 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 1 1 1 1 0 0]";
    // (X^30 + X^29 + X^23 + X^22 + X^21 + X^20 + X^18 + X^16 + X^14 + X^13 + X^12 + X^10 + X^9 + X^4)*Y^12 +
    c[12] 	= "[0 1 1 0 0 0 0 0 1 1 1 1 0 1 0 1 0 1 1 1 0 1 1 0 0 0 0 1 0 0 0 0]";
    // (X^29 + X^25 + X^22 + X^20 + X^17 + X^16 + X^15 + X^13 + X^9 + X^8 + X^7 + X^6 + X^5 + X^4 + X^2)*Y^13 +
    c[13] 	= "[0 0 1 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 1 0 0 0 1 1 1 1 1 1 0 1 0 0]";
    // (X^31 + X^29 + X^27 + X^26 + X^17 + X^16 + X^14 + X^13 + X^10 + X^7 + X^4 + X^3)*Y^14 +
    c[14] 	= "[1 0 1 0 1 1 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 1 0 0 1 0 0 1 1 0 0 0]";
    // (X^31 + X^30 + X^26 + X^25 + X^24 + X^19 + X^17 + X^16 + X^15 + X^13 + X^12 + X^9 + X^8 + X^7 + X^6 + X^4 + X + 1)*Y^15 +
    c[15] 	= "[1 1 0 0 0 1 1 1 0 0 0 0 1 0 1 1 1 0 1 1 0 0 1 1 1 1 0 1 0 0 1 1]";
    // (X^31 + X^30 + X^27 + X^26 + X^25 + X^24 + X^23 + X^20 + X^19 + X^18 + X^14 + X^12 + X^11 + X^9 + X^8 + X^6 + X^5 + X^3 + X^2)*Y^16 +
    c[16] 	= "[1 1 0 0 1 1 1 1 1 0 0 1 1 1 0 0 0 1 0 1 1 0 1 1 0 1 1 0 1 1 0 0]";
    // (X^31 + X^30 + X^29 + X^28 + X^25 + X^21 + X^20 + X^19 + X^18 + X^17 + X^15 + X^13 + X^12 + X^11 + X^9 + X^8 + X^7 + X^2)*Y^17 +
    c[17] 	= "[1 1 1 1 0 0 1 0 0 0 1 1 1 1 1 0 1 0 1 1 1 0 1 1 1 0 0 0 0 1 0 0]";
    // (X^31 + X^30 + X^24 + X^23 + X^19 + X^17 + X^15 + X^10 + X^8 + X^6 + X^3 + X^2)*Y^18 +
    c[18] 	= "[1 1 0 0 0 0 0 1 1 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 1 0 0 1 1 0 0]";
    // (X^30 + X^29 + X^26 + X^25 + X^20 + X^19 + X^15 + X^14 + X^10 + X^9 + X^8 + X^6 + X^5 + X^3)*Y^19 +
    c[19] 	= "[0 1 1 0 0 1 1 0 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1 0 0 0]";
    // (X^31 + X^30 + X^27 + X^25 + X^19 + X^17 + X^16 + X^14 + X^8 + X^6 + X^4 + X^3 + X^2 + 1)*Y^20 +
    c[20] 	= "[1 1 0 0 1 0 1 0 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 1 0 1 0 1 1 1 0 1]";
    // (X^31 + X^28 + X^27 + X^25 + X^24 + X^21 + X^17 + X^16 + X^14 + X^13 + X^10 + X^8 + X^6 + X^5 + X^2)*Y^21 +
    c[21] 	= "[1 0 0 1 1 0 1 1 0 0 1 0 0 0 1 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 0]";
    // (X^31 + X^28 + X^25 + X^24 + X^23 + X^21 + X^20 + X^18 + X^17 + X^16 + X^15 + X^14 + X^11 + X^10 + X^9 + X^7 + X^6 + X^5 + X^3 + 1)*Y^22 +
    c[22] 	= "[1 0 0 1 0 0 1 1 1 0 1 1 0 1 1 1 1 1 0 0 1 1 1 0 1 1 1 0 1 0 0 1]";
    // (X^31 + X^29 + X^27 + X^26 + X^24 + X^23 + X^22 + X^19 + X^18 + X^17 + X^15 + X^14 + X^13 + X^12 + X^11 + X^6 + X^5 + X^4)*Y^23 +
    c[23] 	= "[1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 1 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0]";
    // (X^31 + X^30 + X^29 + X^23 + X^21 + X^19 + X^17 + X^16 + X^13 + X^11 + X^10 + X^9 + X^8 + X^6 + X + 1)*Y^24 +
    c[24] 	= "[1 1 1 0 0 0 0 0 1 0 1 0 1 0 1 1 0 0 1 0 1 1 1 1 0 1 0 0 0 0 1 1]";
    // (X^31 + X^30 + X^29 + X^28 + X^27 + X^25 + X^20 + X^18 + X^17 + X^16 + X^15 + X^14 + X^9 + X^6 + X^3 + 1)*Y^25 +
    c[25] 	= "[1 1 1 1 1 0 1 0 0 0 0 1 0 1 1 1 1 1 0 0 0 0 1 0 0 1 0 0 1 0 0 1]";
    // (X^30 + X^28 + X^25 + X^24 + X^23 + X^20 + X^18 + X^17 + X^16 + X^15 + X^12 + X^9 + X^7 + X^6 + X^5 + X^4)*Y^26 +
    c[26] 	= "[0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 1 0 0 1 0 0 1 0 1 1 1 1 0 0 0 0]";
    // (X^30 + X^29 + X^28 + X^27 + X^26 + X^25 + X^24 + X^21 + X^20 + X^19 + X^18 + X^12 + X^8 + X^7 + X^2 + X + 1)*Y^27 +
    c[27] 	= "[0 1 1 1 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 1 1]";
    // (X^31 + X^29 + X^26 + X^25 + X^23 + X^19 + X^18 + X^17 + X^15 + X^13 + X^9 + X^7 + X^4 + 1)*Y^28 +
    c[28] 	= "[1 0 1 0 0 1 1 0 1 0 0 0 1 1 1 0 1 0 1 0 0 0 1 0 1 0 0 1 0 0 0 1]";
    // (X^31 + X^25 + X^24 + X^23 + X^22 + X^20 + X^17 + X^16 + X^15 + X^14 + X^13 + X^12 + X^9 + X^8 + X^3 + X^2)*Y^29 +
    c[29] 	= "[1 0 0 0 0 0 1 1 1 1 0 1 0 0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0]";
    // (X^31 + X^29 + X^28 + X^27 + X^24 + X^22 + X^21 + X^20 + X^16 + X^15 + X^13 + X^10 + X^7 + X^5 + X^4 + X^3 + X^2)*Y^30 +
    c[30] 	= "[1 0 1 1 1 0 0 1 0 1 1 1 0 0 0 1 1 0 1 0 0 1 0 0 1 0 1 1 1 1 0 0]";
    // (X^31 + X^26 + X^24 + X^22 + X^20 + X^15 + X^14 + X^12 + X^11 + X^9 + X^8 + X^5 + X^2 + X + 1)*Y^31 +
    c[31] 	= "[1 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0 1 1 0 1 1 0 1 1 0 0 1 0 0 1 1 1]";


    stringstream caix0(c[0]);
    stringstream caix1(c[1]);
    stringstream caix2(c[2]);
    stringstream caix3(c[3]);
    stringstream caix4(c[4]);
    stringstream caix5(c[5]);
    stringstream caix6(c[6]);
    stringstream caix7(c[7]);
    stringstream caix8(c[8]);
    stringstream caix9(c[9]);
    stringstream caix10(c[10]);
    stringstream caix11(c[11]);
    stringstream caix12(c[12]);
    stringstream caix13(c[13]);
    stringstream caix14(c[14]);
    stringstream caix15(c[15]);
    stringstream caix16(c[16]);
    stringstream caix17(c[17]);
    stringstream caix18(c[18]);
    stringstream caix19(c[19]);
    stringstream caix20(c[20]);
    stringstream caix21(c[21]);
    stringstream caix22(c[22]);
    stringstream caix23(c[23]);
    stringstream caix24(c[24]);
    stringstream caix25(c[25]);
    stringstream caix26(c[26]);
    stringstream caix27(c[27]);
    stringstream caix28(c[28]);
    stringstream caix29(c[29]);
    stringstream caix30(c[30]);
    stringstream caix31(c[31]);

    caix0 >> wp[0];
    caix1 >> wp[1];
    caix2 >> wp[2];
    caix3 >> wp[3];
    caix4 >> wp[4];
    caix5 >> wp[5];
    caix6 >> wp[6];
    caix7 >> wp[7];
    caix8 >> wp[8];
    caix9 >> wp[9];
    caix10 >> wp[10];
    caix11 >> wp[11];
    caix12 >> wp[12];
    caix13 >> wp[13];
    caix14 >> wp[14];
    caix15 >> wp[15];
    caix16 >> wp[16];
    caix17 >> wp[17];
    caix18 >> wp[18];
    caix19 >> wp[19];
    caix20 >> wp[20];
    caix21 >> wp[21];
    caix22 >> wp[22];
    caix23 >> wp[23];
    caix24 >> wp[24];
    caix25 >> wp[25];
    caix26 >> wp[26];
    caix27 >> wp[27];
    caix28 >> wp[28];
    caix29 >> wp[29];
    caix30 >> wp[30];
    caix31 >> wp[31];

    ZZ_pEX auxi(32,one);

    for(int i=0; i<32; i++) {
        ZZ_pEX aux(i,wp[i]);
        mod3232 += aux;
    }
}
예제 #18
0
/* require thread support.						*/

#undef HAVE_PUSH_REGS

#if defined(USE_ASM_PUSH_REGS)
#  define HAVE_PUSH_REGS
#else  /* No asm implementation */
void GC_push_regs()
{
#	if defined(M68K) && defined(AMIGA)
	 /*  AMIGA - could be replaced by generic code 			*/
	 /* a0, a1, d0 and d1 are caller save */

#        ifdef __GNUC__
	  asm("subq.w &0x4,%sp");	/* allocate word on top of stack */

	  asm("mov.l %a2,(%sp)"); asm("jsr _GC_push_one");
	  asm("mov.l %a3,(%sp)"); asm("jsr _GC_push_one");
	  asm("mov.l %a4,(%sp)"); asm("jsr _GC_push_one");
	  asm("mov.l %a5,(%sp)"); asm("jsr _GC_push_one");
	  asm("mov.l %a6,(%sp)"); asm("jsr _GC_push_one");
	  /* Skip frame pointer and stack pointer */
	  asm("mov.l %d2,(%sp)"); asm("jsr _GC_push_one");
	  asm("mov.l %d3,(%sp)"); asm("jsr _GC_push_one");
	  asm("mov.l %d4,(%sp)"); asm("jsr _GC_push_one");
	  asm("mov.l %d5,(%sp)"); asm("jsr _GC_push_one");
	  asm("mov.l %d6,(%sp)"); asm("jsr _GC_push_one");
	  asm("mov.l %d7,(%sp)"); asm("jsr _GC_push_one");

	  asm("addq.w &0x4,%sp");	/* put stack back where it was	*/
#	  define HAVE_PUSH_REGS
#        else /* !__GNUC__ */
	  GC_push_one(getreg(REG_A2));
	  GC_push_one(getreg(REG_A3));
#         ifndef __SASC
	      /* Can probably be changed to #if 0 -Kjetil M. (a4=globals)*/
	    GC_push_one(getreg(REG_A4));
#	  endif
	  GC_push_one(getreg(REG_A5));
	  GC_push_one(getreg(REG_A6));
	  /* Skip stack pointer */
	  GC_push_one(getreg(REG_D2));
	  GC_push_one(getreg(REG_D3));
	  GC_push_one(getreg(REG_D4));
	  GC_push_one(getreg(REG_D5));
	  GC_push_one(getreg(REG_D6));
	  GC_push_one(getreg(REG_D7));
#	  define HAVE_PUSH_REGS
#	 endif /* !__GNUC__ */
#       endif /* AMIGA */

#	if defined(M68K) && defined(MACOS)
#	if defined(THINK_C)
#         define PushMacReg(reg) \
              move.l  reg,(sp) \
              jsr             GC_push_one
	  asm {
              sub.w   #4,sp                   ; reserve space for one parameter.
              PushMacReg(a2);
              PushMacReg(a3);
              PushMacReg(a4);
              ; skip a5 (globals), a6 (frame pointer), and a7 (stack pointer)
              PushMacReg(d2);
              PushMacReg(d3);
              PushMacReg(d4);
              PushMacReg(d5);
              PushMacReg(d6);
              PushMacReg(d7);
              add.w   #4,sp                   ; fix stack.
	  }
#	  define HAVE_PUSH_REGS
#	  undef PushMacReg
#	endif /* THINK_C */
#	if defined(__MWERKS__)
	  PushMacRegisters();
#	  define HAVE_PUSH_REGS
#	endif	/* __MWERKS__ */
#   endif	/* MACOS */
}
예제 #19
0
파일: main.cpp 프로젝트: murak/BigInteger
int main() {
    /* test cases */

    /*
    * case 1: addition a>b and b>a and a=b 
    */
    BigInt a1("99");
    BigInt b1("9131");
    std::cout<<"\na = "<<a1.toString();
    std::cout<<"\nb = "<<b1.toString();
    std::cout<<"\nsum = "<<(a1+b1).toString();
    std::cout<<"\na-b = "<<(a1-b1).toString();

    BigInt a2("99");
    BigInt b2("91");
    std::cout<<"\na = "<<a2.toString();
    std::cout<<"\nb = "<<b2.toString();
    std::cout<<"\nsum = "<<(a2+b2).toString();
    std::cout<<"\nproduct = "<<(a2*b2).toString();
    std::cout<<"\na-b = "<<(a2-b2).toString();

    /*
    * case 2: a=b and one is negative
    */
    BigInt a3("-99");
    BigInt b3("91");
    std::cout<<"\na = "<<a3.toString();
    std::cout<<"\nb = "<<b3.toString();
    std::cout<<"\nsum = "<<(a3+b3).toString();
    std::cout<<"\nsum = "<<(b3+a3).toString();
    std::cout<<"\nproduct = "<<(b3*a3).toString();
    std::cout<<"\na-b = "<<(a3-b3).toString();

    /*
    * case 2: abs(a)>abs(b) and a is negative
    */
    BigInt a4("-999");
    BigInt b4("91");
    std::cout<<"\na = "<<a4.toString();
    std::cout<<"\nb = "<<b4.toString();
    std::cout<<"\nsum = "<<(a4+b4).toString();
    std::cout<<"\nsum = "<<(b4+a4).toString();
    std::cout<<"\nproduct = "<<(b4*a4).toString();
    std::cout<<"\na-b = "<<(a4-b4).toString();

    /*
    * case 3: abs(b)>abs(a) and b is negative
    */
    BigInt a5("99");
    BigInt b5("-991");
    std::cout<<"\na = "<<a5.toString();
    std::cout<<"\nb = "<<b5.toString();
    std::cout<<"\nsum = "<<(a5+b5).toString();
    std::cout<<"\nsum = "<<(b5+a5).toString();
    std::cout<<"\nproduct = "<<(b5*a5).toString();
    std::cout<<"\na-b = "<<(a5-b5).toString();

    /*
    * case 4: abs(b)>abs(a) and a,b is negative
    */
    BigInt a6("-99");
    BigInt b6("-991");
    std::cout<<"\na = "<<a6.toString();
    std::cout<<"\nb = "<<b6.toString();
    std::cout<<"\nsum = "<<(a6+b6).toString();
    std::cout<<"\nsum = "<<(b6+a6).toString();
    std::cout<<"\na-b = "<<(a6-b6).toString();

    /*
    * case 4: abs(b)=abs(a) and a,b is negative
    */
    BigInt a7("-999");
    BigInt b7("-991");
    std::cout<<"\na = "<<a7.toString();
    std::cout<<"\nb = "<<b7.toString();
    std::cout<<"\nsum = "<<(a7+b7).toString();
    std::cout<<"\nsum = "<<(b7+a7).toString();
    std::cout<<"\nproduct = "<<(b7*a7).toString();
    std::cout<<"\na-b = "<<(a7-b7).toString();

    /*
    * case 5: a-b
    */
    BigInt a8("-999");
    BigInt b8("-991");
    std::cout<<"\na = "<<a8.toString();
    std::cout<<"\nb = "<<b8.toString();
    std::cout<<"\na-b = "<<(a8-b8).toString();
    std::cout<<"\na-b = "<<(a8-b8).toString();



    BigInt fact("1");
    clock_t time = clock();
    fact = fact.factorial(1000);
    time = clock() - time;
    std::cout<<"\n\n10000 Factorial:\n"<<fact.toString()<<std::endl;
    std::cout<<"\n\ntime taken to find 1000! = "<<time/CLOCKS_PER_SEC<<" seconds";

    BigInt rd;
    rd = rd.random();
    std::cout<<"\n\n\nRandom number = "<<rd.toString()<<"\n\n";

    rd = rd.random();
    std::cout<<"\n\n\nRandom number = "<<rd.toString()<<"\n\n";

    rd = rd.random();
    std::cout<<"\n\n\nRandom number = "<<rd.toString()<<"\n\n";

    return 0;
}
예제 #20
0
void test()
{
      cout << " zDate Class Demo \n\n";

      // default constructor, Jan 1 0000
      zDate a;
      cout << a << endl;
      // Various versions of the constructors
      zDate x(zDate::oct,20,1962);
      cout << x << endl;
      // constructor with a julian
      zDate z( 2450000L );
      cout << z << endl;
      // make a date with system date (tests copy constructor)
      zDate s(zDate::Today());
      cout << s << endl;
      // init with the day of year
      zDate y(33, 1996);
      cout << y << endl;
      // init from current system time
      time_t secs_now = time(NULL);
      zDate n(localtime(&secs_now));
      cout << n << endl;

      // using date addition and subtraction
      zDate adder = x + 10;
      cout << adder << endl;
      adder = adder - 25;
      cout << adder << endl;

      //using subtraction of two date objects
      zDate a1(zDate::Today());
      zDate a2 = a1 + 14;
      cout << (a1 - a2) << endl;
      cout << (a2 += 10) << endl;

      a1++;
      cout << "Tommorrow= " << a1 << endl;

      a1 = zDate(zDate::jul, 14, 1991);
      cout << "a1 (7-14-91) < a2 (" << a2
             << ")? ==> " << ((a1 < a2) ? "TRUE" : "FALSE") << endl;
      cout << "a1 (7-14-91) > a2 ("<< a2
             << ")? ==> " << ((a1 > a2) ? "TRUE" : "FALSE") << endl;
      cout << "a1 (7-14-91) < 8-01-91 ? ==> "
             << ((a1 < zDate(zDate::aug, 1, 1991)) ? "TRUE" : "FALSE") << endl;
      cout << "a1 (7-14-91) > 8-01-91 ? ==> "
             << ((a1 > zDate(zDate::aug, 1, 1991)) ? "TRUE" : "FALSE") << endl;
      cout << "a1 (7-14-91) == 7-14-91 ? ==> "
             << ((a1==zDate(zDate::jul, 14, 1991)) ? "TRUE" : "FALSE") << endl;
      zDate a3 = a1;

      cout << "a1 (" << a1 << ") == a3 (" << a3
             << ") ? ==> " << ((a1==a3) ? "TRUE" : "FALSE") << endl;
      zDate a4 = a1;
      ++a4;
      cout << "a1 ("<< a1 <<") == a4 (" << a4
             << ") ? ==> " << ((a1==a4) ? "TRUE" : "FALSE") << endl;

      zDate a5(zDate::Today());
      cout << "Today is: " << a5 << endl;
      a4 = zDate::Today();
      cout << "Today (a4) is: " << a4 << endl;

      cout << "Today + 4 is: " << (a4 += 4) << endl;
      a4 = zDate::Today();
      cout << "Today - 4 is: " << (a4 -= 4) << endl;
      cout << "=========== Leap Year Test ===========\n";
      a1 = zDate(zDate::jan, 15, 1992);
      cout << a1 << "\t" << ((a1.IsLeapYear()) ? "Leap" : "non-Leap");
      cout << "\t" << "day of year:  " << a1.DayOfYear() << endl;

      a1 = zDate(zDate::feb, 16, 1993);
      cout << a1 << "\t" << ((a1.IsLeapYear()) ? "Leap" : "non-Leap");
      cout << "\t" << "day of year:  " << a1.DayOfYear() << endl;

      zDate v4(zDate::Today());
      cout << "---------- Add Stuff -----------\n";
      cout << "Start => " << v4 << endl;
      cout << "Add  4 Weeks  => " << v4.AddWeeks(4) << endl;
      cout << "Sub 52 Weeks  => " << v4.AddWeeks(-52)  << endl;
      cout << "Add  2 Years  => " << v4.AddYears(2)    << endl;

      cout << flush;

      cout << "---------- Misc Stuff -----------\n";
      cout << "The date aboves' day of the month is => " << v4.Day() << endl;
      cout << "There are " << v4.DaysInMonth() << " days in this month.\n";
      cout << "This day happens to be " << v4.DayOfWeek() << " day of week" << endl;
      cout << "on the " << v4.WeekOfYear() << " week of the year," << endl;
      cout << "on the " << v4.WeekOfMonth() << " week of the month, " << endl;
      cout << "which is the "<< (int)v4.Month() << "nth month in the year.\n";
      cout << "The year alone is " << v4.Year() << endl;
      cout << "And this is the " << v4.DayOfYear() << " day of year" << endl;
      cout << "of a year with " << v4.DaysInYear() << " days in it" << endl;
      cout << "which makes exatcly " << v4.WeeksInYear() << " weeks" << endl;

      zDate birthday(zDate::jul, 16, 1973);
      cout << "The age test: i was born on " << birthday
             << " which makes me " << v4.Age(birthday) << " years old" << endl;

      zDate       D2(zDate::jul, 4, 1776);
      int         I1 = 4;

      cout << "Before: I1 = " << I1 << ",  D2 = " << D2 << endl;
      cout << "---------- Postfix '++' test -----------\n";
      cout << "Test : I1++ = " << I1++ << ",  D2++ = " << D2++ << endl;
      cout << "After: I1   = " << I1 << ",  D2   = " << D2 << endl;

      cout << "---------- Prefix '++' test -----------\n";
      cout << "Test : ++I1 = " << ++I1 << ",  ++D2 = " << ++D2 << endl;
      cout << "After:   I1 = " << I1 << ",    D2 = " << D2 << endl;

      cout << "---------- Postfix '--' test -----------\n";
      cout << "Test : I1-- = " << I1-- << ",  D2-- = " << D2-- << endl;
      cout << "After: I1   = " << I1 << ",  D2   = " << D2 << endl;

      cout << "---------- Prefix '--' test -----------\n";
      cout << "Test : --I1 = " << --I1 << ",  --D2 = " << --D2 << endl;
      cout << "After:   I1 = " << I1 << ",    D2 = " << D2 << endl;

      cout << "Last day of this year is dayno "
             << zDate(zDate::dec, 31, 1996).DayOfYear() << endl;
      cout << "Last day of prev year is dayno "
             << zDate(zDate::dec, 31, 1995).DayOfYear() << endl;

      cout << "Today the moon is " << zDate::Today().MoonPhase() << endl;

      zDate today = zDate::Today();

      cout << "DST for " << today.Year() << " starts on " << today.BeginDST()
             << " and ends on " << today.EndDST() << endl;
      cout << "Today, " << today << ", DST is "
             << (today.IsDST() ? "" : "not") << "in effect" << endl;

      zDate date1(zDate::aug, 31, 1996);
      cout << "Adding 6 months to " << date1 << " results in "
             << date1.AddMonths(6) << endl;

      zDate date2(zDate::mar, 31, 1996);
      cout << "Subtracting 1 month from " << date2 << " results in "
             << date2.AddMonths(-1) << endl;

      zDate date3(zDate::jul, 4, 1776);
      cout << "Adding 2400 months to " << date3 << " results in "
             << date3.AddMonths(2400) << endl;

      cout << "Today's day number is " << zDate::Today().DayNumber() << endl;

      zDate date4(zDate::feb, 29, 1996);
      cout << date4 << " subtract two years = " << date4.AddYears(-2) << endl;

      cout << "In 1996, DST began on " << zDate::BeginDST(1996) << endl;

      zDate date5(zDate::sep, 26, 1996);
      cout << "Moon phase on " << date5 << " was " << date5.MoonPhase() << endl;

      zDate date6(zDate::oct, 3, 1996);
      cout << date6 << " + 55 days is " << (date6 + 55) << endl;

      zDate date7(zDate::oct, 4, 1996);
      cout << date7 << " + 217 days is ";
      date7 += 217;
      cout << date7 << endl;
      date7 = zDate(zDate::oct, 4, 1996);
      cout << "Same date - (-217) days is ";
      date7 -= -217;
      cout << date7 << endl;

      cout << "For 1996, Easter is on " << zDate::Easter(1996) << endl;
}
예제 #21
0
int main()
{
    Samoyed::Scheduler scheduler(8);

    AlarmDriver d1(scheduler, 1, 1, 1),
                d2(scheduler, 2, 2, 2),
                d3(scheduler, 3, 3, 3),
                d4(scheduler, 4, 4, 4),
                d5(scheduler, 5, 5, 5);
    boost::system_time t = boost::get_system_time();
    printf("Alarm 1 runs 10 times\n");
    d1.run(10, false);
    printf("Scheduler starts 3 threads\n");
    scheduler.size_controller().resize(3);
    printf("Alarm 2 runs 1 more time\n");
    d2.run(1, true);
    t += boost::posix_time::seconds(5);
    boost::thread::sleep(t);
    printf("Alarm 1 runs 1 time\n");
    d1.run(1, false);
    printf("Alarm 2 runs 2 more times\n");
    d2.run(2, true);
    printf("Alarm 3 runs 1 more time\n");
    d3.run(1, true);
    printf("Alarm 4 runs 7 more times\n");
    d4.run(7, true);
    printf("Alarm 5 runs 5 more times\n");
    d5.run(5, true);
    t += boost::posix_time::seconds(7);
    boost::thread::sleep(t);
    printf("Scheduler resizes to 2 threads\n");
    scheduler.size_controller().resize(2);
    printf("Alarm 1 runs 1 time\n");
    d1.run(1, false);
    printf("Alarm 2 runs 7 more times\n");
    d2.run(7, true);
    printf("Alarm 3 runs 11 more times\n");
    d3.run(11, true);
    printf("Alarm 4 runs 5 more times\n");
    d4.run(5, true);
    printf("Alarm 5 runs 7 times\n");
    d5.run(7, false);

    scheduler.wait();

    GMainContext *ctx = g_main_context_default();
    while (g_main_context_pending(ctx))
        g_main_context_iteration(ctx, TRUE);

    boost::shared_ptr<Alarm> a1(new Alarm(scheduler, 1, 1, 1, 1)),
                             a2(new Alarm(scheduler, 2, 2, 2, 2)),
                             a3(new Alarm(scheduler, 3, 3, 3, 3)),
                             a4(new Alarm(scheduler, 4, 4, 4, 4)),
                             a5(new Alarm(scheduler, 5, 5, 5, 5));
    a2->addDependency(a1);
    a3->addDependency(a1);
    a4->addDependency(a2);
    a4->addDependency(a3);
    a5->addDependency(a1);
    a5->addDependency(a2);
    a5->addDependency(a3);

    printf("Submit all\n");
    a5->submit(a5);
    a4->submit(a4);
    a3->submit(a3);
    a2->submit(a2);
    a1->submit(a1);

    a1.reset();
    a2.reset();
    a3.reset();
    a4.reset();

    t = boost::get_system_time() + boost::posix_time::seconds(5);
    boost::thread::sleep(t);
    printf("Cancel alarm 5\n");
    a5->cancel(a5);
    a5.reset();

    scheduler.wait();

    while (g_main_context_pending(ctx))
        g_main_context_iteration(ctx, TRUE);
    return 0;
}
예제 #22
0
void drive_operation()
{

    // Uint64 tests

    CQLValue a1(Uint64(10));
    CQLValue a2(Uint64(15));
    CQLValue a3(Uint64(25));
    CQLValue a4(Uint64(30));
    CQLValue a5(Uint64(150));

    PEGASUS_TEST_ASSERT(a1 != a2);
    PEGASUS_TEST_ASSERT(a5 == a5);
    PEGASUS_TEST_ASSERT(a1 < a2);
    PEGASUS_TEST_ASSERT(a2 >= a1);
    PEGASUS_TEST_ASSERT(a1 <= a2);
    PEGASUS_TEST_ASSERT(a2 > a1);

    // Sint64 tests

    CQLValue b1(Sint64(10));
    CQLValue b2(Sint64(15));
    CQLValue b3(Sint64(25));
    CQLValue b4(Sint64(30));
    CQLValue b5(Sint64(150));

    PEGASUS_TEST_ASSERT(b1 != b2);
    PEGASUS_TEST_ASSERT(b5 == b5);
    PEGASUS_TEST_ASSERT(b1 < b2);
    PEGASUS_TEST_ASSERT(b2 >= b1);
    PEGASUS_TEST_ASSERT(b1 <= b2);
    PEGASUS_TEST_ASSERT(b2 > b1);

    // Real64 tests

    CQLValue c1(Real64(10.00));
    CQLValue c2(Real64(15.00));
    CQLValue c3(Real64(25.00));
    CQLValue c4(Real64(30.00));
    CQLValue c5(Real64(150.00));

    PEGASUS_TEST_ASSERT(c1 != c2);
    PEGASUS_TEST_ASSERT(c5 == c5);
    PEGASUS_TEST_ASSERT(c1 < c2);
    PEGASUS_TEST_ASSERT(c2 >= c1);
    PEGASUS_TEST_ASSERT(c1 <= c2);
    PEGASUS_TEST_ASSERT(c2 > c1);

    // Misc
    PEGASUS_TEST_ASSERT(a1 == b1);
    PEGASUS_TEST_ASSERT(a1 == c1);
    PEGASUS_TEST_ASSERT(b1 == a1);
    PEGASUS_TEST_ASSERT(b1 == c1);
    PEGASUS_TEST_ASSERT(c1 == a1);
    PEGASUS_TEST_ASSERT(c1 == b1);

    PEGASUS_TEST_ASSERT(a2 != b1);
    PEGASUS_TEST_ASSERT(a2 != c1);
    PEGASUS_TEST_ASSERT(b2 != a1);
    PEGASUS_TEST_ASSERT(b2 != c1);
    PEGASUS_TEST_ASSERT(c2 != a1);
    PEGASUS_TEST_ASSERT(c2 != b1);

    PEGASUS_TEST_ASSERT(a2 >= b1);
    PEGASUS_TEST_ASSERT(a2 >= c1);
    PEGASUS_TEST_ASSERT(b2 >= a1);
    PEGASUS_TEST_ASSERT(b2 >= c1);
    PEGASUS_TEST_ASSERT(c2 >= a1);
    PEGASUS_TEST_ASSERT(c2 >= b1);

    PEGASUS_TEST_ASSERT(a2 <= b3);
    PEGASUS_TEST_ASSERT(a2 <= c3);
    PEGASUS_TEST_ASSERT(b2 <= a3);
    PEGASUS_TEST_ASSERT(b2 <= c3);
    PEGASUS_TEST_ASSERT(c2 <= a3);
    PEGASUS_TEST_ASSERT(c2 <= b3);

    PEGASUS_TEST_ASSERT(a2 > b1);
    PEGASUS_TEST_ASSERT(a2 > c1);
    PEGASUS_TEST_ASSERT(b2 > a1);
    PEGASUS_TEST_ASSERT(b2 > c1);
    PEGASUS_TEST_ASSERT(c2 > a1);
    PEGASUS_TEST_ASSERT(c2 > b1);

    PEGASUS_TEST_ASSERT(a2 < b3);
    PEGASUS_TEST_ASSERT(a2 < c3);
    PEGASUS_TEST_ASSERT(b2 < a3);
    PEGASUS_TEST_ASSERT(b2 < c3);
    PEGASUS_TEST_ASSERT(c2 < a3);
    PEGASUS_TEST_ASSERT(c2 < b3);

    //Overflow testing
    CQLValue real1(Real64(0.00000001));
    CQLValue sint1(Sint64(-1));
    CQLValue uint1(Sint64(1));
    CQLValue uint2(Uint64(0));

    PEGASUS_TEST_ASSERT(uint1 > sint1);
    PEGASUS_TEST_ASSERT(real1 > sint1);
    PEGASUS_TEST_ASSERT(uint2 > sint1);
    PEGASUS_TEST_ASSERT(real1 > uint2);

    CQLValue real2(Real64(25.00000000000001));
    CQLValue real3(Real64(24.99999999999999));
    CQLValue sint2(Sint64(25));
    CQLValue uint3(Uint64(25));

    PEGASUS_TEST_ASSERT(real2 > real3);
    PEGASUS_TEST_ASSERT(real2 > sint2);
    PEGASUS_TEST_ASSERT(real2 > uint3);
    PEGASUS_TEST_ASSERT(real3 < sint2);
    PEGASUS_TEST_ASSERT(real3 < uint3);

    // String tests

    CQLValue d1(String("HELLO"));
    CQLValue d2(String("HEL"));
    CQLValue d3(String("LO"));
    CQLValue d4(String("AHELLO"));
    CQLValue d5(String("ZHELLO"));

    PEGASUS_TEST_ASSERT(d1 == d2 + d3);
    PEGASUS_TEST_ASSERT(d1 != d2 + d4);

    PEGASUS_TEST_ASSERT(d1 <= d5);
    PEGASUS_TEST_ASSERT(d1 <  d5);

    PEGASUS_TEST_ASSERT(d1 >= d4);
    PEGASUS_TEST_ASSERT(d1 >  d4);

    String str1("0x10");
    String str2("10");
    String str3("10B");
    String str4("10.10");


    CQLValue e1( str1, CQLValue::Hex);
    CQLValue e2( str2, CQLValue::Decimal);
    CQLValue e3( str3, CQLValue::Binary);
    CQLValue e4( str4, CQLValue::Real);

    CQLValue e5(Uint64(16));
    CQLValue e6(Uint64(10));
    CQLValue e7(Uint64(2));
    CQLValue e8(Real64(10.10));

    PEGASUS_TEST_ASSERT(e1 == e5);
    PEGASUS_TEST_ASSERT(e2 == e6);
    PEGASUS_TEST_ASSERT(e3 == e7);
    PEGASUS_TEST_ASSERT(e4 == e8);

    Array<Uint64> array1;

    array1.append(1);
    array1.append(2);
    array1.append(3);
    array1.append(4);
    array1.append(5);
    array1.append(6);
    array1.append(7);
    array1.append(8);
    array1.append(9);
    array1.append(10);

    Array<Sint64> array2;

    array2.append(1);
    array2.append(2);
    array2.append(3);
    array2.append(4);
    array2.append(5);
    array2.append(6);
    array2.append(7);
    array2.append(8);
    array2.append(9);
    array2.append(10);
    array2.append(3);

    Array<Real64> array3;

    array3.append(1.00);
    array3.append(2.00);
    array3.append(3.00);
    array3.append(9.00);
    array3.append(10.00);
    array3.append(3.00);
    array3.append(4.00);
    array3.append(5.00);
    array3.append(6.00);
    array3.append(7.00);
    array3.append(8.00);

    Array<Uint64> array4;

    array4.append(1);
    array4.append(23);
    array4.append(3);
    array4.append(4);
    array4.append(5);
    array4.append(6);
    array4.append(7);
    array4.append(88);
    array4.append(9);
    array4.append(10);

    Array<Sint64> array5;

    array5.append(-1);
    array5.append(2);
    array5.append(3);
    array5.append(4);
    array5.append(5);
    array5.append(-6);
    array5.append(7);
    array5.append(8);
    array5.append(9);
    array5.append(10);
    array5.append(-3);

    Array<Real64> array6;

    array6.append(1.23);
    array6.append(2.00);
    array6.append(3.00);
    array6.append(9.00);
    array6.append(10.00);
    array6.append(3.00);
    array6.append(4.14);
    array6.append(5.00);
    array6.append(6.00);
    array6.append(7.00);
    array6.append(8.00);

    CIMValue cv1(array1);
    CIMValue cv2(array2);
    CIMValue cv3(array3);
    CIMValue cv4(array4);
    CIMValue cv5(array5);
    CIMValue cv6(array6);

    CQLValue vr1(cv1);
    CQLValue vr2(cv1);
    CQLValue vr3(cv2);
    CQLValue vr4(cv3);
    CQLValue vr5(cv4);
    CQLValue vr6(cv5);
    CQLValue vr7(cv6);

    PEGASUS_TEST_ASSERT(vr1 == vr2);
    PEGASUS_TEST_ASSERT(vr1 == vr3);
    PEGASUS_TEST_ASSERT(vr1 == vr4);
    PEGASUS_TEST_ASSERT(vr4 == vr3);

    PEGASUS_TEST_ASSERT(vr1 != vr5);
    PEGASUS_TEST_ASSERT(vr3 != vr6);
    PEGASUS_TEST_ASSERT(vr4 != vr7);

    const CIMName _cimName(String("CIM_OperatingSystem"));

    CIMInstance _i1(_cimName);
    CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules")));
    CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2)));
    CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
    CIMProperty _p4(CIMName("TimeOfLastStateChange"),
                    CIMValue(CIMDateTime(String("20040811105625.000000-360"))));

    _i1.addProperty(_p1);
    _i1.addProperty(_p2);
    _i1.addProperty(_p3);
    _i1.addProperty(_p4);

    CIMInstance _i2(_cimName);
    CIMProperty _p5(CIMName("Description"),
                    CIMValue(String("Dave Rules Everything")));
    CIMProperty _p6(CIMName("EnabledState"),CIMValue(Uint16(2)));
    CIMProperty _p7(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
    CIMProperty _p8(CIMName("TimeOfLastStateChange"),
                    CIMValue(CIMDateTime(String("20040811105625.000000-360"))));

    _i2.addProperty(_p5);
    _i2.addProperty(_p6);
    _i2.addProperty(_p7);
    _i2.addProperty(_p8);

    CQLValue cql1(_i1);
    CQLValue cql2(_i1);
    CQLValue cql3(_i2);
    CQLValue cql4(_i2);

    //PEGASUS_TEST_ASSERT(cql1 == cql1);

    return;
}
예제 #23
0
void drive_resolve_specialChars()
{


    const char* env = getenv("PEGASUS_HOME");
    String repositoryDir(env);
    repositoryDir.append("/repository");
    //String repositoryDir("c:/pegasus-cvs/pegasus/repository");
    CIMNamespaceName _ns("root/cimv2");
    CIMRepository *_rep = new CIMRepository(repositoryDir);
    RepositoryQueryContext _query(_ns, _rep);
    RepositoryQueryContext _query1(_ns, _rep);
    try {
        const CQLIdentifier _Id1(String("CIM_OperatingSystem"));

        _query.insertClassPath(_Id1);

        const CIMName _cimName(String("CIM_OperatingSystem"));

        CIMInstance _i1(_cimName);
        CIMProperty _p1(CIMName("OSType"),CIMValue(Uint16(11)));
        CIMProperty _p2(CIMName("Status"),CIMValue(String("Degraded")));
        Array<Uint16> array16;
        array16.append(Uint16(0));
        array16.append(Uint16(1));
        array16.append(Uint16(2));
        array16.append(Uint16(3));
        CIMProperty _p3(CIMName("OperationalStatus"),CIMValue(array16));

        _i1.addProperty(_p1);
        _i1.addProperty(_p2);
        _i1.addProperty(_p3);

        CQLChainedIdentifier ci1(String("CIM_OperatingSystem.OSType#OS400"));
        CQLChainedIdentifier ci2(String("CIM_OperatingSystem.OSType#LINUX"));
        CQLChainedIdentifier ci3(String("CIM_OperatingSystem.Status#Degraded"));

        CQLChainedIdentifier ci5(String("CIM_OperatingSystem.Status#BOGUS"));

        CQLChainedIdentifier ci6(
            String("CIM_OperatingSystem.CIM_OperatingSystem::"
                   "OperationalStatus[2]"));
        CQLValue a1(ci1);
        CQLValue a2(ci2);
        CQLValue a3(ci3);

        CQLValue a5(ci5);
        CQLValue a6(ci6);


        a1.resolve(_i1, _query);
        a2.resolve(_i1, _query);

        a6.resolve(_i1, _query);

        try
        {
            a3.resolve(_i1, _query);
            PEGASUS_TEST_ASSERT(0);
        }
        catch(...)
        {
            PEGASUS_TEST_ASSERT(1);
        }

        try
        {
            a5.resolve(_i1, _query);
            PEGASUS_TEST_ASSERT(0);
        }
        catch(...)
        {
            PEGASUS_TEST_ASSERT(1);
        }

        PEGASUS_TEST_ASSERT(a1 == CQLValue(Uint64(11)));
        PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(36)));


        PEGASUS_TEST_ASSERT(a6 == CQLValue(Uint64(2)));


    }
    catch(Exception & e)
    {
        cout << e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(0);
    }
    delete _rep;
    return;
}
예제 #24
0
void drive_resolve_primitive()
{


    const char* env = getenv("PEGASUS_HOME");
    String repositoryDir(env);
    repositoryDir.append("/repository");
    //String repositoryDir("c:/pegasus-cvs/pegasus/repository");
    CIMNamespaceName _ns("root/cimv2");
    CIMRepository *_rep = new CIMRepository(repositoryDir);
    RepositoryQueryContext _query(_ns, _rep);
    RepositoryQueryContext _query1(_ns, _rep);
    try {
        const CQLIdentifier _Id1(String("CIM_OperatingSystem"));

        _query.insertClassPath(_Id1);

        const CIMName _cimName(String("CIM_OperatingSystem"));

        CIMInstance _i1(_cimName);
        CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules")));
        CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2)));
        CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
        CIMProperty _p4(CIMName("TimeOfLastStateChange"),
                        CIMValue(CIMDateTime(String("20040811105625.000000-360"))));

        _i1.addProperty(_p1);
        _i1.addProperty(_p2);
        _i1.addProperty(_p3);
        _i1.addProperty(_p4);

        CQLChainedIdentifier ci1(
            String("CIM_OperatingSystem.CIM_OperatingSystem::Description"));
        CQLChainedIdentifier
        ci2(String("CIM_OperatingSystem.CIM_OperatingSystem::EnabledState"));
        CQLChainedIdentifier ci3(
            String("CIM_OperatingSystem.CIM_OperatingSystem::CurrentTimeZone"));
        CQLChainedIdentifier ci4(
            String("CIM_OperatingSystem.CIM_OperatingSystem::TimeOfLastStateChange"));

        CQLChainedIdentifier
        ci5(String(
                "CIM_OperatingSystem.CIM_EnabledLogicalElement::TimeOfLastStateChange"));

        CQLChainedIdentifier
        ci7(String("CIM_OperatingSystem"));

        CQLChainedIdentifier
        ci9(String(
                "CIM_EnabledLogicalElement.CIM_OperatingSystem::CSCreationClassName"));

        CQLChainedIdentifier
        ci10(String("CIM_OperatingSystem.CIM_OperatingSystem::Bubba"));

        CQLValue a1(ci1);
        CQLValue a2(ci2);
        CQLValue a3(ci3);
        CQLValue a4(ci4);
        CQLValue a5(ci5);

        CQLValue a7(ci7);

        CQLValue a9(ci9);
        CQLValue a10(ci10);

        CQLValue a11(_query.getClass(CIMName("CIM_OperatingSystem")));

        a1.resolve(_i1, _query);
        a2.resolve(_i1, _query);
        a3.resolve(_i1, _query);
        a4.resolve(_i1, _query);
        a5.resolve(_i1, _query);
        a7.resolve(_i1, _query);
        a10.resolve(_i1, _query1);

        a9.resolve(_i1, _query);

        PEGASUS_TEST_ASSERT(a1 == CQLValue(String("Dave Rules")));
        PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(2)));
        PEGASUS_TEST_ASSERT(a3 == CQLValue(Sint64(-600)));
        PEGASUS_TEST_ASSERT(a4 == CQLValue(
                                CIMDateTime(String("20040811105625.000000-360"))));
        PEGASUS_TEST_ASSERT(a5 == CQLValue(
                                CIMDateTime(String("20040811105625.000000-360"))));
        //PEGASUS_TEST_ASSERT(a7 == CQLValue(_i1));
        PEGASUS_TEST_ASSERT(a9.isNull());
        PEGASUS_TEST_ASSERT(a10.isNull());

    }
    catch(Exception & e)
    {
        cout << e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(0);
    }
    delete _rep;
    return;
}
예제 #25
0
void TestSymBandDiv_B2(tmv::DivType dt, PosDefCode pdc)
{
    const int N = 10;

    std::vector<tmv::SymBandMatrixView<T> > sb;
    std::vector<tmv::SymBandMatrixView<std::complex<T> > > csb;
    MakeSymBandList(sb,csb,pdc);

    tmv::Matrix<T> a1(N,N);
    for (int i=0; i<N; ++i) for (int j=0; j<N; ++j) a1(i,j) = T(1-3*i+j);
    a1.diag().addToAll(T(10)*N);
    a1 /= T(10);
    tmv::Matrix<std::complex<T> > ca1 = a1 * std::complex<T>(3,-4);
    a1.diag().addToAll(T(10)*N);
    ca1.diag().addToAll(T(10)*N);

    tmv::MatrixView<T> a1v = a1.view();
    tmv::MatrixView<std::complex<T> > ca1v = ca1.view();

#if (XTEST & 2)
    tmv::Matrix<T> a3 = a1.colRange(0,N/2);
    tmv::Matrix<std::complex<T> > ca3 = ca1.colRange(0,N/2);
    tmv::Matrix<T> a4 = a1.rowRange(0,N/2);
    tmv::Matrix<std::complex<T> > ca4 = ca1.rowRange(0,N/2);
    tmv::Matrix<T> a5(2*N,N);
    a5.rowRange(0,N) = a1;
    a5.rowRange(N,2*N) = a1;
    tmv::Matrix<std::complex<T> > ca5(2*N,N);
    ca5.rowRange(0,N) = ca1;
    ca5.rowRange(N,2*N) = ca1;
    tmv::Matrix<T> a6 = a5.transpose();
    tmv::Matrix<std::complex<T> > ca6 = ca5.transpose();

    tmv::MatrixView<T> a3v = a3.view();
    tmv::MatrixView<T> a4v = a4.view();
    tmv::MatrixView<T> a5v = a5.view();
    tmv::MatrixView<T> a6v = a6.view();
    tmv::MatrixView<std::complex<T> > ca3v = ca3.view();
    tmv::MatrixView<std::complex<T> > ca4v = ca4.view();
    tmv::MatrixView<std::complex<T> > ca5v = ca5.view();
    tmv::MatrixView<std::complex<T> > ca6v = ca6.view();
#endif

    for(size_t i=START;i<sb.size();i++) {
        if (showstartdone)
            std::cout<<"Start loop: i = "<<i<<", si = "<<tmv::TMV_Text(sb[i])<<
                "  "<<sb[i]<<std::endl;
        tmv::SymBandMatrixView<T> si = sb[i];
        tmv::SymBandMatrixView<std::complex<T> > csi = csb[i];
        si.saveDiv();
        csi.saveDiv();

        TestMatrixDivArith1(dt,a1v,si,ca1v,csi,"SymBand/SquareMatrix");
        if (dt == tmv::LU) continue;
#if (XTEST & 2)
        TestMatrixDivArith1(dt,a3v,si,ca3v,csi,"SymBand/NonSquareMatrix");
        TestMatrixDivArith1(dt,a4v,si,ca4v,csi,"SymBand/NonSquareMatrix");
        TestMatrixDivArith1(dt,a5v,si,ca5v,csi,"SymBand/NonSquareMatrix");
        TestMatrixDivArith1(dt,a6v,si,ca6v,csi,"SymBand/NonSquareMatrix");
#endif
    }
}
예제 #26
0
void level_two()
{
		vector<DPipe> DPIPES(44);
	vector<DoublePipe> DOUBPIPES(18);
	vector<CrossPipe> CROSSPIPES(3);

	DPipe background(600,400,1200,800);

	DPipe a0(50,750,100,40);
	DPipe a1(150,650,100,40);
	DPipe a2(150,550,100,40);
	DPipe a3(650,450,100,40);
	DPipe a4(550,550,100,40);
	DPipe a5(450,350,100,40);
	DPipe a6(550,250,100,40);
	DPipe a7(650,250,100,40);
	DPipe a8(750,350,100,40);
	DPipe a9(750,450,100,40);
	DPipe a10(750,550,100,40);
	DPipe a11(650,650,100,40);
	DPipe a12(550,650,100,40);
	DPipe a13(450,650,100,40);
	DPipe a14(350,550,100,40);
	DPipe a15(350,350,100,40);
	DPipe a16(350,250,100,40);
	DPipe a17(450,150,100,40);
	DPipe a18(550,150,100,40);
	DPipe a19(650,150,100,40);
	DPipe a20(750,150,100,40);
	DPipe a21(850,250,100,40);
	DPipe a22(850,350,100,40);
	DPipe a23(850,450,100,40);
	DPipe a24(850,550,100,40);
	DPipe a25(850,650,100,40);
	DPipe a26(750,750,100,40);
	DPipe a27(650,750,100,40);
	DPipe a28(550,750,100,40);
	DPipe a29(450,750,100,40);
	DPipe a30(350,750,100,40);
	DPipe a31(250,650,100,40);
	DPipe a32(250,550,100,40);
	DPipe a33(250,350,100,40);
	DPipe a34(250,250,100,40);
	DPipe a35(250,150,100,40);
	DPipe a36(350,50,100,40);
	DPipe a37(450,50,100,40);
	DPipe a38(550,50,100,40);
	DPipe a39(650,50,100,40);
	DPipe a40(750,50,100,40);
	DPipe a41(850,50,100,40);
	DPipe a42(950,150,100,40);
	DPipe a43(950,250,100,40);

	DoublePipe b0(150,750,70,40);
	DoublePipe b1(150,450,70,40);
	DoublePipe b2(550,450,70,40);
	DoublePipe b3(550,350,70,40);
	DoublePipe b4(650,350,70,40);
	DoublePipe b5(650,550,70,40);
	DoublePipe b6(450,550,70,40);
	DoublePipe b7(450,250,70,40);
	DoublePipe b8(750,250,70,40);
	DoublePipe b9(750,650,70,40);
	DoublePipe b10(350,650,70,40);
	DoublePipe b11(350,150,70,40);
	DoublePipe b12(850,150,70,40);
	DoublePipe b13(850,750,70,40);
	DoublePipe b14(250,750,70,40);
	DoublePipe b15(250,50,70,40);
	DoublePipe b16(950,50,70,40);
	DoublePipe b17(950,350,70,40);

	CrossPipe c0(250,450,100,40);
	CrossPipe c1(350,450,100,40);
	CrossPipe c2(450,450,100,40);

	DPIPES[0]=a0;
	DPIPES[1]=a1;
	DPIPES[2]=a2;
	DPIPES[3]=a3;
	DPIPES[4]=a4;
	DPIPES[5]=a5;
	DPIPES[6]=a6;
	DPIPES[7]=a7;
	DPIPES[8]=a8;
	DPIPES[9]=a9;
	DPIPES[10]=a10;
	DPIPES[11]=a11;
	DPIPES[12]=a12;
	DPIPES[13]=a13;
	DPIPES[14]=a14;
	DPIPES[15]=a15;
	DPIPES[16]=a16;
	DPIPES[17]=a17;
	DPIPES[18]=a18;
	DPIPES[19]=a19;
	DPIPES[20]=a20;
	DPIPES[21]=a21;
	DPIPES[22]=a22;
	DPIPES[23]=a23;
	DPIPES[24]=a24;
	DPIPES[25]=a25;
	DPIPES[26]=a26;
	DPIPES[27]=a27;
	DPIPES[28]=a28;
	DPIPES[29]=a29;
	DPIPES[30]=a30;
	DPIPES[31]=a31;
	DPIPES[32]=a32;
	DPIPES[33]=a33;
	DPIPES[34]=a34;
	DPIPES[35]=a35;
	DPIPES[36]=a36;
	DPIPES[37]=a37;
	DPIPES[38]=a38;
	DPIPES[39]=a39;
	DPIPES[40]=a40;
	DPIPES[41]=a41;
	DPIPES[42]=a42;
	DPIPES[43]=a43;

	DOUBPIPES[0]=b0;
	DOUBPIPES[1]=b1;
	DOUBPIPES[2]=b2;
	DOUBPIPES[3]=b3;
	DOUBPIPES[4]=b4;
	DOUBPIPES[5]=b5;
	DOUBPIPES[6]=b6;
	DOUBPIPES[7]=b7;
	DOUBPIPES[8]=b8;
	DOUBPIPES[9]=b9;
	DOUBPIPES[10]=b10;
	DOUBPIPES[11]=b11;
	DOUBPIPES[12]=b12;
	DOUBPIPES[13]=b13;
	DOUBPIPES[14]=b14;
	DOUBPIPES[15]=b15;
	DOUBPIPES[16]=b16;
	DOUBPIPES[17]=b17;

	CROSSPIPES[0]=c0;
	CROSSPIPES[1]=c1;
	CROSSPIPES[2]=c2;
}
예제 #27
0
파일: main.cpp 프로젝트: meh2481/Siftrinth
void main()
{
	//Create our audio channels
	AudioChannel a1(0);
	AudioChannel a2(1);
	AudioChannel a3(2);
	AudioChannel a4(3);
	AudioChannel a5(4);
	AudioChannel a6(5);
	channels[0] = &a1;
	channels[1] = &a2;
	channels[2] = &a3;
	channels[3] = &a4;
	channels[4] = &a5;
	channels[5] = &a6;
	r.seed();
	
	channels[BALL_ROLL_CHANNEL]->play(sRollLoop, REPEAT);	//Start playing rolling marble noise
	channels[BALL_ROLL_CHANNEL]->setVolume(0);
	for(int i = 0; i < NUM_CUBES; i++)
		g_starsCollected[i] = 0;
	for(int i = 0; i < NUM_COLORS; i++)
		g_bColorsUsed[i] = false;
	g_iBoardReset = -1;
	g_iScore = -1;
    TimeStep ts;
	float fTapPromptDelay = 0.0;
	int iBoardDied;

	//Initialize our boards
	for(int i = 0; i < NUM_CUBES; i++)
		boards[i].init(i);
	Events::neighborAdd.set(onNeighborAdd);	//Function for when two cubes touch each other
	Events::cubeTouch.set(onTouch);			//Function for when a cube is tapped
	
	//Add the marble to one of them
	Float2 fVel;
	fVel.set(0,0);
	Float2 fPos = LCD_center;
	fPos.x += TILE_WIDTH/2.0;
	fPos.y += TILE_HEIGHT/2.0;
	boards[0].addMarble(fPos, fVel);
	
	TextDraw td;
	bool bFirstSound = true;
	
	//Main loop
    while (1) 
	{
        ts.next();
		for(int i = 0; i < NUM_CUBES; i++)
		{
			int iMode;
			switch(g_iCurMode)
			{
				case BOARD_NOTHING:
					iMode = boards[i].update(float(ts.delta()));
					//Update our rolling sound to the right volume
					if(boards[i].hasMarble())
					{
						float fVol = boards[i].getMarbleVelocity() * 0.9;
						if(fVol > MAX_VOLUME)
							fVol = MAX_VOLUME;
						channels[BALL_ROLL_CHANNEL]->setVolume(fVol);
					}
					if(iMode & BOARD_GOTPOINT)
					{
						iMode ^= BOARD_GOTPOINT;
						g_iScore++;
						if(++g_starsCollected[i] == NUM_STARS_CUBE)
							g_iBoardReset = i;
						//Play sound for getting a star, but not right on reset
						if(bFirstSound)
							bFirstSound = false;
						else
							channels[BALL_SFX_CHANNEL]->play(sGetStar);
					}
					if(iMode & BOARD_DIED)
					{
						//Show game over screen
						iMode ^= BOARD_DIED;
						iMode |= MODE_GAMEOVER;
						td.draw(boards[i].getVid(), "Game over", 6);
						String<64> s;
						s << "Score: " << g_iScore;
						td.draw(boards[i].getVid(), s.c_str(), 8);
						fTapPromptDelay = 0.0;
						iBoardDied = i;
						bFirstSound = true;
						channels[BALL_ROLL_CHANNEL]->setVolume(0);
						channels[BALL_SFX_CHANNEL]->play(sDie);
					}
					if(iMode & BOARD_LEFT)
					{
						iMode ^= BOARD_LEFT;
						if(g_iBoardReset == i)
						{
							boards[i].reset(g_bColorsUsed);
							g_starsCollected[i] = 0;
							g_iBoardReset = -1;
							g_iScore += 3;	//Three points for clearing board
							//Play sound effect for clearing board
							channels[BOARD_SFX_CHANNEL]->play(sBoardClear);
						}
						//Play pass-through-portal sound
						else if(!channels[PORTAL_CHANNEL]->isPlaying())
							channels[PORTAL_CHANNEL]->play(sThroughPortal);
					}
					if(iMode & BOARD_WAITPORTAL)
					{
						//Play sound effect for entering a portal
						channels[PORTAL_CHANNEL]->play(sPortalEnter);
						channels[BALL_ROLL_CHANNEL]->setVolume(0);
					}
					g_iCurMode = iMode;
					break;
				case BOARD_WAITPORTAL:
					boards[i].waitPortal(float(ts.delta()));
					channels[BALL_ROLL_CHANNEL]->setVolume(0);
					break;
				case MODE_GAMEOVER:
					fTapPromptDelay += float(ts.delta()) / 3.0;
					if(fTapPromptDelay >= TAP_PROMPT_DELAY && fTapPromptDelay < 100.0)
					{
						fTapPromptDelay = 100;
						td.draw(boards[iBoardDied].getVid(), "Tap to restart", 14);
					}
					channels[BALL_ROLL_CHANNEL]->setVolume(0);
			}
		}
		
        System::paint();
    }
}
예제 #28
0
void unordered_test(X&, Key& k, T& t, Hash& hf, Pred& eq)
{
    typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
    typedef BOOST_DEDUCED_TYPENAME X::hasher hasher;
    typedef BOOST_DEDUCED_TYPENAME X::key_equal key_equal;
    typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;

    typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
    typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
    typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator;
    typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;

    typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<iterator>::type iterator_category;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<iterator>::type iterator_difference;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<iterator>::type iterator_pointer;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<iterator>::type iterator_reference;

    typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<local_iterator>::type local_iterator_category;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<local_iterator>::type local_iterator_difference;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<local_iterator>::type local_iterator_pointer;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<local_iterator>::type local_iterator_reference;

    typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<const_iterator>::type const_iterator_category;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<const_iterator>::type const_iterator_difference;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_iterator>::type const_iterator_pointer;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<const_iterator>::type const_iterator_reference;

    typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<const_local_iterator>::type const_local_iterator_category;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<const_local_iterator>::type const_local_iterator_difference;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_local_iterator>::type const_local_iterator_pointer;
    typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<const_local_iterator>::type const_local_iterator_reference;

    BOOST_MPL_ASSERT((boost::is_same<Key, key_type>));
    boost::function_requires<boost::CopyConstructibleConcept<key_type> >();
    boost::function_requires<boost::AssignableConcept<key_type> >();

    BOOST_MPL_ASSERT((boost::is_same<Hash, hasher>));
    test::check_return_type<std::size_t>::equals(hf(k));

    BOOST_MPL_ASSERT((boost::is_same<Pred, key_equal>));
    test::check_return_type<bool>::convertible(eq(k, k));

    boost::function_requires<boost::InputIteratorConcept<local_iterator> >();
    BOOST_MPL_ASSERT((boost::is_same<local_iterator_category, iterator_category>));
    BOOST_MPL_ASSERT((boost::is_same<local_iterator_difference, iterator_difference>));
    BOOST_MPL_ASSERT((boost::is_same<local_iterator_pointer, iterator_pointer>));
    BOOST_MPL_ASSERT((boost::is_same<local_iterator_reference, iterator_reference>));

    boost::function_requires<boost::InputIteratorConcept<const_local_iterator> >();
    BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_category, const_iterator_category>));
    BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_difference, const_iterator_difference>));
    BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_pointer, const_iterator_pointer>));
    BOOST_MPL_ASSERT((boost::is_same<const_local_iterator_reference, const_iterator_reference>));

    X(10, hf, eq);
    X a(10, hf, eq);
    X(10, hf);
    X a2(10, hf);
    X(10);
    X a3(10);
    X();
    X a4;

    BOOST_DEDUCED_TYPENAME X::value_type* i = 0;
    BOOST_DEDUCED_TYPENAME X::value_type* j = 0;

    X(i, j, 10, hf, eq);
    X a5(i, j, 10, hf, eq);
    X(i, j, 10, hf);
    X a6(i, j, 10, hf);
    X(i, j, 10);
    X a7(i, j, 10);
    X(i, j);
    X a8(i, j);

    X const b;
    sink(X(b));
    X a9(b);
    a = b;

    test::check_return_type<hasher>::equals(b.hash_function());
    test::check_return_type<key_equal>::equals(b.key_eq());

    const_iterator q = a.cbegin();
    test::check_return_type<iterator>::equals(a.insert(q, t));
    test::check_return_type<iterator>::equals(a.emplace_hint(q, t));

    a.insert(i, j);
    test::check_return_type<size_type>::equals(a.erase(k));

    BOOST_TEST(a.empty());
    if(a.empty()) {
        a.insert(t);
        q = a.cbegin();
        test::check_return_type<iterator>::equals(a.erase(q));
    }

    const_iterator q1 = a.cbegin(), q2 = a.cend();
    test::check_return_type<iterator>::equals(a.erase(q1, q2));

    a.clear();

    test::check_return_type<iterator>::equals(a.find(k));
    test::check_return_type<const_iterator>::equals(b.find(k));
    test::check_return_type<size_type>::equals(b.count(k));
    test::check_return_type<std::pair<iterator, iterator> >::equals(
            a.equal_range(k));
    test::check_return_type<std::pair<const_iterator, const_iterator> >::equals(
            b.equal_range(k));
    test::check_return_type<size_type>::equals(b.bucket_count());
    test::check_return_type<size_type>::equals(b.max_bucket_count());
    test::check_return_type<size_type>::equals(b.bucket(k));
    test::check_return_type<size_type>::equals(b.bucket_size(0));

    test::check_return_type<local_iterator>::equals(a.begin(0));
    test::check_return_type<const_local_iterator>::equals(b.begin(0));
    test::check_return_type<local_iterator>::equals(a.end(0));
    test::check_return_type<const_local_iterator>::equals(b.end(0));

    test::check_return_type<const_local_iterator>::equals(a.cbegin(0));
    test::check_return_type<const_local_iterator>::equals(b.cbegin(0));
    test::check_return_type<const_local_iterator>::equals(a.cend(0));
    test::check_return_type<const_local_iterator>::equals(b.cend(0));

    test::check_return_type<float>::equals(b.load_factor());
    test::check_return_type<float>::equals(b.max_load_factor());
    a.max_load_factor((float) 2.0);
    a.rehash(100);
}
예제 #29
0
int main()
{
    // Några saker som ska fungera:
    UIntVector a(10);               // initiering med 7 element
    std::cout << "a(10)"<< a.length << std::endl;
    std::cout << "kopiering" << std::endl;
    UIntVector b(a);           // kopieringskonstruktor 
    std::cout << "kopiering" << std::endl;
    a = a;
    std::cout << "s**t" << std::endl;
    UIntVector c = a;          // kopieringskonstruktor 

    //Extra tester för alla Requirments
    a = b;                 // tilldelning genom kopiering
    a[5] = 7;              // tilldelning till element

    const UIntVector e(100000);    // konstant objekt med 10 element
    int i = e[5];          // const int oper[](int) const körs
    i = a[0];              // vektorn är nollindexerad
    i = a[5];              // int oper[](int) körs
    
    a[5]++;                // öka värdet till 8
    
    //Extra tester för alla Requirments
    std::cout << "(1)TEST" << std::endl;
    int aa = e[9];
    int ab = e[0];
    std::cout << "(1)S**T" << aa << ab << std::endl;


    std::cout << "(2)TEST" << std::endl;
    for(long int i = 0; i < 100000; i++)
    {
        e[i];
    } 
    std::cout << "(2)S**T" << std::endl;




    std::cout << "(3)TEST" << std::endl;
    UIntVector a3(10); UIntVector b3(0); UIntVector c3(0);
    b3 = a3;
    a3 = c3;
    std::cout << "(3)S**T" << std::endl;




    std::cout << "(4) START" << std::endl;
    std::initializer_list<unsigned int> list = {1,2,3};
    UIntVector a4(list); UIntVector b4(0);
    a4 = b4;
    std::cout << "length a" << a4.size() << "len b " << b4.size() << std::endl;
    std::cout << "(4) S**T" << std::endl;



    std::cout << "(5)TEST" << std::endl;
    UIntVector b5(list);
    UIntVector a5(std::move(b5));
    std::cout << "(5)S**T" << std::endl;





    std::cout << "(6)TEST" << std::endl;
    UIntVector a6(30);
    UIntVector b6(a6);
    std::cout << "(6)S**T" << std::endl;


    std::cout << "(7)TEST" << std::endl;
    UIntVector a7(1); 
    std::cout << "a) len innan " <<a7.length << std::endl;
    UIntVector b7(std::move(a7));
    std::cout << "b) len " <<b7.length << std::endl;
    std::cout << "a) len " <<a7.length << std::endl;
    std::cout << "(7)S**T" << std::endl;

    std::cout << "(8)TEST" << std::endl;
    UIntVector a8(10);
    a8.reset();
    UIntVector b8(11);
    std::cout << "a) INNAN len " <<a8.size() << "ptr " << a8.vector_ptr <<std::endl;
    UIntVector c8(std::move(a8));
    std::cout << "c) len " <<c8.size() << "ptr" << c8.vector_ptr <<std::endl;
    std::cout << "a) len " <<a8.size() << "ptr " << a8.vector_ptr <<std::endl;
    std::cout << "(8)S**T" << std::endl;


    std::cout << "(9)TEST COPY TO SELF" << std::endl;
    b8 = b8;
    std::cout << "(9)S**T" << std::endl;
    try {
        i = e[10];             // försöker hämta element som ligger utanför e
    } catch (std::out_of_range e) {
        std::cout << e.what() << std::endl;
    }

    
#if 0
    // Diverse saker att testa
    e[5] = 3;              // fel: (kompilerar ej) tilldelning till const
    b = b;                 // hmm: se till att inte minnet som skall behållas frigörs
#endif

    return 0;
}
예제 #30
0
TEST(LockManagerTest, TxDeadlock) {
    LockManager lm(LockManager::kPolicyReadersFirst);
    ClientTransaction t1(&lm, 1);
    ClientTransaction t2(&lm, 2);

    ClientTransaction a1(&lm, 4);
    ClientTransaction a2(&lm, 5);
    ClientTransaction a3(&lm, 6);
    ClientTransaction a4(&lm, 7);
    ClientTransaction a5(&lm, 8);

    // simple deadlock test 1
    t1.acquire(kShared, 1, ACQUIRED);
    a1.acquire(kShared, 2, ACQUIRED);
    t1.acquire(kExclusive, 2, BLOCKED);
    // a1's request would form a dependency cycle, so it should abort
    a1.acquire(kExclusive, 1, ABORTED);
    t1.wakened(); // with t2's locks released, t1 should wake
    t1.release(kExclusive, 2);
    t1.release(kShared, 1);

    // simple deadlock test 2
    a2.acquire(kShared, 1, ACQUIRED);
    t2.acquire(kShared, 2, ACQUIRED);
    t2.acquire(kExclusive, 1, BLOCKED);
    // a2's request would form a dependency cycle, so it should abort
    a2.acquire(kExclusive, 2, ABORTED);
    t2.wakened(); // with a2's locks released, t2 should wake
    t2.release(kExclusive, 1);
    t2.release(kShared, 2);

    // three way deadlock
    t1.acquire(kShared, 1, ACQUIRED);
    t2.acquire(kShared, 2, ACQUIRED);
    a3.acquire(kShared, 3, ACQUIRED);
    t1.acquire(kExclusive, 2, BLOCKED);
    t2.acquire(kExclusive, 3, BLOCKED);
    // a3's request would form a dependency cycle, so it should abort
    a3.acquire(kExclusive, 1, ABORTED);
    t2.wakened(); // with a3's lock release, t2 should wake
    t2.release(kShared, 2);
    t1.wakened(); // with t2's locks released, t1 should wake
    t2.release(kExclusive, 3);
    t1.release(kShared, 1);
    t1.release(kExclusive, 2);

    // test for phantom deadlocks
    t1.acquire(kShared, 1, ACQUIRED);
    t2.acquire(kExclusive, 1, BLOCKED);
    t1.release(kShared, 1);
    t2.wakened();
    // at this point, t2 should no longer be waiting for t1
    // so it should be OK for t1 to wait for t2
    t1.acquire(kShared, 1, BLOCKED);
    t2.release(kExclusive, 1);
    t1.wakened();
    t1.release(kShared, 1);

    // test for missing deadlocks
    t1.acquire(kShared, 1, ACQUIRED);
    t2.acquire(kShared, 2, ACQUIRED); // setup for deadlock with a4
    t2.acquire(kExclusive, 1, BLOCKED); // block on t1
    // after this, because readers first policy, t2 should
    // also be waiting on a4.
    a4.acquire(kShared, 1, ACQUIRED);
    // after this, t2 should be waiting ONLY on a4
    t1.release(kShared, 1);
    // So a4 should not be allowed to wait on t2's resource.
    a4.acquire(kExclusive, 2, ABORTED);
    t2.wakened();
    t2.release(kShared, 2);
    t2.release(kExclusive, 1);

    // test for missing deadlocks: due to downgrades
    a5.acquire(kExclusive, 1, ACQUIRED);
    a5.acquire(kShared, 1, ACQUIRED);
    t2.acquire(kShared, 2, ACQUIRED); // setup for deadlock with a5
    t2.acquire(kExclusive, 1, BLOCKED); // block on a5
    a5.release(kExclusive, 1);
    // at this point, t2 should still be blocked on a5's downgraded lock
    // So a5 should not be allowed to wait on t2's resource.
    a5.acquire(kExclusive, 2, ABORTED);
    t2.wakened();
    t2.release(kShared, 2);
    t2.release(kExclusive, 1);

    t1.quit();
    t2.quit();
}