コード例 #1
0
void XFoilAnalysisDlg::Analyze()
{
	m_pctrlCancel->setText(tr("Cancel"));
	m_pctrlSkip->setEnabled(true);

	//all set to launch the analysis

	//create a timer to update the output at regular intervals
	QTimer *pTimer = new QTimer;
	connect(pTimer, SIGNAL(timeout()), this, SLOT(OnProgress()));
	pTimer->setInterval(QXDirect::s_TimeUpdateInterval);
	pTimer->start();

	//Launch the task

	m_pXFoilTask->run();

	pTimer->stop();
	delete pTimer;

	OnProgress();
	m_pXFoilTask->m_OutStream.flush();

	m_bErrors = m_pXFoilTask->m_bErrors;
	if(m_bErrors)
	{
		m_pctrlTextOutput->insertPlainText(tr(" ...some points are unconverged"));
		m_pctrlTextOutput->ensureCursorVisible();
	}

	m_pctrlCancel->setText(tr("Close"));
	m_pctrlSkip->setEnabled(false);
	update();

}
コード例 #2
0
ファイル: tvsearchmgr.cpp プロジェクト: cg8530/WorkSplace
void TVSearchMgr::SearchFreqs(std::vector<TuningParam> &listFreq)
{
	static int errs;
	errs=0;
	dxreport("[TVSearchMgr::SearchFreqs] freqs: %d\n",listFreq.size());
	for(U32 iLoop = 0 ; iLoop< listFreq.size();iLoop++)
	{
		// 主动结束
		if(m_pThread->check_stop())
		{
			dxreport("force stop called, exit TVSearchMgrPollProc...\n");
			break;
		}
		dxreport("TVSearchMgrPollProc: Searching Freq:%d...\n",listFreq[iLoop].freq);
		OnProgress(CalculatePercent(iLoop,listFreq.size()));
		SearchOneFreq(listFreq[iLoop],BS_PATCATSDT);
/*
		// for test quickly
		dxreport("TVSearchMgrPollProc: Searching qam:%d, symb:%d...\n",listFreq[iLoop].qam, listFreq[iLoop].symb);
		{
			TuningParam tuner;
			tuner.freq = 474000;
			tuner.qam = 2;
			tuner.symb = 6875;
			SearchOneFreq(tuner,BS_PATCATSDT); 
		}
		break;
*/		
	}
}
コード例 #3
0
// Get preferences set from N samples
std::vector<bm::bvector<> *> *RandomSampler::GetNSampleAndPreferenceSet(float nInlierThreshold, unsigned int nSampleN, std::vector<bm::bvector<> *> *nPrevPointsPrefSet, unsigned int nModelSpanN, std::vector<std::vector<float> *> *nPrevModels, void (*OnProgress)(float)){

	// TODO: Add multithreading support to this function.

	// Allocate empty bit vector
	if(nPrevPointsPrefSet == NULL){
		nPrevPointsPrefSet = new std::vector<bm::bvector<> *>(mMaxAllocablePoints);
		for(unsigned int i=0; i < mMaxAllocablePoints; i++)
			(*nPrevPointsPrefSet)[i] = new bm::bvector<>;
	}

	assert(nPrevPointsPrefSet->size() == mMaxAllocablePoints);

	if(this->mActivePoints < this->mMSS){
		return nPrevPointsPrefSet;
	}

	// Get all the sample
	for(unsigned int n=0; n<nSampleN; n++){

		unsigned int currentModelIndex = nModelSpanN + n;

		std::vector<unsigned int> nSample(mMSS);

		if(OnProgress != NULL)
			OnProgress((float)n / (float)nSampleN);
		
		#ifdef _DEBUG
		// If we are in debug mode, generate hypotesis in a non random way
			static unsigned int nCounter = 0;
			nCounter = nCounter % this->mActivePoints;
			nSample[0] = (unsigned int)GetActiveIndex(nCounter);
			nCounter++;
		#else
			nSample[0] = (unsigned int)RandomSampleOnCumSumHist (mNeighCustomVecFCumSum);
		#endif

		GetNonFirstSamples(&nSample);
		
		std::vector<float> *nModelParams =	mGetFunction(mDataPoints, nSample);
		for(unsigned int i=0; i < mMaxAllocablePoints; i++) {
			if(mDataPoints[i]->mActive && (*mDistanceFunction)(*nModelParams, *mDataPoints[i]->mCoord) <nInlierThreshold ){
				// Fill bit vector
				assert(!(*(*nPrevPointsPrefSet)[i])[currentModelIndex]);
				(*(*nPrevPointsPrefSet)[i])[currentModelIndex] = true;
			}
		}
		if(nPrevModels == NULL)
			delete (nModelParams);
		else
			(*nPrevModels)[currentModelIndex] = nModelParams;

	}
	
	for(unsigned int i=0; i<mMaxAllocablePoints; i++)
		if(mDataPoints[i]->mActive)
			(*nPrevPointsPrefSet)[i]->optimize();

	return nPrevPointsPrefSet;
}
コード例 #4
0
ファイル: BlakeTest.cpp プロジェクト: Steppenwolfe65/CEX
	std::string BlakeTest::Run()
	{
		try
		{
			Initialize();

			CEX::Digest::Blake256* dgt256 = new CEX::Digest::Blake256();
			CompareVector(dgt256, m_message[0], m_expected[0]);
			CompareVector(dgt256, m_message[1], m_expected[1]);
			CompareVector(dgt256, m_message[2], m_expected[2]);
			CompareVector(dgt256, m_message[3], m_expected[3]);
			CompareVector(dgt256, m_message[4], m_expected[4]);
			CompareVector(dgt256, m_message[5], m_expected[5]);
			CompareVector(dgt256, m_message[6], m_expected[6]);
			CompareVector(dgt256, m_message[7], m_expected[7]);
			CompareVector(dgt256, m_message[8], m_expected[8]);
			CompareVector(dgt256, m_message[9], m_expected[9]);
			delete dgt256;
			OnProgress("Passed Blake 256 vector tests..");

			CEX::Digest::Blake512* dgt512 = new CEX::Digest::Blake512();
			CompareVector(dgt512, m_message[10], m_expected[10]);
			CompareVector(dgt512, m_message[11], m_expected[11]);
			CompareVector(dgt512, m_message[12], m_expected[12]);
			CompareVector(dgt512, m_message[13], m_expected[13]);
			CompareVector(dgt512, m_message[14], m_expected[14]);
			CompareVector(dgt512, m_message[15], m_expected[15]);
			CompareVector(dgt512, m_message[16], m_expected[16]);
			CompareVector(dgt512, m_message[17], m_expected[17]);
			CompareVector(dgt512, m_message[18], m_expected[18]);
			CompareVector(dgt512, m_message[19], m_expected[19]);
			delete dgt512;
			OnProgress("Passed Blake 512 vector tests..");

			return SUCCESS;
		}
		catch (std::string const& ex)
		{
			throw TestException(std::string(FAILURE + " : " + ex));
		}
		catch (...)
		{
			throw TestException(std::string(FAILURE + " : Internal Error"));
		}
	}
