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 351 - (view) (download) (as text)

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