Skip to content

Commit

Permalink
restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienLeGuillou authored and krivit committed Oct 8, 2024
1 parent e19ca1f commit 5c958dc
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 65 deletions.
11 changes: 0 additions & 11 deletions src/MCMCDyn.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@
should have (k,j) with k>j.
*****************/

SEXP kvint_to_SEXP(kvint v) {
int size = kv_size(v);
SEXP out = PROTECT(allocVector(INTSXP, size));
int *out_ptr = INTEGER(out);
for (int i = 0; i < size; i++) {
out_ptr[i] = kv_A(v, i);
}
UNPROTECT(1);
return out;
}

/*****************
void MCMCDyn_wrapper
Expand Down
5 changes: 1 addition & 4 deletions src/MCMCDyn.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
#include "tergm_model.h"
#include "ergm_state.h"
#include "changestats_lasttoggle.h"
/*#include "diff_vect.h"*/

#include "ergm_kvec.h"
typedef kvec_t(int) kvint;
#include "kvint.h"

// TODO: This might be worth moving into a common "constants.h".
typedef enum MCMCDynStatus_enum {
Expand Down
33 changes: 0 additions & 33 deletions src/diff_vect.c

This file was deleted.

17 changes: 0 additions & 17 deletions src/diff_vect.h

This file was deleted.

12 changes: 12 additions & 0 deletions src/kvint.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "kvint.h"

SEXP kvint_to_SEXP(kvint v) {
int size = kv_size(v);
SEXP out = PROTECT(allocVector(INTSXP, size));
int *out_ptr = INTEGER(out);
for (int i = 0; i < size; i++) {
out_ptr[i] = kv_A(v, i);
}
UNPROTECT(1);
return out;
}
10 changes: 10 additions & 0 deletions src/kvint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef INCLUDE_SRC_KVINT_H_
#define INCLUDE_SRC_KVINT_H_

#include <Rinternals.h>
#include "ergm_kvec.h"

typedef kvec_t(int) kvint;
SEXP kvint_to_SEXP(kvint v);

#endif // INCLUDE_SRC_KVINT_H_

0 comments on commit 5c958dc

Please sign in to comment.