00001
00007 #ifndef __LISSOM_H__
00008 #define __LISSOM_H__
00009
00010
00011
00012
00013
00014
00015 #define MAXITERATION 500000
00016 #define DEATH_FLAG 1.0E-10
00019 #define ALIVE_MINIMUM 1.0E-09
00020 #define MAXFILENAMELENGTH 255
00022 #define MAX_NUM_ANGLES 36
00025
00026
00027
00028
00030 #ifndef NPES
00031 #define NPES 1
00032 #endif
00033
00038 #ifdef NROWS
00039 #define NMAX ((NPES)*(NROWS))
00040 #else
00041
00042 #ifndef NMAX
00043 #define NMAX 24
00044 #endif
00045
00046 #define NROWS ((NMAX)/(NPES))
00047 #endif
00048
00049
00050 #if (NROWS>NMAX)
00051 #error "NROWS can't exceed NMAX"
00052 #endif
00053
00054
00056 #ifndef RNMAX
00057 #define RNMAX 36
00058 #endif
00059
00060
00062 #ifndef MAX_RF_RADIUS
00063 #define MAX_RF_RADIUS 6
00064 #endif
00065
00066 #define WTMAX (2*MAX_RF_RADIUS+1)
00067
00068 #ifndef MAX_NUM_EYES
00069 #define MAX_NUM_EYES 2
00070 #endif
00071
00077 #if (MAX_NUM_EYES==1)
00078 #define combined_eyes 0
00079 #define EYE_ARRAY_SIZE 1
00080
00081 #ifndef NUM_EYES_IS_CONSTANT
00082 #define NUM_EYES_IS_CONSTANT
00083 #endif
00084 #else
00085 #define combined_eyes (num_eyes)
00086 #define EYE_ARRAY_SIZE (MAX_NUM_EYES+1)
00087 #endif
00088
00089 00090 00091 00092 00093 00094
00095
00096
00097
00098
00099
00100 #ifndef MAX_EXC_RADIUS
00101 #ifdef MINIMAL_LATERAL_CONNECTIONS
00102 #define MAX_EXC_RADIUS 0
00103 #else
00104 #define MAX_EXC_RADIUS MIN(NMAX/10,1)
00105 #endif
00106 #endif
00107
00108 #define MAX_EXC_DIMENSION ((2*MAX_EXC_RADIUS+1)*(2*MAX_EXC_RADIUS+1))
00109
00110
00111
00112 #ifndef MAX_INH_RADIUS
00113 #ifdef MINIMAL_LATERAL_CONNECTIONS
00114 #define MAX_INH_RADIUS 0
00115 #else
00116 #define MAX_INH_RADIUS MIN(NMAX/4,2)
00117 #endif
00118 #endif
00119
00120 #define MAX_INH_DIMENSION ((2*MAX_INH_RADIUS+1)*(2*MAX_INH_RADIUS+1))
00121
00122
00123
00124
00125
00126
00127
00128
00129
00132 #define MAPROW(localrow) (ARBITRARY_MAPROW((localrow),MyPE))
00133 #define ARBITRARY_MAPROW(localrow,pe) (pe+(localrow)*NPEs)
00134
00137 #define LOCALROW(maprow) ((maprow)/NPEs)
00138
00140 #define PEFORROW(maprow) ((maprow)%NPEs)
00141
00143 #define ROWISLOCAL(maprow) (ARBITRARY_ROWISLOCAL((maprow),MyPE))
00144 #define ARBITRARY_ROWISLOCAL(maprow,pe) ((pe)==PEFORROW(maprow))
00145
00146
00150 #define PARENTPE 0
00151 #define YOUNGESTPE (NPEs-1)
00152
00153 #define AMPARENTPE (MyPE==PARENTPE)
00154 #define AMYOUNGESTPE (MyPE==YOUNGESTPE)
00155
00156
00157
00158 #define PEISME(pe) ((pe)==MyPE)
00159
00160
00161
00162
00163
00164
00165
00182 #define PARTIAL_INP_INDEX(eye,x) ((eye)*(RN*RN)+(x)*(RN))
00183 #define FULL_INP_INDEX(partial_inp_index,y) ((partial_inp_index)+(y))
00184 #define INP_INDEX(eye,x,y) FULL_INP_INDEX(PARTIAL_INP_INDEX((eye),(x)),(y))
00185 #define INP_INDEX_OTHER_EYE(eye,first_inp_index) ((first_inp_index) + ((eye)*RN*RN))
00186
00187
00188
00189
00190
00191
00193 #define WITHIN_RADIUS(xdistance,ydistance,radius_sq) \
00194 (((xdistance)*(xdistance) + (ydistance)*(ydistance)) <= (radius_sq))
00195
00197 #define WITHIN_RADIUS_SQ(xdistance_sq,ydistance_sq,radius_sq) \
00198 ((xdistance_sq) + (ydistance_sq) <= (radius_sq))
00199
00200
00201
00202
00203
00204
00216 #define PARTIAL_LAT_INDEX(ui,uj,k,radius,width) (((k)-(ui)+(radius))*(width)-(uj)+(radius))
00217 #define FULL_LAT_INDEX(partial_index,l) ((partial_index)+(l))
00218 #define LAT_INDEX(ui,uj,k,l,radius,width) FULL_LAT_INDEX(PARTIAL_LAT_INDEX((ui),(uj),(k),(radius),(width)),(l))
00219
00220
00221
00222
00223
00224
00225
00226 typedef float a_weight;
00227 typedef float l_weight;
00228
00229
00230 typedef struct
00231 {
00232 int centerx, centery ;
00233 a_weight (*weights)[WTMAX][WTMAX];
00234 l_weight *lat_exc_wts ;
00235 l_weight *lat_inh_wts ;
00236 } Neuron ;
00237
00238
00239
00240
00241
00242
00243
00244
00247 #define CONSTRAIN_ANGLE(angle) \
00248 (((angle)>=0) ? \
00249 fmod( (angle), M_PI ) : \
00250 fmod( (angle) + 2*M_PI*(-1*floor((angle)/(M_PI*2))+1), M_PI) )
00251
00254 #define CONSTRAIN_SYMMETRIC(angle) \
00255 (( CONSTRAIN_ANGLE(angle) <M_PI/2) ? \
00256 ( CONSTRAIN_ANGLE(angle)) : \
00257 ( CONSTRAIN_ANGLE(angle) - M_PI) )
00258
00259
00262 #define CONSTRAIN_CIRCLE(angle) \
00263 (((angle)>=0) ? \
00264 fmod( (angle), 2*M_PI ) : \
00265 fmod( (angle) + M_PI*2*(-1*floor((angle)/(M_PI*2))+1), 2*M_PI) )
00266
00267
00274 #define OR_PREF_TO_DEGREES(or_pref) (180.0*(or_pref)/(double)or_num_angles)
00275 #define RADIANS_TO_OR_PREF(theta) (((int)ROUND(or_num_angles*(2+(theta)/M_PI))) % or_num_angles)
00276 #define RADIANS_TO_DEGREES(theta) (180.0*(theta)/M_PI)
00277 #define DEGREES_TO_RADIANS(degree) (M_PI*(degree)/180.0)
00278
00279
00281 #define NEURON_OUTSIDE_CORTEX(ui,uj) \
00282 (((ui) < 0) || ((ui) >= N) || ((uj) < 0) || ((uj) >= N) )
00283
00284 #define ABORT_IF_NEURON_OUTSIDE_CORTEX(ui,uj) \
00285 if ( NEURON_OUTSIDE_CORTEX(ui,uj)) { \
00286 ipc_notify(IPC_ONE,IPC_ERROR,"Neuron (%d,%d) is out of range of the cortex", ui, uj); \
00287 return CMD_PARAMETER_ERROR; \
00288 }
00289
00290 #define ABORT_IF_RANGE_OUTSIDE_CORTEX(ui,uj,uk,ul) \
00291 if ( NEURON_OUTSIDE_CORTEX(ui,uj) || NEURON_OUTSIDE_CORTEX(uk,ul)) { \
00292 ipc_notify(IPC_ONE,IPC_ERROR,"Area (%d,%d) to (%d,%d) is out of range of the cortex", \
00293 ui, uj, uk, ul); \
00294 return CMD_PARAMETER_ERROR; \
00295 }
00296
00297 #define PROGRESS_REPORT_NEEDED(last_msg_time) \
00298 (progress_reports && (time(NULL)-(last_msg_time) >= progress_report_interval))
00299
00300
00301
00302
00303
00304
00305
00306 00307 00308 00309 00310 00311 00312 00313 00314
00315 #include <assert.h>
00316
00317 #ifdef USE_EXTENDED_ASSERT
00318 00319 00320 00321
00322 #ifndef NDEBUG
00323 #undef assert
00324
00329 #if (defined(__GNUC__) && !defined(NO_ASSERT_FUNC_INFO_AVAIL))
00330 #define assert(expr) \
00331 ((void) ((expr) ? 0 : \
00332 (ipc_notify(IPC_ALL,IPC_ERROR,"Assertion (%s) failed at %s:%d in %s()", \
00333 __STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION), 0)) )
00334
00335 #else
00336 #define assert(expr) \
00337 ((void) ((expr) ? 0 : \
00338 (ipc_notify(IPC_ALL,IPC_ERROR,"Assertion (%s) failed at %s:%d", \
00339 #expr, __FILE__, __LINE__), 0)) )
00340 #endif
00341
00342 #endif
00343 #endif
00344
00345
00346
00347
00348
00349
00350
00351
00352 #define DEBUGOUT(val) cerr << #val << ": " << val << endl
00353
00354
00355 #endif