As the following assembly code for the loop shows the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: code, consider the simple vector data structure, shown in Figure 5.3. A vector is represented with two blocks of memory. The header is a structure declared as follows: code/opt/vec.h 1 2 3 4 5 /* Create abstract data type for vector */ typedef struct { int len; data_t *data; } vec_rec, *vec_ptr; code/opt/vec.h The declaration uses data type data t to designate the data type of the underlying elements. In our evaluation, we measure the performance of our code for data types int, float, and double. We do this by compiling and running the program separately for different type declarations, for example: typedef int data_t; In addition to the header, we allocate an array of len objects of type data t to hold the actual vector elements. Figure 5.4 shows some basic procedures for generating vectors, accessing vector elements, and determining the length of a vector. An important feature to note is that get_vec_element, the vector access routine, performs bounds checking for every vector reference. This code is sim...
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.

Ask a homework question - tutors are online