Пример #1
0
void select_sort_rec(complex_t *array[], int n)
{
  int themax = 0;

	if(n==0)
	{
	return;
	}
	themax = find_biggest(array,n,0,themax);
	swap_largest(array, n, themax);
	select_sort_rec(array, n-1);

}
Пример #2
0
void analyser::start_find_peak(){
	// find single peaks "value bigger than surrounding values"
	try{
		for( unsigned int i = 1; i < data.size();i++){
			/*#ifdef DEBUG
			 std::cout << " ---- \n";
			 #endif*/
			if(this->data[i].db > this->data[i-1].db)
				//check surrounding values in the area of "MIN_RADIUS"
				if(check_radius_up(MIN_RADIUS, i, 1) && check_radius_down(MIN_RADIUS, i ,1)){
					/*#ifdef DEBUG
					 std::cout << "found peak at " << this->data[i].lambda << std::endl;
					 #endif*/
					peaks.push_back(this->data[i].lambda);
				}
		}
		//find the biggest vaules
		find_biggest();
		//sort peaks
		std::sort(peaks.begin(),peaks.end());
	}catch(std::exception err){
		std::cerr << err.what() << std::endl;
    }
}
Пример #3
0
void swap_largest(complex_t *array[], int n,int max_index)
{
	complex_t *temp;
	temp=array[max_index];
	array[max_index]=array[n-1];
	array[n-1]=temp;


int find_biggest(complex_t *array[], int n, int start, int curmax) {

	double  cabs2;
	cabs2= abs_complex(*array[start+1]);

	if (start == n-1);
	{
	return(curmax);
	}

	if (cabs2>abs_complex(*array[curmax]))
	{
	curmax=start+1;
	}
	return(find_biggest(array,n,start+1,curmax));
        }