Example #1
0
void demo(int tam_vec, double factor){
    
    Vector<Dni> v = bank_gen(tam_vec);
    
    InsertionSort<Dni> is;
    BubbleSort<Dni> bs;
    ShellSort<Dni> ss(factor);
    QuickSort<Dni> qs;
    MergeSort<Dni> ms;
    
    cout << "Vector: "; v.mostrar();
    cout << " ## InsertionSort: " << endl;
    is.ordenar(v, v.getSize());
    
    cout << "Vector: "; v.mostrar();    
    cout << " ## BubbleSort: " << endl;
    bs.ordenar(v, v.getSize());

    cout << "Vector: "; v.mostrar();
    cout << " ## ShellSort: " << endl;
    ss.ordenar(v, v.getSize());

    cout << "Vector: "; v.mostrar();
    cout << " ## QuickSort: " << endl;
    qs.ordenar(v, v.getSize());
        
    cout << "Vector: "; v.mostrar();
    cout << " ## MergeSort: " << endl;
    ms.ordenar(v, v.getSize());        
}
void SpatialDescriptorFunctionSRD<CoordType>::eval(
  const Vertices<CoordType>& vertices,
  Vector<CoordType>& x,
  Vector<CoordType>& y)
{
  const int numVertices = vertices.getSize();
  int i, j = 0;
  Vector<CoordType> temp;
  temp.setSize(1);
  x.setSize(0);

  for (i = 0; i < numVertices; ++i)
    for (j = i+1; j < numVertices; ++j)
    {
      temp[0] = vertices[i].distance( vertices[j] );
      if ( temp[0] < _distanceThreshold )
        x.append( temp );
    }

  if ( x.getSize() != 0 )
  {
    x.sort();
    y.setSize( x.getSize() );
    CDFTools<CoordType> cdfTools;
    y = cdfTools.cdf( x );
  }
  else
  {
    x.setSize( 1 );
    x[0] = 0;
    y.setSize( x.getSize() );
    CDFTools<CoordType> cdfTools;
    y = cdfTools.cdf( x );
  }
}
Example #3
0
Vector<T> CDFTools<T>::cdf(const Vector<T>& x, const Vector<T>& xEvals) const
{
  if ( x.isIncreasing() == false )
  {
    UsageError usageError;
    usageError.setWhere( "Vector<T> CDFTools<T>::cdf(const Vector<T>&, const Vector<T>&) const" );
    usageError.setWhat( "The input vector is not sorted in increasing order" );
    throw usageError;
  }

  const int n = x.getSize();
  const int numEvals = xEvals.getSize();
  Vector<T> y( numEvals );
  int i, p;

  for (i = 0, p = 0; i < n; ++i)
  {
    while ( p < numEvals && xEvals[p] < x[i] )
    {
      y[p++] = T(i) / n;
    }
  }

  while ( p < numEvals )
  {
    y[p++] = 1.0;
  }

  return y;
}
Example #4
0
void testGraph()
{
    typedef GraphAA<bool> G;
    G sp;
    for(int i = 0; i < 6; ++i)
	{
		sp.addVertex();
	}
	sp.addEdge(0,1,6);
	sp.addEdge(0,2,8);
	sp.addEdge(0,3,18);
	sp.addEdge(1,4,11);
	sp.addEdge(2,3,9);
	sp.addEdge(4,5,3);
	sp.addEdge(5,2,7);
	sp.addEdge(5,3,4);

    Vector<Vector<int> > components = connectedComponents(sp);
    DEBUG(components.getSize());
    for(int i = 0; i < components.getSize(); ++i)
    {
        Vector<int>& c = components[i];
        for(int j = 0; j < c.getSize(); ++j)
        {
            DEBUG(c[j]);
        }
    }

    Vector<int> ranks = topologicalSort(sp);
    DEBUG(ranks.getSize());
    for(int j = 0; j < ranks.getSize(); ++j)
    {
        DEBUG(ranks[j]);
    }
}
Example #5
0
void LeastSquareFit::printVector(Vector vec)
{
  std::cout << "(";
  for (uint i = 0; i < vec.getSize()-1; i++)
    std::cout << vec(i) << ", ";
  std::cout << vec(vec.getSize()-1) << ")" << std::endl;
}
Example #6
0
void TestVector::assignmentOperator()
{
	tools->setFunctionName("assignementOperator");
	{
	  Vector<int> copyFrom;
		Vector<int> instance = copyFrom;
    tools->assertTypeEquals(instance,copyFrom);
    tools->assertEquals(instance.getMaxSize(),(unsigned)10);
    tools->assertEquals(instance.getSize(),(unsigned)0);
	}
	{
	  Vector<int> copyFrom(5);
	  copyFrom.insert(0,2);
	  copyFrom.insert(1,4);
	  copyFrom.insert(2,8);
	  copyFrom.insert(3,16);
	  copyFrom.insert(4,32);
		Vector<int> instance = copyFrom;
    tools->assertEquals(instance.getMaxSize(),(unsigned)10);
    tools->assertEquals(copyFrom.getSize(),(unsigned)5);
    tools->assertEquals(instance.getSize(),(unsigned)5);
    tools->assertEquals(instance.get(4),32);
    tools->assertEquals(instance.get(3),16);
    tools->assertEquals(instance.get(2),8);
    tools->assertEquals(instance.get(1),4);
    tools->assertEquals(instance.get(0),2);
	}
}
Vector<double> AncillaryMethods::conv1D(const Vector<double> &vec, const Vector<double> &kernel)
{
    int kernelSize = kernel.getSize();
    int kCenter = floor(kernelSize/2.0);

    int nn;

    Vector<double> result(vec.getSize(), 0.0);

    double vec_first = vec(0), vec_last = vec(vec.getSize()-1);

    for(int j = 0; j < vec.getSize(); j++)
    {
        for (int n = 0; n < kernelSize; n++)
        {
            nn = kernelSize - 1 - n;
            int pos = j + (n - kCenter);
            if(pos<0)
            {
                result(j) += vec_first*kernel(nn);
            }
            else if(pos >= vec.getSize())
            {
                result(j) += vec_last*kernel(nn);
            }
            else//if(pos >= 0 && pos < vec.getSize())
            {
                result(j) += vec(pos)*kernel(nn);
            }
        }
    }

    return result;
}
Example #8
0
void CDFTools<T>::differences(
  const Vector<T>& cdf1,
  const Vector<T>& cdf2,
  Vector<T>& maxDiff,
  Vector<T>& maxDiffAbove,
  Vector<T>& maxDiffBelow) const
{
  if ( cdf1.isIncreasing() == false || cdf2.isIncreasing() == false )
  {
    UsageError usageError;
    usageError.setWhere( "void CDFTools<T>::differences(...) const" );
    usageError.setWhat( "Non-increasing number sequence passed as cdf" );
    throw usageError;
  }

  const int n = cdf1.getSize();
  const int m = cdf2.getSize();
  int i = 0, j = 0, iprev, jprev;
  T diff;

  maxDiff.setZeros( 2 );
  maxDiffAbove.setZeros( 2 );
  maxDiffBelow.setZeros( 2 );

  while ( i < n && j < m )
  {
    iprev = i;
    jprev = j;

    if ( cdf1[i] <= cdf2[j] )
    {
      while ( i < n-1 && cdf1[i+1] == cdf1[i] ) i++;
      i++;
    }

    if ( cdf2[j] <= cdf1[iprev] )
    {
      while ( j < m-1 && cdf2[j+1] == cdf2[j] ) j++;
      j++;
    }

    diff = T(i)/n - T(j)/m;

    if ( diff > 0.0 && diff > maxDiffAbove[1] )
    {
      maxDiffAbove[0] = 0.5 * (cdf1[iprev]+cdf2[jprev]);
      maxDiffAbove[1] = diff;
    }

    if ( diff < 0.0 && diff < maxDiffBelow[1] )
    {
      maxDiffBelow[0] = 0.5 * (cdf1[iprev]+cdf2[jprev]);
      maxDiffBelow[1] = diff;
    }
  }

  maxDiff = maxDiffAbove[1] >= fabs(maxDiffBelow[1])? maxDiffAbove: maxDiffBelow;
}
Vector<T> Matrix<T>::operator*(const Vector<T>& rhs) const
{
  if( getNumRows() != rhs.getSize() ) throw SizeError(rhs.getSize(), "operator*= vector");
  Vector<T> retVal(getNumRows());
  for(int i=0; i < getNumRows(); i++)
  {
    retVal[i] = getRow(i) * rhs;
  }
  return retVal;
}
Example #10
0
int OtsuThresholding<T>::computeThreshold(const Vector<unsigned int>& histogram) const
{
  const Vector<double> criterion = computeCriterion( histogram );

  return criterion.maxPos();

#if 0
  double s0, ss0, m0, v0, s1, ss1, m1, v1, vmin, vgng;
  // initialisation des statistiques de la classe 0
  m0 = s0 = ss0 = v0 = 0;

  // initialisation des statistiques de la classe 1
  s1 = ss1 = 0;
  for (g = 0; g < histogram.getSize(); ++g)
  {
    n1 += histogram[g];
    s1 += g * histogram[g];
    ss1 += g * g * histogram[g];
  }
  m1 = s1 / n1;
  v1 = ss1 / n1 - m1 * m1;

  vmin = v1;
  gmin = 0;

  for (g = 0; g < histogram.getSize(); ++g)
  {
    n0 += histogram[g];
    n1 -= histogram[g];
    vgng = g * histogram[g];
    s0 += vgng;
    s1 -= vgng;
    ss0 += g * vgng;
    ss1 -= g * vgng;

    if ( n0 && n1 )
    {
      m0 = s0 / n0;
      m1 = s1 / n1;
      v0 = ss0 / n0 - m0 * m0;
      v1 = ss1 / n1 - m1 * m1;
      if ( v0 + v1 < vmin )
      {
        vmin = v0 + v1;
        gmin = g + 1;
      }
    }
  }

    return gmin;
#endif
}
void AncillaryMethods::swapVectorMatrix(Vector<Matrix <double> >& src)
{
    Vector<Matrix <double> > aux;
    for( int i = 0; i < src.getSize(); i++)
    {
        aux.pushBack(src(i));
    }
    src.clearContent();
    for( int i = 0; i < aux.getSize(); i++)
    {
        src.pushBack(aux(aux.getSize() - 1 - i));
    }
}
bool DecisionTreeClusterNode::computeSplit( const UINT &numSplittingSteps, const ClassificationData &trainingData, const Vector< UINT > &features, const Vector< UINT > &classLabels, UINT &featureIndex, Float &minError ){

    const UINT M = trainingData.getNumSamples();
    const UINT N = features.getSize();
    const UINT K = classLabels.getSize();

    if( N == 0 ) return false;
    if( K == 0 ) return false;

    minError = grt_numeric_limits< Float >::max();
    Random random;
    UINT bestFeatureIndex = 0;
    Float bestThreshold = 0;
    Float error = 0;
    Vector< UINT > groupIndex(M);
    Vector< MinMax > ranges = trainingData.getRanges();
    MatrixDouble data(M,1); //This will store our temporary data for each dimension

    //Randomly select which features we want to use
    UINT numRandomFeatures = numSplittingSteps > N ? N : numSplittingSteps;
    Vector< UINT > randomFeatures = random.getRandomSubset( 0, N, numRandomFeatures );

    //Loop over each random feature and try and find the best split point
    for(UINT n=0; n<numRandomFeatures; n++){

        featureIndex = features[ randomFeatures[n] ];

        //Use the data in this feature dimension to create a sum dataset
        for(UINT i=0; i<M; i++){
            data[i][0] = trainingData[i][featureIndex];
        }

        if( computeError( trainingData, data, classLabels, ranges, groupIndex, featureIndex, threshold, error ) ){
            //Store the best threshold and feature index
            if( error < minError ){
                minError = error;
                bestThreshold = threshold;
                bestFeatureIndex = featureIndex;
            }
        }
     }

     //Set the best feature index that will be returned to the DecisionTree that called this function
     featureIndex = bestFeatureIndex;

     //Store the node size, feature index, best threshold and class probabilities for this node
     set( M, featureIndex, bestThreshold, trainingData.getClassProbabilities(classLabels) );

     return true;
}
Example #13
0
void TestVector::getSize()
{
	tools->setFunctionName("getSize");
	{
		Vector<int> instance;
		instance.insert(0,1);
		instance.insert(1,2);
		instance.insert(2,3);
    tools->assertEquals(instance.getSize(),(unsigned)3);
    instance.insert(3,4);
    instance.insert(4,5);
    tools->assertEquals(instance.getSize(),(unsigned)5);
	}
}
Example #14
0
void TestVector::copyConstructor()
{
	tools->setFunctionName("copyConstructor");
	{
		Vector<int> copyFrom;
		copyFrom.insert(0,5);
		copyFrom.insert(1,6);
		copyFrom.insert(2,7);
		tools->assertEquals( copyFrom.get(0), 5);
		tools->assertEquals( copyFrom.get(1), 6);
		tools->assertEquals( copyFrom.get(2), 7);
		Vector<int> copyTo( copyFrom );
		tools->assertEquals(copyTo.get(0),5);
		tools->assertEquals(copyTo.get(1),6);
		tools->assertEquals(copyTo.get(2),7);
		tools->assertEquals(copyFrom.getSize(),copyTo.getSize());
		tools->assertEquals(copyFrom.getMaxSize(),copyTo.getMaxSize());
	}
	{
		Vector<const char *> copyFrom;
		copyFrom.insert(0,"Clem");
		copyFrom.insert(1,"W");
		copyFrom.insert(2,"Davies");
		tools->assertEquals( copyFrom.get(0), "Clem");
		tools->assertEquals( copyFrom.get(1), "W");
		tools->assertEquals( copyFrom.get(2), "Davies");
		Vector<const char *> copyTo( copyFrom );
		tools->assertEquals(copyTo.get(2),"Davies");
		tools->assertEquals(copyTo.get(1),"W");
		tools->assertEquals(copyTo.get(0),"Clem");
	}
}
Example #15
0
void TestVector::paramConstructor()
{
	tools->setFunctionName("paramConstructor");
	{
		Vector<int> instance(3);
		tools->assertEquals(instance.getMaxSize(),(unsigned)10);
	}
	{
		Vector<int> instance(100);
		tools->assertEquals(instance.getMaxSize(),(unsigned)100);
	}
	{
		Vector<const char *> instance(100);
		tools->assertEquals(instance.getMaxSize(),(unsigned)100);
	}
	{
	  tools->description("Vector of Vectors");
		Vector<Vector<int>> instance;
		Vector<int> inner;
		inner.insert(0,55);
		instance.insert(0,inner);
		tools->assertEquals(instance.getSize(),(unsigned)1);
		tools->assertEquals(instance.get(0).getSize(),(unsigned)1);
		tools->assertEquals(instance.getMaxSize(),(unsigned)10);
		tools->assertEquals(instance.get(0).getMaxSize(),(unsigned)10);
		tools->assertEquals(instance.get(0).get(0),55);
	}
}
Vector<T> GaussianElimination<T>::operator()(MatrixBase<T>& A, const Vector<T>& b)
{
  Vector<T> x( b.getSize() );
  
  Matrix<T> newA(A.getNumRows(),A.getNumCols());
  newA = A;
  newA.addColumn(b);
  
  // Forward Elimination
  for(int i=1; i < newA.getNumRows(); i++)
  {
    reduceDown(newA, i);
  }
  // Backward Elimination
  for(int i=newA.getNumRows()-2; i >= 0; i--)
  {
    reduceUp(newA, i);
  }
  // Solve for x
  for(int i=0; i < x.getSize(); i++)
  {
    x[i] = newA(i,newA.getNumCols()-1) / newA(i,i);
  }
  
  return x;
}
Example #17
0
 void updateBest(Vector<int> const& permutation)
 {
     for(int i = 0; i < permutation.getSize(); ++i) DEBUG(permutation[i]);
     current = permutation;
     currentEval = fullScore();
     updateBest();
 }
