Example #1
0
int main(void)
{
    int i;

    double data[ROWS][COLS];

    double data_averages[ROWS];
    double total_average;

    double data_maxs[ROWS];
    double total_max;

    prompt(ROWS, COLS, data);

    for (i = 0; i < ROWS; i++)
    {
        data_averages[i] = get_array_average(data[i], COLS);
    }
    total_average = get_array_average(data_averages, ROWS);

    for (i = 0; i < ROWS; i++)
    {
        data_maxs[i] = get_array_max(data[i], COLS);
    }
    total_max = get_array_max(data_maxs, ROWS);

    for (i = 0; i < ROWS; i++)
    {
        printf("The average for row %d is %lf\n", i, data_averages[i]);
    }

    printf("The average for all numbers is %lf\n", total_average);
    printf("The max for all numbers is %lf\n", total_max);
    return 0;
}
Example #2
0
//Calculates the actual time difference between the signals
int time_diff::calc_time_diff(int hydr1, int hydr2, double &dtime)
{
	//Fourier transform the data, multiply, transform back
	status=fft->convolve(hydr1, hydr2, transform);
	if(status!=0)
	{
		cout<<"Error doing the convolution";
		return -1;
	}

	//Find the absolute maximum
	center=get_array_max(transform,0,size-1);
	
	cout<<"Center: "<<center<<", value: "<<transform[center]<<endl;
	//Find the rest of the maxima
	for(int k=0; k<n; k++)
	{
		maxima_x[k]=get_array_max(transform,center+low_offsets[k],center+high_offsets[k]);
		gsl_vector_set(y,k,transform[rangefix(maxima_x[k])]);
	}

	//Fit to the maxima
	quadfit->fit(y,maxima_x,dtime);
	cout<<"Dtime: "<<dtime<<endl;

	//Note that the fit actaully gives the index of the array and not the time shift
	//I still need to convert it to the actual time

	return 0;
}