Exemple #1
0
bool Columns::Less(int first_column, int second_column, const PhotoInfo& info1, const PhotoInfo& info2, const PhotoInfo& info1a, const PhotoInfo& info2a) const
{
	if (Less(first_column, info1, info2))
		return true;

	if (Less(first_column, info2, info1))
		return false;

	// photos are equivalent in ragard to the first sorting key; use secondary key:

	return Less(second_column, info1a, info2a);
}
    explicit StaticKDTree(std::vector<InputPoint> *points)
    {
        BOOST_ASSERT(k > 0);
        BOOST_ASSERT(points->size() > 0);
        size = points->size();
        kdtree = new InputPoint[size];
        for (Iterator i = 0; i != size; ++i)
        {
            kdtree[i] = points->at(i);
            for (unsigned dim = 0; dim < k; ++dim)
            {
                if (kdtree[i].coordinates[dim] < boundingBox.min[dim])
                    boundingBox.min[dim] = kdtree[i].coordinates[dim];
                if (kdtree[i].coordinates[dim] > boundingBox.max[dim])
                    boundingBox.max[dim] = kdtree[i].coordinates[dim];
            }
        }
        std::stack<Tree> s;
        s.push(Tree(0, size, 0));
        while (!s.empty())
        {
            Tree tree = s.top();
            s.pop();

            if (tree.right - tree.left < KDTREE_BASESIZE)
                continue;

            Iterator middle = tree.left + (tree.right - tree.left) / 2;
            std::nth_element(
                kdtree + tree.left, kdtree + middle, kdtree + tree.right, Less(tree.dimension));
            s.push(Tree(tree.left, middle, (tree.dimension + 1) % k));
            s.push(Tree(middle + 1, tree.right, (tree.dimension + 1) % k));
        }
    }
Exemple #3
0
const SimpleNode<T>* ConstListIterator<T>::Prev()
{
  if (!Less())
    return NULL;

  return IndexNode(_Index - 1);
}
  std::ostream &
  operator<<(std::ostream &ostr, const RangeBunchEventIDL &rhs) 
  {
    
    std::vector<Scan> scan;
    for (unsigned int i = 0; i < rhs.sensor.length(); ++i)
      scan.push_back(Scan(rhs.sensor[i].group, 
			  rhs.sensor[i].index, 
			  rhs.sensor[i].range));
    std::sort(scan.begin(), scan.end(), Less());

    ostr << rhs.time << endl;
    int group = -1;
    int index = 0;
    std::vector<Scan>::const_iterator i, j = scan.end();
    for (i = scan.begin(); i != j; ++i) {
      if (i->group > group) {
	if (group != -1)
	  ostr << endl;
	ostr << i->group << ": ";
	group = i->group;
	index = 0;
      }
      for (; index < i->index; ++index)
	ostr << "      ";
      
      ostr.width(6);
      ostr.fill(' ');
      ostr << i->range;
      index = i->index;
    }
    return ostr;
  }
