Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q3: Matrix Calculations The file associated with this question is MatrixCalculations.py. You are given a matrix of numbers could be int or float) stored in
Q3: Matrix Calculations The file associated with this question is MatrixCalculations.py. You are given a matrix of numbers could be int or float) stored in a list of lists, such as: 9, [9, A = [[14, 8, 1, [3, 4, [2, 13, [10, 16, [14, 8, 0, 5, 3, 11, 5, 17], 14, 6], 10, 11], 1, 15], 3], 4, 9]] 3 11, 1 1 Part A (5 points): Implement the function rowwise_max(A) such that: A is the list of lists, as exemplified above rowwise_max calculates the maximum of each row, row-by-row. The maximums are placed in a one-dimensional list and returned. For the above example, rowwise_max returns: [17, 14, 11, 15, 16, 14] because max of the first row is 17, max of second row is 14, max of third row is 11, etc. Part B (5 points): Implement the function columnwise_avg(A) such that: A is the list of lists, as exemplified above columnwise_avg calculates the average of each column, column-by-column. The averages are placed in a one-dimensional list and retumed. For the above example, columnwise_avg returns: [8.666, 8.333, 5.833, 7.5, 10.166] because average of the first column is 8.666, average of the second column is 8.33, etc. Part C (10 points): Implement the function neighborwise_min(A) such that: A is the list of lists, as exemplified above neighborwise_min returns a matrix of the same size as A, let us denote this returned matrix by B. OB[][] = -2 for the four comers of the matrix (upper left corner, upper right corner, lower left corner, lower right corner) OB[OC] = -1 for the four edges of the matrix (leftmost column, rightmost column, uppermost row, lowermost row), excluding the four corners For the inner elements, B[][] is equal to 1 if and only if B[]] is smaller than ALL of its neighbors. Otherwise, B[[] is equal to 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started