Question: ( 4 0 points ) Create a source file named fmlxxxx _ proj 3 _ vector.c . In this file create a set of functions

(40 points) Create a source file named fmlxxxx_proj3_vector.c. In this file create a set of functions that
process a single dimension array (vector) of doubles of arbitrary length for each operation listed below.
Make sure you don't have any printf statements in this file!
5.1. Add (element by element) two vectors of doubles. Name this function vect_add().
5.2. Subtract (element by element) two vectors of doubles. Name this function vect_sub().
5.3. Multiply (element by element) two vectors. Name this function vect_prod().
5.4. Compute and return the dot product of two vectors. Name this function vect_dot_prod(). The dot
product operation is the result of taking two vectors (single dimension arrays) and multiplying
corresponding element by element and then adding up the sum of all the products. For example, if I
have 2 vectors of length 3 that have the following values {l,2,3} and {3,2, l} the dot product of these
two vectors is: 1*3+2*2+3*1=10
5.5. Compute and return the mean of a single vector. Name this function vect_mean().
5.6. Compute and return the median of a single vector. Name this function vect_median(). First sort
the array. If the length of the sorted array is odd, then the median is the middle element. If the
length is even, the median is the average of the middle two elements. You can use the bubble sort
algorithm covered in class, provided by the book.
5.7. Compute and return the maximum element of a vector. Name this function vect_max().
5.8. Compute and return the minimum element of a vector. Name this function vect_min().
5.9. Write a function that reverses the elements in a given array. This function will change the original
array, passed by reference. Name this function vect_reverse().
5.10. The header for fmlxxxx_proj3_vector.h should contain the following function prototypes. Notice that
for the first three functions, the result is stored in array ans[], it is not "returned".
void vect_add( const double x[], const double y[], double ans[], unsigned length );
void vect_sub( const double x[], const double y[], double ans[], unsigned length );
void vect_prod(const double x[], const double y[], double ans[], unsigned length);
double vect_dot_prod( const double x[], const double y[], unsigned length );
double vect_mean( const double x[], unsigned length );
double vect_median( const double x[], unsigned length );
double vect_max( const double x[], unsigned length );
double vect_min( const double x[], unsigned length );
void vect_reverse( double x[], unsigned length );
Notice that a template header file is provided for you on myCourses (cabeee_proj3_vector.h).
Rename the template to fmlxxxx_proj3_vector.h, and make sure that you change the macros
(#defines) once your code is compiling properly. For example, change:
#define VECT_ADD_WORKING FALSE
to this:
#define VECT_ADD_WORKING TRUE
once the vect_add() function is working properly.
5.11.(20 points) Create a 2nd source file and name it fmlxxxx_proj3_vectortest.c. In the main() of this file
create an array of the values of a sine wave. Include the math.h header to use the sin floating point
function. The function sin takes an argument of radians (not degrees). Make your array 721
elements and initialize each element with 10* sin(2*3.1416*(i/360.0)) where i is the array index
from 0-720. When done properly, the array should contain approximately 2 complete sine wave
cycles. Similarly, create an array of 721 elements only this time initialize it with a cosine function
with amplitude 5. Have the program process and compute the following (in the order given); display
the title of the action and answers on the screen by using printf statements:
5.11.1. The maximum value of the cos and sin array added together. (first add cos and sin arrays,
THEN find the maximum of that resulting array).
5.11.2. The mean value of the sin array
5.11.3. The mean value of the element by element product of the sin and cos.
5.11.4. The median value of the cos array.
5.11.5. The dot product of the cos and sin array.
5.11.6. The dot product of a reversed cos array with a sin array

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 Programming Questions!