Exemple #1
0
  void dump_grid_range_highlight(const Grid & grid,
				 ssize_t ix0, ssize_t iy0,
				 ssize_t ix1, ssize_t iy1,
				 ssize_t ixhigh, ssize_t iyhigh,
				 FILE * stream)
  {
    PVDEBUG("%zu   %zu   %zu   %zu   %zu   %zu\n",
	    ix0, iy0, ix1, iy1, ixhigh, iyhigh);
    fprintf(stream, " ");
    for(ssize_t ix(ix0); ix <= ix1; ++ix)
      if(ix == ixhigh) fprintf(stream, " ***********");
      else             fprintf(stream, "            ");
    fprintf(stream, " \n");
    ssize_t iy(iy1);
    for(/**/; iy != iy0; --iy){
      const char * high(iy == iyhigh ? "*" : " ");
      linesep(grid, stream, ix0, ix1, 0, " ");
      line1(grid, stream, iy, ix0, ix1, 0, high);
      line2(grid, stream, iy, ix0, ix1, 0, high);
      line3(grid, stream, iy, ix0, ix1, 0, high);
      line4(grid, stream, iy, ix0, ix1, 0, high);
    }
    const char * high(iy == iyhigh ? "*" : " ");
    linesep(grid, stream, ix0, ix1, 0, " ");
    line1(grid, stream, iy, ix0, ix1, 0, high);
    line2(grid, stream, iy, ix0, ix1, 0, high);
    line3(grid, stream, iy, ix0, ix1, 0, high);
    line4(grid, stream, iy, ix0, ix1, 0, high);
    linesep(grid, stream, ix0, ix1, 0, " ");
    fprintf(stream, " ");
    for(ssize_t ix(ix0); ix <= ix1; ++ix)
      if(ix == ixhigh) fprintf(stream, " ***********");
      else             fprintf(stream, "            ");
    fprintf(stream, " \n");
  }
//Not used for the time being
void Simulation::debug()
{
	float sum = 0, sump = 0;
	for(int i = 0; i < N; i++)
		for(int j = 0; j < N; j++)
			for(int k = 0; k < N; k++)
			{
				sum += dens[ix(i, j, k)];
				sump += dens_prev[ix(i, j, k)];
			}
	cout<<"sum/prev: "<<sum<<" "<<sump<<endl;
}
Exemple #3
0
  static void line2(const Grid & grid, FILE * stream,
		    ssize_t iy, ssize_t ix0, ssize_t ix1,
		    const char * prefix, const char * high)
  {
    if(0 != high) fprintf(stream, high);
    if(0 != prefix) fprintf(stream, prefix);
    shared_ptr<GridCSpace const> const cspace(grid.GetCSpace());
    for(ssize_t ix(ix0); ix <= ix1; ++ix){
      shared_ptr <GridNode const> node(grid.GetNode(ix, iy));
      if ( ! node) {
	fprintf(stream, "|      ");
	fprintf(stream, "|      ");
      }
      else {
	const flag_t flag(cspace->GetFlag(node->vertex));
	if(NONE == flag)
	  fprintf(stream, "|      ");
	else
	  fprintf(stream, "|%5s ", flag_name(flag));
	const double rhs(cspace->GetRhs(node->vertex));
	if(infinity == rhs)
	  fprintf(stream, "infty");
	else if(huge <= rhs)
	  fprintf(stream, "huge ");
	else
	  fprintf(stream, "%5.2f", rhs);
      }
    }
    if(0 != high) fprintf(stream, "|%s\n", high);
    else          fprintf(stream, "|\n");
  }
