| 1 | #include "mat.h" |
| 2 | #include "matrixdefs.h" |
| 3 | #include "local_proto.h" |
| 4 | |
| 5 | /* |
| 6 | * transpose: returns arg2 as the transpose of arg1 |
| 7 | */ |
| 8 | int transpose(MATRIX *a, MATRIX *b) |
| 9 | { |
| 10 | register int i, j, nr, nc; |
| 11 | static MATRIX m; |
| 12 | |
| 13 | if (a->nrows == 0) |
| 14 | return error("\': arg1 not defined\n"); |
| 15 | |
| 16 | nr = a->nrows; |
| 17 | nc = a->ncols; |
| 18 | |
| 19 | for (i = 0; i < nr; i++) |
| 20 | for (j = 0; j < nc; j++) |
| 21 | m.x[j][i] = a->x[i][j]; |
| 22 | |
| 23 | m.nrows = nc; |
| 24 | m.ncols = nr; |
| 25 | m_copy(b, &m); |
| 26 | return 1; |
| 27 | } |