SCM

SCM Repository

[matrix] Annotation of /pkg/src/Metis_utils.c
ViewVC logotype

Annotation of /pkg/src/Metis_utils.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 148 - (view) (download) (as text)

1 : bates 10 #include "Metis_utils.h"
2 :    
3 : bates 70 void ssc_metis_order(int n, const int Tp [], const int Ti [],
4 : bates 148 int Perm[], int iPerm[])
5 : bates 10 {
6 : bates 70 int j, num_flag = 0, options_flag = 0;
7 : bates 146 idxtype
8 :     *xadj = Calloc(n+1, idxtype),
9 : bates 148 *adj = Calloc(2 * (Tp[n] - n), idxtype),
10 :     *perm = Calloc(n, idxtype), /* in case idxtype != int */
11 :     *iperm = Calloc(n, idxtype);
12 : bates 10
13 :     /* temporarily use perm to store lengths */
14 : bates 70 memset(perm, 0, sizeof(idxtype) * n);
15 : bates 10 for (j = 0; j < n; j++) {
16 : bates 70 int ip, p2 = Tp[j+1];
17 :     for (ip = Tp[j]; ip < p2; ip++) {
18 :     int i = Ti[ip];
19 : bates 10 if (i != j) {
20 :     perm[i]++;
21 :     perm[j]++;
22 :     }
23 :     }
24 :     }
25 :     xadj[0] = 0;
26 :     for (j = 0; j < n; j++) xadj[j+1] = xadj[j] + perm[j];
27 :     /* temporarily use perm to store pointers */
28 : bates 70 Memcpy(perm, xadj, n);
29 : bates 10 for (j = 0; j < n; j++) {
30 : bates 70 int ip, p2 = Tp[j+1];
31 :     for (ip = Tp[j]; ip < p2; ip++) {
32 :     int i = Ti[ip];
33 : bates 10 if (i != j) {
34 :     adj[perm[i]] = j;
35 :     adj[perm[j]] = i;
36 :     perm[i]++;
37 :     perm[j]++;
38 :     }
39 :     }
40 :     }
41 :     METIS_NodeND(&n, xadj, adj, &num_flag, &options_flag, perm, iperm);
42 : bates 148 for (j = 0; j < n; j++) {
43 :     Perm[i] = (int) perm[i];
44 :     iPerm[i] = (int) iperm[i];
45 : bates 146 }
46 : bates 148 Free(iperm); Free(perm); Free(xadj); Free(adj);
47 : bates 146 }

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge