its a sparse matrix and the function should turn it into the transposed matrix.
You can easily do inplace transposition of a matrix, whether it's sparse or not:
Code:
for(i = 0; i < ROWS; i++)
for(j = 0; j < COLS; j++)
A[i][j] = A[j][i];
Simply substitute array subscripts with the appropriate set-/get-functions, maybe something along the lines of
Code:
matrix_set(A, i, j, matrix_get(A, j, i));
If efficiency is a concern, don't use linked data structures for storing matrices.
Greets,
Philip
EDIT: now that I posted the question, I can see the problem. For matrices where ROWS != COLS, this doesn't work as easily. Let me start a new post...