Exemple #4
0
  static void line1(const Grid & grid, FILE * stream,
		    ssize_t iy, ssize_t ix0, ssize_t ix1,
		    const char * prefix, const char * high)
  {
    if(0 != high) fprintf(stream, high);
    if(0 != prefix) fprintf(stream, prefix);
    shared_ptr<GridCSpace const> const cspace(grid.GetCSpace());
    for(ssize_t ix(ix0); ix <= ix1; ++ix){
      shared_ptr <GridNode const> node(grid.GetNode(ix, iy));
      if ( ! node) {
	fprintf(stream, "|      ");
	fprintf(stream, "|      ");
      }
      else {
	const double meta(cspace->GetMeta(node->vertex));
	if(infinity == meta)
	  fprintf(stream, "|infty ");
	else if(huge <= meta)
	  fprintf(stream, "|huge  ");
	else
	  fprintf(stream, "|%5.2f ", meta);
	const double value(cspace->GetValue(node->vertex));
	if(infinity == value)
	  fprintf(stream, "infty");
	else if(huge <= value)
	  fprintf(stream, "huge ");
	else
	  fprintf(stream, "%5.2f", value);
      }
    }
    if(0 != high) fprintf(stream, "|%s\n", high);
    else          fprintf(stream, "|\n");
  }
Exemple #5
0
	void Mapper2d::
	InitAddmask()
	{
		m_addmask_x0 = 0;
		m_addmask_y0 = 0;
		m_addmask_x1 = 0;
		m_addmask_y1 = 0;
		const ssize_t offset(static_cast<ssize_t>(ceil(grown_safe_distance / gridframe.Delta())));
    for (ssize_t ix(-offset); ix <= offset; ++ix) {
      const double x2(sqr(ix * gridframe.Delta()));
      for (ssize_t iy(-offset); iy <= offset; ++iy) {
				int const cost(ComputeCost(sqrt(sqr(iy * gridframe.Delta()) + x2)));
				if (cost > m_travmap->freespace) {
					m_addmask.insert(make_pair(index_t(ix, iy), cost));
					// update the addmask's bounding box
					if (ix < m_addmask_x0)
						m_addmask_x0 = ix;
					if (ix > m_addmask_x1)
						m_addmask_x1 = ix;
					if (iy < m_addmask_y0)
						m_addmask_y0 = iy;
					if (iy > m_addmask_y1)
						m_addmask_y1 = iy;
				}
			}
		}
	}
Exemple #6
0
  static void line3(const Grid & grid, FILE * stream,
		    ssize_t iy, ssize_t ix0, ssize_t ix1,
		    const char * prefix, const char * high)
  {
    if(0 != high) fprintf(stream, high);
    if(0 != prefix) fprintf(stream, prefix);
    shared_ptr<GridCSpace const> const cspace(grid.GetCSpace());
    for(ssize_t ix(ix0); ix <= ix1; ++ix){
      shared_ptr <GridNode const> node(grid.GetNode(ix, iy));
      if ( ! node) {
	fprintf(stream, "|      ");
	fprintf(stream, "|      ");
      }
      else {
	const vertex_t vertex(node->vertex);
	if( ! (OPEN & cspace->GetFlag(vertex)))
	  fprintf(stream, "|      ");
	else if(cspace->GetRhs(vertex) < cspace->GetValue(vertex))
	  fprintf(stream, "|lower ");
	else if(cspace->GetRhs(vertex) > cspace->GetValue(vertex))
	  fprintf(stream, "|raise ");
	else
	  fprintf(stream, "|r==v? ");
	fprintf(stream, "%5zu", node->vertex);
      }
    }
    if(0 != high) fprintf(stream, "|%s\n", high);
    else          fprintf(stream, "|\n");
  }
Exemple #7
0
	void Mapper2d::
	ClearAllObstacles(draw_callback * cb)
	{
		for (ssize_t ix(m_travmap->GetXBegin()); ix < m_travmap->GetXEnd(); ++ix)
			for (ssize_t iy(m_travmap->GetYBegin()); iy < m_travmap->GetYEnd(); ++iy)
				if ( ! m_travmap->IsFree(ix, iy))
					m_travmap->SetFree(ix, iy, cb);
	}
