コード例 #1
0
ファイル: NewChromsweep.cpp プロジェクト: Janee/bedtools2
void NewChromSweep::closeOut() {
	while (!_queryFRM->eof()) {
		nextRecord(true);
	}
	while (!_databaseFRM->eof()) {
		nextRecord(false);
	}
}
コード例 #2
0
ファイル: NewChromsweep.cpp プロジェクト: Yixf-Self/bedtools2
bool NewChromSweep::next(RecordKeyVector &retList) {
	retList.clearVector();


	//make sure the first read of the query file is tested for chrom sort order.
	bool needTestSortOrder = false;
	if (_currQueryRec != NULL) {
		_queryFRM->deleteRecord(_currQueryRec);
	} else {
		needTestSortOrder = true;
	}

	if (!nextRecord(true)) return false; // query EOF hit
	retList.setKey(_currQueryRec);

	if (needTestSortOrder) testChromOrder(_currQueryRec);

	if (allCurrDBrecsNull() && allCachesEmpty() && !_runToQueryEnd) {
		_testLastQueryRec = true;
		return false;
	}
	_currQueryChromName = _currQueryRec->getChrName();

	masterScan(retList);

	if (_context->getSortOutput()) {
		retList.sortVector();
	}

	_prevQueryChromName = _currQueryChromName;
	return true;
}
コード例 #3
0
ファイル: FLOPPYBitmap.cpp プロジェクト: dtumer/cpe468Project
int FLOPPYBitmap::nextRecord() {
	uint8_t curRecord = 0;
		
	if (curBitmapByte == NULL) { //make sure curBitmap is set to original byte
		curBitmapByte = bitmap;
	}
	
	//check to see if there are any more occupied records in the bitmap
	if (numRecords - curRecordOffset > 0) {
		curRecord = 1 << (7 - curBit) & *curBitmapByte;
		
		//if we've looked through the whole byte
		if (curBit == 7) {
			curBit = 0;
			curBitmapByte++;
		}
		else {
			curBit++;
		}
		
		//if we're looking at a bit that is empty call nextRecord() again
		if (curRecord == 0) {	
			curRecordOffset++;
			return nextRecord();
		}
		else {
			return curRecordOffset++;
		}
	}
	else { //reset current bitmap byte to the beginning of the bitmap
		curBitmapByte = bitmap;
		curRecordOffset = 0;
		return -1;
	}
}
コード例 #4
0
ファイル: NewChromsweep.cpp プロジェクト: Yixf-Self/bedtools2
void NewChromSweep::masterScan(RecordKeyVector &retList) {

	for (int i=0; i < _numDBs; i++) {
		if (dbFinished(i) || chromChange(i, retList, true)) {
			continue;
		} else {

			// scan the database cache for hits
			scanCache(i, retList);
			//skip if we hit the end of the DB
			// advance the db until we are ahead of the query. update hits and cache as necessary
			while (_currDbRecs[i] != NULL &&
					_currQueryRec->sameChrom(_currDbRecs[i]) &&
					!(_currDbRecs[i]->after(_currQueryRec))) {
				if (intersects(_currQueryRec, _currDbRecs[i])) {
					retList.push_back(_currDbRecs[i]);
				}
				if (_currQueryRec->after(_currDbRecs[i])) {
					_dbFRMs[i]->deleteRecord(_currDbRecs[i]);
					_currDbRecs[i] = NULL;
				} else {
					_caches[i].push_back(_currDbRecs[i]);
					_currDbRecs[i] = NULL;
				}
				nextRecord(false, i);
			}
		}
	}
}
コード例 #5
0
ファイル: NewChromsweep.cpp プロジェクト: Janee/bedtools2
bool NewChromSweep::init() {
    
	//Create new FileRecordMgrs for the two input files.
	//Open them, and get the first record from each.
	//if any of that goes wrong, return false;
	//otherwise, return true.
    _queryFRM = new FileRecordMgr(_context->getQueryFileIdx(), _context);
    _databaseFRM = new FileRecordMgr(_context->getDatabaseFileIdx(), _context);
    
    if (!_queryFRM->open()) {
    	return false;
    }
    if (!_databaseFRM->open()) {
    	return false;
    }

    _context->determineOutputType();

    nextRecord(false);
    if (_currDatabaseRec == NULL) {
    	return false;
    }

    //determine whether to stop when the database end is hit, or keep going until the
    //end of the query file is hit as well.

    if (_context->getNoHit() || _context->getWriteCount() || _context->getWriteOverlap() || _context->getWriteAllOverlap() || _context->getLeftJoin()) {
    	_runToQueryEnd = true;
    }
    _wasInitialized = true;
    return true;
 }
コード例 #6
0
bool NewChromSweep::init() {

    //Create new FileRecordMgrs for the input files.
    //Open them, and get the first record from each.
    //otherwise, return true.
    _queryFRM = _context->getFile(_context->getQueryFileIdx());

    _dbFRMs.resize(_numDBs, NULL);
    for (int i=0; i < _numDBs; i++) {
        _dbFRMs[i] = _context->getDatabaseFile(i);
    }

    _currDbRecs.resize(_numDBs, NULL);
    if (!_context->hasGenomeFile()) 
    {
        _fileTracks.resize(_numFiles, NULL);
        for (int i=0; i < _numFiles; i++) 
        {
            _fileTracks[i] = new _orderTrackType;
        }
    }

    for (int i=0; i < _numDBs; i++) {
        nextRecord(false, i);
        testChromOrder(_currDbRecs[i]);
    }

    _caches.resize(_numDBs);
    _wasInitialized = true;
    return true;
 }
