예제 #1
0
파일: smsc.c 프로젝트: grobe0ba/plan9front
static int
miird(Dev *d, int idx)
{
	while(rr(d, MIIaddr) & MIIbusy)
		;
	wr(d, MIIaddr, PHYinternal<<11 | idx<<6 | MIIread);
	while(rr(d, MIIaddr) & MIIbusy)
		;
	return rr(d, MIIdata);
}
예제 #2
0
파일: smsc.c 프로젝트: grobe0ba/plan9front
static void
miiwr(Dev *d, int idx, int val)
{
	while(rr(d, MIIaddr) & MIIbusy)
		;
	wr(d, MIIdata, val);
	wr(d, MIIaddr, PHYinternal<<11 | idx<<6 | MIIwrite);
	while(rr(d, MIIaddr) & MIIbusy)
		;
}
예제 #3
0
파일: mathlib.c 프로젝트: gke/UAVP
// OK
void MathMultU8x8(void)	
{
    counter = 8;
    nilrval = 0;
    W = nilgarg1.low8;
    do  {
        nilgarg2.low8 = rr( nilgarg2.low8);
        if (Carry)
            nilrval.high8 += W;
        nilrval = rr( nilrval);
        counter = decsz(counter);
    } while (1);
	return;
}
예제 #4
0
unordered_map<std::string, int> LoadParticles::read_xyzHeader(std::fstream &data) {
  string line;

  // Reading the number of particles
  std::getline(data, line);

  m_nParticles = stoi(line);

  // Reading the comments
  // This program follows a convention that the comments
  // in a xyz-file must name the variables.
  std::getline(data, line);
  boost::regex rr("([A-Za-z_]+)");
  boost::sregex_iterator next(line.begin(), line.end(), rr);
  boost::sregex_iterator end;

  unordered_map<std::string, int> parameters;

  int position = 0;
  while (next != end) {
    boost::smatch match = *next;
    parameters[match.str()] = position;
    position++;
    next++;
  }

  return parameters;
}
예제 #5
0
    cv::Mat extract_region(const cv::Mat& m, const cv::RotatedRect& ir, bool flipped, int interpolation, int bordertype, int value){
        cv::Mat M, enlarged, rotated, cropped;
        cv::Rect margins;
        cv::RotatedRect pos_in_enlarged;
        boost::tie(margins,pos_in_enlarged) = required_padding(m, ir);
        cv::copyMakeBorder(m, enlarged, 
                margins.y, margins.height, margins.x, margins.width, 
                bordertype, value);

        cv::Size rect_size = pos_in_enlarged.size;
        float angle = pos_in_enlarged.angle;
        if(angle == 0.){
            cv::Rect rr(
                    pos_in_enlarged.center.x - pos_in_enlarged.size.width/2,
                    pos_in_enlarged.center.y - pos_in_enlarged.size.height/2,
                    pos_in_enlarged.size.width, pos_in_enlarged.size.height);
            cropped = enlarged(rr);
        }
        else{
            if (pos_in_enlarged.angle < -45.) {
                angle += 90.0;
                std::swap(rect_size.width, rect_size.height);
            }
            M = cv::getRotationMatrix2D(pos_in_enlarged.center, angle, 1.0);
            cv::warpAffine(enlarged, rotated, M, enlarged.size(), interpolation);
            cv::getRectSubPix(rotated, rect_size, pos_in_enlarged.center, cropped);
            assert(cropped.rows == cropped.cols);
        }
        if(flipped)
            cv::flip(cropped, cropped, 1);
        if(!cropped.isContinuous())
            cropped = cropped.clone();
        return cropped;
    }