Exemple #8
0
 forceinline bool
 excludes(const View& x, const IntSet& s) {
   if ((x.max() < s.min()) || (x.min() > s.max()))
     return true;
   ViewRanges<View> ix(x);
   IntSetRanges is(s);
   return Iter::Ranges::disjoint(ix,is);
 }
Exemple #9
0
/// Give the count at a given bin index.
int colvarbias_abf::bin_count(int bin_index) {
  if (bin_index < 0 || bin_index >= bin_num()) {
    cvm::error("Error: Tried to get bin count from invalid bin index "+cvm::to_str(bin_index));
    return -1;
  }
  std::vector<int> ix(1,(int)bin_index);
  return samples->value(ix);
}
Exemple #10
0
 forceinline bool
 includes(const View& x, const IntSet& s) {
   if ((x.max() < s.min()) || (x.min() > s.max()))
     return false;
   ViewRanges<View> ix(x);
   IntSetRanges is(s);
   return Iter::Ranges::subset(ix,is);
 }
Exemple #11
0
/// Give the gradient at a given bin index.
cvm::real colvarbias_abf::bin_gradient(int bin_index) {
  if (bin_index < 0 || bin_index >= bin_num()) {
    cvm::error("Error: Tried to get bin gradient from invalid bin index "+cvm::to_str(bin_index));
    return -1;
  }
  std::vector<int> ix(1,bin_index);
  return -gradients->value(ix)/samples->value(ix);
}
Exemple #12
0
 forceinline bool
 undecided(const View& x, const IntSet& s) {
   if ((x.max() < s.min()) || (x.min() > s.max()))
     return false;
   ViewRanges<View> ix(x);
   IntSetRanges is(s);
   return Iter::Ranges::compare(ix,is) == Iter::Ranges::CS_NONE;
 }
Exemple #13
0
/// Give the free energy from grid edge 0 to current position.
cvm::real colvarbias_abf::delta_free_energy(cvm::real x) {
  // Get the home bin.
  int home = gradients->value_to_bin_scalar(x, 0);
  // There is nothing to integrate if x is before the start of the grid.
  if (home < 0) return 0.0;
  // Get the distance that the position is beyond the home bin.
  cvm::real home_x = (cvm::real)gradients->bin_to_value_scalar(home, 0) - 0.5*gradients->widths[0];
  cvm::real beyond = x - home_x;
  // The adaptive biasing force is not applied beyond the end of the grid.
  if (home >= gradients->number_of_points(0)) {
    home = gradients->number_of_points(0)-1;
    beyond = gradients->widths[0];
  }
  
  // Integrate the gradient up to the home bin.
  cvm::real sum = 0.0;
  for (int i = 0; i < home; i++) {
    std::vector<int> ix(1,i);

    // Include the full_samples factor if necessary.
    int count = samples->value(ix);
    // This factor accounts for the effect of full_samples on the applied force
    cvm::real fact = 1.0;
    if ( count < full_samples ) {
      fact = (count < min_samples) ? 0.0 :
        (cvm::real(count - min_samples)) / (cvm::real(full_samples - min_samples));
    }
    // Add the contribution of this bin.
    if (count > 0) sum += fact*gradients->value(ix)/count*gradients->widths[0];
  }

  // Integrate the gradient from the start of the home bin up to x.
  std::vector<int> ix(1,home);
  int count = samples->value(ix);
  // This factor accounts for the effect of full_samples on the applied force
  cvm::real fact = 1.0;
  if ( count < full_samples ) {
    fact = (count < min_samples) ? 0.0 :
      (cvm::real(count - min_samples)) / (cvm::real(full_samples - min_samples));
  }
  // Add the contribution of the last piece of fractional bin.
  if (count > 0) sum += fact*gradients->value(ix)/count*beyond;
  
  return sum;
}
Exemple #14
0
    array(index_t xsize, index_t ysize, const value_t & init)
      : data(new inner_t[xsize])
    {
      for (index_t ix(0); ix < xsize; ++ix) {
	data[ix].reset(new value_t[ysize]);
        for(index_t iy(0); iy < ysize; ++iy)
	  data[ix][iy] = init;
      }
    }
