~ubuntu-branches/ubuntu/trusty/rheolef/trusty-proposed

« back to all changes in this revision

Viewing changes to skit/lib/genrcm.h

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2010-06-12 09:08:59 UTC
  • Revision ID: james.westby@ubuntu.com-20100612090859-8gpm2gc7j3ab43et
Tags: upstream-5.89
ImportĀ upstreamĀ versionĀ 5.89

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _GENRCM_H
 
2
#define _GENRCM_H
 
3
/// This file is part of Rheolef.
 
4
///
 
5
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
 
6
///
 
7
/// Rheolef is free software; you can redistribute it and/or modify
 
8
/// it under the terms of the GNU General Public License as published by
 
9
/// the Free Software Foundation; either version 2 of the License, or
 
10
/// (at your option) any later version.
 
11
///
 
12
/// Rheolef is distributed in the hope that it will be useful,
 
13
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
/// GNU General Public License for more details.
 
16
///
 
17
/// You should have received a copy of the GNU General Public License
 
18
/// along with Rheolef; if not, write to the Free Software
 
19
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
20
///
 
21
/// =========================================================================
 
22
 
 
23
/* genrcm.f -- translated by f2c (version 19931217).*/
 
24
 
 
25
/*****************************************************************/
 
26
/*****************************************************************/
 
27
/*********   GENRCM ..... GENERAL REVERSE CUTHILL MCKEE   ********/
 
28
/*****************************************************************/
 
29
 
 
30
/*    PURPOSE - GENRCM FINDS THE REVERSE CUTHILL-MCKEE*/
 
31
/*       ORDERING FOR A GENERAL GRAPH. FOR EACH CONNECTED*/
 
32
/*       COMPONENT IN THE GRAPH, GENRCM OBTAINS THE ORDERING*/
 
33
/*       BY CALLING THE SUBROUTINE RCM.*/
 
34
 
 
35
/*    INPUT PARAMETERS -*/
 
36
/*       NEQNS - NUMBER OF EQUATIONS*/
 
37
/*       (XADJ, ADJNCY) - ARRAY PAIR CONTAINING THE ADJACENCY*/
 
38
/*              STRUCTURE OF THE GRAPH OF THE MATRIX.*/
 
39
 
 
40
/*    OUTPUT PARAMETER -*/
 
41
/*       PERM - VECTOR THAT CONTAINS THE RCM ORDERING.*/
 
42
 
 
43
/*    WORKING PARAMETERS -*/
 
44
/*       MASK - IS USED TO MARK VARIABLES THAT HAVE BEEN*/
 
45
/*              NUMBERED DURING THE ORDERING PROCESS. IT IS*/
 
46
/*              INITIALIZED TO 1, AND SET TO ZERO AS EACH NODE*/
 
47
/*              IS NUMBERED.*/
 
48
/*       XLS - THE INDEX VECTOR FOR A LEVEL STRUCTURE.  THE*/
 
49
/*              LEVEL STRUCTURE IS STORED IN THE CURRENTLY*/
 
50
/*              UNUSED SPACES IN THE PERMUTATION VECTOR PERM.*/
 
51
 
 
52
/*    PROGRAM SUBROUTINES -*/
 
53
/*       FNROOT, RCM.*/
 
54
/*****************************************************************/
 
55
 
 
56
#include "rheolef/fnroot.h"
 
57
#include "rheolef/rcm.h"
 
58
 
 
59
template <class Size, class Iterator>
 
60
void
 
61
genrcm(
 
62
        Size     neqns,
 
63
        Iterator xadj,
 
64
        Iterator adjncy, 
 
65
        Iterator perm,
 
66
        Iterator mask,
 
67
        Iterator xls)
 
68
{
 
69
    typedef typename std::iterator_traits<Iterator>::value_type  Integer;
 
70
 
 
71
    /* System generated locals */
 
72
    Integer i__1;
 
73
 
 
74
    /* Local variables */
 
75
    static Integer nlvl, root, i, ccsize;
 
76
    static Integer num;
 
77
 
 
78
    /* Parameter adjustments */
 
79
    --xls;
 
80
    --mask;
 
81
    --perm;
 
82
    --adjncy;
 
83
    --xadj;
 
84
 
 
85
    i__1 = neqns;
 
86
    for (i = 1; i <= i__1; ++i) {
 
87
        mask[i] = 1;
 
88
    }
 
89
    num = 1;
 
90
    i__1 = neqns;
 
91
    for (i = 1; i <= i__1; ++i) {
 
92
/*          FOR EACH MASKED CONNECTED COMPONENT ...*/
 
93
        if (mask[i] == 0) {
 
94
            goto L200;
 
95
        }
 
96
        root = i;
 
97
/*             FIRST FIND A PSEUDO-PERIPHERAL NODE ROOT.*/
 
98
/*             NOTE THAT THE LEVEL STRUCTURE FOUND BY*/
 
99
/*             FNROOT IS STORED STARTING AT PERM(NUM).*/
 
100
/*             THEN RCM IS CALLED TO ORDER THE COMPONENT*/
 
101
/*             USING ROOT AS THE STARTING NODE.*/
 
102
 
 
103
        fnroot(&root, &xadj[1], &adjncy[1], &mask[1], &nlvl, &xls[1], &perm[num]);
 
104
        rcm(&root, &xadj[1], &adjncy[1], &mask[1], &perm[num], &ccsize, &xls[1]);
 
105
 
 
106
        num += ccsize;
 
107
        if (num > neqns) {
 
108
            return;
 
109
        }
 
110
L200:
 
111
        ;
 
112
    }
 
113
}
 
114
#endif // _GENRCM_H