void testMod()
{
	BigData b1("-45353");
	BigData b2("37353753");
	BigData b3("-9223372036854775808");
	BigData b4(" 9223372036854775800");
	BigData b5("-9223372036854775810");
	BigData b6(" 9223372036854775900");
	BigData b7("-1231123203367738338252");

	//1、排除除数为0
	//cout << (b1 / BigData(0)) << endl;

	//2、在范围内

	cout << (b1 % b2) << endl;
	cout << (b2 % b1) << endl;


	//3、不在范围内<左(被除数)比右(除数)小为0,左比右大>
	cout << (b2 % b5) << endl;
	cout << (b2 % b6) << endl;

	cout << (b5 % b2) << endl;

	cout << (b6 % b2) << endl;
	cout << (b6 % b1) << endl;
	cout << (b5 % b1) << endl;

	cout << b7 % b1 << endl;
}
예제 #2
0
파일: main.cpp 프로젝트: CCJY/coliru
int main() 
{
    // empty constructor
    //std::bitset<8> b1; // [0,0,0,0,0,0,0,0]
 
    // unsigned long long constructor
    //std::bitset<8> b2(42); // [0,0,1,0,1,0,1,0]
 
    // string constructor
    //std::string bit_string = "110010";
    std::bitset<8> b3("110010");       // [0,0,1,1,0,0,1,0]
    std::bitset<8> b4("10011001");    // [0,0,0,0,0,0,1,0]
    std::bitset<8> b5("101010"); // [0,0,0,0,0,0,0,1]
 

    std::cout << (b3 & b5 ) << std::endl;
    std::cout << (b3 | b5 ) << std::endl;
    std::cout << (b3 ^ b5 ) << std::endl;
    
    std::cout << b3 << "\t all: " << b3.all() << "\t any: " << b3.any() << "\t none: " << b3.none()  << std::endl;
    
    std::cout << b3.test(0) << " " << b3.test(5) << std::endl;
    
    return 0;
}
void testSub()
{
	BigData b1("-45353");
	BigData b2("37353753");
	BigData b3("-9223372036854775808");
	BigData b4("9223372036854775800");
	BigData b5("-9223372036854775810");
	BigData b6("9223372036854775900");
	//1、都在INT64范围内<运算后在范围内,运算后不在范围内>(再进行构造可以解决)
	cout << (b1 - b2) << endl;
	cout << (b2 - b1) << endl;
	cout << (b3 - b1) << endl;
	cout << (b1 - b4) << endl;
	cout << (b3 - b2) << endl;
	cout << (b4 - b1) << endl;
	cout << (b1 - b3) << endl;
	cout << (b2 - b4) << endl;
	cout << endl;

	//2、一个在一个不在<运算后在范围内,运算后不在范围内>


	cout << (b5 - b1) << endl;
	cout << (b1 - b5) << endl;
	cout << endl;
	cout << (b6 - b2) << endl;
	cout << (b2 - b6) << endl;
	cout << endl;
	cout << (b6 - b5) << endl;
	cout << (b5 - b6) << endl;
	cout << (b2 - b5) << endl;
	cout << (b1 - b6) << endl;
	cout << (b6 - b1) << endl;
}
예제 #4
0
void TestViewAggregateReduction()
{

#if ! KOKKOS_USING_EXP_VIEW

  const int count = 2 ;
  const long result = count % 2 ? ( count * ( ( count + 1 ) / 2 ) )
                                : ( ( count / 2 ) * ( count + 1 ) );

  Kokkos::View< long * , Space > a("a",count);
  Kokkos::View< long * , Space > b("b",count);
  Kokkos::View< StaticArray<long,4> * , Space > a4("a4",count);
  Kokkos::View< StaticArray<long,4> * , Space > b4("b4",count);
  Kokkos::View< StaticArray<long,10> * , Space > a10("a10",count);
  Kokkos::View< StaticArray<long,10> * , Space > b10("b10",count);

  Kokkos::parallel_for( count , FILL<long,Space>(a,b) );
  Kokkos::parallel_for( count , FILL< StaticArray<long,4> , Space >(a4,b4) );
  Kokkos::parallel_for( count , FILL< StaticArray<long,10> , Space >(a10,b10) );

  long r = 0;
  StaticArray<long,4> r4 ;
  StaticArray<long,10> r10 ;

  Kokkos::parallel_reduce( count , DOT<long,Space>(a,b) , r );
  Kokkos::parallel_reduce( count , DOT< StaticArray<long,4> , Space >(a4,b4) , r4 );
  Kokkos::parallel_reduce( count , DOT< StaticArray<long,10> , Space >(a10,b10) , r10 );

  ASSERT_EQ( result , r );
  for ( int i = 0 ; i < 10 ; ++i ) { ASSERT_EQ( result , r10.value[i] ); }
  for ( int i = 0 ; i < 4 ; ++i ) { ASSERT_EQ( result , r4.value[i] ); }

#endif

}
void testAdd()
{
	BigData b1("-45353");
	BigData b2("37353753");
	BigData b3("-   9223372036854775808");
	BigData b4("     9223372036854775800");
	BigData b5("    -9223372036854775810");
	BigData b6("9223372036854775900");

	//1、都在INT64范围内<运算后在范围内,运算后不在范围内>(再进行构造可以解决)
	cout << (b1 + b1) << endl;
	cout << (b2 + b2) << endl;
	cout << (b1 + b2) << endl;
	cout << "b4:" << b4 << endl;
	cout << (b1 + b4) << endl;

	cout << b3 << endl;
	cout << (b1 + b3) << endl;
	cout << (b2 + b4) << endl;

	//2、都不在INT64范围内<运算后在范围内,运算后不在范围内>
	cout << (b2 + b5) << endl;
	cout << (b1 + b6) << endl;
	cout << (b6 + b1) << endl;

	//3、一个在一个不在<运算后在范围内,运算后不在范围内>
}
예제 #6
0
void test_conversion(ConvertibleToBase ctb, ConvertibleToDerived ctd,
                     ConvertibleToFunkyDerived ctfd) {
  Base b1 = ctb;
  Base b2(ctb);
  Base b3 = ctd;
  Base b4(ctd);
  Base b5 = ctfd;
}
예제 #7
0
void convertHFShowerLibrary() {
  TFile *nF=new TFile("david.root","RECREATE","hiThere",1);
  TTree *nT=new TTree("HFSimHits","HF simple tree");
  std::vector<float> *parts=new std::vector<float>();
  std::vector<float> *partsHad=new std::vector<float>();
  nT->Branch("emParticles", &parts);
  nT->GetBranch("emParticles")->SetBasketSize(1);
  nT->Branch("hadParticles", &partsHad);
  nT->GetBranch("hadParticles")->SetBasketSize(1);

  TDirectory *target=gDirectory;
  TFile *oF=TFile::Open("HFShowerLibrary_npmt_noatt_eta4_16en_v3_orig.root");
  TTree *t=(TTree*)oF->Get("HFSimHits");
  TTreeReader fReader(t);
  TTreeReaderArray<Float_t> b1(fReader, "emParticles.position_.fCoordinates.fX");
  TTreeReaderArray<Float_t> b2(fReader, "emParticles.position_.fCoordinates.fY");
  TTreeReaderArray<Float_t> b3(fReader, "emParticles.position_.fCoordinates.fZ");
  TTreeReaderArray<Float_t> b4(fReader, "emParticles.lambda_");
  TTreeReaderArray<Float_t> b5(fReader, "emParticles.time_");

  TTreeReaderArray<Float_t> h1(fReader, "hadParticles.position_.fCoordinates.fX");
  TTreeReaderArray<Float_t> h2(fReader, "hadParticles.position_.fCoordinates.fY");
  TTreeReaderArray<Float_t> h3(fReader, "hadParticles.position_.fCoordinates.fZ");
  TTreeReaderArray<Float_t> h4(fReader, "hadParticles.lambda_");
  TTreeReaderArray<Float_t> h5(fReader, "hadParticles.time_");


  target->cd();
  while ( fReader.Next() ) {
    parts->clear();
    unsigned int s=b1.GetSize();
    parts->resize(5*s);
    for ( unsigned int i=0; i<b1.GetSize(); i++) {
      (*parts)[i]=(b1[i]);
      (*parts)[i+1*s]=(b2[i]);
      (*parts)[i+2*s]=(b3[i]);
      (*parts)[i+3*s]=(b4[i]);
      (*parts)[i+4*s]=(b5[i]);
    }  

    partsHad->clear();
    s=h1.GetSize();
    partsHad->resize(5*s);
    for ( unsigned int i=0; i<h1.GetSize(); i++) {
      (*partsHad)[i]=(h1[i]);
      (*partsHad)[i+1*s]=(h2[i]);
      (*partsHad)[i+2*s]=(h3[i]);
      (*partsHad)[i+3*s]=(h4[i]);
      (*partsHad)[i+4*s]=(h5[i]);
    }  

    nT->Fill();
  }

  nT->Write();
  nF->Close();
}
예제 #8
0
파일: Test.cpp 프로젝트: momo462/Project
void test4()
{
	BigData b1("9999999999999999999999999999999");
	BigData b2("9999999999999999999999999999991");
	cout<<b1-b2<<endl;
	BigData b3("33333333333333");
	BigData b4("9999999999999999999999999999999");
	cout<<b3-b4<<endl;
	BigData b5("9999999999999999999999999999991");
	BigData b6("9999999999999999999999999999999");
	cout<<b5-b6<<endl;
}
예제 #9
0
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    
    GLint viewport[4];
    glGetIntegerv(GL_VIEWPORT, viewport);
    double aspect = (double)viewport[2] / (double)viewport[3];
    gluPerspective(fovy, aspect, clipNear, clipFar);
    
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    
    gluLookAt(0, 0, z, x, y, 0, 0, 1, 0);
    
    if (success) {
        drawFaces();
        
        if (drawAABB) {
            Eigen::Vector3d max = boundingBox.max;
            Eigen::Vector3d min = boundingBox.min;
            Eigen::Vector3d extent = boundingBox.extent;
            
            Eigen::Vector3d b2(min.x() + extent.x(), min.y(), min.z());
            Eigen::Vector3d b3(min.x() + extent.x(), min.y() + extent.y(), min.z());
            Eigen::Vector3d b4(min.x(), min.y() + extent.y(), min.z());
            Eigen::Vector3d b5(max.x() - extent.x(), max.y() - extent.y(), max.z());
            Eigen::Vector3d b6(max.x(), max.y() - extent.y(), max.z());
            Eigen::Vector3d b8(max.x() - extent.x(), max.y(), max.z());
            
            drawBox(min, b2, b3, b4, b5, b6, max, b8);
            
        } else {
            std::vector<Eigen::Vector3d> orientedPoints = boundingBox.orientedPoints;
            
            Eigen::Vector3d b1 = orientedPoints[0] + orientedPoints[2] + orientedPoints[4];
            Eigen::Vector3d b2 = orientedPoints[1] + orientedPoints[2] + orientedPoints[4];
            Eigen::Vector3d b3 = orientedPoints[1] + orientedPoints[2] + orientedPoints[5];
            Eigen::Vector3d b4 = orientedPoints[0] + orientedPoints[2] + orientedPoints[5];
            Eigen::Vector3d b5 = orientedPoints[0] + orientedPoints[3] + orientedPoints[4];
            Eigen::Vector3d b6 = orientedPoints[1] + orientedPoints[3] + orientedPoints[4];
            Eigen::Vector3d b8 = orientedPoints[0] + orientedPoints[3] + orientedPoints[5];
            Eigen::Vector3d b7 = orientedPoints[1] + orientedPoints[3] + orientedPoints[5];
            
            drawBox(b1, b2, b3, b4, b5, b6, b7, b8);
        }
    }
    
    glutSwapBuffers();
}
예제 #10
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);
}
예제 #11
0
void OmniRobot::init()
{
    period = 200;
    xw = 75.0; //mm
    yw = 75.0; //mm
    Dw = 50.0; //mm

    vector<float> u1 (2); u1(0) =  c1; u1(1) =  c1;
    vector<float> u2 (2); u2(0) =  c1; u2(1) = -c1;
    vector<float> u3 (2); u3(0) =  c1; u3(1) =  c1;
    vector<float> u4 (2); u4(0) =  c1; u4(1) = -c1;

    vector<float> n1 (2); n1(0) =  c1; n1(1) = -c1;
    vector<float> n2 (2); n2(0) = -c1; n2(1) = -c1;
    vector<float> n3 (2); n3(0) =  c1; n3(1) = -c1;
    vector<float> n4 (2); n4(0) = -c1; n4(1) = -c1;

    vector<float> b1 (2); b1(0) =  xw; b1(1) =  yw;
    vector<float> b2 (2); b2(0) =  xw; b2(1) = -yw;
    vector<float> b3 (2); b3(0) = -xw; b3(1) = -yw;
    vector<float> b4 (2); b4(0) = -xw; b4(1) =  yw;

    Mt(0,0) = n1(0); Mt(0,1) = n1(1); Mt(0,2) = b1(0)*u1(0) + b1(1)*u1(1);
    Mt(1,0) = n2(0); Mt(1,1) = n2(1); Mt(1,2) = b2(0)*u2(0) + b2(1)*u2(1);
    Mt(2,0) = n3(0); Mt(2,1) = n3(1); Mt(2,2) = b3(0)*u3(0) + b3(1)*u3(1);
    Mt(3,0) = n4(0); Mt(3,1) = n3(1); Mt(3,2) = b4(0)*u4(0) + b4(1)*u4(1);

    Mt = -1 * Mt;

    cmd(0) = 0.0; cmd(1) = 0.0; cmd(2) = 0.0;
    pwm(0) = 0.0; pwm(1) = 0.0; pwm(2) = 0.0; pwm(3) = 0.0;

    omniState = INIT_MODE;
    movementMode = ROTATE_MODE;
    power = 20;
    pplus = 1;
}
예제 #12
0
void TestSymDiv_E2(tmv::DivType dt, PosDefCode pdc)
{
    const int N = 10;

    std::vector<tmv::SymMatrixView<T> > s;
    std::vector<tmv::SymMatrixView<std::complex<T> > > cs;
    MakeSymList(s,cs,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);

    tmv::BandMatrix<T> b1(a1,1,3);
    tmv::BandMatrix<std::complex<T> > cb1(ca1,1,3);

    tmv::BandMatrix<T> b1v = b1.view();
    tmv::BandMatrix<std::complex<T> > cb1v = cb1.view();

#if (XTEST & 2)
    tmv::BandMatrix<T> b3(a1.colRange(0,N-2),1,3);
    tmv::BandMatrix<std::complex<T> > cb3(ca1.colRange(0,N-2),1,3);
    tmv::BandMatrix<T> b4(a1.rowRange(0,N-2),1,3);
    tmv::BandMatrix<std::complex<T> > cb4(ca1.rowRange(0,N-2),1,3);

    tmv::BandMatrix<T> b3v = b3.view();
    tmv::BandMatrix<std::complex<T> > cb3v = cb3.view();
    tmv::BandMatrix<T> b4v = b4.view();
    tmv::BandMatrix<std::complex<T> > cb4v = cb4.view();
#endif

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

        TestMatrixDivArith1(dt,b1v,si,cb1v,csi,"Sym/SquareBandMatrix");
        if (dt == tmv::LU) continue;
#if (XTEST & 2)
        TestMatrixDivArith1(dt,b3v,si,cb3v,csi,"Sym/NonSquareBandMatrix");
        TestMatrixDivArith1(dt,b4v,si,cb4v,csi,"Sym/NonSquareBandMatrix");
#endif
    }
}
예제 #13
0
void drawShapes( QPainter *p )
{
    QBrush b1( blue );				// solid blue brush
    QBrush b2( green, Dense6Pattern );		// green 12% fill
    QBrush b3( NoBrush );			// void brush
    QBrush b4( CrossPattern );			// black cross pattern

    p->setPen( red );
    p->setBrush( b1 );
    p->drawRect( 10, 10, 200, 100 );		// draw some shapes
    p->setBrush( b2 );
    p->drawRoundRect( 10, 150, 200, 100, 20, 20 );
    p->setBrush( b3 );
    p->drawEllipse( 250, 10, 200, 100 );
    p->setBrush( b4 );
    p->drawPie( 250, 150, 200, 100, 45*16, 90*16 );
}
예제 #14
0
void drawShapes( QPainter *p )
{
    QBrush b1( Qt::blue );
    QBrush b2( Qt::green, Qt::Dense6Pattern );		// green 12% fill
    QBrush b3( Qt::NoBrush );				// void brush
    QBrush b4( Qt::CrossPattern );			// black cross pattern

    p->setPen( Qt::red );
    p->setBrush( b1 );
    p->drawRect( 10, 10, 200, 100 );
    p->setBrush( b2 );
    p->drawRoundRect( 10, 150, 200, 100, 20, 20 );
    p->setBrush( b3 );
    p->drawEllipse( 250, 10, 200, 100 );
    p->setBrush( b4 );
    p->drawPie( 250, 150, 200, 100, 45*16, 90*16 );
}
예제 #15
0
TEST(BubbleInitializing, Colors)
{
  bbs::Bubble b1(1, 1, bbs::colors_t::NONE);
  EXPECT_EQ(b1.getStatus(), bbs::colors_t::NONE);

  bbs::Bubble b2(1, 1, bbs::colors_t::RED);
  EXPECT_EQ(b2.getStatus(), bbs::colors_t::RED);

  bbs::Bubble b3(1, 1, bbs::colors_t::GREEN);
  EXPECT_EQ(b3.getStatus(), bbs::colors_t::GREEN);

  bbs::Bubble b4(1, 1, bbs::colors_t::YELLOW);
  EXPECT_EQ(b4.getStatus(), bbs::colors_t::YELLOW);

  bbs::Bubble b5(1, 1, bbs::colors_t::BLUE);
  EXPECT_EQ(b5.getStatus(), bbs::colors_t::BLUE);
}
예제 #16
0
TEST(Bubbles, PrintStatus)
{
  bbs::Bubble b1(1, 1, bbs::colors_t::NONE);
  EXPECT_EQ(b1.getPrintableStatus(), "N");

  bbs::Bubble b2(1, 1, bbs::colors_t::RED);
  EXPECT_EQ(b2.getPrintableStatus(), "R");

  bbs::Bubble b3(1, 1, bbs::colors_t::GREEN);
  EXPECT_EQ(b3.getPrintableStatus(), "G");

  bbs::Bubble b4(1, 1, bbs::colors_t::YELLOW);
  EXPECT_EQ(b4.getPrintableStatus(), "Y");

  bbs::Bubble b5(1, 1, bbs::colors_t::BLUE);
  EXPECT_EQ(b5.getPrintableStatus(), "B");
}
int main()
{
	Big b0("b0");

	Big b1(b0);
	b1.setName("b1");
	std::cout << std::endl << "现在b1:" << std::endl;
	print(b1);

	Big b2(std::move(makeBig(1, 2, "临时b2") + 4));
	b2.setName("b2");
	std::cout << std::endl << "现在b2:" << std::endl;
	print(b2);

	Big b3("b3");
	b3 = b0;
	b3.setName("变量b3=b0");
	std::cout << std::endl << "现在b3:" << std::endl;
	print(b3);

	Big b4("b4");
	b4 = b0 + 8;
	b4.setName("变量b4=b0+8");
	std::cout << std::endl << "现在b4:" << std::endl;
	print(b4);

	std::cout << "-----------------------" << std::endl;

	std::vector<Big> *v = new std::vector<Big>;
	v->push_back(b0 + 16);
	std::cout << "1st push_back" << std::endl;

	v->push_back(makeBig(32, 64, "临时b5"));
	std::cout << "2nd push_back" << std::endl;

	v->push_back(makeBig(128, 256, "临时b6") + 512);
	std::cout << "3rd push_back" << std::endl;

	std::cout << std::endl << "释放vector<Big>内所有的资源:" << std::endl;
	delete v;

	std::cout << "-----------------------" << std::endl;
	
	std::cout << "程序到达终点,操作系统释放剩余的资源!" << std::endl;
	return 0;
}//main
예제 #18
0
파일: b_0_49.cpp 프로젝트: jakexie/micmac
template <class Type> void bench_pack_im(Type *,INT vmax,bool quick)
{

	for (INT x=10; x< (quick ? 300 : 1200); x+= 220)
	{
cout << x << "\n";
		Bench_PackB_IM<Type>  b1(Pt2di(x,x),0);
		Bench_PackB_IM<Type>  b0(Pt2di(x,x),FX%vmax);
		Bench_PackB_IM<Type>  b2(Pt2di(x,x),(FX>FY)*vmax);
		Bench_PackB_IM<Type>  b3(Pt2di(x,x),frandr()<0.1);
		Bench_PackB_IM<Type>  b4(Pt2di(x,x),frandr()<(1/128.0));

                b0.DoNothing();
                b1.DoNothing();
                b2.DoNothing();
                b3.DoNothing();
                b4.DoNothing();
	}
}
void testMul()
{
	BigData b1("-45353");
	BigData b2("37353753");
	BigData b3("-9223372036854775808");
	BigData b4(" 9223372036854775800");
	BigData b5("-9223372036854775810");
	BigData b6(" 9223372036854775900");
	//1、都在INT64范围内<运算后在范围内,运算后不在范围内>(再进行构造可以解决)
	cout << (BigData("999") * BigData("22222222222222222222222222222")) << endl;

	cout << (b2 * b1) << endl;
	cout << (b1 * b2) << endl;
	cout << (b1 * BigData("0")) << endl;
	cout << (BigData("0") * b2) << endl;
	cout << endl;
	cout << (b3 * b1) << endl;
	cout << (b1 * b3) << endl;
	cout << (b1 * b4) << endl;
	cout << (b4 * b1) << endl;
	cout << (b3 * b2) << endl;
	cout << (b2 * b4) << endl;
	cout << endl;

	//2、一个在一个不在<运算后在范围内,运算后不在范围内>

	cout << (BigData("0") * b6) << endl;
	cout << (b5 * BigData("0")) << endl;
	cout << (b5 * b1) << endl;
	cout << (b1* b5) << endl;
	cout << endl;
	cout << (b6 * b2) << endl;
	cout << (b2 * b6) << endl;
	cout << endl;
	cout << (b6 * b5) << endl;
	cout << (b5 * b6) << endl;
	cout << (b2 * b5) << endl;
	cout << endl;
	cout << (b1 * b6) << endl;
	cout << (b6 * b1) << endl;
}
예제 #20
0
TEST(Binary,SEQ) {
    Message m("{}");
    
    Binary b1(Binary::Type::SEQ, mv("foo"), mv("bar") );
    EXPECT_FALSE(b1.eval(m));

    Binary b2(Binary::Type::SEQ, mv("foo"), mv("foo") );
    EXPECT_TRUE(b2.eval(m));
    
    Binary b3(Binary::Type::SEQ, mv(""), mv("") );
    EXPECT_TRUE(b3.eval(m));
    
    Binary b4(Binary::Type::SEQ, mv(""), mv("foo") );
    EXPECT_FALSE(b4.eval(m));
    
    Binary b5(Binary::Type::SEQ, mv("4"), mv("4") );
    EXPECT_TRUE(b5.eval(m));
    
    Binary b6(Binary::Type::SEQ, mv("4"), mv("04") );
    EXPECT_FALSE(b6.eval(m));
}
예제 #21
0
TEST(BubblePlopping, AllOnce)
{
  bbs::Bubble b1(1, 1, bbs::colors_t::NONE);
  b1.plopp();
  EXPECT_EQ(b1.getStatus(), bbs::colors_t::NONE);

  bbs::Bubble b2(1, 1, bbs::colors_t::RED);
  b2.plopp();
  EXPECT_EQ(b2.getStatus(), bbs::colors_t::NONE);

  bbs::Bubble b3(1, 1, bbs::colors_t::GREEN);
  b3.plopp();
  EXPECT_EQ(b3.getStatus(), bbs::colors_t::RED);

  bbs::Bubble b4(1, 1, bbs::colors_t::YELLOW);
  b4.plopp();
  EXPECT_EQ(b4.getStatus(), bbs::colors_t::GREEN);

  bbs::Bubble b5(1, 1, bbs::colors_t::BLUE);
  b5.plopp();
  EXPECT_EQ(b5.getStatus(), bbs::colors_t::YELLOW);
}
예제 #22
0
파일: Test.cpp 프로젝트: momo462/Project
void test2()
{
	BigData b1("");
	BigData b2("-123");
	BigData b3("-");
	BigData b4("+");
	BigData b5("+aa123");
	BigData b6("-aa123");
	BigData b7("aa123");
	BigData b8("123");
	BigData b9("+12aa3");
	BigData b10("-12aa3");
	BigData b11("12aa3");
	BigData b13("-000123");
	BigData b14("+000123");
	BigData b15("9999999999999999999999999999999999999999999999999999999");
	BigData b16(123);
	BigData b17(1234);
	cout<<b15;
	cin>>b1;

}
예제 #23
0
TEST(BubbleInitializing, Mixed)
{
  bbs::Bubble b1(-1, 1, bbs::colors_t::NONE);
  EXPECT_EQ(b1.getPositionColumn(), -1);
  EXPECT_EQ(b1.getPositionRow(), 1);

  bbs::Bubble b2(-50, 50, bbs::colors_t::NONE);
  EXPECT_EQ(b2.getPositionColumn(), -50);
  EXPECT_EQ(b2.getPositionRow(), 50);

  bbs::Bubble b3(30000, -30000, bbs::colors_t::NONE);
  EXPECT_EQ(b3.getPositionColumn(), 30000);
  EXPECT_EQ(b3.getPositionRow(), -30000);

  bbs::Bubble b4(2, -13, bbs::colors_t::NONE);
  EXPECT_EQ(b4.getPositionColumn(), 2);
  EXPECT_EQ(b4.getPositionRow(), -13);

  bbs::Bubble b5(-17, 3, bbs::colors_t::NONE);
  EXPECT_EQ(b5.getPositionColumn(), -17);
  EXPECT_EQ(b5.getPositionRow(), 3);
}
예제 #24
0
TEST(BubbleInitializing, Negative)
{
  bbs::Bubble b1(-1, -1, bbs::colors_t::NONE);
  EXPECT_EQ(b1.getPositionColumn(), -1);
  EXPECT_EQ(b1.getPositionRow(), -1);

  bbs::Bubble b2(-50, -50, bbs::colors_t::NONE);
  EXPECT_EQ(b2.getPositionColumn(), -50);
  EXPECT_EQ(b2.getPositionRow(), -50);

  bbs::Bubble b3(-30000, -30000, bbs::colors_t::NONE);
  EXPECT_EQ(b3.getPositionColumn(), -30000);
  EXPECT_EQ(b3.getPositionRow(), -30000);

  bbs::Bubble b4(-2, -13, bbs::colors_t::NONE);
  EXPECT_EQ(b4.getPositionColumn(), -2);
  EXPECT_EQ(b4.getPositionRow(), -13);

  bbs::Bubble b5(-17, -3, bbs::colors_t::NONE);
  EXPECT_EQ(b5.getPositionColumn(), -17);
  EXPECT_EQ(b5.getPositionRow(), -3);
}
예제 #25
0
TEST(BubbleInitializing, Positive)
{
  bbs::Bubble b1(1, 1, bbs::colors_t::NONE);
  EXPECT_EQ(b1.getPositionColumn(), 1);
  EXPECT_EQ(b1.getPositionRow(), 1);

  bbs::Bubble b2(50, 50, bbs::colors_t::NONE);
  EXPECT_EQ(b2.getPositionColumn(), 50);
  EXPECT_EQ(b2.getPositionRow(), 50);

  bbs::Bubble b3(30000, 30000, bbs::colors_t::NONE);
  EXPECT_EQ(b3.getPositionColumn(), 30000);
  EXPECT_EQ(b3.getPositionRow(), 30000);

  bbs::Bubble b4(2, 13, bbs::colors_t::NONE);
  EXPECT_EQ(b4.getPositionColumn(), 2);
  EXPECT_EQ(b4.getPositionRow(), 13);

  bbs::Bubble b5(17, 3, bbs::colors_t::NONE);
  EXPECT_EQ(b5.getPositionColumn(), 17);
  EXPECT_EQ(b5.getPositionRow(), 3);
}
예제 #26
0
void level_one()
{
	vector<DPipe> DPIPES(5);
	vector<DoublePipe> DOUBPIPES(8);
	vector<CrossPipe> CROSSPIPES(1);

	DPipe a0(70,600,100,40);
	DPipe a1(170,600,100,40);
	DoublePipe b0(270,600,70,40);
	DoublePipe b1(270,500,70,40);
	DoublePipe b2(170,500,70,40);
	DoublePipe b3(170,400,70,40);
	DPipe a2(270,400,100,40);
	CrossPipe c0(370,400,100,40);
	DoublePipe b4(470,400,70,40);
	DoublePipe b5(470,300,70,40);
	DoublePipe b6(370,300,70,40);
	DoublePipe b7(370,500,70,40);
	DPipe a3(470,500,100,40);
	DPipe a4(570,500,100,40);

	DPIPES[0]=a0;
	DPIPES[1]=a1;
	DPIPES[2]=a2;
	DPIPES[3]=a3;
	DPIPES[4]=a4;

	DOUBPIPES[0]=b0;
	DOUBPIPES[1]=b1;
	DOUBPIPES[2]=b2;
	DOUBPIPES[3]=b3;
	DOUBPIPES[4]=b4;
	DOUBPIPES[5]=b5;
	DOUBPIPES[6]=b6;
	DOUBPIPES[7]=b7;

	CROSSPIPES[0]=c0;
}
void Test1()
{
	BigData n1(123456);

	BigData b2("12346678");
	BigData b3("+12346678");
	BigData b4("-123466");
	BigData b5("+");
	BigData b6("    ");
	BigData b7("12346aaaa");
	BigData b8("+asd12346678");
	BigData b9("000012346678");

	cout << "n1:" << n1 << endl;
	cout << "b2:" << b2 << endl;
	cout << "b3:" << b3 << endl;
	cout << "b4:" << b4 << endl;
	cout << "b5:" << b5 << endl;
	cout << "b6:" << b6 << endl;
	cout << "b7:" << b7 << endl;
	cout << "b8:" << b8 << endl;
	cout << "b9:" << b9 << endl;
}
예제 #28
0
void testSkipListNode()
{
	SkipListNode head_bottom;
	SkipListNode head_mid;
	SkipListNode head_roof;

	head_roof.down = &head_mid; head_mid.down = &head_bottom;
	head_bottom.up = &head_mid; head_mid.up = &head_roof;

	SkipListNode b1(1), b2(2), b3(3), b4(4);
	SkipListNode m1(1), m2(2), m4(4);
	SkipListNode r1(1), r4(4);

	r1.down = &m1; m1.down = &b1;
	b1.up = &m1; m1.up = &r1;

	r4.down = &m4; m4.down = &b4;
	b4.up = &m4; m4.up = &r4;

	m2.down = &b2;
	b2.up = &m2;

	head_bottom.next = &b1; b1.next = &b2; b2.next = &b3; b3.next = &b4;
	b4.prev = &b3; b3.prev = &b2; b2.prev = &b1; b1.prev = &head_bottom;

	head_mid.next = &m1; m1.next = &m2; m2.next = &m4;
	m4.prev = &m2; m2.prev = &m1; m1.prev = &head_mid;

	head_roof.next = &r1; r1.next = &r4;
	r4.prev = &r1; r1.prev = &head_roof;

	std::cout<<head_roof;
	std::cout<<head_mid;
	std::cout<<head_bottom;

}
예제 #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
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;
}