Exemple #15
0
void boid()
{
    if (cond) {
#ifdef URANIUM_PU36
        ux();
#else
        ix();
#endif
    }
}
Exemple #16
0
//REV: This adds a "1" to each category as it is sampled hahahaha. So if I only choose 1...
std::vector<size_t> multinomial_sample( const std::vector<float64_t>& p, const size_t& nsamples, std::default_random_engine& rand_gen )
{
  //p.size() is 3 (i.e. same as nCR in his case, i.e. same as ncat
  //1 is n.
  
  //Call binomial sample multiple times. As in PDFLIB.
  //All probabilities are [0, 1]
  float64_t ptot = 0.0;
  for( size_t i = 0; i < p.size()-1; ++i )
  {
    if( std::isnan( p[i] ) || std::isinf( p[i]) )
      {
	fprintf(stderr, "ERROR in multinomial sample: One or more of the probabilities passed is NAN or INF\n");
	exit(1);
      }
    ptot = ptot + p[i];
  }
  
  if ( 0.99999 < ptot ) 
  {
    std::cerr << std::endl;
    std::cerr << "multinomial sample: fatal error." << std::endl;
    std::cerr << "  1.0 < Sum of P()." << std::endl;
    exit ( 1 );
  }
  
  size_t ntot = nsamples;
  ptot = 1.0;

  std::vector<size_t> ix( p.size(), 0 );

  //Make binomial distribution.
  
  
  for( size_t icat = 0; icat < (ix.size() - 1); ++icat )
    {
      float64_t prob = p[icat] / ptot;
      std::binomial_distribution<size_t> bdist( ntot, prob );
      ix[icat] = bdist(rand_gen);
      //ntot = ntot - ix[icat];
      //if ( ntot <= 0 )
      if( ix[icat] >= ntot )
	{
	  return ix;
	}
      ntot -= ix[icat]; //only do this if it would be >0 (these are unsigned ints)
      ptot -= p[icat];
    }

  //Final one is that...yea. Hm, I think probabilities are all messed up, I need to shift them over. Final one is assumed to be distance to 1.0...
  ix[ ix.size()-1 ] = ntot;

  return ix;
} //end multinomial.
Exemple #17
0
  void dump_probabilities(const array<double> &prob,
			  size_t x0, size_t y0, size_t x1, size_t y1,
			  FILE * stream)
  {
    for(size_t iy(y1); iy >= y0; --iy){
      for(size_t ix(x0); ix <= x1; ++ix)
	fprintf(stream, "+-----");
      fprintf(stream, "+\n");
      for(size_t ix(x0); ix <= x1; ++ix){
	const double value(prob[ix][iy]);
	if(value < 0)           fprintf(stream, "| < 0 ");
	else if(value > 1)      fprintf(stream, "| > 1 ");
	else if(value < 1e-9)   fprintf(stream, "|tiny ");
	else if(value > 1-1e-9) fprintf(stream, "| one ");
	else                    fprintf(stream, "|%5.2f", value);
      }
      fprintf(stream, "|\n");
    }
    for(size_t ix(x0); ix <= x1; ++ix)
      fprintf(stream, "+-----");
    fprintf(stream, "+\n");
  }