Exemple #5
0
void f(std::vector<X>& v)
{
    struct Less {
	bool operator()(const X& a, const X& b) { return a<b; }
    };
    std::sort(v.begin(), v.end(), Less());	// C++98: error: Less is local
    // C++11: ok
}
void Relation() {
  Expression();
  if(IsRelop(Look)) {
    Push();
    switch(Look) {
      case '=': Equals();break;
      case '#': NotEquals();break;
      case '<': Less();break;
      case '>': Greater();break;
    }
  }
}
void Relation() {
  Expression();
  if (IsRelop(Look)) {
    EmitLn("push rax");
    switch(Look) {
      case '=': Equals(); break;
      case '#': NotEquals(); break;
      case '<': Less(); break;
      case '>': Greater(); break;
    }
    EmitLn("add rsp, 8");
    EmitLn("cmp rax, 0");
  }
}
Exemple #8
0
void __fastcall TIspList::N1Click(TObject *Sender)
{
//добавить
TObd_edit *wnd=new TObd_edit(this);
wnd->ShowModal();
if (wnd->ModalResult==mrOk)
    {
    int i=0;
    bool find=false;
    String obd=GostToVin(wnd->Edit1->Text),obdm="";
    while (i<list.size()&&!find)
        {
        if (list[i].Get_Obd(false)==obd)
            {
            find=true;
            }else
            {
            i++;
            }
        }
    if (!find)
        {
        i=0;
        while (i<list.size()&&!find)
            {
            if (list[i].main_isp)
                {
                find=true;
                }else
                {
                i++;
                }
            }
        if (find)
            {
            obdm=list[i].Get_Obd(false);
            }
        if (obd.SubString(1,obd.Length()-2)==obdm.SubString(1,obdm.Length()-2))
            {
            IspData tmp;
            tmp.id=0;
            tmp.main_isp=false;
            tmp.Set_Obd(wnd->Edit1->Text);
            list.push_back(tmp);
            std::sort (list.begin(),list.end(),Less());
            Show();
            }
        }
    }
}
void Relation(void)
{
	message("Relation...");
	Expression();
	if (IsRelop(Token[0]) ) {
		message("  (Relation \'%c\')", Token[0]);
		Push();
		switch (Token[0]) {
		case '=': Equals(); break;
		case '#': NotEquals(); break;
		case '<': Less(); break;
		case '>': Greater(); break;
		}
	}
}
Exemple #10
0
bool Less(string s, string t) // s,t are assumed to be little-endian
{
  assert(s.size() == t.size());
  bool ret_val = true;

  if(s.size() == 0)
    return(false);
  else if(s.size() == 1)
    return(s[0] == '0' && t[0] == '1');
  else
    ret_val = 
      Less(s.substr(1), t.substr(1)) || 
      ((s[0] == '0' && t[0] == '1') && Equal(s.substr(1), t.substr(1)));

  return(ret_val);

}
Exemple #11
0
__fastcall TIspList::TIspList(TComponent* Owner,cSQL *const db,vector <IspData> &_list,bool _edit)
    : TForm(Owner),list(_list),DB(db)
{
//сортировка вектора по обозначению
std::sort (list.begin(),list.end(),Less());
TV->Items->Clear();
edit=_edit;
if (edit)
    {
    TV->PopupMenu=PAB;
    }else
    {
    TV->PopupMenu=0;
    }
for (int i= 0; i <list.size(); i++)
    {
    list[i].selected=!edit;
    }
Show();
}
/* Parse and Translate a Relation */
void Relation()
{
    Expression();
    if (IsRelop(Token)) {
        Push();
        switch (Token) {
            case '=':
                Equals();
                break;
            case '<':
                Less();
                break;
            case '>':
                Greater();
                break;
            default:
                break;
        }
    }
}
Exemple #13
0
    static ColumnPtr execute(const ColumnArray & array, ColumnPtr mapped)
    {
        const ColumnArray::Offsets & offsets = array.getOffsets();

        size_t size = offsets.size();
        size_t nested_size = array.getData().size();
        IColumn::Permutation permutation(nested_size);

        for (size_t i = 0; i < nested_size; ++i)
            permutation[i] = i;

        ColumnArray::Offset current_offset = 0;
        for (size_t i = 0; i < size; ++i)
        {
            auto next_offset = offsets[i];
            std::sort(&permutation[current_offset], &permutation[next_offset], Less(*mapped));
            current_offset = next_offset;
        }

        return ColumnArray::create(array.getData().permute(permutation, 0), array.getOffsetsPtr());
    }
