Example #1
0
void Timer::addTimer(int idTimer, f32 Timing)
{
	std::pair<int, f32> t(idTimer, Timing);
	std::pair<f32, f32> t2(0, 0);
	//timers.insert();
}
inline void
PanelHouseholder( DistMatrix<F>& A, DistMatrix<F,MD,STAR>& t )
{
#ifndef RELEASE
    CallStackEntry entry("lq::PanelHouseholder");
    if( A.Grid() != t.Grid() )
        LogicError("{A,t} must be distributed over the same grid");
    if( t.Height() != Min(A.Height(),A.Width()) || t.Width() != 1 )
        LogicError
        ("t must be a vector of height equal to the minimum dimension of A");
    if( !t.AlignedWithDiagonal( A, 0 ) )
        LogicError("t must be aligned with A's main diagonal");
#endif
    const Grid& g = A.Grid();

    // Matrix views
    DistMatrix<F>
        ATL(g), ATR(g),  A00(g), a01(g),     A02(g),  aTopRow(g), ABottomPan(g),
        ABL(g), ABR(g),  a10(g), alpha11(g), a12(g),
                         A20(g), a21(g),     A22(g);
    DistMatrix<F,MD,STAR>
        tT(g),  t0(g),
        tB(g),  tau1(g),
                t2(g);

    // Temporary distributions
    DistMatrix<F> aTopRowConj(g);
    DistMatrix<F,STAR,MR  > aTopRowConj_STAR_MR(g);
    DistMatrix<F,MC,  STAR> z_MC_STAR(g);

    PartitionDownDiagonal
    ( A, ATL, ATR,
         ABL, ABR, 0 );
    PartitionDown
    ( t, tT,
         tB, 0 );
    while( ATL.Height() < A.Height() && ATL.Width() < A.Width() )
    {
        RepartitionDownDiagonal
        ( ATL, /**/ ATR,  A00, /**/ a01,     A02,
         /*************/ /**********************/
               /**/       a10, /**/ alpha11, a12,
          ABL, /**/ ABR,  A20, /**/ a21,     A22, 1 );

        RepartitionDown
        ( tT,  t0,
         /**/ /****/
               tau1,
          tB,  t2, 1 );

        View1x2( aTopRow, alpha11, a12 );
        View1x2( ABottomPan, a21, A22 );

        aTopRowConj_STAR_MR.AlignWith( ABottomPan );
        z_MC_STAR.AlignWith( ABottomPan );
        //--------------------------------------------------------------------//
        // Compute the Householder reflector
        const F tau = Reflector( alpha11, a12 );
        tau1.Set( 0, 0, tau );

        // Apply the Householder reflector
        const bool myDiagonalEntry = ( g.Row() == alpha11.ColAlignment() &&
                                       g.Col() == alpha11.RowAlignment() );
        F alpha = 0;
        if( myDiagonalEntry )
        {
            alpha = alpha11.GetLocal(0,0);
            alpha11.SetLocal(0,0,1);
        }
        Conjugate( aTopRow, aTopRowConj );
        aTopRowConj_STAR_MR = aTopRowConj;
        Zeros( z_MC_STAR, ABottomPan.Height(), 1 );
        LocalGemv
        ( NORMAL, F(1), ABottomPan, aTopRowConj_STAR_MR, F(0), z_MC_STAR );
        z_MC_STAR.SumOverRow();
        Ger
        ( -Conj(tau),
          z_MC_STAR.LockedMatrix(),
          aTopRowConj_STAR_MR.LockedMatrix(),
          ABottomPan.Matrix() );
        if( myDiagonalEntry )
            alpha11.SetLocal(0,0,alpha);
        //--------------------------------------------------------------------//

        SlidePartitionDown
        ( tT,  t0,
               tau1,
         /**/ /****/
          tB,  t2 );

        SlidePartitionDownDiagonal
        ( ATL, /**/ ATR,  A00, a01,     /**/ A02,
               /**/       a10, alpha11, /**/ a12,
         /*************/ /**********************/
          ABL, /**/ ABR,  A20, a21,     /**/ A22 );
    }
}
Example #3
0
void nofFarmhand::HandleDerivedEvent(const unsigned int id)
{
    switch(state)
    {
        case STATE_WORK:
        {
            // fertig mit Arbeiten --> dann müssen die "Folgen des Arbeitens" ausgeführt werden
            WorkFinished();
            // Objekt wieder freigeben
            gwg->GetNode(pos).reserved = false;
            // Wieder nach Hause gehen
            StartWalkingHome();

            // Evtl. Sounds löschen
            if(was_sounding)
            {
                SOUNDMANAGER.WorkingFinished(this);
                was_sounding = false;
            }

        } break;
        case STATE_WAITING1:
        {
            // Fertig mit warten --> anfangen zu arbeiten
            // Die Arbeitsradien der Berufe wie in JobConst.h (ab JOB_WOODCUTTER!)
            const unsigned char RADIUS[7] =
            { 6, 7, 6, 0, 8, 2, 2 };

            // Additional radius delta r which is used when a point in radius r was found
            // I.e. looks till radius r + delta r
            const unsigned ADD_RADIUS_WHEN_FOUND[7] =
            { 1, 1, 1, 1, 0, 1, 1};


            // Anzahl der Radien, wo wir gültige Punkte gefunden haben
            unsigned radius_count = 0;

            // Available points: 1st class and 2st class
            std::vector< MapPoint > available_points[3];

            unsigned max_radius = (job_ == JOB_CHARBURNER) ? 3 : RADIUS[job_ - JOB_WOODCUTTER];
            unsigned add_radius_when_found = (job_ == JOB_CHARBURNER) ? 1 : ADD_RADIUS_WHEN_FOUND[job_ - JOB_WOODCUTTER];

            bool points_found = false;
            bool wait = false;

            for(MapCoord tx = gwg->GetXA(pos, 0), r = 1; r <= max_radius; tx = gwg->GetXA(tx, pos.y, 0), ++r)
            {
                // Wurde ein Punkt in diesem Radius gefunden?
                bool found_in_radius = false;

                MapPoint t2(tx, pos.y);
                for(unsigned i = 2; i < 8; ++i)
                {
                    for(MapCoord r2 = 0; r2 < r; t2 = gwg->GetNeighbour(t2,  i % 6), ++r2)
                    {
                        if(IsPointAvailable(t2))
                        {
                            if (!gwg->GetNode(t2).reserved)
                            {
                                available_points[GetPointQuality(t2) - PQ_CLASS1].push_back(MapPoint(t2));
                                found_in_radius = true;
                                points_found = true;
                            }
                            else if (job_ == JOB_STONEMASON)
                            {
                                // just wait a little bit longer
                                wait = true;
                            }
                        }
                    }
                }


                // Nur die zwei ADD_RADIUS_WHEN_FOUND Radien erst einmal nehmen
                if(found_in_radius)
                {
                    if( radius_count++ == add_radius_when_found)
                        break;
                }
            }

            // Are there any objects at all?
            if(points_found)
            {
                // Prefer 1st class objects and use only 2nd class objects if there are no more other objects anymore
                MapPoint p(0, 0);
                for(unsigned i = 0; i < 3; ++i)
                {
                    if(!available_points[i].empty())
                    {
                        p = available_points[i][RANDOM.Rand(__FILE__, __LINE__, GetObjId(), available_points[i].size())];
                        break;
                    }
                }

                // Als neues Ziel nehmen
                dest = p;

                state = STATE_WALKTOWORKPOINT;

                // Wir arbeiten jetzt
                workplace->is_working = true;

                // Punkt für uns reservieren
                gwg->GetNode(dest).reserved = true;;

                // Anfangen zu laufen (erstmal aus dem Haus raus!)
                StartWalking(4);

                StopNotWorking();

                WalkingStarted();
            }
            else if (wait)
            {
                // We have to wait, since we do not know whether there are any unreachable or reserved points where there's more to get
                current_ev = em->AddEvent(this, JOB_CONSTS[job_].wait1_length, 1);

                StartNotWorking();
            }
            else
            {

                if(GAMECLIENT.GetPlayerID() == this->player)
                {
                    if (!OutOfRessourcesMsgSent)
                    {
                        switch(job_)
                        {
                            case JOB_STONEMASON:
                                GAMECLIENT.SendPostMessage(
                                    new ImagePostMsgWithLocation(_("No more stones in range"), PMC_GENERAL, pos, workplace->GetBuildingType(), workplace->GetNation()));
                                OutOfRessourcesMsgSent = true;
                                // Produktivitätsanzeige auf 0 setzen
                                workplace->SetProductivityToZero();
                                break;
                            case JOB_FISHER:
                                GAMECLIENT.SendPostMessage(
                                    new ImagePostMsgWithLocation(_("No more fishes in range"), PMC_GENERAL, pos, workplace->GetBuildingType(), workplace->GetNation()));
                                OutOfRessourcesMsgSent = true;
                                // Produktivitätsanzeige auf 0 setzen
                                workplace->SetProductivityToZero();
                                break;
                            default:
                                break;
                        }
                    }
                }

                // KI-Event erzeugen
                switch(workplace->GetBuildingType())
                {
                    case BLD_WOODCUTTER:
                    case BLD_QUARRY:
                    case BLD_FISHERY:
                        GAMECLIENT.SendAIEvent(new AIEvent::Building(AIEvent::NoMoreResourcesReachable, workplace->GetPos(), workplace->GetBuildingType()), player);
                        break;
                    default:
                        break;
                }

                // Weiter warten, vielleicht gibts ja später wieder mal was
                current_ev = em->AddEvent(this, JOB_CONSTS[job_].wait1_length, 1);

                StartNotWorking();
            }

        } break;
        default:
            break;
    }
}
Example #4
0
int main()
{
	int pid1 = 0;
	int pid2 = 0;
	try {
		std::cout << "Cancel before" << std::endl;
		io::io_service srv;
		the_service = &srv;
		io::acceptor ac(srv);
		the_socket = &ac;
		ac.open(io::pf_inet);
		ac.set_option(io::basic_socket::reuse_address,true);
		io::endpoint ep("127.0.0.1",8080);
		ac.bind(ep);
		ac.listen(5);
		io::stream_socket s1(srv);
		ac.async_accept(s1,socket_accept_failer);
		ac.cancel();
		srv.run();
		TEST(called); called=false;
		srv.reset();
		std::cout << "Cancel by timer" << std::endl;
		
		io::deadline_timer dt(srv);
		dt.expires_from_now(booster::ptime::milliseconds(100));
		dt.async_wait(socket_canceler);
		ac.async_accept(s1,socket_accept_failer);
		srv.run();
		TEST(called); called=false;
		srv.reset();

		std::cout << "Cancel by thread" << std::endl;
		booster::thread t1(thread_socket_canceler);
		ac.async_accept(s1,socket_accept_failer);
		srv.run();
		TEST(called); called=false;
		t1.join();
		srv.reset();
		
		std::cout << "Accept by thread" << std::endl;
		booster::thread t2(thread_socket_connector);
		ac.async_accept(s1,async_socket_writer);
		accepted_socket=&s1;
		srv.run();
		TEST(called); called=false;
		t2.join();
		srv.reset();
		s1.close();
		std::cout << "Acceptor is shared" << std::endl;
		
		pid1=fork();
		if(pid1==0) {
			child();
			return 0;
		}
		pid2=fork();
		if(pid2==0) {
			child();
			return 0;
		}

		booster::ptime::millisleep(100);
		s1.open(io::pf_inet);
		s1.connect(ep);
		int in_pid1=0;
		s1.read(io::buffer(&in_pid1,sizeof(int)));
		s1.close();
		s1.open(io::pf_inet);
		s1.connect(ep);
		int in_pid2=0;
		s1.read(io::buffer(&in_pid2,sizeof(int)));
		s1.close();

		TEST((in_pid1==pid1 && in_pid2==pid2) || (in_pid1==pid2 && in_pid2==pid1));
	
	}
	catch(std::exception const &e) {
		std::cerr << e.what() << std::endl;
		if(pid1!=0) {
			kill(pid1,SIGKILL);
			int r;
			wait(&r);
		}
		if(pid2!=0) {
			kill(pid2,SIGKILL);
			int r;
			wait(&r);
		}
		return 1;
	}
	if(pid1!=0 && pid2!=0) {
		int r1=0,r2=0;
		::wait(&r1);
		::wait(&r2);
		if(	WIFEXITED(r1) && WEXITSTATUS(r1)==0 
			&& WIFEXITED(r2) && WEXITSTATUS(r2)==0) 
		{
			std::cerr << "Ok" <<std::endl;
			return 0;
		}
		return 1;
	}
	return 0;
}
	void Roket_PhysicsBody::applyTorque(irr::core::vector3df torque)
	{
		irr::core::vector3df t2(torque);
		torqueToApply.push_back(t2);
		nonlua_debug("Torque is loaded into stack.",LVL_INFO);
	}