Exemple #18
0
/*-----------------------------------------------------------Attlist::replace-+
| Make a deep copy of an attribute, and replace it in the attribute list.     |
| Note: pAttSource *must* belong to the list!                                 |
+----------------------------------------------------------------------------*/
Attribute * Attlist::replace(Attribute const * pAttSource)
{
    Attribute * pAtt = new Attribute(pAttSource->key(), pAttSource->dclv);
    if (pAtt) {
        if (!*pAtt) {
            delete pAtt;
            pAtt = 0;
        } else {
            if (!replaceAt(pAtt, ix(pAttSource))) pAtt = 0;
        }
    }
    return pAtt;
}
Exemple #19
0
 forceinline TakesStatus
 takes(const View& x, const IntSet& s) {
   if ((x.max() < s.min()) || (x.min() > s.max()))
     return TS_NO;
   ViewRanges<View> ix(x);
   IntSetRanges is(s);
   switch (Iter::Ranges::compare(ix,is)) {
   case Iter::Ranges::CS_SUBSET: return TS_YES;
   case Iter::Ranges::CS_DISJOINT: return TS_NO;
   case Iter::Ranges::CS_NONE: return TS_MAYBE;
   default: GECODE_NEVER;
   }
   return TS_MAYBE;
 }
Exemple #20
0
  static void linesep(const Grid & grid, FILE * stream,
		      ssize_t ix0, ssize_t ix1,
		      const char * prefix, const char * high)
  {
    char * line;
    if(grid.GetNeighborhood() == Grid::SIX) line = "+-----+-----";
    else                                    line = "+-----------";
    if(0 != high)   fprintf(stream, high);
    if(0 != prefix) fprintf(stream, prefix);
    for(ssize_t ix(ix0); ix <= ix1; ++ix)
      fprintf(stream, line);
    if(0 != high) fprintf(stream, "+%s\n", high);
    else          fprintf(stream, "+\n");
  }
Exemple #21
0
template<class T1, class T2> bool Skeleton_fast<T1,T2>::isInSkel( const clipper::Xmap<T1>& xskl, const clipper::Coord_grid& c ) const
{
  int dx, dy, dz;

  /* Fill the cube with flags Each non-rejected grid point is given
     its own number. We will the reduce these to 'region numbers', so
     that each connected region takes the value of one of its
     neighbours. (A performace benefit is gaine from allocating these
     in decreasing order). */
  clipper::Xmap_base::Map_reference_index ix( xskl, c );
  for ( dz = 0; dz < 3; dz++ )
    for ( dy = 0; dy < 3; dy++ )
      for ( dx = 0; dx < 3; dx++ )
	cube[dx][dy][dz] = xskl.get_data( ix.index_offset( dx-1, dy-1, dz-1 ) );
  // the centre cannot be  a link - set to zero
  cube[1][1][1] = 0;

  /* The following is a simple optimisation which could be omitted.
     We count the number of neightbours or the centre point which are
     not yet eliminated from the skeleton. If this is more than 14 or
     less than 1, then this pint cannot be part of the skeleton. */
  int nneigh = 0;
  for ( int i = 0; i < neigh.size(); i++ ) {
    dx = neigh[i].u()+1;
    dy = neigh[i].v()+1;
    dz = neigh[i].w()+1;
    if ( cube[dx][dy][dz] > 0 ) nneigh++;
  }
  if ( nneigh > 14 ) return false;
  if ( nneigh < 1 ) return false;

  /* Now alter flags for one connected region. If all flags are
     altered, then this point is not part of the skeleton. */
  for ( int i = 0; i < neigh.size(); i++ ) {
    dx = neigh[i].u()+1;
    dy = neigh[i].v()+1;
    dz = neigh[i].w()+1;
    if ( cube[dx][dy][dz] > 0 ) break;
  }
  flood_cube( dx, dy, dz );
  bool res2 = false;
  for ( int i = 0; i < neigh.size(); i++ ) {
    dx = neigh[i].u()+1;
    dy = neigh[i].v()+1;
    dz = neigh[i].w()+1;
    if ( cube[dx][dy][dz] > 0 ) return true;
  }
  return false;
}
Exemple #22
0
  static void line4(const Grid & grid, FILE * stream,
		    ssize_t iy, ssize_t ix0, ssize_t ix1,
		    const char * prefix, const char * high)
  {
    if(0 != high) fprintf(stream, high);
    if(0 != prefix) fprintf(stream, prefix);
    for(ssize_t ix(ix0); ix <= ix1; ++ix){
      shared_ptr <GridNode const> node(grid.GetNode(ix, iy));
      if ( ! node)
	fprintf(stream, "|           ");
      else
	fprintf(stream, "| (%3zu, %3zu)", ix, iy);
    }
    if(0 != high) fprintf(stream, "|%s\n", high);
    else          fprintf(stream, "|\n");
  }
Exemple #23
0
void SSfind::prep_xmap( const clipper::Xmap<float>& xmap, const double radius )
{
  // make a 1-d array of gridded density values covering ASU+border
  grid = xmap.grid_sampling();
  grrot = xmap.operator_orth_grid().rot();
  clipper::Grid_range gr0 = xmap.grid_asu();
  clipper::Grid_range gr1( xmap.cell(), xmap.grid_sampling(), radius );
  mxgr = clipper::Grid_range( gr0.min()+gr1.min(), gr0.max()+gr1.max() );
  mapbox = std::vector<float>( mxgr.size(), 0.0 );

  // make 1d list of densities
  clipper::Xmap<float>::Map_reference_index ix( xmap );
  for ( int i = 0; i < mapbox.size(); i++ ) {
    ix.set_coord( mxgr.deindex( i ) );
    mapbox[i] = xmap[ix];
  }
}
void CAdjacent::generateTriangles(ushort*idx,uint count){

	Triangle t;
	for (short i=0;i<count;i+=3)
	{
		Index3 ix(idx[i],idx[i+1],idx[i+2]);
		ushort xyz[3]={0};
		getEdgesIncr(ix,xyz);
		uint h=HashEdge(xyz[0],xyz[1]); 
		t.e1=m_edgeIDMap[h];
		h=HashEdge(xyz[0],xyz[2]); 
		t.e2=m_edgeIDMap[h];
		h=HashEdge(xyz[1],xyz[2]); 
		t.e3=m_edgeIDMap[h];

		m_triangles.push_back(t);
	}
	int ent=0;
	for (int i=0;i<m_triangles.size();i++)
	{
		Triangle &t=m_triangles[i];
		for (int j=i+1;j<m_triangles.size();j++)
		{
			Triangle &t2=m_triangles[j];
			if( t.e1==t2.e1 || 
				t.e1==t2.e2 || 
				t.e1==t2.e3 || 

				t.e2==t2.e1 || 
				t.e2==t2.e2 || 
				t.e2==t2.e3 ||

				t.e3==t2.e1 || 
				t.e3==t2.e2 || 
				t.e3==t2.e3  )
			{
				m_TriMap[i].insert(j);
				m_TriMap[j].insert(i);
				ent++;
			}
		}
	}
}
void FriendsWidget::paintExtBackFace(QPainter *p,
     const QStyleOptionGraphicsItem *e,
     QWidget *)
{
    qDebug() << "drawing back face" << __PRETTY_FUNCTION__ << __LINE__;
    QRectF r = e->exposedRect;

    p->setCompositionMode(QPainter::CompositionMode_Source);
    p->fillRect(rect(), Qt::transparent);

    p->drawImage(QRect(0, 0, m_main_bg.width(), m_main_bg.height()), m_main_bg);
    p->setCompositionMode(QPainter::CompositionMode_SourceOver);
    p->setBackgroundMode(Qt::TransparentMode);
    p->save();
    p->setRenderHint(QPainter::SmoothPixmapTransform);

    if (mShade == 0) {
        p->drawPixmap(m_main_bg.rect(), QPixmap().fromImage(m_main_bg));
        mShade = 1;
    }

    p->restore();

    p->setRenderHints(QPainter::SmoothPixmapTransform |
         QPainter::Antialiasing |
         QPainter::HighQualityAntialiasing);

    p->setPen(QColor(255, 255, 255));
    p->setFont(QFont("Bitstream Charter", 10, QFont::Bold));
    p->drawText(QRect(60, 5, 100, 64), Qt::AlignCenter, "Plexy-Friends");

    QMapIterator<QString, QGraphicsItem *> i(mItems);
    while (i.hasNext()) {
        i.next();
             (i.value())->hide();
    }

    QMapIterator<QString, QGraphicsItem *> ix(mActions);
    while (ix.hasNext()) {
        ix.next();
             (ix.value())->show();
    }
}
Exemple #26
0
Vector4f ColorGradient::GetColorWOErrorChecking(float f) const
{
    f = Mathf::Clamp(f, OrderedNodes[0].Position, OrderedNodes[OrderedNodes.size() - 1].Position);

	//Edge cases. Choose a random node side if the given value sits right on a Node.
	if (f == OrderedNodes[0].Position)
	{
		return ((rand() % 9) < 5) ? OrderedNodes[0].LeftColor : OrderedNodes[0].RightColor;
	}
	if (f == OrderedNodes[OrderedNodes.size() - 1].Position)
	{
		return ((rand() % 9) < 5) ? OrderedNodes[OrderedNodes.size() - 1].LeftColor : OrderedNodes[OrderedNodes.size() - 1].RightColor;
	}

	//Count to the first node above the given position.
	int index;
	for (index = OrderedNodes.size() - 1; OrderedNodes[index].Position > f && index > 0; --index) { }

	//Lerp between the two color values.

	Vector4f leftCol = OrderedNodes[index].RightColor;
	Vector4f rightCol = OrderedNodes[index + 1].LeftColor;
	Interval posInt(OrderedNodes[index].Position, OrderedNodes[index + 1].Position, 0.001f, true, true);
	Vector4b needReversed((unsigned char)(leftCol.x > rightCol.x), leftCol.y > rightCol.y, leftCol.z > rightCol.z, leftCol.w > rightCol.w);
	float ref = posInt.Reflect(f);
	float rx = (needReversed.x) ? ref : f,
		  ry = (needReversed.y) ? ref : f,
		  rz = (needReversed.z) ? ref : f,
		  rw = (needReversed.w) ? ref : f;
	Interval ix(leftCol.x, rightCol.x, 0.001f, true, true),
			 iy(leftCol.y, rightCol.y, 0.001f, true, true),
			 iz(leftCol.z, rightCol.z, 0.001f, true, true),
			 iw(leftCol.w, rightCol.w, 0.001f, true, true);
	rx = posInt.MapValue(ix, rx);
	ry = posInt.MapValue(iy, ry);
	rz = posInt.MapValue(iz, rz);
	rw = posInt.MapValue(iw, rw);
	Vector4f ret(rx, ry, rz, rw);

	return ret;
}
Node* TreeBuilder::CreateChild( NodeType::E nt, bool bUseTerminal, bool bUseNode, unsigned int nDepth, unsigned int nMaxDepth ) {

    /*               | !depth==max | depth==max |
      *               |-------------|------------|
      * !term * !node | illegal     | illegal    |
      *  term * !node | term        | term       |
      * !term *  node | node        | term       |
      *  term *  node | node, term  | term       |
      */

  Node* node( 0 );

  // determine what type of Node to Construct

  FactoryType::E ft( FactoryType::All ); // default to mixture of nodes and terminals

  if ( nDepth == nMaxDepth ) {
    ft = FactoryType::Terminals; // force terminal on last level
  }
  else {
    if ( ( 1 == nDepth ) && ( nDepth < nMaxDepth ) ) {
      ft = FactoryType::Nodes; // don't use terminal on first node, if more levels available
    }
    else {
      if ( !bUseTerminal ) {
        ft = FactoryType::Nodes;  // make sure most levels are nodes
      }
    }
  }

  // choose factory based upon factors computed above
  vNodeFactory_t& vFactory( *m_rNodeFactories[ nt ][ ft ] );

  // construct the node
  boost::random::uniform_int_distribution<unsigned int> dist( 0, vFactory.size() - 1 );
  vNodeFactory_t::size_type ix( dist( m_rng ) );
  node = vFactory[ ix ]();

  return node;
}
Exemple #28
0
/*! A log-likelihood FFFear search is performed for the target in the given map.
  \param resultscr The best scores.
  \param resultrot The best rotations.
  \param resulttrn The best translations.
  \param xmap The map to search.
  \param rtops The oprientations to search. */
