本文整理汇总了C++中ratio函数的典型用法代码示例。如果您正苦于以下问题:C++ ratio函数的具体用法?C++ ratio怎么用?C++ ratio使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ratio函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QObject
ApplicationInfo::ApplicationInfo(QObject *parent): QObject(parent)
{
m_isMobile = false;
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) || defined(Q_OS_BLACKBERRY)
m_isMobile = true;
#endif
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
m_platform = Linux;
#elif defined(Q_OS_WIN)
m_platform = Windows;
#elif defined(Q_OS_MAC)
m_platform = MacOSX;
#elif defined(Q_OS_ANDROID)
m_platform = Android;
#elif defined(Q_OS_IOS)
m_platform = Ios;
#elif defined(Q_OS_BLACKBERRY)
m_platform = Blackberry;
#endif
QRect rect = qApp->primaryScreen()->geometry();
m_ratio = m_isMobile ? qMin(qMax(rect.width(), rect.height())/800. , qMin(rect.width(), rect.height())/520.) : 1;
m_sliderHandleWidth = getSizeWithRatio(70);
m_sliderHandleHeight = getSizeWithRatio(87);
m_sliderGapWidth = getSizeWithRatio(100);
m_isPortraitMode = m_isMobile ? rect.height() > rect.width() : false;
m_hMargin = m_isPortraitMode ? 20 * ratio() : 50 * ratio();
m_applicationWidth = m_isMobile ? rect.width() : 1120;
if (m_isMobile)
connect(qApp->primaryScreen(), SIGNAL(physicalSizeChanged(QSizeF)), this, SLOT(notifyPortraitMode()));
}
示例2: ratio
void ApplicationInfo::setIsPortraitMode(const bool newMode)
{
if (m_isPortraitMode != newMode) {
m_isPortraitMode = newMode;
m_hMargin = m_isPortraitMode ? 20 * ratio() : 50 * ratio();
emit portraitModeChanged();
emit hMarginChanged();
}
}
示例3: SYNC
void InlineCacheRegistry::print_stats(STATE) {
SYNC(state);
int total = 0;
std::vector<int> sizes(cTrackedICHits + 1);
int overflow = 0;
for(CacheHash::iterator hi = caches_.begin();
hi != caches_.end();
++hi) {
for(CacheVector::iterator vi = hi->second.begin();
vi != hi->second.end();
++vi) {
InlineCache* ic = *vi;
int seen = ic->classes_seen();
if(ic->seen_classes_overflow() > 0) {
total++;
overflow++;
} else if(seen > 0) {
total++;
sizes[seen]++;
}
}
}
std::cerr << "IC Stats:\n";
for(int i = 1; i < cTrackedICHits + 1; i++) {
std::cerr << " " << i << ": " << sizes[i] << " "
<< ratio(sizes[i], total) << "%\n";
}
std::cerr << cTrackedICHits << "+: " << overflow << " "
<< ratio(overflow, total) << "%\n";
// print out the mega-morphic ones
std::cerr << "\nMegamorphic call sites:\n";
for(CacheHash::iterator hi = caches_.begin();
hi != caches_.end();
++hi) {
for(CacheVector::iterator vi = hi->second.begin();
vi != hi->second.end();
++vi) {
InlineCache* ic = *vi;
if(ic->seen_classes_overflow() > 0) {
ic->print(state, std::cerr);
std::cerr << "location: ";
ic->print_location(state, std::cerr);
std::cerr << "\n\n";
}
}
}
}
示例4: results_compare
int results_compare(struct ts_results *tsr1, struct ts_results *tsr2)
{
int i;
struct ts_plugin_results *tspr1, *tspr2;
if (!tsr1 || !tsr2) {
CRITICAL("Null energy result list\n");
return -1;
}
if (tsr1->nr_results != tsr2->nr_results)
WARNING("There is a different number of results\n");
tspr1 = tsr1->tspr;
tspr2 = tsr2->tspr;
if (!tspr1 || !tspr2) {
CRITICAL("No plugin results !\n");
return -1;
}
for (i = 0; i < tsr1->nr_results; i++) {
struct ts_plugin_results *tspr;
char *name = basename(tsr1->tspr[i].path);
tspr = results_find(tspr1[i].path, tsr2);
if (!tspr) {
WARNING("Failed to find plugin '%s' result to compare\n", name);
continue;
}
DEBUG("'%s': %.0lf / %.0lf usecs\n",
name, tspr1[i].duration, tspr->duration);
DEBUG("'%s': %lf / %lf uJ\n", name, tspr1[i].energy, tspr->energy);
NOTICE("'%s': %+.2lf%% usecs / %+.2lf%% uJ\n",
name, ratio(tspr1[i].duration, tspr->duration),
ratio(tspr1[i].energy, tspr->energy));
}
DEBUG("Overall time: %.0lf / %.0lf usecs\n",
tsr1->duration, tsr2->duration);
DEBUG("Overall energy: %lf / %lf uJ\n", tsr1->energy, tsr2->energy);
NOTICE("Overall: %+.2lf%% usecs / %+.2lf%% uJ\n",
ratio(tsr1->duration, tsr2->duration),
ratio(tsr1->energy, tsr2->energy));
return 0;
}
示例5: product
/**
* parameter:
* @lp1 the left bound of the first bucket
* @rp1 the right bound of the first bucket
* @d1 the distinct value in the first bucket
* @lp2 the left bound of the second bucket
* @rp2 the right bound of the second bucket
* @d2 the distinct value in the second bucket
*/
unsigned long product(const void *lp1, const void *rp1, const int d1,
const int c1, const void *lp2, const void *rp2, const int d2,
const int c2, const column_type *type) {
double r1 = ratio(lp1, rp1, lp2, rp2, type);
double r2 = ratio(lp2, rp2, lp1, rp1, type);
int numDistinctValue1 = d1 * r1;
int numDistinctValue2 = d2 * r2;
int numCombination =
numDistinctValue1 < numDistinctValue2 ?
numDistinctValue1 : numDistinctValue2;
return c1 / d1 * c2 / d2 * numCombination;
}
示例6: ratio
/**
* assume both lowPara and upperPara is legal
* lowPara:
* upperPara:
* range is used with < and >, instead of =
* for <=, it decomposed into < and =
*/
unsigned long Estimation::estRangeOper(AttributeID attrID, void *lowPara,
void *upperPara) {
unsigned long ret = 0;
const Histogram *stat = StatManager::getInstance()->getHistogram(attrID);
Attribute attr =
Catalog::getInstance()->getTable(attrID.table_id)->getAttribute(
attrID.offset);
Operate *op = attr.attrType->operate;
// column_type* type =
// Catalog::getInstance()->getTable(attrID.table_id)->getAttribute(
// attrID.offset).attrType;
// Operate *op = type->operate;
double sel = 0;
for (unsigned i = 0; i < stat->m_bucketCnt - 1; ++i) {
if ((op->Compare(lowPara, stat->m_staValues1[i]) <= 0)
&& (op->Compare(stat->m_staValues1[i + 1], upperPara) <= 0)) {
sel += 1;
//the lowest value of the bucket is unreachable
if (op->Equal(lowPara, stat->m_staValues1[i]))
sel -= 1.0 / stat->m_staNumbers1[i];
} else { //intersect
double r = ratio(stat->m_staValues1[i], stat->m_staValues1[i + 1],
lowPara, upperPara, attr.attrType);
sel += r;
}
}
sel = sel / (stat->m_bucketCnt - 1);
ret = sel * stat->m_staCount;
return ret;
}
示例7: QGLWidget
MyWidget::MyWidget(QGLWidget *parent)
: QGLWidget(QGLFormat(), parent)
{
setMouseTracking(true);
setPaletteBackgroundColor(QColor(255,255,255));
setstatus();
menu = new QMenuBar(this, "Menu bar");
file = new QPopupMenu( this , "file");
save = new QPopupMenu( this , "save");
placement = new QPopupMenu( this , "placement");
options = new QPopupMenu( this , "options");
view = new QPopupMenu( this , "viewing");
save->insertItem( "Save &eps file", this, SLOT(savedepsfile()), CTRL+Key_E );
save->insertItem( "Save &stl file", this, SLOT(savedstlfile()), CTRL+Key_S );
file->insertItem( "&Load", this, SLOT(openedfile()), CTRL+Key_L );
generate_id = placement->insertItem( "&Generate", &p, SLOT(generate()), CTRL+Key_G );
generatefirst_id = placement->insertItem( "Generate &First", &p, SLOT(generateFirst()), CTRL+Key_F );
generatenext_id = placement->insertItem( "Generate &Next", &p, SLOT(generateNext()), CTRL+Key_N );
generateten_id = placement->insertItem( "Next &ten streamlines", &p, SLOT(generateTen()), CTRL+Key_T );
generateresume_id = placement->insertItem( "&Resume the placement", &p, SLOT(generateAll()), CTRL+Key_C );
clear_id = placement->insertItem( "&Clear", &p, SLOT(purge()), CTRL+Key_M );
drawstl_id = view->insertItem( "&Draw streamlines", &p, SLOT(draw_stl()), CTRL+Key_D );
drawpq_id = view->insertItem( "Draw &queue elements", &p, SLOT(draw_pq()), CTRL+Key_Q );
drawtr_id = view->insertItem( "Draw t&riangulation", &p, SLOT(draw_tr()), CTRL+Key_R );
drawbc_id = view->insertItem( "Draw &biggest circle", &p, SLOT(draw_bc()), CTRL+Key_B );
addimage_id = placement->insertItem( "&Image", this, SLOT(openedimage()), CTRL+Key_I );
options->insertItem( "Density...", &p, SLOT(density()));
options->insertItem( "Saturation ration...", &p, SLOT(ratio()));
options->insertItem( "Sampling step...", &p, SLOT(sampling()));
options->insertItem( "Integrating step...", &p, SLOT(integrating()));
placement->insertItem( "&Options ", options );
save_id = file->insertItem( "&Save", save );
menu->insertItem( "&File", file );
menu->insertItem( "&Placement", placement );
view_id = menu->insertItem( "&View ", view );
file->insertItem( "&Quit", qApp, SLOT(quit()), ALT+Key_F4 );
// desable all generator menu items
placement->setItemEnabled(generate_id, false);
placement->setItemEnabled(generatefirst_id, false);
placement->setItemEnabled(generatenext_id, false);
placement->setItemEnabled(generateten_id, false);
placement->setItemEnabled(generateresume_id, false);
placement->setItemEnabled(clear_id, false);
menu->setItemEnabled(view_id, false);
placement->setItemEnabled(addimage_id, false);
file->setItemEnabled(save_id, false);
connect(this, SIGNAL(fileloaded(const QString &)), &p, SLOT(load(const QString &)));
connect(this, SIGNAL(imageloaded(const QString &)), &p, SLOT(image(const QString &)));
connect(&p, SIGNAL(optionschanged()), this, SLOT(updatestatus()));
}
示例8: ratio
void RELabel::renderAtWithShadow(const REFloat32 x, const REFloat32 y)
{
if (_font)
{
RERenderDevice * device = RERenderDevice::defaultDevice();
RESize ratio(_font->getCharsScaleRatio());
if (_frame.height != 0.0f)
{
ratio.height *= (_textInsets.adjustedRect(_frame).height / _frame.height);
}
REFloat32 penX = x;
const REFloat32 bottomY = y + _font->getHeight() - _textInsets.bottom - _textInsets.top;
for (REUInt32 i = 0; i < _chars.count(); i++)
{
RETTFFontChar * fontChar = _chars[i];
penX += ((ratio.width * fontChar->offsetX) * _charsSpaceRatio);
const REFloat32 penY = bottomY - (ratio.height * fontChar->offsetY);
const REFloat32 width = (ratio.width * fontChar->width);
const REFloat32 height = (ratio.height * fontChar->height);
device->renderRect(RERect(penX + _shadowOffset.x, penY + _shadowOffset.y, width, height),
_shadowColor,
fontChar->textureFrame,
fontChar->texture);
device->renderRect(RERect(penX, penY, width, height),
_textColor,
fontChar->textureFrame,
fontChar->texture);
penX += (ratio.width * fontChar->advanceX);
}
}
}
示例9: doTask5B
void doTask5B()
{
int a;
int b;
int x;
int y;
scanf("%d %d %d %d", &a, &b, &x, &y);
Fraction monitor(a, b);
//monitor.reduce();
Fraction ratio(x, y);
//ratio.reduce();
while (monitor != ratio && !monitor.isEmpty()) {
if (monitor.getValue() > ratio.getValue()) {
monitor.setNumerator(ratio.getValue() * monitor.getDenominator());
//monitor.reduce();
} else {
monitor.setDenominator(monitor.getNumerator() / ratio.getValue());
//monitor.reduce();
}
}
if (monitor.isEmpty()) {
printf("0 0\n");
} else {
printf("%d %d\n", monitor.getNumerator(), monitor.getDenominator());
}
//auto stop = 0;
//scanf("%d", &stop);
}
示例10: ratio
// drives wheels with differential based on angle
void wheels::drive(int angle, int speed) {
int left;
int right;
if (angle > 0) {
right = speed;
left = speed * ratio(angle); //max angle here is +45 left goes 1/4 as fast
} else {
left = speed;
right = speed * ratio(angle); //"max" angle here is -45 _CHANGE
}
driveWheels(left, right);
return;
}
示例11: ratio
void REGUIApplication::onClickOnScreenEnd(const REFloat32 screenX, const REFloat32 screenY)
{
if (_userActionViews.count() && _renderDevice)
{
RESize ratio(_renderDevice->screenToRenderSizeRatio());
const REFloat32 x = ratio.width * screenX;
const REFloat32 y = ratio.height * screenY;
for (REUInt32 i = 0; i < _userActionViews.count(); i++)
{
_userActionViews[i]->userActionClickDidEnd(_lastUserClickPos.x, _lastUserClickPos.y, x, y);
}
if (_isLastUserClickMoving)
{
_isLastUserClickMoving = 0;
if ((fabs(_lastUserClickPos.x - x) > 0.0) || (fabs(_lastUserClickPos.y - y) > 0.0))
{
for (REUInt32 i = 0; i < _userActionViews.count(); i++)
{
_userActionViews[i]->userActionClickMovingDidEnd(_lastUserClickPos.x, _lastUserClickPos.y, x, y);
}
}
}
}
}
示例12: ratio
void steering::drive(int angle, int speed) {
int left;
int right;
if (angle > 0) {
left = speed;
right = speed * ratio(angle);
} else {
right = speed;
left = speed/ratio(angle);
}
analogWrite(PWMR, right);
analogWrite(PWML, left);
return;
}
示例13: main
int main(int argc, char ** argv) {
char buffer[BUFFER_SIZE] = { 0 };
char comp[BUFFER_SIZE] = { 0 };
char out[BUFFER_SIZE] = { 0 };
int count = 0;
double ratios = 0;
double rat = 0;
int inlen, complen, outlen;
while (fgets(buffer, BUFFER_SIZE, stdin) != NULL) {
char *end = strchr(buffer, '\n');
if (end != NULL)
*end = '\0';
else
break;
inlen = strlen(buffer);
complen = shoco_compress(buffer, 0, comp, BUFFER_SIZE);
outlen = shoco_decompress(comp, complen, out, BUFFER_SIZE);
rat = ratio(inlen, complen);
if (complen != 0) {
++count;
ratios += rat;
}
if ((argc > 1) && ((strcmp(argv[1], "-v") == 0) || (strcmp(argv[1], "--verbose") == 0))) {
print(buffer, rat);
}
assert(inlen == outlen);
assert(strcmp(buffer, out) == 0);
}
printf("Number of compressed strings: %d, average compression ratio: %d%%\n", count, percent(ratios / count));
return 0;
}
示例14: logRatio
DiracDeterminantBase::ValueType DiracDeterminantBase::logRatio(ParticleSet& P, int iat,
ParticleSet::ParticleGradient_t& dG,
ParticleSet::ParticleLaplacian_t& dL) {
//THIS SHOULD NOT BE CALLED
ValueType r=ratio(P,iat,dG,dL);
return LogValue = evaluateLogAndPhase(r,PhaseValue);
}
示例15: decode
int64_t decode(void *buffer, size_t size, int64_t sum)
{
unsigned int i;
C(table_t) foobarcontainer;
FooBar(vec_t) list;
FooBar(table_t) foobar;
Bar(struct_t) bar;
Foo(struct_t) foo;
foobarcontainer = C(as_root(buffer));
sum += C(initialized(foobarcontainer));
sum += StringLen(C(location(foobarcontainer)));
sum += C(fruit(foobarcontainer));
list = C(list(foobarcontainer));
for (i = 0; i < FooBar(vec_len(list)); ++i) {
foobar = FooBar(vec_at(list, i));
sum += StringLen(FooBar(name(foobar)));
sum += FooBar(postfix(foobar));
sum += (int64_t)FooBar(rating(foobar));
bar = FooBar(sibling(foobar));
sum += (int64_t)Bar(ratio(bar));
sum += Bar(size(bar));
sum += Bar(time(bar));
foo = Bar(parent(bar));
sum += Foo(count(foo));
sum += Foo(id(foo));
sum += Foo(length(foo));
sum += Foo(prefix(foo));
}
return sum + 2 * sum;
}