void Relation()
{
    Expression();
    if (IsRelop(Look)) {
        EmitLn("pushl %eax");
        switch (Look) {
            case '=':
                Equals();
                break;
            case '#':
                NotEquals();
                break;
            case '<':
                Less();
                break;
            case '>':
                Greater();
                break;
        }
    }
    EmitLn("test %eax, %eax");
}
Exemple #15
0
cv::Mat SIFT::sp_find_sift_grid( Mat I,Mat gridX,Mat gridY,int patchSize, float sigma_edge )
{
	int num_angles=8;
	float num_bins=4;
	int num_samples=num_bins*num_bins;
	int alpha = 9;

	//此处需要判断总共传入多少个变量,如果变量数小于5,就把sigma_edge设置为1
	float angle_step=2*pi/num_angles;

	//初始化angles 为一个一维矩阵从0到2*pi;间隔为angle_step
	Mat angles=create(0,2*pi,angle_step);
	angles=deleteO(angles); //删除最后一个元素

	CvSize size=I.size();
	//int hgt=size.height;
	//int wid=size.width;

	int num_patches=gridX.total();//计算gridX总共有多少个元素

	Mat sift_arr=Mat::zeros(num_patches,num_samples*num_angles,CV_32F);

	//计算滤波算子
	int  f_wid = 4 * ceil(sigma_edge) + 1;
	Mat G=gaussian(f_wid,sigma_edge);

	Mat GX=gradientX(G);
	Mat GY=gradientY(G);


	GX=GX*2/totalSumO(GX);
	GY=GY*2/totalSumO(GY);



	Mat I_X(I.rows,I.cols,CV_32F);
	I_X=filter2(GX,I);              //因为I,图片读入不同,所以I_X不同,与I有关的均布相同,但是,都正确


	Mat I_Y(I.rows,I.cols,CV_32F);
	I_Y=filter2(GY,I);

	Mat T(I_X.rows,I_X.cols,CV_32F);
	add(I_X.mul(I_X),I_Y.mul(I_Y),T);
	Mat I_mag(I_X.rows,I_X.cols,CV_32F);
	sqrt(T,I_mag);
	Mat I_theta=matan2(I_Y,I_X);

	Mat interval=create(2/num_bins,2,2/num_bins);
	interval-=(1/num_bins+1);

	Mat sample_x=meshgrid_X(interval,interval);


	Mat sample_y=meshgrid_Y(interval,interval);

	sample_x=reshapeX(sample_x);//变为一个1维矩阵

	sample_y=reshapeX(sample_y);

	Mat I_orientation[8] = {Mat::zeros(size,CV_32F)};
	for(int i=0;i<8;i++)
	{
		I_orientation[i] = Mat::zeros(size,CV_32F);
	}
	float *pt=angles.ptr<float>(0);

	for(int a=0;a<num_angles;a++)
	{
		Mat tep1=mcos(I_theta-pt[a]);//cos
		//cout<<tep1.at<float>(0,1)<<endl;
		Mat tep(tep1.rows,tep1.cols,CV_32F);
		pow(tep1,alpha,tep);
		tep=compareB(tep,0);
		I_orientation[a]=tep.mul(I_mag);
	}

	for(int i=0;i<num_patches;i++)
	{

		double r=patchSize/2;
		float l=(float)(i/gridX.rows);
		float m=i%gridX.rows;
		float cx=gridX.at<float>(m,l)+r-0.5;
		float cy=gridY.at<float>(m,l)+r-0.5;

		Mat sample_x_t=Add(sample_x*r,cx);
		Mat sample_y_t=Add(sample_y*r,cy);
		float *pt1=sample_y_t.ptr<float>(0);
		float sample_res=pt1[1]-pt1[0];

// 		int c=(int)i/gridX.rows;
// 		float *ptc1=gridX.ptr<float>(c);
// 		int x_lo=ptc1[i%gridX.rows];

		int x_lo = gridX.at<float>(i % gridX.rows, i / gridX.rows);
		int x_hi=patchSize+x_lo-1;
/*		float *ptc2=gridY.ptr<float>(c);*/


		int y_lo=gridY.at<float>(i % gridY.rows, i / gridY.rows);
		int y_hi=y_lo+patchSize-1;

		Mat A=create(x_lo,x_hi,1);
		Mat B=create(y_lo,y_hi,1);


		Mat sample_px=meshgrid_X(A,B);
		Mat sample_py=meshgrid_Y(A,B);

		int num_pix = sample_px.total();//计算sample_px元素总数
		sample_px=reshapeY(sample_px);
		sample_py=reshapeY(sample_py);


		Mat dist_px=abs(repmat(sample_px,1,num_samples)-repmat(sample_x_t,num_pix,1));
		Mat dist_py=abs(repmat(sample_py,1,num_samples)-repmat(sample_y_t,num_pix,1));


		Mat weights_x=dist_px/sample_res;
		Mat weights_x_l=Less(weights_x,1);
		weights_x=(1-weights_x).mul(weights_x_l);

		Mat weights_y=dist_py/sample_res;
		Mat weights_y_l=Less(weights_y,1);
		weights_y=(1-weights_y).mul(weights_y_l);
		Mat weights=weights_x.mul(weights_y);

		Mat curr_sift=Mat::zeros(num_angles,num_samples,CV_32F);
		for(int a=0;a<num_angles;a++)
		{
			//Mat I=getNum(I_orientation[a],y_lo,y_hi,x_lo,x_hi);
			Mat I = I_orientation[a](Range(y_lo, y_hi), Range(x_lo, x_hi));
			Mat tep=reshapeY(I);

			// Fill tep with zeros to fit size of weight
			if (tep.cols < weights.cols)
			{
				for (int i = tep.rows; i < weights.rows; i++)
					tep.push_back(0.0f);
			}

			tep=repmat(tep,1,num_samples);
			Mat t=tep.mul(weights);
			Mat ta=sum_every_col(t);
			float *p=ta.ptr<float>(0);
			for(int i=0;i<curr_sift.cols;i++)
			{
				curr_sift.at<float>(a,i)=p[i];
			}

		}
		Mat tp=reshapeX(curr_sift);
		float *p=tp.ptr<float>(0);
		for(int j=0;j<sift_arr.cols;j++)
		{
			sift_arr.at<float>(i,j)=p[j];
		}

	}

	return sift_arr;
}
Exemple #16
0
bool operator<(vcIntValue& s, vcIntValue& t)
{
  return (Less(s.Get_Value(),t.Get_Value()));
}
Exemple #17
0
 void sort(Less less = Less()) {
     if(!empty()) merge_sort(&data_.first_,
             (std::numeric_limits<size_type>::max)(), less);
 }