コード例 #7
0
ファイル: NewChromsweep.cpp プロジェクト: Janee/bedtools2
bool NewChromSweep::chromChange()
{
    // the files are on the same chrom
	if (_currDatabaseRec == NULL || _currQueryRec->sameChrom(_currDatabaseRec)) {
		return false;
	}
	// the query is ahead of the database. fast-forward the database to catch-up.
	if (_currQueryRec->chromAfter(_currDatabaseRec)) {

		while (_currDatabaseRec != NULL &&
				_currQueryRec->chromAfter(_currDatabaseRec)) {
			_databaseFRM->deleteRecord(_currDatabaseRec);
			nextRecord(false);
		}
		clearCache();
        return false;
    }
    // the database is ahead of the query.
    else {
        // 1. scan the cache for remaining hits on the query's current chrom.
        if (_currQueryRec->getChrName() == _currChromName)
        {
            scanCache();
        }
        // 2. fast-forward until we catch up and report 0 hits until we do.
        else if (_currQueryRec->chromBefore(_currDatabaseRec))
        {
            clearCache();
        }

        return true;
    }
}
コード例 #8
0
ファイル: NewChromsweep.cpp プロジェクト: Yixf-Self/bedtools2
void NewChromSweep::closeOut(bool testChromOrderVal) {
	if (_testLastQueryRec) {
		testChromOrder(_currQueryRec);
	}
	while (!_queryFRM->eof()) {
		nextRecord(true);
		testChromOrder(_currQueryRec);
	}
	if (testChromOrderVal) testChromOrder(_currQueryRec);

    for (int i=0; i < _numDBs; i++) {
    	while (!_dbFRMs[i]->eof()) {
    		if (testChromOrderVal) testChromOrder(_currDbRecs[i]);
    		nextRecord(false, i);
    	}
   		if (testChromOrderVal) testChromOrder(_currDbRecs[i]);

    }
}
コード例 #9
0
ファイル: NewChromsweep.cpp プロジェクト: Janee/bedtools2
bool NewChromSweep::next(RecordKeyList &next) {
	if (_currQueryRec != NULL) {
		_queryFRM->deleteRecord(_currQueryRec);
	}
	nextRecord(true);
	if (_currQueryRec == NULL) { //eof hit!
		return false;
	}

	if (_currDatabaseRec == NULL && _cache.empty() && !_runToQueryEnd) {
		return false;
	}
	_hits.clear();
	_currChromName = _currQueryRec->getChrName();
	// have we changed chromosomes?
	if (!chromChange()) {
		// scan the database cache for hits
		scanCache();
		//skip if we hit the end of the DB
		// advance the db until we are ahead of the query. update hits and cache as necessary
		while (_currDatabaseRec != NULL &&
				_currQueryRec->sameChrom(_currDatabaseRec) &&
				!(_currDatabaseRec->after(_currQueryRec))) {
			if (intersects(_currQueryRec, _currDatabaseRec)) {
				_hits.push_back(_currDatabaseRec);
			}
			if (_currQueryRec->after(_currDatabaseRec)) {
				_databaseFRM->deleteRecord(_currDatabaseRec);
				_currDatabaseRec = NULL;
			} else {
				_cache.push_back(_currDatabaseRec);
				_currDatabaseRec = NULL;
			}
			nextRecord(false);
		}
	}
	next.setKey(_currQueryRec);
	next.setListNoCopy(_hits);
	return true;
}
コード例 #10
0
ファイル: service.c プロジェクト: CyberGrandChallenge/samples
int main(void) {
	Dataset dataset;
	Portfolio portfolio;
	Record record;
	int recordType;

	dataset.sampleSize = 0;

	while((recordType = nextRecord(&record)) != NO_MORE_RECORDS) {

		if(recordType == BALANCE_RECORD) {
			initPortfolio(&portfolio, record.y);
			continue;
		}

		if(dataset.sampleSize > LEARNING_MODE_SIZE) {

			updateStockValues(record, &portfolio);
			
			if(portfolio.assetBalance >= portfolio.goal) {

				sellAllStock(record, &portfolio);
				sendGoalNotification();
			}

			// check to see if out of cash
			if(portfolio.cashBalance == 0) {

				// If out of stock, quit
				if(portfolio.assetBalance == 0)
					break;

				// sell all stock to raise cash
				sellAllStock(record, &portfolio);
			}


			tradeStocks(record, dataset, &portfolio);

		}

		addRecordToDataset(&dataset, record);



	}

	return 0;

}
コード例 #11
0
ファイル: CloseSweep.cpp プロジェクト: daler/bedtools2
bool CloseSweep::chromChange(int dbIdx, RecordKeyVector &retList)
{
//	if (_currQueryRec->getChrName() == "chr1_gl000191_random" || (_currDbRecs[dbIdx] != NULL && _currDbRecs[dbIdx]->getChrName() == "chr1_gl000191_random")) {
//		printf("Break point here.\n");
//	}

    // the files are on the same chrom
	if (_currDbRecs[dbIdx] == NULL || _currQueryRec->sameChrom(_currDbRecs[dbIdx])) {

		//if this is the first time the query's chrom is ahead of the chrom that was in this cache,
		//then we have to clear the cache.
		if (!_caches[dbIdx].empty() && _currQueryRec->chromAfter(_caches[dbIdx].begin()->value())) {
			clearCache(dbIdx);
			_maxPrevLeftClosestEndPos[dbIdx] = 0;
		}
		return false;
	}
	if (_currDbRecs[dbIdx]->chromAfter(_currQueryRec) && (!_caches[dbIdx].empty() && (_caches[dbIdx].begin()->value()->sameChrom(_currQueryRec)))) {
		//the newest DB record's chrom is ahead of the query, but the cache still
		//has old records on that query's chrom
		scanCache(dbIdx, retList);
		finalizeSelections(dbIdx, retList);
		return true;
	}
	// the query is ahead of the database. fast-forward the database to catch-up.
	if (_currQueryRec->chromAfter(_currDbRecs[dbIdx])) {

		while (_currDbRecs[dbIdx] != NULL &&
				_currQueryRec->chromAfter(_currDbRecs[dbIdx])) {
			_dbFRMs[dbIdx]->deleteRecord(_currDbRecs[dbIdx]);
			nextRecord(false, dbIdx);
		}
		clearCache(dbIdx);
		_maxPrevLeftClosestEndPos[dbIdx] = 0;
        return false;
    }
    // the database is ahead of the query.
    else {
        // 1. scan the cache for remaining hits on the query's current chrom.
		scanCache(dbIdx, retList);

        return true;
    }

	//control can't reach here, but compiler still wants a return statement.
	return true;
}
コード例 #12
0
ファイル: CloseSweep.cpp プロジェクト: daler/bedtools2
void CloseSweep::masterScan(RecordKeyVector &retList) {
	//first clear out everything from the previous scan
	if (_context->reportDistance()) {
		_finalDistances.clear();
	}

	//initialize distances
	for (int i=0; i < _numDBs; i++) {
		_minUpstreamDist[i] = INT_MAX;
		_minDownstreamDist[i] = INT_MAX;
	}

	for (int i=0; i < _numDBs; i++) {

		_minUpstreamRecs[i]->clear();
		_minDownstreamRecs[i]->clear();
		_overlapRecs[i]->clear();

		if (dbFinished(i) || chromChange(i, retList)) {
			continue;
		} else {

			// scan the database cache for hits
			scanCache(i, retList);

			// skip if we hit the end of the DB
			// advance the db until we are ahead of the query. update hits and cache as necessary
			bool stopScanning = false;
			while (_currDbRecs[i] != NULL &&
					_currQueryRec->sameChrom(_currDbRecs[i]) &&
					!stopScanning) {
				if (considerRecord(_currDbRecs[i], i, stopScanning) == DELETE) {
					_dbFRMs[i]->deleteRecord(_currDbRecs[i]);
					_currDbRecs[i] = NULL;
				} else {
					_caches[i].push_back(_currDbRecs[i]);
					_currDbRecs[i] = NULL;
				}
				nextRecord(false, i);
			}
		}
		finalizeSelections(i, retList);
	}
	checkMultiDbs(retList);
}
コード例 #13
0
ファイル: NewChromsweep.cpp プロジェクト: Yixf-Self/bedtools2
bool NewChromSweep::chromChange(int dbIdx, RecordKeyVector &retList, bool wantScan)
{
	const Record *dbRec = _currDbRecs[dbIdx];

	if (_currQueryRec != NULL && _currQueryChromName != _prevQueryChromName) {
		_context->testNameConventions(_currQueryRec);
		testChromOrder(_currQueryRec);
	}

	if (dbRec != NULL) {
		_context->testNameConventions(dbRec);
		testChromOrder(dbRec);
	}

	// If the query rec and db rec are on the same chrom, stop.
	if (dbRec != NULL && _currQueryRec != NULL && _currQueryRec->sameChrom(dbRec)) return false;


	if (dbRec == NULL || _currQueryRec == NULL) return false;

	if (queryChromAfterDbRec(dbRec)) {
		// the query is ahead of the database. fast-forward the database to catch-up.
		QuickString oldDbChrom(dbRec->getChrName());
		while (dbRec != NULL &&
				queryChromAfterDbRec(dbRec)) {
				_dbFRMs[dbIdx]->deleteRecord(dbRec);
			if (!nextRecord(false, dbIdx)) break;
			dbRec =  _currDbRecs[dbIdx];
			const QuickString &newDbChrom = dbRec->getChrName();
			if (newDbChrom != oldDbChrom) {
				testChromOrder(dbRec);
				oldDbChrom = newDbChrom;
			}
		}
		clearCache(dbIdx);
        return false;
    } else {
        // the database is ahead of the query.
        // scan the cache for remaining hits on the query's current chrom.
    	if (wantScan) scanCache(dbIdx, retList);
        return true;
    }
}
コード例 #14
0
ファイル: NewChromsweep.cpp プロジェクト: Yixf-Self/bedtools2
bool NewChromSweep::init() {
    
	//Create new FileRecordMgrs for the input files.
	//Open them, and get the first record from each.
	//otherwise, return true.
    _queryFRM = _context->getFile(_context->getQueryFileIdx());
    
    _dbFRMs.resize(_numDBs, NULL);
    for (int i=0; i < _numDBs; i++) {
    	_dbFRMs[i] = _context->getDatabaseFile(i);
    }

    _currDbRecs.resize(_numDBs, NULL);
    if (!_context->hasGenomeFile()) {
    	_fileTracks.resize(_numFiles, NULL);
    	for (int i=0; i < _numFiles; i++) {
    		_fileTracks[i] = new _orderTrackType;
    	}
    }


    for (int i=0; i < _numDBs; i++) {
    	nextRecord(false, i);
    	testChromOrder(_currDbRecs[i]);
    }

    _caches.resize(_numDBs);

    //determine whether to stop when the database end is hit, or keep going until the
    //end of the query file is hit as well.

    if (_context->getNoHit() || _context->getWriteCount() || _context->getWriteOverlap() || _context->getWriteAllOverlap() || _context->getLeftJoin()) {
    	_runToQueryEnd = true;
    }
    _wasInitialized = true;
    return true;
 }
