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

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------------
00002   $Id: LCDNNSeedVertex.c,v 1.2 2001/05/11 21:35:53 toshi Exp $
00003   -----------------------------------------------------------------------------
00004 
00005   $Log: LCDNNSeedVertex.c,v $
00006   Revision 1.2  2001/05/11 21:35:53  toshi
00007   Add CVS tags $Id: $ and $Log: $.
00008 
00009 
00010 */
00011 /*********************************************************
00012   LCDNNSeedVertex.c
00013   --------------------------------------------------------
00014   generated at Fri Feb 16 14:09:57 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[8];
00035   /* Sources definition section */
00036   static pUnit Sources[] =  {
00037 Units + 1, Units + 2, Units + 3, 
00038 Units + 1, Units + 2, Units + 3, 
00039 Units + 1, Units + 2, Units + 3, 
00040 Units + 4, Units + 5, Units + 6, 
00041 
00042   };
00043 
00044   /* Weigths definition section */
00045   static float Weights[] =  {
00046 -11.317890, -0.705460, 15.902080, 
00047 7.238910, 7.200770, -2.640270, 
00048 -16.638500, -7.847330, -2.392810, 
00049 4.946140, 3.236760, -5.214430, 
00050 
00051   };
00052 
00053   /* unit definition section (see also UnitType) */
00054   static UnitType Units[8] = 
00055   {
00056     { 0.0, 0.0, 0, NULL , NULL },
00057     { /* unit 1 (Old: 1) */
00058       0.0, -0.647750, 0,
00059        &Sources[0] , 
00060        &Weights[0] , 
00061       },
00062     { /* unit 2 (Old: 2) */
00063       0.0, -0.459980, 0,
00064        &Sources[0] , 
00065        &Weights[0] , 
00066       },
00067     { /* unit 3 (Old: 3) */
00068       0.0, 0.545420, 0,
00069        &Sources[0] , 
00070        &Weights[0] , 
00071       },
00072     { /* unit 4 (Old: 4) */
00073       0.0, 4.517060, 3,
00074        &Sources[0] , 
00075        &Weights[0] , 
00076       },
00077     { /* unit 5 (Old: 5) */
00078       0.0, -4.168520, 3,
00079        &Sources[3] , 
00080        &Weights[3] , 
00081       },
00082     { /* unit 6 (Old: 6) */
00083       0.0, 8.460350, 3,
00084        &Sources[6] , 
00085        &Weights[6] , 
00086       },
00087     { /* unit 7 (Old: 7) */
00088       0.0, -4.339520, 3,
00089        &Sources[9] , 
00090        &Weights[9] , 
00091       }
00092 
00093   };
00094 
00095 
00096 
00097 int LCDNNSeedVertex(float *in, float *out, int init)
00098 {
00099   int member, source;
00100   float sum;
00101   enum{OK, Error, Not_Valid};
00102   pUnit unit;
00103 
00104 
00105   /* layer definition section (names & member units) */
00106 
00107   static pUnit Input[3] = {Units + 1, Units + 2, Units + 3}; /* members */
00108 
00109   static pUnit Hidden1[3] = {Units + 4, Units + 5, Units + 6}; /* members */
00110 
00111   static pUnit Output1[1] = {Units + 7}; /* members */
00112 
00113   static int Output[1] = {7};
00114 
00115   for(member = 0; member < 3; member++) {
00116     Input[member]->act = in[member];
00117   }
00118 
00119   for (member = 0; member < 3; member++) {
00120     unit = Hidden1[member];
00121     sum = 0.0;
00122     for (source = 0; source < unit->NoOfSources; source++) {
00123       sum += unit->sources[source]->act
00124              * unit->weights[source];
00125     }
00126     unit->act = Act_Logistic(sum, unit->Bias);
00127   };
00128 
00129   for (member = 0; member < 1; member++) {
00130     unit = Output1[member];
00131     sum = 0.0;
00132     for (source = 0; source < unit->NoOfSources; source++) {
00133       sum += unit->sources[source]->act
00134              * unit->weights[source];
00135     }
00136     unit->act = Act_Logistic(sum, unit->Bias);
00137   };
00138 
00139   for(member = 0; member < 1; member++) {
00140     out[member] = Units[Output[member]].act;
00141   }
00142 
00143   return(OK);
00144 }

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