int main(){
	Sortvector<int> sv(10);
	//cout<<sv<<endl;
	Zoekboom<int> zb(sv);
	Printspecial("Zoekboom");
	//cout<<zb<<endl;
	zb.printlevelorder();
	//cout<<zb.max_diepte()<<endl;
	//cout<<zb.gem_diepte2()<<endl;
	//cout<<zb.gem_diepte()<<endl;
	
	
	Printspecial("zoeken naar minimum");
	cout<<zb.min()<<endl;
	Printspecial("zoeken naar maximum");
	cout<<zb.max()<<endl;
	Printspecial("zoeken naar opvolger");
	cout<<zb.opvolger(1)<<endl;
	Printspecial("verwijderen van knoop");
	zb.verwijderknoop(4);
	zb.printlevelorder();
	
	
	
}
void ZippedBufferPoolTests::testBasic()
{

    ZippedBufferPool pool;

    QString name("toto.txt");
    QByteArray data;
    data.reserve(2);
    data[0] = 'a';
    data[1] = 'b';
    ZippedBuffer zb(name, data);

    pool.put(zb);
    auto result = pool.tryGet();
    QVERIFY2(result.first == true, "Buffer invalid");
    QVERIFY2(result.second.get_filename() == zb.get_filename(), "Filename not equal");

}
Exemple #3
0
   int ARLambda::search( const Matrix<double>& L, 
                         const Vector<double>& D, 
                         const Vector<double>& zs, 
                         Matrix<double>& zn, 
                         Vector<double>& s, 
                          const int& m )
   {

      ARException e("The LAMBDA search method have not been implemented.");
      GPSTK_THROW(e);

      // TODO: CHECK UNEXPECTED INPUT
      // n - number of float parameters
      // m - number of fixed solutions
      // L - nxn
      // D - nx1
      // zs - nxn
      // zn - nxm
      // s  - m
      const int LOOPMAX = 10000;
      const int n = L.rows();

      zn.resize(n,m,0.0);
      s.resize(m,0.0);

      Matrix<double> S(n,n,0.0);
      Vector<double> dist(n,0.0),zb(n,0.0),z(n,0.0),step(n,0.0);

      int k=n-1; dist[k]=0.0;
      zb(k)=zs(k);
      z(k)=round(zb(k)); 
      double y=zb(k)-z(k); 
      step(k)=sign(y);

      int c(0),nn(0),imax(0);
      double maxdist=1E99;
      for(int c=0;c<LOOPMAX;c++)
      {
         double newdist=dist(k)+y*y/D(k);
         if(newdist<maxdist) 
         {
            if(k!=0) 
            {
               dist(--k)=newdist;
               for(int i=0;i<=k;i++)
               {
                  S(k,i)=S(k+1,i)+(z(k+1)-zb(k+1))*L(k+1,i);
               }
               zb(k)=zs(k)+S(k,k);
               z(k)=round(zb(k)); y=zb(k)-z(k); step(k)=sign(y);
            }
            else 
            {
               if(nn<m) 
               {
                  if(nn==0||newdist>s(imax)) imax=nn;
                  for(int i=0;i<n;i++) zn(i,nn)=z(i);
                  s(nn++)=newdist;
               }
               else 
               {
                  if(newdist<s(imax)) 
                  {
                     for(int i=0;i<n;i++) zn(i,imax)=z(i);
                     s(imax)=newdist;
                     for(int i=imax=0;i<m;i++) if (s(imax)<s(i)) imax=i;
                  }
                  maxdist=s(imax);
               }
               z(0)+=step(0); y=zb(0)-z(0); step(0)=-step(0)-sign(step(0));
            }
         }
         else 
         {
            if(k==n-1) break;
            else 
            {
               k++;
               z(k)+=step(k); y=zb(k)-z(k); step(k)=-step(k)-sign(step(k));
            }
         }
      }
      for(int i=0;i<m-1;i++) 
      { 
         for(int j=i+1;j<m;j++) 
         {
            if(s(i)<s(j)) continue;
            swap(s(i),s(j));
            for(k=0;k<n;k++) swap(zn(k,i),zn(k,j));
         }
      }

      if (c>=LOOPMAX) 
      {
         return -1;
      }

      return 0;

   }  // End of method 'ARLambda::search()'
