本文整理汇总了C++中vec::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ vec::empty方法的具体用法?C++ vec::empty怎么用?C++ vec::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec
的用法示例。
在下文中一共展示了vec::empty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solve
vec bokhoven::solve(const vec& q, const stop& s, vec x ) const {
const natural n = lcp.dim();
assert(q.rows() == int(n));
if(x.empty()) { x = vec::Zero(n); }
assert( x.rows() == q.rows() );
const mat& M = lcp.M;
algo::iter_eps(s, [&](real& eps) {
x.each([&](natural i ) {
const real x_i = x(i);
x(i) = (q(i) - this->P.row(i).dot(x) + std::abs( x(i) ) - M.row(i).dot(x.array().abs().matrix()) ) / this->d(i);
const real diff = x(i) - x_i;
eps += diff * diff;
});
eps = std::sqrt(eps);
});
return (x.array().abs() + x.array());
}
示例2: unlink
static void
pidclean ()
{
for (; !pidfiles.empty (); pidfiles.pop_front ()) {
pidfile &pf = pidfiles.front ();
struct stat sb;
if (!stat (pf.path, &sb)
&& sb.st_dev == pf.sb.st_dev
&& sb.st_ino == pf.sb.st_ino)
unlink (pf.path);
}
}
示例3: bzero
static void
launchservers ()
{
for (sfssrv *nsp, *sp = services.first; sp; sp = nsp) {
nsp = services.next (sp);
sp->launch ();
}
if (listenaddrs.empty () && sfs_defport) {
sockaddr_in *sinp = New sockaddr_in;
bzero (sinp, sizeof (*sinp));
sinp->sin_family = AF_INET;
sinp->sin_port = htons (SFS_PORT);
sinp->sin_addr.s_addr = htonl (INADDR_ANY);
listenaddrs.push_back (reinterpret_cast<sockaddr *> (sinp));
}
if (listenaddrs.empty ())
whatport (sfshostname (), wrap (setaddrs));
else
dolisten ();
}
示例4: results
void results(const mat& Q, const vec& c,
const mat& A, const vec& b,
const vec& x,
vec reference = vec()) {
// std::cout << "solution: " << x.transpose() << std::endl;
using namespace std;
const math::natural m = c.rows();
const math::natural n = b.rows();
cout << "violation: " << (A * x - b).cwiseMin( vec::Zero(n) ).squaredNorm() / m << endl;
cout << "obj: " << x.dot( 0.5 * (Q * x) + c ) << endl;
if(!reference.empty()) {
core::log("error:", (x - reference).norm() );
}
cout << endl;
}
示例5: inetsocket
static void
dolisten ()
{
for (sockaddr **sp = listenaddrs.base (); sp < listenaddrs.lim (); sp++) {
sockaddr_in *sinp = reinterpret_cast<sockaddr_in *> (*sp);
int fd = inetsocket (SOCK_STREAM, ntohs (sinp->sin_port),
ntohl (sinp->sin_addr.s_addr));
if (fd < 0)
warn ("could not bind TCP port %d: %m\n", ntohs (sinp->sin_port));
else {
if (sinp->sin_addr.s_addr == htonl (INADDR_ANY))
warn ("listening on TCP port %d\n", ntohs (sinp->sin_port));
else
warn ("listening on %s TCP port %d\n",
inet_ntoa (sinp->sin_addr), ntohs (sinp->sin_port));
listeners.push_back (New refcounted<listener> (fd));
}
}
if (listeners.empty ())
fatal ("no TCP ports to listen on\n");
hup_lock = false;
}
示例6: validateNewAttachments
void FrameBuffer::validateNewAttachments(const vec<sptr<Texture2D>> &attachments)
{
SL_DEBUG_PANIC(attachments.empty(), "Frame buffer must have at least one attachment");
auto width = (std::numeric_limits<u32>::max)(), height = (std::numeric_limits<u32>::max)();
auto depthAttachmentCount = 0;
for (const auto &attachment : attachments)
{
if (attachment->format() == TextureFormat::Depth24)
SL_DEBUG_PANIC(++depthAttachmentCount > 1, "Frame buffer can only have one depth attachment");
const auto size = attachment->dimensions();
if (width == (std::numeric_limits<u32>::max)())
{
width = static_cast<u32>(size.x());
height = static_cast<u32>(size.y());
}
else
{
SL_DEBUG_PANIC(static_cast<u32>(size.x()) != width || static_cast<u32>(size.y()) != height,
"Frame buffer attachments must have same dimentions");
}
}
}
示例7: worst
double worst() {
return best.empty()
? -std::numeric_limits< double >::max()
: *best.rbegin();
}
示例8: while
static void
unixserv_cleanup ()
{
while (!sockets.empty ())
unlink (sockets.pop_front ());
}