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


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

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


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

示例1: EvaluateDataSet


//.........这里部分代码省略.........
	   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()) )
			{
				NLLValues.push_back(fit_thread_data[threadnum].dataPoint_Result[ point_num ] - thisPoint->GetInitialNLL() );
			}
			else
			{
				if( this->GetOffSetNLL() )
				{
					NLLValues.push_back( 0. );
					thisPoint->SetInitialNLL( fit_thread_data[threadnum].dataPoint_Result[ point_num ] );
				}
				else
				{
					NLLValues.push_back( fit_thread_data[threadnum].dataPoint_Result[ point_num ] );
				}
			}

		}
		vector<double> empty;
		fit_thread_data[threadnum].dataPoint_Result.swap( empty );
	}

	sort( NLLValues.begin(), NLLValues.end(), NLLSort );

	for( vector<double>::iterator this_i = NLLValues.begin(); this_i != NLLValues.end(); ++this_i )
	{
		total+=*this_i;
	}

	delete [] Thread;

	//cout << total << endl;
	//exit(0);

	return -total;
}
开发者ID:kgizdov,项目名称:RapidFit,代码行数:101,代码来源:NegativeLogLikelihoodThreaded.cpp


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