コード例 #5
0
// Get preferences set from N samples
std::vector<std::vector<float> *> *RandomSampler::GetNSampleFromStartingPoint(unsigned int nSampleN, unsigned int nStartingPoint, unsigned int nModelSpanN, std::vector<std::vector<float> *> *nPrevModels, void (*OnProgress)(float) ){


	// Allocate empty bit vector
	if(nPrevModels == NULL)
		nPrevModels = new std::vector<std::vector<float> *>(nSampleN + nModelSpanN);

	if(nPrevModels->size() < nSampleN + nModelSpanN)
		nPrevModels->resize(nSampleN + nModelSpanN);

#ifndef RS_NO_THREADS
	boost::thread_group *tg = new boost::thread_group();
#endif RS_NO_THREADS
		
	// Get all the samples
	for(unsigned int n=0; n<nSampleN; n++){

		unsigned int currentModelIndex = nModelSpanN + n;

		std::vector<unsigned int> nSample(mMSS);

		if(OnProgress != NULL)
			OnProgress((float)n / (float)nSampleN);

	#ifdef RS_NO_THREADS
		
		nSample[0] = nStartingPoint;

		GetNonFirstSamples(&nSample);
		
		std::vector<float> *nModelParams =	mGetFunction(mDataPoints, nSample);

		(*nPrevModels)[currentModelIndex] = nModelParams;

	#else

		tg->create_thread( boost::bind(&RandomSampler::GetSampleMultiThreadWrapper,this, nSample, currentModelIndex,nPrevModels, nStartingPoint));

		if(tg->size() >= MAXTHREADS){
			tg->join_all();
			delete tg;
			tg = new boost::thread_group();
		}

	#endif

	}
	

#ifndef RS_NO_THREADS
	if(tg->size() > 0)
		tg->join_all();
	delete tg;
#endif RS_NO_THREADS

	return nPrevModels;
}
コード例 #6
0
ファイル: CipherModeTest.cpp プロジェクト: Steppenwolfe65/CEX
	std::string CipherModeTest::Run()
	{
		try
		{
			Initialize();

			// test modes with each key (128/192/256)
			CompareCBC(m_keys[0], m_input, m_output);
			CompareCBC(m_keys[1], m_input, m_output);
			CompareCBC(m_keys[2], m_input, m_output);
			OnProgress("CipherModeTest: Passed CBC 128/192/256 bit key encryption/decryption tests..");

			CompareCFB(m_keys[0], m_input, m_output);
			CompareCFB(m_keys[1], m_input, m_output);
			CompareCFB(m_keys[2], m_input, m_output);
			OnProgress("CipherModeTest: Passed CFB 128/192/256 bit key encryption/decryption tests..");

			CompareCTR(m_keys[0], m_input, m_output);
			CompareCTR(m_keys[1], m_input, m_output);
			CompareCTR(m_keys[2], m_input, m_output);
			OnProgress("CipherModeTest: Passed CTR 128/192/256 bit key encryption/decryption tests..");

			CompareECB(m_keys[0], m_input, m_output);
			CompareECB(m_keys[1], m_input, m_output);
			CompareECB(m_keys[2], m_input, m_output);
			OnProgress("CipherModeTest: Passed ECB 128/192/256 bit key encryption/decryption tests..");

			CompareOFB(m_keys[0], m_input, m_output);
			CompareOFB(m_keys[1], m_input, m_output);
			CompareOFB(m_keys[2], m_input, m_output);
			OnProgress("CipherModeTest: Passed OFB 128/192/256 bit key encryption/decryption tests..");

			return SUCCESS;
		}
		catch (std::string const& ex)
		{
			throw TestException(std::string(FAILURE + " : " + ex));
		}
		catch (...)
		{
			throw TestException(std::string(FAILURE + " : Internal Error"));
		}
	}
コード例 #7
0
ファイル: HttpChannelChild.cpp プロジェクト: mozilla/pjs
bool
HttpChannelChild::RecvOnProgress(const PRUint64& progress,
                                 const PRUint64& progressMax)
{
  if (mEventQ.ShouldEnqueue())  {
    mEventQ.Enqueue(new ProgressEvent(this, progress, progressMax));
  } else {
    OnProgress(progress, progressMax);
  }
  return true;
}
コード例 #8
0
ファイル: VMACTest.cpp プロジェクト: Steppenwolfe65/CEX
	std::string VMACTest::Run()
	{
		try
		{
			Initialize();
			CompareVector(m_key, m_iv, m_expected);
			OnProgress("Passed VMAC vector tests..");
			CompareAccess(m_key, m_iv);
			OnProgress("Passed DoFinal/ComputeHash methods output comparison..");

			return SUCCESS;
		}
		catch (std::string const& ex)
		{
			throw TestException(std::string(FAILURE + " : " + ex));
		}
		catch (...)
		{
			throw TestException(std::string(FAILURE + " : Internal Error"));
		}
	}
コード例 #9
0
ファイル: HMACTest.cpp プロジェクト: Steppenwolfe65/CEX
	std::string HMACTest::Run()
	{
		try
		{
			Initialize();

			CompareVector256(m_keys[0], m_input[0], m_expected256[0]);
			CompareVector256(m_keys[1], m_input[1], m_expected256[1]);
			CompareVector256(m_keys[2], m_input[2], m_expected256[2]);
			CompareVector256(m_keys[3], m_input[3], m_expected256[3]);
			CompareVector256(m_keys[4], m_input[4], m_expected256[4]);
			CompareVector256(m_keys[5], m_input[5], m_expected256[5]);
			CompareVector256(m_keys[6], m_input[6], m_expected256[6]);
			OnProgress("HMACTest: Passed SHA-2 256 bit known answer vector tests..");

			CompareVector512(m_keys[0], m_input[0], m_expected512[0]);
			CompareVector512(m_keys[1], m_input[1], m_expected512[1]);
			CompareVector512(m_keys[2], m_input[2], m_expected512[2]);
			CompareVector512(m_keys[3], m_input[3], m_expected512[3]);
			CompareVector512(m_keys[4], m_input[4], m_expected512[4]);
			CompareVector512(m_keys[5], m_input[5], m_expected512[5]);
			CompareVector512(m_keys[6], m_input[6], m_expected512[6]);
			OnProgress("HMACTest: Passed SHA-2 512 bit known answer vector tests..");

			CompareAccess(m_keys[3]);
			OnProgress("Passed DoFinal/ComputeHash methods output comparison..");

			return SUCCESS;
		}
		catch (std::string const& ex)
		{
			throw TestException(std::string(FAILURE + " : " + ex));
		}
		catch (...)
		{
			throw TestException(std::string(FAILURE + " : Internal Error"));
		}
	}
