Question: ( 4 0 points ) Create a source file named fmlxxxx _ proj 3 _ vector.c . In this file create a set of functions
points Create a source file named fmlxxxxprojvector.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!
Add element by element two vectors of doubles. Name this function vectadd
Subtract element by element two vectors of doubles. Name this function vectsub
Multiply element by element two vectors. Name this function vectprod
Compute and return the dot product of two vectors. Name this function vectdotprod 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 vectors of length that have the following values l and l the dot product of these
two vectors is:
Compute and return the mean of a single vector. Name this function vectmean
Compute and return the median of a single vector. Name this function vectmedian 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.
Compute and return the maximum element of a vector. Name this function vectmax
Compute and return the minimum element of a vector. Name this function vectmin
Write a function that reverses the elements in a given array. This function will change the original
array, passed by reference. Name this function vectreverse
The header for fmlxxxxprojvector.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 vectadd const double x const double y double ans unsigned length ;
void vectsub const double x const double y double ans unsigned length ;
void vectprodconst double x const double y double ans unsigned length;
double vectdotprod const double x const double y unsigned length ;
double vectmean const double x unsigned length ;
double vectmedian const double x unsigned length ;
double vectmax const double x unsigned length ;
double vectmin const double x unsigned length ;
void vectreverse double x unsigned length ;
Notice that a template header file is provided for you on myCourses cabeeeprojvector.h
Rename the template to fmlxxxxprojvector.h and make sure that you change the macros
#defines once your code is compiling properly. For example, change:
#define VECTADDWORKING FALSE
to this:
#define VECTADDWORKING TRUE
once the vectadd function is working properly.
points Create a nd source file and name it fmlxxxxprojvectortest.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
elements and initialize each element with sini where i is the array index
from When done properly, the array should contain approximately complete sine wave
cycles. Similarly, create an array of elements only this time initialize it with a cosine function
with amplitude 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:
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
The mean value of the sin array
The mean value of the element by element product of the sin and cos
The median value of the cos array.
The dot product of the cos and sin array.
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