Exemple #4
0
int CLAMBDA::search(int n, int m, std::vector< std::vector<double> > L,  std::vector<double>  D,	std::vector<double>& zs,std::vector< std::vector<double> >& zn,  std::vector<double>& s)
{
	//
	//SYNTAX:
	//            ======================================
	//            | [zn,  s]=search( n, m, L, D, zs) |
	//            ======================================
	//      Search m best integer vectors zn and correspondent quadratic residual error was given by s
	//INPUTS:
	//      n: dimension of ambiguity vectors
	//      m: how many ambiguity vectors one want to output, when m=2, zn could given the best and the second best solution  
	//      L&D: Qzz=L'*D*L, where Qzz was co-variance matrices after Z transformation 
	//      zs: float  ambiguities
	//OUTPUT:
	//      zn: m integer ambiguity vectors
	//      s:   quadratic residual error of m sets ambiguity vectors
	//	revised by D. Xiang on 2014/05/06 in Tongji Univ
	//	email: [email protected]
	//	School.of Surveying and Geoinformatics Engineering,Tongji Univ.,China
	//	Originally written by D. Xiang on 2012 in CASM, Beijing 
	//////////////////////////////////////////////////////////////////////////
	int i,j,k,c,nn=0,imax=0;
	double newdist,maxdist=1E99,y;
	std::vector< std::vector<double> > S(n); std::vector<double> dist(n),zb(n),z(n),step(n);
	for(i=0;i<n;i++)S[i].resize(n);
	CMatrix mymat;
	mymat.zeros(S,n,n);

	k=n-1; dist[k]=0.0;
	zb[k]=zs[k];
	z[k]=ROUND(zb[k]); y=zb[k]-z[k]; step[k]=SGN(y);
	for (c=0;c<LOOPMAX;c++) 
	{
		newdist=dist[k]+y*y/D[k];
		if (newdist<maxdist) 
		{
			if (k!=0) 
			{
				dist[--k]=newdist;
				for (i=0;i<=k;i++)
					S[i][k]=S[i][k+1]+(z[k+1]-zb[k+1])*L[i][k+1];
				zb[k]=zs[k]+S[k][k];
				z[k]=ROUND(zb[k]); y=zb[k]-z[k]; step[k]=SGN(y);
			}
			else {
				if (nn<m) 
				{
					if (nn==0||newdist>s[imax]) imax=nn;
					for (i=0;i<n;i++) zn[nn][i]=z[i];
					s[nn++]=newdist;
				}
				else 
				{
					if (newdist<s[imax]) 
					{
						for (i=0;i<n;i++) zn[imax][i]=z[i];
						s[imax]=newdist;
						for (i=imax=0;i<m;i++) if (s[imax]<s[i]) imax=i;
					}
					maxdist=s[imax];
				}
				z[0]+=step[0]; y=zb[0]-z[0]; step[0]=-step[0]-SGN(step[0]);
			}
		}
		else 
		{
			if (k==n-1) break;
			else 
			{
				k++;
				z[k]+=step[k]; y=zb[k]-z[k]; step[k]=-step[k]-SGN(step[k]);
			}
		}
	}
	for (i=0;i<m-1;i++) 
	{   /* sort by s */
		for (j=i+1;j<m;j++) 
		{
			if (s[i]<s[j]) continue;
			SWAP(s[i],s[j]);
			for (k=0;k<n;k++) SWAP(zn[i][k],zn[j][k]);
		}
	}

	if (c>=LOOPMAX) {
//		AfxMessageBox("search loop count overflow");
		return -1;
	}
	return 0;
}