Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 6.2, Problem 6.7PP
Program Plan Intro
Given Information:
The sample program for sum of a 3-D array is given below:
// Sum of a 3-dimensional array
int sumarray3d(int a[N] [N] [N])
{
//variable declaration
int i,j,k, sum=0;
//Traverse the array
for(i=0;i<n;i++)
{
for(j=0;j>N;j++)
{
for(k=0;k<N;k++)
{
//sum of all the array elements
sum = sum+ a[k][i][j];
}
}
}
return sum;
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Sparse matrix–vector product) Recall from Section 3.4.2 that a matrix is said to be sparse if most of its entries are zero. More formally, assume a m × n matrix A has sparsity coefficient γ(A) ≪ 1, where γ(A) ≐ d(A)/s(A), d(A) is the number of nonzero elements in A, and s(A) is the size of A (in this case, s(A) = mn). 1. Evaluate the number of operations (multiplications and additions) that are required to form the matrix– vector product Ax, for any given vector x ∈ Rn and generic, non-sparse A. Show that this number is reduced by a factor γ(A), if A is sparse. 2. Now assume that A is not sparse, but is a rank-one modification of a sparse matrix. That is, A is of the form à + uv⊤, where à ∈ Rm,n is sparse, and u ∈ Rm, v ∈ Rm are given. Devise a method to compute the matrix–vector product Ax that exploits sparsity.
4. Use NumPy's arange function to create vectors identical to the following created with the linspace
function:
(a) np.linspace (-2,1.5,8)
(b) np. linspace (8,4.5,8)
7. Consider the sample program array max.cpp.
(a) Clearly describe the changes necessary to find the minimum value in the array.
(b) Explain how to test your answer to (a).
Chapter 6 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 6.1 - Prob. 6.1PPCh. 6.1 - Prob. 6.2PPCh. 6.1 - Prob. 6.3PPCh. 6.1 - Prob. 6.4PPCh. 6.1 - Prob. 6.5PPCh. 6.1 - Prob. 6.6PPCh. 6.2 - Prob. 6.7PPCh. 6.2 - Prob. 6.8PPCh. 6.4 - Prob. 6.9PPCh. 6.4 - Prob. 6.10PP
Ch. 6.4 - Prob. 6.11PPCh. 6.4 - Prob. 6.12PPCh. 6.4 - Prob. 6.13PPCh. 6.4 - Prob. 6.14PPCh. 6.4 - Prob. 6.15PPCh. 6.4 - Prob. 6.16PPCh. 6.5 - Prob. 6.17PPCh. 6.5 - Prob. 6.18PPCh. 6.5 - Prob. 6.19PPCh. 6.5 - Prob. 6.20PPCh. 6.6 - Prob. 6.21PPCh. 6 - Prob. 6.22HWCh. 6 - Prob. 6.23HWCh. 6 - Suppose that a 2 MB file consisting of 512-byte...Ch. 6 - The following table gives the parameters for a...Ch. 6 - The following table gives the parameters for a...Ch. 6 - Prob. 6.27HWCh. 6 - This problem concerns the cache in Practice...Ch. 6 - Suppose we have a system with the following...Ch. 6 - Suppose we have a system with following...Ch. 6 - Suppose that a program using the cache in Problem...Ch. 6 - Repeat Problem 6.31 for memory address0x16E8 A....Ch. 6 - Prob. 6.33HWCh. 6 - Prob. 6.34HWCh. 6 - Prob. 6.35HWCh. 6 - Prob. 6.36HWCh. 6 - Prob. 6.37HWCh. 6 - Prob. 6.38HWCh. 6 - Prob. 6.39HWCh. 6 - Given the assumptions in Problem 6.38, determine...Ch. 6 - You are writing a new 3D game that you hope will...Ch. 6 - Prob. 6.42HWCh. 6 - Prob. 6.43HWCh. 6 - Prob. 6.45HWCh. 6 - Prob. 6.46HW
Knowledge Booster
Similar questions
- Source computer sources.. 33.arrow_forwardList the restrictions to arrayarrow_forwardProblem 3: Dot Product Write a function which takes input parameters A, and B and returns the dotproduct of two matrices then compare your dot product function w.r.t. the built-in function np.dot() [ ] def dotprod(A,B): A = np.array([[3,4],[-1, 2]]) B = np.array([[5,2],[8, -3]]) #calculate dotprod (A,B) Compare your results to the built.in function np. dot(A, B) [ ] np.dot(A,B) [ ] # how about some random matrices,arrow_forward
- computer science questionarrow_forwardPYTHON/ COMPUTATIONAL STOICHIOMETRY Please help me build the stochiometric matrix for the chemical reaction.kindly use the code provided to guide your solution. 1.7 A + 2.1 B + 1.5 C <=> 3 D + 3.8 E + 1.2 F Code Block to build stoichiometric matrix: import numpy as np # Initialize the stoichiometric matrix as zeros_mtrx = np.zeros((len(reactions), len(species))) for (i_row, r) in enumerate(reactions): left = r.split('<=>')[0].strip() right = r.split('<=>')[1].strip() left_terms = left.split('+') left_terms = [t.strip() for t in left_terms] # in-place clean up right_terms = right.split('+') right_terms = [t.strip() for t in right_terms] # in-place clean up for t in left_terms: # reactants tmp = t.split(' ') # split stoichiometric coeff and species name if len(tmp) == 2: # stoich coeff and species name coeff = float(tmp[0].strip()) species_member = tmp[1].strip() j_col…arrow_forwardLanguage: C Write a C program that allocates memory using the malloc function for an array of size specified by the user at runtime. Assign pseudo-random double values to the array elements, then sort the array using the qsort function. Using the examples from the lecture, define a function that compares numbers of type double. Pass the function address to the qsort function. Use the free function to free up memory. Problem 1 and Problem 2.arrow_forward
- Q1 2(a). Show how the AND-OR array should be programmed to implement the SOP expressions. Y3 АВС+ AВС + АВС A A B В сarrow_forwardM. 0om question 6.arrow_forward(C++) I need a quicksort algorithm implementation which returns the indices of the sorted array in an array without modifying the array itself:ie,Before sortingindex : 0 1 2 3 4 5values: 70 60 40 20 30 50After sortingindex : 3 4 2 5 1 0values: 70 60 40 20 30 50 function returns an array with indexes: [3 4 2 5 1 0]arrow_forward
- (c) A palindromic number is a number that is the same if read forwards or backwards: 12321 and 641146 are examples. It is possible to represent a number using an array of digits (numbers 0- 9), for example: [1,9,5, 2] could represent 1952. i. Using an appropriate iteration construct, write an algorithm as a procedure that decides if an input array A[1..n] of digits is a palindromic number.arrow_forwardUsing C++ write code for the following and call from a main function (a) A function that via its parameter list, receives a one-dimensional array of an arbitrary ( i.e. []) size, of type double and populates it with random positive doubles only in the range 0.0 and 9.0. Show how to pass array size also in parameter list to this function. (b) A function that via its parameter list receives a one-dimensional array of arbitrary size of type double and returns the average of the elements in the array via a double return variable. Enforce that the function may not change the array or size parameter data passed to it in any way. (c) A function that receives via its parameter list a one-dimensional array of arbitrary size, containing type double and prints its elements. Enforce that the function may not change the array or size parameter data passed to it in any way. (d) Write a main function in which you show how to call the functions in parts (a), (b), and (c) above. You may only declare…arrow_forward1. Write a python function to calculate the following mathematical function: f(x) = sin(2x)e-x/5 Test your function for x = 4 and for the array x = np.array ([2.6, 9.1, 3.7]).arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education