本文整理汇总了C++中DataPoint::SetDiscreteIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ DataPoint::SetDiscreteIndex方法的具体用法?C++ DataPoint::SetDiscreteIndex怎么用?C++ DataPoint::SetDiscreteIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataPoint
的用法示例。
在下文中一共展示了DataPoint::SetDiscreteIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateData
//Use accept/reject method to create data
int Foam::GenerateData( int DataAmount )
{
//if( newDataSet->GetDataNumber() < DataAmount ) newDataSet->ReserveDataSpace( DataAmount );
for( int dataIndex = 0; dataIndex < DataAmount; ++dataIndex )
{
//Generate the discrete observables, and select the correct Foam generator to use
int combinationIndex = 0;
int incrementValue = 1;
DataPoint * temporaryDataPoint = new DataPoint(allNames);
for( int discreteIndex = int(discreteNames.size() - 1); discreteIndex >= 0; --discreteIndex )
{
//Create the discrete observable
Observable * temporaryObservable = generationBoundary->GetConstraint( *discreteNames_ref[unsigned(discreteIndex)] )->CreateObservable(rootRandom);
double currentValue = temporaryObservable->GetValue();
temporaryDataPoint->SetObservable( *discreteNames_ref2[unsigned(discreteIndex)], temporaryObservable );
delete temporaryObservable;
//Calculate the index
for (unsigned int valueIndex = 0; valueIndex < discreteValues[unsigned(discreteIndex)].size(); ++valueIndex )
{
if ( fabs( discreteValues[unsigned(discreteIndex)][valueIndex] - currentValue ) < DOUBLE_TOLERANCE )
{
combinationIndex += ( incrementValue * int(valueIndex) );
incrementValue *= int(discreteValues[unsigned(discreteIndex)].size());
break;
}
}
}
//Use the index calculated to select a Foam generator and generate an event with it
Double_t* generatedEvent = new Double_t[ continuousNames.size() ];
foamGenerators[unsigned(combinationIndex)]->MakeEvent();
foamGenerators[unsigned(combinationIndex)]->GetMCvect(generatedEvent);
//Store the continuous observables
for (unsigned int continuousIndex = 0; continuousIndex < continuousNames.size(); ++continuousIndex )
{
string unit = generationBoundary->GetConstraint( *continuousNames_ref[continuousIndex] )->GetUnit();
double newValue = minima[continuousIndex] + ( ranges[continuousIndex] * generatedEvent[continuousIndex] );
temporaryDataPoint->SetObservable( *continuousNames_ref2[continuousIndex], newValue, unit );
//cout << continuousNames[continuousIndex] << "\t" << newValue << "\t" << 0.0 << "\t" << unit << endl;
}
delete[] generatedEvent;
// Store the event
temporaryDataPoint->SetDiscreteIndex(dataIndex);
newDataSet->AddDataPoint(temporaryDataPoint);
}
//cout << "Destroying Generator(s)" << endl;
//this->RemoveGenerator();
return DataAmount;
}