示例#1
0
文件: friend2.cpp 项目: bmanga/clang
int main() { f(1234); }
示例#2
0
/*
 * Basic test: two 4-bit input
 */
static void base_test4var(void (*f)(uint32_t, literal_t *, literal_t *)) {
  literal_t a[4];
  literal_t b[4];
  uint32_t i;

  for (i=0; i<4; i++) {
    a[i] = false_literal;
    b[i] = fresh_lit();
  }
  f(4, a, b);

  for (i=0; i<4; i++) {
    a[i] = fresh_lit();
    b[i] = false_literal;
  }
  f(4, a, b);

  for (i=0; i<4; i++) {
    a[i] = true_literal;
    b[i] = fresh_lit();
  }
  f(4, a, b);

  for (i=0; i<4; i++) {
    a[i] = fresh_lit();
    b[i] = true_literal;
  }
  f(4, a, b);

  for (i=0; i<4; i++) {
    a[i] = fresh_lit();
    b[i] = a[i];
  }
  f(4, a, b);

  for (i=0; i<4; i++) {
    a[i] = false_literal;
    b[i] = fresh_lit();
  }
  a[0] = true_literal;
  f(4, a, b);

  for (i=0; i<4; i++) {
    a[i] = fresh_lit();
    b[i] = false_literal;
  }
  b[0] = true_literal;
  f(4, a, b);

  for (i=0; i<4; i++) {
    a[i] = false_literal;
    b[i] = fresh_lit();
  }
  a[1] = true_literal;
  f(4, a, b);

  for (i=0; i<4; i++) {
    a[i] = fresh_lit();
    b[i] = false_literal;
  }
  b[1] = true_literal;
  f(4, a, b);

  for (i=0; i<4; i++) {
    a[i] = false_literal;
    b[i] = fresh_lit();
  }
  a[2] = true_literal;
  f(4, a, b);

  for (i=0; i<4; i++) {
    a[i] = fresh_lit();
    b[i] = false_literal;
  }
  b[2] = true_literal;
  f(4, a, b);

  for (i=0; i<4; i++) {
    a[i] = false_literal;
    b[i] = fresh_lit();
  }
  a[3] = true_literal;
  f(4, a, b);

  for (i=0; i<4; i++) {
    a[i] = fresh_lit();
    b[i] = false_literal;
  }
  b[3] = true_literal;
  f(4, a, b);
}
示例#3
0
void loop(auto begin, auto end, auto f)
{
  for(auto i = begin ; i != end ; ++i) f(i);
}
示例#4
0
bool MainWindow::autoMount()
{
	QFile f( QDir::homePath() + QString( zuluMOUNT_AUTOPATH ) ) ;
	return f.exists() ;
}
void Base::g()
{
  f();
}
void HelpPlugin::LaunchHelp(const wxString &c_helpfile, bool isExecutable, bool openEmbeddedViewer, HelpCommon::StringCase keyCase, const wxString &defkeyword, const wxString &c_keyword)
{
  const static wxString http_prefix(_T("http://"));
  const static wxString man_prefix(_T("man:"));
  wxString helpfile(c_helpfile);

  // Patch by Yorgos Pagles: Use the new attributes to calculate the keyword
  wxString keyword = c_keyword.IsEmpty() ? defkeyword : c_keyword;

  if (keyCase == HelpCommon::UpperCase)
    keyword.MakeUpper();
  else if (keyCase == HelpCommon::LowerCase)
    keyword.MakeLower();

  helpfile.Replace(_T("$(keyword)"), keyword);
  Manager::Get()->GetMacrosManager()->ReplaceMacros(helpfile);

  if (isExecutable)
  {
    Manager::Get()->GetLogManager()->DebugLog(_T("Executing ") + helpfile);
    wxExecute(helpfile);
    return;
  }

  // Support C::B scripts
  if (wxFileName(helpfile).GetExt() == _T("script"))
  {
      if (Manager::Get()->GetScriptingManager()->LoadScript(helpfile))
      {
        // help scripts must contain a function with the following signature:
        // function SearchHelp(keyword)
        try
        {
            SqPlus::SquirrelFunction<void> f("SearchHelp");
            f(keyword);
        }
        catch (SquirrelError& e)
        {
            Manager::Get()->GetScriptingManager()->DisplayErrors(&e);
        }
      }
      else
        Manager::Get()->GetLogManager()->DebugLog(_T("Couldn't run script"));

      return;
  }

  // Operate on help html file links inside embedded viewer
  if (openEmbeddedViewer && wxFileName(helpfile).GetExt().Mid(0, 3).CmpNoCase(_T("htm")) == 0)
  {
    Manager::Get()->GetLogManager()->DebugLog(_T("Launching ") + helpfile);
    cbMimePlugin* p = Manager::Get()->GetPluginManager()->GetMIMEHandlerForFile(helpfile);
    if (p)
      p->OpenFile(helpfile);
    else
    {
      reinterpret_cast<MANFrame *>(m_manFrame)->LoadPage(helpfile);
      ShowMANViewer();
    }
    return;
  }

  // Operate on help http (web) links
  if (helpfile.Mid(0, http_prefix.size()).CmpNoCase(http_prefix) == 0)
  {
    Manager::Get()->GetLogManager()->DebugLog(_T("Launching ") + helpfile);
    wxLaunchDefaultBrowser(helpfile);
    return;
  }

  // Operate on man pages
  if (helpfile.Mid(0, man_prefix.size()).CmpNoCase(man_prefix) == 0)
  {
    if (reinterpret_cast<MANFrame *>(m_manFrame)->SearchManPage(keyword))
      Manager::Get()->GetLogManager()->DebugLog(_T("Couldn't find man page"));
    else
      Manager::Get()->GetLogManager()->DebugLog(_T("Launching man page"));

    ShowMANViewer();
    return;
  }

#ifdef __WXMSW__
  if (helpfile.StartsWith(_T("ms-xhelp:///")))
  {
    Manager::Get()->GetLogManager()->DebugLog(_T("Launching ") + helpfile);
    ShellExecute(0, 0, helpfile.c_str(), 0, 0, SW_SHOWDEFAULT);
    return;
  }
#endif // __WXMSW__

  wxFileName the_helpfile = wxFileName(helpfile);
  Manager::Get()->GetLogManager()->DebugLog(_T("Help File is ") + helpfile);

  if (!(the_helpfile.FileExists()))
  {
    wxString msg;
    msg << _("Couldn't find the help file:\n")
        << the_helpfile.GetFullPath() << _("\n")
        << _("Do you want to run the associated program anyway?");
    if (!(cbMessageBox(msg, _("Warning"), wxICON_WARNING | wxYES_NO | wxNO_DEFAULT) == wxID_YES))
        return;
  }

  wxString ext = the_helpfile.GetExt();

#ifdef __WXMSW__
  // Operate on help files with keyword search (windows only)
  if (!keyword.IsEmpty())
  {
    if (ext.CmpNoCase(_T("hlp")) == 0)
    {
      wxWinHelpController HelpCtl;
      HelpCtl.Initialize(helpfile);
      HelpCtl.KeywordSearch(keyword);
      return;
    }

    if ((ext.CmpNoCase(_T("chm")) == 0) || (ext.CmpNoCase(_T("col")) == 0))
    {
      LaunchCHMThread *p_thread = new LaunchCHMThread(helpfile, keyword);
      p_thread->Create();
      p_thread->Run();
      return;
    }
  }
#endif

  // Just call it with the associated program
  wxFileType *filetype = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);

  if (!filetype)
  {
    cbMessageBox(_("Couldn't find an associated program to open:\n") +
      the_helpfile.GetFullPath(), _("Warning"), wxOK | wxICON_EXCLAMATION);
    return;
  }

  wxExecute(filetype->GetOpenCommand(helpfile));
  delete filetype;
}
示例#7
0
文件: all.hpp 项目: ACEZLY/GreenLeaf
 BOOST_FUSION_GPU_ENABLED
 static bool call(It const& it, F f)
 {
     return f(*it);
 }