void LLK_map_target::search( clipper::Xmap<float>& resultscr, clipper::Xmap<int>& resultrot, clipper::Xmap<int>& resulttrn, const clipper::Xmap<float>& xmap, const std::vector<clipper::RTop_orth>& rtops ) const
{
  // set up results
  const clipper::Spacegroup&    spgr = xmap.spacegroup();
  const clipper::Cell&          cell = xmap.cell();
  const clipper::Grid_sampling& grid = xmap.grid_sampling();
  resultscr.init( spgr, cell, grid );
  resultrot.init( spgr, cell, grid );
  resulttrn.init( spgr, cell, grid );
  resultscr = 1.0e20;

  // now search for ML target in each orientation in turn
  clipper::Xmap<float> resultp1( clipper::Spacegroup::p1(), cell, grid );
  clipper::Xmap<float>::Map_reference_index i1(resultp1);
  clipper::Xmap<float>::Map_reference_coord ix(resultscr);

  // set up z scoring
  clipper::FFFear_fft<float> srch( xmap );
  clipper::NX_operator nxop( xmap, target, rtops[0] );
  srch( resultp1, target, weight, nxop );
  clipper::Map_stats zstats( resultp1 );

  // loop over orientations
  for ( int op = 0; op < rtops.size(); op++ ) {
    // do the fffear search
    clipper::NX_operator nxop( xmap, target, rtops[op].inverse() );
    srch( resultp1, target, weight, nxop );

    // store best scores
    for ( i1 = resultp1.first(); !i1.last(); i1.next() ) {
      ix.set_coord( i1.coord() );
      float score = ( resultp1[i1] - zstats.mean() ) / zstats.std_dev();
      if ( score < resultscr[ix] ) {
	resultscr[ix] = score;
	resultrot[ix] = op;
	resulttrn[ix] = grid.index( i1.coord() );
      }
    }
  }
}
Exemple #29
0
  /** \todo this implementation is a bit brute force... */
  void NF1::
  SetLocalDisk(GridFrame const & gframe,
	       grid_t & grid, position_t center,
	       double radius, double value)
  {
    index_t index(gframe.LocalIndex(center));
    if(grid.ValidIndex(index))
      grid[index] = value;
    const index_t
      minidx(gframe.LocalIndex(center.v0 - radius, center.v1 - radius));
    const index_t
      maxidx(gframe.LocalIndex(center.v0 + radius, center.v1 + radius));
    const double radius2(sqr(radius));
    for(ssize_t ix(minidx.v0); ix < maxidx.v0; ++ix)
      for(ssize_t iy(minidx.v1); iy < maxidx.v1; ++iy)
	if(grid.ValidIndex(ix, iy)){
	  const position_t point(gframe.LocalPoint(ix, iy) - center);
	  const double r2(sqr(point.v0) + sqr(point.v1));
	  if(r2 <= radius2)
	    grid[ix][iy] = value;
	}
  }
void FriendsWidget::paintExtDockFace(QPainter *p,
     const QStyleOptionGraphicsItem *e,
     QWidget *)
{
    qDebug() << "drawing dock" << __PRETTY_FUNCTION__ << __LINE__;
    p->setRenderHints(QPainter::SmoothPixmapTransform |
         QPainter::Antialiasing |
         QPainter::HighQualityAntialiasing);

    p->save();
    QMapIterator<QString, QGraphicsItem *> i(mItems);
    while (i.hasNext()) {
        i.next();
             (i.value())->hide();
    }

    QMapIterator<QString, QGraphicsItem *> ix(mActions);
    while (ix.hasNext()) {
        ix.next();
             (ix.value())->hide();
    }
    p->restore();
}