2025_ECL_535_HW3_ApproximateComputing
2025_ECL_535_HW3_ApproximateComputing
All the files required for executing the code have been uploaded in
FilesForHomeworks folder on teams.
2) The data-values stored in a buffer with 4-rows and 4-columns is shown below (all
values in hexadecimal).( 4 marks)
constint N=9;
oldArr[i] = 0.2*i;
Arr[0] = 5;
Arr[i] = (Arr[i-1]+oldArr[i]) ;
In the above code, we replace the second for loop with the below loop.
Arr[i] = (Arr[i-1]+oldArr[i]);
Arr[i+1] = (Arr[i-1]+oldArr[i+1]);
(a) Baseline strategy stops only when all the points have converged. Find
TotalIteration for this strategy [1 mark]
6. (1+1 mark) To see how the scope of applying approximate computing depends on
the input, run ImageNearbyPixelDiff.cpp on two images: CrowdedCity.jpg and
SkyPhoto.jpeg. Write the value of its output (diff) for each case. For detailed
instructions, see the top lines of the file ImageNearbyPixelDiff.cpp
6. See Kmeans_Final.cpp.
(a) We discussed that “in clustering algorithm, only relative distances matter, not
absolute distances.”
and
dist = sqrt(sum); ==> dist = sum;
(b) To change the maximum number of iterations, you need to change the fourth
parameter in the first line of DataSet.txt, as follows:
1000 4 30 100 1
1000 4 30 1000 1
Now, run the program with 34 iterations. You can see that for this dataset, all
points converge at 33 iterations. The cluster to which each point is assigned is
printed in ResultsPointWiseK.txt, where K refers to maximum number of iterations
we specified.
Now, you have to run with less than 34 iterations and observe that less points
converge for less number of iterations. You can compare ResultsPointWiseK1.txt for
certain number of iterations (K1) with ResultsPointWise34.txt to see how many
points have not converged by end of K1 iterations. Call it NumPointsNotConverged
Hint: To find the number of lines that are different in two files, you can use
following command.
$awk 'NR==FNR{a[FNR]=$0;next}$0!=a[FNR]{print}'
ResultsPointWiseK1.txt ResultsPointWise34.txt | wc -l
Fill a to f in the table below by using above command. Then, compute difference in
third column. What is your conclusion from “difference” column? [6 marks]
34 0
30 a= a-0 =
25 b= b-a =
20 c= c-b =
15 d= d-c =
10 e= e-d =
5 f= f-e =
Root value
Iteration Original.cpp EarlyTermination.cpp
1
2
….