Sort of functional implementation

This commit is contained in:
Adam Goldsmith 2016-05-01 20:34:11 -04:00
parent a44e5fda1f
commit 2857ac72a5

25
trans.c
View File

@ -45,6 +45,31 @@ void diff_array(int M, int N, int A[N][M], int B[M][N], int x, int y)
char transpose_submit_desc[] = "Transpose submission";
void transpose_submit(int M, int N, int A[N][M], int B[M][N])
{
int blocksize = 8; //2^5/4
int i, j, k, diag, diagX, diagY;
for(i=0; i<M; i+=blocksize)
{
for(j=0; j<N; j++)
{
diag = 0;
for(k=0; k<blocksize && (i+k < M); k++)
{
if (j*N + i + k != (i + k)*M + j)
{
B[i+k][j] = A[j][i+k];
//diff_array(M, N, A, B, j, i+k);
}
else
{
diag = A[j][i+k];
diagX = i+k;
diagY = j;
}
}
if(diag)
B[diagX][diagY] = diag;
}
}
}
/*