void KDoubleSpinBox::updateValidator() { if ( !d->mValidator ) { d->mValidator = new KDoubleSpinBoxValidator( minValue(), maxValue(), precision(), this, "d->mValidator" ); base::setValidator( d->mValidator ); } else d->mValidator->setRange( minValue(), maxValue(), precision() ); }
string asset::to_string()const { string result = fc::to_string(amount.value / precision()); if( decimals() ) { auto fract = amount.value % precision(); result += "." + fc::to_string(precision() + fract).erase(0,1); } return result + " " + symbol_name(); }
bool QgsRendererRangeV2LabelFormat::operator==( const QgsRendererRangeV2LabelFormat &other ) const { return format() == other.format() && precision() == other.precision() && trimTrailingZeroes() == other.trimTrailingZeroes(); }
/* encode contiguous floating-point block */ uint _t2(zfp_encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) { /* compute maximum exponent */ int emax = _t1(exponent_block, Scalar)(fblock, BLOCK_SIZE); int maxprec = precision(emax, zfp->maxprec, zfp->minexp, DIMS); uint e = maxprec ? emax + EBIAS : 0; /* encode block only if biased exponent is nonzero */ if (e) { cache_align_(Int iblock[BLOCK_SIZE]); /* encode common exponent; LSB indicates that exponent is nonzero */ int ebits = EBITS + 1; stream_write_bits(zfp->stream, 2 * e + 1, ebits); /* perform forward block-floating-point transform */ _t1(fwd_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); /* encode integer block */ return ebits + _t2(encode_block, Int, DIMS)(zfp->stream, zfp->minbits - ebits, zfp->maxbits - ebits, maxprec, iblock); } else { /* write single zero-bit to indicate that all values are zero */ stream_write_bit(zfp->stream, 0); if (zfp->minbits > 1) { stream_pad(zfp->stream, zfp->minbits - 1); return zfp->minbits; } else return 1; } }
MessageHandler_() : std::ostream(new Buf(*this)), indent(indentLevel * INDENT_SIZE), beginLine(0), stepCount(0) { flags(os.flags()); precision(os.precision()); width(os.width()); }
void CardTableModRefBSForCTRS::non_clean_card_iterate_possibly_parallel( Space* sp, MemRegion mr, OopsInGenClosure* cl, CardTableRS* ct, uint n_threads) { if (!mr.is_empty()) { if (n_threads > 0) { #if INCLUDE_ALL_GCS non_clean_card_iterate_parallel_work(sp, mr, cl, ct, n_threads); #else // INCLUDE_ALL_GCS fatal("Parallel gc not supported here."); #endif // INCLUDE_ALL_GCS } else { // clear_cl finds contiguous dirty ranges of cards to process and clear. // This is the single-threaded version used by DefNew. const bool parallel = false; DirtyCardToOopClosure* dcto_cl = sp->new_dcto_cl(cl, precision(), cl->gen_boundary(), parallel); ClearNoncleanCardWrapper clear_cl(dcto_cl, ct, parallel); clear_cl.do_MemRegion(mr); } } }
double ConfusionMatrix::fscore(int category) { double p = precision(category); double r = recall(category); if((p + r) == 0.0) return 0.0; return (2 * p * r) / (p + r); }
AplusFuncLabel::AplusFuncLabel(A a_, AplusLabelOut *alo_) : AplusLabelOut() { if (alo_!=0 && alo_->outFunc()!=0) { outFunc(alo_->outFunc()); v(alo_->v()); } if (alo_!=0 && alo_->format()!=AplusFormatter::BadFormat) { format(alo_->format()); precision(alo_->precision()); } if (verify(a_)==MSTrue) { a((A) ic(a_)); } else { MSStringVector emptyStringVector; a((A)0); tick((A)0); grid((A)0); value((A)0); labels(emptyStringVector); } }
// network specific types int operator()(Layout_type const* t) { int n = 0; for (Decl* d : t->declaration()->fields()) n += precision(d->type()); return n; }
void ft_putloo(va_list ap) { char *str; if ((g_trait & OPT_J) == OPT_J) str = ft_putjo(ap); else if (g_trait & OPT_Z) str = ft_putzo(ap); else if ((g_trait & OPT_LL) == OPT_LL) str = ft_putllo(ap); else if ((g_trait & OPT_L) == OPT_L) str = ft_putlo(ap); else if ((g_trait & OPT_HH) == OPT_HH) str = ft_puthho(ap); else if ((g_trait & OPT_H) == OPT_H) str = ft_putho(ap); else str = ft_putosf(ap); str = precision(str, 8); if (ft_strcmp(str, "") == 0 && g_trait & OPT_DIESE) str = ft_strdup("0"); str = treat_o(str); g_print += ft_strlen(str); ft_putstr_fd(str, g_fd); free(str); }
void CLabHorizScale::drawScale(CDC *pDC) { int tickLength; CRgn rgn; CRect rect = bounds(); rgn.CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom); pDC->SelectClipRgn(&rgn); for(double x=getTickMin(); x<=maximum(); x=x+tickIncrement()) { double temp = x/(majorTickFrequency()*tickIncrement()); if(temp == ceil(temp)) tickLength = 7; else tickLength = 3; pDC->MoveTo(translateCoordinate(x), rect.top); pDC->LineTo(translateCoordinate(x), rect.top + tickLength); temp = x/(tickMarkFrequency() * tickIncrement()); if(temp == ceil(temp)) { CString tickMarkStr; tickMarkStr.Format("%.*f", precision(), x); pDC->TextOut(translateCoordinate(x) - _parent->getCharWidth() * tickMarkStr.GetLength()/2, rect.top + 7 /* _parent->getCharHeight()*/, tickMarkStr); } } }
MessageHandler_() : std::ostream(&buf), buf(*this), indent(indentLevel * INDENT_SIZE), beginLine(0), totalSteps(0), stepCount(0), dotCount(0), dotTime(0), stepping(false) { flags(os.flags()); precision(os.precision()); width(os.width()); }
model::AssetResponse PbQueryResponseFactory::deserializeAssetResponse( const protocol::AssetResponse &response) const { model::AssetResponse res; auto asset = response.asset(); res.asset = Asset(asset.asset_id(), asset.domain_id(), asset.precision()); return res; }
double CoverMetrics::f1score() const { double p = precision(); double r = recall(); if (p + r < std::numeric_limits<double>::epsilon()) { return std::sqrt(-1); // return NaN } return 2*p*r/(p + r); }
basic_ios& copyfmt(const ios& right) { fill(right.fill()); flags(right.flags() ); exceptions(right.exceptions()); width(right.width()); precision(right.precision()); return *this; }
/** * Stringify the data. * @return the content of asset. */ std::string toString() const override { return detail::PrettyStringBuilder() .init("Asset") .append("assetId", assetId()) .append("domainId", domainId()) .append("precision", std::to_string(precision())) .finalize(); }
//------------------------------------------------------------------------------ void ostream::putDouble(double n) { uint8_t nd = precision(); double round = 0.5; char sign; char buf[13]; // room for sign, 10 digits, '.', and zero byte char *end = buf + sizeof(buf) - 1; char *str = end; // terminate string *end = '\0'; // get sign and make nonnegative if (n < 0.0) { sign = '-'; n = -n; } else { sign = flags() & showpos ? '+' : '\0'; } // check for larger than uint32_t if (n > 4.0E9) { pgm err(PSTR("BIG FLT")); putPgm(err); return; } // round up and separate in and fraction parts for (uint8_t i = 0; i < nd; ++i) round *= 0.1; n += round; uint32_t intPart = n; double fractionPart = n - intPart; // format intPart and decimal point if (nd || (flags() & showpoint)) *--str = '.'; str = fmtNum(intPart, str, 10); // calculate length for fill uint8_t len = sign ? 1 : 0; len += nd + end - str; // extract adjust field fmtflags adj = flags() & adjustfield; if (adj == internal) { if (sign) putch(sign); do_fill(len); } else { // do fill for internal or right fill_not_left(len); if (sign) *--str = sign; } putstr(str); // output fraction while (nd-- > 0) { fractionPart *= 10.0; int digit = static_cast<int>(fractionPart); putch(digit + '0'); fractionPart -= digit; } // do fill if not done above do_fill(len); }
SVOutStream::SVOutStream(ostream& out, const String& sep, const String& replacement, String::QuotingMethod quoting) : ostream(out.rdbuf()), sep_(sep), replacement_(replacement), nan_("nan"), inf_("inf"), quoting_(quoting), modify_strings_(true), newline_(true) { // use high decimal precision (appropriate for double): precision(std::numeric_limits<double>::digits10); }
ACE_UINT32 ACE_Stats_Value::fractional_field (void) const { if (precision () == 0) { return 1; } else { ACE_UINT32 field = 10; for (u_int i = 0; i < precision () - 1; ++i) { field *= 10; } return field; } }
void writeLogfileEntry(std::ofstream &ofLog, const std::string &sFilename, int tp, int fp, int fn) { ofLog << sFilename << std::endl; ofLog << "# faces: " << tp+fn; ofLog << ", # detected faces: " << tp+fp << std::endl; ofLog << "tp = " << tp << ", fp = " << fp << ", fn = " << fn; ofLog << ", pr = " << precision(tp, fp); ofLog << ", rc = " << recall(tp, fn) << std::endl; ofLog.flush(); }
bool UVSphere::hit(const Ray& r, precision tMin, precision tMax, precision time, HitRecord& record) const{ Vector3 temp = r.origin() - center; double a = dot(r.direction(), r.direction()); double b = 2 * dot(r.direction(), temp); double c = dot(temp, temp) - radius * radius; double discriminant = b * b - 4 * a * c; //First check to see if the ray intersects the sphere if(discriminant > 0){ discriminant = sqrt(discriminant); double t = (- b - discriminant) / (2 * a); //Now check for a valid interval if(t < tMin) t = (- b + discriminant) / (2 * a); if(t < tMin || t > tMax) return false; //We have a valid hit record.t = (precision)t; record.hitP = (r.origin() + (precision)t * r.direction()); //record.normal = unitVector(r.origin() + (precision)t * r.direction() - center); Vector3 n = record.normal = (record.hitP - center) / radius; //Calculate UV coordinates precision twopi = precision(2 * M_PI); precision one_over_2pi = precision(M_1_PI / 2) ; precision theta = acos(n.z()); precision phi = atan2(n.y(), n.x()); if (phi < 0.0f) phi += twopi; record.uv = Vector2(precision(phi * one_over_2pi), precision((M_PI - theta) * M_1_PI)); return true; } return false; }
string asset::to_string() const { int64_t prec = precision(); string result = fc::to_string(amount.value / prec); if (prec > 1) { auto fract = amount.value % prec; // prec is a power of ten, so for example when working with // 7.005 we have fract = 5, prec = 1000. So prec+fract=1005 // has the correct number of zeros and we can simply trim the // leading 1. result += "." + fc::to_string(prec + fract).erase(0, 1); } return result + " " + symbol_name(); }
pgsOperand pgsGenReal::eval(pgsVarMap &vars) const { // Evaluate parameters pgsOperand min(m_min->eval(vars)); pgsOperand max(m_max->eval(vars)); pgsOperand precision(m_precision->eval(vars)); pgsOperand sequence(m_sequence->eval(vars)); pgsOperand seed(m_seed->eval(vars)); // Check parameters and create the generator if (min->is_number() && max->is_number() && sequence->is_integer() && seed->is_integer() && precision->is_integer()) { long aux_sequence, aux_seed, aux_precision; sequence->value().ToLong(&aux_sequence); seed->value().ToLong(&aux_seed); precision->value().ToLong(&aux_precision); return pnew pgsGenerator(pgsVariable::pgsTReal, pnew pgsRealGen(pgsVariable::num(min), pgsVariable::num(max), aux_precision, aux_sequence != 0, aux_seed)); } else { // Deal with errors if (!min->is_number()) { throw pgsParameterException(wxString() << value() << wxT(":\nmin should be a number")); } else if (!max->is_number()) { throw pgsParameterException(wxString() << value() << wxT(":\nmax should be a number")); } else if (!precision->is_integer()) { throw pgsParameterException(wxString() << value() << wxT(":\nprecision should be an integer")); } else if (!sequence->is_integer()) { throw pgsParameterException(wxString() << value() << wxT(":\nsequence should be an integer")); } else { throw pgsParameterException(wxString() << value() << wxT(":\nseed should be an integer")); } } }
AplusFormatLabelOut::AplusFormatLabelOut(AplusFormatter::OutputFormat format_, int precision_, AplusLabelOut *alo_) : AplusLabelOut() { format(format_); precision(precision_); if (alo_!=0 && alo_->a()!=0) { a((A)ic(alo_->a())); tick(alo_->tick()); grid(alo_->grid()); value(alo_->value()); } }
bool Matrix::operator==(const Matrix& m) const { if(size() != m.size()) { return false; } if(precision() != m.precision()) { return false; } return reduce(apply(*this, m, NotEqual()), {}, Add())[0] == 0; }
/** * \return Log of the probability of the given sample \c vector * * \param vector sample which should be evaluated * * \throws see has_full_rank() */ Real log_probability(const Variate& vector) const override { // assert(has_full_rank()); if(has_full_rank()) { return log_normalizer() - 0.5 * (vector - mean()).transpose() * precision() * (vector - mean()); } return -std::numeric_limits<Real>::infinity(); }
// function: sig_fig // ------------------- REAL_TYPE sig_fig(REAL_TYPE x, int sigFigs) throw(std::invalid_argument) { if(sigFigs <= 0) throw(std::invalid_argument("sig_fig(): sigFigs must be greater than 0.")); int sign; if(x < 0.0) sign = -1; else sign = 1; x = std::abs(x); REAL_TYPE powers = std::pow(10.0, std::floor(std::log10(x)) + 1.0); return sign * precision(x / powers, sigFigs) * powers; }
//! @{ virtual void compute_nodes() override { this->nodes = vector<precision>(this->num_nodes, precision(0.0)); auto l = Polynomial<precision>::legendre(this->num_nodes); auto lm1 = Polynomial<precision>::legendre(this->num_nodes - 1); for (size_t i = 0; i < this->num_nodes; i++) { l[i] += lm1[i]; } auto roots = l.roots(); for (size_t j = 1; j < this->num_nodes; j++) { this->nodes[j - 1] = 0.5 * (1.0 - roots[this->num_nodes - j]); } this->nodes.back() = 1.0; }
void ConfusionMatrix::print_summary() { // overall counts and summary cout.precision(4); cout << "== Summary ==" << endl; cout << setw(23) <<"Correctly classified:" << setw(12) << right << correct << setw(10) << right << accuracy() * 100 << "%" << endl; cout << setw(23) << "Incorrectly classified:" << setw(12) << right << incorrect << setw(10) << right << error() * 100 << "%" << endl; cout << setw(23) << "Total classifications:" << setw(12) << right << correct + incorrect << endl << endl; // determine the width of the left (category name) column int max_name_length = 0; for(int category = 1; category <= data_set->categories_size(); category++) if(data_set->category_feature()->names[category].length() > max_name_length) max_name_length = data_set->category_feature()->names[category].length(); if(average_row_name.length() > max_name_length) max_name_length = average_row_name.length(); max_name_length += 1; // detailed category information cout << "== Category Performance ==" << endl; cout << setw(max_name_length) << ""; cout << setw(9) << right << "True +"; cout << setw(9) << right << "False +"; cout << setw(9) << right << "True -"; cout << setw(9) << right << "False -"; cout << setw(9) << right << "Precis."; cout << setw(9) << right << "Recall"; cout << setw(9) << right << "F-score" << endl; for(int category = 1; category <= data_set->categories_size(); category++) { cout << setw(max_name_length) << data_set->category_feature()->names[category]; cout << setw(9) << tp(category); cout << setw(9) << fp(category); cout << setw(9) << tn(category); cout << setw(9) << fn(category); cout << setw(8) << precision(category) * 100 << "%"; cout << setw(8) << recall(category) * 100 << "%"; cout << setw(8) << fscore(category) * 100 << "%" << endl; } cout << setw(max_name_length) << average_row_name; cout << setw(9) << avg_tp(); cout << setw(9) << avg_fp(); cout << setw(9) << avg_tn(); cout << setw(9) << avg_fn(); cout << setw(8) << avg_precision() * 100 << "%"; cout << setw(8) << avg_recall() * 100 << "%"; cout << setw(8) << avg_fscore() * 100 << "%" << endl; }
Foam::ensightFile::ensightFile ( const fileName& pathname, IOstream::streamFormat format ) : OFstream(pathname, format) { // ascii formatting specs setf ( ios_base::scientific, ios_base::floatfield ); precision(5); }