예제 #1
0
int main ()
{
	int i, j;
	employee p[N];			//p - pointer
	for (i=0; i<N; i++)
	{
		fflush (stdin);
		printf ("vvedite familijy %d sotrudnika: ", i+1);
		fgets (p[i].surname, SE, stdin);
		fflush (stdin);
		printf ("vvedite imja %d sotrudnika: ", i+1);
		fgets (p[i].name, NE, stdin);
		fflush (stdin);
		printf ("vvedite otchestvo %d sotrudnika: ", i+1);
		fgets (p[i].father_name, FE, stdin);
		for (j=0; j<M; )
		{
			printf ("vvedite zarplaty za mesyac %d v milionah: ", j+1);
			if (!scanf ("%d", &(p[i].salary[j])))
				fflush (stdin);
			else j++;
		}
	}
	printf ("User surname, name, father name and salarys:\n");
	qsort (p, N, sizeof (employee), f_sort_e);
	for (i=0; i<N; i++)
		flist (p[i]);
}
예제 #2
0
파일: corrobj.cpp 프로젝트: esheldon/misc
void corrobj::intersect(double ra, double dec, float DA, vector<uint64> &idlist)
{

    double d = cos( par.rmax/DA );
    ValVec<uint64> plist, flist;

    // We must intitialize each time because it remembers it's state
    // internally
    SpatialDomain domain;    // initialize empty domain

    domain.setRaDecD(ra,dec,d); //put in ra,dec,d E.S.S.

    domain.intersect(spatialIndex, plist, flist);	  // intersect with list

    //cout << "Number in plist+flist: " << plist.length() + flist.length() << endl;
    //cout << "   Separately: " << plist.length() << " " << flist.length() << endl;
    // Save the result in idlist. This is not a bottleneck
    idlist.resize( flist.length() + plist.length() );

    int idCount=0;
    // ----------- FULL NODES -------------
    for(int i = 0; i < flist.length(); i++)
    {  
        idlist[idCount] = flist(i);
        idCount++;
    }
    // ----------- Partial Nodes ----------
    for(int i = 0; i < plist.length(); i++)
    {  
        idlist[idCount] = plist(i);
        idCount++;
    }


}
예제 #3
0
void FmRepair::slotRemoveUnref()
{
    FMFontDb *db(FMFontDb::DB());
    QStringList failed;
    QList<FontItem*> flist(typotek::getInstance()->getTheMainView()->curFonts());
    for(int i(0); i < unrefList->count(); ++i)
    {
        if(unrefList->item(i)->checkState() == Qt::Checked)
        {
            FontItem* curItem = 0;
            QString fId(unrefList->item(i)->text());
            foreach(FontItem* it, flist)
            {
                if(it->path() == fId)
                {
                    curItem = it;
                    break;
                }
            }
            if(!db->Remove(fId))
                failed << fId;
            else if(curItem)
                flist.removeAll(curItem);

        }
    }
예제 #4
0
파일: common.c 프로젝트: pauley/pcc
/*
 * Do a preorder walk of the CM list p and apply function f on each element.
 */
void
flist(NODE *p, void (*f)(NODE *, void *), void *arg)
{
	if (p->n_op == CM) {
		(*f)(p->n_right, arg);
		flist(p->n_left, f, arg);
	} else
		(*f)(p, arg);
}
예제 #5
0
파일: gcc_compat.c 프로젝트: pauley/pcc
/*
 * Extract attributes from a node tree and return attribute entries
 * based on its contents.
 */
struct attr *
gcc_attr_parse(NODE *p)
{
    struct attr a;

    if (p == NIL)
        return NULL;
    a.next = NULL;
    flist(p, gcc_attribs, &a);
    tfree(p);
    return a.next;
}
예제 #6
0
void FmRepair::fillActNotLinked()
{
    typotek *t = typotek::getInstance();
    actNotLinkList->clear();
    QList<FontItem*> flist(FMFontDb::DB()->AllFonts());
    QStringList activated;
    for(int i(0); i < flist.count(); ++i)
    {
        if((!t->isSysFont(flist[i])) && (flist[i]->isActivated()))
            activated << flist[i]->path();
    }

    QStringList linked;
    QDir md(t->getManagedDir());
    md.setFilter( QDir::Files );
    QFileInfoList list = md.entryInfoList();
    for(int i(0); i < list.count(); ++i)
    {
        if(list[i].isSymLink())
        {
            if(  QFileInfo(list[i].symLinkTarget()).exists()  )
            {
// 				qDebug()<< "ACT NOT LINK "<<list[i].symLinkTarget();
                linked << list[i].symLinkTarget();
            }
            else
            {
                qDebug()<<list[i].filePath()<<" is a broken symlink";
            }
        }
        else
        {
            qDebug()<<list[i].filePath() << " is not a symlink";
        }
    }

    for(int i(0); i < activated.count(); ++i)
    {
        if(!linked.contains(activated[i]))
        {
            QListWidgetItem *lit = new QListWidgetItem(activated[i]);
            lit->setCheckState(Qt::Unchecked);
            lit->setToolTip(activated[i]);
            actNotLinkList->addItem(lit);
// 			listItems << lit;
        }
    }
}
void SimFieldDictionary::writeFields(SimObject *obj, Stream &stream, U32 tabStop)
{
   const AbstractClassRep::FieldList &list = obj->getFieldList();
   Vector<Entry *> flist(__FILE__, __LINE__);

   for(U32 i = 0; i < HashTableSize; i++)
   {
      for(Entry *walk = mHashTable[i];walk; walk = walk->next)
      {
         // make sure we haven't written this out yet:
         U32 i;
         for(i = 0; i < list.size(); i++)
            if(list[i].pFieldname == walk->slotName)
               break;

         if(i != list.size())
            continue;


         if (!obj->writeField(walk->slotName, walk->value))
            continue;

         flist.push_back(walk);
      }
   }

   // Sort Entries to prevent version control conflicts
   dQsort(flist.address(),flist.size(),sizeof(Entry *),compareEntries);

   // Save them out
   for(Vector<Entry *>::iterator itr = flist.begin(); itr != flist.end(); itr++)
   {
      U32 nBufferSize = (dStrlen( (*itr)->value ) * 2) + dStrlen( (*itr)->slotName ) + 16;
      FrameTemp<char> expandedBuffer( nBufferSize );

      stream.writeTabs(tabStop+1);

      const char *typeName = (*itr)->type && (*itr)->type->getTypeID() != TypeString ? (*itr)->type->getTypeName() : "";
      dSprintf(expandedBuffer, nBufferSize, "%s%s%s = \"", typeName, *typeName ? " " : "", (*itr)->slotName);
      if ( (*itr)->value )
         expandEscape((char*)expandedBuffer + dStrlen(expandedBuffer), (*itr)->value);
      dStrcat(expandedBuffer, "\";\r\n");

      stream.write(dStrlen(expandedBuffer),expandedBuffer);
   }

}
// readFileLists reads the srclist file specified in params
// and reads the names of the images and fitpsf 
void MultiShearCatalog::readFileLists()
{
    std::string file = _params.get("coadd_srclist");
    if (!DoesFileExist(file)) {
        throw FileNotFoundException(file);
    }

    try {
        dbg<<"Opening coadd srclist\n";
        std::ifstream flist(file.c_str(), std::ios::in);
        if (!flist) {
            throw ReadException("Unable to open source list file " + file);
        }

        _image_file_list.clear();
        _shear_file_list.clear();
        _fitpsf_file_list.clear();
        _skymap_file_list.clear();

        std::string image_filename;
        std::string shear_filename;
        std::string fitpsf_filename;
        std::string skymap_filename;
        bool isSkyMapIn_list = _params.read("multishear_skymap_in_list",false);

        while (flist >> image_filename >> shear_filename >> fitpsf_filename) {
            dbg<<"Files are :\n"<<image_filename<<std::endl;
            dbg<<shear_filename<<std::endl;
            dbg<<fitpsf_filename<<std::endl;
            if (isSkyMapIn_list) {
                flist >> skymap_filename;
                if (!flist) {
                    throw ReadException(
                        "Unable to read skymap_filename in list file " + file);
                }
                addImage(image_filename,fitpsf_filename,
                         shear_filename,skymap_filename);
            } else {
                addImage(image_filename,fitpsf_filename,shear_filename);
            }
        }
        if (isSkyMapIn_list) {
            Assert(_skymap_file_list.size() == _image_file_list.size());
        }
    } catch (std::exception& e) {
예제 #9
0
void FmRepair::fillDeactLinked()
{
    typotek *t = typotek::getInstance();
    deactLinkList->clear();
    QList<FontItem*> flist(FMFontDb::DB()->AllFonts());
    QStringList deactivated;
    for(int i(0); i < flist.count(); ++i)
    {
        if(!t->isSysFont(flist[i]) && !flist[i]->isRemote() && !flist[i]->isActivated())
            deactivated << flist[i]->path();
    }
// 	qDebug() << deactivated.join("\nDEACT : ");
    QStringList linked;
    QDir md(t->getManagedDir());
    md.setFilter( QDir::Files );
    QFileInfoList list = md.entryInfoList();
    for(int i(0); i < list.count(); ++i)
    {
        if(list[i].isSymLink())
        {
            if(  QFileInfo(list[i].symLinkTarget()).exists()  )
            {
                linked << list[i].symLinkTarget();
            }
        }
    }

    for(int i(0); i < linked.count(); ++i)
    {
        if(deactivated.contains(linked[i]))
        {
// 			qDebug() << "NO " << linked[i] ;
            QListWidgetItem *lit = new QListWidgetItem(linked[i]);
            lit->setCheckState(Qt::Unchecked);
            lit->setToolTip(linked[i]);
            deactLinkList->addItem(lit);
// 			listItems << lit;
        }
        else
        {
// 			qDebug() << "OK " << linked[i] ;
        }
    }
}
예제 #10
0
/*
 * Compare a matching prototype for an argument tree.
 * Here we can expand to also do inexact matches.
 * Return 0 if equal, -1 if failed.
 */
static int
cxxptreecmp(struct symtab *sp, NODE *p)
{
	struct ckstr ckstr;
	union arglist *a1;

	if (!ISFTN(sp->stype) || sp->sdf == NULL ||
	    (a1 = sp->sdf->dfun) == NULL)
		return 0; /* no dimfun */

	if (p == NULL && a1[0].type == TNULL)
		return 1; /* arg-less */

	ckstr.rv = 0;
	ckstr.al = a1;
	flist(p, cxxckproto, &ckstr);

	if (ckstr.al[0].type != TNULL)
		return -1; /* arg number error */
	return ckstr.rv;
}
bool L1Ntuple::OpenNtupleList(const std::string & fname)
{
  std::ifstream flist(fname.c_str());
  if (!flist)
    {
      std::cout << "File "<<fname<<" is not found !"<<std::endl;
      return false;
    }

  while(!flist.eof())
    {
      std::string str;
      getline(flist,str);
      if (!flist.fail())
  {
           if (str!="") listNtuples.push_back(str);
  }
    }

  return true;
}
void SimFieldDictionary::printFields(SimObject *obj)
{
   const AbstractClassRep::FieldList &list = obj->getFieldList();
   char expandedBuffer[4096];
   Vector<Entry *> flist(__FILE__, __LINE__);

   for(U32 i = 0; i < HashTableSize; i++)
   {
      for(Entry *walk = mHashTable[i];walk; walk = walk->next)
      {
         // make sure we haven't written this out yet:
         U32 i;
         for(i = 0; i < list.size(); i++)
            if(list[i].pFieldname == walk->slotName)
               break;

         if(i != list.size())
            continue;

         flist.push_back(walk);
      }
   }
   dQsort(flist.address(),flist.size(),sizeof(Entry *),compareEntries);

   for(Vector<Entry *>::iterator itr = flist.begin(); itr != flist.end(); itr++)
   {
      const char* type = "string";
      if( ( *itr )->type )
         type = ( *itr )->type->getTypeClassName();
         
      dSprintf( expandedBuffer, sizeof( expandedBuffer ), "  %s %s = \"", type, ( *itr )->slotName );
      if ( (*itr)->value )
         expandEscape(expandedBuffer + dStrlen(expandedBuffer), (*itr)->value);
      Con::printf("%s\"", expandedBuffer);
   }
}
예제 #13
0
IGL_INLINE bool igl::writePLY(
  const std::string & filename,
  const Eigen::PlainObjectBase<DerivedV> & V,
  const Eigen::PlainObjectBase<DerivedF> & F,
  const Eigen::PlainObjectBase<DerivedN> & N,
  const Eigen::PlainObjectBase<DerivedUV> & UV,
  const bool ascii)
{
  // Largely based on obj2ply.c

  typedef struct Vertex
  {
    double x,y,z,w;          /* position */
    double nx,ny,nz;         /* surface normal */
    double s,t;              /* texture coordinates */
  } Vertex;

  typedef struct Face
  {
    unsigned char nverts;    /* number of vertex indices in list */
    int *verts;              /* vertex index list */
  } Face;

  PlyProperty vert_props[] =
  { /* list of property information for a vertex */
    {"x", PLY_DOUBLE, PLY_DOUBLE, offsetof(Vertex,x), 0, 0, 0, 0},
    {"y", PLY_DOUBLE, PLY_DOUBLE, offsetof(Vertex,y), 0, 0, 0, 0},
    {"z", PLY_DOUBLE, PLY_DOUBLE, offsetof(Vertex,z), 0, 0, 0, 0},
    {"nx", PLY_DOUBLE, PLY_DOUBLE, offsetof(Vertex,nx), 0, 0, 0, 0},
    {"ny", PLY_DOUBLE, PLY_DOUBLE, offsetof(Vertex,ny), 0, 0, 0, 0},
    {"nz", PLY_DOUBLE, PLY_DOUBLE, offsetof(Vertex,nz), 0, 0, 0, 0},
    {"s", PLY_DOUBLE, PLY_DOUBLE, offsetof(Vertex,s), 0, 0, 0, 0},
    {"t", PLY_DOUBLE, PLY_DOUBLE, offsetof(Vertex,t), 0, 0, 0, 0},
  };

  PlyProperty face_props[] =
  { /* list of property information for a face */
    {"vertex_indices", PLY_INT, PLY_INT, offsetof(Face,verts),
      1, PLY_UCHAR, PLY_UCHAR, offsetof(Face,nverts)},
  };
  const bool has_normals = N.rows() > 0;
  const bool has_texture_coords = UV.rows() > 0;
  std::vector<Vertex> vlist(V.rows());
  std::vector<Face> flist(F.rows());
  for(size_t i = 0;i<(size_t)V.rows();i++)
  {
    vlist[i].x = V(i,0);
    vlist[i].y = V(i,1);
    vlist[i].z = V(i,2);
    if(has_normals)
    {
      vlist[i].nx = N(i,0);
      vlist[i].ny = N(i,1);
      vlist[i].nz = N(i,2);
    }
    if(has_texture_coords)
    {
      vlist[i].s = UV(i,0);
      vlist[i].t = UV(i,1);
    }
  }
  for(size_t i = 0;i<(size_t)F.rows();i++)
  {
    flist[i].nverts = F.cols();
    flist[i].verts = new int[F.cols()];
    for(size_t c = 0;c<(size_t)F.cols();c++)
    {
      flist[i].verts[c] = F(i,c);
    }
  }

  const char * elem_names[] = {"vertex","face"};
  FILE * fp = fopen(filename.c_str(),"w");
  if(fp==NULL)
  {
    return false;
  }
  PlyFile * ply = ply_write(fp, 2,elem_names,
      (ascii ? PLY_ASCII : PLY_BINARY_LE));
  if(ply==NULL)
  {
    return false;
  }

  std::vector<PlyProperty> plist;
  plist.push_back(vert_props[0]);
  plist.push_back(vert_props[1]);
  plist.push_back(vert_props[2]);
  if (has_normals)
  {
    plist.push_back(vert_props[3]);
    plist.push_back(vert_props[4]);
    plist.push_back(vert_props[5]);
  }
  if (has_texture_coords)
  {
    plist.push_back(vert_props[6]);
    plist.push_back(vert_props[7]);
  }
  ply_describe_element(ply, "vertex", V.rows(),plist.size(),
    &plist[0]);

  ply_describe_element(ply, "face", F.rows(),1,&face_props[0]);
  ply_header_complete(ply);
  int native_binary_type = get_native_binary_type2();
  ply_put_element_setup(ply, "vertex");
  for(const auto v : vlist)
  {
    ply_put_element(ply, (void *) &v, &native_binary_type);
  }
  ply_put_element_setup(ply, "face");
  for(const auto f : flist)
  {
    ply_put_element(ply, (void *) &f, &native_binary_type);
  }

  ply_close(ply);
  for(size_t i = 0;i<(size_t)F.rows();i++)
  {
    delete[] flist[i].verts;
  }
  return true;
}
예제 #14
0
파일: amfitter.cpp 프로젝트: nategri/AMBER
// Function sets up and reads in data from the temperature files and AMBER housekeeping
AmFitter::AmFitter(char* temps_name) {
  int horn_id;

  for(int i=0; i<N_HSK; i++) {
    _blacklist[i] = 0;
  }

  string tempnamestr(temps_name);

  if(tempnamestr == "C1H_temps.out") {
    horn_id = 0;
  }
  if(tempnamestr == "C2H_temps.out") {
    horn_id = 8;
  }
  if(tempnamestr == "C3H_temps.out") {
    horn_id = 16;
  }
  if(tempnamestr == "C4H_temps.out") {
    horn_id = 24;
  }
  if(tempnamestr == "C5_temps.out") {
    horn_id = 4;
  }
  if(tempnamestr == "C6_temps.out") {
    horn_id = 5;
  }
  if(tempnamestr == "C7_temps.out") {
    horn_id = 6;
  }
  if(tempnamestr == "C8_temps.out") {
    horn_id = 12;
  }
  if(tempnamestr == "C9_temps.out") {
    horn_id = 13;
  }
  if(tempnamestr == "C10_temps.out") {
    horn_id = 14;
  }
  if(tempnamestr == "C11_temps.out") {
    horn_id = 20;
  }
  if(tempnamestr == "C12_temps.out") {
    horn_id = 21;
  }
  if(tempnamestr == "C13_temps.out") {
    horn_id = 22;
  }
  if(tempnamestr == "C14_temps.out") {
    horn_id = 28;
  }
  if(tempnamestr == "C15_temps.out") {
    horn_id = 29;
  }
  if(tempnamestr == "C16_temps.out") {
    horn_id = 30;
  }

  cout << "horn id: " << horn_id << endl;

  // open temperature file, load into arrays and create interpolation
  ifstream temps_input(temps_name);

  double toss1,toss2,toss3,toss4;

  int i,j;

  for(i=0;i<1;i++) {
    temps_input >> toss1;
    //cout << toss1 << endl;
    for(j=0;j<215;j++) {
      temps_input >> time_arr[i][j] >> toss2 >> toss3 >> temp_arr[i][j] >> toss4;
    }
  }

  // set up interpolation
  for(i=0;i<1;i++) {
    _acc[i] = gsl_interp_accel_alloc();
    _spline[i] = gsl_spline_alloc(gsl_interp_cspline,215);
    gsl_spline_init(_spline[i],time_arr[i],temp_arr[i],215);
  }

  // read in list of root files to use for fit
  string filename[N_HSK];
  ifstream flist("rootfiles.list");
  for(i=0;i<N_HSK;i++) {
    getline(flist,filename[i]);
    cout << filename[i] << endl;
    if(filename[i].find('#') != string::npos) {
      i--;
      cout << "Line ignored in list" << endl;
    }
  }

  // open AMBER housekeeping files, set histogram pointers
  for(i=0;i<N_HSK;i++) {
    
    TFile* f = new TFile(filename[i].c_str());

    f->ReadAll();
    TAmHskTree* amhsk = AMBER::GetHousekeepingFromFile(f);

    _amhsk_hist[i] = amhsk->GetPercentRfpRaw(0.0,100.0,(AMBER::eChannelId) horn_id);
    cout << setprecision(10) << "Starts at: " <<  _amhsk_hist[i]->GetXaxis()->GetBinCenter(1) << endl;

    // how many days is the offset from "orginal" day?
    int d_int;
    double day_diff = (_amhsk_hist[i]->GetXaxis()->GetBinCenter(1) - 1331618356/*_amhsk_hist[0]->GetXaxis()->GetBinCenter(1)*/)/86400;
    d_int = (int) (day_diff+0.5);
    //cout << day_diff << " " << d_int << " " << fabs(day_diff-d_int) << endl;
    if(i>=0) {
      if( fabs(day_diff-d_int) < 0.01 ) {
	      _n_days[i] = d_int;
      }
      else {
	      cout << "Error: " << filename[i] << ": Not an integer number of day offset from 'original' file" << endl;
	      cout << "File is this many days off from last: ";
	      cout << (_amhsk_hist[i]->GetXaxis()->GetBinCenter(1) - _amhsk_hist[i-1]->GetXaxis()->GetBinCenter(1))/86400 << endl;
	      exit(EXIT_FAILURE);
      }
    }
    //else {
    //n_days[0] = 0;
    //}

    //cout << "I worked!" << endl;

    //delete f;
    f->Close();
  }

  //for(int k=0; k<N_HSK; k++) {
  //  cout << _n_days[k] << endl;
  //}
}
예제 #15
0
void analyPerfbyrun(int nEvents=0, int iseg){
  gSystem->Load("libfun4all.so");
  gSystem->Load("librecal.so");
  gSystem->Load("libfvtx_subsysreco.so");
  gSystem->Load("/gpfs/mnt/gpfs02/phenix/plhf/plhf1/xuq/phenix/flow/Run16dAu/install/lib/libPerformTestMB.so");
  
  Fun4AllServer *se = Fun4AllServer::instance();
  int ifile = 0;
  char cntfile[1000];
  char dstevefile[1000];
  char irun[1000];

  ifstream findex(Form("Run16dAu39GeV.lst"));
  int temp=0;
  while (findex.getline(irun, 500) && temp<iseg){
    temp++;
  }
  cout<<iseg<<" "<<irun<<endl;
  ifstream flist(Form("run-by-run/run_%s.lst",irun));
  TString out=Form("output/output_perform_mix_%d.root",iseg);
  Fun4AllDstInputManager *in = new Fun4AllDstInputManager("CNT");
  se->registerInputManager(in);
  while (flist.getline(cntfile, 500)){
    cout<<ifile<<" "<<cntfile<<endl;
    if(strstr(cntfile,"0000454"))
    in->AddFile(Form("/phenix/prod/online_production/run16_online_ca/run_0000454000_0000455000/CNT/CNT_%s",cntfile));
    if(strstr(cntfile,"0000455"))
    in->AddFile(Form("/phenix/prod/online_production/run16_online_ca/run_0000455000_0000456000/CNT/CNT_%s",cntfile));
    if(strstr(cntfile,"0000456"))
    in->AddFile(Form("/phenix/prod/online_production/run16_online_ca/run_0000456000_0000457000/CNT/CNT_%s",cntfile));
    if(strstr(cntfile,"0000457"))
    in->AddFile(Form("/phenix/prod/online_production/run16_online_ca/run_0000457000_0000458000/CNT/CNT_%s",cntfile));
    ifile++;
  }
  int ifile=0;
  ifstream flist(Form("run-by-run/run_%s.lst",irun));
  Fun4AllDstInputManager *in = new Fun4AllDstInputManager("DST");
  se->registerInputManager(in);
  while (flist.getline(dstevefile, 500)){
    cout<<ifile<<" "<<dstevefile<<endl;
    if(strstr(dstevefile,"0000454"))
    in->AddFile(Form("/phenix/prod/online_production/run16_online_ca/run_0000454000_0000455000/DST_EVE/DST_EVE_%s",dstevefile));
    if(strstr(dstevefile,"0000455"))
    in->AddFile(Form("/phenix/prod/online_production/run16_online_ca/run_0000455000_0000456000/DST_EVE/DST_EVE_%s",dstevefile));
    if(strstr(dstevefile,"0000456"))
    in->AddFile(Form("/phenix/prod/online_production/run16_online_ca/run_0000456000_0000457000/DST_EVE/DST_EVE_%s",dstevefile));
    if(strstr(dstevefile,"0000457"))
    in->AddFile(Form("/phenix/prod/online_production/run16_online_ca/run_0000457000_0000458000/DST_EVE/DST_EVE_%s",dstevefile));
    ifile++;
  }

  MasterRecalibratorManager *mr = new MasterRecalibratorManager("MASTERRECALIBRATORMANAGER");
  mr->FillHistos(0);
  se->registerSubsystem(mr);
  
//FVTX cluster
  FvtxReadbackDST *fvtx_readback_dst = new FvtxReadbackDST();
  se->registerSubsystem( fvtx_readback_dst );

  PerformTestMB *rpana = new PerformTestMB(out.Data());
  se->registerSubsystem(rpana);
  se->run(nEvents);
  se->End();
  
}