Exemplo n.º 1
0
int del(int i)   // delete node i
{
    if (i == na) return i;
    int x, y, l, r;
    l = tr[i].l;
    r = tr[i].r;
    y = tr[i].f;
    tr[i].l = tr[i].r = tr[i].f = na;
    tr[x = merge(l, r)].f = y;
    if (y != na && tr[y].l == i) tr[y].l = x;
    if (y != na && tr[y].r == i) tr[y].r = x;
    for ( ; y != na; x = y, y = tr[y].f)
        {
            if (tr[tr[y].l].dist < tr[tr[y].r].dist)
                swap(tr[y].l, tr[y].r);
            if (tr[tr[y].r].dist + 1 == tr[y].dist) break;
            tr[y].dist = tr[tr[y].r].dist + 1;
        }
    if (x != na) return iroot(x); // return new root
    else return iroot(y);
}
Exemplo n.º 2
0
CMPICascade::CMPICascade(int nodes_per_level, MPI_Comm comm)
{
	int remaining_levels;
	MPI_Comm intraComm;
	int l = 0; // current level
	do {
		level.push_back(comm);
		remaining_levels = ilog(nodes_per_level /*base*/, level[l].size /*arg*/) + 1;
		level[l].group_size = iroot(remaining_levels, level[l].size); // group_size^remaining_levels <= size
		level[l].p_grp_size = level[l].size/level[l].group_size;
	
		MPI_Comm_split(comm, level[l].colour(), level[l].key(), &intraComm);
		MPI_Comm_split(comm, level[l].p_colour(), level[l].p_key(), &(level[l].pg_comm));
		comm = intraComm;
		l++;
	} while (--remaining_levels);
	num_levels = l;
}
Exemplo n.º 3
0
// build root file
void EXOnator::makeTables(string bed_file,string conf_file)
{
  string files[] = {"T_dup.txt","N_dup.txt"};
  char buffer[5000];
  string chrom,gene,sid;
  int start,end;
  double vals[1000];
  for (int i = 0;i < 2;i++) {
    TFile iroot(_root_file.c_str(),"update");
    TTree tree(files[i].substr(0,5).c_str(),files[i].substr(0,5).c_str());
    tree.Branch("chrom",&chrom);
    tree.Branch("start",&start,"start/I");
    tree.Branch("end",  &end,  "end/I");
    tree.Branch("gene", &gene);

    ifstream fin(files[i].c_str());
    fin.getline(buffer,5000);
    istringstream line0(buffer);
    line0>>sid>>sid>>sid>>sid;
    double *address = vals;
    while (line0>>sid)
      tree.Branch(sid.c_str(),address++,(sid + "/D").c_str());

    while (fin.good()) {
      fin.getline(buffer,5000);
      istringstream line(buffer);
      line>>chrom>>start>>end>>gene;
      address = vals;
      while (line>>(*address)) address++;
      tree.Fill();
    }
    fin.close();

    tree.Write("",TObject::kOverwrite);
    iroot.Close();
  }
}