Resources: changestats.h

File changestats.h, 2.7 KB (added by lxwang, 5 years ago)
Line 
1#ifndef CHANGESTATS_H
2#define CHANGESTATS_H
3
4#include "edgetree.h"
5
6typedef struct ModelTermstruct {
7        void (*func)(int, Vertex*, Vertex*, struct ModelTermstruct*, Network*);
8        double *attrib; /* Ptr to vector of covariates (if necessary; generally unused) */
9        int nstats;   /* Number of change statistics to be returned */
10        double *dstats; /* ptr to change statistics returned */
11        int ninputparams; /* Number of input parameters passed to function */
12        double *inputparams; /* ptr to input parameters passed */
13} ModelTerm;
14
15
16/****************************************************
17 Macros to make life easier                         *
18 Note:  These things still need to be documented    */
19#define CHOOSE(n,r) ((n)<(r) ? (0) : (my_choose((double)(n),(int)(r))))
20
21#define IS_OUTEDGE(a,b) (EdgetreeSearch((a),(b),nwp->outedges)!=0?1:0)
22#define IS_INEDGE(a,b) (EdgetreeSearch((a),(b),nwp->inedges)!=0?1:0)
23#define IS_UNDIRECTED_EDGE(a,b) IS_OUTEDGE(MIN(a,b), MAX(a,b))
24#define MIN_OUTEDGE(a) (EdgetreeMinimum(nwp->outedges, (a)))
25#define MIN_INEDGE(a) (EdgetreeMinimum(nwp->inedges, (a)))
26#define NEXT_OUTEDGE(e) (EdgetreeSuccessor(nwp->outedges,(e)))
27#define NEXT_INEDGE(e) (EdgetreeSuccessor(nwp->inedges,(e)))
28#define OUTVAL(e) (nwp->outedges[(e)].value)
29#define INVAL(e) (nwp->inedges[(e)].value)
30#define TOGGLE(a,b) (ToggleEdge((a),(b),nwp));
31
32#define STEP_THROUGH_OUTEDGES(a,e,v) for((e)=MIN_OUTEDGE(a);((v)=OUTVAL(e))!=0;(e)=NEXT_OUTEDGE(e))
33#define STEP_THROUGH_INEDGES(a,e,v) for((e)=MIN_INEDGE(a);((v)=INVAL(e))!=0;(e)=NEXT_INEDGE(e))
34
35#define N_NODES (nwp->nnodes)
36#define OUT_DEG (nwp->outdegree)
37#define IN_DEG (nwp->indegree)
38#define DIRECTED (nwp->directed_flag)
39#define BIPARTITE (nwp->bipartite)
40#define N_EDGES (nwp->nedges)
41#define NEXT_INEDGE_NUM (nwp->next_inedge)
42#define NEXT_OUTEDGE_NUM (nwp->next_outedge)
43
44#define N_CHANGE_STATS (mtp->nstats)
45#define INPUT_PARAM (mtp->inputparams)
46#define CHANGE_STAT (mtp->dstats)
47#define INPUT_ATTRIB (mtp->attrib)
48#define N_INPUT_PARAMS (mtp->ninputparams)
49
50#define ZERO_ALL_CHANGESTATS(a) for((a)=0; (a)<N_CHANGE_STATS; (a)++) CHANGE_STAT[(a)]=0.0
51#define FOR_EACH_TOGGLE(a) for((a)=0; (a)<ntoggles; (a)++)
52#define TOGGLE_IF_MORE_TO_COME(a) if((a)+1<ntoggles) TOGGLE(heads[(a)],tails[(a)])
53#define UNDO_PREVIOUS_TOGGLES(a) (a)--; while(--(a)>=0) TOGGLE(heads[(a)],tails[(a)])
54
55/****************************************************/
56/* changestat function prototype */
57#define CHANGESTAT_FN(a) void (a) (int ntoggles, Vertex *heads, Vertex *tails, ModelTerm *mtp, Network *nwp)
58
59/* IMPORTANT: Add your function names here */
60
61CHANGESTAT_FN(d_testme);
62CHANGESTAT_FN(d_m2star);
63             
64#endif