np.array: computes matrix-vector multiplication via the width=1149 height=398> 7 Defining Matrix-Vector Multiplication Your- self (Programming) (15
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
7 Defining Matrix-Vector Multiplication Your- self (Programming) (15 points) This week you will be writing your own definition of matrix-vector multiplication in Python. This will give you the opportunity to work with numpy arrays directly if you haven't already (all your previous assignments have only required indirect use of numpy arrays). Read through the docstring of each function carefully. You are given starter code in the file hw04prog.py. Don't change the name of this file when you submit. Also don't change the names of the functions included in the starter code. The only changes you should make are to fill in the TODO items in the starter code. There are three functions you need to fill in. • inner_product, which computes the inner product of two vectors. Recall that the inner product, also called the dot product, is defined as 212 0.0 Un = U1V₁ + U2V₂ + … + Un ³n = Σ U₂V₂ Vn i=1 • mat_vec_mult_ip, which computes matrix-vector multiplication using the row-column rule and inner products: a11 a12 021 022 ⠀ : aml am2 [a₁ 82 ain a2n an ⠀ amn V₂ V1 V2 Zi=1 amivi] Recall that the rows of a numpy array are themselves numpy arrays, so you should be able to use your inner product function directly here. • mat-vec-mult_vs, which computes matrix-vector multiplication, but using the definition we gave in class: V1 U2 = Un Σ" =1 alivi Zi=192ivi : = V₁ª₁ + V₂ª2 + … ·· + Vnªn Of course, the last two functions will compute the same vector, but they will do so in different ways. The first should compute each entry of the output vector individually, whereas the second should compute a linear combination of the columns of the given matrix using addition and scaling of numpy arrays. For this assignment you are not allowed use built in numpy functions for inner products or matrix-vector multiplication, like np.inner or np. dot or . The point is for you to implement your own. You will upload the single python file hw04prog.py to Gradescope with your implementations of the required functions. We will be running autograder tests on your submission to determine its correctness. You will not have access to the autograder tests. 7 Defining Matrix-Vector Multiplication Your- self (Programming) (15 points) This week you will be writing your own definition of matrix-vector multiplication in Python. This will give you the opportunity to work with numpy arrays directly if you haven't already (all your previous assignments have only required indirect use of numpy arrays). Read through the docstring of each function carefully. You are given starter code in the file hw04prog.py. Don't change the name of this file when you submit. Also don't change the names of the functions included in the starter code. The only changes you should make are to fill in the TODO items in the starter code. There are three functions you need to fill in. • inner_product, which computes the inner product of two vectors. Recall that the inner product, also called the dot product, is defined as 212 0.0 Un = U1V₁ + U2V₂ + … + Un ³n = Σ U₂V₂ Vn i=1 • mat_vec_mult_ip, which computes matrix-vector multiplication using the row-column rule and inner products: a11 a12 021 022 ⠀ : aml am2 [a₁ 82 ain a2n an ⠀ amn V₂ V1 V2 Recall that the rows of a numpy array are themselves numpy arrays, so you should be able to use your inner-product function directly here. • mat-vec-mult_vs, which computes matrix-vector multiplication, but using the definition we gave in class: V1 U2 = Un Σ" =1 alivi Zi=192ivi : Zi=1 ami vi] = V₁ª₁ + V₂ª2 + …·· + Vnªn Of course, the last two functions will compute the same vector, but they will do so in different ways. The first should compute each entry of the output vector individually, whereas the second should compute a linear combination of the columns of the given matrix using addition and scaling of numpy arrays. For this assignment you are not allowed use built in numpy functions for inner products or matrix-vector multiplication, like np.inner or np. dot or . The point is for you to implement your own. You will upload the single python file hw04prog.py to Gradescope with your implementations of the required functions. We will be running autograder tests on your submission to determine its correctness. You will not have access to the autograder tests. 7 Defining Matrix-Vector Multiplication Your- self (Programming) (15 points) This week you will be writing your own definition of matrix-vector multiplication in Python. This will give you the opportunity to work with numpy arrays directly if you haven't already (all your previous assignments have only required indirect use of numpy arrays). Read through the docstring of each function carefully. You are given starter code in the file hw04prog.py. Don't change the name of this file when you submit. Also don't change the names of the functions included in the starter code. The only changes you should make are to fill in the TODO items in the starter code. There are three functions you need to fill in. • inner_product, which computes the inner product of two vectors. Recall that the inner product, also called the dot product, is defined as 212 0.0 Un = U1V₁ + U2V₂ + … + Un ³n = Σ U₂V₂ Vn i=1 • mat_vec_mult_ip, which computes matrix-vector multiplication using the row-column rule and inner products: a11 a12 021 022 ⠀ : aml am2 [a₁ 82 ain a2n an ⠀ amn V₂ V1 V2 Zi=1 amivi] Recall that the rows of a numpy array are themselves numpy arrays, so you should be able to use your inner product function directly here. • mat-vec-mult_vs, which computes matrix-vector multiplication, but using the definition we gave in class: V1 U2 = Un Σ" =1 alivi Zi=192ivi : = V₁ª₁ + V₂ª2 + … ·· + Vnªn Of course, the last two functions will compute the same vector, but they will do so in different ways. The first should compute each entry of the output vector individually, whereas the second should compute a linear combination of the columns of the given matrix using addition and scaling of numpy arrays. For this assignment you are not allowed use built in numpy functions for inner products or matrix-vector multiplication, like np.inner or np. dot or . The point is for you to implement your own. You will upload the single python file hw04prog.py to Gradescope with your implementations of the required functions. We will be running autograder tests on your submission to determine its correctness. You will not have access to the autograder tests. 7 Defining Matrix-Vector Multiplication Your- self (Programming) (15 points) This week you will be writing your own definition of matrix-vector multiplication in Python. This will give you the opportunity to work with numpy arrays directly if you haven't already (all your previous assignments have only required indirect use of numpy arrays). Read through the docstring of each function carefully. You are given starter code in the file hw04prog.py. Don't change the name of this file when you submit. Also don't change the names of the functions included in the starter code. The only changes you should make are to fill in the TODO items in the starter code. There are three functions you need to fill in. • inner_product, which computes the inner product of two vectors. Recall that the inner product, also called the dot product, is defined as 212 0.0 Un = U1V₁ + U2V₂ + … + Un ³n = Σ U₂V₂ Vn i=1 • mat_vec_mult_ip, which computes matrix-vector multiplication using the row-column rule and inner products: a11 a12 021 022 ⠀ : aml am2 [a₁ 82 ain a2n an ⠀ amn V₂ V1 V2 Recall that the rows of a numpy array are themselves numpy arrays, so you should be able to use your inner-product function directly here. • mat-vec-mult_vs, which computes matrix-vector multiplication, but using the definition we gave in class: V1 U2 = Un Σ" =1 alivi Zi=192ivi : Zi=1 ami vi] = V₁ª₁ + V₂ª2 + …·· + Vnªn Of course, the last two functions will compute the same vector, but they will do so in different ways. The first should compute each entry of the output vector individually, whereas the second should compute a linear combination of the columns of the given matrix using addition and scaling of numpy arrays. For this assignment you are not allowed use built in numpy functions for inner products or matrix-vector multiplication, like np.inner or np. dot or . The point is for you to implement your own. You will upload the single python file hw04prog.py to Gradescope with your implementations of the required functions. We will be running autograder tests on your submission to determine its correctness. You will not have access to the autograder tests.
Expert Answer:
Answer rating: 100% (QA)
The images show an assignment where you are required to define matrixvector multiplication and related functions without using builtin NumPy functiona... View the full answer
Related Book For
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts
Posted Date:
Students also viewed these programming questions
-
How do resource mobilization theories, as advanced by scholars like Charles Tilly and Mayer Zald, illuminate the processes through which social movements emerge, organize, and mobilize resources to...
-
The purpose of this project is to work more with lists, looping, file I/O, functions, and dictionaries. For this assignment, you will work with real data from the web. Background Major solar storms...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
A driver of a car is initially 455 miles from home, traveling toward home on a straight freeway at 70 miles per hour. (a) Write a formula for a linear function f that models the distance between the...
-
The reflecting surfaces of two intersecting flat mirrors are at an angle θ (0° For a light ray that strikes the horizontal mirror, show that the emerging ray will intersect the incident ray...
-
Jetter Engine Corporation manufactures a single model of gasoline engine used in lawn mowers, portable generators, and pumps. The basic engine block is cast from steel and machined in the Casting...
-
Number of classes: 6 Data set: Amounts (in dollars) spent on conveyance for a quarter of a year. Construct a frequency distribution for the data set using the indicated number of classes. In the...
-
The rectangular gate of width w is pinned at its center A and is prevented from rotating by the block at B. Determine the reactions at these supports due to hydrostatic pressure. Units Used: Mg = 103...
-
An overhead absorption rate of $ 1 2 per direct labour hour was established based on a budget of 2 , 1 0 0 hours. Actual direct labour hours worked were 2 , 1 8 0 and actual overhead expenditure was...
-
Air containing 1.6 vol% sulfur dioxide is scrubbed with pure water in a packed column of 1.5-m2 cross-sectional area and 3.5-m height packed with no. 2 plastic Super Intalox saddles, at a pressure of...
-
For the system in Fig. (a) Find the locus of closed-loop roots with respect to K. (b) Is there a value of K that will cause all roots to have a damping ratio greater than 0.5? (c) Find the values of...
-
4. An arrow is drawn back against a bowstring with a force of 280 N. If the arrow makes an angle of 55 with the string above and below the arrow, find the tension in the string. 5. What is the force...
-
A motion detector sends out ultrasonic pulses and listens for beat frequencies in the reflections to identify when objects are moving. If the motion sensor produces an ultrasound pulse with a...
-
23. A particle travels in a circle of radius 76 cm and completes one revolution in 4,5 s. What is the centripetal acceleration of the particle? O 3.3 m/s O2.8 m/s O 1.5 m/s O 0.97 m/s
-
Michael Heizer's "City" project in Nevada took the artist over five decades to complete. (It was completed in 2022.) Please first read the article by Michael Kimmelman's article on Michael Heizer...
-
Karen just got promoted to general manager of her restaurant, which is part of a chain. Her restaurant is located in Northern British Columbia. When she applied internally for the job, she was told...
-
What is the pH of 0.001M HCl?
-
Explain the operation of the dividends received deduction.
-
The plaintiff, John W. VonHoldt, Jr., brought the present action in the circuit court of Cook County against defendant, Barba & Barba Construction, Inc. The complaint alleged that defendant breached...
-
McCoy, an Oklahoma cattle dealer, orally agreed with Chandler, a Texas cattle broker, to ship cattle to a New Mexico feedlot for delivery to Chandler. The agreement was for six lots of cattle valued...
-
Robert and Majorie Wake owned land that they used as both a cattle ranch and a farm. Each spring and autumn, the Wakes would drive their cattle from the ranch portion of the operation across an...
-
Determine the differential equations governing the motion of the system by using the equivalent systems method. Use the generalized coordinates shown in Figures P2.54. 3L - C Slender bar of mass m...
-
Determine the differential equations governing the motion of the system by using the equivalent systems method. Use the generalized coordinates shown in Figures P2.56. --- k Thin disk of mass m...
-
Determine the differential equations governing the motion of the system by using the equivalent systems method. Use the generalized coordinates shown in Figures P2.55. FIGURE P 2.55 C k 12c Slender...
Study smarter with the SolutionInn App