コード例 #10
0
ファイル: model.cpp プロジェクト: fgroen/zxtune
 virtual void OnProgress(uint_t current, const String& /*message*/)
 {
   OnProgress(current);
 }
コード例 #11
0
void DownloadMissionPackForm::OnBegin(void *ctx, int cbLength) {
    OnProgress(ctx, 0, cbLength);
}
コード例 #12
0
ファイル: JLinkage.cpp プロジェクト: camadrigalg/opensvr
const std::list<sClLnk *> JLinkage::DoJLClusterization(void (*OnProgress)(float)){
	
	
	float tEps = (float)1.0f/(1.0f+(float)mModels.size()); // Just a distance to see if the jaccard distance is equal to one
	float tOneEpsDistance = 1.0f - tEps; // Just a distance to see if the jaccard distance is equal to one

	
	// Update neighboardhood information
	if(mUseKDTree){
		mKDTree.optimise();
		
		/* old FIND WITHING RANGE
		static std::vector<sPtLnkPointer> nearPtsIdx;
	
		static bool firsttime = true;
		if(firsttime){
			nearPtsIdx.reserve(500);
			firsttime = false;
		}
		*/
		for(std::list<sPtLnk *>::iterator tIterPt = mDataPoints.begin(); tIterPt != mDataPoints.end(); ++tIterPt){
			if(!(*tIterPt)->mToBeUpdateKDTree)
				continue;
			// Threadable build Distance list for kdtree 


			/* old FIND WITHING RANGE
			nearPtsIdx.clear();
			sPtLnkPointer nPtPointer; nPtPointer.mPtLnk = *tIterPt;
			mKDTree.find_within_range(nPtPointer, mNNeighboardsUpdateDistance, std::back_inserter(nearPtsIdx));
			*/
			sPtLnkPointer nPtPointer; nPtPointer.mPtLnk = *tIterPt; nPtPointer.mPtLnk->mAlreadyFound = false;
			std::list<sPtLnkPointer> kneigh = FindKNearest(nPtPointer,std::numeric_limits<float>::max(),mKNeighboards, (int)mDataPointsSize);

			// Find K-Nearest
			for(std::list<sPtLnkPointer>::iterator tIter = kneigh.begin(); tIter != kneigh.end(); ++tIter){
			
			//for(std::vector<sPtLnkPointer>::iterator tIter = nearPtsIdx.begin(); tIter != nearPtsIdx.end(); ++tIter){
				if((*tIter).mPtLnk->mBelongingCluster == (*tIterPt)->mBelongingCluster)
					continue;				
				
				bool alreadyPresent = false;
				for(std::list<sDist *>::iterator distIter = (*tIter).mPtLnk->mBelongingCluster->mPairwiseJaccardDistance.begin();
					distIter != (*tIter).mPtLnk->mBelongingCluster->mPairwiseJaccardDistance.end();
					distIter++){
					
					if((*distIter)->mCluster1 == (*tIterPt)->mBelongingCluster || (*distIter)->mCluster2 == (*tIterPt)->mBelongingCluster)
						alreadyPresent = true;
				}

				if(alreadyPresent)
					continue;

				sDist *tDist = new sDist;
				tDist->mCluster1 = (*tIterPt)->mBelongingCluster;
				tDist->mCluster2 = (*tIter).mPtLnk->mBelongingCluster;
				
				(*tIterPt)->mBelongingCluster->mPairwiseJaccardDistance.push_back(tDist);
				(*tIter).mPtLnk->mBelongingCluster->mPairwiseJaccardDistance.push_back(tDist);
				
				tDist->mToBeUpdated = true;
				mDistancesToBeUpdated.push_back(tDist);
				mDistancesToBeUpdatedSize++;
			}
			(*tIterPt)->mToBeUpdateKDTree = false;			
		}
		
	}
	
	if(OnProgress != NULL)
		OnProgress(0.01f);
	
	// First step: update all the pw distances that needs an update
	// Please Note: If a distance don't need to be updated it means that it would be certainly equal to 1 from the previous JLClusterization
	// --> Store also a list with ALL the pairwise unique jaccard distance
	std::vector<sDist *> mHeapDistanceList(mDistancesToBeUpdatedSize);	
	
	unsigned int counter = 0;
	while(mDistancesToBeUpdatedSize > 0){
		sDist *tDist = mDistancesToBeUpdated.back();
		mDistancesToBeUpdated.pop_back();
		mDistancesToBeUpdatedSize--;
		tDist->mPairwiseJaccardDistance = 
			PSJaccardDist(	tDist->mCluster1->mPreferenceSet,
							tDist->mCluster2->mPreferenceSet,
							&(tDist->mPairwiseUnion),
							&(tDist->mPairwiseIntersection) );
		tDist->mToBeUpdated = false;
		if(tDist->mPairwiseJaccardDistance < tOneEpsDistance){
			mHeapDistanceList[counter] = tDist;
			++counter;
		}
	}

	if(OnProgress != NULL)
		OnProgress(0.02f);

	mHeapDistanceList.resize(counter);

	// A distance that will invalidate the heap, needing a heap resort
	float mCurrentInvalidatingDistance = 1.0f;

	// Make the heap
	std::sort(mHeapDistanceList.begin(), mHeapDistanceList.end(), sDist());
	
	unsigned int currentSortIdx = 0;
	unsigned int initialDistance = (unsigned int)mHeapDistanceList.size();
		
	while(mHeapDistanceList.size() > 0){
		
		
		sDist *sCurrentMinDist = NULL;
		if(currentSortIdx < mHeapDistanceList.size())
			sCurrentMinDist = mHeapDistanceList[currentSortIdx];
		// TODO speed up previous line!
		
	    if(sCurrentMinDist == NULL || sCurrentMinDist->mPairwiseJaccardDistance > tOneEpsDistance && mCurrentInvalidatingDistance > tOneEpsDistance  ){ // All the distance will be equals to one - clusterization is finished
			// We've finished since all distances have been processed or are equal to 1.0f
			mHeapDistanceList.clear();
		}
		else if(sCurrentMinDist->mCluster1 == NULL || sCurrentMinDist->mCluster2 == NULL ){
			// Eliminate the non-valid distance(belong to an eliminated clusters
			for(std::vector<sDist *>::iterator tIterDist = mHeapDistanceList.begin() + currentSortIdx + 1 ; tIterDist != mHeapDistanceList.end(); tIterDist++){
				assert((*tIterDist) != sCurrentMinDist);
			}
			delete sCurrentMinDist;
			++currentSortIdx;
		}
		else if(sCurrentMinDist->mPairwiseJaccardDistance > (mCurrentInvalidatingDistance-tEps)){ // We need an heap resort
			
			mHeapDistanceList.erase(mHeapDistanceList.begin(), mHeapDistanceList.begin()+(currentSortIdx));
			
			if(mHeapDistanceList.size() > 1){

				// First eliminate all the distance equals to one from the heap
				// Push all these distances to the end of the vector...
				unsigned int idxElementProcessing = 0;
				unsigned int idxLastUsefullElement = (unsigned int)mHeapDistanceList.size() - 1;
				
				while(idxElementProcessing <= idxLastUsefullElement && idxLastUsefullElement > 0 ){
					
					if(mHeapDistanceList[idxElementProcessing]->mPairwiseJaccardDistance > tOneEpsDistance || mHeapDistanceList[idxElementProcessing]->mCluster1 == NULL || mHeapDistanceList[idxElementProcessing]->mCluster2 == NULL){
						// In this case we need to move the distance to the end

						// Swap elements
						sDist *temp = mHeapDistanceList[idxElementProcessing];
						mHeapDistanceList[idxElementProcessing] = mHeapDistanceList[idxLastUsefullElement];
						mHeapDistanceList[idxLastUsefullElement] = temp;

						// If the distance belongs to one eliminated cluster, delete it
						if(mHeapDistanceList[idxLastUsefullElement]->mCluster1 == NULL || mHeapDistanceList[idxLastUsefullElement]->mCluster2 == NULL)
							delete mHeapDistanceList[idxLastUsefullElement];

						idxLastUsefullElement--;
					}
					else{
						idxElementProcessing++;
					}
				}
				
				if(idxLastUsefullElement > 0){
					// ... and then erase them
					if(idxLastUsefullElement < mHeapDistanceList.size()-1)
						mHeapDistanceList.erase(mHeapDistanceList.begin()+idxLastUsefullElement+1, mHeapDistanceList.end());
					// Re-Set the heap
					std::sort(mHeapDistanceList.begin(), mHeapDistanceList.end(), sDist());
				}
				else{
					// Ok we finished
					mHeapDistanceList.clear();
				}
								
			}
			
			mCurrentInvalidatingDistance = 2.0f;
			currentSortIdx = 0;
		}
		else{
			// The distance is less than the invalidating distance, merge the two cluster and update the other distances accordingly
			
			// if kd-tree is used, merge the distances of the clusters for adding the new ones of the new created cluster
			std::list<sClLnk *> distancesToBeAdded;

			sCurrentMinDist->mCluster2->mPairwiseJaccardDistance.remove(sCurrentMinDist);
			sCurrentMinDist->mCluster1->mPairwiseJaccardDistance.remove(sCurrentMinDist);

			if(mUseKDTree){
				for(std::list<sDist *>::iterator distIter1 = sCurrentMinDist->mCluster2->mPairwiseJaccardDistance.begin(); distIter1 != sCurrentMinDist->mCluster2->mPairwiseJaccardDistance.end(); ++distIter1){
					// Threadable Check distance to merge KD-Tree
					bool add = true;
					// Check if the distance already exists
					for(std::list<sDist *>::iterator distIter2 = sCurrentMinDist->mCluster1->mPairwiseJaccardDistance.begin(); distIter2 != sCurrentMinDist->mCluster1->mPairwiseJaccardDistance.end(); ++distIter2){
						if((*distIter1)->mCluster1 == (*distIter2)->mCluster1 || (*distIter1)->mCluster2 == (*distIter2)->mCluster2 
						   || (*distIter1)->mCluster2 == (*distIter2)->mCluster1 || (*distIter1)->mCluster1 == (*distIter2)->mCluster2){
							add = false; // Point already present
							break;
						}
					}
					if(add){
						if((*distIter1)->mCluster1 != sCurrentMinDist->mCluster2)
							distancesToBeAdded.push_back((*distIter1)->mCluster1);
						else if((*distIter1)->mCluster2 != sCurrentMinDist->mCluster2)
							distancesToBeAdded.push_back((*distIter1)->mCluster2);
					}
					
				}
			}
			
			
			// Update the cluster pointer of all the points of the deleted cluster
			for(std::list<sPtLnk *>::iterator ptIter = sCurrentMinDist->mCluster2->mBelongingPts.begin(); ptIter != sCurrentMinDist->mCluster2->mBelongingPts.end(); ptIter++)
				(*ptIter)->mBelongingCluster = sCurrentMinDist->mCluster1;

						
			// Merge the two clusters into cluster 1
			sCurrentMinDist->mCluster1->mPreferenceSet &= sCurrentMinDist->mCluster2->mPreferenceSet;
			sCurrentMinDist->mCluster1->mBelongingPts.merge(sCurrentMinDist->mCluster2->mBelongingPts);			

			
			// Delete cluster 2
			mDataClusters.remove(sCurrentMinDist->mCluster2);

			if(mUseKDTree){
				for(std::list<sClLnk *>::iterator clIter = distancesToBeAdded.begin(); clIter != distancesToBeAdded.end(); ++clIter){
					// Threadable Add kd-tree distances
					sDist *tDist = new sDist;
					tDist->mCluster1 = sCurrentMinDist->mCluster1;
					tDist->mCluster2 = *clIter;
					
					sCurrentMinDist->mCluster1->mPairwiseJaccardDistance.push_back(tDist);
					(*clIter)->mPairwiseJaccardDistance.push_back(tDist);
					mHeapDistanceList.push_back(tDist);
				}
			}
			
				
			
			// Update all the distances of the old cluster -- delete
			for(std::list<sDist *>::iterator tIterDist = sCurrentMinDist->mCluster2->mPairwiseJaccardDistance.begin(); tIterDist != sCurrentMinDist->mCluster2->mPairwiseJaccardDistance.end(); tIterDist++){
				// Threadable: delete distance for the old cluster
				if(sCurrentMinDist != (*tIterDist)){
					if((*tIterDist)->mCluster1 != sCurrentMinDist->mCluster2)
						(*tIterDist)->mCluster1->mPairwiseJaccardDistance.remove( (*tIterDist));
					else if((*tIterDist)->mCluster2 != sCurrentMinDist->mCluster2)
						(*tIterDist)->mCluster2->mPairwiseJaccardDistance.remove( (*tIterDist));
					(*tIterDist)->mCluster1 = NULL;
					(*tIterDist)->mCluster2 = NULL;
				}
			}

			// Do additional user-defined update steps if specified
			if(mClusterMergeAdditionalOperation != NULL)
				mClusterMergeAdditionalOperation(sCurrentMinDist->mCluster1);

#ifndef JL_NO_THREADS
				boost::thread_group *tg = new boost::thread_group();
				// Update all the distances of the new cluster
				for(std::list<sDist *>::iterator tIterDist = sCurrentMinDist->mCluster1->mPairwiseJaccardDistance.begin(); tIterDist != sCurrentMinDist->mCluster1->mPairwiseJaccardDistance.end(); tIterDist++){
					// Update distances
					tg->create_thread(boost::bind(&(UpdateDistance),*tIterDist, &mCurrentInvalidatingDistance, mClusterClusterDiscardTest));
					if(tg->size() >= MAXTHREADS){
						tg->join_all();
						delete tg;
						tg = new boost::thread_group();
					}
				}
			tg->join_all();
			delete tg;
#else
				for(std::list<sDist *>::iterator tIterDist = sCurrentMinDist->mCluster1->mPairwiseJaccardDistance.begin(); tIterDist != sCurrentMinDist->mCluster1->mPairwiseJaccardDistance.end(); tIterDist++){
					// Update distances
					JLinkage::UpdateDistance(*tIterDist, &mCurrentInvalidatingDistance, mClusterClusterDiscardTest);
				}

#endif

			if(OnProgress != NULL)
				OnProgress(1.0f - ((float) (mHeapDistanceList.size() - currentSortIdx) / (float)initialDistance));
			
			// Delete old cluster
			if(sCurrentMinDist->mCluster2 && mDestroyAdditionalData)
				mDestroyAdditionalData(sCurrentMinDist->mCluster2);
		
			delete sCurrentMinDist->mCluster2;
			delete sCurrentMinDist;

			++currentSortIdx;

		}



	}

	if(OnProgress != NULL)
		OnProgress(1.0f);
	
	// return the list of clusters
	return mDataClusters;
}
コード例 #13
0
// Get preferences set from N samples
std::vector<std::vector<float> *> *RandomSampler::GetNSample(unsigned int nSampleN, unsigned int nModelSpanN, std::vector<std::vector<float> *> *nPrevModels, void (*OnProgress)(float)){

	if(this->mActivePoints < this->mMSS){
		return NULL;
	}

	// Allocate empty bit vector
	if(nPrevModels == NULL)
		nPrevModels = new std::vector<std::vector<float> *>(nSampleN + nModelSpanN);

	if(nPrevModels->size() < nSampleN + nModelSpanN)
		nPrevModels->resize(nSampleN + nModelSpanN);

#ifndef RS_NO_THREADS
	boost::thread_group *tg = new boost::thread_group();
#endif RS_NO_THREADS
		
	// Get all the samples
	for(unsigned int n=0; n<nSampleN; n++){

		unsigned int currentModelIndex = nModelSpanN + n;

		std::vector<unsigned int> nSample(mMSS);

		if(OnProgress != NULL)
			OnProgress((float)n / (float)nSampleN);

	#ifdef RS_NO_THREADS

		#ifdef _DEBUG
		// If we are in debug mode, generate hypotesis in a non random way
			static unsigned int nCounter = 0;
			nCounter = nCounter % this->mActivePoints;
			nSample[0] = (unsigned int)GetActiveIndex(nCounter);
			nCounter++;
		#else
			nSample[0] = (unsigned int)RandomSampleOnCumSumHist (mNeighCustomVecFCumSum);
		#endif
		GetNonFirstSamples(&nSample);

		std::vector<float> *nModelParams =	mGetFunction(mDataPoints, nSample);

		(*nPrevModels)[currentModelIndex] = nModelParams;
	#else

		tg->create_thread( boost::bind(&RandomSampler::GetSampleMultiThreadWrapper,this, nSample, currentModelIndex,nPrevModels, -1));

		if(tg->size() >= MAXTHREADS){
			tg->join_all();
			delete tg;
			tg = new boost::thread_group();
		}
	#endif

	}

#ifndef RS_NO_THREADS
	if(tg->size() > 0)
		tg->join_all();
	delete tg;
#endif RS_NO_THREADS

	return nPrevModels;

}
コード例 #14
0
ファイル: BoatAnalysisDlg.cpp プロジェクト: kolzar/sail7
void BoatAnalysisDlg::StartAnalysis()
{
	//
	// Method applied from v6.00 onwards
	// 
	// First case :
	// If the analysis is for a wing and not a plane, the full 3D panel method is applied
	// and the wing is modelled as a thick surface
	// The method is strictly the one described in NASA TN 4023
	// The boundary condition is of the Dirichlet type, which has proved more convincing 
	// than the Neumann BC for full 3D panel methods
	//
	// Second case :
	// If the analysis is for a plane, the full 3D method is not applicable since the 
	// junctions between wing and body, or between fin and elevator, cannot be adequately 
	// represented as closed surfaces. This would require a 3D CAD programe. 
	// Therefore, in this case, the wings are modelled as thin surfaces.
	// Trial tests using the method of NASA TN 4023 have not been conclusive. With a uniform doublet
	// distribution and a boundary condition applied at the panel's centroid, the results 
	// are less convincing than with VLM.
	// Therefore in this case, the VLM1 method is applied to the thin surfaces, and the 3D-panel method 
	// is applied to the body.
	// Last consideration : since the potential of a straight vortex line requires a lot of computations, 
	// the Neumann type BC is applied to the body panels, rather than the Dirichlet type BC
	//
//	MainFrame *pMainFrame = (MainFrame*)s_pMainFrame;
	qApp->processEvents();

	if(!m_pBoatPolar) return;

	QString strong;
	m_pctrlCancel->setText(tr("Cancel"));
	m_bIsFinished = false;


	if(m_pBoatPolar->m_bVLM1) strong = tr("Launching VLM1 Analysis....")+"\n";
	else                      strong = tr("Launching VLM2 Analysis....")+"\n";

	AddString(strong);


	if(m_pBoat->m_poaHull.size())
	{
		if(m_pBoatPolar->m_bDirichlet) strong = tr("Using Dirichlet boundary conditions for thick bodies")+"\n";
		else                           strong = tr("Using Neumann boundary conditions for thick bodies")+"\n";
		AddString(strong);
		AddString("\n");
	}


	strong = tr("Type 1 - Fixed speed polar");
	AddString(strong);
	m_bCancel = false;

	QTimer *pTimer = new QTimer;
	connect(pTimer, SIGNAL(timeout()), this, SLOT(OnProgress()));
	pTimer->setInterval(100);
	pTimer->start();

	qApp->processEvents();

	UnitLoop();


	if (!m_bCancel && !m_bWarning) strong = "\n"+tr("Panel Analysis completed successfully")+"\n";
	else if (m_bWarning)           strong = "\n"+tr("Panel Analysis completed ... Errors encountered")+"\n";
	AddString(strong);
	pTimer->stop();

//	if(m_pBoatPolar && (m_pBoatPolar->m_Type==STABILITYPOLAR || m_pBoatPolar->m_bTiltedGeom || m_pBoatPolar->m_bWakeRollUp))
	{
		//restore the panels and nodes;
		memcpy(s_pPanel, s_pMemPanel, m_MatSize * sizeof(CPanel));
		memcpy(s_pNode,  s_pMemNode,  m_nNodes  * sizeof(CVector));
		memcpy(s_pWakePanel, s_pRefWakePanel, m_WakeSize * sizeof(CPanel));
		memcpy(s_pWakeNode,  s_pRefWakeNode,  m_nWakeNodes * sizeof(CVector));
	}

	m_bIsFinished = true;
	m_pctrlCancel->setText(tr("Close"));
}
コード例 #15
0
ファイル: raw_supp.cpp プロジェクト: djdron/zxtune
 void OnProgress(uint_t current) override
 {
   OnProgress(current, Text);
 }