1. Takafumi Arakaki
  2. ctypes_icc

Commits

Takafumi Arakaki  committed 3160dde

cleaned up ifnet_a2a2.c without changing the segfaults behavior

  • Participants
  • Parent commits 6439d2b
  • Branches default

Comments (0)

Files changed (2)

File ifnet_a2a2.c

View file
  • Ignore whitespace
 typedef struct ifnetalltoall2_{
-  int num_n, num_s, num_k;
+  int num_n;
   double dt, ie, gl, isyn, vrest, th, ssyn, tau1, tau2, lmd1, lmd2;
   double k1_mean, k2_mean;
-  int *fired, *total_spikes, **rec_sspike, **rec_fired;
-  double *vi, *v0, *k1, *k2, *lspike, *rec_isyn;
-  double **rec_vi, **rec_lspike;
+  double *vi, *v0;
 } IFNetAllToAll2;
 
 
 IFNetAllToAll2_vec_v0_rk2(IFNetAllToAll2 *self)
 {
   double isyn_estimate;
-  isyn_estimate =  /* ~Isyn(t+dt) */
+  isyn_estimate =
     self->ssyn * (self->lmd1 * self->k1_mean - self->lmd2 * self->k2_mean) /
     (self->tau1 - self->tau2);
-  vec_v0_rk2(  /* v0(t+dt) = vi(t) + dt * (dv/dt(t) + ~dv/dt(t+dt)) / 2 */
+  vec_v0_rk2(
       self->v0, self->vi, self->dt, self->gl, self->isyn,
       self->ie, isyn_estimate, self->num_n);
   return 0;

File run.py

View file
  • Ignore whitespace
 import numpy
 
 NUM_N = 100
-NUM_S = 2
 
-int1d = ctypes.POINTER(ctypes.c_int)
-double1d = ctypes.POINTER(ctypes.c_double)
-## c_double_p = ctypes.POINTER(ctypes.c_double)
-## c_int_p = ctypes.POINTER(ctypes.c_int)
+c_double_p = ctypes.POINTER(ctypes.c_double)
 
 
 class IFNetAllToAll2Struct(ctypes.Structure):
     _fields_ = [
         ("num_n", ctypes.c_int),
-        ("num_s", ctypes.c_int),
-        ("num_k", ctypes.c_int),
         ("dt", ctypes.c_double),
         ("ie", ctypes.c_double),
         ("gl", ctypes.c_double),
         ("lmd2", ctypes.c_double),
         ("k1_mean", ctypes.c_double),
         ("k2_mean", ctypes.c_double),
-        ("fired", int1d),
-        ("total_spikes", int1d),
-        ("rec_sspike", ctypes.c_void_p),
-        ("rec_fired", ctypes.c_void_p),
-        ("vi", double1d),
-        ("v0", double1d),
-        ("k1", double1d),
-        ("k2", double1d),
-        ("lspike", double1d),
-        ("rec_isyn", double1d),
-        ("rec_vi", ctypes.c_void_p),
-        ("rec_lspike", ctypes.c_void_p),
+        ("vi", c_double_p),
+        ("v0", c_double_p),
         ]
 
 
 
 if __name__ == '__main__':
     ifn = IFNetAllToAll2Struct(
-        num_n=NUM_N, num_s=NUM_S, dt=0.1, gl=0.1, vrest=-60, ie=-3.7, th=-40,
+        num_n=NUM_N, dt=0.1, gl=0.1, vrest=-60, ie=-3.7, th=-40,
         ssyn=0.5, tau1=3, tau2=1,
         )
-    ifn.num_k = ifn.num_s
     v0 = numpy.zeros(ifn.num_n, dtype=float)
     vi = numpy.zeros(ifn.num_n, dtype=float)
-    ifn.v0 = v0.ctypes.data_as(double1d)
-    ifn.vi = vi.ctypes.data_as(double1d)
+    ifn.v0 = v0.ctypes.data_as(c_double_p)
+    ifn.vi = vi.ctypes.data_as(c_double_p)
 
     init(ifn)
     vec_v0_rk2(ifn)