本文整理汇总了C++中yvec_t::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ yvec_t::push_back方法的具体用法?C++ yvec_t::push_back怎么用?C++ yvec_t::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yvec_t
的用法示例。
在下文中一共展示了yvec_t::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
load(const char *fname, xvec_t &xp, yvec_t &yp)
{
cout << "Loading " << fname << "." << endl;
igzstream f;
f.open(fname);
if (! f.good())
{
cerr << "ERROR: cannot open " << fname << "." << endl;
exit(10);
}
int pcount = 0;
int ncount = 0;
bool binary;
string suffix = fname;
if (suffix.size() >= 7)
suffix = suffix.substr(suffix.size() - 7);
if (suffix == ".dat.gz")
binary = false;
else if (suffix == ".bin.gz")
binary = true;
else
{
cerr << "ERROR: filename should end with .bin.gz or .dat.gz" << endl;
exit(10);
}
while (f.good())
{
SVector x;
double y;
if (binary)
{
y = (f.get()) ? +1 : -1;
x.load(f);
}
else
{
f >> y >> x;
}
if (f.good())
{
assert(y == +1 || y == -1);
xp.push_back(x);
yp.push_back(y);
if (y > 0)
pcount += 1;
else
ncount += 1;
if (x.size() > dim)
dim = x.size();
}
if (trainsize > 0 && xp.size() > (unsigned int)trainsize)
break;
}
cout << "Read " << pcount << "+" << ncount
<< "=" << pcount + ncount << " examples." << endl;
}
示例2: assertfail
static void
loadmult_datafile_sub(istream &f, bool binary, const char *fname,
xvec_t &xp, yvec_t &yp, int &maxdim, int maxrows)
{
cout << "# Reading file " << fname << endl;
if (! f.good())
assertfail("Cannot open " << fname);
int pcount = 0;
while (f.good() && maxrows--)
{
double y;
SVector x;
y = (f.get());
x.load(f);
if (f.good())
{
xp.push_back(x);
yp.push_back(y);
pcount += 1;
if (x.size() > maxdim)
maxdim = x.size();
}
}
cout << "# Read " << pcount << " examples." << endl;
}