/Home/aooliver/hepsoft/lcdroot/LCDRootApps/PhUtil/src/LCDNNHFSelectGhostZH.c

Go to the documentation of this file.
00001 /*********************************************************
00002   LCDNNHFSelectGhostZH.c
00003   --------------------------------------------------------
00004   generated at Thu Oct  4 08:16:11 2001
00005   by snns2c ( Bernward Kett 1995 ) 
00006 *********************************************************/
00007 
00008 #include <math.h>
00009 
00010 #define Act_Logistic(sum, bias)  ( (sum+bias<10000.0) ? ( 1.0/(1.0 + exp(-sum-bias) ) ) : 0.0 )
00011 #ifndef NULL
00012 #define NULL (void *)0
00013 #endif
00014 
00015 typedef struct UT {
00016           float act;         /* Activation       */
00017           float Bias;        /* Bias of the Unit */
00018           int   NoOfSources; /* Number of predecessor units */
00019    struct UT   **sources; /* predecessor units */
00020           float *weights; /* weights from predecessor units */
00021         } UnitType, *pUnit;
00022 
00023   /* Forward Declaration for all unit types */
00024   static UnitType Units[18];
00025   /* Sources definition section */
00026   static pUnit Sources[] =  {
00027 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, Units + 6, Units + 7, 
00028 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, Units + 6, Units + 7, 
00029 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, Units + 6, Units + 7, 
00030 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, Units + 6, Units + 7, 
00031 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, Units + 6, Units + 7, 
00032 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, Units + 6, Units + 7, 
00033 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, Units + 6, Units + 7, 
00034 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, Units + 6, Units + 7, 
00035 Units + 8, Units + 9, Units + 10, Units + 11, Units + 12, Units + 13, Units + 14, Units + 15, 
00036 Units + 8, Units + 9, Units + 10, Units + 11, Units + 12, Units + 13, Units + 14, Units + 15, 
00037 
00038   };
00039 
00040   /* Weigths definition section */
00041   static float Weights[] =  {
00042 -40.251732, 30.447550, -1.602510, 4.982160, -1.672310, -2.706350, 2.616760, 
00043 75.607498, 8.297900, 14.142590, -2.111890, 8.203920, -21.157690, -13.410130, 
00044 8.054140, 14.547020, 25.253889, -3.139480, 14.607220, 4.823490, -2.293770, 
00045 44.736389, 12.803110, 10.143750, -0.941820, 9.562440, -23.232090, -42.112411, 
00046 -3.999900, 3.262790, 1.200900, -10.326560, -1.438990, -1.786290, -2.894920, 
00047 20.389650, 1.138780, -7.157040, -5.356400, 2.709180, -2.203460, -13.270920, 
00048 -9.687040, -58.619419, 7.007860, 6.591980, 7.104910, -9.463710, -3.212440, 
00049 -14.819140, -9.980000, -17.429661, 0.006080, -6.279540, -16.674580, 11.335890, 
00050 3.341770, 2.599630, 1.212160, -1.699510, -2.672590, -2.016580, -1.450800, -2.368060, 
00051 -3.529960, -2.641480, -1.278930, 1.656950, 2.647930, 2.161220, 1.495570, 2.351890, 
00052 
00053   };
00054 
00055   /* unit definition section (see also UnitType) */
00056   static UnitType Units[18] = 
00057   {
00058     { 0.0, 0.0, 0, NULL , NULL },
00059     { /* unit 1 (Old: 1) */
00060       0.0, -0.996130, 0,
00061        &Sources[0] , 
00062        &Weights[0] , 
00063       },
00064     { /* unit 2 (Old: 2) */
00065       0.0, 0.640110, 0,
00066        &Sources[0] , 
00067        &Weights[0] , 
00068       },
00069     { /* unit 3 (Old: 3) */
00070       0.0, 0.465430, 0,
00071        &Sources[0] , 
00072        &Weights[0] , 
00073       },
00074     { /* unit 4 (Old: 4) */
00075       0.0, 0.964590, 0,
00076        &Sources[0] , 
00077        &Weights[0] , 
00078       },
00079     { /* unit 5 (Old: 5) */
00080       0.0, -0.613660, 0,
00081        &Sources[0] , 
00082        &Weights[0] , 
00083       },
00084     { /* unit 6 (Old: 6) */
00085       0.0, 0.727940, 0,
00086        &Sources[0] , 
00087        &Weights[0] , 
00088       },
00089     { /* unit 7 (Old: 7) */
00090       0.0, 0.325820, 0,
00091        &Sources[0] , 
00092        &Weights[0] , 
00093       },
00094     { /* unit 8 (Old: 8) */
00095       0.0, -7.565630, 7,
00096        &Sources[0] , 
00097        &Weights[0] , 
00098       },
00099     { /* unit 9 (Old: 9) */
00100       0.0, -23.198351, 7,
00101        &Sources[7] , 
00102        &Weights[7] , 
00103       },
00104     { /* unit 10 (Old: 10) */
00105       0.0, -23.227440, 7,
00106        &Sources[14] , 
00107        &Weights[14] , 
00108       },
00109     { /* unit 11 (Old: 11) */
00110       0.0, -14.414860, 7,
00111        &Sources[21] , 
00112        &Weights[21] , 
00113       },
00114     { /* unit 12 (Old: 12) */
00115       0.0, 7.112380, 7,
00116        &Sources[28] , 
00117        &Weights[28] , 
00118       },
00119     { /* unit 13 (Old: 13) */
00120       0.0, -6.969480, 7,
00121        &Sources[35] , 
00122        &Weights[35] , 
00123       },
00124     { /* unit 14 (Old: 14) */
00125       0.0, -3.288610, 7,
00126        &Sources[42] , 
00127        &Weights[42] , 
00128       },
00129     { /* unit 15 (Old: 15) */
00130       0.0, 10.541330, 7,
00131        &Sources[49] , 
00132        &Weights[49] , 
00133       },
00134     { /* unit 16 (Old: 16) */
00135       0.0, 2.547040, 8,
00136        &Sources[56] , 
00137        &Weights[56] , 
00138       },
00139     { /* unit 17 (Old: 17) */
00140       0.0, -2.574890, 8,
00141        &Sources[64] , 
00142        &Weights[64] , 
00143       }
00144 
00145   };
00146 
00147 
00148 
00149 int LCDNNHFSelectGhostZH(float *in, float *out, int init)
00150 {
00151   int member, source;
00152   float sum;
00153   enum{OK, Error, Not_Valid};
00154   pUnit unit;
00155 
00156 
00157   /* layer definition section (names & member units) */
00158 
00159   static pUnit Input[7] = {Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, Units + 6, Units + 7}; /* members */
00160 
00161   static pUnit Hidden1[8] = {Units + 8, Units + 9, Units + 10, Units + 11, Units + 12, Units + 13, Units + 14, Units + 15}; /* members */
00162 
00163   static pUnit Output1[2] = {Units + 16, Units + 17}; /* members */
00164 
00165   static int Output[2] = {16, 17};
00166 
00167   for(member = 0; member < 7; member++) {
00168     Input[member]->act = in[member];
00169   }
00170 
00171   for (member = 0; member < 8; member++) {
00172     unit = Hidden1[member];
00173     sum = 0.0;
00174     for (source = 0; source < unit->NoOfSources; source++) {
00175       sum += unit->sources[source]->act
00176              * unit->weights[source];
00177     }
00178     unit->act = Act_Logistic(sum, unit->Bias);
00179   };
00180 
00181   for (member = 0; member < 2; member++) {
00182     unit = Output1[member];
00183     sum = 0.0;
00184     for (source = 0; source < unit->NoOfSources; source++) {
00185       sum += unit->sources[source]->act
00186              * unit->weights[source];
00187     }
00188     unit->act = Act_Logistic(sum, unit->Bias);
00189   };
00190 
00191   for(member = 0; member < 2; member++) {
00192     out[member] = Units[Output[member]].act;
00193   }
00194 
00195   return(OK);
00196 }

Generated on Tue Jul 18 18:33:59 2006 for LCDROOT by  doxygen 1.4.6