Esempio n. 1
0
void Qcalculation::init(int flag = 0)
{

#ifdef Q_WS_WIN
    file = path+"data/qsalat.xml";
#else
    file = QDir::homePath ()+"/.qsalat/config/qsalat.xml";
#endif
    parser.readFile(file);
    calcMethod = parser.getElement(2,0).toInt();
    asrMethod = parser.getElement(2,2).toInt();
    prayers->setAsrMethod(asrMethod);
    times = prayers->getDatePrayerTimes(date.year(),date.month(),date.day(),parser.getElement(0,0).toDouble(),parser.getElement(0,1).toDouble(),parser.getElement(0,4).toDouble());
    duhrBox->setMaximum(calcTime(times[2],times[3]));
    label_12->setText(" Max "+QString::number(duhrBox->maximum())+" min (5 min before asr)");

    if (0 == flag) {
        list << "Ithna Ashari"<<"University of Islamic Sciences, Karachi"<<"Islamic Society of North America (ISNA)"
             <<"Muslim World League (MWL)"<<"Umm al-Qura, Makkah"<<"Egyptian General Authority of Survey"<<"Institute of Geophysics, University of Tehran";
        //<<"Custom settings";
        calcList->addItems(list);
        calcList->setCurrentIndex(parser.getElement(2,0).toInt());
        hList << "No adjustment"<<"middle of night"<<"1/7th of night"<<"angle/60th of night";
        highList->addItems(hList);
        highList->setCurrentIndex(parser.getElement(2,4).toInt());
        duhrBox->setValue(parser.getElement(2,1).toInt());
        if (parser.getElement(2,2).toInt() == 0) shafiiButton->setChecked(true);
        else hanafiButton->setChecked(true);
        hijriBox->setValue(parser.getElement(2,3).toInt());
    }
    else {
        apply();
    }
}
Esempio n. 2
0
int main(void) {
    int cases;
    scanf("%d", &cases);
    for(int cas=1;cas<=cases;cas++) {
        scanf("%d %lld %d %d", &l, &t, &n, &c);
        FOR(i, c) scanf("%d", &a[i]);
        FOR(i, n) dist[i] = a[i % c];

        // first to build
        long long int total = 0;
        int start = n;
        FOR(i, n) {
            if (t < total + dist[i] * 2) {
                start = i;
                break;
            }
            total += dist[i] * 2;
        }

        FOR(i, n) placed[i] = false;

        if (start < n && l > 0) {
            indCount = n - start - 1;
            FOR(i, indCount) indices[i] = start + 1 + i;
            qsort(indices, indCount, sizeof(int), (int(*)(const void *, const void *))compare);

            FOR(i, l) placed[indices[i]] = true;

            result = calcTime();

            FOR(i, n) placed[i] = false;
            placed[start] = true;
            FOR(i, l - 1) placed[indices[i]] = true;
            double res2 = calcTime();
            if (res2 < result) result = res2;
        } else {
            result = calcTime();
        }


        printf("Case #%d: %.0lf\n", cas, result);
    }
}
Esempio n. 3
0
double testSequence(Node * nodes, size_t size) {
    double sum = 0;
    std::clock_t start = clock();
    for(unsigned i = 0; i < size; i++) {
        sum += nodes->val[0];
        nodes = nodes->next_sequential;
    }
    std::clock_t stop = clock();
    return calcTime(start, stop);
}
Esempio n. 4
0
double testRandom(Node * nodes, size_t size) {
    long long sum = 0;
    std::clock_t start = clock();
    for(unsigned i = 0; i < size; i++) {
        sum += nodes->val[0];
        nodes = nodes->next_random;
    }
    std::clock_t stop = clock();
    return calcTime(start, stop);

}
Esempio n. 5
0
void Renderer::drawAll()
{
    calcTime();
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);         // Clear The Screen And The Depth Buffer
    glColor4f (1,1,1,1);

    glLoadIdentity();
    glTranslatef(-game->ships[0]->position[0],-game->ships[0]->position[1],-30);
    //  glTranslatef(0,0,-30);

    drawAxis(0,0,0);
    glColor3f( 0.0, 1.0, 1.0 );
    wMesh->drawPolygon(-width*0.023,-height*0.023,0);


    drawShip();
    drawModules();
    drawMissles();
    drawAsteroids();


//   DrawQuadTexture(obiekty[0]->position[0],obiekty[0]->position[1],3,3,obiekty[0]->fOrientation, statek.imageID);

//    DrawQuadTexture(2.0f,2.0f,5.0f,5.0f,a[0]->myId);



    // drawAxis(0,0,0);
    //glPushMatrix();
    // wMesh->drawPolygon(-width*0.023,-height*0.023,0);

    glPopMatrix();
    glColor3f( 0.0, 1.0, 1.0 );

    glLoadIdentity();
    freetype::print(a, 77, 77, "Siemanko....");
    CEGUI::System::getSingleton().renderAllGUIContexts();

    glPushMatrix();

    glTranslatef(0.0f, 0.0f, -15.0f);


    //obiekty.drawAll();

    //DrawQuadTexture(1, 1, 10, 10, statek.imageID);





    SDL_GL_SwapWindow(window);
}
Esempio n. 6
0
void check(int todo, int start) {
    if (todo == 0) {
        double res = calcTime();
        if (res < result) result = res;
    } else {
        for(int i=start;i<n;i++) {
            placed[i] = true;
            check(todo - 1, i + 1);
            placed[i] = false;
        }
    }
}
Esempio n. 7
0
/**
* @brief Function runs process
*
* @details Function delays certain time for process run
*
* @pre struct* current contains current meta
*
* @pre struct* pcb contains the pcb table
*
* @post certain time delayd for process
*
* @return None
*
*/
   void runProcess( struct meta* current, struct pcb_table** pcbPtr )
      {
       int time = 0;   // init. time

       time = calcTime( *current, **pcbPtr );

       // delay that long time
       delay( ( clock_t ) time );

       ( *pcbPtr ) -> currentLeft -= ( *pcbPtr ) -> quantumTime;
       if( ( *pcbPtr ) -> currentLeft < 0 )
       ( *pcbPtr ) -> currentLeft = 0;
      }   // end of func