void Matrix<T>::addColumn(const Vector<T>& newCol)
{
  if(newCol.getSize() != numRows) throw SizeError(newCol.getSize());
  Vector<T> temp(numCols + 1);
  for(int i=0; i < numRows; i++)
  {
    for(int j=0; j < numCols; j++)
    {
      temp[j] = head[i][j];
    }
    temp[numCols] = newCol[i];
    head[i].setSize(numCols + 1);
    head[i] = temp;
  }
  numCols++;
}
Example #19
0
Matrix<T> CDFTools<T>::percentiles(
  const vector<const Vector<T>*>& x,
  const Vector<T>& xEvals,
  const Vectorf& percents) const
{
  const int numSamples = x.size();
  const int numEvals = xEvals.getSize();
  const int numPercents = percents.getSize();
  Matrix<T> matrix( numEvals, numSamples );
  Matrix<T> y( numPercents, numEvals );

  for (int i = 0; i < numSamples; ++i)
  {
    matrix.setColumn( i, cdf(*x[i],xEvals) );
  }

  for (int j = 0; j < numEvals; ++j)
  {
    matrix[j].sort();
    for (int p = 0; p < numPercents; ++p)
    {
      y(p,j) = matrix[j].percentile( percents[p] );
    }
  }

  return y;
}
Example #20
0
int main()
{
    Vector<int> *m = new Vector<int>();

    for  (int i = 4;i < 60;i ++) {
        m->pushBack(i);
    }

    cout << m->getSize() << endl;
    cout << m->getCapacity() << endl;
    cout << m->getFront() << endl;
    cout << m->getBack() << endl;
    cout << m->operator[](1) << endl;

    m->insert(0,32);
    m->erase(0);
    m->resize(100);

    Vector<Course> *cr = new Vector<Course>();

    Course *cpp = new Course("C++",100);
    Course *python = new Course("Python",200);
    Course *java = new Course("Java",300);

    cr->pushBack(*cpp);
    cr->pushBack(*python);
    cr->pushBack(*java);

    delete cpp;
    delete python;
    delete java;

    return 0;
}
Example #21
0
void HugeInteger< T >::convert( Vector< unsigned int > vector )
{
   // vector[ 0 ] is the most significant digit ( could be 0 )
   // vector[ vector.end() - 1 ] is the least significant digit

   unsigned int size = vector.getSize();
   Vector< unsigned int >::iterator msd = vector.begin();
   for( ; msd != vector.end(); ++msd, --size ) // find the position of the most significant nonzero digit
      if( *msd != 0 )
         break;

   // msd points to the most significant nonzero digit in vector

   if( size == 0 ) // all digits of vector are 0
      return;

   integer.resize( size );
   Vector< unsigned int >::iterator it1 = msd;
   T::reverse_iterator it2 = integer.rbegin();
   for( ; it1 != vector.end(); ++it1, --it2 )
      *it2 = *it1;

   // integer.begin() points to the least significant digit
   // integer.end() points to the most significant nonzero digit

} // end function convert
Example #22
0
Vector<double> OtsuThresholding<T>::computeCriterion(const Vector<unsigned int>& histogram) const
{
  const int numBins = histogram.getSize();
  Vector<double> criterion( numBins );
  int n0 = 0, n1 = 0; // class sizes
  int s0 = 0, s1 = 0; // sum of values
  double m0, m1; // mean values
  double p0, p1; // class proportions
  int g;

  for (g = 0; g < numBins; ++g)
  {
    criterion[g] = 0;
    n1 += histogram[g];
    s1 += g * histogram[g];
  }

  for (g = 1; g < numBins; ++g)
  {
    n0 += histogram[g-1];
    n1 -= histogram[g-1];
    s0 += (g-1) * histogram[g-1];
    s1 -= (g-1) * histogram[g-1];
    if ( n0 > 0 && n1 > 0 )
    {
      m0 = static_cast<double>(s0) / n0;
      m1 = static_cast<double>(s1) / n1;
      p0 = static_cast<double>(n0) / (n0+n1);
      p1 = static_cast<double>(n1) / (n0+n1);
      criterion[g] = p0 * p1 * Maths::sqr( m0-m1 );
    }
  }

  return criterion;
}
Example #23
0
void timeFFMinCost()
{
    GraphAA<int> sp(6);
    Vector<FlowData> data;
    data.append(FlowData(0, 300, 0));//to 1
	sp.addUndirectedEdge(0,1,0);
	data.append(FlowData(0, 300, 0));//to 2
	sp.addUndirectedEdge(0,2,1);
	data.append(FlowData(1, 200, 7));//to 3
	sp.addUndirectedEdge(1,3,2);
	data.append(FlowData(1, 200, 6));//to 4
	sp.addUndirectedEdge(1,4,3);
	data.append(FlowData(2, 280, 4));//to 3
	sp.addUndirectedEdge(2,3,4);
	data.append(FlowData(2, 350, 6));//to 4
	sp.addUndirectedEdge(2,4,5);
	data.append(FlowData(3, 300, 0));//to 5
	sp.addUndirectedEdge(3,5,6);
	data.append(FlowData(4, 300, 0));//to 5
	sp.addUndirectedEdge(4,5,7);

	ShortestAugmentingPath<GraphAA<int> > dk(sp, data, 0, 5, 600);
	for(int i = 0; i < data.getSize(); ++i)
    {
        DEBUG(data[i].flow);
        DEBUG(data[i].capacity);
    }
    DEBUG(dk.total);
}
Example #24
0
void testMST()
{
    typedef GraphAA<double> G;
    G sp;
    for(int i = 0; i < 5; ++i)
	{
		sp.addVertex();
	}
	sp.addEdge(0,1,2);
	sp.addEdge(0,3,8);
	sp.addEdge(0,4,4);
	sp.addEdge(1,0,2);
	sp.addEdge(1,2,3);
	sp.addEdge(2,1,3);
	sp.addEdge(2,3,5);
	sp.addEdge(2,4,1);
	sp.addEdge(3,0,8);
	sp.addEdge(3,2,5);
	sp.addEdge(3,4,7);
	sp.addEdge(4,0,4);
	sp.addEdge(4,2,1);
	sp.addEdge(4,3,7);

    Vector<int> mst = MST(sp);
    for(int i = 0; i < mst.getSize(); ++i)
    {
        DEBUG(mst[i]);
    }
}
Example #25
0
bool ClassificationData::merge(const ClassificationData &otherData){

    if( otherData.getNumDimensions() != numDimensions ){
        errorLog << "merge(const ClassificationData &labelledData) - The number of dimensions in the labelledData (" << otherData.getNumDimensions() << ") does not match the number of dimensions of this dataset (" << numDimensions << ")" << std::endl;
        return false;
    }

    //The dataset has changed so flag that any previous cross validation setup will now not work
    crossValidationSetup = false;
    crossValidationIndexs.clear();

    const UINT M = otherData.getNumSamples();
    
    //Reserve the memory
    reserve( getNumSamples() + M );

    //Add the data from the labelledData to this instance
    
    for(UINT i=0; i<M; i++){
        addSample(otherData[i].getClassLabel(), otherData[i].getSample());
    }

    //Set the class names from the dataset
    Vector< ClassTracker > classTracker = otherData.getClassTracker();
    for(UINT i=0; i<classTracker.getSize(); i++){
        setClassNameForCorrespondingClassLabel(classTracker[i].className, classTracker[i].classLabel);
    }

    //Sort the class labels
    sortClassLabels();

    return true;
}
void AncillaryMethods::ExtractSlopsOnBorder(const Matrix<double>& image, Vector<double>& ys, Vector<double>& slopes, int start_x, int end_x, int start_y, int end_y)
{
    if(end_x<0)
        end_x = image.x_size() - start_x - 1;
    if(end_y<0)
        end_y = image.y_size() - start_y - 1;

    slopes.setSize(end_x - start_x + 1);

    ys.setSize(end_x - start_x + 1);

    for(int x = start_x ; x <= end_x; ++x)
    {
        int y0= end_y;
        for(int y=start_y; y<=end_y; ++y)
        {
            if(image(x,y) > 0)
            {
                y0 = y;
                break;
            }
        }
        ys(x - start_x) = end_y - y0;
    }

    ys = AncillaryMethods::conv1D(ys, AncillaryMethods::getGaussian1D(3,1));

    for(int i=0; i<ys.getSize()-1; ++i)
        slopes(i) = ys(i+1) - ys(i);
    slopes(end_x - start_x) = 0;
}
double SumaCuadrados::getEvaluation(Vector<double> argument)
{

    if (argument.getSize() != numberOfVariables){
        std::cout << std::endl
                  << "Error: SumaCuadrados class. Metodo getEvaluation " << std::endl
                  << "dimension vector coeficientes incorrecta" << std::endl
                  << std::endl;
        exit(1);
    }

    // valores estimados en la regresiĆ³n

    Vector<double> res = Residuals(argument);
    // tbc


    // error = sum(error^2)
    double error = 0;
    for (int irow=0;irow<ModelMatrix.getNumberOfRows();irow++){
    	error+=res[irow]*res[irow];
    }

    //tbc
    return error;
}
void Detector::ExtractPointsInROIs(/*Vector<Vector<Vector<double> > > &all_points_in_ROIs*/Vector<ROI> &all_ROIs, const Matrix<int> &mat_2D_pos_x, const Matrix<int> &mat_2D_pos_y, const PointCloud& point_cloud, const Matrix<int> &labeled_ROIs)
{
//    int number_of_ROIs = all_points_in_ROIs.getSize();
    int number_of_ROIs = all_ROIs.getSize();

//    for(int i = 0; i < number_of_ROIs; i++)
//    {
//        all_points_in_ROIs(i).reserveCapacity(50000);
//    }

    Vector<ROIBound> min_maxs(number_of_ROIs);
    ROIBound* roi_bound;
    int roi_ind;
    int mat_size = mat_2D_pos_x.x_size()*mat_2D_pos_x.y_size();
    for(int i = 0; i < mat_size; i++)
    {
        if(mat_2D_pos_x.data()[i] >= 0)
        {
            roi_ind = labeled_ROIs(mat_2D_pos_x.data()[i], mat_2D_pos_y.data()[i])-1;
            if(roi_ind > -1)
            {
//                all_points_in_ROIs(pos_in_proj).pushBack(Vector<double>(point_cloud.X(i), point_cloud.Y(i), point_cloud.Z(i)));
                all_ROIs(roi_ind).has_any_point = true;
                double x = point_cloud.X(i), y = point_cloud.Y(i), z = point_cloud.Z(i);
                roi_bound = &min_maxs(roi_ind);
                if(roi_bound->min_x > x)
                {
                    roi_bound->min_x = x;
                    all_ROIs(roi_ind).ind_min_x = i;
                }
                if(roi_bound->max_x < x)
                {
                    roi_bound->max_x = x;
                    all_ROIs(roi_ind).ind_max_x = i;
                }
                if(roi_bound->min_y > y)
                {
                    roi_bound->min_y = y;
                    all_ROIs(roi_ind).ind_min_y = i;
                }
                if(roi_bound->max_y < y)
                {
                    roi_bound->max_y = y;
                    all_ROIs(roi_ind).ind_max_y = i;
                }
                if(roi_bound->min_z > z)
                {
                    roi_bound->min_z = z;
                    all_ROIs(roi_ind).ind_min_z = i;
                }
                if(roi_bound->max_z < z)
                {
                    roi_bound->max_z = z;
                    all_ROIs(roi_ind).ind_max_z = i;
                }
            }
        }
    }
}
Example #29
0
// Tests the square function
TEST(Classifier, RegisteredClassifiers) {
  
  //Get a list of the registered classifiers
  Vector< std::string > registeredClassifiers = Classifier::getRegisteredClassifiers();

  //The classifier list should be great than zero
  EXPECT_TRUE( registeredClassifiers.getSize() > 0 );
}
Example #30
0
void ShellSort<VAL>::sort(Vector<VAL> & vec) {
  int del = vec.getSize();
  while (del > 1) {
    del = deltaF(del);
    trace("Delta: " << del << endl);
    deltaSort(del,vec);
  };
}