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

Go to the documentation of this file.
00001 /*********************************************************
00002   LCDNNHFSelectOneProngGhostZH.c
00003   --------------------------------------------------------
00004   generated at Thu Oct  4 10:11:46 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[14];
00025   /* Sources definition section */
00026   static pUnit Sources[] =  {
00027 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, 
00028 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, 
00029 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, 
00030 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, 
00031 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, 
00032 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, 
00033 Units + 6, Units + 7, Units + 8, Units + 9, Units + 10, Units + 11, 
00034 Units + 6, Units + 7, Units + 8, Units + 9, Units + 10, Units + 11, 
00035 
00036   };
00037 
00038   /* Weigths definition section */
00039   static float Weights[] =  {
00040 6.795080, 36.615761, -38.710850, 11.104960, -1.342090, 
00041 -2.561920, 10.766250, 11.876540, -4.658730, -3.258800, 
00042 -10.470490, 6.696490, 12.796300, -8.132660, 37.982201, 
00043 -36.927010, 26.769621, 4.696060, -35.883621, -1.331190, 
00044 -1.814090, -10.446790, -52.487320, -1.633120, -1.313840, 
00045 -4.088760, 2.603680, -16.130280, -5.030680, -0.511690, 
00046 0.874110, -2.418170, 1.527290, -1.497610, -3.742840, -1.930660, 
00047 -1.060450, -1.356060, -1.438570, 1.634410, -21.754440, 2.132080, 
00048 
00049   };
00050 
00051   /* unit definition section (see also UnitType) */
00052   static UnitType Units[14] = 
00053   {
00054     { 0.0, 0.0, 0, NULL , NULL },
00055     { /* unit 1 (Old: 1) */
00056       0.0, -0.457800, 0,
00057        &Sources[0] , 
00058        &Weights[0] , 
00059       },
00060     { /* unit 2 (Old: 2) */
00061       0.0, -0.496710, 0,
00062        &Sources[0] , 
00063        &Weights[0] , 
00064       },
00065     { /* unit 3 (Old: 3) */
00066       0.0, 0.701980, 0,
00067        &Sources[0] , 
00068        &Weights[0] , 
00069       },
00070     { /* unit 4 (Old: 4) */
00071       0.0, 0.559260, 0,
00072        &Sources[0] , 
00073        &Weights[0] , 
00074       },
00075     { /* unit 5 (Old: 5) */
00076       0.0, 0.788770, 0,
00077        &Sources[0] , 
00078        &Weights[0] , 
00079       },
00080     { /* unit 6 (Old: 6) */
00081       0.0, -3.223680, 5,
00082        &Sources[0] , 
00083        &Weights[0] , 
00084       },
00085     { /* unit 7 (Old: 7) */
00086       0.0, -5.314620, 5,
00087        &Sources[5] , 
00088        &Weights[5] , 
00089       },
00090     { /* unit 8 (Old: 8) */
00091       0.0, -34.981300, 5,
00092        &Sources[10] , 
00093        &Weights[10] , 
00094       },
00095     { /* unit 9 (Old: 9) */
00096       0.0, 30.231039, 5,
00097        &Sources[15] , 
00098        &Weights[15] , 
00099       },
00100     { /* unit 10 (Old: 10) */
00101       0.0, -0.487060, 5,
00102        &Sources[20] , 
00103        &Weights[20] , 
00104       },
00105     { /* unit 11 (Old: 11) */
00106       0.0, 3.969660, 5,
00107        &Sources[25] , 
00108        &Weights[25] , 
00109       },
00110     { /* unit 12 (Old: 12) */
00111       0.0, 0.102590, 6,
00112        &Sources[30] , 
00113        &Weights[30] , 
00114       },
00115     { /* unit 13 (Old: 13) */
00116       0.0, -0.362750, 6,
00117        &Sources[36] , 
00118        &Weights[36] , 
00119       }
00120 
00121   };
00122 
00123 
00124 
00125 int LCDNNHFSelectOneProngGhostZH(float *in, float *out, int init)
00126 {
00127   int member, source;
00128   float sum;
00129   enum{OK, Error, Not_Valid};
00130   pUnit unit;
00131 
00132 
00133   /* layer definition section (names & member units) */
00134 
00135   static pUnit Input[5] = {Units + 1, Units + 2, Units + 3, Units + 4, Units + 5}; /* members */
00136 
00137   static pUnit Hidden1[6] = {Units + 6, Units + 7, Units + 8, Units + 9, Units + 10, Units + 11}; /* members */
00138 
00139   static pUnit Output1[2] = {Units + 12, Units + 13}; /* members */
00140 
00141   static int Output[2] = {12, 13};
00142 
00143   for(member = 0; member < 5; member++) {
00144     Input[member]->act = in[member];
00145   }
00146 
00147   for (member = 0; member < 6; member++) {
00148     unit = Hidden1[member];
00149     sum = 0.0;
00150     for (source = 0; source < unit->NoOfSources; source++) {
00151       sum += unit->sources[source]->act
00152              * unit->weights[source];
00153     }
00154     unit->act = Act_Logistic(sum, unit->Bias);
00155   };
00156 
00157   for (member = 0; member < 2; member++) {
00158     unit = Output1[member];
00159     sum = 0.0;
00160     for (source = 0; source < unit->NoOfSources; source++) {
00161       sum += unit->sources[source]->act
00162              * unit->weights[source];
00163     }
00164     unit->act = Act_Logistic(sum, unit->Bias);
00165   };
00166 
00167   for(member = 0; member < 2; member++) {
00168     out[member] = Units[Output[member]].act;
00169   }
00170 
00171   return(OK);
00172 }

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