示例#8
0
X void* ho(int(*f)(int), int x) {
    g2 = f(x);
    return ho_return;
}
示例#9
0
/* int hoho(int x, int_to_int2int f) { */
X int hoho(int x, int(*(*f)(int))(int)) {
    return (f(x+1))(x-1);
}
示例#10
0
X float  callback3_float_float_float(float(*f)(float)) {
    return f(3.0);
}
示例#11
0
X double  callback3_double_double_double(double(*f)(double)) {
    return f(3.0);
}
示例#12
0
int main(int argc, char** argv)
{
	bool error = false;

	if(argc != 4)
	{
		std::cerr << "USAGE: " << argv[0] << " PARTICLE_FILE NX1 NY1" << std::endl;
		exit(0);
	}

   boost::filesystem::path path(argv[1]);
	if(!boost::filesystem::exists(path))
	{
		std::cerr << "ERROR: " << argv[1] << " does not exist!" << std::endl;
		exit(1);
	}
	std::ifstream f(path.string().c_str(), std::ios::binary);
	const float NX1 = static_cast<float>(atoi(argv[2]));
	const float NY1 = static_cast<float>(atoi(argv[3]));
	std::cout << "NX1 = " << NX1 << std::endl;
	std::cout << "NY1 = " << NY1 << std::endl;

	int numParticles;
	int numHot;
	int numCold;
	f.read(reinterpret_cast<char*>(&numParticles), sizeof(numParticles));
	f.read(reinterpret_cast<char*>(&numHot), sizeof(numHot));
	f.read(reinterpret_cast<char*>(&numCold), sizeof(numCold));

	if(numParticles != numHot + numCold)
	{
		error = true;
		std::cout << "ERROR: " << argv[0] << std::endl;
		std::cout << "  numParticles != numHot + numCold" << std::endl;
		std::cout << "  " << numParticles << " != " << numHot << " + " << numCold << std::endl;
	}

   const double percentSize = static_cast<double>(numParticles) / 100.0;
	int lastPercent = 0;
   std::size_t numOobPartX = 0;
   std::size_t numOobPartY = 0;
	const std::size_t sampleSize = 5;
	typedef std::vector<std::pair<float, float> > PartVector_t;
	PartVector_t sampleOobX;
	PartVector_t sampleOobY;

	for(std::size_t i = 0; i < numParticles; i++)
	{
		float x;
		float y;
		f.read(reinterpret_cast<char*>(&x), sizeof(x));
		f.read(reinterpret_cast<char*>(&y), sizeof(y));
		// Skip the velocity
		f.seekg(sizeof(float)*3, std::ios_base::cur);
		if(NX1 <= x)
		{
			error = true;
			++numOobPartX;
			if(sampleOobX.size() < sampleSize)
			{
				sampleOobX.push_back(std::make_pair(x, y));
			}
		}
		if(NY1 <= y)
		{
			error = true;
			++numOobPartY;
			if(sampleOobY.size() < sampleSize)
			{
				sampleOobY.push_back(std::make_pair(x, y));
			}
		}

		if(lastPercent < static_cast<int>(i / percentSize))
		{
			++lastPercent;
			std::cout << lastPercent << "% complete" << std::endl;
		}
	}

	if(!sampleOobX.empty())
	{
		std::cout << numOobPartX << " particles of " << numParticles << " had X values >= " << NX1 << ". A sample has been printed below." << std::endl;
		for(PartVector_t::iterator i = sampleOobX.begin(); i != sampleOobX.end(); i++)
		{
			std::cout << "x=" << (*i).first << " y=" << (*i).second << std::endl;
		}
		std::cout << std::endl;
	}
	if(!sampleOobY.empty())
	{
		std::cout << numOobPartY << " particles of " << numParticles << " had Y values >= " << NY1 << ". A sample has been printed below." << std::endl;
		for(PartVector_t::iterator i = sampleOobY.begin(); i != sampleOobY.end(); i++)
		{
			std::cout << "x=" << (*i).first << " y=" << (*i).second << std::endl;
		}
	}

	if(!error)
	{
		std::cout << argv[0] << " has been successfully verified!" << std::endl;
	}

	return 0;
}
示例#13
0
void FileWatcher::saveFile(QString file) {
    Note newNote;
    NoteTable ntable(global.db);

    QFile f(file);
    f.open(QIODevice::ReadOnly);
    QByteArray data = f.readAll();
    f.close();
    if (f.size() == 0)
        return;

    QLOG_DEBUG() << data;
    ConfigStore cs(global.db);
    qint32 lid = cs.incrementLidCounter();

    QCryptographicHash md5hash(QCryptographicHash::Md5);
    QByteArray hash = md5hash.hash(data, QCryptographicHash::Md5);

    // * Start setting up the new note
    newNote.guid = QString::number(lid);
    newNote.title = file;

    NotebookTable bookTable(global.db);
    QString notebook;
    bookTable.getGuid(notebook, notebookLid);
    newNote.notebookGuid = notebook;

    QString newNoteBody = QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")+
           QString("<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">")+
           QString("<en-note style=\"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\">");

    MimeReference mimeRef;
    QString mime = mimeRef.getMimeFromFileName(file);
    QString enMedia =QString("<en-media hash=\"") +hash.toHex() +QString("\" border=\"0\"")
            +QString(" type=\"" +mime +"\" ")
            +QString("/>");
    newNoteBody.append(enMedia + QString("</en-note>"));
    newNote.content = newNoteBody;
    newNote.active = true;
    newNote.created = QDateTime::currentMSecsSinceEpoch();;
    newNote.updated = newNote.created;
    newNote.updateSequenceNum = 0;
    NoteAttributes na;
    na.sourceURL = "file://" + file;
    newNote.attributes = na;

    qint32 noteLid = lid;
    ntable.add(lid, newNote, true);
    QString noteGuid = ntable.getGuid(lid);
    lid = cs.incrementLidCounter();


    // Start creating the new resource
    Resource newRes;
    Data d;
    d.body = data;
    d.bodyHash = hash;
    d.size = data.size();
    newRes.data = d;
    newRes.mime = mime;
    ResourceAttributes ra;
    ra.fileName = file;
    if (mime.startsWith("image", Qt::CaseInsensitive) || mime.endsWith("pdf", Qt::CaseInsensitive))
        ra.attachment = false;
    else
        ra.attachment = true;
    newRes.active = true;
    newRes.guid = QString::number(lid);
    newRes.noteGuid = noteGuid;
    newRes.updateSequenceNum = 0;
    ResourceTable restable(global.db);
    restable.add(lid, newRes, true, noteLid);

    emit(fileImported(noteLid, lid));

    if (scanType == FileWatcher::ImportDelete) {
        QLOG_DEBUG() << f.remove();
    }
}
示例#14
0
文件: exptrees.c 项目: dgu123/dc-lib
  else if (op == TIMES) res = a * b; 
  else                  res = a + b; 
  return res;
}

T op_h(node_t* p, T v_l, T v_r) {

  node_t* left = lvalue(&p->left, node_t*);
  node_t* right = lvalue(&p->right, node_t*);

  T r_l = lvalue(&left->num, T);
  T r_r = lvalue(&right->num, T);

  int op = lvalue(&p->op,int);

  T res = f(v_l, v_r, op);

  lvalue(&p->num, T) = f(r_l, r_r, op);

  printf ("[%p] left: c=%ld (s=%ld [%p]), right: c=%ld (s=%ld [%p]) -- Op %d: c=%ld (s=%ld) %s\n", 
    p, v_l, r_l, left, v_r, r_r, right, op, res, lvalue(&p->num, T), res != lvalue(&p->num, T) ? "- ERROR" : "");

  return res;
}

// leaf constructor
node_t* exptrees_leaf (T val) {
  node_t* p = alloc(sizeof(node_t));
  if (p==NULL) exit(printf("rm_malloc error\n"));
  lvalue(&p->num, T) = val;
  lvalue(&p->left, node_t*) = lvalue(&p->right, node_t*) = NULL;
示例#15
0
X byte  callback3_byte_byte_byte  (byte(*f)(byte)) {
    return f(3);
}
示例#16
0
X int   callback3_int_int_int     (int(*f)(int))   {
    if (f) return f(3);
    else return 79;
}
示例#17
0
X short  callback3_short_short_short(short(*f)(short)) {
    return f(3);
}
示例#18
0
X int   callback3_short_int_int   (int(*f)(short)) {
    return f(3);
}
示例#19
0
void aether::task::retrieve_forecast::forecast_received(
        styx::element e
        )
{
    styx::object f(e);
    for(styx::object point : f.get_list("list"))
    {
        forecast f_db;
        f_db.get_int<attr::forecast_dt>() = point.copy_int("dt");
        f_db.save(connection());

        if(point.has_key("main"))
        {
            const styx::object& main = point.get_object("main");
            forecast_main f_main;
            f_main.get_int<attr::forecast_dt>() = point.copy_int("dt");
            f_main.get_double<attr::forecast_main_temp>() = main.copy_double("temp");
            f_main.get_double<attr::forecast_main_temp_min>() = main.copy_double("temp_min");
            f_main.get_double<attr::forecast_main_temp_max>() = main.copy_double("temp_max");
            f_main.get_int<attr::forecast_main_humidity>() = main.copy_int("humidity");
            f_main.get_double<attr::forecast_main_pressure>() = main.copy_double("pressure");
            f_main.get_double<attr::forecast_main_sea_level>() = main.copy_double("sea_level");
            f_main.get_double<attr::forecast_main_grnd_level>() = main.copy_double("grnd_level");
            f_main.save(connection());
        }
        if(point.has_key("clouds"))
        {
            const styx::object& clouds = point.get_object("clouds");
            forecast_clouds f_clouds;
            f_clouds.get_int<attr::forecast_dt>() = point.copy_int("dt");
            f_clouds.get_int<attr::forecast_clouds_all>() = clouds.copy_int("all");
            f_clouds.save(connection());
        }
        if(point.has_key("rain"))
        {
            const styx::object& rain = point.get_object("rain");
            forecast_rain f_rain;
            f_rain.get_int<attr::forecast_dt>() = point.copy_int("dt");
            f_rain.get_int<attr::forecast_rain>() = rain.copy_int("3h");
            f_rain.save(connection());
        }
        if(point.has_key("weather"))
        {
            const styx::object weather = styx::cast<styx::object>(point.get_list("weather").at(0));
            forecast_weather f_weather;
            f_weather.get_int<attr::forecast_dt>() = point.copy_int("dt");
            f_weather.get_string<attr::forecast_weather_main>() = weather.copy_string("main");
            f_weather.get_string<attr::forecast_weather_description>() = weather.copy_string("description");
            f_weather.save(connection());
        }
        if(point.has_key("wind"))
        {
            const styx::object& wind = point.get_object("wind");
            forecast_wind f_wind;
            f_wind.get_int<attr::forecast_dt>() = point.copy_int("dt");
            f_wind.get_double<attr::forecast_wind_speed>() = wind.copy_double("speed");
            f_wind.get_double<attr::forecast_wind_deg>() = wind.copy_double("deg");
            f_wind.get_double<attr::forecast_wind_gust>() = wind.copy_double("gust");
            f_wind.save(connection());
        }
    }
    atlas::log::information("aether::task::retrieve_forecast") <<
        "saved forecast";
    mark_finished();
}
示例#20
0
X int   callback3_int_byte_int    (byte(*f)(int))  {
    return f(3);
}
示例#21
0
void geom_gentle_yellow(Bool_t register_as_global=kTRUE)
{
  TEveGeoShape* gsre1;
  TEveGeoShape* gsre2;
  TEveGeoShape* gsre3;
  
{
  TFile f("$ALICE_ROOT/EVE/resources/geometry/gentle_geo.root");
  TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) f.Get("Gentle");
  gsre1 = TEveGeoShape::ImportShapeExtract(gse);
  f.Close();

  if (register_as_global)
  {
    gEve->AddGlobalElement(gsre1);
  }

  // Fix visibility, color and transparency

  gsre1->SetRnrSelf(kFALSE);
  TEveElement::List_i i = gsre1->BeginChildren();

//ITS
  {
    TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
    lvl1->SetRnrSelf(kFALSE);
    TEveElement::List_i j = lvl1->BeginChildren();

    TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
    lvl2->SetRnrSelf(kFALSE);
    TEveElement::List_i k = lvl2->BeginChildren();

    TEveGeoShape* its1 = (TEveGeoShape*) *k;
    its1->SetRnrSelf(kTRUE);
    its1->SetMainColor(kYellow-4);
    its1->SetMainTransparency(50);
    k++;

    TEveGeoShape* its2 = (TEveGeoShape*) *k;
    its2->SetRnrSelf(kTRUE);
    its2->SetMainColor(kYellow-7);
    its2->SetMainTransparency(50);
    k++;

    TEveGeoShape* its3 = (TEveGeoShape*) *k;
    its3->SetRnrSelf(kTRUE);
    its3->SetMainColor(kYellow-9);
    its3->SetMainTransparency(50);
  }
//TPC

  i++;
  {
    TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
    lvl1->SetRnrSelf(kFALSE);
    TEveElement::List_i j = lvl1->BeginChildren();

    TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
    lvl2->SetRnrSelf(kFALSE);
    TEveElement::List_i k = lvl2->BeginChildren();

    TEveGeoShape* lvl3 = (TEveGeoShape*) *k;
    lvl3->SetRnrSelf(kTRUE);
    lvl3->SetMainColor(kGray);
    lvl3->SetMainTransparency(80);
    TEveElement::List_i l = lvl3->BeginChildren();

    TEveGeoShape* lvl4 = (TEveGeoShape*) *l;
    lvl4->SetRnrSelf(kFALSE);
    TEveElement::List_i m = lvl4->BeginChildren();

    TEveGeoShape* tpc1 = (TEveGeoShape*) *m;
    tpc1->SetRnrSelf(kTRUE);
    tpc1->SetMainColor(kGray+2);
    tpc1->SetMainTransparency(80);
    m++;

    TEveGeoShape* tpc2 = (TEveGeoShape*) *m;
    tpc2->SetMainColor(kGray);
    tpc2->SetMainColor(kGray+2);
    tpc2->SetMainTransparency(80);
    m++;

    TEveGeoShape* tpc3 = (TEveGeoShape*) *m;
    tpc3->SetRnrSelf(kTRUE);
    tpc3->SetMainColor(kGray+2);
    tpc3->SetMainTransparency(80);
    m++;
  }
//TRD+TOF

  i++;
  {
    TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
    lvl1->SetRnrSelf(kFALSE);

    for (TEveElement::List_i j = lvl1->BeginChildren(); j != lvl1->EndChildren(); ++j)
      {
        TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
        lvl2->SetRnrSelf(kFALSE);
        lvl2->SetMainColor(0);
        lvl2->SetMainTransparency(80);

      }
  }
//PHOS

  i++;
  {
    TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
    lvl1->SetRnrSelf(kFALSE);

    for (TEveElement::List_i j = lvl1->BeginChildren(); j != lvl1->EndChildren(); ++j)
      {
        TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
        lvl2->SetRnrSelf(kTRUE);
        lvl2->SetMainTransparency(30);
      }
  }
//HMPID

  i++;
  {
    TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
    lvl1->SetRnrSelf(kFALSE);

    for (TEveElement::List_i j = lvl1->BeginChildren(); j != lvl1->EndChildren(); ++j)
      {
        TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
        lvl2->SetRnrSelf(kTRUE);
        lvl2->SetMainTransparency(30);
      }
  }
}
  // The resulting geometry is NOT added into the global scene!
{
  TFile f("$ALICE_ROOT/EVE/resources/geometry/gentle_rphi_geo.root");
  TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) f.Get("Gentle");
  gsre2 = TEveGeoShape::ImportShapeExtract(gse);
  f.Close();

  // Fix visibility, color and transparency

  gsre2->SetRnrSelf(kFALSE);
  TEveElement::List_i i = gsre2->BeginChildren();

//ITS
  {
    TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
    lvl1->SetRnrSelf(kFALSE);
    TEveElement::List_i j = lvl1->BeginChildren();

    TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
    lvl2->SetRnrSelf(kFALSE);
    TEveElement::List_i k = lvl2->BeginChildren();

    TEveGeoShape* its1 = (TEveGeoShape*) *k;
    its1->SetRnrSelf(kTRUE);
    its1->SetMainColor(kYellow-4);
    its1->SetMainTransparency(50);

    k++;

    TEveGeoShape* its2 = (TEveGeoShape*) *k;
    its2->SetRnrSelf(kTRUE);
    its2->SetMainColor(kYellow-7);
    its2->SetMainTransparency(50);
    k++;

    TEveGeoShape* its3 = (TEveGeoShape*) *k;
    its3->SetRnrSelf(kTRUE);
    its3->SetMainColor(kYellow-9);
    its3->SetMainTransparency(50);
  }
//TPC

  i++;
  {
    TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
    lvl1->SetRnrSelf(kFALSE);

    for (TEveElement::List_i j = lvl1->BeginChildren(); j != lvl1->EndChildren(); j++)
      {
        TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
        lvl2->SetRnrSelf(kTRUE);
        lvl2->SetMainColor(kGray);
        lvl2->SetMainTransparency(80);
      }
  }
//PHOS

  i++;
  i++;
  
  {
    TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
    lvl1->SetRnrSelf(kFALSE);

    for (TEveElement::List_i j = lvl1->BeginChildren(); j != lvl1->EndChildren(); j++)
      {
        TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
        lvl2->SetRnrSelf(kTRUE);
        lvl2->SetMainTransparency(30);

      }
  }
//HMPID

  i++;
  {
    TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
    lvl1->SetRnrSelf(kFALSE);

    for (TEveElement::List_i j = lvl1->BeginChildren(); j != lvl1->EndChildren(); j++)
      {
        TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
        lvl2->SetRnrSelf(kTRUE);
        lvl2->SetMainTransparency(30);
      }
  }
}

  // The resulting geometry is NOT added into the global scene!
{
  TFile f("$ALICE_ROOT/EVE/resources/geometry/gentle_rhoz_geo.root");
  TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) f.Get("Gentle");
  gsre3 = TEveGeoShape::ImportShapeExtract(gse);
  f.Close();

  // Fix visibility, color and transparency

  gsre3->SetRnrSelf(kFALSE);
  TEveElement::List_i i = gsre3->BeginChildren();

