One of the most common numerical kernels is the dot product. Given two vectors (r1,x2, ..., xn) and (y1, Y2, .. Yn), their dot product is

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Please provide me complete and correct solution thanks 2
One of the most common numerical kernels is the dot product. Given two vectors (21, 2,..., 2n)
and (y1, Y2, ... , Yn), their dot product is
x1yı + x2Y2 + ·+ xnYn.
Starting with the code
dot.c
double dot (const double *const x, const double *const y, const long int n)
{
write a C function dot () that returns the dot product of the vectors x and y. The latter are
pointers to two C arrays of length n. Do not change the signature of the function. Be sure
to accumulate the answer in double precision.
The const declaration in const long int n means that n cannot be changed in the
function. The declaration const * const x means that x is a constant pointer to constant
values. That is, we cannot change x nor anything it points to (e.g., x[0]).
What to do
Create your C code in a file named dot.c. If you want to test it while keeping your test
code in a separate file, here is how you do it. If your test code (including main()) is in the
file main.c, then you can build an executable with
gcc -Wall -pedantic -o dot main.c dot.c
./dot
You can compile your dot.c into object code, the first step in building an executable, with
the command
gcc -Wall -pedantic -c dot.c
./dot
This will create a file dot.o.
Submit your file dot.c and the corresponding Linux object file dot.o to the autograder
on Gradescope for grading. An object file built on a Mac or a Windows system will not
work in a Linux environment such as Gradescope.
Transcribed Image Text:One of the most common numerical kernels is the dot product. Given two vectors (21, 2,..., 2n) and (y1, Y2, ... , Yn), their dot product is x1yı + x2Y2 + ·+ xnYn. Starting with the code dot.c double dot (const double *const x, const double *const y, const long int n) { write a C function dot () that returns the dot product of the vectors x and y. The latter are pointers to two C arrays of length n. Do not change the signature of the function. Be sure to accumulate the answer in double precision. The const declaration in const long int n means that n cannot be changed in the function. The declaration const * const x means that x is a constant pointer to constant values. That is, we cannot change x nor anything it points to (e.g., x[0]). What to do Create your C code in a file named dot.c. If you want to test it while keeping your test code in a separate file, here is how you do it. If your test code (including main()) is in the file main.c, then you can build an executable with gcc -Wall -pedantic -o dot main.c dot.c ./dot You can compile your dot.c into object code, the first step in building an executable, with the command gcc -Wall -pedantic -c dot.c ./dot This will create a file dot.o. Submit your file dot.c and the corresponding Linux object file dot.o to the autograder on Gradescope for grading. An object file built on a Mac or a Windows system will not work in a Linux environment such as Gradescope.
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY