Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We have considered several implementations of functions in which the elements of an array are combined using either addition or multiplication, with both integer

We have considered several implementations of functions in which the elements of an array are combined using either addition or multiplication, with both integer and floating point numbers. The specific functions which you will implement are combine3(), combine5), and combine7) using double precision floating point numbers and the operation will be multiplication. The routines are shown in figures 5.9, 5.16, and 5.26 respectively. To eliminate the need for additional functions, tailor the routines to accept as parameters: the array address, the address of the destination, and the array length. Your implementation should correspond to the following prototypes: prototype definitions* void combine3 (double *A, double * dest, int length); void combine5(double *A, double * dest, int length); void combine7(double *A, double * dest, int length); As you will be multiplying a large number of values together, you may encounter problems with either overflow or underflow. To address that issue, you will want to keep your numbers in a range that is close to 1.0. You can use the following examples to define your array length and parameters for initializing the array elements. #define LENGTH 5000 #define K 10000 double A[LENGTH] // input matrix for (i-0; ik LENGTH; i++) // initialize the array elements Ali-0.90 + (double )(rand() % K) / 50000; With the three functions, vary the size of the arrays, execute each function, and measure the execution times of each. As you are executing in a multiprocessing environment, you will observe variations in the execution times, so you should conduct the experiment a few times with each array size to get average results. Generate a summary of the results and explain how the different implementations lead to different execution times. Also, submit a copy of your source code. 

We have considered several implementations of functions in which the elements of an array are combined using either addition or multiplication, with both integer and floating point numbers. The specific functions which you will implement are combine3), combine5( ), and combine7( ) using double precision floating point numbers and the operation will be multiplication. The routines are shown in figures 5.9, 5.16, and 5.26 respectively. To eliminate the need for additional functions, tailor the routines to accept as parameters: the array address, the address of the destination, and the array length. Your implementation should correspond to the following prototypes: -- prototype definitions --- */ void combine3(double * A, double * dest, int length); void combine5(double * A, double * dest, int length); void combine7(double * A, double * dest, int length); As you will be multiplying a large number of values together, you may encounter problems with either overflow or underflow. To address that issue, you will want to keep your numbers in a range that is close to 1.0. You can use the following examples to define your array length and parameters for initializing the array elements. #define LENGTH 5000 #define K 10000 double A[LENGTH]; // input matrix for (i=0; i < LENGTH; i++) A[i) = 0.90 + (double )(rand() % K) / 50000.; // initialize the array elements With the three functions, vary the size of the arrays, execute each function, and measure the execution times of each. As you are executing in a multiprocessing environment, you will observe variations in the execution times, so you should conduct the experiment a few times with each array size to get average results. Generate a summary of the results and explain how the different implementations lead to different execution times. Also, submit a copy of your source code.

Step by Step Solution

3.50 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

Implement in java CombineArrayElementsjava public class CombineArrayElem... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Quantum Chemistry

Authors: Ira N. Levine

7th edition

321803450, 978-0321803450

More Books

Students also viewed these Programming questions