Skip to content

Commit

Permalink
The DyadSet auxiliaries and the corresponding test code now use Stric…
Browse files Browse the repository at this point in the history
…tDyadSet.
  • Loading branch information
krivit committed May 15, 2024
1 parent d65020f commit cf9d2ae
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion inst/include/ergm_changestats_auxnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "ergm_changestat_auxnet.h"
#include "ergm_dyad_hashmap.h"

typedef struct{StoreDyadSet *nwp; int *ref_el;} StoreDyadSetAndRefEL;
typedef struct{StoreStrictDyadSet *nwp; int *ref_el;} StoreStrictDyadSetAndRefEL;

#define map_toggle_maxtoggles__discord_net_Network 1
MAP_TOGGLE_FN(map_toggle__discord_net_Network){
Expand Down
72 changes: 36 additions & 36 deletions src/changestats_auxnetalike.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,113 +50,113 @@ F_CHANGESTAT_FN(f__discord_isociomatrix){
}

I_CHANGESTAT_FN(i__discord_net_DyadSet){
ALLOC_AUX_STORAGE(1, StoreDyadSetAndRefEL, storage);
StoreDyadSet *dnwp = storage->nwp = NetworkToDyadSet(nwp);
ALLOC_AUX_STORAGE(1, StoreStrictDyadSetAndRefEL, storage);
StoreStrictDyadSet *dnwp = storage->nwp = NetworkToStrictDyadSet(nwp);
int *ref_el = storage->ref_el = IINPUT_PARAM;

Edge nedges = *ref_el;
for(Edge i=0; i<nedges; i++){
Vertex tail=ref_el[1+i], head=ref_el[1+nedges+i];
DyadSetToggle(tail,head, dnwp);
DDyadSetToggle(tail,head, dnwp);
}
}

U_CHANGESTAT_FN(u__discord_net_DyadSet){
GET_AUX_STORAGE(StoreDyadSetAndRefEL, storage);
StoreDyadSet *dnwp = storage->nwp;
GET_AUX_STORAGE(StoreStrictDyadSetAndRefEL, storage);
StoreStrictDyadSet *dnwp = storage->nwp;

DyadSetToggle(tail,head, dnwp);
DDyadSetToggle(tail,head, dnwp);
}

F_CHANGESTAT_FN(f__discord_net_DyadSet){
GET_AUX_STORAGE(StoreDyadSetAndRefEL, storage);
StoreDyadSet *dnwp = storage->nwp;
GET_AUX_STORAGE(StoreStrictDyadSetAndRefEL, storage);
StoreStrictDyadSet *dnwp = storage->nwp;

kh_destroy(DyadSet, dnwp);
kh_destroy(StrictDyadSet, dnwp);
}

I_CHANGESTAT_FN(i__intersect_net_DyadSet){
ALLOC_AUX_STORAGE(1, StoreDyadSetAndRefEL, storage);
StoreDyadSet *dnwp = storage->nwp = kh_init(DyadSet); dnwp->directed=DIRECTED;
ALLOC_AUX_STORAGE(1, StoreStrictDyadSetAndRefEL, storage);
StoreStrictDyadSet *dnwp = storage->nwp = kh_init(StrictDyadSet);
int *ref_el = storage->ref_el = IINPUT_PARAM;

Edge nedges = *ref_el;
for(Edge i=0; i<nedges; i++){
Vertex tail=ref_el[1+i], head=ref_el[1+nedges+i];
if(IS_OUTEDGE(tail, head)) {
DyadSetToggle(tail,head, dnwp);
DDyadSetToggle(tail,head, dnwp);
}
}
}

U_CHANGESTAT_FN(u__intersect_net_DyadSet){
GET_AUX_STORAGE(StoreDyadSetAndRefEL, storage);
StoreDyadSet *dnwp = storage->nwp;
GET_AUX_STORAGE(StoreStrictDyadSetAndRefEL, storage);
StoreStrictDyadSet *dnwp = storage->nwp;
int *ref_el = storage->ref_el;
// only toggle if the edge is in y0. otherwise changing y1 won't matter.
if(iEdgeListSearch(tail, head, ref_el))
DyadSetToggle(tail,head, dnwp);
DDyadSetToggle(tail,head, dnwp);
}

F_CHANGESTAT_FN(f__intersect_net_DyadSet){
GET_AUX_STORAGE(StoreDyadSetAndRefEL, storage);
StoreDyadSet *dnwp = storage->nwp;
GET_AUX_STORAGE(StoreStrictDyadSetAndRefEL, storage);
StoreStrictDyadSet *dnwp = storage->nwp;

kh_destroy(DyadSet, dnwp);
kh_destroy(StrictDyadSet, dnwp);
}

I_CHANGESTAT_FN(i__intersect_net_toggles_in_list_DyadSet){
ALLOC_AUX_STORAGE(1, StoreDyadSetAndRefEL, storage);
StoreDyadSet *dnwp = storage->nwp = kh_init(DyadSet); dnwp->directed=DIRECTED;
ALLOC_AUX_STORAGE(1, StoreStrictDyadSetAndRefEL, storage);
StoreStrictDyadSet *dnwp = storage->nwp = kh_init(StrictDyadSet);
int *ref_el = storage->ref_el = IINPUT_PARAM;

Edge nedges = *ref_el;
for(Edge i=0; i<nedges; i++){
Vertex tail=ref_el[1+i], head=ref_el[1+nedges+i];
if(IS_OUTEDGE(tail, head)!=0)
DyadSetToggle(tail,head, dnwp);
DDyadSetToggle(tail,head, dnwp);
}
}

U_CHANGESTAT_FN(u__intersect_net_toggles_in_list_DyadSet){
GET_AUX_STORAGE(StoreDyadSetAndRefEL, storage);
StoreDyadSet *dnwp = storage->nwp;
GET_AUX_STORAGE(StoreStrictDyadSetAndRefEL, storage);
StoreStrictDyadSet *dnwp = storage->nwp;

DyadSetToggle(tail,head, dnwp);
DDyadSetToggle(tail,head, dnwp);
}

F_CHANGESTAT_FN(f__intersect_net_toggles_in_list_DyadSet){
GET_AUX_STORAGE(StoreDyadSetAndRefEL, storage);
StoreDyadSet *dnwp = storage->nwp;
GET_AUX_STORAGE(StoreStrictDyadSetAndRefEL, storage);
StoreStrictDyadSet *dnwp = storage->nwp;

kh_destroy(DyadSet, dnwp);
kh_destroy(StrictDyadSet, dnwp);
}

I_CHANGESTAT_FN(i__union_net_DyadSet){
ALLOC_AUX_STORAGE(1, StoreDyadSetAndRefEL, storage);
StoreDyadSet *dnwp = storage->nwp = NetworkToDyadSet(nwp);
ALLOC_AUX_STORAGE(1, StoreStrictDyadSetAndRefEL, storage);
StoreStrictDyadSet *dnwp = storage->nwp = NetworkToStrictDyadSet(nwp);
int *ref_el = storage->ref_el = IINPUT_PARAM;

Edge nedges = *ref_el;
for(Edge i=0; i<nedges; i++){
Vertex tail=ref_el[1+i], head=ref_el[1+nedges+i];
if(IS_OUTEDGE(tail, head)==0)
DyadSetToggle(tail,head, dnwp);
DDyadSetToggle(tail,head, dnwp);
}
}

U_CHANGESTAT_FN(u__union_net_DyadSet){
GET_AUX_STORAGE(StoreDyadSetAndRefEL, storage);
StoreDyadSet *dnwp = storage->nwp;
GET_AUX_STORAGE(StoreStrictDyadSetAndRefEL, storage);
StoreStrictDyadSet *dnwp = storage->nwp;
int *ref_el = storage->ref_el;
// If the edge is in y0, changing y1 won't matter.
if(iEdgeListSearch(tail, head, ref_el)==0)
DyadSetToggle(tail,head, dnwp);
DDyadSetToggle(tail,head, dnwp);
}

F_CHANGESTAT_FN(f__union_net_DyadSet){
GET_AUX_STORAGE(StoreDyadSetAndRefEL, storage);
StoreDyadSet *dnwp = storage->nwp;
GET_AUX_STORAGE(StoreStrictDyadSetAndRefEL, storage);
StoreStrictDyadSet *dnwp = storage->nwp;

kh_destroy(DyadSet, dnwp);
kh_destroy(StrictDyadSet, dnwp);
}
6 changes: 3 additions & 3 deletions src/changestats_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ C_CHANGESTAT_FN(c_disc_inter_union_net_Network){
}

C_CHANGESTAT_FN(c_disc_inter_union_net_DyadSet){
GET_AUX_STORAGE_NUM(StoreDyadSetAndRefEL, dstorage, 0);
GET_AUX_STORAGE_NUM(StoreDyadSetAndRefEL, istorage, 1);
GET_AUX_STORAGE_NUM(StoreDyadSetAndRefEL, ustorage, 2);
GET_AUX_STORAGE_NUM(StoreStrictDyadSetAndRefEL, dstorage, 0);
GET_AUX_STORAGE_NUM(StoreStrictDyadSetAndRefEL, istorage, 1);
GET_AUX_STORAGE_NUM(StoreStrictDyadSetAndRefEL, ustorage, 2);

int refedge = dEdgeListSearch(tail, head, INPUT_PARAM)!=0;

Expand Down

0 comments on commit cf9d2ae

Please sign in to comment.