Esempio n. 8
0
int main(){
    
    struct timeval first, second, lapsed;
    struct timezone tzp;
    printf( "Please wait while we calculate primes using Cpp... " );
    gettimeofday(&first, &tzp);
    printf( "%d primes in ", calc() );
    gettimeofday(&second, &tzp);
    
    calcTime( first, second, &lapsed );
    printf( "%d.%06d \n", (int) lapsed.tv_sec, (int) lapsed.tv_usec );
    
    return 0;
}
Esempio n. 9
0
int func(int nthreads)
{
    omp_set_num_threads(nthreads);
    double ti[N], tj[N], F[N];
    for (i = 0; i < N; i++)
    {
    	ti[i] 	= i;
    	tj[i] 	= i * i;
    	F[i]	= 0;
    }
    
    double start = calcTime();
    
    for (j = 0; j < LOOPS; j++) {
    	#pragma omp parallel for
    	for (i = 0; i < N; i++) {
    		F[i] = ti[i] + tj[i];
    	}
    }
    
    double end = calcTime();
    printf("%d threads takes %e seconds\n", omp_get_max_threads(), end - start);
}
Esempio n. 10
0
void printTime ( char *label, struct timeval *tp1, struct timeval *tp2, long bytes, long mflops )
{
	//calculate and print out passed time measured with gettimeofday
	long usecs;

	usecs = calcTime (tp1, tp2);
	if ( bytes != 0 )
		printf ( "%s: %4ld usecs passed (%.2lf MB/s)\n", label, usecs, (double) bytes/usecs );
	else if ( mflops != 0 )
		printf ( "%s: %4ld usecs passed (%ld MFLOP, %.2lf MFLOP/s)\n", label, usecs, mflops, (double) mflops/usecs*1E06 );
	else
		printf ( "%s: %4ld usecs passed\n", label, usecs );
	fflush (stdout);
}
Esempio n. 11
0
void cacheTest(size_t size) {
    int * a = new int[size];
    for(unsigned i = 0; i < size; i ++) {
        a[i] = i;
    }

    std::vector<int> *data = new std::vector<int>;
    for(unsigned i = 0; i < size; i++) {
        data->push_back(i);
    }

    long long sum = 0;

    std::clock_t start = clock();
    for(unsigned i = 0; i < size; i++) {
        sum += data->at(a[i]);
    }
    std::clock_t stop = clock();


    std::cout << calcTime(start, stop) / (double)size * 1000.0 << " ms    ---    ";

    mix(a,size);
    sum = 0;

    start = clock();
    for(unsigned i = 0; i < size; i++) {
        sum += data->at(a[i]);
    }
    stop = clock();

    std::cout << calcTime(start, stop) / (double)size * 1000.0 << " ms" << std::endl;

    delete[] a;
    delete data;
}
Esempio n. 12
0
void Qcalculation::apply()
{
    int asrChecked = 0;
    parser.changeElement(QString::number(calcList->currentIndex()),2,0);
    if (hanafiButton->isChecked()) asrChecked = 1;
    parser.changeElement(QString::number(asrChecked),2,2);
    parser.changeElement(QString::number(hijriBox->value()),2,3);
    parser.changeElement(QString::number(highList->currentIndex()),2,4);
    if (asrMethod != asrChecked) {
        prayers->setAsrMethod(asrChecked);
        QString *times_ = new QString[7];
        times_ = prayers->getDatePrayerTimes(date.year(),date.month(),date.day(),parser.getElement(0,0).toDouble(),parser.getElement(0,1).toDouble(),parser.getElement(0,4).toDouble());
        asrMinutes = calcTime(times[3],times_[3]);
    }
    else {
        asrMinutes = 0;
    }
    //int temp = setDuhrMinutes() + asrMinutes;
    parser.changeElement(QString::number(duhrBox->value()),2,1);
    parser.saveData(file);
    DomParser::changed = true;
}
Esempio n. 13
0
/**
* @brief Function creates a thread
*
* @details Function creates a thread according its cycle time, then
*          unblock the process
*
* @pre void* argument contains argument
*
* @post thread run for its time
*
* @return None
*
*/
   void* thread_perform( void* argument )
      {
       struct pcb_table* temp;   // temp argument
       int time = 0;   // init. time

       temp = ( ( struct pcb_table * ) argument );

       // calculate running time
       time = calcTime( *( temp->current ), *temp );

       // delay that long time
       delay( ( clock_t ) time );

       // print log
       clock_gettime( CLOCK_REALTIME, &endTime );
       totalTime = timeLap( startTime, endTime );
       interruptLog( temp->current, logComment );
       recordLog( &logList, &currentLog, totalTime, logComment );
       if( toMonitor )
          printLog( currentLog );

       // unblock process
       unblockProcess(temp->processNum);
      }   // end of func
Esempio n. 14
0
  void mStop(){
    _tSto = std::chrono::high_resolution_clock::now();
		calcTime();
  }
Esempio n. 15
0
//calculate time diffrence between duhr and asr
int Qcalculation::getAsrDiff(int flag,QString time1,QString time2) {
    if (0 == flag) return calcTime(time1,time2);
    else return -1 * calcTime(time1,time2);
}
Esempio n. 16
0
	double Sin::generate(int i) {		
		return A*sin(calcTime(i) * 2 / double(T));
	};