本文整理汇总了C++中xs函数的典型用法代码示例。如果您正苦于以下问题:C++ xs函数的具体用法?C++ xs怎么用?C++ xs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void GaussianProcess::update_K(bool all)
{
//const unsigned int start_idx = all? last_x_size : 0;
const unsigned int start_idx = 0;
const unsigned int x_len = xs.size() - start_idx;
// const unsigned int num_rows = K.rows();
// const unsigned int num_cols = K.cols();
/*
if (!all){
assert(num_rows < last_x_size);
}
*/
//K.resize(num_rows+x_len,num_cols+x_len);
K.resize(x_len,+x_len);
for (unsigned int i = 0; i < xs.size(); ++i) {
for (unsigned int j = start_idx; j < xs.size(); ++j) {
const double diff = kernel->eval(xs(j),xs(i));
std::cout << "diff: " << diff << std::endl;
if (diff != diff){
exit(-1);
}
K(i,j) = diff;
K(j,i) = diff;
}
}
stale = false;
}
示例2: sse_test
static void
sse_test (void)
{
assert (ys (1) == xs ());
assert (ys (2) == xs () * 2);
assert (yd (1) == xd ());
assert (yd (2) == xd () * 2);
}
示例3: print_line
void
print_line(line* t)
{
fprintf(outfile, "newpath\n");
fprintf(outfile, "4 setlinewidth\n");
fprintf(outfile, "0.3 setgray\n");
fprintf(outfile, "%f %f moveto\n", xs(t->v1[0]), ys(t->v1[1]));
fprintf(outfile, "%f %f lineto\n", xs(t->v2[0]), ys(t->v2[1]));
fprintf(outfile, "stroke\n");
}
示例4: print_circle
void print_circle()
{
fprintf(outfile, "newpath\n");
fprintf(outfile, "0 setgray\n");
fprintf(outfile, "1 setlinewidth\n");
fprintf(outfile, "%f %f %f 0 360 arc\n",
(double)(xs(0)), (double)(ys(0)), (double)((xs(RADIUS))-(xs(0))));
fprintf(outfile, "stroke\n");
}
示例5: print_proj_xy
void
print_proj_xy(triangle* t)
{
fprintf(outfile, "newpath\n");
fprintf(outfile, "0.2 setlinewidth\n");
fprintf(outfile, "%f %f moveto\n", xs(t->v1[0]), ys(t->v1[1]));
fprintf(outfile, "%f %f lineto\n", xs(t->v2[0]), ys(t->v2[1]));
fprintf(outfile, "%f %f lineto\n", xs(t->v3[0]), ys(t->v3[1]));
fprintf(outfile, "%f %f lineto\n", xs(t->v1[0]), ys(t->v1[1]));
fprintf(outfile, "stroke\n");
}
示例6: assert
void
MockReadonlyIndex::build(SortableStrVec& keys) {
const Schema* schema = m_schema;
const byte* base = keys.m_strpool.data();
size_t fixlen = schema->getFixedRowLen();
if (fixlen) {
assert(keys.m_index.size() == 0);
assert(keys.str_size() % fixlen == 0);
m_ids.resize_no_init(keys.str_size() / fixlen);
for (size_t i = 0; i < m_ids.size(); ++i) m_ids[i] = i;
std::sort(m_ids.begin(), m_ids.end(), [=](size_t x, size_t y) {
fstring xs(base + fixlen * x, fixlen);
fstring ys(base + fixlen * y, fixlen);
int r = schema->compareData(xs, ys);
if (r) return r < 0;
else return x < y;
});
}
else {
if (keys.str_size() >= UINT32_MAX) {
THROW_STD(length_error,
"keys.str_size=%lld is too large", llong(keys.str_size()));
}
// reuse memory of keys.m_index
auto offsets = (uint32_t*)keys.m_index.data();
size_t rows = keys.m_index.size();
m_ids.resize_no_init(rows);
for (size_t i = 0; i < rows; ++i) m_ids[i] = i;
for (size_t i = 0; i < rows; ++i) {
uint32_t offset = uint32_t(keys.m_index[i].offset);
offsets[i] = offset;
}
offsets[rows] = keys.str_size();
std::sort(m_ids.begin(), m_ids.end(), [=](size_t x, size_t y) {
size_t xoff0 = offsets[x], xoff1 = offsets[x+1];
size_t yoff0 = offsets[y], yoff1 = offsets[y+1];
fstring xs(base + xoff0, xoff1 - xoff0);
fstring ys(base + yoff0, yoff1 - yoff0);
int r = schema->compareData(xs, ys);
if (r) return r < 0;
else return x < y;
});
BOOST_STATIC_ASSERT(sizeof(SortableStrVec::SEntry) == 4*3);
m_keys.offsets.risk_set_data(offsets);
m_keys.offsets.risk_set_size(rows + 1);
m_keys.offsets.risk_set_capacity(3 * rows);
m_keys.offsets.shrink_to_fit();
keys.m_index.risk_release_ownership();
}
m_keys.strpool.swap((valvec<char>&)keys.m_strpool);
m_fixedLen = fixlen;
}
示例7: main
int main()
{
unsigned long cpu_facilities;
cpu_facilities = i386_cpuid ();
if (cpu_facilities & bit_SSE)
{
assert (ys (1) == xs ());
assert (ys (2) == xs () * 2);
assert (yd (1) == xd ());
assert (yd (2) == xd () * 2);
}
return 0;
}
示例8: validate_quant_solution
static void validate_quant_solution(ast_manager& m, expr* fml, expr* guard, qe::def_vector const& defs) {
// verify:
// new_fml => fml[t/x]
scoped_ptr<expr_replacer> rep = mk_expr_simp_replacer(m);
app_ref_vector xs(m);
expr_substitution sub(m);
for (unsigned i = 0; i < defs.size(); ++i) {
xs.push_back(m.mk_const(defs.var(i)));
sub.insert(xs.back(), defs.def(i));
}
rep->set_substitution(&sub);
expr_ref fml1(fml, m);
(*rep)(fml1);
expr_ref tmp(m);
tmp = m.mk_not(m.mk_implies(guard, fml1));
front_end_params fp;
smt::kernel solver(m, fp);
solver.assert_expr(tmp);
lbool res = solver.check();
//SASSERT(res == l_false);
if (res != l_false) {
std::cout << "Validation failed: " << res << "\n";
std::cout << mk_pp(tmp, m) << "\n";
model_ref model;
solver.get_model(model);
model_smt2_pp(std::cout, m, *model, 0);
fatal_error(0);
}
}
示例9: main
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
if (app.arguments().count() != 2) {
std::cerr << qPrintable(Traverse::tr("Usage: traverse <XML file>")) << std::endl;
return 1;
}
QFile file(app.arguments()[1]);
if (!file.open(QFile::ReadOnly)) {
std::cerr << qPrintable(Traverse::tr("Failed to open file: %1").arg(app.arguments()[1])) << std::endl;
return 1;
}
//! [traverse document]
QXmlStreamReader xs(&file);
while (!xs.atEnd()) {
if (xs.readNextStartElement())
std::cout << qPrintable(xs.name().toString()) << std::endl;
}
//! [traverse document]
file.close();
return 0;
}
示例10: xs
void DOMElement::setTextContent(const std::wstring & ws)
{
if(isNull())
return;
std::basic_string<XMLCh> xs(ws.begin(), ws.end());
XELEM(m_wrapped)->setTextContent(xs.c_str());
}
示例11: linSpaceVec
std::vector<T> linSpaceVec(T a, T b, size_t N) {
T h = (b - a) / static_cast<T>(N-1);
std::vector<T> xs(N);
typename std::vector<T>::iterator x;
T val;
for (x = xs.begin(), val = a; x != xs.end(); ++x, val += h)
*x = val;
return xs;
}
示例12: operator
std::vector<T> operator()(std::size_t size)
{
// Generate double as many elements because many will be discarded by
// applying unique.
result_type xs(source(2 * size));
std::sort(xs.begin(), xs.end());
auto last = std::unique(xs.begin(), xs.end());
xs.erase(last, xs.end());
return std::move(xs);
}
示例13: main
int main()
{
std::vector<X> xs(10);
set_parameter(xs, 42, &X::foo);
set_parameter(xs, "hello world", &X::splurgle);
for (auto const& x : xs)
std::cout << x.foo << ", " << x.splurgle << "\n";
}
示例14: linspace
std::vector<T> linspace(T begin, T end, size_t n) {
T h = (end - begin) / static_cast<T>(n-1);
std::vector<T> xs(n);
typename std::vector<T>::iterator it;
T val;
for (it = xs.begin(), val = begin;
it != xs.end(); ++it, val += h)
*it = val;
return xs;
}
示例15: wide_check_box
box
wide_check_box (path ip, SI x1, SI x2, pencil pen) {
SI width, height;
get_wide_parameters (x1, x2, pen, width, height);
array<box> bs (2);
array<SI> xs (2);
array<SI> ys (2);
xs[0]= ys[0]= xs[1]= ys[1]= 0;
bs[0]= line_box (decorate_middle (ip), 0, height, width/2, 0, pen);
bs[1]= line_box (decorate_middle (ip), width/2, 0, width, height, pen);
return composite_box (ip, bs, xs, ys);
}