本文整理汇总了C++中api::ITableWorkspace_sptr::getColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ ITableWorkspace_sptr::getColumn方法的具体用法?C++ ITableWorkspace_sptr::getColumn怎么用?C++ ITableWorkspace_sptr::getColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::ITableWorkspace_sptr
的用法示例。
在下文中一共展示了ITableWorkspace_sptr::getColumn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculateEISF
/**
* Calculates the EISF if the fit includes a Delta function
* @param tableWs - The TableWorkspace to append the EISF calculation to
*/
void ConvolutionFitSequential::calculateEISF(
API::ITableWorkspace_sptr &tableWs) {
// Get height data from parameter table
const auto columns = tableWs->getColumnNames();
const auto height = searchForFitParams("Height", columns).at(0);
const auto heightErr = searchForFitParams("Height_Err", columns).at(0);
auto heightY = tableWs->getColumn(height)->numeric_fill<>();
auto heightE = tableWs->getColumn(heightErr)->numeric_fill<>();
// Get amplitude column names
const auto ampNames = searchForFitParams("Amplitude", columns);
const auto ampErrorNames = searchForFitParams("Amplitude_Err", columns);
// For each lorentzian, calculate EISF
size_t maxSize = ampNames.size();
if (ampErrorNames.size() > maxSize) {
maxSize = ampErrorNames.size();
}
for (size_t i = 0; i < maxSize; i++) {
// Get amplitude from column in table workspace
const auto ampName = ampNames.at(i);
auto ampY = tableWs->getColumn(ampName)->numeric_fill<>();
const auto ampErrorName = ampErrorNames.at(i);
auto ampErr = tableWs->getColumn(ampErrorName)->numeric_fill<>();
// Calculate EISF and EISF error
// total = heightY + ampY
auto total = cloneVector(heightY);
std::transform(total.begin(), total.end(), ampY.begin(), total.begin(),
std::plus<double>());
// eisfY = heightY / total
auto eisfY = cloneVector(heightY);
std::transform(eisfY.begin(), eisfY.end(), total.begin(), eisfY.begin(),
std::divides<double>());
// heightE squared
auto heightESq = cloneVector(heightE);
heightESq = squareVector(heightESq);
// ampErr squared
auto ampErrSq = cloneVector(ampErr);
ampErrSq = squareVector(ampErrSq);
// totalErr = heightE squared + ampErr squared
auto totalErr = cloneVector(heightESq);
std::transform(totalErr.begin(), totalErr.end(), ampErrSq.begin(),
totalErr.begin(), std::plus<double>());
// heightY squared
auto heightYSq = cloneVector(heightY);
heightYSq = squareVector(heightYSq);
// total Squared
auto totalSq = cloneVector(total);
totalSq = squareVector(totalSq);
// errOverTotalSq = totalErr / total squared
auto errOverTotalSq = cloneVector(totalErr);
std::transform(errOverTotalSq.begin(), errOverTotalSq.end(),
totalSq.begin(), errOverTotalSq.begin(),
std::divides<double>());
// heightESqOverYSq = heightESq / heightYSq
auto heightESqOverYSq = cloneVector(heightESq);
std::transform(heightESqOverYSq.begin(), heightESqOverYSq.end(),
heightYSq.begin(), heightESqOverYSq.begin(),
std::divides<double>());
// sqrtESqOverYSq = squareRoot( heightESqOverYSq )
auto sqrtESqOverYSq = cloneVector(heightESqOverYSq);
std::transform(sqrtESqOverYSq.begin(), sqrtESqOverYSq.end(),
sqrtESqOverYSq.begin(),
static_cast<double (*)(double)>(sqrt));
// eisfYSumRoot = eisfY * sqrtESqOverYSq
auto eisfYSumRoot = cloneVector(eisfY);
std::transform(eisfYSumRoot.begin(), eisfYSumRoot.end(),
sqrtESqOverYSq.begin(), eisfYSumRoot.begin(),
std::multiplies<double>());
// eisfErr = eisfYSumRoot + errOverTotalSq
auto eisfErr = cloneVector(eisfYSumRoot);
std::transform(eisfErr.begin(), eisfErr.end(), errOverTotalSq.begin(),
eisfErr.begin(), std::plus<double>());
// Append the calculated values to the table workspace
auto columnName =
ampName.substr(0, (ampName.size() - std::string("Amplitude").size()));
columnName += "EISF";
auto errorColumnName = ampErrorName.substr(
0, (ampErrorName.size() - std::string("Amplitude_Err").size()));
errorColumnName += "EISF_Err";
tableWs->addColumn("double", columnName);
tableWs->addColumn("double", errorColumnName);
size_t maxEisf = eisfY.size();
if (eisfErr.size() > maxEisf) {
maxEisf = eisfErr.size();
}
Column_sptr col = tableWs->getColumn(columnName);
Column_sptr errCol = tableWs->getColumn(errorColumnName);
for (size_t j = 0; j < maxEisf; j++) {
col->cell<double>(j) = eisfY.at(j);
errCol->cell<double>(j) = eisfErr.at(j);
}
//.........这里部分代码省略.........