SCM

SCM Repository

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

Diff of /pkg/src/Metis_utils.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 10, Mon Mar 22 20:20:05 2004 UTC revision 70, Mon Apr 12 12:10:01 2004 UTC
# Line 1  Line 1 
1  #include "Metis_utils.h"  #include "Metis_utils.h"
2    
3  void ssc_metis_order(int n, int nnz,  void ssc_metis_order(int n, const int Tp [], const int Ti [],
                      const int Tp [], const int Ti [],  
4                       idxtype* perm, idxtype* iperm)                       idxtype* perm, idxtype* iperm)
5  {  {
6      int i, j, ip, nnodes, num_flag = 0, options_flag = 0;      int  j, num_flag = 0, options_flag = 0;
7      idxtype *xadj, *adj;      idxtype *xadj, *adj;
8    
     nnodes = 2 * (nnz - n);  
9      xadj = (idxtype *) R_alloc(n + 1, sizeof(idxtype));      xadj = (idxtype *) R_alloc(n + 1, sizeof(idxtype));
10      adj = (idxtype *) R_alloc(nnodes, sizeof(idxtype));      adj = (idxtype *) R_alloc(2 * (Tp[n] - n), sizeof(idxtype));
11                                  /* temporarily use perm to store lengths */                                  /* temporarily use perm to store lengths */
12      for (j = 0; j < n; j++) perm[j] = 0;      memset(perm, 0, sizeof(idxtype) * n);
13      for (j = 0; j < n; j++) {      for (j = 0; j < n; j++) {
14          for (ip = Tp[j]; ip < Tp[j+1]; ip++) {          int ip, p2 = Tp[j+1];
15              i = Ti[ip];          for (ip = Tp[j]; ip < p2; ip++) {
16                int i = Ti[ip];
17              if (i != j) {              if (i != j) {
18                  perm[i]++;                  perm[i]++;
19                  perm[j]++;                  perm[j]++;
# Line 24  Line 23 
23      xadj[0] = 0;      xadj[0] = 0;
24      for (j = 0; j < n; j++) xadj[j+1] = xadj[j] + perm[j];      for (j = 0; j < n; j++) xadj[j+1] = xadj[j] + perm[j];
25                                  /* temporarily use perm to store pointers */                                  /* temporarily use perm to store pointers */
26      for (j = 0; j < n; j++) perm[j] = xadj[j];      Memcpy(perm, xadj, n);
27      for (j = 0; j < n; j++) {      for (j = 0; j < n; j++) {
28          for (ip = Tp[j]; ip < Tp[j+1]; ip++) {          int ip, p2 = Tp[j+1];
29              i = Ti[ip];          for (ip = Tp[j]; ip < p2; ip++) {
30                int i = Ti[ip];
31              if (i != j) {              if (i != j) {
32                  adj[perm[i]] = j;                  adj[perm[i]] = j;
33                  adj[perm[j]] = i;                  adj[perm[j]] = i;

Legend:
Removed from v.10  
changed lines
  Added in v.70

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