Exemple #18
0
bool TIndex::TPos::Equal(const TPos& pos, int wordOffset) const
{
	return !(Less(pos, wordOffset) || pos.Less(*this, -wordOffset));
}
    vector_less(const std::vector <T>& data, Less less = Less()) :
      _less(less), data_(data)
    {

    }
Exemple #20
0
 bool Clock::MoreOrEqual(const time_t x) {
   return !Less(x);
 }
Exemple #21
0
/*** Execute this node ***/
Outcome For::execute()
{
	// Check for the for value
	if(forValue == 0)
		throw Excep(getLineNumber(), getColumnNumber(), "No variable specified in for loop.");

	if(forValue->getType() != OP_VARIABLE)
		throw Excep(getLineNumber(), getColumnNumber(), "For loop must be given a valid variable.");

	// Store the for value variable
	Variable* forVar = static_cast<Variable*>(forValue);

	// If a from value was given, set the counter to this initial value
	if(from != 0)
	{
		// Evaluate the 
		std::auto_ptr<Object> fromEval(from->evaluate());
		if(fromEval->getType() != OBJ_INTEGER && fromEval->getType() != OBJ_REAL)
			throw InvalidTypeException(getLineNumber(), getColumnNumber(), OBJ_INTEGER | OBJ_REAL, fromEval->getType());
		Assign(forVar->clone(), fromEval.release()).execute();
	}
	else
		Assign(forVar->clone(), new Integer(1)).execute();

	// Create an Outcome object to store the result
	Outcome result(S_SUCCESS);

	do
	{
		// Check the while condition, if present
		if(whileCond != 0)
		{
			std::auto_ptr<Object> whileCondEval(whileCond->evaluate());
			if(whileCondEval->getType() != OBJ_LOGICAL)
				throw InvalidTypeException(getLineNumber(), getColumnNumber(), OBJ_LOGICAL, whileCondEval->getType());
			bool whileCondResult = static_cast<Logical*>(whileCondEval.get())->getValue();

			if(!whileCondResult)
				break;
		}

		// Check the to value
		if(to != 0)
		{
			std::auto_ptr<Object> toEval(to->evaluate());

			// Store the step value evaluated
			std::auto_ptr<Object> stepEval;
			if(step == 0)
				stepEval.reset(new Integer(1));
			else
				stepEval.reset(step->evaluate());

			// Confirm that the step is an integer
			if(stepEval->getType() != OBJ_INTEGER && stepEval->getType() != OBJ_REAL)
				throw InvalidTypeException(getLineNumber(), getColumnNumber(), OBJ_INTEGER | OBJ_REAL, stepEval->getType());

			std::auto_ptr<Real> castStep;
			// Cast the step value to a real
			if(stepEval->getType() == OBJ_INTEGER)
				castStep.reset(new Real(static_cast<Integer*>(stepEval.get())->getValue()));
			else
				castStep.reset(static_cast<Real*>(stepEval.release()));

			bool toCondition = false;

			if(castStep->getValue() > 0)
			{
				std::auto_ptr<Object> operation(Greater(forVar->clone(), toEval.release()).evaluate());
				toCondition = static_cast<Logical*>(operation.get())->getValue();
			}
			if(castStep->getValue() < 0)
			{
				std::auto_ptr<Object> operation(Less(forVar->clone(), toEval.release()).evaluate());
				toCondition = static_cast<Logical*>(operation.get())->getValue();
			}

			if(toCondition)
				break;
		}

		// Execute the NodeList of statements
		result = list->execute();

		// Modify forVar based on step
		if(step == 0)
		{
			std::auto_ptr<Object> addOperation(Add(forVar->clone(), new Integer(1)).evaluate());
			Assign(forVar->clone(), addOperation.release()).execute();
		}
		else
		{
			std::auto_ptr<Object> stepEval(step->evaluate());
			if(stepEval->getType() != OBJ_INTEGER && stepEval->getType() != OBJ_REAL)
				throw InvalidTypeException(getLineNumber(), getColumnNumber(), OBJ_INTEGER | OBJ_REAL, stepEval->getType());
			std::auto_ptr<Object> addOperation(Add(forVar->clone(), stepEval.release()).evaluate());
			Assign(forVar->clone(), addOperation.release()).execute();
		}

		// Check the until condition, if present
		if(untilCond != 0)
		{
			std::auto_ptr<Object> untilEval(untilCond->evaluate());
			if(untilEval->getType() != OBJ_LOGICAL)
				throw InvalidTypeException(getLineNumber(), getColumnNumber(), OBJ_LOGICAL, untilEval->getType());
			bool untilResult = static_cast<Logical*>(untilEval.get())->getValue();

			if(untilResult)
				break;
		}
	}
	while(result.getStatus() == S_SUCCESS);

	return result;
}
Exemple #22
0
 compare_first(Less less = Less()): less(less) {}