当前位置: 首页>>代码示例>>C++>>正文


C++ rf函数代码示例

本文整理汇总了C++中rf函数的典型用法代码示例。如果您正苦于以下问题:C++ rf函数的具体用法?C++ rf怎么用?C++ rf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: o

DgOutLocFile& 
DgOutGeoJSONFile::insert (DgPolygon& poly, const string* label,
   const DgLocation* cent)
{
   DgOutGeoJSONFile& o(*this);   

   rf().convert(poly);

   o << "{\"type\":\"Feature\",";
   o << "\"properties\":{";
   if (label)
      o << "\"name\":" << *label;
   o << "},";
   o << "\"geometry\":{";
   o << "\"type\":\"Polygon\",";
   o << "\"coordinates\":[[";

   vector<DgAddressBase *>& v = poly.addressVec();
   for(vector<DgAddressBase *>::iterator i = v.begin(); v.end() != i; ++i)
   {
         o.insert(rf().getVecAddress(*(*i)));
         o << ",";
   }

   // rewrite first vertex:
   o.insert(rf().getVecAddress(*v[0]));

   o << "]]}},";
   o.flush();

   return *this;
}
开发者ID:cran,项目名称:dggridR,代码行数:32,代码来源:DgOutGeoJSONFile.cpp

示例2: test1

static int
test1(gs_state * pgs, gs_memory_t * mem)
{
    int n;

    gs_scale(pgs, 72.0, 72.0);
    gs_translate(pgs, 4.25, 5.5);
    gs_scale(pgs, 4.0, 4.0);
    gs_newpath(pgs);
    for (n = 200; --n >= 0;) {
        int j;

#define rf() (rand() / (1.0 * 0x10000 * 0x8000))
        double r = rf(), g = rf(), b = rf();
        double x0 = rf(), y0 = rf(), x1 = rf(), y1 = rf(), x2 = rf(), y2 = rf();

        gs_setrgbcolor(pgs, r, g, b);
        for (j = 0; j < 6; j++) {
            gs_gsave(pgs);
            gs_rotate(pgs, 60.0 * j);
            gs_moveto(pgs, x0, y0);
            gs_lineto(pgs, x1, y1);
            gs_lineto(pgs, x2, y2);
            gs_fill(pgs);
            gs_grestore(pgs);
        }
    }
#undef mem
    return 0;
}
开发者ID:BorodaZizitopa,项目名称:ghostscript,代码行数:30,代码来源:gslib.c

示例3: rf

int daFakeStarCoin::onCreate() {

	allocator.link(-1, GameHeaps[0], 0, 0x20);

	nw4r::g3d::ResFile rf(getResource("star_coin", "g3d/star_coin.brres"));
	bodyModel.setup(rf.GetResMdl("star_coinA"), &allocator, 0x224, 1, 0);
	SetupTextures_MapObj(&bodyModel, 0);

	allocator.unlink();

	ActivePhysics::Info HitMeBaby;
	HitMeBaby.xDistToCenter = 0.0;
	HitMeBaby.yDistToCenter = -3.0;
	HitMeBaby.xDistToEdge = 12.0;
	HitMeBaby.yDistToEdge = 15.0;
	HitMeBaby.category1 = 0x5;
	HitMeBaby.category2 = 0x0;
	HitMeBaby.bitfield1 = 0x4F;
	HitMeBaby.bitfield2 = 0xFFFFFFFF;
	HitMeBaby.unkShort1C = 0;
	HitMeBaby.callback = &dEn_c::collisionCallback;

	this->aPhysics.initWithStruct(this, &HitMeBaby);
	this->aPhysics.addToList();

	this->scale.x = 1.0;
	this->scale.y = 1.0;
	this->scale.z = 1.0;

	this->pos.x -= 120.0;
	this->pos.z = 3300.0;

	this->onExecute();
	return true;
}
开发者ID:InfosHack,项目名称:NewerSMBW,代码行数:35,代码来源:fakeStarCoin.cpp

示例4: rf