コード例 #15
0
ファイル: merge.c プロジェクト: newATyork/Query-Parser
void naiveMerge2(int recSize, int memSize, int maxDegree, char* fileInPath, char* outfileprefix, char* fileOutPath)
{
	FILE *finlist, *foutlist;  /* files with lists of in/output file names */
	
	int numFiles = 0;        /* # of output files that are generated */
	int degree;   /* actual degree */
	char *bufSpace;
	char filename1[300];
	char filename2[300];

	void heapify();   /* function declaration */
	void writeRecord();  /*  function declaration */
	int nextRecord();  /* function declaration */
	int i;
	int fsRet;
	
	bufSpace = (unsigned char *) malloc(memSize);
	ioBufs = (buffer *) malloc((maxDegree + 1) * sizeof(buffer));
	heap.arr = (int *) malloc((maxDegree + 1) * sizeof(int));
	heap.cache = (void *) malloc(maxDegree * recSize);     /* record size is 12Bytes, lengthOfPosting */

	finlist = fopen(fileInPath, "r");
	foutlist = fopen(fileOutPath, "w");

	while (!feof(finlist))
	{
		  for (degree = 0; degree < maxDegree; degree++)
		  {
			    //memset(filename1, 0, sizeof(filename1));
			    fsRet = fscanf(finlist, "%s", filename1);
			    if (feof(finlist)) 
				     break;
			    //puts(filename1);
			    ioBufs[degree].f = fopen(filename1, "r"); 
		  }
		  if (degree == 0) break;

		    /* open output file (output is handled by the buffer ioBufs[degree]) */
		  sprintf(filename2, "%s%d", outfileprefix, numFiles);
		  ioBufs[degree].f = fopen(filename2, "w");

		  /* assign buffer space (all buffers same space) and init to empty */
		  bufSize = memSize / ((degree + 1) * recSize);
		  for (i = 0; i <= degree; i++)
		  {
			    ioBufs[i].buf = &(bufSpace[i * bufSize * recSize]);
			    ioBufs[i].curRec = 0;
			    ioBufs[i].numRec = 0;
		  }

	    /* initialize heap with first elements. Heap root is in heap[1] (not 0) */
		  heap.size = degree;
		  for (i = 0; i < degree; i++)  heap.arr[i+1] = nextRecord(i);
		  for (i = degree; i > 0; i--)  heapify(i);

	    /* now do the merge - ridiculously simple: do 2 steps until heap empty */
		  while (heap.size > 0)
		  {
			      /* copy the record corresponding to the minimum to the output */
			    writeRecord(&(ioBufs[degree]), heap.arr[1]); 

			      /* replace minimum in heap by the next record from that file */
			    if (nextRecord(heap.arr[1]) == -1)
				heap.arr[1] = heap.arr[heap.size--];     /* if EOF, shrink heap by 1 */
			    if (heap.size > 1)  heapify(1);
		  }
		    
	    /* flush output, add output file to list, close in/output files, and next */
		  writeRecord(&(ioBufs[degree]), -1); 

		  fprintf(foutlist, "%s\n", filename2);

		  for (i = 0; i <= degree; i++)  
			fclose(ioBufs[i].f);

		  numFiles++;
	}

	fclose(finlist);
	fclose(foutlist);

	free(ioBufs);
	free(heap.arr);
	free(heap.cache);
}
コード例 #16
0
ファイル: CloseSweep.cpp プロジェクト: nkindlon/bedtools2
bool CloseSweep::chromChange(int dbIdx, RecordKeyVector &retList, bool wantScan)
{
    Record *dbRec = _currDbRecs[dbIdx];

    bool haveQuery = _currQueryRec != NULL;
    bool haveDB = dbRec != NULL;

    if (haveQuery && _currQueryChromName != _prevQueryChromName) {
        _context->testNameConventions(_currQueryRec);
        testChromOrder(_currQueryRec);
    }

    if (haveDB) {
        _context->testNameConventions(dbRec);
        testChromOrder(dbRec);
    }

    // the files are on the same chrom
    if (haveQuery && (!haveDB || _currQueryRec->sameChrom(dbRec))) {

        //if this is the first time the query's chrom is ahead of the chrom that was in this cache,
        //then we have to clear the cache.
        if (!_caches[dbIdx].empty() && queryChromAfterDbRec(_caches[dbIdx].begin()->value())) {
            clearCache(dbIdx);
            clearClosestEndPos(dbIdx);
        }
        return false;
    }

    if (!haveQuery || !haveDB) return false;

    if (!_caches[dbIdx].empty() && (_caches[dbIdx].begin()->value()->sameChrom(_currQueryRec))) {
        //the newest DB record's chrom is ahead of the query, but the cache still
        //has old records on that query's chrom
        scanCache(dbIdx, retList);
        finalizeSelections(dbIdx, retList);
        return true;
    }


    // the query is ahead of the database. fast-forward the database to catch-up.
    if (queryChromAfterDbRec(dbRec)) {
        string oldDbChrom(dbRec->getChrName());

        while (dbRec != NULL &&
                queryChromAfterDbRec(dbRec)) {
            _dbFRMs[dbIdx]->deleteRecord(dbRec);
            if (!nextRecord(false, dbIdx)) break;
            dbRec =  _currDbRecs[dbIdx];
            const string &newDbChrom = dbRec->getChrName();
            if (newDbChrom != oldDbChrom) {
                testChromOrder(dbRec);
                oldDbChrom = newDbChrom;
            }
        }
        clearCache(dbIdx);
        clearClosestEndPos(dbIdx);
        return false;
    }
    // the database is ahead of the query.
    else {
        // 1. scan the cache for remaining hits on the query's current chrom.
        if (wantScan) scanCache(dbIdx, retList);

        return true;
    }

    //control can't reach here, but compiler still wants a return statement.
    return true;
}
コード例 #17
0
bool QFTCSPCReaderPicoquantPT3::open(const QString &filename, const QString &parameters) {
    Q_UNUSED(parameters)

    close();
    fileinfo.init(filename);
    tttrfile=fopen(filename.toLatin1().data(), "rb");
    if (tttrfile) {
        QString error="";
        bool ok=PT3ReadConfiguration(tttrfile, &txtHeader, &binHeader, &boardHeader, &TTTRHeader, error);
        syncperiod = (double)1E9 / TTTRHeader.CntRate0; //in nanoseconds

        if (!ok) {
            setLastError(error);
            return false;
        }


        fileinfo.properties["CommentField"]=(char*)txtHeader.CommentField;
        fileinfo.properties["FileTime"]=(char*)txtHeader.FileTime;
        fileinfo.properties["CreatorName"]=(char*)txtHeader.CreatorName;
        fileinfo.properties["CreatorVersion"]=(char*)txtHeader.CreatorVersion;

        fileinfo.properties["Tacq"]=(qlonglong)binHeader.Tacq;
        fileinfo.properties["NumberOfBoards"]=(qlonglong)binHeader.NumberOfBoards;
        fileinfo.properties["RoutingChannels"]=(qlonglong)binHeader.RoutingChannels;
        fileinfo.properties["MeasMode"]=(qlonglong)binHeader.MeasMode;
        fileinfo.properties["SubMode"]=(qlonglong)binHeader.SubMode;
        fileinfo.properties["StopAt"]=(qlonglong)binHeader.StopAt;
        fileinfo.properties["StopOnOvfl"]=(qlonglong)binHeader.StopOnOvfl;

        fileinfo.properties["HardwareIdent"]=(char*)boardHeader.HardwareIdent;
        fileinfo.properties["HardwareVersion"]=(char*)boardHeader.HardwareVersion;
        fileinfo.properties["HardwareSerial"]=boardHeader.HardwareSerial;
        fileinfo.properties["SyncDivider"]=(qlonglong)boardHeader.SyncDivider;
        fileinfo.properties["CFDZeroCross0"]=(qlonglong)boardHeader.CFDZeroCross0;
        fileinfo.properties["CFDLevel0"]=(qlonglong)boardHeader.CFDLevel0;
        fileinfo.properties["CFDZeroCross1"]=(qlonglong)boardHeader.CFDZeroCross1;
        fileinfo.properties["CFDLevel1"]=(qlonglong)boardHeader.CFDLevel1;
        fileinfo.properties["Resolution"]=boardHeader.Resolution;


        fileinfo.properties["CntRate0"]=(qlonglong)TTTRHeader.CntRate0;
        fileinfo.properties["CntRate1"]=(qlonglong)TTTRHeader.CntRate1;
        fileinfo.properties["StopAfter"]=(qlonglong)TTTRHeader.StopAfter;
        fileinfo.properties["StopReason"]=(qlonglong)TTTRHeader.StopReason;
        fileinfo.properties["NoOfRecords"]=(qlonglong)TTTRHeader.Records;

        fgetpos(tttrfile, &fileResetPos);
        currentTTTRRecordNum=0;
        current.microtime_offset=0;
        current.microtime_deltaT=boardHeader.Resolution;
        current.isPhoton=true;
        current.marker_type=0;
        nextRecord();

        // read some photons to estimate a countrate
        cr.clear();
        double t=0;
        uint16_t cnt=0;
        do {
            QFTCSPCRecord r=getCurrentRecord();
            t=r.absoluteTime();
            cr[r.input_channel]=cr.value(r.input_channel, 0)+1;
            cnt++;
        } while (nextRecord() && (t<0.01) && (cnt<10000));
        for (int i=0; i<inputChannels(); i++) {
            cr[i]=cr.value(i, 0)/t/1000.0;
        }

        fsetpos(tttrfile, &fileResetPos);
        currentTTTRRecordNum=0;
        current.microtime_offset=0;
        current.microtime_deltaT=boardHeader.Resolution;

        duration=double(binHeader.Tacq)/1000.0;

        return true;
    }
    setLastError(QObject::tr("could not open TTTR file '%1'").arg(filename));
    duration=0;
    return false;
}
コード例 #18
0
void FLFormRecordDB::setMainWidget( QWidget * w ) {
    if ( !cursor_ || !w )
        return ;

    if ( !cursor_->metadata() )
        return ;

    if ( showed ) {
        if ( mainWidget_ && mainWidget_ != w )
            initMainWidget( w );
    } else
        w->hide();

    if ( pushButtonAcceptContinue )
        pushButtonAcceptContinue->hide();

    if ( pushButtonAccept )
        pushButtonAccept->hide();

    if ( pushButtonCancel )
        pushButtonCancel->hide();

    if ( pushButtonFirst )
        pushButtonFirst->hide();

    if ( pushButtonPrevious )
        pushButtonPrevious->hide();

    if ( pushButtonNext )
        pushButtonNext->hide();

    if ( pushButtonLast )
        pushButtonLast->hide();

    if ( layoutButtons )
        delete layoutButtons;

    if ( layout )
        delete layout;

    w->setFont( qApp->font() );
    layout = new QVBoxLayout( this, 2, 3, "vlay" + name_ );

    layout->add( w );

    layoutButtons = new QHBoxLayout( layout, 3, "hlay" + name_ ) ;
    QSpacerItem *spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding,
            QSizePolicy::Minimum );

    QSize pbSize( 26, 26 );

