本文整理汇总了C++中IFunction::function方法的典型用法代码示例。如果您正苦于以下问题:C++ IFunction::function方法的具体用法?C++ IFunction::function怎么用?C++ IFunction::function使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFunction
的用法示例。
在下文中一共展示了IFunction::function方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addColumn
/**
* Add a column to a table workspace filled with double values
* calculated with a function wich uses another numeric column as its x values.
* @param tws :: The table workspace.
* @param xColumn :: Name of the column with the x-values. Must exist and be numeric
* @param yColumn :: Name of a column to store the calculated values. If a column with
* this name exists it will be overwritten if numeric or exception thrown otherwise.
* If the column doesn't exist it will be created.
* @param fun :: A function to calculate the values.
*/
void AddFunctionValuesToTable::addColumn(API::TableWorkspace_ptr tws,
const std::string& xColumn,
const std::string& yColumn,
const IFunction& fun,
API::NumericColumn::PlotRole role
)
{
auto& x = tws->getDoubleData( xColumn );
if ( tws->hasColumn( yColumn ) )
{
if ( !tws->getColumn( yColumn )->isNumeric() )
throw std::runtime_error("Column "+yColumn+" isn't numeric");
}
else
{
tws->addColumn( "double", yColumn );
}
tws->getColumn( yColumn )->asNumeric()->setPlotRole(role);
auto& y = tws->getDoubleData( yColumn );
FunctionDomain1DView domain( x.data(), x.size() );
FunctionValues values( domain );
fun.function( domain, values );
for(size_t i = 0; i < y.size(); ++i)
{
y[i] = values.getCalculated(i);
}
}