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

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------------
00002   $Id: LCDNNTrackAttach.c,v 1.2 2001/05/11 21:35:54 toshi Exp $
00003   -----------------------------------------------------------------------------
00004 
00005   $Log: LCDNNTrackAttach.c,v $
00006   Revision 1.2  2001/05/11 21:35:54  toshi
00007   Add CVS tags $Id: $ and $Log: $.
00008 
00009 
00010 */
00011 /*********************************************************
00012   LCDNNTrackAttach.c
00013   --------------------------------------------------------
00014   generated at Wed Feb 21 15:53:50 2001
00015   by snns2c ( Bernward Kett 1995 ) 
00016 *********************************************************/
00017 
00018 #include <math.h>
00019 
00020 #define Act_Logistic(sum, bias)  ( (sum+bias<10000.0) ? ( 1.0/(1.0 + exp(-sum-bias) ) ) : 0.0 )
00021 #ifndef NULL
00022 #define NULL (void *)0
00023 #endif
00024 
00025 typedef struct UT {
00026           float act;         /* Activation       */
00027           float Bias;        /* Bias of the Unit */
00028           int   NoOfSources; /* Number of predecessor units */
00029    struct UT   **sources; /* predecessor units */
00030           float *weights; /* weights from predecessor units */
00031         } UnitType, *pUnit;
00032 
00033   /* Forward Declaration for all unit types */
00034   static UnitType Units[13];
00035   /* Sources definition section */
00036   static pUnit Sources[] =  {
00037 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, 
00038 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, 
00039 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, 
00040 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, 
00041 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, 
00042 Units + 1, Units + 2, Units + 3, Units + 4, Units + 5, 
00043 Units + 6, Units + 7, Units + 8, Units + 9, Units + 10, Units + 11, 
00044 
00045   };
00046 
00047   /* Weigths definition section */
00048   static float Weights[] =  {
00049 19.414761, -2.808000, -2.919760, -4.624430, 6.222280, 
00050 -75.335892, 9.486310, 2.994320, 11.566720, -11.007780, 
00051 -6.970760, 8.919360, 8.702320, 58.130859, -32.872280, 
00052 8.711170, -0.439700, -27.810261, 3.990040, -58.625229, 
00053 -8.255880, -12.572060, -59.266869, 18.190960, -8.602950, 
00054 69.875412, -0.535590, -6.422460, -80.229103, -5.782360, 
00055 -24.869949, 29.129721, -28.617640, -9.017590, -4.131780, 12.596730, 
00056 
00057   };
00058 
00059   /* unit definition section (see also UnitType) */
00060   static UnitType Units[13] = 
00061   {
00062     { 0.0, 0.0, 0, NULL , NULL },
00063     { /* unit 1 (Old: 1) */
00064       0.0, -0.766380, 0,
00065        &Sources[0] , 
00066        &Weights[0] , 
00067       },
00068     { /* unit 2 (Old: 2) */
00069       0.0, 0.593860, 0,
00070        &Sources[0] , 
00071        &Weights[0] , 
00072       },
00073     { /* unit 3 (Old: 3) */
00074       0.0, -0.397640, 0,
00075        &Sources[0] , 
00076        &Weights[0] , 
00077       },
00078     { /* unit 4 (Old: 4) */
00079       0.0, -0.748070, 0,
00080        &Sources[0] , 
00081        &Weights[0] , 
00082       },
00083     { /* unit 5 (Old: 5) */
00084       0.0, -0.141930, 0,
00085        &Sources[0] , 
00086        &Weights[0] , 
00087       },
00088     { /* unit 6 (Old: 6) */
00089       0.0, -6.281700, 5,
00090        &Sources[0] , 
00091        &Weights[0] , 
00092       },
00093     { /* unit 7 (Old: 7) */
00094       0.0, 6.387160, 5,
00095        &Sources[5] , 
00096        &Weights[5] , 
00097       },
00098     { /* unit 8 (Old: 8) */
00099       0.0, 12.803090, 5,
00100        &Sources[10] , 
00101        &Weights[10] , 
00102       },
00103     { /* unit 9 (Old: 9) */
00104       0.0, 10.464650, 5,
00105        &Sources[15] , 
00106        &Weights[15] , 
00107       },
00108     { /* unit 10 (Old: 10) */
00109       0.0, 0.437120, 5,
00110        &Sources[20] , 
00111        &Weights[20] , 
00112       },
00113     { /* unit 11 (Old: 11) */
00114       0.0, -0.157340, 5,
00115        &Sources[25] , 
00116        &Weights[25] , 
00117       },
00118     { /* unit 12 (Old: 12) */
00119       0.0, 6.594040, 6,
00120        &Sources[30] , 
00121        &Weights[30] , 
00122       }
00123 
00124   };
00125 
00126 
00127 
00128 int LCDNNTrackAttach(float *in, float *out, int init)
00129 {
00130   int member, source;
00131   float sum;
00132   enum{OK, Error, Not_Valid};
00133   pUnit unit;
00134 
00135 
00136   /* layer definition section (names & member units) */
00137 
00138   static pUnit Input[5] = {Units + 1, Units + 2, Units + 3, Units + 4, Units + 5}; /* members */
00139 
00140   static pUnit Hidden1[6] = {Units + 6, Units + 7, Units + 8, Units + 9, Units + 10, Units + 11}; /* members */
00141 
00142   static pUnit Output1[1] = {Units + 12}; /* members */
00143 
00144   static int Output[1] = {12};
00145 
00146   for(member = 0; member < 5; member++) {
00147     Input[member]->act = in[member];
00148   }
00149 
00150   for (member = 0; member < 6; member++) {
00151     unit = Hidden1[member];
00152     sum = 0.0;
00153     for (source = 0; source < unit->NoOfSources; source++) {
00154       sum += unit->sources[source]->act
00155              * unit->weights[source];
00156     }
00157     unit->act = Act_Logistic(sum, unit->Bias);
00158   };
00159 
00160   for (member = 0; member < 1; member++) {
00161     unit = Output1[member];
00162     sum = 0.0;
00163     for (source = 0; source < unit->NoOfSources; source++) {
00164       sum += unit->sources[source]->act
00165              * unit->weights[source];
00166     }
00167     unit->act = Act_Logistic(sum, unit->Bias);
00168   };
00169 
00170   for(member = 0; member < 1; member++) {
00171     out[member] = Units[Output[member]].act;
00172   }
00173 
00174   return(OK);
00175 }

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