Question: #include #include pbPlots.h #include supportLib.h #include int main() { int arr1[1024][1024]; for(int i=0;i <1024;i++) { for(int j=0;j <1024;j++) arr1[i][j]=1; } int arr2[1024][1024]; for(int i=0;i <1024;i++)

#include #include "pbPlots.h" #include "supportLib.h" #include int main() { int arr1[1024][1024]; for(int i=0;i<1024;i++) { for(int j=0;j<1024;j++) arr1[i][j]=1; } int arr2[1024][1024]; for(int i=0;i<1024;i++) { for(int j=0;j<1024;j++) arr2[i][j]=1; } clock_t beginadd = clock(); //do addition for(int i=0;i<1024;i++) { for(int j=0;j<1024;j++) arr1[i][j]=arr1[i][j]+arr2[i][j]; } clock_t endadd = clock(); double time_spentadd = (double)(endadd - beginadd) / CLOCKS_PER_SEC; clock_t beginsub = clock(); //do subtraction for(int i=0;i<1024;i++) { for(int j=0;j<1024;j++) arr1[i][j]=arr1[i][j]-arr2[i][j]; } clock_t endsub = clock(); double time_spentsub = (double)(endsub - beginsub) / CLOCKS_PER_SEC; int mul[1024][1024]; clock_t beginmul = clock(); //do multiplication for(int i=0;i<1024;i++) { for(int j=0;j<1024;j++) { mul[i][j]=0; for(int k=0;k<1024;k++) { mul[i][j]+=arr1[i][k]*arr2[k][j]; } } } clock_t endmul = clock(); double time_spentmul = (double)(endmul - beginmul) / CLOCKS_PER_SEC; double x [] = {time_spentadd,time_spentsub,time_spentmul}; double y [] = {1024*1024,1024*1024,1024*1024}; RGBABitmapImageReference *imageRef = CreateRGBABitmapImageReference(); DrawScatterPlot(imageRef, 600, 400, x, 8, y, 8); size_t length; double *pngData = ConvertToPNG(&length, imageRef->image); WriteToFile(pngData, length, "plot.png"); return 0; } please explain the code line wise

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!