This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ode operating on multi-dimensional arrays of ﬁxed size. For example, suppose we declare data type fix_matrix to be ½ ¢ ½ arrays of integers as follows:
1 2 #define N 16 typedef int fix_matrix[N][N]; The code in Figure 3.23(a) computes element of the product of matrices A and B. The C compiler generates code similar to that shown in Figure 3.23(b). This code contains a number of clever optimizations. It recognizes that the loop will access the elements of array A as A[i], A[i], . . . , A[i] in sequence. These elements occupy adjacent positions in memory starting with the address of array element A[i]. The program can therefore use a pointer variable Aptr to access these successive locations. The loop will access the elements of array B as B[k], B[k], . . . , B[k] in sequence. These elements occupy positions in memory starting with the address of array element B[k] and spaced 64 bytes apart. The program can therefore use a pointer variable Bptr to access these successive locations. In C, this pointer is shown as being incremented by 16, although in fact the actual pointer is incremented by...
View Full Document
This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.
- Spring '10
- The American