1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| Status FastTransposeSMatrix(TSMatrix M, TSMatrix &T) { int col, num[MAXSIZE + 1], copt[MAXSIZE + 1]; T.nu = M.mu; T.mu = M.nu; T.tu = M.tu; if (T.tu) { for (col = 1; col <= M.nu; ++col) { num[col] = 0; } for (int t = 1; t <= M.tu; ++t) { ++num[M.data[t].j]; } cout << "num : " ; for (int t = 1; t <= M.nu; ++t) { cout << num[t] << " "; } cout << endl; copt[1] = 1; for (col = 2; col <= M.nu; ++col) { copt[col] = copt[col - 1] + num[col - 1]; } cout << "copt: " ; for (int s = 1; s <= M.nu; s++) { cout << copt[s] << " "; } cout << endl; for (int p = 1; p <= M.tu; ++p) { col = M.data[p].j; int q = copt[col]; T.data[q].i = M.data[p].j; T.data[q].j = M.data[p].i; T.data[q].e = M.data[p].e; ++copt[col]; } cout << "转置之后: " <<endl; for (int i = 1; i <= T.tu; i++) { cout << T.data[i].i << " " << T.data[i].j << " " << T.data[i].e << endl; }
} return TRUE; }
|