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

Go to the documentation of this file.
00001 /*********************************************************
00002   LCDNNHFSelectOneProngGhostZpole.c
00003   --------------------------------------------------------
00004   generated at Sun Aug  5 20:30:55 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.261400, 5.287470, 19.333639, -10.045840, -2.607960, 
00041 -5.625460, 1.221120, 7.125640, -7.765170, -11.557370, 
00042 -24.978720, 6.799010, 23.034220, -28.224720, -1.916180, 
00043 -0.991310, -6.426360, -40.838009, -0.573490, -0.079970, 
00044 4.804940, -1.267260, -13.772060, 4.390400, -0.249890, 
00045 4.236590, -7.014590, -6.124230, -17.582581, 6.818620, 
00046 -1.298830, -6.547730, -2.690760, -4.488850, -3.294750, 0.688090, 
00047 -4.177030, -4.728670, 2.762380, -19.176821, 3.950630, -0.484780, 
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.942510, 0,
00057        &Sources[0] , 
00058        &Weights[0] , 
00059       },
00060     { /* unit 2 (Old: 2) */
00061       0.0, 0.900710, 0,
00062        &Sources[0] , 
00063        &Weights[0] , 
00064       },
00065     { /* unit 3 (Old: 3) */
00066       0.0, -0.008050, 0,
00067        &Sources[0] , 
00068        &Weights[0] , 
00069       },
00070     { /* unit 4 (Old: 4) */
00071       0.0, 0.635220, 0,
00072        &Sources[0] , 
00073        &Weights[0] , 
00074       },
00075     { /* unit 5 (Old: 5) */
00076       0.0, -0.629470, 0,
00077        &Sources[0] , 
00078        &Weights[0] , 
00079       },
00080     { /* unit 6 (Old: 6) */
00081       0.0, -1.349160, 5,
00082        &Sources[0] , 
00083        &Weights[0] , 
00084       },
00085     { /* unit 7 (Old: 7) */
00086       0.0, 3.280860, 5,
00087        &Sources[5] , 
00088        &Weights[5] , 
00089       },
00090     { /* unit 8 (Old: 8) */
00091       0.0, 18.570400, 5,
00092        &Sources[10] , 
00093        &Weights[10] , 
00094       },
00095     { /* unit 9 (Old: 9) */
00096       0.0, -0.520250, 5,
00097        &Sources[15] , 
00098        &Weights[15] , 
00099       },
00100     { /* unit 10 (Old: 10) */
00101       0.0, -2.067190, 5,
00102        &Sources[20] , 
00103        &Weights[20] , 
00104       },
00105     { /* unit 11 (Old: 11) */
00106       0.0, 3.443480, 5,
00107        &Sources[25] , 
00108        &Weights[25] , 
00109       },
00110     { /* unit 12 (Old: 12) */
00111       0.0, 0.843660, 6,
00112        &Sources[30] , 
00113        &Weights[30] , 
00114       },
00115     { /* unit 13 (Old: 13) */
00116       0.0, -1.336580, 6,
00117        &Sources[36] , 
00118        &Weights[36] , 
00119       }
00120 
00121   };
00122 
00123 
00124 
00125 int LCDNNHFSelectOneProngGhostZpole(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