Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since:
Apr 2017
Last Sign in:
103 Weeks Ago, 4 Days Ago
Questions Answered:
4870
Tutorials Posted:
4863
Education
MBA IT, Mater in Science and Technology
Devry Jul-1996 - Jul-2000
Experience
Professor
Devry University Mar-2010 - Oct-2016
Category > ProgrammingPosted 25 May 2017My Price8.00
elements of an NxN matrix of type
In this assignment, you will apply the concepts you learned in Chapters 5 and 6 to the problem of optimising code for a memory-intensive application. Consider a procedure to copy and transpose the elements of an NxN matrix of type int. That is, for source matrix S and destination matrix D, we want to copy each element s_i,j to d_j,i. This code can be written with a simple loop.
Â
void transpose (int *dst, int *src, int dim)
{
int i,j;
for (i = 0; i < dim; i++)
for (j = 0; j < dim; j++)
dst[j*dim + i] = src[i*dim + j];
}
where the arguments to the procedure are pointers to the destination (dst) and source (src) matrices, as well as the matrix of size N (dim). Your job is to devise a transpose routine that runs as fast as possible.