Example #6
0
static void s_TestMisc(int idx)
{
    // AsString()
    {{
        CTime t1;
        assert(t1.AsString() == "");

        CTime t2(2000, 365 / 2);
        t2.SetFormat("M/D/Y h:m:s");
        assert(t2.AsString() == "06/30/2000 00:00:00");
    }}
    
    // Year 2000 problem
    {{
        CTime t(1999, 12, 30); 
        t.SetFormat("M/D/Y");
        t.AddDay();
        assert(t.AsString() == "12/31/1999");
        t.AddDay();
        assert(t.AsString() == "01/01/2000");
        t.AddDay();
        assert(t.AsString() == "01/02/2000");
        t="02/27/2000";
        t.AddDay();
        assert(t.AsString() == "02/28/2000");
        t.AddDay();
        assert(t.AsString() == "02/29/2000");
        t.AddDay();
        assert(t.AsString() == "03/01/2000");
        t.AddDay();
        assert(t.AsString() == "03/02/2000");
    }}

    // String assignment
    {{
        CTime::SetFormat("M/D/Y h:m:s");
        CTime t("02/15/2000 01:12:33");
        assert(t.AsString() == "02/15/2000 01:12:33");
        t = "3/16/2001 02:13:34";
        assert(t.AsString() == "03/16/2001 02:13:34");
    }}

    CTime::SetFormat("M/D/Y h:m:s.S");

    // Adding Nanoseconds
    {{
        CTime t;
        for (CTime ti(1999, 12, 31, 23, 59, 59, 999999995);
             ti <= CTime(2000, 1, 1, 0, 0, 0, 000000003);
             t = ti, ti.AddNanoSecond(2)) {
        }
        assert(t.AsString() == "01/01/2000 00:00:00.000000003");
    }}

    CTime::SetFormat("M/D/Y h:m:s");

    // Adding seconds
    {{
        CTime t;
        for (CTime ti(1999, 12, 31, 23, 59, 5);
             ti <= CTime(2000, 1, 1, 0, 1, 20);
             t = ti, ti.AddSecond(11)) {
        }
        assert(t.AsString() == "01/01/2000 00:01:17");
    }}

    // Adding minutes
    {{
        CTime t;
        for (CTime ti(1999, 12, 31, 23, 45);
             ti <= CTime(2000, 1, 1, 0, 15);
             t = ti, ti.AddMinute(11)) {
        }
        assert(t.AsString() == "01/01/2000 00:07:00");
    }}

    // Adding hours
    {{
        CTime t;
        for (CTime ti(1999, 12, 31); ti <= CTime(2000, 1, 1, 15);
             t = ti, ti.AddHour(11)) {
        }
        assert(t.AsString() == "01/01/2000 09:00:00");
    }}

    // Adding months
    {{
        CTime t;
        for (CTime ti(1998, 12, 29); ti <= CTime(1999, 4, 1);
             t = ti, ti.AddMonth()) {
        }
        assert(t.AsString() == "03/28/1999 00:00:00");
    }}
    
    // Difference
    {{
        CTime t1(2000, 10, 1, 12, 3, 45,1);
        CTime t2(2000, 10, 2, 14, 55, 1,2);

        assert((t2.DiffDay(t1)-1.12) < 0.01);
        assert((t2.DiffHour(t1)-26.85) < 0.01);
        assert((t2.DiffMinute(t1)-1611.27) < 0.01);
        assert(t2.DiffSecond(t1) == 96676);
    }}

    // Database time formats
    {{
        CTime t(2000, 1, 1, 1, 1, 1, 10000000);
        CTime::SetFormat("M/D/Y h:m:s.S");
        
        TDBTimeI dbi = t.GetTimeDBI();

        CTime::SetFormat("M/D/Y h:m:s");
        dbi.days = 37093;
        dbi.time = 12301381;
        t.SetTimeDBI(dbi);
        assert(t.AsString() == "07/23/2001 11:23:24");
    }}
}
Example #7
0
inline void
LQ( DistMatrix<Complex<R>,MC,MR  >& A, 
    DistMatrix<Complex<R>,MD,STAR>& t )
{
#ifndef RELEASE
    PushCallStack("LQ");
    if( A.Grid() != t.Grid() )
        throw std::logic_error("{A,t} must be distributed over the same grid");
#endif
    typedef Complex<R> C;
    const Grid& g = A.Grid();
    if( t.Viewing() )
    {
        if( !t.AlignedWithDiagonal( A ) )
            throw std::logic_error("t was not aligned with A");
        if( t.Height() != std::min(A.Height(),A.Width()) || t.Width() != 1 )
            throw std::logic_error("t was not the appropriate shape");
    }
    else
    {
        t.AlignWithDiagonal( A );
        t.ResizeTo( std::min(A.Height(),A.Width()), 1 );
    }

    // Matrix views
    DistMatrix<C,MC,MR>
        ATL(g), ATR(g),  A00(g), A01(g), A02(g),  ATopPan(g), ABottomPan(g),
        ABL(g), ABR(g),  A10(g), A11(g), A12(g),
                         A20(g), A21(g), A22(g);
    DistMatrix<C,MD,STAR>
        tT(g),  t0(g),
        tB(g),  t1(g),
                t2(g);

    PartitionDownLeftDiagonal
    ( A, ATL, ATR,
         ABL, ABR, 0 );
    PartitionDown
    ( t, tT,
         tB, 0 );
    while( ATL.Height() < A.Height() && ATL.Width() < A.Width() )
    {
        RepartitionDownDiagonal
        ( ATL, /**/ ATR,  A00, /**/ A01, A02,
         /*************/ /******************/
               /**/       A10, /**/ A11, A12,
          ABL, /**/ ABR,  A20, /**/ A21, A22 );

        RepartitionDown
        ( tT,  t0,
         /**/ /**/
               t1,
          tB,  t2 );

        ATopPan.View1x2( A11, A12 );
        ABottomPan.View1x2( A21, A22 );

        //--------------------------------------------------------------------//
        internal::PanelLQ( ATopPan, t1 );
        ApplyPackedReflectors
        ( RIGHT, UPPER, HORIZONTAL, FORWARD, CONJUGATED,
          0, ATopPan, t1, ABottomPan );
        //--------------------------------------------------------------------//

        SlidePartitionDown
        ( tT,  t0,
               t1,
         /**/ /**/
          tB,  t2 );

        SlidePartitionDownDiagonal
        ( ATL, /**/ ATR,  A00, A01, /**/ A02,
               /**/       A10, A11, /**/ A12,
         /*************/ /******************/
          ABL, /**/ ABR,  A20, A21, /**/ A22 );
    }
#ifndef RELEASE
    PopCallStack();
#endif
}
Example #8
0
int main()
{
	struct dbSysHead head;
	long fid1, fid2;

	/*
	≥ı ºªØ£¨»ª∫Û¥Ú”°≥ˆµ±«∞œµÕ≥µƒ–≈œ¢
	*/
	init_database(&head);
	showDesc(&head);

//	printf("create file1...\n");
	fid1 = creatFileSpace(&head);//Œ™Œƒº˛“ª∑÷≈‰ø’º‰
        fid2 = creatFileSpace(&head);
//	showFileDesc(&head);
/*	printf("extend 10 pages for file1...\n");
	extendFileSpace(&head, fid1, 10);//¿©’π Æ“≥
	showFileDesc(&head);
	printf("extend 10 pages for file1...\n");
	extendFileSpace(&head, fid1, 10);//‘Ÿ¿©’π Æ“≥
	showFileDesc(&head);

	printf("create file2...\n");
	fid2 = creatFileSpace(&head);
	showFileDesc(&head);
	printf("extend 10 pages for file2...\n");
	extendFileSpace(&head, fid2, 10);
	showFileDesc(&head);
	printf("extend 10 pages for file2...\n");
	extendFileSpace(&head, fid2, 10);
	showFileDesc(&head);

	printf("delete file1...\n");
	recyFileSpace(&head, fid1);
	showFileDesc(&head);
	printf("delete file2...\n");
	recyFileSpace(&head, fid2);
	showFileDesc(&head);*/
    //use dictID to scan file1
    /*
     int dictID = 1;
     int scanPointer = 0;
     int rec_length = head.redef[dictID].getRecordLength();
     printf("attributeName::%s", head.redef[dictID].getAttributeByNo(0).getName());
     RecordCursor scanTable(&head, 1, rec_length, 0);
     char * one_Row_ = (char *)malloc(sizeof(char)*rec_length);
     while (true == scanTable.getNextRecord(one_Row_)) { //only scan
     scanPointer ++;
     if(scanPointer > 230)
     getOneRecord(one_Row_, head.redef[dictID]); //get each attribute value and print
     }
     free(one_Row_);
     */

//	if(initTable(&head, fid1) == 0)
    if(initTable(&head, FIRST_FID) == 0)
		printf("1 initTable: customer.tbl\n");
	if(showTable(&head, "customer") == -1 )
		printf("2 showTable: customer\n");
    
    if(initTable(&head, FIRST_FID+1) == 0)
        printf("1 initTable: nation.tbl\n");
    if(showTable(&head, "nation") == -1 )
        printf("2 showTable: nation\n");
    //read customer.tbl and write into our file1, 一次性
    loaddata(&head, FIRST_FID);
    

    //Scan Table
    relation * temp_data_dict = new relation[MAX_FILE_NUM];
    TableScan(&head, FIRST_FID, temp_data_dict);
    //get the output of tablescan, temporarily according to datadict1, other than temp_data_dict[1]
    int buffer_ID_ = - temp_data_dict[0].fileID;   //find which buffer
    int record_num_ = temp_data_dict[0].getRecordNum();
    int record_len_ = temp_data_dict[0].getRecordLength();
 //   RecordCursorTmp t1(&head,1,record_len_,buffer_ID_,record_num_);
    cout<<buffer_ID_<<"~"<<record_len_<<"~"<<record_num_<<endl;
 /*   int scanPointer = 0;
    int dictID = queryFileID(&head, FIRST_FID);
    char * one_Row_ = (char *)malloc(sizeof(char)*record_len_);
    while (true == t1.getNextRecord(one_Row_)) { //only scan
        scanPointer ++;
        if(scanPointer < 20)
            getOneRecord(one_Row_, &head.redef[dictID]); //get each attribute value and print
    }
    free(one_Row_);*/
    
    loaddata(&head, FIRST_FID + 1);
    
    TableScan(&head, FIRST_FID + 1, temp_data_dict);
    //get the output of tablescan, temporarily according to datadict1, other than temp_data_dict[1]
    buffer_ID_ = - temp_data_dict[1].fileID;   //find which buffer
    record_num_ = temp_data_dict[1].getRecordNum();
    record_len_ = temp_data_dict[1].getRecordLength();
//    RecordCursorTmp t2(&head,1,record_len_,buffer_ID_,record_num_);
    cout<<buffer_ID_<<"~"<<record_len_<<"~"<<record_num_<<endl;
/*    scanPointer = 0;
    dictID = queryFileID(&head, FIRST_FID + 1);
    char * one_Row_2 = (char *)malloc(sizeof(char)*record_len_);
    while (true == t2.getNextRecord(one_Row_2)) { //only scan
        scanPointer ++;
        if(scanPointer < 20)
            getOneRecord(one_Row_2, &head.redef[dictID]); //get each attribute value and print
    }
    free(one_Row_2);*/

    // create index
/*
    printf("recordNum:%d\n",head.redef[dictID].recordNum);
	if(true == createIndexOn(&head, 1, "custkey")){
		char* index_filename= "b_plus_tree_index_1custkey.dat";
		
		FILE* fp = fopen(index_filename,"rb+");
		printf("search(fp,-10):%d\n",search(fp,-10));
		printf("search(fp,1):%d\n",search(fp,1));
		printf("search(fp,2):%d\n",search(fp,2));
		printf("search(fp,50):%d\n",search(fp,50));
		display(fp);
		fclose(fp);
	}
	
    // insert one record
	relationDefine dic = head.redef[0];
    int size_per_record = dic.recordLength;
    char *oneRec = (char *)malloc(sizeof(char)*size_per_record);
        
	char * insertTest = (char *)malloc(sizeof(char)* 256);
    strcpy(insertTest,"501|Customer#000000001|IVhzIApeRb ot,c,E|15|25-989-741-2988|711.56|BUILDING|to the even, regular platelets. regular, ironic epitaphs nag eHHHHHH|");
    parserOneLineFromFile(insertTest, oneRec, dic);
    insertOneRecord(&head, 1, oneRec);//≤»ΓªÃı ˝æ›£¨◊‘∂Ø∏¸–¬À˜“˝
	free(insertTest);
    free(oneRec);
    
    // look up key in index
	char* index_filename= "b_plus_tree_index_1custkey.dat";
	FILE* fp = fopen(index_filename,"rb+");
	int pos = search(fp,501);
	printf("pos:::%d\n",pos);
	fclose(fp);
	
	
	one_Row_ = (char *)malloc(sizeof(char)*rec_length);
	rdFile( &head, 0, 1, pos, rec_length,one_Row_);
	printf("reading from index:\n");
	getOneRecord(one_Row_, dic);
*/    
    /*
	relation result;
	result.init("customer", "TianzhenWu");
	result.insertAttribute("name", 2, 64);
	result.insertAttribute("phone", 2, 64);
	showRelation(&result);
	project(&head, &temp_data_dict[0], &result);********/

    printf("start tableScanEqualFilter()...\n");
    
//    if(true == tableScanEqualFilter(&head, FIRST_FID, temp_data_dict,"custkey","3",&temp_data_dict[5])){
//	printf("tableScanEqualFilter()\n");
//    }
/*
    if(true == tableScanEqualFilter(&head, FIRST_FID, temp_data_dict,"name","Customer#000000009",&temp_data_dict[5])){
        printf("tableScanEqualFilter()\n");
    }

    buffer_ID_ = - temp_data_dict[5].fileID;   //find which buffer
    record_num_ = temp_data_dict[5].getRecordNum();
    record_len_ = temp_data_dict[5].getRecordLength();
    RecordCursorTmp t2(&head,1,record_len_,buffer_ID_,record_num_);
    cout<<buffer_ID_<<"~"<<record_len_<<"~"<<record_num_<<endl;
    one_Row_ = (char *)malloc(sizeof(char)*record_len_);
    while (true == t2.getNextRecord(one_Row_)) { //only scan
        getOneRecord(one_Row_, &temp_data_dict[5]); //get each attribute value and print
    }
    free(one_Row_);
    //head.buff[buffer_ID_].emptyOrnot = false;

*/
    if(true == tableScanScopeFilter(&head, FIRST_FID, temp_data_dict,"custkey","220",NOT_MORE_THAN,"230",LESS_THAN,&temp_data_dict[5])){
        printf("tableScanScopeFilter()\n");
    }

    buffer_ID_ = - temp_data_dict[5].fileID;   //find which buffer
    record_num_ = temp_data_dict[5].getRecordNum();
    record_len_ = temp_data_dict[5].getRecordLength();
    RecordCursorTmp t2(&head,1,record_len_,buffer_ID_,record_num_);
    cout<<buffer_ID_<<"~"<<record_len_<<"~"<<record_num_<<endl;
    char *one_Row_ = (char *)malloc(sizeof(char)*record_len_);
    while (true == t2.getNextRecord(one_Row_)) { //only scan
        getOneRecord(one_Row_, &temp_data_dict[5]); //get each attribute value and print
    }
    free(one_Row_);
    //head.buff[buffer_ID_].emptyOrnot = false;



    showFileDesc(&head);
    exit_database(&head);
	system("pause");
	return 0;
}
Example #9
0
void tst_QSemaphore::acquire()
{
    {
        // old incrementOne() test
        QVERIFY(!semaphore);
        semaphore = new QSemaphore;
        // make some "thing" available
        semaphore->release();

        ThreadOne t1;
        ThreadOne t2;

        t1.start();
        t2.start();

        QVERIFY(t1.wait(4000));
        QVERIFY(t2.wait(4000));

        delete semaphore;
        semaphore = 0;
    }

    // old incrementN() test
    {
        QVERIFY(!semaphore);
        semaphore = new QSemaphore;
        // make 4 "things" available
        semaphore->release(4);

        ThreadN t1(2);
        ThreadN t2(3);

        t1.start();
        t2.start();

        QVERIFY(t1.wait(4000));
        QVERIFY(t2.wait(4000));

        delete semaphore;
        semaphore = 0;
    }

    QSemaphore semaphore;

    QCOMPARE(semaphore.available(), 0);
    semaphore.release();
    QCOMPARE(semaphore.available(), 1);
    semaphore.release();
    QCOMPARE(semaphore.available(), 2);
    semaphore.release(10);
    QCOMPARE(semaphore.available(), 12);
    semaphore.release(10);
    QCOMPARE(semaphore.available(), 22);

    semaphore.acquire();
    QCOMPARE(semaphore.available(), 21);
    semaphore.acquire();
    QCOMPARE(semaphore.available(), 20);
    semaphore.acquire(10);
    QCOMPARE(semaphore.available(), 10);
    semaphore.acquire(10);
    QCOMPARE(semaphore.available(), 0);
}
Example #10
0
static void add_random_ineq(
    expr_ref_vector& fmls, 
    opt::model_based_opt& mbo,
    random_gen& r,
    svector<int>  const& values,
    unsigned max_vars,
    unsigned max_coeff) 
{
    ast_manager& m = fmls.get_manager();
    arith_util a(m);

    unsigned num_vars = values.size();
    uint_set used_vars;
    vector<var_t> vars;
    int value = 0;
    for (unsigned i = 0; i < max_vars; ++i) {
        unsigned x = r(num_vars);
        if (used_vars.contains(x)) {
            continue;
        }
        used_vars.insert(x);
        int coeff = r(max_coeff + 1);
        if (coeff == 0) {
            continue;
        }
        unsigned sign = r(2);
        coeff = sign == 0 ? coeff : -coeff;
        vars.push_back(var_t(x, rational(coeff)));
        value += coeff*values[x];
    }
    unsigned abs_value = value < 0 ? - value : value;
    // value + k <= 0
    // k <= - value
    // range for k is 2*|value|
    // k <= - value - range
    opt::ineq_type rel = opt::t_le;

    int coeff = 0;
    if (r(4) == 0) {
        rel = opt::t_eq;
        coeff = -value;
    }
    else {
        if (abs_value > 0) {
            coeff = -value - r(2*abs_value);
        }
        else {
            coeff = 0;
        }
        if (coeff != -value && r(3) == 0) {
            rel = opt::t_lt;
        }   
    }
    expr_ref fml(m);
    app_ref t1(m);
    app_ref t2(a.mk_numeral(rational(0), a.mk_real()), m);
    mk_term(vars, rational(coeff), t1);
    switch (rel) {
    case opt::t_eq:
        fml = m.mk_eq(t1, t2);
        break;
    case opt::t_lt:
        fml = a.mk_lt(t1, t2);
        break;
    case opt::t_le:
        fml = a.mk_le(t1, t2);
        break;
    case opt::t_mod:
        NOT_IMPLEMENTED_YET();        
        break;        
    }
    fmls.push_back(fml);
    mbo.add_constraint(vars, rational(coeff), rel);
}
Example #11
0
int CHttpProxyThread::run()
{
    Thread::Link();

    int ret = 0;
    try
    {
        char peername[256];
        int clientport = m_client->peer_name(peername, 256);
        if(httptest_tracelevel > 5)
            fprintf(m_ofile, "\n>>receivd request from %s:%d\n", peername, clientport);

        char oneline[2049];
        memset(oneline, 0, 2049);

        bool socketclosed = false;
        int lenread = readline(m_client.get(), oneline, 2048, socketclosed);

        if(httptest_tracelevel > 40)
            printf("firstline=%s\n", oneline);

        if(strncmp(oneline, "CONNECT ", 8) == 0)
        {
            char* curptr = oneline + 8;
            while(*curptr && *curptr == ' ')
                curptr++;
            const char* hostptr = curptr;
            while(*curptr && *curptr != ':' && *curptr != ' ')
                curptr++;
            int port = 80;
            if(*curptr == ':')
            {
                *curptr = 0;
                curptr++;
                const char* portptr = curptr;
                while(*curptr && *curptr != ' ')
                    curptr++;
                *curptr = 0;
                if(*portptr)
                    port = atoi(portptr);
            }

            StringBuffer host(hostptr);

            while(lenread > 2 && !socketclosed)
                lenread = readline(m_client.get(), oneline, 2048, socketclosed);

            SocketEndpoint ep;
            ep.set(host.str(), port);
            m_remotesocket.setown(ISocket::connect(ep));

            const char* resp = "HTTP/1.0 200 Connection established\r\n"
                                "Proxy-agent: Netscape-Proxy/1.1\r\n\r\n";
            m_client->write(resp, strlen(resp));

            m_client->set_nonblock(false);
            m_remotesocket->set_nonblock(false);
            CReadWriteThread t1(m_client.get(), m_remotesocket.get());
            CReadWriteThread t2(m_remotesocket.get(), m_client.get());
            t1.start();
            t2.start();
            t1.join();
            t2.join();
            //printf("read/write threads returned\n");
            m_remotesocket->shutdown();
            m_remotesocket->close();
            m_client->shutdown();
            m_client->close();
        }
        else
        {
            const char* http = strstr(oneline, "http://");
            if(!http)
                http = strstr(oneline, "HTTP://");

            if(!http)
                throw MakeStringException(-1, "protocol not recognized\n");

            StringBuffer requestbuf;
            requestbuf.append(http - oneline, oneline);
            const char* slash = http + 7;
            while(*slash && *slash != '/' && *slash != ' ' && *slash != '\r')
                slash++;

            if(*slash != '/')
                requestbuf.append('/');
            else
                requestbuf.append(slash);

            Owned<IByteOutputStream> reqstream = createOutputStream(requestbuf);
            receiveData(m_client, reqstream.get(), false, "Proxy-Connection");

            if(httptest_tracelevel > 40)
                printf("%s\n", requestbuf.str());


            const char* hostname = http + 7;
            char* ptr = (char*)hostname;
            while(*ptr && *ptr != ':' && *ptr != '/' && *ptr != ' ')
                ptr++;

            int port = 80;
            if(*ptr == ':')
            {
                *ptr = 0;
                ptr++;
                const char* portptr = ptr;
                while(*ptr && *ptr != ' ' && *ptr != '/')
                    ptr++;
                if(*ptr)
                    *ptr = 0;
                if(portptr)
                    port = atoi(portptr);
            }
            else
                *ptr = 0;

            SocketEndpoint ep;
            ep.set(hostname, port);
            m_remotesocket.setown(ISocket::connect(ep));
            if(httptest_tracelevel > 5)
                fprintf(m_ofile, ">>sending request to %s:%d\n", hostname, port);

            m_remotesocket->write(requestbuf.str(), requestbuf.length());
            StringBuffer respbuf;
            Owned<CSocketOutputStream> respstream = new CSocketOutputStream(m_client.get());
            receiveData(m_remotesocket.get(), respstream.get(), true);

            if(httptest_tracelevel > 5)
                fprintf(m_ofile, ">>receivd response from %s:%d, and sent back to %s:%d:\n", hostname, port, peername, clientport);
            //fprintf(m_ofile, "%s", respbuf.str());

            //m_client->write(respbuf.str(), respbuf.length());
            fflush(m_ofile);

            m_remotesocket->shutdown();
            m_remotesocket->close();
            m_client->shutdown();
            m_client->close();
        }
    }
    catch(IException *excpt)
    {
        StringBuffer errMsg;
        DBGLOG("%s", excpt->errorMessage(errMsg).str());
        ret = -1;
    }
    catch(...)
    {
        DBGLOG("unknown exception");
        ret = -1;
    }

    Thread::Release();

    return 0;
}
Example #12
0
void LSquare
( DistMatrix<Complex<R> >& A,
  DistMatrix<Complex<R>,STAR,STAR>& t )
{
#ifndef RELEASE
    CallStackEntry entry("hermitian_tridiag::LSquare");
    if( A.Grid() != t.Grid() )
        throw std::logic_error("{A,t} must be distributed over the same grid");
#endif
    const Grid& g = A.Grid();
#ifndef RELEASE
    if( g.Height() != g.Width() )
        throw std::logic_error("The process grid must be square");
    if( A.Height() != A.Width() )
        throw std::logic_error("A must be square");
    if( t.Viewing() )
        throw std::logic_error("t must not be a view");
#endif
    typedef Complex<R> C;

    DistMatrix<C,MD,STAR> tDiag(g);
    tDiag.AlignWithDiagonal( A, -1 );
    tDiag.ResizeTo( A.Height()-1, 1 );

    // Matrix views 
    DistMatrix<C> 
        ATL(g), ATR(g),  A00(g), A01(g), A02(g), 
        ABL(g), ABR(g),  A10(g), A11(g), A12(g),
                         A20(g), A21(g), A22(g);
    DistMatrix<C,MD,STAR> tT(g),  t0(g), 
                          tB(g),  t1(g),
                                  t2(g);

    // Temporary distributions
    DistMatrix<C> WPan(g);
    DistMatrix<C,STAR,STAR> t1_STAR_STAR(g);
    DistMatrix<C,STAR,STAR> A11_STAR_STAR(g);
    DistMatrix<C,MC,  STAR> APan_MC_STAR(g),  A11_MC_STAR(g),
                                              A21_MC_STAR(g);
    DistMatrix<C,MR,  STAR> APan_MR_STAR(g),  A11_MR_STAR(g),
                                              A21_MR_STAR(g);
    DistMatrix<C,MC,  STAR> WPan_MC_STAR(g),  W11_MC_STAR(g),
                                              W21_MC_STAR(g);
    DistMatrix<C,MR,  STAR> WPan_MR_STAR(g),  W11_MR_STAR(g),
                                              W21_MR_STAR(g);

    PartitionDownDiagonal
    ( A, ATL, ATR,
         ABL, ABR, 0 );
    PartitionDown
    ( tDiag, tT,
             tB, 0 );
    while( ATL.Height() < A.Height() )
    {
        RepartitionDownDiagonal
        ( ATL, /**/ ATR,  A00, /**/ A01, A02,
         /*************/ /******************/
               /**/       A10, /**/ A11, A12,
          ABL, /**/ ABR,  A20, /**/ A21, A22 );

        RepartitionDown
        ( tT,  t0,
         /**/ /**/
               t1,
          tB,  t2 );
            
        if( A22.Height() > 0 )
        {
            WPan.AlignWith( A11 );
            APan_MC_STAR.AlignWith( A11 );
            WPan_MC_STAR.AlignWith( A11 );
            APan_MR_STAR.AlignWith( A11 );
            WPan_MR_STAR.AlignWith( A11 );
            //----------------------------------------------------------------//
            WPan.ResizeTo( ABR.Height(), A11.Width() );
            APan_MC_STAR.ResizeTo( ABR.Height(), A11.Width() );
            WPan_MC_STAR.ResizeTo( ABR.Height(), A11.Width() );
            APan_MR_STAR.ResizeTo( ABR.Height(), A11.Width() );
            WPan_MR_STAR.ResizeTo( ABR.Height(), A11.Width() );

            hermitian_tridiag::PanelLSquare
            ( ABR, WPan, t1,
              APan_MC_STAR, APan_MR_STAR, WPan_MC_STAR, WPan_MR_STAR );

            PartitionDown
            ( APan_MC_STAR, A11_MC_STAR,
                            A21_MC_STAR, A11.Height() );
            PartitionDown
            ( APan_MR_STAR, A11_MR_STAR,
                            A21_MR_STAR, A11.Height() );
            PartitionDown
            ( WPan_MC_STAR, W11_MC_STAR,
                            W21_MC_STAR, A11.Height() );
            PartitionDown
            ( WPan_MR_STAR, W11_MR_STAR,
                            W21_MR_STAR, A11.Height() );

            LocalTrr2k
            ( LOWER, ADJOINT, ADJOINT,
              C(-1), A21_MC_STAR, W21_MR_STAR,
                     W21_MC_STAR, A21_MR_STAR,
              C(1), A22 );
            //----------------------------------------------------------------//
            WPan_MR_STAR.FreeAlignments();
            APan_MR_STAR.FreeAlignments();
            WPan_MC_STAR.FreeAlignments();
            APan_MC_STAR.FreeAlignments();
            WPan.FreeAlignments();
        }
        else
        {
            A11_STAR_STAR = A11;
            t1_STAR_STAR.ResizeTo( t1.Height(), 1 );

            HermitianTridiag
            ( LOWER, A11_STAR_STAR.Matrix(), t1_STAR_STAR.Matrix() );

            A11 = A11_STAR_STAR;
            t1 = t1_STAR_STAR;
        }

        SlidePartitionDown
        ( tT,  t0,
               t1,
         /**/ /**/
          tB,  t2 );

        SlidePartitionDownDiagonal
        ( ATL, /**/ ATR,  A00, A01, /**/ A02,
               /**/       A10, A11, /**/ A12,
         /*************/ /******************/
          ABL, /**/ ABR,  A20, A21, /**/ A22 );
    }

    // Redistribute from matrix-diagonal form to fully replicated
    t = tDiag;
}
Example #13
0
void
t1 (void)
{
  t2 ();
}
Example #14
0
/**
 *  verbraucht einen Rohstoff einer Mine oder eines Brunnens
 *  an einer (umliegenden) Stelle.
 *
 *  @author OLiver
 */
