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...
-
Does a raw score less than the mean correspond to a positive or negative standard score? What about a raw score greater than the mean?
-
How does a monopoly's demand for labor change if a second firm enters its output market and the result is a Stackelberg duopoly equilibrium, where the former monopoly becomes the Stackelberg leader?...
-
How will organizing your financial documents help you manage your money?
-
Given the following project (all times are in days): (a) Draw the network and find the critical path, time, and cost for an all-normal level of project activity. (b) Calculate the crash cost-per-day...
-
The marketing department of Jessi Corporation has submitted thefollowing sales forecast for the upcoming fiscal year (all salesare on account): 1st Quarter 2nd Quarter 3rd Quarter 4th QuarterBudget 2...
-
Holmes Corporation is a leading designer and manufacturer of material handling and processing equipment for heavy industry in the United States and abroad. Its sales have more than doubled, and its...
-
3. Solve for the currents through R, R, and R6 using the mesh current method. ww ww R3 R6 300 100 Q 12: = 14 16 = ww R4 400 mA mA mA R2 200 Q R5 100 2 + V1 10 V ww R1 500 Q
-
The Ethan Corporation sells200,000V262 valves to the automobile and truck industry. Ethan has a capacity of120,000machine-hours and can produce two valves per machine-hour. V262's contribution margin...
-
Dresser Company uses time & material pricing. The time rate is $30/hour. The material charge is 15% for ordering, handling & storing materials and 25% for the desired profit on these materials. Given...
-
1. What are some examples (5 examples) of where technology has been used to improve the value chain? (10 marks)
-
A bank term deposit yields 6% interest, compounded daily. Calculate, showing and briefly explaining your algebraic workings , the interest rate that would ensure the path of the account's value would...
-
Saviour company had the following transaction during its first month of operations: spent and used P30,000 and P40,000 of direct labor and manufacturing overhead, respectively, and used P14,000 of...
-
Question 13 Stocks that do not pay a dividend must have a value of $0 True False
-
Which of the followingcarbocations is the least stable? CH3CH2 . CH3CHCH3 CH3 I . CH3C0 T CH3 IV. V. CH3 CH3CCH2 CH3
-
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...
-
Rationalize the denominator of the following: 1. \(\frac{5}{\sqrt{7}}\) 2. \(\frac{3 \sqrt{6}}{2 \sqrt{10}}\)
-
Perform the following operations without a calculator. Simplify if possible. 1. \(3 \sqrt{15} \div(8 \sqrt{3})\) 2. \(14.7 \sqrt{135} \div(3 \sqrt{5})\).
-
Identify all subsets of the real numbers to which the following real numbers belong: 1. 14 2. -14.223 3. \(\sqrt{17}\)
Study smarter with the SolutionInn App