Question: To make sure we have access to appropriate programming tools, please write a small library (including a header file) of serial C functions that perform

To make sure we have access to appropriate programming tools, please write a small library (including a header file) of serial C functions that perform as described. In a separate C file write a main routine that uses your library to generate a small-ish array of random values and show that the standard deviation lowers as the array is smoothed.

void random_array(double* array, int size, double scale);

load an array with random double values scaled by scale (random number generators generate double values between 0 and 1). Note: array should point to memory already allocated.

double sum(double* array, int size);

return the sum of all elements in the array

double stdev(double* array, int size);

calculate the standard deviation of the elements in array

void smooth(double* array, int size, double w);

replace all internal values (not the first or last) with a weighted sum of itself and average of the neighboring elements newvali = oldvali w + (oldvali1 + oldvali+1)(1 w)/2

Compiler to use:

Please compile your code by hand, using gcc with the -Wall flag to provide compiler warnings. You should fix your code so that no warnings appear. You can install gcc in Windows using Cygwin.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!