bool nofBuildingWorker::GetResources(unsigned char type)
{
    //this makes granite mines work everywhere
    if (type == 0 && GAMECLIENT.GetGGS().isEnabled(ADDON_INEXHAUSTIBLE_GRANITEMINES))
        return true;
    // in Map-Resource-Koordinaten konvertieren
    type = RESOURCES_MINE_TO_MAP[type];

    MapPoint mP(0, 0);
    bool found = false;

    // Alle Punkte durchgehen, bis man einen findet, wo man graben kann
    if(GetResourcesOfNode(pos, type))
    {
        mP = pos;
        found = true;
    }

    for(MapCoord tx = gwg->GetXA(pos, 0), r = 1; !found && r <= MINER_RADIUS; tx = gwg->GetXA(tx, pos.y, 0), ++r)
    {
        MapPoint t2(tx, pos.y);
        for(unsigned int i = 2; !found && i < 8; ++i)
        {
            for(MapCoord r2 = 0; !found && r2 < r; t2 = gwg->GetNeighbour(t2,  i % 6), ++r2)
            {
                if(GetResourcesOfNode(t2, type))
                {
                    mP = t2;
                    found = true;
                }
            }
        }
    }

    if(found)
    {
        // Minen / Brunnen unerschöpflich?
        if( (type == 4 && GAMECLIENT.GetGGS().isEnabled(ADDON_EXHAUSTIBLE_WELLS)) ||
                (type != 4 && !GAMECLIENT.GetGGS().isEnabled(ADDON_INEXHAUSTIBLE_MINES)) )
            --gwg->GetNode(mP).resources;
        return true;
    }

    // Hoffe das passt auch, Post verschicken, keine Rohstoffe mehr da
    if (!OutOfRessourcesMsgSent)
    {
        if(GAMECLIENT.GetPlayerID() == this->player)
        {
            std::string error = _("This mine is exhausted");
            if(workplace->GetBuildingType() == BLD_WELL)
                error = _("This well is dried out");

            GAMECLIENT.SendPostMessage(
                new ImagePostMsgWithLocation(_(error), PMC_GENERAL, pos,
                                             workplace->GetBuildingType(), workplace->GetNation())
            );
        }

        OutOfRessourcesMsgSent = true;
        // Produktivitätsanzeige auf 0 setzen
        workplace->SetProductivityToZero();

        // KI-Event erzeugen
        GAMECLIENT.SendAIEvent(new AIEvent::Building(AIEvent::NoMoreResourcesReachable, workplace->GetPos(), workplace->GetBuildingType()), player);
    }

    // Hoffe das passt...
    return false;
}
Example #15
0
static void s_TestFormats(void)
{
    struct SFormatTest {
        const char* format;
        int         truncated; 
    };

    static const SFormatTest s_Fmt[] = {
        {"b D Y h:m:s:r",           1},
        {"b D Y h:m:s:lp",          1},
        {"b D Y H:m:s P",           1},
        {"M/D/Y h:m:s",             1},
        {"M/D/Y h:m:s.S",           0},
        {"M/D/y h:m:s",             1},
        {"M/DY  h:m:s",             1},
        {"M/Dy  h:m:s",             1},
        {"M/D/Y hm:s",              1},
        {"M/D/Y h:ms",              1},
        {"M/D/Y hms",               1},
        {"MD/y  h:m:s",             1},
        {"MD/Y  h:m:s",             1},
        {"MYD   m:h:s",             1},
        {"M/D/Y smh",               1},
        {"YMD   h:sm",              1},
        {"yDM   h:ms",              1},
        {"yMD   h:ms",              1},
        {"D B Y h:m:s",             1},
        {"B d, Y h:m:s",            1},
        {"D b Y h:m:s",             1},
#if !defined(TIMEZONE_IS_UNDEFINED)
        {"M/D/Y h:m:s z",           1},
#endif
        {"M/D/Y Z h:m:s",           1},
        {"smhyMD",                  1},
        {"y||||M++++D   h===ms",    1},
        {"   yM[][D   h:,.,.,ms  ", 1},
        {"\tkkkMy++D   h:ms\n",     1},
        {0,0}
    };

    for ( int hour = 0; hour < 24; ++hour ) {
        for (int i = 0;  s_Fmt[i].format;  i++) {
            const char* fmt = s_Fmt[i].format;
            
            bool is_gmt = (strchr(fmt, 'Z') ||  strchr(fmt, 'z'));
            CTime t1(2001, 4, 2, hour, 4, 5, 88888888,
                     is_gmt ? CTime::eGmt : CTime::eLocal);
            
            CTime::SetFormat(fmt);
            string t1_str = t1.AsString();
            CTime::SetFormat("MDY__s");
            CTime t2(t1_str, fmt);
            if ( s_Fmt[i].truncated ) {
                string test_str = t2.AsString("M/D/Y h:m:s");
                CNcbiOstrstream s;
                s << "04/02/2001 " << hour/10 << hour%10 << ":04:05";
                string need_str = CNcbiOstrstreamToString(s);
                assert(test_str == need_str);
            } else {
                assert(t1 == t2);
            }
            CTime::SetFormat(fmt);
            string t2_str = t2;
            assert(t1_str.compare(t2_str) == 0);
        }
    }

    // Check against well-known dates
    {{
        const char fmtstr[] = "M/D/Y h:m:s Z W";
        {{
            CTime t(2003, 2, 10, 20, 40, 30, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("02/10/2003 20:40:30 GMT Monday") == 0);
        }}
        {{
            CTime t(1998, 2, 10, 20, 40, 30, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("02/10/1998 20:40:30 GMT Tuesday") == 0);
        }}
        {{
            CTime t(2003, 3, 13, 15, 49, 30, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("03/13/2003 15:49:30 GMT Thursday") == 0);
        }}
        {{
            CTime t(2001, 3, 13, 15, 49, 30, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("03/13/2001 15:49:30 GMT Tuesday") == 0);
        }}
        {{
            CTime t(2002, 12, 31, 23, 59, 59, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("12/31/2002 23:59:59 GMT Tuesday") == 0);
        }}
        {{
            CTime t(2003, 1, 1, 0, 0, 0, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("01/01/2003 00:00:00 GMT Wednesday") == 0);
        }}
        {{
            CTime t(2002, 12, 13, 12, 34, 56, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("12/13/2002 12:34:56 GMT Friday") == 0);
        }}
    }}
    {{
        const char fmtstr[] = "M/D/Y H:m:s P Z W";
        {{
            CTime t(2003, 2, 10, 20, 40, 30, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("02/10/2003 08:40:30 PM GMT Monday") == 0);
        }}
        {{
            CTime t(1998, 2, 10, 20, 40, 30, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("02/10/1998 08:40:30 PM GMT Tuesday") == 0);
        }}
        {{
            CTime t(2003, 3, 13, 15, 49, 30, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("03/13/2003 03:49:30 PM GMT Thursday") == 0);
        }}
        {{
            CTime t(2001, 3, 13, 15, 49, 30, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("03/13/2001 03:49:30 PM GMT Tuesday") == 0);
        }}
        {{
            CTime t(2002, 12, 31, 23, 59, 59, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("12/31/2002 11:59:59 PM GMT Tuesday") == 0);
        }}
        {{
            CTime t(2003, 1, 1, 0, 0, 0, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("01/01/2003 12:00:00 AM GMT Wednesday") == 0);
        }}
        {{
            CTime t(2002, 12, 13, 12, 34, 56, 0, CTime::eGmt);
            t.SetFormat(fmtstr);
            string s = t.AsString();
            assert(s.compare("12/13/2002 12:34:56 PM GMT Friday") == 0);
        }}
    }}

    // Partialy defined time
    {{
        string s;
        {{  // Y
            CTime t("2001", "Y");
            s = t.AsString("M/D/Y h:m:s");
            assert(s.compare("01/01/2001 00:00:00") == 0);
        }}
        {{  // Y/M
            CTime t("2001/2", "Y/M");
            s = t.AsString("M/D/Y h:m:s");
            assert(s.compare("02/01/2001 00:00:00") == 0);
        }}
        {{  // M/D
            CTime current(CTime::eCurrent);
            current.Truncate();
            CTime t("01/02", "M/D");
            current.SetMonth(1);
            current.SetDay(2);
            assert(t == current);
        }}
        {{  // M
            CTime current(CTime::eCurrent);
            current.Truncate();
            CTime t("2", "M");
            current.SetMonth(2);
            current.SetDay(1);
            assert(t == current);
        }}
        {{  // D time
            CTime current(CTime::eCurrent);
            current.Truncate();
            CTime t("2 11:22", "D h:m");
            current.SetDay(2);
            current.SetHour(11);
            current.SetMinute(22);
            assert(t == current);
        }}
        {{  // D
            CTime current(CTime::eCurrent);
            current.Truncate();
            CTime t("2", "D");
            current.SetDay(2);
            assert(t == current);
        }}
        {{  // time
            CTime current(CTime::eCurrent);
            CTime t("11:22", "h:m");
            current.SetHour(11);
            current.SetMinute(22);
            current.SetSecond(0);
            current.SetNanoSecond(0);
            assert(t == current);
        }}

        try {
            CTime t("2001/2 00:00", "Y/M h:m");
            _TROUBLE; // day is not defined
        }
        catch (CTimeException&) {}

        try {
            CTime t("2001/2 00:00", "Y/D h:m");
            _TROUBLE; // month is not defined
        }
        catch (CTimeException&) {}

        try {
            CTime t("2001/2", "Y/D");
            _TROUBLE; // month is not defined
        }
        catch (CTimeException&) {}

        try {
            CTime t("2001 00:00", "Y h:m");
            _TROUBLE; // month and day are not defined
        }
        catch (CTimeException&) {}

        try {
            CTime t("2 00:00", "M h:m");
            _TROUBLE; // year and day are not defined
        }
        catch (CTimeException&) {}
    }}

    // Strict/weak time assignment from a astring
    {{
        string s;
        {{
            CTime t("2001", CTimeFormat("Y/M/D", CTimeFormat::fMatch_ShortTime));
            s = t.AsString("M/D/Y h:m:s");
            assert(s.compare("01/01/2001 00:00:00") == 0);
        }}
        {{
            // Note that day and month changed
            CTime t("2001/01/02", CTimeFormat("Y", CTimeFormat::fMatch_ShortFormat));
            s = t.AsString("M/D/Y h:m:s");
            assert(s.compare("01/01/2001 00:00:00") == 0);
        }}
        {{
            CTime t("2001", CTimeFormat("Y/M/D", CTimeFormat::fMatch_Weak));
            s = t.AsString("M/D/Y h:m:s");
            assert(s.compare("01/01/2001 00:00:00") == 0);
        }}
        {{
            // Note that day and month changed
            CTime t("2001/01/02", CTimeFormat("Y", CTimeFormat::fMatch_Weak));
            s = t.AsString("M/D/Y h:m:s");
            assert(s.compare("01/01/2001 00:00:00") == 0);
        }}
        {{  
            try {
                CTime t("2001", "Y/M/D");
                _TROUBLE;  // by default used strict format matching
            }
            catch (CTimeException&) {}
            try {
                CTime t("2001/01/02", "Y");
                _TROUBLE;  // by default used strict format matching
            }
            catch (CTimeException&) {}
        }}
    }}

    // SetFormat/AsString with flag parameter test
    {{
        CTime t(2003, 2, 10, 20, 40, 30, 0, CTime::eGmt);
        string s;
        s = t.AsString("M/D/Y h:m:s");
        assert(s.compare("02/10/2003 20:40:30") == 0);
        s = t.AsString("MDY $M/$D/$Y $h:$m:$s hms");
        assert(s.compare("02102003 $02/$10/$2003 $20:$40:$30 204030") == 0);
        s = t.AsString(CTimeFormat("MDY $M/$D/$Y $h:$m:$s hms",
                                   CTimeFormat::eNcbi));
        assert(s.compare("MDY 02/10/2003 20:40:30 hms") == 0);
    }}

    // CTimeFormat::GetPredefined() test
    {{
        CTime t(2003, 2, 10, 20, 40, 30, 123456789, CTime::eGmt);
        string s;
        s = t.AsString(CTimeFormat::GetPredefined(CTimeFormat::eISO8601_Year));
        assert(s.compare("2003") == 0);
        s = t.AsString(CTimeFormat::GetPredefined(CTimeFormat::eISO8601_YearMonth));
        assert(s.compare("2003-02") == 0);
        s = t.AsString(CTimeFormat::GetPredefined(CTimeFormat::eISO8601_Date));
        assert(s.compare("2003-02-10") == 0);
        s = t.AsString(CTimeFormat::GetPredefined(CTimeFormat::eISO8601_DateTimeMin));
        assert(s.compare("2003-02-10T20:40") == 0);
        s = t.AsString(CTimeFormat::GetPredefined(CTimeFormat::eISO8601_DateTimeSec));
        assert(s.compare("2003-02-10T20:40:30") == 0);
        s = t.AsString(CTimeFormat::GetPredefined(CTimeFormat::eISO8601_DateTimeFrac));
        assert(s.compare("2003-02-10T20:40:30.123") == 0);
    }}

    // Test assignment operator in different (from default) time format
    {{
        CTime t0(2003, 2, 10, 20, 40, 30, 0, CTime::eLocal);
        CTime::SetFormat(CTimeFormat::GetPredefined(
                                CTimeFormat::eISO8601_DateTimeMin,
                                CTimeFormat::eNcbi));
        assert(t0.AsString() == "2003-02-10T20:40");
        CTime t("2003-02-10T20:40");
        t.SetSecond(30);
        assert(t == t0);
    }}
}
Example #16
0
void run_test(int TEAMSIZE, int VECTORSIZE, int numpools){


  const int leage_size = 100;
  typedef Kokkos::TeamPolicy<MyExecSpace1> team_policy_t ;

  team_policy_t my_policy_t1 (leage_size, Kokkos::AUTO_t(), 1);
  team_policy_t my_policy_t2 (leage_size, Kokkos::AUTO_t(), 2);
  team_policy_t my_policy_t4 (leage_size, Kokkos::AUTO_t(), 4);
  team_policy_t my_policy_t8 (leage_size, Kokkos::AUTO_t(), 8);
  team_policy_t my_policy_t16 (leage_size, Kokkos::AUTO_t(), 16);
  team_policy_t my_policy_t32 (leage_size, Kokkos::AUTO_t(), 32);

  std::cout << "my_policy_t1.teamsize():" << my_policy_t1.team_size()
            << " my_policy_t2.teamsize():" << my_policy_t2.team_size()
            << " my_policy_t4.teamsize():" << my_policy_t4.team_size()
            << " my_policy_t8.teamsize():" << my_policy_t8.team_size()
            << " my_policy_t16.teamsize():" << my_policy_t16.team_size()
            << " my_policy_t32.teamsize():" << my_policy_t32.team_size()
            << std::endl;



  typedef typename KokkosKernels::Experimental::Util::UniformMemoryPool<MyExecSpace1, idx> simple_pool1;

  int chunk_size = 32;
  int space_1_concurrency  = MyExecSpace1::concurrency() / VECTORSIZE;

  simple_pool1 space1_one2one_mp (space_1_concurrency, chunk_size, -1, KokkosKernels::Experimental::Util::OneThread2OneChunk);
  simple_pool1 space1_many2one_mp (numpools, chunk_size, -1, KokkosKernels::Experimental::Util::ManyThread2OneChunk);

  MemoryPoolTest<simple_pool1, MyExecSpace1> t1 (space1_one2one_mp);
  MemoryPoolTest<simple_pool1, MyExecSpace1> t2 (space1_many2one_mp);


  printf("\n\nRunning One2One\n");
  printf("Memory Pool\n");
  space1_one2one_mp.print_memory_pool();

  Kokkos::Impl::Timer timer1;
  Kokkos::parallel_for( team_policy_t(leage_size , Kokkos::AUTO_t(), VECTORSIZE), t1);
  MyExecSpace1::fence();
  std::cout << "One to One Time:" << timer1.seconds() << std::endl;

  timer1.reset();
  Kokkos::parallel_for( my_policy_t1, t1);
  MyExecSpace1::fence();
  std::cout << "team_policy_t1:" << timer1.seconds() << std::endl;

  timer1.reset();
  Kokkos::parallel_for( my_policy_t2, t1);
  MyExecSpace1::fence();
  std::cout << "team_policy_t2:" << timer1.seconds() << std::endl;

  timer1.reset();
  Kokkos::parallel_for( my_policy_t4, t1);
  MyExecSpace1::fence();
  std::cout << "my_policy_t4:" << timer1.seconds() << std::endl;



  printf("\n\nRunning Many2One\n");
  printf("Memory Pool\n");
  space1_many2one_mp.print_memory_pool();
  timer1.reset();
  Kokkos::parallel_for( team_policy_t(leage_size, TEAMSIZE, VECTORSIZE), t2);
  MyExecSpace1::fence();
  std::cout << "Many to One Time:" << timer1.seconds() << std::endl;


}
Example #17
0
static void s_TestGMT(int idx)
{
    // Write time in timezone format
    {{   
        CTime::SetFormat("M/D/Y h:m:s Z");
        CTime t1(2001, 3, 12, 11, 22, 33, 999, CTime::eGmt);
        assert(t1.AsString() == "03/12/2001 11:22:33 GMT");
        CTime t2(2001, 3, 12, 11, 22, 33, 999, CTime::eLocal);
        assert(t2.AsString() == "03/12/2001 11:22:33 ");
    }}

    // Process timezone string
    {{   
        CTime t;
        t.SetFormat("M/D/Y h:m:s Z");
        t="03/12/2001 11:22:33 GMT";
        assert(t.AsString() == "03/12/2001 11:22:33 GMT");
        t="03/12/2001 11:22:33 ";
        assert(t.AsString() == "03/12/2001 11:22:33 ");
    }}

    // Day of week
    {{   
        CTime t(2001, 4, 1);
        t.SetFormat("M/D/Y h:m:s w");
        int i;
        for (i=0; t<=CTime(2001, 4, 10); t.AddDay(),i++) {
            assert(t.DayOfWeek() == (i%7));
        }
    }}

    // Test GetTimeT
    {{  
        time_t timer = time(0);
        CTime tgmt(CTime::eCurrent, CTime::eGmt, CTime::eTZPrecisionDefault);
        CTime tloc(CTime::eCurrent, CTime::eLocal, CTime::eTZPrecisionDefault);
        CTime t(timer);
        // Set the same time to all time objects
        tgmt.SetTimeT(timer);
        tloc.SetTimeT(timer);

        assert(timer == t.GetTimeT());
        assert(timer == tgmt.GetTimeT());
        // On the day of changing to summer/winter time, the local time
        // converted to GMT may differ from the value returned by time(0),
        // because in the common case API don't know if DST is in effect for
        // specified local time or not (see mktime()).
        time_t l_ = tloc.GetTimeT();
        if (timer != l_ ) {
            if ( abs((int)(timer - l_)) > 3600 )
                assert(timer == l_);
        }
    }}

    // Test TimeZoneOffset (1) -- EST timezone only
    {{   
        CTime tw(2001, 1, 1, 12); 
        CTime ts(2001, 6, 1, 12);
        assert(tw.TimeZoneOffset() / 3600 == -5);
        assert(ts.TimeZoneOffset()/3600 == -4);
    }}

    // Test TimeZoneOffset (2) -- EST timezone only
    {{   
        CTime tw(2001, 6, 1, 12); 
        CTime ts(2002, 1, 1, 12);
        assert(tw.TimeZoneOffset() / 3600 == -4);
        assert(ts.TimeZoneOffset() / 3600 == -5);
    }}

    // Test AdjustTime
    {{   
        CTime::SetFormat("M/D/Y h:m:s");
        CTime t("03/11/2007 01:01:00");
        CTime tn;
        t.SetTimeZonePrecision(CTime::eTZPrecisionDefault);

        // GMT
        t.SetTimeZone(CTime::eGmt);
        tn = t;
        tn.AddDay(5);  
        assert(tn.AsString() == "03/16/2007 01:01:00");
        tn = t;
        tn.AddDay(40); 
        assert(tn.AsString() == "04/20/2007 01:01:00");

        // Local eNone
        t.SetTimeZone(CTime::eLocal);
        t.SetTimeZonePrecision(CTime::eNone);
        tn = t;
        tn.AddDay(5);
        assert(tn.AsString() == "03/16/2007 01:01:00");
        tn = t;
        tn.AddDay(40);
        assert(tn.AsString() == "04/20/2007 01:01:00");

        //Local eMonth
        t.SetTimeZonePrecision(CTime::eMonth);
        tn = t;
        tn.AddDay(5);
        assert(tn.AsString() == "03/16/2007 01:01:00");
        tn = t; 
        tn.AddMonth(-1);
        assert(tn.AsString() == "02/11/2007 01:01:00");
        tn = t; 
        tn.AddMonth(+1);
        assert(tn.AsString() == "04/11/2007 02:01:00");

        // Local eDay
        t.SetTimeZonePrecision(CTime::eDay);
        tn = t;
        tn.AddDay(-1); 
        assert(tn.AsString() == "03/10/2007 01:01:00");
        tn.AddDay();   
        assert(tn.AsString() == "03/11/2007 01:01:00");
        tn = t;
        tn.AddDay(); 
        assert(tn.AsString() == "03/12/2007 02:01:00");

        // Local eHour
        t.SetTimeZonePrecision(CTime::eHour);
        tn = t; 
        tn.AddHour(-3);
        CTime te = t; 
        te.AddHour(3);
        assert(tn.AsString() == "03/10/2007 22:01:00");
        assert(te.AsString() == "03/11/2007 05:01:00");
        CTime th = tn; 
        th.AddHour(49);
        assert(th.AsString() == "03/13/2007 00:01:00");

        tn = "11/04/2007 00:01:00"; 
        tn.SetTimeZonePrecision(CTime::eHour);
        te = tn; 
        tn.AddHour(-3); 
        te.AddHour(9);
        assert(tn.AsString() == "11/03/2007 21:01:00");
        assert(te.AsString() == "11/04/2007 08:01:00");
        th = tn; 
        th.AddHour(49);
        assert(th.AsString() == "11/05/2007 21:01:00");

        tn = "11/04/2007 09:01:00"; 
        tn.SetTimeZonePrecision(CTime::eHour);
        te = tn; 
        tn.AddHour(-10); 
        te.AddHour(+10);
        assert(tn.AsString() == "11/04/2007 00:01:00");
        assert(te.AsString() == "11/04/2007 19:01:00");
    }}
}
int main()
{
    {  // https://bugs.llvm.org/show_bug.cgi?id=18843
    std::shared_ptr<T const> t1(new T);
    std::shared_ptr<T const> t2(std::make_shared<T>());
    }
    { // https://bugs.llvm.org/show_bug.cgi?id=27115
    int x = 42;
    std::shared_ptr<Bar> t1(new Bar(42));
    assert(t1->shared_from_this() == t1);
    std::shared_ptr<Bar> t2(std::make_shared<Bar>(x));
    assert(t2->shared_from_this() == t2);
    }
    {
    std::shared_ptr<Y> p(new Z);
    std::shared_ptr<T> q = p->shared_from_this();
    assert(p == q);
    assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
    }
    {
    std::shared_ptr<Y> p = std::make_shared<Z>();
    std::shared_ptr<T> q = p->shared_from_this();
    assert(p == q);
    assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
    }
    {
      typedef std::shared_ptr<PrivateBase> APtr;
      APtr a1 = std::make_shared<PrivateBase>();
      assert(a1.use_count() == 1);
    }
    // Test LWG issue 2529. Only reset '__weak_ptr_' when it's already expired.
    // https://cplusplus.github.io/LWG/lwg-defects.html#2529
    // Test two different ways:
    // * Using 'weak_from_this().expired()' in C++17.
    // * Using 'shared_from_this()' in all dialects.
    {
        assert(globalMemCounter.checkOutstandingNewEq(0));
        T* ptr = new T;
        std::shared_ptr<T> s(ptr);
        {
            // Don't re-initialize the "enable_shared_from_this" base
            // because it already references a non-expired shared_ptr.
            std::shared_ptr<T> s2(ptr, &nullDeleter);
        }
#if TEST_STD_VER > 14
        // The enable_shared_from_this base should still be referencing
        // the original shared_ptr.
        assert(!ptr->weak_from_this().expired());
#endif
#ifndef TEST_HAS_NO_EXCEPTIONS
        {
            try {
                std::shared_ptr<T> new_s = ptr->shared_from_this();
                assert(new_s == s);
            } catch (std::bad_weak_ptr const&) {
                assert(false);
            } catch (...) {
                assert(false);
            }
        }
#endif
        s.reset();
        assert(globalMemCounter.checkOutstandingNewEq(0));
    }
    // Test LWG issue 2529 again. This time check that an expired pointer
    // is replaced.
    {
        assert(globalMemCounter.checkOutstandingNewEq(0));
        T* ptr = new T;
        std::weak_ptr<T> weak;
        {
            std::shared_ptr<T> s(ptr, &nullDeleter);
            assert(ptr->shared_from_this() == s);
            weak = s;
            assert(!weak.expired());
        }
        assert(weak.expired());
        weak.reset();

#ifndef TEST_HAS_NO_EXCEPTIONS
        try {
            TEST_IGNORE_NODISCARD ptr->shared_from_this();
            assert(false);
        } catch (std::bad_weak_ptr const&) {
        } catch (...) { assert(false); }
#endif
        {
            std::shared_ptr<T> s2(ptr, &nullDeleter);
            assert(ptr->shared_from_this() == s2);
        }
        delete ptr;
        assert(globalMemCounter.checkOutstandingNewEq(0));
    }
    // Test weak_from_this_methods
#if TEST_STD_VER > 14
    {
        T* ptr = new T;
        const T* cptr = ptr;

        static_assert(noexcept(ptr->weak_from_this()), "Operation must be noexcept");
        static_assert(noexcept(cptr->weak_from_this()), "Operation must be noexcept");

        std::weak_ptr<T> my_weak = ptr->weak_from_this();
        assert(my_weak.expired());

        std::weak_ptr<T const> my_const_weak = cptr->weak_from_this();
        assert(my_const_weak.expired());

        // Enable shared_from_this with ptr.
        std::shared_ptr<T> sptr(ptr);
        my_weak = ptr->weak_from_this();
        assert(!my_weak.expired());
        assert(my_weak.lock().get() == ptr);
    }
#endif
}
Example #19
0
inline void
RLHF
( Conjugation conjugation, int offset, 
  const DistMatrix<Complex<R> >& H,
  const DistMatrix<Complex<R>,MD,STAR>& t,
        DistMatrix<Complex<R> >& A )
{
#ifndef RELEASE
    PushCallStack("apply_packed_reflectors::RLHF");
    if( H.Grid() != t.Grid() || t.Grid() != A.Grid() )
        throw std::logic_error
        ("{H,t,A} must be distributed over the same grid");
    if( offset > 0 || offset < -H.Width() )
        throw std::logic_error("Transforms out of bounds");
    if( H.Width() != A.Width() )
        throw std::logic_error
        ("Width of transforms must equal width of target matrix");
    if( t.Height() != H.DiagonalLength( offset ) )
        throw std::logic_error("t must be the same length as H's offset diag");
    if( !t.AlignedWithDiagonal( H, offset ) )
        throw std::logic_error("t must be aligned with H's 'offset' diagonal");
#endif
    typedef Complex<R> C;
    const Grid& g = H.Grid();

    DistMatrix<C>
        HTL(g), HTR(g),  H00(g), H01(g), H02(g),  HPan(g), HPanCopy(g),
        HBL(g), HBR(g),  H10(g), H11(g), H12(g),
                         H20(g), H21(g), H22(g);
    DistMatrix<C> ALeft(g);
    DistMatrix<C,MD,STAR>
        tT(g),  t0(g),
        tB(g),  t1(g),
                t2(g);

    DistMatrix<C,STAR,VR  > HPan_STAR_VR(g);
    DistMatrix<C,STAR,MR  > HPan_STAR_MR(g);
    DistMatrix<C,STAR,STAR> t1_STAR_STAR(g);
    DistMatrix<C,STAR,STAR> SInv_STAR_STAR(g);
    DistMatrix<C,STAR,MC  > ZAdj_STAR_MC(g);
    DistMatrix<C,STAR,VC  > ZAdj_STAR_VC(g);

    LockedPartitionDownDiagonal
    ( H, HTL, HTR,
         HBL, HBR, 0 );
    LockedPartitionDown
    ( t, tT,
         tB, 0 );
    while( HTL.Height() < H.Height() && HTL.Width() < H.Width() )
    {
        LockedRepartitionDownDiagonal
        ( HTL, /**/ HTR,  H00, /**/ H01, H02,
         /*************/ /******************/
               /**/       H10, /**/ H11, H12,
          HBL, /**/ HBR,  H20, /**/ H21, H22 );

        const int HPanWidth = H10.Width() + H11.Width();
        const int HPanOffset = 
            std::min( H11.Height(), std::max(-offset-H00.Height(),0) );
        const int HPanHeight = H11.Height()-HPanOffset;
        LockedView
        ( HPan, H, H00.Height()+HPanOffset, 0, HPanHeight, HPanWidth );

        LockedRepartitionDown
        ( tT,  t0,
         /**/ /**/
               t1,
          tB,  t2, HPanHeight );

        View( ALeft, A, 0, 0, A.Height(), HPanWidth );

        HPan_STAR_MR.AlignWith( ALeft );
        ZAdj_STAR_MC.AlignWith( ALeft );
        ZAdj_STAR_VC.AlignWith( ALeft );
        Zeros( HPan.Height(), ALeft.Height(), ZAdj_STAR_MC );
        Zeros( HPan.Height(), HPan.Height(), SInv_STAR_STAR );
        //--------------------------------------------------------------------//
        HPanCopy = HPan;
        MakeTrapezoidal( RIGHT, LOWER, offset, HPanCopy );
        SetDiagonal( RIGHT, offset, HPanCopy, C(1) );

        HPan_STAR_VR = HPanCopy;
        Herk
        ( UPPER, NORMAL,
          C(1), HPan_STAR_VR.LockedMatrix(),
          C(0), SInv_STAR_STAR.Matrix() );
        SInv_STAR_STAR.SumOverGrid();
        t1_STAR_STAR = t1;
        FixDiagonal( conjugation, t1_STAR_STAR, SInv_STAR_STAR );

        HPan_STAR_MR = HPan_STAR_VR;
        LocalGemm
        ( NORMAL, ADJOINT,
          C(1), HPan_STAR_MR, ALeft, C(0), ZAdj_STAR_MC );
        ZAdj_STAR_VC.SumScatterFrom( ZAdj_STAR_MC );

        LocalTrsm
        ( LEFT, UPPER, ADJOINT, NON_UNIT,
          C(1), SInv_STAR_STAR, ZAdj_STAR_VC );

        ZAdj_STAR_MC = ZAdj_STAR_VC;
        LocalGemm
        ( ADJOINT, NORMAL,
          C(-1), ZAdj_STAR_MC, HPan_STAR_MR, C(1), ALeft );
        //--------------------------------------------------------------------//
        HPan_STAR_MR.FreeAlignments();
        ZAdj_STAR_MC.FreeAlignments();
        ZAdj_STAR_VC.FreeAlignments();

        SlideLockedPartitionDownDiagonal
        ( HTL, /**/ HTR,  H00, H01, /**/ H02,
               /**/       H10, H11, /**/ H12,
         /*************/ /******************/
          HBL, /**/ HBR,  H20, H21, /**/ H22 );

        SlideLockedPartitionDown
        ( tT,  t0,
               t1,
         /**/ /**/
          tB,  t2 );
    }
#ifndef RELEASE
    PopCallStack();
#endif
}
void LLInventoryPanel::modelChanged(U32 mask)
{
	static LLFastTimer::DeclareTimer FTM_REFRESH("Inventory Refresh");
	LLFastTimer t2(FTM_REFRESH);

	bool handled = false;

	if (!mViewsInitialized) return;
	
	const LLInventoryModel* model = getModel();
	if (!model) return;

	const LLInventoryModel::changed_items_t& changed_items = model->getChangedIDs();
	if (changed_items.empty()) return;

	for (LLInventoryModel::changed_items_t::const_iterator items_iter = changed_items.begin();
		 items_iter != changed_items.end();
		 ++items_iter)
	{
		const LLUUID& item_id = (*items_iter);
		const LLInventoryObject* model_item = model->getObject(item_id);
		LLFolderViewItem* view_item = mFolderRoot->getItemByID(item_id);

		// LLFolderViewFolder is derived from LLFolderViewItem so dynamic_cast from item
		// to folder is the fast way to get a folder without searching through folders tree.
		LLFolderViewFolder* view_folder = dynamic_cast<LLFolderViewFolder*>(view_item);

		//////////////////////////////
		// LABEL Operation
		// Empty out the display name for relabel.
		if (mask & LLInventoryObserver::LABEL)
		{
			handled = true;
			if (view_item)
			{
				// Request refresh on this item (also flags for filtering)
				LLInvFVBridge* bridge = (LLInvFVBridge*)view_item->getListener();
				if(bridge)
				{	// Clear the display name first, so it gets properly re-built during refresh()
					bridge->clearDisplayName();

					view_item->refresh();
				}
			}
		}

		//////////////////////////////
		// REBUILD Operation
		// Destroy and regenerate the UI.
		if (mask & LLInventoryObserver::REBUILD)
		{
			handled = true;
			if (model_item && view_item)
			{
				view_item->destroyView();
			}
			view_item = buildNewViews(item_id);
			view_folder = dynamic_cast<LLFolderViewFolder *>(view_item);
		}

		//////////////////////////////
		// INTERNAL Operation
		// This could be anything.  For now, just refresh the item.
		if (mask & LLInventoryObserver::INTERNAL)
		{
			if (view_item)
			{
				view_item->refresh();
			}
		}

		//////////////////////////////
		// SORT Operation
		// Sort the folder.
		if (mask & LLInventoryObserver::SORT)
		{
			if (view_folder)
			{
				view_folder->requestSort();
			}
		}	

		// We don't typically care which of these masks the item is actually flagged with, since the masks
		// may not be accurate (e.g. in the main inventory panel, I move an item from My Inventory into
		// Landmarks; this is a STRUCTURE change for that panel but is an ADD change for the Landmarks
		// panel).  What's relevant is that the item and UI are probably out of sync and thus need to be
		// resynchronized.
		if (mask & (LLInventoryObserver::STRUCTURE |
					LLInventoryObserver::ADD |
					LLInventoryObserver::REMOVE))
		{
			handled = true;

			//////////////////////////////
			// ADD Operation
			// Item exists in memory but a UI element hasn't been created for it.
			if (model_item && !view_item)
			{
				// Add the UI element for this item.
				buildNewViews(item_id);
				// Select any newly created object that has the auto rename at top of folder root set.
				if(mFolderRoot->getRoot()->needsAutoRename())
				{
					setSelection(item_id, FALSE);
				}
			}

			//////////////////////////////
			// STRUCTURE Operation
			// This item already exists in both memory and UI.  It was probably reparented.
			else if (model_item && view_item)
			{
				// Don't process the item if it is the root
				if (view_item->getRoot() != view_item)
				{
					LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolderRoot->getItemByID(model_item->getParentUUID());
					// Item has been moved.
					if (view_item->getParentFolder() != new_parent)
					{
						if (new_parent != NULL)
						{
							// Item is to be moved and we found its new parent in the panel's directory, so move the item's UI.
							view_item->getParentFolder()->extractItem(view_item);
							view_item->addToFolder(new_parent, mFolderRoot);
						}
						else
						{
							// Item is to be moved outside the panel's directory (e.g. moved to trash for a panel that
							// doesn't include trash).  Just remove the item's UI.
							view_item->destroyView();
						}
					}
				}
			}

			//////////////////////////////
			// REMOVE Operation
			// This item has been removed from memory, but its associated UI element still exists.
			else if (!model_item && view_item)
			{
				// Remove the item's UI.
				view_item->destroyView();
			}
		}
	}
}
Example #21
0
inline void
RUVF
( Conjugation conjugation, Int offset, 
  const DistMatrix<F>& H, const DistMatrix<F,MD,STAR>& t, DistMatrix<F>& A )
{
#ifndef RELEASE
    CallStackEntry cse("apply_packed_reflectors::RUVF");
    if( H.Grid() != t.Grid() || t.Grid() != A.Grid() )
        LogicError("{H,t,A} must be distributed over the same grid");
    // TODO: Proper dimension checks
    if( t.Height() != H.DiagonalLength(offset) )
        LogicError("t must be the same length as H's offset diag");
    if( !t.AlignedWithDiagonal( H, offset ) )
        LogicError("t must be aligned with H's 'offset' diagonal");
#endif
    const Grid& g = H.Grid();
    DistMatrix<F>
        HTL(g), HTR(g),  H00(g), H01(g), H02(g),  HPan(g), HPanCopy(g),
        HBL(g), HBR(g),  H10(g), H11(g), H12(g),
                         H20(g), H21(g), H22(g);
    DistMatrix<F> ALeft(g);
    DistMatrix<F,MD,STAR>
        tT(g),  t0(g),
        tB(g),  t1(g),
                t2(g);

    DistMatrix<F,VC,  STAR> HPan_VC_STAR(g);
    DistMatrix<F,MR,  STAR> HPan_MR_STAR(g);
    DistMatrix<F,STAR,STAR> t1_STAR_STAR(g);
    DistMatrix<F,STAR,STAR> SInv_STAR_STAR(g);
    DistMatrix<F,STAR,MC  > ZAdj_STAR_MC(g);
    DistMatrix<F,STAR,VC  > ZAdj_STAR_VC(g);

    LockedPartitionDownOffsetDiagonal
    ( offset,
      H, HTL, HTR,
         HBL, HBR, 0 );
    LockedPartitionDown
    ( t, tT,
         tB, 0 );
    while( HTL.Height() < H.Height() && HTL.Width() < H.Width() )
    {
        LockedRepartitionDownDiagonal
        ( HTL, /**/ HTR,  H00, /**/ H01, H02,
         /*************/ /******************/
               /**/       H10, /**/ H11, H12,
          HBL, /**/ HBR,  H20, /**/ H21, H22 );

        LockedRepartitionDown
        ( tT,  t0,
         /**/ /**/
               t1,
          tB,  t2 );

        LockedView2x1( HPan, H01, H11 );
        View( ALeft, A, 0, 0, A.Height(), HPan.Height() );

        HPan_MR_STAR.AlignWith( ALeft );
        ZAdj_STAR_MC.AlignWith( ALeft );
        ZAdj_STAR_VC.AlignWith( ALeft );
        //--------------------------------------------------------------------//
        HPanCopy = HPan;
        MakeTrapezoidal( UPPER, HPanCopy, 0, RIGHT );
        SetDiagonal( HPanCopy, F(1), 0, RIGHT );
 
        HPan_VC_STAR = HPanCopy;
        Zeros( SInv_STAR_STAR, HPan.Width(), HPan.Width() );
        Herk
        ( UPPER, ADJOINT, 
          F(1), HPan_VC_STAR.LockedMatrix(),
          F(0), SInv_STAR_STAR.Matrix() ); 
        SInv_STAR_STAR.SumOverGrid();
        t1_STAR_STAR = t1;
        FixDiagonal( conjugation, t1_STAR_STAR, SInv_STAR_STAR );

        HPan_MR_STAR = HPan_VC_STAR;
        LocalGemm( ADJOINT, ADJOINT, F(1), HPan_MR_STAR, ALeft, ZAdj_STAR_MC );
        ZAdj_STAR_VC.SumScatterFrom( ZAdj_STAR_MC );
        
        LocalTrsm
        ( LEFT, UPPER, ADJOINT, NON_UNIT, 
          F(1), SInv_STAR_STAR, ZAdj_STAR_VC );

        ZAdj_STAR_MC = ZAdj_STAR_VC;
        LocalGemm
        ( ADJOINT, ADJOINT, F(-1), ZAdj_STAR_MC, HPan_MR_STAR, F(1), ALeft );
        //--------------------------------------------------------------------//

        SlideLockedPartitionDownDiagonal
        ( HTL, /**/ HTR,  H00, H01, /**/ H02,
               /**/       H10, H11, /**/ H12,
         /*************/ /******************/
          HBL, /**/ HBR,  H20, H21, /**/ H22 );

        SlideLockedPartitionDown
        ( tT,  t0,
               t1,
         /**/ /**/
          tB,  t2 );
    }
}
Example #22
0
void ARX_INTERFACE_ManageOpenedBook_Finish()
{

	Vec3f pos = Vec3f(0.f, 0.f, 2100.f);
	Anglef angle = Anglef::ZERO;
	
	EERIE_LIGHT * light = lightHandleGet(torchLightHandle);
	
	EERIE_LIGHT tl = *light;
	
	light->pos = Vec3f(500.f, -1960.f, 1590.f);
	light->exist = 1;
	light->rgb = Color3f(0.6f, 0.7f, 0.9f);
	light->intensity  = 1.8f;
	light->fallstart=4520.f;
	light->fallend = light->fallstart + 600.f;
	RecalcLight(light);
	
	EERIE_CAMERA * oldcam = ACTIVECAM;
	
	PDL[0] = light;
	TOTPDL=1;
	
	Vec2i tmpPos = Vec2i_ZERO;
	
	for(size_t i = 0; i < RUNE_COUNT; i++) {
		if(!gui::necklace.runes[i])
			continue;
		
		EERIE_3DOBJ * rune = gui::necklace.runes[i];
		
		bookcam.center.x = (382 + tmpPos.x * 45 + BOOKDEC.x) * g_sizeRatio.x;
		bookcam.center.y = (100 + tmpPos.y * 64 + BOOKDEC.y) * g_sizeRatio.y;
		
		SetActiveCamera(&bookcam);
		PrepareCamera(&bookcam, g_size);
		
		// First draw the lace
		angle.setPitch(0.f);
		
		if(player.hasRune((Rune)i)) {
			
			TransformInfo t1(pos, glm::toQuat(toRotationMatrix(angle)));
			DrawEERIEInter(gui::necklace.lacet, t1, NULL);
			
			if(rune->angle.getPitch() != 0.f) {
				if(rune->angle.getPitch() > 300.f)
					rune->angle.setPitch(300.f);
				
				angle.setPitch(std::sin(arxtime.get_updated() * (1.0f / 200)) * rune->angle.getPitch() * (1.0f / 40));
			}
			
			rune->angle.setPitch(rune->angle.getPitch() - framedelay * 0.2f);
			
			if(rune->angle.getPitch() < 0.f)
				rune->angle.setPitch(0.f);
			
			GRenderer->SetRenderState(Renderer::DepthWrite, true);
			GRenderer->SetRenderState(Renderer::AlphaBlending, false);
			
			// Now draw the rune
			TransformInfo t2(pos, glm::toQuat(toRotationMatrix(angle)));
			DrawEERIEInter(rune, t2, NULL);
			
			EERIE_2D_BBOX runeBox;
			UpdateBbox2d(*rune, runeBox);
			
			PopAllTriangleList();
			
			tmpPos.x++;
			
			if(tmpPos.x > 4) {
				tmpPos.x = 0;
				tmpPos.y++;
			}
			
			const Rect runeMouseTestRect(
			runeBox.min.x,
			runeBox.min.y,
			runeBox.max.x,
			runeBox.max.y
			);
			
			// Checks for Mouse floating over a rune...
			if(runeMouseTestRect.contains(Vec2i(DANAEMouse))) {
				long r=0;
				
				for(size_t j = 0; j < rune->facelist.size(); j++) {
					float n = PtIn2DPolyProj(rune, &rune->facelist[j], (float)DANAEMouse.x, (float)DANAEMouse.y);
					
					if(n!=0.f) {
						r=1;
						break;
					}
				}
				
				if(r) {
					GRenderer->SetRenderState(Renderer::AlphaBlending, true);
					GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne);
					
					TransformInfo t(pos, glm::toQuat(toRotationMatrix(angle)));
					DrawEERIEInter(rune, t, NULL);
					
					rune->angle.setPitch(rune->angle.getPitch() + framedelay*2.f);
					
					PopAllTriangleList();
					
					GRenderer->SetRenderState(Renderer::AlphaBlending, false);
					
					SpecialCursor=CURSOR_INTERACTION_ON;
					
					if(eeMouseDown1())
						if((size_t)LastRune != i) {
							PlayerBookDrawRune((Rune)i);
						}
						
						LastRune=i;
				}
			}
		}
	}
	
	GRenderer->SetCulling(Renderer::CullCCW);
	
	LastRune=-1;
	
	*light = tl;
	
	SetActiveCamera(oldcam);
	PrepareCamera(oldcam, g_size);
}
Example #23
0
inline void
Householder( DistMatrix<F>& A, DistMatrix<F,MD,STAR>& t )
{
#ifndef RELEASE
    CallStackEntry entry("qr::Householder");
    if( A.Grid() != t.Grid() )
        LogicError("{A,s} must be distributed over the same grid");
#endif
    const Grid& g = A.Grid();
    if( t.Viewing() )
    {
        if( !t.AlignedWithDiagonal( A ) ) 
            LogicError("t was not aligned with A");
    }
    else
    {
        t.AlignWithDiagonal( A );
    }
    t.ResizeTo( Min(A.Height(),A.Width()), 1 );

    // Matrix views
    DistMatrix<F>
        ATL(g), ATR(g),  A00(g), A01(g), A02(g),  ALeftPan(g), ARightPan(g),
        ABL(g), ABR(g),  A10(g), A11(g), A12(g),
                         A20(g), A21(g), A22(g);
    DistMatrix<F,MD,STAR>
        tT(g),  t0(g),
        tB(g),  t1(g),
                t2(g);

    PartitionDownDiagonal
    ( A, ATL, ATR,
         ABL, ABR, 0 );
    PartitionDown
    ( t, tT,
         tB, 0 );
    while( ATL.Height() < A.Height() && ATL.Width() < A.Width() )
    {
        RepartitionDownDiagonal
        ( ATL, /**/ ATR,  A00, /**/ A01, A02,
         /*************/ /******************/
               /**/       A10, /**/ A11, A12,
          ABL, /**/ ABR,  A20, /**/ A21, A22 );

        RepartitionDown
        ( tT,  t0,
         /**/ /**/
               t1,
          tB,  t2 );

        View2x1
        ( ALeftPan, A11,
                    A21 );

        View2x1
        ( ARightPan, A12,
                     A22 );

        //--------------------------------------------------------------------//
        PanelHouseholder( ALeftPan, t1 );
        ApplyQ( LEFT, ADJOINT, ALeftPan, t1, ARightPan );
        //--------------------------------------------------------------------//

        SlidePartitionDown
        ( tT,  t0,
               t1,
         /**/ /**/
          tB,  t2 );

        SlidePartitionDownDiagonal
        ( ATL, /**/ ATR,  A00, A01, /**/ A02,
               /**/       A10, A11, /**/ A12,
         /*************/ /******************/
          ABL, /**/ ABR,  A20, A21, /**/ A22 );
    }
}
Example #24
0
void checkThatCopyConstructorDoesNotInvalidateObjectBeingCopied() {
  B t;
  t.x = 0;
  B t2(t);
  clang_analyzer_eval(t.x == 0); // expected-warning{{TRUE}}
}
Example #25
0
void getCluAvgEff(Char_t* signalFile="signalShapes.root", Int_t diskNr=3, Bool_t onlyQuadB=false)
{
  gStyle->SetPalette(1);
  gStyle->SetOptStat(0);
   plFgtQuads_dbMap();

   TFile f(signalFile);
   //TFile f("signalShapes.root");
 char buffer[100];

 sprintf(buffer,"allClusterCountsDisk_%d",diskNr);//counting different for this histo
 TH2D* hEff=(TH2D*)f.Get(buffer);

 sprintf(buffer,"radioDiskNonEff_%d",diskNr-1);
 TH2D* hNonEff=(TH2D*)f.Get(buffer);
 // hEff->Rebin2D(2,2); //merge wo bins...
 // hNonEff->Rebin2D(2,2);

 Double_t max=hEff->GetXaxis()->GetXmax();
 Double_t min=hEff->GetXaxis()->GetXmin();
 Int_t minCounts=10;
 // cout <<"max: " << max << " min: " << min << " numBins: "<< h->GetNbinsX() <<endl;

 TH2D OverallEff("overallEff","overallEff",hEff->GetNbinsX(),min,max,hEff->GetNbinsY(),min,max);
 TH2D OverallCounts("overallCounts","overallCounts",hEff->GetNbinsX(),min,max,hEff->GetNbinsY(),min,max);
 TH2D OverallFound("overallFound","overallFound",hEff->GetNbinsX(),min,max,hEff->GetNbinsY(),min,max);
 OverallEff.GetXaxis()->SetTitle("x [cm]");
 OverallEff.GetYaxis()->SetTitle("y [cm]");
 OverallCounts.GetXaxis()->SetTitle("x [cm]");
 OverallCounts.GetYaxis()->SetTitle("y [cm]");
 OverallFound.GetXaxis()->SetTitle("x [cm]");
 OverallFound.GetYaxis()->SetTitle("y [cm]");



Double_t eff=0;
Int_t count=0;

 Int_t sumEff=0;
 Int_t sumNonEff=0;

 Double_t overallErr=0;
for(Int_t i=1;i<hEff->GetNbinsX()+1;i++)
  {
    for(Int_t j=1;j<hEff->GetNbinsY()+1;j++)
      {
	///do you only want to use Quad B?
	if(onlyQuadB)
	  {
	    if(i<(hEff->GetNbinsX()-1)/2|| j>(hEff->GetNbinsY()-1)/2)
	      continue;
	  }
	//Int_t gBin=h->GetBin(i,j);
	//	Double_t xpos=h->GetXaxis()->GetBinCenter(gBin);
	//	Double_t ypos=h->GetYaxis()->GetBinCenter(gBin);
	//	if(xpos<0 || ypos >0)
	//	  continue;


	    Int_t numEff=hEff->GetBinContent(i,j);
	    Int_t numNonEff=hNonEff->GetBinContent(i,j);
	    Int_t numCounts=numEff+numNonEff;
	    //	    cout <<"numEff: " << numEff <<" nonEff: " << numNonEff << " counts: " << numCounts<<endl;
	    Double_t efficiency=0;
	    if(numCounts>minCounts)
	      {
		efficiency=(Double_t)numEff/(Double_t)numCounts;
	      }
	    if(numEff>0)
	      {
		sumEff+=numEff;
		sumNonEff+=numNonEff;
	      }
	    OverallEff.SetBinContent(i,j,efficiency);
	    OverallCounts.SetBinContent(i,j,numCounts);
	    OverallFound.SetBinContent(i,j,numEff);

	if(numCounts>minCounts)
	  {
	    //
	    Double_t relErr=999;
	    Double_t err=999;
	    if(numEff>0)
	      {
		relErr=sqrt((1/(Double_t)(numEff+numNonEff)+1/(Double_t)numEff));
		err=relErr*efficiency;

	      }
	    else
	      {
		err=1/sqrt(numNonEff);
	      }
	    eff+=efficiency/(err*err);
	    overallErr+=(1/(err*err));

	    count++;
	  }
      }
  }

 Double_t avgEff=sumEff/(Double_t)(sumEff+sumNonEff);
 //binomial error, beware of 0
 Double_t errOnEffNum=sqrt(avgEff*(1-avgEff)*(sumEff+sumNonEff));
 Double_t altErr= ((Double_t)1/(Double_t)(sumEff+sumNonEff))*sqrt(sumEff*(Double_t)(1-sumEff/(sumEff+sumNonEff)));
 sprintf(buffer,"Average Efficiency is %f +- %f",avgEff,altErr);
 //15 degrees
 Float_t rotationRadians=-0.261799388;
 Float_t rotationRadians2=-1.83259571;
 Float_t rotation=-15;
 Float_t innerR=11.5;
 Float_t outerR=38;
 TLatex t1(-30,0,buffer);
 TArc outerA(0,0,outerR,90+rotation,-90+rotation);
 TArc innerA(0,0,innerR,90+rotation,-90+rotation);
 // cout <<"cos rot: " << cos(rotation) <<" sin: " << sin(rotation) <<endl;
 TLine l1(innerR*cos(rotationRadians),innerR*sin(rotationRadians),outerR*cos(rotationRadians),outerR*sin(rotationRadians));
 TLine l2(innerR*cos(rotationRadians2),innerR*sin(rotationRadians2),outerR*cos(rotationRadians2),outerR*sin(rotationRadians2));
 l1.SetLineWidth(3);
 l2.SetLineWidth(3);
 outerA.SetLineWidth(3);
 innerA.SetLineWidth(3);

 // plGood();

 int apvMap[]={5,6,7,8,9,12,13,14,15,16};
 char buffer2[200];
 TCanvas* c2=new TCanvas("ceff","ceff",1,1,800,800);
 for(int i=0;i<10;i++)
   {
     //     sprintf(buffer2,"cD%d_apv%d",diskNr,i);
     //     c2=new TCanvas(buffer2,buffer2,1,1,800,800);
     if(i==0)
       {
	 sprintf(buffer2,"overallEff_D%d.pdf(",diskNr);
	 Char_t buffer3[100];
	 sprintf(buffer3,"overallEff_D%d.png",diskNr);
     OverallEff.Draw("colz");
     outerA.Draw();
     innerA.Draw();
     OverallEff.Draw("same colz");

     t1.Draw();
     l1.Draw();
     l2.Draw();
	 c2.SaveAs(buffer3);
       }
     else
       {
	 if(i==9)
	   sprintf(buffer2,"overallEff_D%d.pdf)",diskNr);
	 else
	   sprintf(buffer2,"overallEff_D%d.pdf",diskNr);
       }
     OverallEff.Draw("colz");
     outerA.Draw();
     innerA.Draw();
     
     OverallEff.Draw("same colz");
     t1.Draw();
     l1.Draw();
     l2.Draw();
     sprintf(buffer,"overallEff_D%d_APV%d.pdf",diskNr,apvMap[i]);
     plAPV(apvMap[i],1,'B');
     c2->SaveAs(buffer);
     cout <<"printing to " << buffer2 <<endl;
     c2->Print(buffer2,"pdf");
 }
 TCanvas c("effs","effs",1,1,800,800);


 //counts

 TCanvas cC("counts","counts",1,1,800,800);
 OverallCounts.Draw("colz");
 outerA.Draw();
 innerA.Draw();
 
 OverallCounts.Draw("same colz");
 l1.Draw();
 l2.Draw();
 cC.SaveAs("overallCounts.png");


 TCanvas cf("found","found",1,1,800,800);
 OverallFound.Draw("colz");
 outerA.Draw();
 innerA.Draw();
 OverallFound.Draw("same colz");
 l1.Draw();
 l2.Draw();
 cf.SaveAs("overallFound.png");

 sprintf(buffer,"overall found");
 sprintf(buffer2,"cFoundD",diskNr);
 c2=new TCanvas(buffer2,buffer2,1,1,800,800);
 TLatex t2(-30,0,buffer);
 for(int i=0;i<10;i++)
   {
     if(i==0)
       {
	 sprintf(buffer2,"overallFound_D%d.pdf(",diskNr);
	 Char_t buffer3[100];
	 sprintf(buffer3,"overallFound_D%d.png",diskNr);
	 sprintf(buffer2,"overallFound_D%d.pdf(",diskNr);
	 OverallFound.Draw("colz");
     outerA.Draw();
     innerA.Draw();
	 OverallFound.Draw("same colz");
 l1.Draw();
 l2.Draw();
	 c2.SaveAs(buffer3);
       }
     else
       {
	 if(i==9)
	   sprintf(buffer2,"overallFound_D%d.pdf)",diskNr);
	 else
	   sprintf(buffer2,"overallFound_D%d.pdf",diskNr);
       }
     OverallEff.Draw("colz");
     outerA.Draw();
     innerA.Draw();
     
     //     OverallFound.Draw("same colz");
     t2.Draw();
     l1.Draw();
     l2.Draw();
     sprintf(buffer,"overallFound_D%d_APV%d.png",diskNr,apvMap[i]);
     plAPV(apvMap[i],1,'B');
     c2.SaveAs(buffer);
     cout <<"printing to " << buffer2 <<endl;
     c2->Print(buffer2,"pdf");
 }






 // c.SaveAs("overallEff.C");
//cout <<"avg eff: " << eff/count <<endl;
 cout <<"Hits found: " << sumEff <<" Hits not found: " << sumNonEff<< " efficiency: " <<avgEff<<" +- " << altErr<<endl;

}
int main() {
    CounterThread t1(1, 200), t2(2, 200);
    std::cout << std::endl;
}
Example #27
0
int main() {

	/** Setup test environ */

	setupTestTree();
	
	std::vector<int16_t> v201501, v201502, v201503;
	/** (1420070400) NO_DATA (1420074000) 75 (1420077600) NO_DATA (1422748800) */
	for (int i = 0; i < 267840; ++i) {
		if (i < 360 || i > 720) v201501.push_back(-32768);
		else v201501.push_back(75);
	}
	for (int i = 0; i < 241920; ++i) {
		if (i > 720 && i < 1080) v201502.push_back(-32768);
		else v201502.push_back(85);

	}
	for (int i = 0; i < 267840; ++i) {
		if (i < 360) v201503.push_back(-32768);
		else v201503.push_back(95);
		//v201503.push_back(-32768);
	}

	createSzCacheFile("TestA/TestB/TestC/201501.szc", v201501);
	createSzCacheFile("TestA/TestB/TestC/201502.szc", v201502);
	createSzCacheFile("TestA/TestB/TestC/201503.szc", v201503);

	/** Test */

	SzCache szc("./",2);

	/** availableRange() */
	SzCache::SzRange szr = szc.availableRange();
	std::cout << "SzCache::availableRange(): (" << szr.first << "," << szr.second << ")\n";
	std::cout << "= ( " << time2str(szr.first) << " , " << time2str(szr.second) << " )\n";
	std::cout << "\n";

	SzCache::SzTime t1(1420070400 );
	SzCache::SzTime t2(1420070400 + 3600);
	SzCache::SzTime t3(1420070400 + 3600 + 3600);
	SzCache::SzTime t4(1420070400 + 2678400);
	SzCache::SzTime t5(1420070400 + 2678400 + 3600 + 3600);
	SzCache::SzTime t6(1420070400 + 2678400 + 3600 + 3600 + 3600);
	SzCache::SzTime t7(1420070400 + 2678400 + 2419200);
	SzCache::SzTime t8(1420070400 + 2678400 + 2419200 + 3600);
	SzCache::SzPath szp1("TestA/TestB/TestC");

	try {
		SzCache::SzSearchResult ssr = szc.searchInPlace(t1,szp1);
		std::cout << "SzCache::searchInPlace("<<t1<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t2,szp1);
		std::cout << "SzCache::searchInPlace("<<t2<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t2) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t2-10,szp1);
		std::cout << "SzCache::searchInPlace("<<t2-10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t3,szp1);
		std::cout << "SzCache::searchInPlace("<<t3<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t3) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t3+10,szp1);
		std::cout << "SzCache::searchInPlace("<<t3+10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t4,szp1);
		std::cout << "SzCache::searchInPlace("<<t4<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t4) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t5,szp1);
		std::cout << "SzCache::searchInPlace("<<t5<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t5) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t5+10,szp1);
		std::cout << "SzCache::searchInPlace("<<t5+10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t6,szp1);
		std::cout << "SzCache::searchInPlace("<<t6<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t6) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t6-10,szp1);
		std::cout << "SzCache::searchInPlace("<<t6-10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t7,szp1);
		std::cout << "SzCache::searchInPlace("<<t7<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t8,szp1);
		std::cout << "SzCache::searchInPlace("<<t8<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t8) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t8-10,szp1);
		std::cout << "SzCache::searchInPlace("<<t8-10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchRight(t2-50,t3,szp1); 
		std::cout << "SzCache::searcRight("<<t2-50<<","<<t3<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t2) throw std::logic_error("Assertion failed!");

		ssr = szc.searchRight(t2+50,t4,szp1); 
		std::cout << "SzCache::searcRight("<<t2+50<<","<<t4<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != (t2+50)) throw std::logic_error("Assertion failed!");
		
		ssr = szc.searchRight(t3+10,t3+50,szp1); 
		std::cout << "SzCache::searcRight("<<t3+10<<","<<t3+50<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchRight(t4-100,t5,szp1); 
		std::cout << "SzCache::searcRight("<<t4-100<<","<<t5<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t4) throw std::logic_error("Assertion failed!");

		ssr = szc.searchLeft(t7+100,t6,szp1); 
		std::cout << "SzCache::searchLeft("<<t7+100<<","<<t6<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != (t7-10)) throw std::logic_error("Assertion failed!");

		ssr = szc.searchLeft(t6+100,t5,szp1); 
		std::cout << "SzCache::searchLeft("<<t6+100<<","<<t5<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != (t6+100)) throw std::logic_error("Assertion failed!");

		ssr = szc.searchLeft(t3+100,t3+10,szp1); 
		std::cout << "SzCache::searchLeft("<<t3+100<<","<<t3+10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchLeft(t3+100,t3+10,szp1); 
		std::cout << "SzCache::searchLeft("<<t3+100<<","<<t3+10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");
		
		std::vector<int16_t> vals;
		
		SzCache::SzTime wtime = szc.writeData(vals, t2-50, t2+50, szp1);
		while( wtime < t2+50 ) 
			wtime = szc.writeData(vals, wtime, t2+50, szp1);
		std::cout << "writeData(" << t2-50 << "," << t2+50 << "):\n";
		for (unsigned int i = 0; i < vals.size(); i++) {
			std::cout << vals[i] << std::endl;
			if ((i < 5) && (vals[i] != SzCache::cSzCacheNoData))
				throw std::logic_error("Assertion failed!");
			if ((i > 5) && (vals[i] != 75))
				throw std::logic_error("Assertion failed!");
		}
		std::cout << std::endl;
		vals.clear();

		wtime = szc.writeData(vals, t4-50, t4+50, szp1);
		while( wtime < t4+50 ) 
			wtime = szc.writeData(vals, wtime, t4+50, szp1);
		std::cout << "writeData(" << t4-50 << "," << t4+50 << "):\n";
		for (unsigned int i = 0; i < vals.size(); i++) {
			std::cout << vals[i] << std::endl;	
			if ((i < 5) && (vals[i] != SzCache::cSzCacheNoData))
				throw std::logic_error("Assertion failed!");
			if ((i > 5) && (vals[i] != 85))
				throw std::logic_error("Assertion failed!");
		}
		std::cout << std::endl;
		vals.clear();

		wtime = szc.writeData(vals, t7-50, t7+50, szp1);
		while( wtime < t7+50 ) 
			wtime = szc.writeData(vals, wtime, t7+50, szp1);
		std::cout << "writeData(" << t7-50 << "," << t7+50 << "):\n";
		for (unsigned int i = 0; i < vals.size(); i++) {
			std::cout << vals[i] << std::endl;
			if ((i < 5) && (vals[i] != 85))
				throw std::logic_error("Assertion failed!");
			if ((i > 5) && (vals[i] != SzCache::cSzCacheNoData))
				throw std::logic_error("Assertion failed!");
		}
		std::cout << std::endl;
		vals.clear();

		

	} catch (std::logic_error& le) {
		removeSzCacheFile("TestA/TestB/TestC/201501.szc");
		removeSzCacheFile("TestA/TestB/TestC/201502.szc");
		removeSzCacheFile("TestA/TestB/TestC/201503.szc");
		removeTestTree();

		std::cout << "Assertion has failed!" << std::endl;
		return -1;
	}
		
	std::cout << "All assertions valid: Test PASSED" << std::endl;
	/** Remove test environ */

	removeSzCacheFile("TestA/TestB/TestC/201501.szc");
	removeSzCacheFile("TestA/TestB/TestC/201502.szc");
	removeSzCacheFile("TestA/TestB/TestC/201503.szc");
	removeTestTree();
	
	return 0;
}
Example #28
0
File: tp7.cpp Project: dtbinh/M1S2
std::vector<Triangle> triangulationSphere(Point centreSphere, int rayon){

	double phi = 0;
	double teta;
	int nbPoint = 10;
	int tailleM = nbPoint*meridien;
	int tailleP = nbPoint*parallele;
	
	std::vector<Triangle> listeTriangle;
		
	Point poleNord(rayon*sin(0)*cos(0), rayon*sin(0)*sin(0), rayon*cos(0));
	
	for(int j=0; j<=parallele; j++){
		
		Point p1(rayon*sin(M_PI * 1 / parallele)*cos(2*M_PI * (j%parallele) / parallele),
				rayon*sin(M_PI * 1 / meridien)*sin(2*M_PI * (j%parallele) / parallele), 
				rayon*cos(M_PI * 1 / meridien));
				
		Point p2(rayon*sin(M_PI * 1 / parallele)*cos(2*M_PI * ((j+1)%parallele) / parallele),
				rayon*sin(M_PI * 1 / meridien)*sin(2*M_PI * ((j+1)%parallele) / parallele), 
				rayon*cos(M_PI * 1 / meridien));
		
		Triangle t(poleNord,p1, p2);
		
		listeTriangle.push_back(t);
	}
	
	
	Point poleSud(rayon*sin(M_PI)*cos(2*M_PI), rayon*sin(M_PI)*sin(2*M_PI), rayon*cos(M_PI));
	
	for(int j=0; j<=parallele; j++){
		
		Point p2(rayon*sin(M_PI * (parallele - 1) / parallele)*cos(2*M_PI * (j%parallele) / parallele),
				rayon*sin(M_PI * (parallele - 1)  / meridien)*sin(2*M_PI * (j%parallele) / parallele), 
				rayon*cos(M_PI * (parallele - 1)  / meridien));
				
		Point p1(rayon*sin(M_PI * (parallele - 1) / parallele)*cos(2*M_PI * ((j+1)%parallele) / parallele),
				rayon*sin(M_PI * (parallele - 1)  / meridien)*sin(2*M_PI * ((j+1)%parallele) / parallele), 
				rayon*cos(M_PI * (parallele - 1)  / meridien));
		
		Triangle t(poleSud,p1, p2);
		
		listeTriangle.push_back(t);
	}
			
	for(int i=1; i<meridien-1; i++){
		for(int j=0; j<parallele; j++){
		
		
			Point p1(rayon*sin(M_PI * i / parallele)*cos(2*M_PI * j / parallele),
							rayon*sin(M_PI * i / meridien)*sin(2*M_PI * j / parallele), 
							rayon*cos(M_PI * i / meridien));
							
			Point p2(rayon*sin(M_PI * i / meridien)*cos(2*M_PI * (j+1) / parallele),
							rayon*sin(M_PI * i / meridien)*sin(2*M_PI * (j+1) / parallele), 
							rayon*cos(M_PI * i / meridien));
							
			Point p3(rayon*sin(M_PI * (i+1) / meridien)*cos(2*M_PI * (j+1) / parallele),
							rayon*sin(M_PI * (i+1) / meridien)*sin(2*M_PI * (j+1) / parallele), 
							rayon*cos(M_PI * (i+1) / meridien));
							
			Point p4(rayon*sin(M_PI * (i+1) / meridien)*cos(2*M_PI * j / parallele),
							rayon*sin(M_PI * (i+1) / meridien)*sin(2*M_PI * j / parallele), 
							rayon*cos(M_PI * (i+1) / meridien));				
		
			Triangle t1 (p1,p3,p2);
			
			listeTriangle.push_back(t1);
			
			Triangle t2(p1,p4,p3);
			
			listeTriangle.push_back(t2);
			
		}
	}
	
	return listeTriangle;
}
Example #29
0
void t3(int c) {
  c ? t1() : t2();
}
Example #30
0
  // TODO: DOCUMENT EVERYTHING
  Spice::Spice (Isis::Pvl &lab) {
    NaifStatus::CheckErrors();

    // Initialization
    p_startTime = 0.0;
    p_endTime = 0.0;
    p_cacheSize = 0;
    p_et = -DBL_MAX;
    p_allowDownsizing = false;

    // Get the kernel group and load main kernels
    Isis::PvlGroup kernels = lab.FindGroup("Kernels",Isis::Pvl::Traverse);

    // Get the time padding first
    if(kernels.HasKeyword("StartPadding")) {
      p_startTimePadding = kernels["StartPadding"][0];
    }
    else {
      p_startTimePadding = 0.0;
    }

    if(kernels.HasKeyword("EndPadding")) {
      p_endTimePadding  = kernels["EndPadding"][0];
    }
    else {
      p_endTimePadding = 0.0;
    }


//  Modified  to load planetary ephemeris SPKs before s/c SPKs since some 
//  missions (e.g., MESSENGER) may augment the s/c SPK with new planet 
//  ephemerides. (2008-02-27 (KJB))
    Load(kernels["TargetPosition"]);
    Load(kernels["InstrumentPosition"]);
    Load(kernels["InstrumentPointing"]);

    if (kernels.HasKeyword("Frame")) {
      Load(kernels["Frame"]);
    }

    if (kernels.HasKeyword("Extra")) {
      Load(kernels["Extra"]);
    }

    Load(kernels["TargetAttitudeShape"]);
    Load(kernels["Instrument"]);
    Load(kernels["InstrumentAddendum"]);  // Always load after instrument
    Load(kernels["LeapSecond"]);
    Load(kernels["SpacecraftClock"]);

    // Get NAIF ik, spk, sclk, and ck codes
    //
    //    Use ikcode to get parameters from instrument kernel such as focal
    //    length, distortions, focal plane maps, etc
    //
    //    Use spkcode to get spacecraft position from spk file
    //
    //    Use sclkcode to transform times from et to tics
    //
    //    Use ckcode to transform between frames
    //
    //    Use bodycode to obtain radii and attitude (pole position/omega0)
    //
    //    Use spkbodycode to read body position from spk
    
    string trykey = "NaifIkCode";
    if (kernels.HasKeyword("NaifFrameCode")) trykey = "NaifFrameCode";
    p_ikCode = (int) kernels[trykey];
    
    p_spkCode = p_ikCode / 1000;
    p_sclkCode = p_spkCode;
    p_ckCode = p_ikCode;
    
    Isis::PvlGroup &inst = lab.FindGroup("Instrument",Isis::Pvl::Traverse);
    p_target = (string) inst["TargetName"];
    
    if (iString(p_target).UpCase() == "SKY") {
      p_bodyCode = p_spkCode;
      p_radii[0] = p_radii[1] = p_radii[2] = 1.0;
      p_sky = true;
    }
    else {
      p_bodyCode = NaifBodyCode();
      SpiceInt n;
      bodvar_c(p_bodyCode,"RADII",&n,p_radii);
      p_sky = false;
    }
    p_spkBodyCode = p_bodyCode;
    
    // Override them if they exist in the labels
    if (kernels.HasKeyword("NaifSpkCode")) p_spkCode = (int) kernels["NaifSpkCode"];
    if (kernels.HasKeyword("NaifCkCode")) p_ckCode = (int) kernels["NaifCkCode"];
    if (kernels.HasKeyword("NaifSclkCode")) p_sclkCode = (int) kernels["NaifSclkCode"];
    if (kernels.HasKeyword("NaifBodyCode")) p_bodyCode = (int) kernels["NaifBodyCode"];
    if (!p_sky) {
      if (kernels.HasKeyword("NaifSpkBodyCode")) p_spkBodyCode = (int) kernels["NaifSpkBodyCode"];
    }
    
    // Create our SpicePosition and SpiceRotation objects
    p_bodyRotation = 0;
    p_instrumentRotation = 0;
    p_instrumentPosition = 0;
    p_sunPosition = 0;
    
    if (p_sky) {
      // Create the identity rotation for sky targets
      // Everything in bodyfixed will really be J2000
      p_bodyRotation = new SpiceRotation(1);
    }
    else {
      char frameName[32];
      SpiceInt frameCode;
      SpiceBoolean found;
      cidfrm_c (p_spkBodyCode, sizeof(frameName), &frameCode, frameName, &found);

      if (!found) { 
        string naifTarget = string("IAU_") + iString(p_target).UpCase();
        namfrm_c(naifTarget.c_str(),&frameCode);
        if (frameCode == 0) {
          string msg = "Can not find NAIF code for [" + naifTarget + "]";
          throw Isis::iException::Message(Isis::iException::Io,msg,_FILEINFO_);
        }
      }
      p_bodyRotation = new SpiceRotation(frameCode);
    }
    p_instrumentRotation = new SpiceRotation(p_ckCode);
    p_instrumentPosition = new SpicePosition(p_spkCode,p_spkBodyCode);
    p_sunPosition = new SpicePosition(10,p_bodyCode);
    
    // Check to see if we have nadir pointing that needs to be computed &
    // See if we have table blobs to load
    if (iString((std::string)kernels["TargetPosition"]).UpCase() == "TABLE") {
      Table t("SunPosition",lab.Filename());
      p_sunPosition->LoadCache(t);

      Table t2("BodyRotation",lab.Filename());
      p_bodyRotation->LoadCache(t2);
      if (t2.Label().HasKeyword("SolarLongitude")) {
        p_solarLongitude = t2.Label()["SolarLongitude"];
      }
      else {
        SolarLongitude();
      }
    }

    //  We can't assume InstrumentPointing & InstrumentPosition exist, old
    //  files may be around with the old keywords, SpacecraftPointing &
    //  SpacecraftPosition.  The old keywords were in existance before the
    //  Table option, so we don't need to check for Table under the old
    //  keywords.

    if(kernels["InstrumentPointing"].Size() == 0) {
      throw iException::Message(iException::Camera, 
                                "No camera pointing available", 
                                _FILEINFO_);
    }

    //  2009-03-18  Tracie Sucharski - Removed test for old keywords, any files
    // with the old keywords should be re-run through spiceinit.
    if (iString((std::string)kernels["InstrumentPointing"]).UpCase() == "NADIR") {
      delete p_instrumentRotation;
      p_instrumentRotation = new SpiceRotation(p_ikCode,p_spkBodyCode);
    }
    else if (iString((std::string)kernels["InstrumentPointing"]).UpCase() == "TABLE") {
      Table t("InstrumentPointing",lab.Filename());
      p_instrumentRotation->LoadCache(t);
    }

    if(kernels["InstrumentPosition"].Size() == 0) {
      throw iException::Message(iException::Camera, 
                                "No instrument position available", 
                                _FILEINFO_);
    }

    if (iString((std::string)kernels["InstrumentPosition"]).UpCase() == "TABLE") {
      Table t("InstrumentPosition",lab.Filename());
      p_instrumentPosition->LoadCache(t);
    }

    NaifStatus::CheckErrors();
  }