当前位置: 首页>>代码示例>>C++>>正文


C++ DataPoint::GetInitialNLL方法代码示例

本文整理汇总了C++中DataPoint::GetInitialNLL方法的典型用法代码示例。如果您正苦于以下问题:C++ DataPoint::GetInitialNLL方法的具体用法?C++ DataPoint::GetInitialNLL怎么用?C++ DataPoint::GetInitialNLL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataPoint的用法示例。


在下文中一共展示了DataPoint::GetInitialNLL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: EvaluateDataSet

//Return the negative log likelihood for a PDF/DataSet result
double NegativeLogLikelihoodThreaded::EvaluateDataSet( IPDF * FittingPDF, IDataSet * TotalDataSet, int number )
{
	(void) FittingPDF;

	if( TotalDataSet->GetDataNumber() == 0 ) return 0.;

	if( Threads <= 0 )
	{
		cerr<< "Bad Number of Threads: " << Threads << " check your XML!!!" << endl << endl;
		exit(-125);
	}

	//	1 thread per core
	pthread_t* Thread = new pthread_t[ (unsigned)Threads ];
	pthread_attr_t attrib;

	//	Threads HAVE to be joinable
	//	We CANNOT _AND_SHOULD_NOT_ ***EVER*** return information to Minuit without the results from ALL threads successfully returned
	//	Not all pthread implementations are required to obey this as default when constructing the thread _SO_BE_EXPLICIT_
	pthread_attr_init(&attrib);
	pthread_attr_setdetachstate(&attrib, PTHREAD_CREATE_JOINABLE);

	//cout << "Setup Threads: " << Threads << endl;
	ObservableRef weightObservableRef( weightObservableName );

	/*
	   for( int i=0; i< StoredDataSubSet.size(); ++i )
	   {
	   if( i == number )
	   {
	   int tot=0;
	   for( int j=0; j< StoredDataSubSet[i].size(); ++j )
	   {
	   cout << "+" << StoredDataSubSet[i][j].size() << endl;
	   tot+=StoredDataSubSet[i][j].size();
	   }
	   cout << "=" << tot << endl;
	   }
	   }
	   */

	//	Initialize the Fitting_Thread objects which contain the objects to be passed to each thread
	for( unsigned int threadnum=0; threadnum< (unsigned)Threads; ++threadnum )
	{
		fit_thread_data[threadnum].dataSubSet = StoredDataSubSet[(unsigned)number][threadnum];
		fit_thread_data[threadnum].fittingPDF = stored_pdfs[((unsigned)number)*(unsigned)Threads + threadnum];
		fit_thread_data[threadnum].fittingPDF->SetDebugMutex( &eval_lock, false );
		fit_thread_data[threadnum].useWeights = useWeights;					//	Defined in the fitfunction baseclass
		fit_thread_data[threadnum].FitBoundary = StoredBoundary[(unsigned)Threads*((unsigned)number)+threadnum];
		fit_thread_data[threadnum].dataPoint_Result = vector<double>();
		fit_thread_data[threadnum].weightsSquared = weightsSquared;
	}

	//cout << "Creating Threads" << endl;

	//	Create the Threads and set them to be joinable
	for( unsigned int threadnum=0; threadnum< (unsigned)Threads ; ++threadnum )
	{
		int status = pthread_create(&Thread[threadnum], &attrib, this->ThreadWork, (void *) &fit_thread_data[threadnum] );
		if( status )
		{
			cerr << "ERROR:\tfrom pthread_create()\t" << status << "\t...Exiting\n" << endl;
			exit(-1);
		}
	}

	//cout << "Joining Threads!!" << endl;

	//	Join the Threads
	for( unsigned int threadnum=0; threadnum< (unsigned)Threads ; ++threadnum )
	{
		int status = pthread_join( Thread[threadnum], NULL);
		if( status )
		{
			cerr << "Error Joining a Thread:\t" << threadnum << "\t:\t" << status << "\t...Exiting\n" << endl;
		}
	}

	//      Do some cleaning Up
	pthread_attr_destroy(&attrib);

	//cout << "Leaving Threads" << endl;

	double total=0;

	vector<double> NLLValues;

	for( unsigned int threadnum=0; threadnum< (unsigned)Threads; ++threadnum )
	{
		for( unsigned int point_num=0; point_num< fit_thread_data[threadnum].dataPoint_Result.size(); ++point_num )
		{
			if( fabs(fit_thread_data[threadnum].dataPoint_Result[ point_num ]) >= DBL_MAX )
			{
				return DBL_MAX;
			}

			DataPoint* thisPoint = fit_thread_data[threadnum].dataSubSet[ point_num ];

			if( this->GetOffSetNLL() && !std::isnan(thisPoint->GetInitialNLL()) )
//.........这里部分代码省略.........
开发者ID:kgizdov,项目名称:RapidFit,代码行数:101,代码来源:NegativeLogLikelihoodThreaded.cpp


注:本文中的DataPoint::GetInitialNLL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。