Ejemplo n.º 1
0
Dynamic::TrackSet
Dynamic::IfElseBias::matchingTracks( const Meta::TrackList& playlist,
                                     int contextCount, int finalCount,
                                     Dynamic::TrackCollectionPtr universe ) const
{
    // store the parameters in case we need to request additional matching tracks later
    m_playlist = playlist;
    m_contextCount = contextCount;
    m_finalCount = finalCount;
    m_universe = universe;

    m_tracks = Dynamic::TrackSet( universe, false );
    m_outstandingMatches = 0;

    foreach( Dynamic::BiasPtr bias, m_biases )
    {
        m_tracks = bias->matchingTracks( playlist, contextCount, finalCount, universe );
        if( m_tracks.isOutstanding() )
        {
            m_outstandingMatches++;
            return m_tracks;
        }
        else
        {
            removeDuplicate();
            if( !m_tracks.isEmpty() ) {
                return m_tracks;
            }
        }
    }
Ejemplo n.º 2
0
int main(){
	std::vector<int> array{1,2,2,3,4,4,5,6,7,8,9,1,2,1,3,15};

	removeDuplicate(array);
	std::copy(array.begin(),array.end(),std::ostream_iterator<int>(std::cout,","));
	 
}
Ejemplo n.º 3
0
int main(){
    char a[]="aaesgesbsesdgde";
    printf("%s\n",a);
    removeDuplicate(a);
    printf("%s\n",a);
    return 0;
}
Ejemplo n.º 4
0
std::vector<std::string> MailList::getMails(const std::string & emailAddressesString) const {

  auto emailAddresses = extractEmailAddresses(emailAddressesString);

  emailAddresses = filterValid(emailAddresses);

  emailAddresses = removeDuplicate(emailAddresses);

  return emailAddresses;
}
Ejemplo n.º 5
0
void ObjectBrowserWidget::loadData()
{
  const CCopasiContainer * root = CCopasiRootContainer::getRoot();
  ObjectBrowserItem * itemRoot = new ObjectBrowserItem(ObjectListView, NULL, root, objectItemList);
  itemRoot->attachKey();
  itemRoot->setObjectType(CONTAINERATTR);
  //  itemRoot->setText(0, FROM_UTF8(root->getObjectName()));
  itemRoot->setText(0, QString("COPASI"));
  itemRoot->setOpen(true);
  loadChild(itemRoot, root, true);
  removeDuplicate(objectItemList);
  loadUI();
}
char * concat_4strings(char *s1, char *s2, char *s3, char *s4){
	//Return the new string created.
	if (s1 == '\0' || s2 == '\0' || s3 == '\0' || s4 == '\0')
		return NULL;

	int i, j, len1, len2, len3, len4, finallen;
	len1 = strlen(s1);
	len2 = strlen(s2);
	len3 = strlen(s3);
	len4 = strlen(s4);
	finallen = len1 + len2 + len3 + len4;
	char *result, *temp, *temp1, *flag;
	result = (char *)malloc(finallen * sizeof(char));
	temp = (char *)malloc(finallen * sizeof(char));
	temp1 = (char *)malloc(finallen * sizeof(char));
	flag = (char *)malloc(finallen * sizeof(char));
	temp = strcat(s1, s2);
	temp1 = strcat(s3, s4);
	flag = strcat(temp, temp1);
	result = removeDuplicate(flag);
	return result;

}
Ejemplo n.º 7
0
vector<int> CPCAOnFFT::selectPivots(CMetricDistance *metric, vector<shared_ptr<CMetricData> > &data, 

                                    int first, int dataSize, int numPivots)

{



	if (numPivots >= dataSize) 

	{

		vector<int>* pivots=new vector<int>;

		for (int i = first; i < first+dataSize + 0; i++)

			pivots->push_back(i);

		

		return removeDuplicate(metric, data, *pivots,first,dataSize);

	}
	
	


   CFFTPivotSelectionMethod FFTMethod;

	vector<int> fftResult = FFTMethod.selectPivots(metric,data,first,dataSize, numPivots*FFTScale);

	
	 if(fftResult.size() <= min(numPivots, dataSize))

        return fftResult;

	

    gsl_matrix* matrix = gsl_matrix_alloc(dataSize, fftResult.size());

 
	for (int col = 0; col < fftResult.size(); col++)
            for (int row = 0; row < dataSize; row++)
                gsl_matrix_set(matrix, row, col, metric->getDistance( data.at(row).get(), data.at(fftResult.at(col)).get() ));


    gsl_matrix* pcaResult = gsl_matrix_alloc( numPivots, fftResult.size());

	

    try

    {

        pcaResult = CPCA::EMPCA( matrix, numPivots);

    }

    catch(exception e)

    {

        cout<< "Exception!  data size =" << dataSize 

            << " , num pivots = " << numPivots << endl;  

        cout<< e.what() << endl;



        if (numPivots >= fftResult.size())

            return fftResult;

        else

        {

            fftResult.resize(numPivots);

            return fftResult;

        }

    }

    vector<int> selectByAngleResult 

        = CPCA::pivotSelectionByAngleWithAxes( pcaResult, numPivots);
	 
    vector<int> finalResult;
    for (int i = 0; i < numPivots; ++i)
    {	
		finalResult.push_back( fftResult.at( selectByAngleResult.at(i) ));
    }


	

	/*vector<int> selectByProjectionResult  
	      = CPCA::pivotSelectionByPCAResultProjection( matrix,pcaResult, numPivots);
	     
	
    vector<int> finalResult;

    for (int i = 0; i < numPivots; ++i)

    {
		finalResult.push_back( selectByProjectionResult .at(i) + first ) ;
    }*/

	
	

	/*vector<int> selectByAngleResult 
	      = CPCA::pivotSelectionByAngleWithPoint( matrix,pcaResult, numPivots);
	  
    vector<int> finalResult;

    for (int i = 0; i < numPivots; ++i)

    {
		finalResult.push_back( selectByAngleResult.at(i) +first) ;
    }*/

	
	
	
	return finalResult;


}
Ejemplo n.º 8
0
int main(){
  int c, n, r;
  do {
    printf("0.  Show\n");
    printf("1.  Append\n");
    printf("2.  Push\n");
    printf("3.  pop\n");
    printf("4.  Count Nodes\n");
    printf("5.  Get nth element\n");
    printf("6.  Delete List\n");
    printf("7.  Insert at nth index\n");
    printf("8.  InsertSort the List\n");
    printf("9.  FrontBackSplit\n");
    printf("10. Remove Duplicates\n");
    printf("11. Reverse the List\n");
    printf("12. Alternating Split\n");
    printf("13. Make a Dummy List\n");
    printf("14. Shuffle Merge\n");
    printf("15. EXIT\n");
    printf("Your Choice : ");
    scanf("%d", &c);
    switch(c){
      case 0 : show();
               break;
      case 1 : printf("Enter a number : ");
               scanf("%d", &n);
               append(n);
               break;
      case 2 : printf("Enter a number : ");
               scanf("%d", &n);
               push(n);
               break;         
      case 3 : if((r = pop()) > 0)
                 printf("%d\n", r);
               else
                 printf("List Empty\n");  
               break;
      case 4 : printf("%d\n", countNodes());
               break;
      case 5 : printf("Enter the index : ");
               scanf("%d", &n);
               ((r = getNth(n)) >= 0) ? printf("%d\n", r) : printf("Index out of Range\n");
               break;
      case 6 : deleteList();
               break;
      case 7 : printf("Enter the index and the number : ");
               scanf("%d%d", &r, &n);
               if(insertNth(r, n) < 0)
                 printf("Index out of Range. Aborting...");
               break;
      case 8 : insertSort();
               break;
      case 9 : frontBackSplit();
               break;
      case 10: removeDuplicate();
               break;
      case 11: reverse();
               break;
      case 12: alternatingSplit();
               break;    
      case 13: makeDummyList();
               break; 
      case 14: shuffleMerge();
               break;                                                                                           
      case 15: exit(0);         
      default: printf("wrong Choice\n");
               exit(0);                  
    }
  }while(c >= 0 && c <= 14);
}
Ejemplo n.º 9
0
vector<int> CFFTPivotSelectionMethod::selectPivots(CMetric *metric, vector<CIndexObject*> &data,int first, int dataSize, int numPivots, int firstPivot)
{
	if (numPivots >= dataSize) //if the number of pivots required is bigger than dataSize then return all the points in the data(duplicate removed).
	{
		vector<int>* pivots = new vector<int>;
		for (int i = first; i < first+dataSize + 0; i++)
			pivots->push_back(i);

		return removeDuplicate(metric, data, *pivots,first,dataSize);
	}

	bool* isCenter = new bool[dataSize];
	double* minDist = new double[dataSize];
	for (int i = 0; i < dataSize; i++)
	{
		isCenter[i] = false;
		minDist[i] = DBL_MAX;
	}

	 isCenter[firstPivot-first] = true;

	 int* indices = new int[numPivots]; // indices is used to record the offsets
                                       // of the pivots in the original data list
	 indices[0] = firstPivot;

	 for (int i = 1; i < numPivots; i++)
                indices[i] = -1;
	 // transparently firstPivot is found already 


	 for (int centerSize = 1; centerSize < numPivots; centerSize++)
	 {
		        double currMaxDist = -1;
                CIndexObject* const lastCenter = data[indices[centerSize - 1]];
				
                for (int i = 0; i < dataSize; i++)
                {
                    if (isCenter[i] == false) // if the point is not a center, we should calculate the distance
											// between this point and the set of Centers, for each centerSize we
											// grasp one Center form the set of Centers.
                    {
                        double tempDist = metric->getDistance(data[i + first], lastCenter);

                        minDist[i] = (tempDist < minDist[i]) ? tempDist : minDist[i];

                        // TODO
                        if (minDist[i] > currMaxDist)
                        {
                            indices[centerSize] = i+first; // save the index the
                                                     // current farthest
                                                     // point
                            currMaxDist = minDist[i];
                        }

                    }
                }

                if (indices[centerSize] == -1)
                    break;
                else
                    isCenter[indices[centerSize]-first] = true;
	 }

	int returnSize = 0;
	while ((returnSize < numPivots) && (indices[returnSize] >= 0))
		returnSize++;

	// to decide the size of the result vector.
	if (returnSize > numPivots)
		returnSize = numPivots;
	vector<int> result;
	for(int i=0; i<returnSize; i++)
		result.push_back(indices[i]);
	return result;


}