本文整理汇总了C++中AnyType::numFields方法的典型用法代码示例。如果您正苦于以下问题:C++ AnyType::numFields方法的具体用法?C++ AnyType::numFields怎么用?C++ AnyType::numFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyType
的用法示例。
在下文中一共展示了AnyType::numFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: invalid_argument
AnyType
chi2_gof_test_transition::run(AnyType &args) {
// §4.15.4 ("Aggregate functions") of ISO/IEC 9075-2:2003, "SQL/Foundation"
// demands that rows containing NULLs are ignored
// We currently rely on the backend filtering out rows with NULLs, i.e., to
// perform an action equivalent to:
// for (uint16_t i = 0; i < args.numFields(); ++i)
// if (args[i].isNull)
// return state;
Chi2TestTransitionState<MutableArrayHandle<double> > state = args[0];
double observed = static_cast<double>(args[1].getAs<int64_t>());
double expected = args.numFields() <= 2 ? 1 : args[2].getAs<double>();
int64_t df = args.numFields() <= 3 ? 0 : args[3].getAs<int64_t>();
if (observed < 0)
throw std::invalid_argument("Number of observations must be "
"nonnegative.");
else if (df < 0)
throw std::invalid_argument("Degree of freedom must be positive (or 0 "
"to use the default of <number of rows> - 1).");
else if (state.df != df) {
if (state.numRows > 0)
throw std::invalid_argument("Degree of freedom must be constant.");
state.df = df;
}
updateSumSquaredDeviations(state.numRows.ref(), state.sum_expect.ref(),
state.sum_obs_square_over_expect.ref(), state.sum_obs.ref(),
state.sumSquaredDeviations.ref(),
1, expected, observed * observed / expected,
observed, 0);
return state;
}