With the following C++ code, implement the “indirect sum” method of computing a sum. You will need to provide an implementation inside both the setup() and sum() functions in the sum_indirect.cpp file in the code harness. Here, setup() consists of initializing an array of length N to contain random numbers in the range 0..N-1 (hint: use lrand48() % N). --- #include #include #include #include #include #include #include void setup(int64_t N, uint64_t A[]) { printf(" inside sum_indirect problem_setup, N=%lld ", N); } int64_t sum(int64_t N, uint64_t A[]) { printf(" inside sum_indirect perform_sum, N=%lld ", N); return 0; }
With the following C++ code, implement the “indirect sum” method of computing a sum. You will need to provide an implementation inside both the setup() and sum() functions in the sum_indirect.cpp file in the code harness. Here, setup() consists of initializing an array of length N to contain random numbers in the range 0..N-1 (hint: use lrand48() % N).
---
#include <algorithm>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <random>
#include <vector>
#include <string.h>
void
setup(int64_t N, uint64_t A[])
{
printf(" inside sum_indirect problem_setup, N=%lld ", N);
}
int64_t
sum(int64_t N, uint64_t A[])
{
printf(" inside sum_indirect perform_sum, N=%lld ", N);
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images