// load biterm topic assignments output by training precess
// each line is a doc, format:w1-w2:topic_w1-topic_w2 ...
// set topic recorder _nwz and _nw_z
void Infer::load_model() {
  ostringstream ss;
  ss << "dbz.k" << K;
  string pt = train_dir + ss.str();
  
  cout << "->load dbz from:" << pt << endl;
  ifstream rf( pt.c_str() );
  if (!rf) {
	EXIT_ERR("file not find:", pt.c_str());
  }

  string line;
  while(getline(rf, line)) {
	// read a doc
    istringstream iss(line);
	
	int w1, w2, k1, k2;
	char c1, c2, c3;
    while (iss >> w1 >> c1 >> w2 >> c2 >> k1 >> c3 >> k2) {
		// allocacte _nwz
	  while (_nwz.size() < w2+1) {
		vector<int> tmp(K);
		_nwz.push_back(tmp);
	  }
	  assert(k1 < K && k2 < K);
	  _nwz[w1][k1]++;
	  _nw_z[k1]++;
	  _nwz[w2][k2]++;
	  _nw_z[k2]++;
	}
  }

  printf("M=%d\n", _nwz.size());
}
开发者ID:ylqfp,项目名称:tmrf,代码行数:37,代码来源:infer.cpp

示例5: p

void MessageOverlay::paintEvent(QPaintEvent *)
{
    QPainter p(this);
    QRect r(rect());
    QRectF rf(r.x()+0.5, r.y()+0.5, r.width()-1, r.height()-1);
    QColor borderCol=palette().color(QPalette::Highlight).darker(120);
    QColor col=palette().color(QPalette::Window);
    QPainterPath path=Utils::buildPath(rf, r.height()/4.0);
    col.setAlphaF(0.8);
    p.setRenderHint(QPainter::Antialiasing, true);
    p.fillPath(path, col);
    p.setPen(QPen(borderCol, qMax(2, r.height()/16)));
    p.drawPath(path);

    int pad=r.height()/4;
    if (cancelButton->isVisible()) {
        if (Qt::LeftToRight==layoutDirection() && !closeOnLeft) {
            rf.adjust(pad, pad, -((pad*2)+cancelButton->width()), -pad);
        } else {
            rf.adjust(((pad*2)+cancelButton->width()), pad, -pad, -pad);
        }
    } else {
        rf.adjust(pad, pad, -pad, -pad);
    }
    QFont fnt(QApplication::font());
    fnt.setBold(true);
    QFontMetrics fm(fnt);
    col=palette().color(QPalette::WindowText);

    p.setPen(col);
    p.setFont(fnt);
    p.drawText(rf, fm.elidedText(text, Qt::ElideRight, r.width(), QPalette::WindowText), QTextOption(Qt::LeftToRight==layoutDirection() ? Qt::AlignLeft : Qt::AlignRight));
    p.end();
}
开发者ID:BinChengfei,项目名称:cantata,代码行数:34,代码来源:messageoverlay.cpp

示例6: rf

char rf(const char* str, char current){
  if(*str=='\0')
    return current;
  if(*str=='@')
    current = *(str+1);
  return rf(str+1, current);
}
开发者ID:atommed,项目名称:OP_repo,代码行数:7,代码来源:main.c

示例7: linux

/*!
  \internal
  Read some random bytes into \a keybuf.

  If on linux (ie read embedded) the os MUST have /dev/[u]random
  available.
  */