int main(int argc, const char** argv) {
  Options options;
  if (!options.parse(argc, argv))
    return 1;

  radical::RadiometricResponse rr(options.r_response);
  auto min_radiance = rr.inverseMap(cv::Vec3b(0, 0, 0));
  auto max_radiance = rr.inverseMap(cv::Vec3b(255, 255, 255));

  std::cout << "Loaded radiometric response from file \"" << options.r_response << "\"" << std::endl;
  std::cout << "Irradiance range: " << min_radiance << " - " << max_radiance << std::endl;

  auto plot = utils::plotRadiometricResponse(rr);

  if (options.save) {
    auto output = options.r_response + ".png";
    cv::imwrite(output, plot);
    std::cout << "Saved radiometric response visualization to file \"" << output << "\"" << std::endl;
  } else {
    cv::imshow("Radiometric response", plot);
    cv::waitKey(-1);
  }

  return 0;
}
예제 #7
0
RationalNumber RationalNumber::operator/(const int i) const {
	RationalNumber ri(i);
	RationalNumber rr(*this);
	rr /= ri;
	rr.normalize();
	return rr;
}
예제 #8
0
파일: Dialog.cpp 프로젝트: KB3NZQ/hexedit4
LRESULT CHexFileDialog::OnPostInit(WPARAM wp, LPARAM lp)
{
	// Set text of "OK" button
	if (!strOKName.IsEmpty())
		SetControlText(IDOK, strOKName);

	// Restore the window position and size
	CRect rr(theApp.GetProfileInt("Window-Settings", strName+"X1", -30000),
			 theApp.GetProfileInt("Window-Settings", strName+"Y1", -30000),
			 theApp.GetProfileInt("Window-Settings", strName+"X2", -30000),
			 theApp.GetProfileInt("Window-Settings", strName+"Y2", -30000));
	if (rr.top != -30000)
		GetParent()->MoveWindow(&rr);  // Note: there was a crash here until we set 8th
									   // param of CFileDialog (bVistaStyle) c'tor to FALSE.

	// Restore the list view display mode (details, report, icons, etc)
	ASSERT(GetParent() != NULL);
	CWnd *psdv  = FindWindowEx(GetParent()->m_hWnd, NULL, "SHELLDLL_DefView", NULL);
	if (psdv != NULL)
	{
		int mode = theApp.GetProfileInt("Window-Settings", strName+"Mode", REPORT);
		psdv->SendMessage(WM_COMMAND, mode, 0);
	}

	return 0;
}
예제 #9
0
void rrtester(int& rrcntr)
{
	extern const int globalWindow;
	extern double k;
	double u[globalWindow], v[globalWindow];
	double rrmean = 0.0, testdiff = 0.0, tempdiff = 0.0;
	const int iters = 200, num = 20;

	cout << "Testing calibration of rr()..." << endl;
	cout << setw(10) << "Expected" << setw(12) << " Actual  " << setw(10) << "Difference" << endl;
	cout << setw(10) << "--------" << setw(12) << " ------  " << setw(10) << "----------" << endl;

	for (int i = 1; i < num; i++)
	{
		u[0] = 0.0;
		v[0] = 1.0 / static_cast<double> (i);
//		stdmpInit(0.0,u,v,w);	// These need to be created from scratch, and follow the older definitions of the functions because they are calling a k = 0 option.
		rrmean = rrInit(u,v,rrcntr);
		for (int j = 0; j < iters; j++)
		{
//			stdmp(0.0,u,v,w,n);
			rrmean += rr(u,v,rrcntr);
		}
		tempdiff = fabs(1.0/static_cast<double> (i) - rrmean/(static_cast<double> (iters + 1)));
		testdiff += tempdiff;
		
		cout << std::fixed << std::setprecision(5) << setw(10) << 1.0/i << setw(10) << rrmean/(iters+1) << setw(12) << std::scientific << std::setprecision(3) << tempdiff << endl;
		rrmean = 0.0;
		rrcntr = 0.0;
	}

	testdiff /= static_cast<double> (num);
	cout << endl;
	cout << "--->  rr() is accurate to within " << std::fixed << testdiff*100 << "% on average." << endl;
}
예제 #10
0
void TestCtcExist::test01() {

    Variable x,y;
    Function f(x,y,1.5*sqr(x)+1.5*sqr(y)-x*y-0.2);

    double prec=1e-05;

    NumConstraint c(f,LEQ);
    CtcExist exist_y(c,y,IntervalVector(1,Interval(-10,10)),prec);
    CtcExist exist_x(c,x,IntervalVector(1,Interval(-10,10)),prec);

    IntervalVector box(1,Interval(-10,10));

    RoundRobin rr(1e-03);
    CellStack stack;
    vector<IntervalVector> sols;

    double right_bound=+0.3872983346072957;

    Solver sx(exist_y,rr,stack);
    sx.start(box);
    sx.next(sols);
    // note: we use the fact that the solver always explores the right
    // branch first
    TEST_ASSERT(sols.back()[0].contains(right_bound));

    sols.clear();
    Solver sy(exist_x,rr,stack);
    sy.start(box);
    sy.next(sols);
    // note: we use the fact that the constraint is symmetric in x/y
    TEST_ASSERT(sols.back()[0].contains(right_bound));

}
예제 #11
0
void directworm(struct wormy *worms, float addx, float addy, float param){ // test directionworm
// change angle randomly within param as max deviation
static float angle=1.0;

xy acc;
angle+=rr(param);
acc.x= cosf(angle*(PI/180.0));
acc.y= sinf(angle*(PI/180.0));


  acc.x=acc.x*worms->speed;
  acc.y=acc.y*worms->speed;
  xy vel=worms->vel;
  vel.x+=acc.x;
  vel.y+=acc.y;
  limit(&vel,worms->maxspeed);
  worms->wloc.x+=vel.x;
  worms->wloc.y+=vel.y;

// when hit boundary slowly change angle back or just reverse with larger deviation
if (worms->wloc.x>worms->boundx || worms->wloc.x<addx ) angle=180.0-angle;//-180.0;
if (worms->wloc.y>worms->boundy || worms->wloc.y<addy ) angle=360.0-angle;//-180.0;a
  
//  checkbound(&worms->wloc,worms->boundx,worms->boundy,addx,addy);
  //  worms->acc=acc;
//  worms->vel=vel;

}
예제 #12
0
파일: pathview.cpp 프로젝트: tumic0/GPXSee
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
{
	if ((_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
	  || !_map) {
		painter->fillRect(rect, Qt::white);
		return;
	}

	qreal scale = mapScale(_zoom);
	QRectF rr(rect.topLeft() * scale, rect.size());
	QPoint tile = mercator2tile(QPointF(rr.topLeft().x(), -rr.topLeft().y()),
	  _zoom);
	QPointF tm = tile2mercator(tile, _zoom);
	QPoint tl = mapToScene(mapFromScene(QPointF(tm.x() / scale,
	  -tm.y() / scale))).toPoint();

	QList<Tile> tiles;
	for (int i = 0; i <= rr.size().width() / Tile::size() + 1; i++) {
		for (int j = 0; j <= rr.size().height() / Tile::size() + 1; j++) {
			tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
		}
	}

	_map->loadTiles(tiles, _plot);

	for (int i = 0; i < tiles.count(); i++) {
		Tile &t = tiles[i];
		QPoint tp(tl.x() + (t.xy().x() - tile.x()) * Tile::size(),
		  tl.y() + (t.xy().y() - tile.y()) * Tile::size());
		painter->drawPixmap(tp, t.pixmap());
	}
}
예제 #13
0
void send_data( char dout )
{
    char i;
#asm
    comf    dout, F                     // invert the bits for sending
#endasm

    RS232_out = LOW;                    // start bit
    delay1bit();

    for ( i = 8; i > 0; i-- )
    {
        dout = rr( dout );
        RS232_out = Carry;
        delay1bit();
    }

    RS232_out = HIGH;                   // stop bit
    delay1bit();
    /*-----------------10/19/2001 12:51PM---------------
     * ## WARNING ## without the nop() after the above
     * function call the code generated for the function
     * call was a GOTO and not a CALL.  The return from
     * this function was also not generated.
     * --------------------------------------------------*/
    nop();
}
예제 #14
0
void QWidget::updateOverlappingChildren() const
{
    if ( overlapping_children != -1 || isSettingGeometry )
	return;

    QRegion r;
    const QObjectList *c = children();
    if ( c ) {
	QObjectListIt it(*c);
	QObject* ch;
	while ((ch=it.current())) {
	    ++it;
	    if ( ch->isWidgetType() && !((QWidget*)ch)->isTopLevel() ) {
		QWidget *w = (QWidget *)ch;
		if ( w->isVisible() ) {
		    QRegion rr( w->req_region );
		    QRegion ir = r & rr;
		    if ( !ir.isEmpty() ) {
			overlapping_children = 1;
			return;
		    }
		    r |= rr;
		}
	    }
	}
    }
    overlapping_children = 0;
}
예제 #15
0
파일: ScrView.cpp 프로젝트: KB3NZQ/hexedit4
// InvalidateRange is an overrideable function that is used to invalidate the view
// between two caret positions.  This is used to invalidate bits of the window
// when the selection is changed (using mouse selection or with SetSel()).
// The default behaviour invalidates the lines (whole width of document) from
// the top of start to the bottom of end (using the current character height).
void CScrView::InvalidateRange(CPointAp start, CPointAp end, bool f /*=false*/)
{
	if (start.y > scrollpos_.y + win_height_ || start.x > scrollpos_.x + win_width_ ||
		end.y < scrollpos_.y || end.x < scrollpos_.x)
	{
		// All outside display area so do nothing.  Note that this may appear to not be nec.
		// as Windows does this too but due to overflow problems is safer to do it here.
		return;
	}

	CSizeAp ss = caret_size();

	// Also invalidate a row above and up to 3 rows below (this is necessary for stacked mode)
	start.y -= ss.cy;
	end.y += 3*ss.cy;

	if (start.x < scrollpos_.x) start.x = scrollpos_.x;
	if (start.y < scrollpos_.y) start.y = scrollpos_.y;
	if (end.y > scrollpos_.y + win_height_)
		end.y = scrollpos_.y + win_height_;

	// Invalidate the full width of display from top of start to bottom of end
	CRectAp rr(0, start.y, total_.cx, end.y);

	// Convert to device coords
	CRect norm_rect = ConvertToDP(rr);

	CRect cli;
	GetDisplayRect(&cli);

	// Invalidate the previous selection so that it is drawn unselected
	CRect rct;
	if (rct.IntersectRect(&cli, &norm_rect))
		DoInvalidateRect(&norm_rect);
}
예제 #16
0
TInt RealToRatio(SRatio& aRatio, const TRealX& aReal)
	{
	aRatio.iSpare1 = 0;
	aRatio.iSpare2 = 0;
	if (aReal.iSign || aReal.IsZero() || aReal.IsNaN())
		{
		aRatio.iM = 0;
		aRatio.iX = 0;
		return (aReal.IsZero()) ? KErrNone : KErrNotSupported;
		}
	TRealX rx(aReal);
	TRealX rr(rx);
	rr.iExp -= 32;
	rr.iMantLo = 0;
	rr.iMantHi = 0x80000000u;
	rx += rr;	// rounding
	TInt exp = rx.iExp - 32767 - 31;
	if (exp < -32768)
		{
		aRatio.iM = 0;
		aRatio.iX = 0;
		return KErrUnderflow;
		}
	if (exp > 32767)
		{
		aRatio.iM = 0xffffffffu;
		aRatio.iX = 32767;
		return KErrOverflow;
		}
	aRatio.iM = rx.iMantHi;
	aRatio.iX = (TInt16)exp;
	return KErrNone;
	}
예제 #17
0
Color<real> BlinnPhongShader<real>::GetReflection()
{
    ////////////////////////////////////////////
    //////////////////IFT 3355//////////////////
    ////////////////////////////////////////////
    //Ici, vous calculerez le rayon réfléchi
    //par la surface.
    //Vous calculerez ensuite la nouvelle
    //contribution en le pondérant par la couleur
    //de réflexion du matériau
    //hint :
    //CastShadingRay()
    ////////////////////////////////////////////
    //////////////////IFT 3355//////////////////
    ////////////////////////////////////////////

    // No contribution => black

    if (mRecursionDepth != 0) {
        Vector3<real> r = (mIntersection.GetNormal() * -1 * mRay.GetDirection()) * 2.0 * mIntersection.GetNormal() + mRay.GetDirection();
        Ray<real> rr(mIntersection.GetPosition() + EPS*mIntersection.GetNormal(), r);
        Color<real> reflectedColor = mRayTracer.CastShadingRay(rr, mRecursionDepth - 1);
        return reflectedColor * mMaterial.GetReflection();
    }
    else {
        return Color<real>( 0, 0, 0, 1 );
    }
}
예제 #18
0
void positions::step(double distance, int axis, int Particle)
{
    pos(axis,Particle)+=distance;
    // update r
    r[Particle]=norm(pos.col(Particle),2);

    // update rr
    for (int j=0;j<Particle;j++)
    {
        rr(Particle-1,j)=norm(pos.col(Particle)-pos.col(j),2);
    }
    for (int i=Particle+1; i<nParticles;i++)
    {
        rr(i-1,Particle) = norm(pos.col(Particle)-pos.col(i),2);
    }
}
예제 #19
0
void TrillSegment::layout()
      {
      QRectF b1(symbols[score()->symIdx()][trillSym].bbox(magS()));
      QRectF rr(b1.translated(-b1.x(), 0.0));
      rr |= QRectF(0.0, rr.y(), pos2().x(), rr.height());
      setbbox(rr);
      }
예제 #20
0
void NR::mpdiv(Vec_O_UCHR &q, Vec_O_UCHR &r, Vec_I_UCHR &u, Vec_I_UCHR &v)
{
	const int MACC=1;
	int i,is,mm;

	int n=u.size();
	int m=v.size();
	int p=r.size();
	int n_min=MIN(m,p);
	if (m > n) nrerror("Divisor longer than dividend in mpdiv");
	mm=m+MACC;
	Vec_UCHR s(mm),rr(mm),ss(mm+1),qq(n-m+1),t(n);
	mpinv(s,v);
	mpmul(rr,s,u);
	mpsad(ss,rr,1);
	mplsh(ss);
	mplsh(ss);
	mpmov(qq,ss);
	mpmov(q,qq);
	mpmul(t,qq,v);
	mplsh(t);
	mpsub(is,t,u,t);
	if (is != 0) nrerror("MACC too small in mpdiv");
	for (i=0;i<n_min;i++) r[i]=t[i+n-m];
	if (p>m)
		for (i=m;i<p;i++) r[i]=0;
}
예제 #21
0
bool lib_hack(Conjunct *c, DNF * d, Rel_Body * rb) {
    bool result=0;
    if (WANT_SEGM_FAULT) {
// relation constructors
        Relation r(0,0);
        Relation rc(r,c);
        Relation rbi(*rb,1);
        Relation r0;
        Relation rr(r);

// input/output variable functions
        r.n_inp();
        r.n_out();
        r.n_set();
        r.input_var(1);
        r.output_var(1);
        r.set_var(1);

//other functions
        rr=r;
        result = r.is_upper_bound_satisfiable();
        d->prefix_print(NULL);
    }
    return result;
}
예제 #22
0
void main()
{
	clrscr();
	cout << "Enter the Number of Process : ";
	cin >> n;

	cout << "\n\n1) FCFS   2) SJF   3) SRTF   4) RR\n\n";
	cout << "Enter Your Choice : ";
	cin >> choice;

	cout << "\n";
	int i;
	for(i=0;i<n;i++)
	{
	cout << "Arrival Time & Service Time for Process " << i+1 << " : ";
	tab[i][0]=i+1;
	cin >> tab[i][1];
	cin >> tab[i][2];
	}
	ttt=totaltime();
	switch(choice)
	{
		case '1': fcfs();break;
		case '2': sjf();break;
		case '3': srtf();break;
		case '4': rr();break;
		default : exit(0);
	}

}
예제 #23
0
void TestSolver::circle2() {
	const ExprSymbol& x=ExprSymbol::new_("x");
	const ExprSymbol& y=ExprSymbol::new_("y");

	SystemFactory f;
	f.add_var(x);
	f.add_var(y);
	f.add_ctr(sqr(x)+sqr(y)=1);
	f.add_ctr(sqr(x-2)+sqr(y)=1);
	double _sol1[]={1,0};
	Vector sol1(2,_sol1);
	System sys(f);
	RoundRobin rr(1e-3);
	CellStack stack;
	CtcHC4 hc4(sys);
	Vector prec(2,1e-3);
	Solver solver(sys,hc4,rr,stack,prec,prec);

	solver.start(IntervalVector(2,Interval(-10,10)));

	CovSolverData::BoxStatus status;

	bool res=solver.next(status);
	CPPUNIT_ASSERT(res);
	CPPUNIT_ASSERT(status==CovSolverData::UNKNOWN);
	CPPUNIT_ASSERT(solver.get_data().nb_unknown()==1);
	CPPUNIT_ASSERT(solver.get_data().unknown(0).is_superset(sol1));

	res=solver.next(status);
	CPPUNIT_ASSERT(!res);
}
예제 #24
0
static auto bindSimulator(EAlgorithms algorithm)
{
    switch (algorithm)
    {
        case EAlgorithms::FCFS:
            {
                AlgorithmSimulator fcfs(std::bind(&Algorithms::FCFS, std::placeholders::_1, std::placeholders::_2));
                return fcfs;
            }
        case EAlgorithms::RR:
            {
                AlgorithmSimulator rr(std::bind(&Algorithms::RR, std::placeholders::_1, std::placeholders::_2));
                return rr;
            }
        case EAlgorithms::PQ:
            {
                AlgorithmSimulator pq(std::bind(&Algorithms::PriorityQueue, std::placeholders::_1, std::placeholders::_2));
                return pq;
            }
        case EAlgorithms::SJK:
            {
                AlgorithmSimulator sjk(std::bind(&Algorithms::SJK, std::placeholders::_1, std::placeholders::_2));
                return sjk;
            }
        default:
            throw std::logic_error("Invalid algorithm...");
    }
}
예제 #25
0
WEXPORT WControl::WControl( WWindow* parent, char* classname, const WRect& r, char* text, WStyle wstyle )
	: WWindow( parent, classname, r, text, wstyle|WS_CHILD )
{
    	WRect rr( r );
	if( rr.w() == 0 ) rr.w( 150 );
	if( rr.h() == 0 ) rr.h( 24 );
	move( rr );
}
RouteRequest* 
ParserRouteHandler::redoRoute(const RouteID& oldRouteID,
                              const RouteRequestParams& rrParams,
                              const RequestUserData& user,
                              const TopRegionRequest* topReq,
                              const DisturbanceList* disturbances)
{
   //find the origin and destination of the old route

   //the old route reply
   auto_ptr<RouteReplyPacket> oldRouteReply( 
                               m_thread->getStoredRoute( oldRouteID ) );

   if ( oldRouteReply.get() == NULL ) {
      return NULL;
   }
   //we need a DriverPref to decode the routereplypacket contents
   DriverPref driverPref;
   //the vector of subroutes is extracted
   auto_ptr<SubRouteVector> oldRouteVector( 
      oldRouteReply->createSubRouteVector(&driverPref) );

   //we need the first...
   SubRoute* firstSub = oldRouteVector->getSubRouteAt(0);
   //...and last subroute.
   SubRoute* lastSub  = 
      oldRouteVector->getSubRouteAt( oldRouteVector->getSize() - 1);

   //the origin parameters
   uint32 originMap  = firstSub->getThisMapID();
   uint32 originNode = firstSub->getOrigNodeID();
   uint16 originOffset = oldRouteVector->getStartOffsetUint16();
   //unfortunately not possible to use right now. 
   //bool startDirFromZero = oldRouteVector->getStartDirFromZero();

   //the destination parameters
   uint32 destMap    = lastSub->getThisMapID();
   uint32 destNode   = lastSub->getDestNodeID();
   uint16 destOffset = oldRouteVector->getEndOffsetUint16();


   //create the routerequest
   auto_ptr<RouteRequest> rr(
      rrParams.createRouteRequest( user, m_thread->getNextRequestID(),
                                   topReq, disturbances ) );

   rr->addOriginID(      originMap, originNode, originOffset );
   rr->addDestinationID( destMap,   destNode,   destOffset   );

   m_thread->putRequest( rr.get() );

   if ( rr->getStatus() != StringTable::OK ) {
      delete rr->getAnswer();
      rr.reset(NULL); //delete the object the auto_ptr holds.
   }

   return rr.release(); //release the object and return the held pointer
}
예제 #27
0
TLFRect* TLFAverageNNPredictor::Predict(ILFDetectEngine* engine)
{
	if (this->m_list.GetCount() == 0)
		return NULL;
	if (engine == NULL)
		return NULL;

	if (m_pPredicted != NULL)
	{
		delete m_pPredicted;
		m_pPredicted = NULL;
	}

	ILFObjectDetector* detector = NULL;
	detector = engine->GetDetector(0);
	if (detector == NULL)
		return NULL;
	ILFScanner* scanner = detector->GetScanner();
	if (scanner == NULL)
		return NULL;
	TLFRect rect(m_rect);
	double min_err = FLT_MAX;

	awpRect result;

	for (int i = 0; i < scanner->GetFragmentsCount(); i++)
	{
		TLFBounds* b = scanner->GetFragment(i);
		TLFRect   rr(b->Rect);
		if (rect.RectOverlap(rr) > 0.3)
		{
			TLFDblVector* d = this->Features(engine, &rr, 0);
			if (d != NULL)
			{
				double e;
				if (this->Classify(d, &e))
				{
					if (e < min_err)
					{
						min_err = e;
						result = b->Rect;
					}
				}
				delete d;
			}
		}
	}
	if (min_err < 1)
	{
		TLFRect* r_result = new TLFRect(result);
		m_pPredicted = r_result;
		return r_result;
	}
	else
		return NULL;

}
예제 #28
0
void positions::set_singlePos(vec NewPosition, int particleNumber)
{
    // write new particle position
    pos.col(particleNumber)=NewPosition;

    // update r
    r(particleNumber)=norm(pos.col(particleNumber),2);

    // update rr
    for (int j=0;j<particleNumber;j++)
    {
        rr(particleNumber-1,j)=norm(pos.col(particleNumber)-pos.col(j),2);
    }
    for (int i=particleNumber+1; i<nParticles;i++)
    {
        rr(i-1,particleNumber) = norm(pos.col(particleNumber)-pos.col(i),2);
    }
}
예제 #29
0
파일: trill.cpp 프로젝트: aiena/MuseScore
void TrillSegment::layout()
      {
      QRectF b1(symbols[score()->symIdx()][trillSym].bbox(magS()));
      QRectF rr(b1.translated(-b1.x(), 0.0));
      rr |= QRectF(0.0, rr.y(), pos2().x(), rr.height());
      setbbox(rr);
      rypos() += score()->styleS(ST_trillY).val() * spatium();
      adjustReadPos();
      }
예제 #30
0
string rec(shared_ptr < Node > v, map < string, string > q) {
    //cerr << genAns(v) << endl;
    if (v->isVar()) {
        //int id;
        //db(q.size());
        //for (auto x: q)
            //db2(x.fr, x.sc);
        //db(v->type);

        assert(q.count(v->type) == 1);
        return q[v->type]; 
    } 

    //db(v->type);
    if (v->isAbstr()) {
        string s = v->l->type;
        string vv = "t" + myToString(cur++);
        q[s] = vv; 
    }

    string l = rec(v->l, q);
    string r = rec(v->r, q);
    string myId = "t" + myToString(cur++);
    varId[myId] = genAns(v);

    //cerr << "l r myId: " << l << " " << r << " " << myId << endl;
    if (v->type == "APPLY") {
        shared_ptr < TNode > ll(new TNode(l));
        shared_ptr < TNode > rr(new TNode(r));
        shared_ptr < TNode > me(new TNode(myId));
        shared_ptr < TNode > res(new TNode("a", {rr, me}));
        G.pb(mp(ll, res));
        return myId;
    }
    if (v->type == "ABSTR") {
        shared_ptr < TNode > ll(new TNode(l));
        shared_ptr < TNode > rr(new TNode(r));
        shared_ptr < TNode > res(new TNode("a", {ll, rr}));
        shared_ptr < TNode > me(new TNode(myId));
        G.pb(mp(me, res));
        return myId;
    }
    assert(false);
}