//ITS
  {
    TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
    lvl1->SetRnrSelf(kFALSE);
    TEveElement::List_i j = lvl1->BeginChildren();

    TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
    lvl2->SetRnrSelf(kFALSE);
    TEveElement::List_i k = lvl2->BeginChildren();

    TEveGeoShape* its1 = (TEveGeoShape*) *k;
    its1->SetRnrSelf(kTRUE);
    its1->SetMainColor(kYellow-4);
    k++;

    TEveGeoShape* its2 = (TEveGeoShape*) *k;
    its2->SetRnrSelf(kTRUE);
    its2->SetMainColor(kYellow-7);
    k++;

    TEveGeoShape* its3 = (TEveGeoShape*) *k;
    its3->SetRnrSelf(kTRUE);
    its3->SetMainColor(kYellow-9);
  }
//TPC

  i++;
  {
    TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
    lvl1->SetRnrSelf(kFALSE);

    for (TEveElement::List_i j = lvl1->BeginChildren(); j != lvl1->EndChildren(); j++)
      {
        TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
        lvl2->SetRnrSelf(kTRUE);
        lvl2->SetMainColor(kGray);
        lvl2->SetMainTransparency(80);

      }
  }
//PHOS

  i++;
  i++;
  
  {
    TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
    lvl1->SetRnrSelf(kFALSE);

    for (TEveElement::List_i j = lvl1->BeginChildren(); j != lvl1->EndChildren(); j++)
      {
        TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
        lvl2->SetRnrSelf(kTRUE);
        lvl2->SetMainTransparency(30);
      }
  }
//HMPID

  i++;
  {
  TEveGeoShape* lvl1 = (TEveGeoShape*) *i;
  lvl1->SetRnrSelf(kFALSE);

  for (TEveElement::List_i j = lvl1->BeginChildren(); j != lvl1->EndChildren(); j++)
    {
      TEveGeoShape* lvl2 = (TEveGeoShape*) *j;
      lvl2->SetRnrSelf(kTRUE);
      lvl2->SetMainTransparency(30);
    }
  }
  
}
  TEveElement* top = gEve->GetCurrentEvent();

  AliEveMultiView *mv = AliEveMultiView::Instance();

  mv->InitGeomGentle(gsre1, gsre2, gsre3, 0);

  gEve->FullRedraw3D(kTRUE, kTRUE);

}
示例#22
0
X int   callback3_byte_byte_int   (byte(*f)(byte)) {
    return f(3);
}
示例#23
0
int main() {
  f();
  return 0;
}
示例#24
0
X byte  callback3_byte_int_byte   (int(*f)(byte))  {
    return f(3);
}
`给 n 个数,求着 n 个数划分成互不相交的 m 段的最大m 子段和。`
`经典的动态规划优化问题。`
`设 f(i,j)表示前 i 个数划分成 j 段,且包括第 i 个数的最大 j 段和,那么 dp 方程为:`
`f(i,j)=max(f(i-1,j),max {f(k,j-1)})+v[i];``分析:第 i 个数要么和前一个数一起划分到第 j 段里,要么独自划分到第 j 段,也就是我们要找到 i 之前的数划分为 j-1 段的最优值,这个可以只需一个变量标记最大值岂可。`
`转移复杂度:O(1),总复杂度 O(n*m)`
int g[N];
int max_m_sum(int* str,int n,int m) {
    memset(g,0,sizeof(g));
    int i,j,_max,tmp;
    for(i=1; i<=m; i++) {
        _max = g[i-1];
        for(j=i; j<=n; j++) {
            tmp = _max;
            _max = max(_max,g[j]);
            g[j] = max(g[j-1],tmp) + str[j];
        }
    }
    _max = g[m];
    for(i=m; i<=n; i++) {
        _max = max(_max,g[i]);
    }
    return _max;
}
示例#26
0
X byte  callback3_int_byte_byte   (byte(*f)(int))  {
    return f(3);
}
示例#27
0
bool UBFileSystemUtils::deleteFile(const QString &path)
{
    QFile f(path);
    f.setPermissions(path, QFile::ReadOwner | QFile::WriteOwner);
    return f.remove();
}
示例#28
0
X short callback3_int_short_short (short(*f)(int))  {
    return f(3);
}
示例#29
0
void Matrix::save(const QString &fn, const QString &info, bool saveAsTemplate)
{
	QFile f(fn);
	if (!f.isOpen()){
		if (!f.open(QIODevice::Append))
			return;
	}
	bool notTemplate = !saveAsTemplate;

	QTextStream t( &f );
	t.setEncoding(QTextStream::UnicodeUTF8);
	t << "<matrix>\n";
	if (notTemplate)
        t << QString(objectName()) + "\t";
	t << QString::number(numRows())+"\t";
	t << QString::number(numCols())+"\t";
	if (notTemplate)
        t << birthDate() + "\n";
	t << info;
	t << "ColWidth\t" + QString::number(d_column_width)+"\n";
	t << "<formula>\n" + formula_str + "\n</formula>\n";
	t << "TextFormat\t" + QString(txt_format) + "\t" + QString::number(num_precision) + "\n";
	if (notTemplate)
        t << "WindowLabel\t" + windowLabel() + "\t" + QString::number(captionPolicy()) + "\n";
	t << "Coordinates\t" + QString::number(x_start,'g',15) + "\t" +QString::number(x_end,'g',15) + "\t";
	t << QString::number(y_start,'g',15) + "\t" + QString::number(y_end,'g',15) + "\n";
	t << "ViewType\t" + QString::number((int)d_view_type) + "\n";
    t << "HeaderViewType\t" + QString::number((int)d_header_view_type) + "\n";

	if (d_color_map_type != Custom)
		t << "ColorPolicy\t" + QString::number(d_color_map_type) + "\n";
	else
		t << ColorMapEditor::saveToXmlString(d_color_map);

    if (notTemplate){//save data
		t << "<data>\n";
		double* d_data = d_matrix_model->dataVector();
		int d_rows = numRows();
		int d_cols = numCols();
		int cols = d_cols - 1;

		for(int i = 0; i < d_rows; i++){
			int aux = d_cols*i;
			bool emptyRow = true;
			for(int j = 0; j < d_cols; j++){
				if (gsl_finite(d_data[aux + j])){
					emptyRow = false;
					break;
				}
			}
			if (emptyRow)
				continue;

			t << QString::number(i) + "\t";

			for(int j = 0; j < cols; j++){
				double val = d_data[aux + j];
				if (gsl_finite(val))
					t << QString::number(val, 'e', 16);
				t << "\t";
			}
			double val = d_data[aux + cols];
			if (gsl_finite(val))
				t << QString::number(val, 'e', 16);
			t << "\n";
		}
		t << "</data>\n";
    }
    t << "</matrix>\n";
}
示例#30
0
文件: field.C 项目: SALAM2016/orbiter
void prepare_latex_simple(BYTE *fname_base, INT verbose_level)
{
	char tex_file_name[1000];
	char dvi_file_name[1000];
	char ps_file_name[1000];
	
	sprintf(tex_file_name, "%s.tex", fname_base);
	sprintf(dvi_file_name, "%s.dvi", fname_base);
	sprintf(ps_file_name, "%s.ps", fname_base);
	
	{
	ofstream f(tex_file_name);
	
	f << "\\documentclass[]{article}" << endl;
	f << "\\usepackage{amsmath}" << endl;
	f << "\\usepackage{amssymb}" << endl;
	f << "\\usepackage{latexsym}" << endl;
	f << "\\usepackage{epsfig}" << endl;
	f << "%%\\usepackage{supertabular}" << endl;
	f << "\\evensidemargin 0in" << endl;
	f << "\\oddsidemargin 0in" << endl;
	f << "\\marginparwidth 0pt" << endl;
	f << "\\marginparsep 0pt" << endl;
	f << "\\topmargin -1in" << endl;
	f << "\\headheight 0.7cm" << endl;
	f << "\\headsep 1.8cm" << endl;
	f << "%%\\footheight 0.7cm" << endl;
	f << "\\footskip 2cm" << endl;
	f << "\\textheight 22cm" << endl;
	f << "\\textwidth 6.2in" << endl;
	f << "\\marginparpush 0pt" << endl;
	f << "%%\\newcommand{\\dominowidth}{167mm}" << endl;
	f << "\\newcommand{\\dominowidth}{190mm}" << endl;
	f << "\\newcommand{\\dominowidthsmall}{90mm}" << endl;
	//f << "\\title{" << photo_label_tex << "}" << endl;
	//f << "%%\\author{{\\sc }}" << endl;
	//f << "\\date{\\today}" << endl;
	f << "\\pagestyle{empty}" << endl;
	f << "\\begin{document}" << endl;
	//f << "\\maketitle" << endl;
	f << "\\begin{center}" << endl;
	f << "\\hspace*{-15mm}\\epsfig{file=" << fname_base << ".1,width=\\dominowidth}" << endl; 
	
	f << "\\end{center}" << endl;
	

	f << "\\end{document}" << endl;
	}
	char cmd0[1000];
	char cmd1[1000];
	char cmd2[1000];
	char cmd3[1000];
	char cmd4[1000];
	
	sprintf(cmd0, "mpost %s.mp", fname_base);
	sprintf(cmd1, "latex %s", tex_file_name);
	sprintf(cmd2, "dvips %s -o", dvi_file_name);
	sprintf(cmd4, "convert -trim -density 300 %s.ps %s.png", fname_base, fname_base);
	sprintf(cmd3, "open %s &", ps_file_name);
	system(cmd0);
	system(cmd1);
	system(cmd2);
	system(cmd4);
	system(cmd3);
	//system("latex view.tex");
	//system("dvips view.dvi -o");
	//system("open view.ps &");


}