void KeyFiler::randomizeKey( char keybuf[] )
{
    qint64 rc;
    QFile rf( RAND_DEV );
    if ( !rf.open( QIODevice::ReadOnly ))
    {
        time_t curTime = time(0);
        perror( "open " RAND_DEV );
#if defined(Q_OS_LINUX) || defined(_OS_LINUX_)
        qFatal( "Safe execution requires " RAND_DEV );
#endif
        qWarning( "Warning: Using inferior random numbers!" );
        srandom(curTime);  // this is very crappy
        long int r;
        for ( int i = 0; i < QSXE_KEY_LEN; i++ )
        {
            r = random();
            keybuf[i] = (char)r;
        }
    }
    else
    {
        rc = rf.read( keybuf, QSXE_KEY_LEN );
        rf.close();
        if ( rc != QSXE_KEY_LEN )
            qFatal( "read %s: %s", RAND_DEV, strerror(errno) );
    }
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:35,代码来源:keyfiler.cpp

示例8: r

void Label::OnDraw(Graphics *g) 
{
	if (_bmp == NULL)
		return;

	Rect r(_x, _y, _w, _h);
	g->DrawImage(_bmp, r, 0, 0, _w, _h, UnitPixel);	


	wstring wtext;	
	wtext.assign(_text.begin(), _text.end());

	SolidBrush b(_font_color);

	wstring wffname;
	wffname.assign(_font_family.begin(), _font_family.end());
	FontFamily ff(wffname.c_str());

	StringFormat sf(0, LANG_NEUTRAL);
	sf.SetLineAlignment(Gdiplus::StringAlignmentCenter);

	if (_align == TEXT_ALIGN_LEFT)
		sf.SetAlignment(Gdiplus::StringAlignmentNear);
	else if (_align == TEXT_ALIGN_CENTER)
		sf.SetAlignment(Gdiplus::StringAlignmentCenter);
	else if (_align == TEXT_ALIGN_RIGHT)
		sf.SetAlignment(Gdiplus::StringAlignmentFar);

	RectF rf(_x, _y, _w, _h);
	Font font(&ff, _font_size, Gdiplus::FontStyleRegular, UnitPixel);
	g->DrawString(wtext.c_str(), wtext.length(), &font, rf, &sf, &b);

}
开发者ID:beatwise,项目名称:wisegui-library,代码行数:33,代码来源:label.cpp

示例9: rf

int LogisticRegression::gradientAscent() {
	long double* deviations = new long double[sampleNum];
	int iterations = 0;
	do {
		++iterations;

		/*
		 * How to handle the case that 'z' is either too big or too small???
		 */
		// calculate deviations for all samples, one per sample.
		for(int i = 0; i < sampleNum; ++i)
			deviations[i] = categories[i] - rf(trainingSamples.getSample(i), 
				parameters, featureNum);

		// adjust parameters
		for(int j = 0; j < featureNum; ++j) {
			long double factor = 0.0;
			for(int i = 0; i < sampleNum; ++i) 
				factor +=  trainingSamples.getSample(i)[j] * deviations[i];
			parameters[j] += alpha * factor;
		}
	} while(convergent(deviations, categoryRange) == false);
	delete[] deviations;

	return iterations;
}
开发者ID:JackieXie168,项目名称:machine_learning,代码行数:26,代码来源:LogisticRegression.cpp

示例10: stylesheets_upgrade

void stylesheets_upgrade()
// Upgrade older stylesheets to the currently used format.
{
  // Make the \r marker a section heading instead of a normal paragraph.
  {
    ReadFiles rf(Directories->get_stylesheets(), "", ".xml1");
    for (unsigned int i = 0; i < rf.files.size(); i++) {
      ustring filename = gw_build_filename(Directories->get_stylesheets(), rf.files[i]);
      gw_message(_("Updating stylesheet: ") + filename);
      ReadText rt (filename, true, false);
      stylesheet_upgrade_value (rt.lines, "r", "subtype", "2");
      unix_unlink (filename.c_str());
      ustring newfilename(filename);
      newfilename.replace(newfilename.length() - 1, 1, "2");
      write_lines (newfilename, rt.lines);
    }
  }

  // Note: The stylesheet.xml template has been updated thus far.
  // Every update listed below still needs to be entered into the template.

  // At the end of everything, check that we have at least one stylesheet.  
  {
    vector < ustring > stylesheets;
    stylesheet_get_ones_available(stylesheets);
    if (stylesheets.size() == 0) {
      stylesheet_create_new(STANDARDSHEET, stFull);
    }
  }
}
开发者ID:postiffm,项目名称:bibledit-gtk,代码行数:30,代码来源:stylesheetutils.cpp

示例11: rf

int rf(int x)
{
	int temp = two(x) ;
	if ( temp == 1)
		return (x + 1);
	return rf( x + (1 << (temp - 1)));
}
开发者ID:suikay,项目名称:acm,代码行数:7,代码来源:4368731_TLE.cpp

示例12: rf

void MaxCutHyperheuristic::UpdateBestModel(std::string code, Prob problem,
                                           const std::vector<double>& metrics,
                                           double* bestProbability,
                                           Prob* bestProblem,
                                           std::string* bestCode,
                                           int* numBest) {
  std::ostringstream fname;
  fname << "hhdata/" << code << ".rf";
  std::string filename = fname.str();
  if (FileExists(filename)) {
    RandomForest rf(filename);
    double probability = rf.Predict(metrics);
    if (probability > *bestProbability) {
      // New best
      *bestProbability = probability;
      *bestProblem = problem;
      *bestCode = code;
      *numBest = 1;
    } else if (probability == *bestProbability &&
               Random::RandInt(0, *numBest) == *numBest) {
      // Tied the best and selected by streaming algorithm
      *bestProblem = problem;
      *bestCode = code;
      ++(*numBest);
    }
  }
}
开发者ID:MQLib,项目名称:MQLib,代码行数:27,代码来源:hyperheuristic.cpp

示例13: Mine_LoadLibraryExW

/// Mine entry point for intercepted function
/// \param lpLibFileName Library file name
/// \param hFile File handle
/// \param dwFlags load flags
/// \return Loaded module.
static HMODULE WINAPI Mine_LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
{
    RefTracker rf(&s_dwInsideLoadLibrary);

    if (s_dwInsideLoadLibrary == 1)
    {
        LogTrace(traceENTER, "lpLibFilename = %S, hFile = %p, dwFlags = %d", lpLibFileName, hFile, dwFlags);
    }

    HMODULE res = Real_LoadLibraryExW(lpLibFileName, hFile, dwFlags);
    DWORD realError = GetLastError();

    if (my_lstrcmpW(lpLibFileName, L"comctl32.dll") != 0)
    {
        // This function uses MessageBox - which will load comctl32.dll if necessary
        // To avoid recursion problems, only call it when a different DLL is being loaded.
        CheckForDebuggerAttach();
    }

    if (s_dwInsideLoadLibrary == 1)
    {
        CheckWrappers();
        LogTrace(traceEXIT, "returned 0x%p", res);
    }

    SetLastError(realError);
    return res;
}
开发者ID:StephenThomasUWTSD,项目名称:CodeXL,代码行数:33,代码来源:LoadLibrary.cpp

示例14: main

int main(int argc, char* argv[])
{

  DCapp app(dn, ".dita", ".ditamap");

  app.Init(argc, argv);

  if (!app.Proc(D2M::SwitchList)) {
    fprintf(stderr, "usage: %s [-v] [-t \"Map Title\"] [-d \"D:\\path\\to\\DTDs\"]"
			"\n        [-i inifile.ini] [-o mapfile.ditamap] topicfile.dita\n", argv[0]);
    exit(dc_err_arg);
  }

  D2M::Verbose = app.verbose();

  XMLrfile rf(D2M::TopicFileName = app.rfile());
  if (rf.FErr() != fok)
    rf.Err();
	else
		D2M::TopicFile = &rf;

  HTMwfile wf(D2M::MapFileName = app.wfile());
  if (wf.FErr() != fok)
    wf.Err();
	else
		D2M::MapFile = &wf;

	// look in current directory for correct ini file
	DCirfile *inif = new DCirfile(D2M::IniFileName);

	if (inif->FErr() != fok) {
		delete inif;
		inif = new DCirfile("xml2htm.ini");
	}

	if (inif->FErr() != fok) {
		delete inif;
		inif = new DCirfile("xml2rtf.ini");
	}

	if ((inif->FErr() != fok)
	 && strcmp(D2M::IniFileName, "dita2map.ini")) {
		delete inif;
		inif = new DCirfile("dita2map.ini");
	}

	if (inif->FErr() == fok)
		D2M::IniFile = inif;  // make accessible everywhere

	D2M::InitCurrProps(); // set up vars per ini file


	D2M::ProcessTopic();

  rf.CloseFile();
  wf.CloseFile();
  wf.Err();      // if error, exits with the err (and a message)
  return dc_ok;  // so if we get here, it worked
}
开发者ID:omsys-dev,项目名称:original-source,代码行数:59,代码来源:DITA2map.cpp

示例15: ellf

float ellf(float phi, float ak)
{
	float rf(float x, float y, float z);
	float s;

	s=sin(phi);
	return s*rf(SQR(cos(phi)),(1.0-s*ak)*(1.0+s*ak),1.0);
}
开发者ID:bamford,项目名称:astrobamf,代码行数:8,代码来源:ellf.c


注:本文中的rf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。