本文整理汇总了C++中ITableWorkspace_sptr::getColumnNames方法的典型用法代码示例。如果您正苦于以下问题:C++ ITableWorkspace_sptr::getColumnNames方法的具体用法?C++ ITableWorkspace_sptr::getColumnNames怎么用?C++ ITableWorkspace_sptr::getColumnNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITableWorkspace_sptr
的用法示例。
在下文中一共展示了ITableWorkspace_sptr::getColumnNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseProfileTableWorkspace
/** Parse profile table workspace to a map (the new ...
*/
void SaveGSASInstrumentFile::parseProfileTableWorkspace(
ITableWorkspace_sptr ws,
map<unsigned int, map<string, double>> &profilemap) {
size_t numbanks = ws->columnCount() - 1;
size_t numparams = ws->rowCount();
vector<map<string, double>> vec_maptemp(numbanks);
vector<unsigned int> vecbankindex(numbanks);
// Check
vector<string> colnames = ws->getColumnNames();
if (colnames[0].compare("Name"))
throw runtime_error("The first column must be Name");
// Parse
for (size_t irow = 0; irow < numparams; ++irow) {
TableRow tmprow = ws->getRow(irow);
string parname;
tmprow >> parname;
if (parname.compare("BANK")) {
for (size_t icol = 0; icol < numbanks; ++icol) {
double tmpdbl;
tmprow >> tmpdbl;
vec_maptemp[icol].insert(make_pair(parname, tmpdbl));
}
} else {
for (size_t icol = 0; icol < numbanks; ++icol) {
double tmpint;
tmprow >> tmpint;
vecbankindex[icol] = static_cast<unsigned int>(tmpint);
}
}
}
示例2: removeFixedParameterErrors
/**
* Removes error columns from the table if all errors are zero,
* as these columns correspond to fixed parameters.
* @param table :: [input, output] Pointer to TableWorkspace to edit
*/
void MuonAnalysisResultTableCreator::removeFixedParameterErrors(
const ITableWorkspace_sptr table) const {
assert(table);
const size_t nRows = table->rowCount();
const auto colNames = table->getColumnNames();
std::vector<std::string> zeroErrorColumns;
for (const auto &name : colNames) {
// if name does not end with "Error", continue
const size_t nameLength = name.length();
if (nameLength < ERROR_LENGTH ||
name.compare(nameLength - ERROR_LENGTH, ERROR_LENGTH, ERROR_STRING)) {
continue;
}
auto col = table->getColumn(name);
bool allZeros = true;
// Check if all values in the column are zero
for (size_t iRow = 0; iRow < nRows; ++iRow) {
const double val = col->toDouble(iRow);
if (std::abs(val) > std::numeric_limits<double>::epsilon()) {
allZeros = false;
break;
}
}
if (allZeros) {
zeroErrorColumns.push_back(name);
}
}
for (const auto &name : zeroErrorColumns) {
table->removeColumn(name);
}
}