1 /*  metrics.c  */
2 
3 #include "../ETree.h"
4 
5 /*--------------------------------------------------------------------*/
6 /*
7    ------------------------------------
8    return an IV object with the weights
9    of the vertices in each front.
10 
11    created -- 96jun23, cca
12    ------------------------------------
13 */
14 IV *
ETree_nvtxMetric(ETree * etree)15 ETree_nvtxMetric (
16    ETree   *etree
17 ) {
18 IV   *metricIV ;
19 /*
20    ---------------
21    check the input
22    ---------------
23 */
24 if (  etree == NULL || etree->nfront <= 0 || etree->nvtx <= 0 ) {
25    fprintf(stderr, "\n fatal error in ETree_nvtxMetric(%p)"
26            "\n bad input\n", etree) ;
27    exit(-1) ;
28 }
29 metricIV = IV_new() ;
30 IV_init(metricIV, etree->nfront, NULL) ;
31 IVcopy(etree->nfront, IV_entries(metricIV),
32                       IV_entries(etree->nodwghtsIV)) ;
33 
34 return(metricIV) ; }
35 
36 /*--------------------------------------------------------------------*/
37 /*
38    ---------------------------------------------------------------
39    return an IV object with the number
40    of factor entries in each front.
41 
42    symflag -- symmetryflag
43       SPOOLES_SYMMETRIC, SPOOLES_HERMITIAN or SPOOLES_NONSYMMETRIC
44 
45    created -- 96jun23, cca
46    ---------------------------------------------------------------
47 */
48 IV *
ETree_nentMetric(ETree * etree,int flag)49 ETree_nentMetric (
50    ETree   *etree,
51    int     flag
52 ) {
53 int    front, nfront, nb, nv ;
54 int    *bndwghts, *metric, *nodwghts ;
55 IV     *metricIV ;
56 /*
57    ---------------
58    check the input
59    ---------------
60 */
61 if (  etree == NULL
62    || (nfront = etree->nfront) <= 0 || etree->nvtx <= 0 ) {
63    fprintf(stderr, "\n fatal error in ETree_nentMetric(%p)"
64            "\n bad input\n", etree) ;
65    exit(-1) ;
66 }
67 metricIV = IV_new() ;
68 IV_init(metricIV, nfront, NULL) ;
69 metric   = IV_entries(metricIV) ;
70 nodwghts = IV_entries(etree->nodwghtsIV) ;
71 bndwghts = IV_entries(etree->bndwghtsIV) ;
72 if ( flag == 1 ) {
73    for ( front = 0 ; front < nfront ; front++ ) {
74       nv = nodwghts[front] ;
75       nb = bndwghts[front] ;
76       metric[front] = (nv*(nv+1))/2 + nv*nb ;
77    }
78 } else if ( flag == 2 ) {
79    for ( front = 0 ; front < nfront ; front++ ) {
80       nv = nodwghts[front] ;
81       nb = bndwghts[front] ;
82       metric[front] = nv*nv + 2*nv*nb ;
83    }
84 }
85 
86 return(metricIV) ; }
87 
88 /*--------------------------------------------------------------------*/
89 /*
90    ---------------------------------------------------------------
91    return a DV object with the number
92    of factor operations in each front.
93 
94    type -- type of entries,
95       SPOOLES_REAL or SPOOLES_COMPLEX
96 
97    symflag -- symmetryflag,
98       SPOOLES_SYMMETRIC, SPOOLES_HERMITIAN or SPOOLES_NONSYMMETRIC
99 
100    created -- 96jun23, cca
101    ---------------------------------------------------------------
102 */
103 DV *
ETree_nopsMetric(ETree * etree,int type,int symflag)104 ETree_nopsMetric (
105    ETree   *etree,
106    int     type,
107    int     symflag
108 ) {
109 DV       *metricDV ;
110 /*
111    ---------------
112    check the input
113    ---------------
114 */
115 if (  etree == NULL || etree->nfront <= 0 || etree->nvtx <= 0 ) {
116    fprintf(stderr, "\n fatal error in ETree_nopsMetric(%p)"
117            "\n bad input\n", etree) ;
118    exit(-1) ;
119 }
120 metricDV = ETree_forwardOps(etree, type, symflag) ;
121 
122 return(metricDV) ; }
123 
124 /*--------------------------------------------------------------------*/
125