コード例 #1
0
ファイル: list.c プロジェクト: MFreeze/TER-Master1-Preflots
// {{{ popTail
void popTail(List * l) {
  Item * it = end(l);
  if (nb(l) > 1) next(prev(it)) = NULL;
  end(l) = prev(it);
  free (it);
  nb(l)--;
}
コード例 #2
0
ファイル: list.c プロジェクト: MFreeze/TER-Master1-Preflots
// {{{ popHead
void popHead(List * l) {
  if (nb(l) == 0) return;
  Item * it = begin(l);
  if (nb(l) > 1) prev(next(it)) = NULL;
  begin(l) = next(it);
  free (it);
  nb(l)--;
}
コード例 #3
0
ファイル: list.c プロジェクト: MFreeze/TER-Master1-Preflots
// {{{ pushTail
void pushTail(List * l, int num, int val) {
  Item * it = (Item*) malloc(SIZE_ITEM);
  num(it) = num;
  val(it) = val;
  prev(it) = end(l);
  next(it) = NULL;
  if (nb(l) == 0) begin(l) = it;
  else next(end(l)) = it;
  end(l) = it;
  nb(l)++;
}
コード例 #4
0
ファイル: list.c プロジェクト: MFreeze/TER-Master1-Preflots
// {{{ List operations
// {{{ pushHead
void pushHead(List * l, int num, int val) {
  Item * it = (Item*) malloc(SIZE_ITEM);
  num(it) = num;
  val(it) = val;
  prev(it) = NULL;
  next(it) = begin(l);
  if (nb(l) == 0) end(l) = it;
  else prev(begin(l)) = it;
  begin(l) = it;
  nb(l)++;
}
コード例 #5
0
ファイル: graph.cpp プロジェクト: afbarnard/libdai
void GraphAL::checkConsistency() const {
    size_t N = nrNodes();
    for( size_t n1 = 0; n1 < N; n1++ ) {
        size_t iter = 0;
        foreach( const Neighbor &n2, nb(n1) ) {
            DAI_ASSERT( n2.iter == iter );
            DAI_ASSERT( n2.node < N );
            DAI_ASSERT( n2.dual < nb(n2).size() );
            DAI_ASSERT( nb(n2, n2.dual) == n1 );
            iter++;
        }
    }
コード例 #6
0
ファイル: list.c プロジェクト: MFreeze/TER-Master1-Preflots
// {{{ popNum
void popNum(List * l, int num) {
  if (nb(l) == 0) return;
  if (num(begin(l)) == num) { popHead(l); return; }
  if (num(end(l)) == num) {popTail(l); return; }
  Item * it = begin(l);
  while (it != NULL && num(it) < num) it = next(it);
  if (it == NULL || num(it) > num) return;
  else {
    next(prev(it)) = next(it);
    prev(next(it)) = prev(it);
    free(it);
    nb(l)--;
  }
}
コード例 #7
0
ファイル: list.c プロジェクト: MFreeze/TER-Master1-Preflots
// {{{ Memory management
// {{{ allocList
List * allocList() {
  List * res = (List *) malloc(sizeof(List));
  nb(res) = 0;
  begin(res) = NULL;
  end(res) = NULL;
  return res;
}
コード例 #8
0
ファイル: t-eoSelect.cpp プロジェクト: aldukeman/dae
void testSelectMany(eoSelect<EOT> & _select, std::string _name)
{
    unsigned i;
  std::cout << "\n\n" << fitnessType + _name << std::endl;
  std::cout << "===============\n";

    eoDummyPop parents(parentsOrg);
    eoDummyPop offspring(0);

    // do the selection
    _select(parents, offspring);

    // compute stats
    std::vector<unsigned> nb(parents.size(), 0);
    for (i=0; i<offspring.size();  i++)
      {
	unsigned trouve = isInPop<Dummy>(offspring[i], parents);
	if (trouve == parents.size()) // pas trouve
	  throw std::runtime_error("Pas trouve ds parents");
	nb[trouve]++;
       }
    // dump to file so you can plot using gnuplot - dir name is hardcoded!
    std::string fName = "ResSelect/" + fitnessType + _name + ".select";
    std::ofstream os(fName.c_str());
    for (i=0; i<parents.size();  i++)
      {
	std::cout << i << " -> " << ( (double)nb[i])/offspring.size() << std::endl;
	os << i << " " << ( (double)nb[i])/offspring.size() << std::endl;
      }

}
コード例 #9
0
 // search all gates position, put into queue as level 0 nodes
 // for each gate, do BFS
 void wallsAndGates(vector<vector<int>>& rooms) {
     const int m = rooms.size();
     if(m==0) return;
     int n = rooms[0].size();
     bool visited[m][n];
     queue<Pos> Q;
     for(int i=0; i<m; i++){
         fill_n(visited[i], n, false);
         for(int j=0; j<n; j++){
             if(rooms[i][j]==0){
                 Q.push(Pos(i, j));
                 visited[i][j] = true;
             }
         }
     }
     int level = 1;
     while(!Q.empty()){
         int num_cur_level = Q.size();
         for(int i=0; i<num_cur_level; i++){
             //visit neighbors
             auto cur = Q.front();
             Q.pop();
             for(int j=0; j<4; j++){
                 Pos nb(cur.x + dx[j], cur.y + dy[j]);
                 if(nb.x >=m || nb.x <0 || nb.y>=n || nb.y<0) continue;
                 if(rooms[nb.x][nb.y]==-1 || visited[nb.x][nb.y]) continue;
                 visited[nb.x][nb.y] = true;
                 Q.push(nb);
                 rooms[nb.x][nb.y] = level;
             }
         }
         level++;
     }
 }
コード例 #10
0
 static void close(T& t, Sink& snk, BOOST_IOS::openmode which)
 {
     if (which == BOOST_IOS::out) {
         non_blocking_adapter<Sink> nb(snk);
         iostreams::flush(t, nb);
     }
 }
コード例 #11
0
ファイル: bootstrap.hpp プロジェクト: ChaiScript/iSSB
 std::shared_ptr<P1> construct_pod(Boxed_Number v)
 {
   std::shared_ptr<P1> p(new P1());
   Boxed_Value bv(p);
   Boxed_Number nb(bv);
   nb = v;
   return p;
 }
コード例 #12
0
VariableSymbol* NodeBuilder::get_cstr_const_var(String s, ProcedureDefinition* p)
{
  NodeBuilder nb(p->get_symbol_table());
  MultiValueBlock* vb = nb.new_cstr_value_block(s);
  VariableSymbol* var = new_var("", vb->get_type());
  nb.add_variable_definition(p, var, vb);
  return var;
}
コード例 #13
0
void Tuto5Topo::cb_initGL(Scene* scene){
		m_render_topo = new Algo::Render::GL2::Topo3Render();


		SelectorDartNoBoundary<PFP::MAP> nb(*myMap);
		m_render_topo->updateData<PFP>(*myMap, position,  0.9f, 0.9f, 0.9f, nb);

}
コード例 #14
0
ファイル: list.c プロジェクト: MFreeze/TER-Master1-Preflots
// {{{ insertNum
void insertNum(List * l, int num, int val) {
  if (val == 0) popNum(l,num);
  else if (nb(l) == 0 || num(begin(l)) > num) pushHead(l, num, val);
  else if (num(end(l)) < num) pushTail(l, num, val);
  else {
    Item * it = begin(l);
    while (num(it) < num) it = next(it);
    if (num(it) == num) val(it) = val;
    else {
      Item * i = (Item*) malloc(SIZE_ITEM);
      num(i) = num; val(i) = val;
      prev(i) = prev(it); next(i) = it;
      next(prev(it)) = i; prev(it) = i;
      nb(l)++;
    }
  }
}
コード例 #15
0
ファイル: list.c プロジェクト: MFreeze/TER-Master1-Preflots
// {{{ Display functions
// {{{ printList
void printList (FILE * f, List * l) {
  fprintf(f,"nb = %d : ", nb(l));
  Item * it = begin(l);
  while (it != NULL) {
    fprintf(f, "%2d (%2d) - ", num(it), val(it));
    it = next(it);
  }
  fprintf(f, "\n");
}
コード例 #16
0
ファイル: Price.c プロジェクト: stackprobe/Factory
Price_t *CreatePrice(double bid, double ask)
{
	Price_t *i = nb(Price_t);

	i->Bid = bid;
	i->Ask = ask;

	return i;
}
コード例 #17
0
ファイル: board.cpp プロジェクト: SergioCaronte/nnm_agent
std::shared_ptr<Board> Board::copy()
{
	std::shared_ptr<Board> nb (new Board);
	for( int i = 0; i < BOARD_SPOT; i++)
		 this->spot[i]->copy(nb->spot[i]);
	nb->num_black_pieces = this->num_black_pieces;
	nb->num_white_pieces = this->num_white_pieces;
	return nb;
}
コード例 #18
0
ファイル: list.c プロジェクト: MFreeze/TER-Master1-Preflots
// {{{ Item Informations
// {{{ valOfNum
int valOfNum(List * l, int num) {
	if (l) {
  	if (nb(l) == 0 || num(begin(l)) > num || num(end(l)) < num) return 0;
  	Item * it = begin(l);
  	while (num(it) < num) it = next(it);
  	if (num(it) == num) return val(it);
	}
  return 0;
}
コード例 #19
0
ファイル: CalibSort.C プロジェクト: owen234/cmssw
void CalibSort::Loop() {
  //   In a ROOT session, you can do:
  //      Root > .L CalibSort.C
  //      Root > CalibSort t
  //      Root > t.GetEntry(12); // Fill t data members with entry number 12
  //      Root > t.Show();       // Show values of entry 12
  //      Root > t.Show(16);     // Read and show values of entry 16
  //      Root > t.Loop();       // Loop on all entries
  //

  //   This is the loop skeleton where:
  //      jentry is the global entry number in the chain
  //      ientry is the entry number in the current Tree
  //   Note that the argument to GetEntry must be:
  //      jentry for TChain::GetEntry
  //      ientry for TTree::GetEntry and TBranch::GetEntry
  //
  //       To read only selected branches, Insert statements like:
  // METHOD1:
  //    fChain->SetBranchStatus("*",0);  // disable all branches
  //    fChain->SetBranchStatus("branchname",1);  // activate branchname
  // METHOD2: replace line
  //    fChain->GetEntry(jentry);       //read all branches
  //by  b_branchname->GetEntry(ientry); //read only this branch
  if (fChain == 0) return;

  std::ofstream fileout;
  if ((flag_%10)==1) {
    fileout.open("events.txt", std::ofstream::out);
    std::cout << "Opens events.txt in output mode\n";
  } else {
    fileout.open("events.txt", std::ofstream::app);
    std::cout << "Opens events.txt in append mode\n";
  }
  fileout << "Input file: " << fname_ << " Directory: " << dirnm_ 
	  << " Prefix: " << prefix_ << "\n";
  Long64_t nbytes(0), nb(0), good(0);
  Long64_t nentries = fChain->GetEntriesFast();
  for (Long64_t jentry=0; jentry<nentries;jentry++) {
    Long64_t ientry = LoadTree(jentry);
    if (ientry < 0) break;
    nb = fChain->GetEntry(jentry);   nbytes += nb;
    double cut = (t_p > 20) ? 10.0 : 0.0;
    if ((flag_/10)%10 > 0) 
      std::cout << "Entry " << jentry << " p " << t_p << " Cuts " << t_qltyFlag
		<< "|" << t_selectTk << "|" << (t_hmaxNearP < cut) << "|" 
		<< (t_eMipDR < mipCut_) << std::endl;
    if (t_qltyFlag && t_selectTk && (t_hmaxNearP<cut) && (t_eMipDR<mipCut_)) {
      good++;
      fileout << good << " " << jentry << " " << t_Run  << " " << t_Event 
	      << " " << t_ieta << " " << t_p << std::endl;
    }
  }
  fileout.close();
  std::cout << "Writes " << good << " events in the file events.txt from "
	    << nentries << " entries" << std::endl;
}
コード例 #20
0
ファイル: list.c プロジェクト: MFreeze/TER-Master1-Preflots
// {{{ printListReverse
void printListReverse (FILE * f, List * l) {
  fprintf(f,"nb = %d : ", nb(l));
  Item * it = end(l);
  while (it != NULL) {
    fprintf(f, "%2d (%2d) - ", num(it), val(it));
    it = prev(it);
  }
  fprintf(f, "\n");
}
コード例 #21
0
 static void close(T& t, Sink& snk, BOOST_IOS::openmode which)
 {
     typedef typename category_of<T>::type category;
     const bool in =  is_convertible<category, input>::value &&
                     !is_convertible<category, output>::value;
     if (in == (which == BOOST_IOS::in)) {
         non_blocking_adapter<Sink> nb(snk);
         t.close(nb);
     }
 }
コード例 #22
0
void byte_buffer::reserve( const int sz ) {
	if ( block::refcount( _block ) == 1 
		&& sz < static_cast<int>(capacity())) {
		return;
	}	
	byte_buffer nb( sz );
	if ( _block != nullptr ) {
		nb.write( rd_ptr() , length() );
	}
	swap( nb );
}
コード例 #23
0
ファイル: list.c プロジェクト: MFreeze/TER-Master1-Preflots
// {{{ copyList
List * copyList(List * l) {
  List * res = allocList();
  if (nb(l) !=0) {
    Item * it = begin(l);
    while (it != NULL) {
      pushTail(res, num(it), val(it));
      it = next(it);
    }
  }
  return res;    
}
コード例 #24
0
ファイル: groupCutManager.cpp プロジェクト: pigoblock/TFYP
void groupCutManager::loadVoxelArray()
{
	// index of voxel start from left down to right up
	// NX
	// Hash function: idx = i*NX*NY + j*NY + k
	std::vector<int> voxelHash;
	voxelHash.resize(NumXYZ[0] * NumXYZ[1] * NumXYZ[2]);
	std::fill(voxelHash.begin(), voxelHash.end(), -1);

	std::vector<octreeSNode*> *leaves = &m_octree->leaves;
	boxes.resize(leaves->size());
	for (int i = 0; i < leaves->size(); i++)
	{
		octreeSNode* node = leaves->at(i);
		// List
		voxelBox newBox(node->leftDownf, node->rightUpTight);
		Vec3i xyzIdx = hashTable.getVoxelCoord(newBox.center);
		newBox.xyzIndex = xyzIdx;

		boxes[i] = newBox;

		// Hash
		int hashF = xyzIdx[2] * NumXYZ[0] * NumXYZ[1] + xyzIdx[1] * NumXYZ[0] + xyzIdx[0];

		voxelHash[hashF] = i;
		node->idxInLeaf = i;
	}

	hashTable.voxelHash = voxelHash;

	// neighbor information
	// neighbor
	neighborVoxel.resize(boxes.size());

	for (int i = 0; i < NumXYZ[0]; i++){
		for (int j = 0; j < NumXYZ[1]; j++){
			for (int k = 0; k < NumXYZ[2]; k++){
				int idx = hashTable.getBoxIndexFromVoxelCoord(Vec3i(i, j, k));
				if (idx != -1){
					for (int xyz = 0; xyz < 3; xyz++){
						Vec3i nb(i, j, k);
						nb[xyz] ++;

						int idxN = hashTable.getBoxIndexFromVoxelCoord(nb);
						if (idxN != -1 && idx != idxN){
							neighborVoxel[idx].push_back(idxN);
							neighborVoxel[idxN].push_back(idx);
						}
					}
				}
			}
		}
	}
}
コード例 #25
0
    osmium::memory::Buffer create_testdata() {
        osmium::memory::Buffer buffer(1000);

        {
            osmium::builder::NodeBuilder nb(buffer);
            nb.add_user("foo");
        }
        buffer.commit();

        return buffer;
    }
コード例 #26
0
ファイル: graph.cpp プロジェクト: afbarnard/libdai
void GraphAL::eraseNode( size_t n ) {
    DAI_ASSERT( n < nrNodes() );
    // Erase neighbor entry of node n
    _nb.erase( _nb.begin() + n );
    // Adjust neighbor entries of nodes
    for( size_t n2 = 0; n2 < nrNodes(); n2++ ) {
        for( size_t iter = 0; iter < nb(n2).size(); ) {
            Neighbor &m = nb(n2, iter);
            if( m.node == n ) {
                // delete this entry, because it points to the deleted node
                nb(n2).erase( nb(n2).begin() + iter );
            } else {
                // update this entry and the corresponding dual of the neighboring node
                if( m.node > n ) 
                    m.node--;
                nb( m.node, m.dual ).dual = iter;
                m.iter = iter++;
            }
        }
    }
}
コード例 #27
0
ファイル: netbans.cpp プロジェクト: SuckerServ/hopmod
void add_ban(const char * addr, bool persist, const char * reason)
{
    netban nb(addr, persist);

    if(nb.is_valid())
    {
        if(find_ban(nb)) return;

        nb.set_reason(reason);
        netbans.push_back(nb);
    }
}
コード例 #28
0
ファイル: mcmesh.cpp プロジェクト: codistmonk/CGoGN
void MCMesh::updateRender()
{
	SelectorDartNoBoundary<PFP::MAP> nb(myMap);
	m_render->initPrimitives<PFP>(myMap, nb, Algo::Render::GL2::LINES);
	m_render->initPrimitives<PFP>(myMap, nb, Algo::Render::GL2::TRIANGLES);

	m_positionVBO->updateData(position);

	bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);

	setParamObject(bb.maxSize(), bb.center().data());
	updateGLMatrices();
}
コード例 #29
0
ファイル: ObsRngDev.cpp プロジェクト: ianmartin/GPSTk
 ObsRngDev::ObsRngDev(
    const double prange,
    const SatID& svid,
    const DayTime& time,
    const ECEF& rxpos,
    const XvtStore<SatID>& eph,
    GeoidModel& gm,
    bool svTime)
    : obstime(time), svid(svid), ord(0), wonky(false)
 {
    computeOrd(prange, rxpos, eph, gm, svTime);
    Geodetic gx(rxpos, &gm);
    NBTropModel nb(gx.getAltitude(), gx.getLatitude(), time.DOYday());
    computeTrop(nb);
 }
コード例 #30
0
ファイル: Tests.hpp プロジェクト: BookmanHan/ThirdScripted
void test_for_NB()
{
    MatrixXd dataset(5,5);
    vector<unsigned> label = {0,0,1,0,1};
    dataset<<1,2,1,1,5, 2,3,0,1,5, 1,0,14,5,0, 5,6,1,0,5, 0,1,6,6,0;
    
    NaiveBayes nb(5,2);
    nb.train(dataset, label, 0.01);
    
    cout<<nb.infer(dataset.row(0))<<endl;
    cout<<nb.infer(dataset.row(1))<<endl;
    cout<<nb.infer(dataset.row(2))<<endl;
    cout<<nb.infer(dataset.row(3))<<endl;
    cout<<nb.infer(dataset.row(4))<<endl;
}