#ifdef FL_DEBUGGER
    if ( !pushButtonIDE ) {
        pushButtonIDE = new QPushButton( this, "pushButtonIDE" );
        connect( pushButtonIDE, SIGNAL( clicked() ), this, SLOT( openIde() ) );
    }
    pushButtonIDE->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                  pushButtonIDE->sizePolicy().hasHeightForWidth() ) );
    pushButtonIDE->setMinimumSize( pbSize );
    pushButtonIDE->setMaximumSize( pbSize );
    QPixmap qsa( QPixmap::fromMimeSource( "bug.png" ) );
    pushButtonIDE->setIconSet( qsa );
    pushButtonIDE->setAccel( QKeySequence( Qt::Key_F3 ) );
    QToolTip::add( pushButtonIDE, tr( "Abrir Depurador (F3)" ) );
    QWhatsThis::add( pushButtonIDE, tr( "Abrir Depurador (F3)" ) );
    pushButtonIDE->setFocusPolicy( QWidget::NoFocus );
    layoutButtons->addWidget( pushButtonIDE );
    connect( pushButtonIDE, SIGNAL( clicked() ), this, SLOT( openIde() ) );
#endif

    layoutButtons->addItem( spacer_2 );

    if ( cursor_->modeAccess() == FLSqlCursor::EDIT ||
            cursor_->modeAccess() == FLSqlCursor::BROWSE ) {
        if ( !pushButtonFirst ) {
            pushButtonFirst = new QPushButton( this, "pushButtonFirst" );
            connect( pushButtonFirst, SIGNAL( clicked() ), this, SLOT( firstRecord() ) );
        }
        pushButtonFirst->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                        pushButtonFirst->sizePolicy().hasHeightForWidth() ) );
        pushButtonFirst->setMinimumSize( pbSize );
        pushButtonFirst->setMaximumSize( pbSize );
        QPixmap rld( QPixmap::fromMimeSource( "first.png" ) );
        pushButtonFirst->setIconSet( rld );
        pushButtonFirst->setAccel( QKeySequence( Qt::Key_F5 ) );
        QToolTip::add( pushButtonFirst, tr( "Aceptar los cambios e ir al primer registro (F5)" ) );
        QWhatsThis::add( pushButtonFirst, tr( "Aceptar los cambios e ir al primer registro (F5)" ) );
        pushButtonFirst->setFocusPolicy( QWidget::NoFocus );
        layoutButtons->addWidget( pushButtonFirst );
        pushButtonFirst->show();

        if ( !pushButtonPrevious ) {
            pushButtonPrevious = new QPushButton( this, "pushButtonPrevious" );
            connect( pushButtonPrevious, SIGNAL( clicked() ), this, SLOT( previousRecord() ) );
        }
        pushButtonPrevious->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                           pushButtonPrevious->sizePolicy().hasHeightForWidth() ) );
        pushButtonPrevious->setMinimumSize( pbSize );
        pushButtonPrevious->setMaximumSize( pbSize );
        QPixmap rld2( QPixmap::fromMimeSource( "previous.png" ) );
        pushButtonPrevious->setIconSet( rld2 );
        pushButtonPrevious->setAccel( QKeySequence( Qt::Key_F6 ) );
        QToolTip::add( pushButtonPrevious, tr( "Aceptar los cambios e ir al registro anterior (F6)" ) );
        QWhatsThis::add( pushButtonPrevious, tr( "Aceptar los cambios e ir al registro anterior (F6)" ) );
        pushButtonPrevious->setFocusPolicy( QWidget::NoFocus );
        layoutButtons->addWidget( pushButtonPrevious );
        pushButtonPrevious->show();

        if ( !pushButtonNext ) {
            pushButtonNext = new QPushButton( this, "pushButtonNext" );
            connect( pushButtonNext, SIGNAL( clicked() ), this, SLOT( nextRecord() ) );
        }
        pushButtonNext->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                       pushButtonNext->sizePolicy().hasHeightForWidth() ) );
        pushButtonNext->setMinimumSize( pbSize );
        pushButtonNext->setMaximumSize( pbSize );
        QPixmap rld3( QPixmap::fromMimeSource( "next.png" ) );
        pushButtonNext->setIconSet( rld3 );
        pushButtonNext->setAccel( QKeySequence( Qt::Key_F7 ) );
        QToolTip::add( pushButtonNext, tr( "Aceptar los cambios e ir al registro siguiente (F7)" ) );
        QWhatsThis::add( pushButtonNext, tr( "Aceptar los cambios e ir al registro siguiente (F7)" ) );
        pushButtonNext->setFocusPolicy( QWidget::NoFocus );
        layoutButtons->addWidget( pushButtonNext );
        pushButtonNext->show();

        if ( !pushButtonLast ) {
            pushButtonLast = new QPushButton( this, "pushButtonLast" );
            connect( pushButtonLast, SIGNAL( clicked() ), this, SLOT( lastRecord() ) );
        }
        pushButtonLast->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                       pushButtonLast->sizePolicy().hasHeightForWidth() ) );
        pushButtonLast->setMinimumSize( pbSize );
        pushButtonLast->setMaximumSize( pbSize );
        QPixmap rld4( QPixmap::fromMimeSource( "last.png" ) );
        pushButtonLast->setIconSet( rld4 );
        pushButtonLast->setAccel( QKeySequence( Qt::Key_F8 ) );
        QToolTip::add( pushButtonLast, tr( "Aceptar los cambios e ir al último registro (F8)" ) );
        QWhatsThis::add( pushButtonLast, tr( "Aceptar los cambios e ir al último registro (F8)" ) );
        pushButtonLast->setFocusPolicy( QWidget::NoFocus );
        layoutButtons->addWidget( pushButtonLast );
        pushButtonLast->show();
    }

    if ( cursor_->modeAccess() != FLSqlCursor::BROWSE ) {
        if ( showAcceptContinue_ ) {
            if ( !pushButtonAcceptContinue ) {
                pushButtonAcceptContinue = new QPushButton( this, "pushButtonAcceptContinue" );
                connect( pushButtonAcceptContinue, SIGNAL( clicked() ), this, SLOT( acceptContinue() ) );
            }
            pushButtonAcceptContinue->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                    pushButtonAcceptContinue->sizePolicy().hasHeightForWidth() ) );
            pushButtonAcceptContinue->setMinimumSize( pbSize );
            pushButtonAcceptContinue->setMaximumSize( pbSize );
            QPixmap rld( QPixmap::fromMimeSource( "reload.png" ) );
            pushButtonAcceptContinue->setIconSet( rld );
            pushButtonAcceptContinue->setFocusPolicy( QWidget::NoFocus );
            pushButtonAcceptContinue->setAccel( QKeySequence( Qt::Key_F9 ) );
            QToolTip::add( pushButtonAcceptContinue, tr( "Aceptar los cambios y continuar con la edición de un nuevo registro (F9)" ) );
            QWhatsThis::add( pushButtonAcceptContinue, tr( "Aceptar los cambios y continuar con la edición de un nuevo registro (F9)" ) );
            layoutButtons->addWidget( pushButtonAcceptContinue );
            pushButtonAcceptContinue->show();
        }

        if ( !pushButtonAccept ) {
            pushButtonAccept = new QPushButton( this, "pushButtonAccept" );
            connect( pushButtonAccept, SIGNAL( clicked() ), this, SLOT( accept() ) );
        }
        pushButtonAccept->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                         pushButtonAccept->sizePolicy().hasHeightForWidth() ) );
        pushButtonAccept->setMinimumSize( pbSize );
        pushButtonAccept->setMaximumSize( pbSize );
        QPixmap ok( QPixmap::fromMimeSource( "button_ok.png" ) );
        pushButtonAccept->setIconSet( ok );
        pushButtonAccept->setFocusPolicy( QWidget::NoFocus );
        pushButtonAccept->setAccel( QKeySequence( Qt::Key_F10 ) );
        QToolTip::add( pushButtonAccept, tr( "Aceptar los cambios y cerrar formulario (F10)" ) );
        QWhatsThis::add( pushButtonAccept, tr( "Aceptar los cambios y cerrar formulario (F10)" ) );
        layoutButtons->addWidget( pushButtonAccept );
        pushButtonAccept->show();
    }

    if ( !pushButtonCancel ) {
        pushButtonCancel = new QPushButton( this, "pushButtonCancel" );
        connect( cursor_, SIGNAL( autoCommit() ), this, SLOT( disablePushButtonCancel() ) );
        connect( pushButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
    }
    pushButtonCancel->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                     pushButtonCancel->sizePolicy().hasHeightForWidth() ) );
    pushButtonCancel->setMinimumSize( pbSize );
    pushButtonCancel->setMaximumSize( pbSize );
    QPixmap cancel( QPixmap::fromMimeSource( "button_cancel.png" ) );
    pushButtonCancel->setIconSet( cancel );
    if ( cursor_->modeAccess() != FLSqlCursor::BROWSE ) {
        pushButtonCancel->setFocusPolicy( QWidget::NoFocus );
        pushButtonCancel->setAccel( 4096 );
        QToolTip::add( pushButtonCancel, tr( "Cancelar los cambios y cerrar formulario (Esc)" ) );
        QWhatsThis::add( pushButtonCancel, tr( "Cancelar los cambios y cerrar formulario (Esc)" ) );
    } else {
        QPixmap ok( QPixmap::fromMimeSource( "button_cancel.png" ) );
        pushButtonCancel->setIconSet( ok );
        pushButtonCancel->setFocusPolicy( QWidget::StrongFocus );
        pushButtonCancel->setFocus();
        pushButtonCancel->setAccel( 4096 );
        QToolTip::add( pushButtonCancel, tr( "Aceptar y cerrar formulario (Esc)" ) );
        QWhatsThis::add( pushButtonCancel, tr( "Aceptar y cerrar formulario (Esc)" ) );
    }
    pushButtonCancel->setDefault( true );
    layoutButtons->addWidget( pushButtonCancel );
    pushButtonCancel->show();

    mainWidget_ = w;
    mainWidget_->setFocusPolicy( QWidget::NoFocus );
    int mWidth = mainWidget_->width();
    int mHeight = mainWidget_->height();
    QWidget * actWin = qApp->activeWindow();
    QRect screen = ( actWin ? actWin->geometry() : qApp->mainWidget()->geometry() );
    QRect desk = QApplication::desktop()->geometry();
    QPoint p = screen.center() - QPoint( mWidth / 2, mHeight / 2 );
    if ( p.x() + mWidth > desk.width() )
        p.setX( desk.width() - mWidth );
    if ( p.y() + mHeight > desk.height() )
        p.setY( desk.height() - mHeight );
    if ( p.x() < 0 )
        p.setX( 0 );
    if ( p.y() < 0 )
        p.setY( 0 );
    move( p );
}
コード例 #19
0
bool QFTCSPCReaderPicoquant::open(const QString &filename, const QString &parameters) {
    Q_UNUSED(parameters)
    close();
    fileinfo.init(filename);
    tttrfile=fopen(filename.toLatin1().data(), "rb");
    if (tttrfile) {
        QString error="";
        isV6=false;
        bool ok=TTTRReadConfiguration(tttrfile, &txtHeader, &binHeader, &boardHeader, &TTTRHeader, error, isV6);
        if (!ok && isV6) {
            fseek(tttrfile,0,SEEK_SET);
            ok=TTTRReadConfiguration6(tttrfile, &txtHeader6, &binHeader6, &boardHeader6, &TTTRHeader6, error);
        }

        if (!ok) {
            setLastError(error);
            return false;
        }

        if (isV6) {
            fileinfo.properties["CommentField"]=(char*)txtHeader6.CommentField;
            fileinfo.properties["FileTime"]=(char*)txtHeader6.FileTime;
            fileinfo.properties["CreatorName"]=(char*)txtHeader6.CreatorName;
            fileinfo.properties["CreatorVersion"]=(char*)txtHeader6.CreatorVersion;

            fileinfo.properties["NumberOfChannels"]=(qlonglong)binHeader6.Channels;
            fileinfo.properties["NumberOfBoards"]=(qlonglong)binHeader6.NumberOfBoards;
            fileinfo.properties["RoutingChannels"]=(qlonglong)binHeader6.RoutingChannels;
            fileinfo.properties["MeasMode"]=(qlonglong)binHeader6.MeasMode;
            fileinfo.properties["SubMode"]=(qlonglong)binHeader6.SubMode;
            fileinfo.properties["AcquisitionTime"]=(qlonglong)binHeader6.Tacq;
            fileinfo.properties["StopAt"]=(qlonglong)binHeader6.StopAt;
            fileinfo.properties["StopOnOvfl"]=(qlonglong)binHeader6.StopOnOvfl;

            fileinfo.properties["BoardSerial"]=(qlonglong)boardHeader6.BoardSerial;
            fileinfo.properties["CFDZeroCross"]=(qlonglong)boardHeader6.CFDZeroCross;
            fileinfo.properties["CFDDiscrMin"]=(qlonglong)boardHeader6.CFDDiscrMin;
            fileinfo.properties["SyncLevel"]=(qlonglong)boardHeader6.SyncLevel;
            fileinfo.properties["CFDDiscrMin"]=(qlonglong)boardHeader6.CFDDiscrMin;

            fileinfo.properties["Globclock"]=(qlonglong)TTTRHeader6.Globclock;
            fileinfo.properties["SyncRate"]=(qlonglong)TTTRHeader6.SyncRate;
            fileinfo.properties["TTTRCFDRate"]=(qlonglong)TTTRHeader6.TTTRCFDRate;
            fileinfo.properties["TTTRStopAfter"]=(qlonglong)TTTRHeader6.TTTRStopAfter;
            fileinfo.properties["TTTRStopReason"]=(qlonglong)TTTRHeader6.TTTRStopReason;
            fileinfo.properties["NoOfRecords"]=(qlonglong)TTTRHeader6.NoOfRecords;
        } else {
            fileinfo.properties["CommentField"]=(char*)txtHeader.CommentField;
            fileinfo.properties["FileTime"]=(char*)txtHeader.FileTime;
            fileinfo.properties["HardwareVersion"]=(char*)txtHeader.HardwareVersion;
            fileinfo.properties["SoftwareVersion"]=(char*)txtHeader.SoftwareVersion;

            fileinfo.properties["NumberOfChannels"]=(qlonglong)binHeader.Channels;
            fileinfo.properties["NumberOfBoards"]=(qlonglong)binHeader.NumberOfBoards;
            fileinfo.properties["RoutingChannels"]=(qlonglong)binHeader.RoutingChannels;
            fileinfo.properties["MeasMode"]=(qlonglong)binHeader.MeasMode;
            fileinfo.properties["SubMode"]=(qlonglong)binHeader.SubMode;
            fileinfo.properties["AcquisitionTime"]=(qlonglong)binHeader.Tacq;
            fileinfo.properties["StopAt"]=(qlonglong)binHeader.StopAt;
            fileinfo.properties["StopOnOvfl"]=(qlonglong)binHeader.StopOnOvfl;

            fileinfo.properties["BoardSerial"]=(qlonglong)boardHeader.BoardSerial;
            fileinfo.properties["CFDZeroCross"]=(qlonglong)boardHeader.CFDZeroCross;
            fileinfo.properties["CFDDiscrMin"]=(qlonglong)boardHeader.CFDDiscrMin;
            fileinfo.properties["SyncLevel"]=(qlonglong)boardHeader.SyncLevel;
            fileinfo.properties["CFDDiscrMin"]=(qlonglong)boardHeader.CFDDiscrMin;

            fileinfo.properties["Globclock"]=(qlonglong)TTTRHeader.Globclock;
            fileinfo.properties["SyncRate"]=(qlonglong)TTTRHeader.SyncRate;
            fileinfo.properties["TTTRCFDRate"]=(qlonglong)TTTRHeader.TTTRCFDRate;
            fileinfo.properties["TTTRStopAfter"]=(qlonglong)TTTRHeader.TTTRStopAfter;
            fileinfo.properties["TTTRStopReason"]=(qlonglong)TTTRHeader.TTTRStopReason;
            fileinfo.properties["NoOfRecords"]=(qlonglong)TTTRHeader.NoOfRecords;
        }

        fgetpos(tttrfile, &fileResetPos);
        currentTTTRRecordNum=0;
        current.microtime_offset=0;
        if (isV6) current.microtime_deltaT=boardHeader6.Resolution;
        else current.microtime_deltaT=boardHeader.Resolution;
        nextRecord();

        // read some photons to estimate a countrate
        cr.clear();
        double t=0;
        uint16_t cnt=0;
        do {
            QFTCSPCRecord r=getCurrentRecord();
            t=r.absoluteTime();
            cr[r.input_channel]=cr.value(r.input_channel, 0)+1;
            cnt++;
        } while (nextRecord() && (t<0.01) && (cnt<10000));
        for (int i=0; i<inputChannels(); i++) {
            cr[i]=cr.value(i, 0)/t/1000.0;
        }

        fsetpos(tttrfile, &fileResetPos);
        currentTTTRRecordNum=0;
        current.microtime_offset=0;
        if (isV6) current.microtime_deltaT=boardHeader6.Resolution;
        else current.microtime_deltaT=boardHeader.Resolution;

        return true;
    }
    setLastError(QObject::tr("could not open TTTR file '%1'").arg(filename));
    return false;
}
コード例 #20
0
ファイル: merge.c プロジェクト: newATyork/Inverted-Indexer
int main(int argc, char* argv[])
{  
	  //printf("posting lenght is :%d \n",sizeof(posting));
	
	  FILE *finlist, *foutlist;  /* files with lists of in/output file names */

	  int memSize;             /* available memory for merge buffers (in bytes) */
	  int maxDegree, degree;   /* max allowed merge degree, and actual degree */
	  int numFiles = 0;        /* # of output files that are generated */
	  char *bufSpace;
	  char *basepath = "/home/alexwang/mycode/readgz/savedata/";
	  char filename[200];
	  char completefilename[500];
	  void heapify();   /* function declaration */
	  void writeRecord();  /*  function declaration */
	  int nextRecord();  /* function declaration */
	  int i;
	  int fsRet;
	
	  clock_t start_time=clock();

	  recSize = atoi(argv[1]);                 /* recordSize is 12 Bytes  (sizeof(posting))) */
	  memSize = atoi(argv[2]);                 /* default 100MB = 100,000,000 Bytes */
	  bufSpace = (unsigned char *) malloc(memSize);
	  maxDegree = atoi(argv[3]);               /* here is 83*/
	  ioBufs = (buffer *) malloc((maxDegree + 1) * sizeof(buffer));
	  heap.arr = (int *) malloc((maxDegree + 1) * sizeof(int));
	  heap.cache = (void *) malloc(maxDegree * recSize);     /* record size is 12Bytes, lengthOfPosting */
	  
	  finlist = fopen(argv[4], "r");
	  foutlist = fopen(argv[6], "w");


	  while (!feof(finlist))
	  {
		    for (degree = 0; degree < maxDegree; degree++)
		    {
			      memset(completefilename, 0, sizeof(completefilename));
			      fsRet = fscanf(finlist, "%s", filename);
			      if (feof(finlist)) 
				       break;
			      strcat(completefilename,basepath);
			      strcat(completefilename,filename);    // finlist just gives us relative path of these tempindex files.
			
			      ioBufs[degree].f = fopen(completefilename, "r");  // completefilename stands for each absolute path respectively.
		    }
		    if (degree == 0) break;

		    /* open output file (output is handled by the buffer ioBufs[degree]) */
		    sprintf(filename, "%s%d", argv[5], numFiles);
		    ioBufs[degree].f = fopen(filename, "w");

		    /* assign buffer space (all buffers same space) and init to empty */
		    bufSize = memSize / ((degree + 1) * recSize);
		    for (i = 0; i <= degree; i++)
		    {
			      ioBufs[i].buf = &(bufSpace[i * bufSize * recSize]);
			      ioBufs[i].curRec = 0;
			      ioBufs[i].numRec = 0;
		    }

	    /* initialize heap with first elements. Heap root is in heap[1] (not 0) */
		    heap.size = degree;
		    for (i = 0; i < degree; i++)  heap.arr[i+1] = nextRecord(i);
		    for (i = degree; i > 0; i--)  heapify(i);

	    /* now do the merge - ridiculously simple: do 2 steps until heap empty */
		    while (heap.size > 0)
		    {
			      /* copy the record corresponding to the minimum to the output */
			      writeRecord(&(ioBufs[degree]), heap.arr[1]); 

			      /* replace minimum in heap by the next record from that file */
			      if (nextRecord(heap.arr[1]) == -1)
				heap.arr[1] = heap.arr[heap.size--];     /* if EOF, shrink heap by 1 */
			      if (heap.size > 1)  heapify(1);
		    }
		    
	    /* flush output, add output file to list, close in/output files, and next */
		    writeRecord(&(ioBufs[degree]), -1); 
		    fprintf(foutlist, "%s\n", filename);
		    for (i = 0; i <= degree; i++)  
			fclose(ioBufs[i].f);

		    numFiles++;
	  }

	  fclose(finlist);
	  fclose(foutlist);
	  free(ioBufs);
	  free(heap.arr);
	  free(heap.cache);


	  clock_t end_time=clock();
	
	  printf( "Running time is: %f ms\n", (double)(end_time-start_time)/CLOCKS_PER_SEC*1000.0);


	  return 0;
}