
/* WARNING: This file has been generated by Nettool3 */


/**** Here is the Non Linear Function */

/* This is the default function:
 * Update according to the SN settings.
 */

static double squash(x)
double x;
{
   double tanh();
   return 1.7159*tanh(x*0.6666);
}


/**** Here is the Forward Propagation Code */

void fprop(input, output, wbase)
 float input[20][20];
 float output[40][1];
 float wbase[17680];
{
  float hid_den[40][1];

   /**** LAYER hid_den *****/

  /* BIAS-CONNECT */
  {  int i,j;
     float *w = wbase+0;
     for (i=0; i<40; i++)
       for (j=0; j<1; j++)
          hid_den[i][j] = *w++;
  }

  /* CT-CONNECT from input to hid_den */
  {  int i,j,k,l;
     float sum;
     float (*w)[20][40][1] = (void*)(wbase + 80);
     for(i=0;i<40;i++)
       for(j=0;j<1;j++) {
         sum = 0.0;
         for(k=0;k<20;k++)
           for(l=0;l<20;l++)
             sum += w[k][l][i][j] * input[k][l];
         hid_den[i][j] += sum;
       }
   }

  /* Sigmoid */
  {  int i,j;
     for (j=0; j<40; j++) 
       for (i=0; i<1; i++)
          hid_den[i][j] = squash(hid_den[i][j]);
  }

   /**** LAYER output *****/

  /* BIAS-CONNECT */
  {  int i,j;
     float *w = wbase+40;
     for (i=0; i<40; i++)
       for (j=0; j<1; j++)
          output[i][j] = *w++;
  }

  /* CT-CONNECT from hid_den to output */
  {  int i,j,k,l;
     float sum;
     float (*w)[1][40][1] = (void*)(wbase + 16080);
     for(i=0;i<40;i++)
       for(j=0;j<1;j++) {
         sum = 0.0;
         for(k=0;k<40;k++)
           for(l=0;l<1;l++)
             sum += w[k][l][i][j] * hid_den[k][l];
         output[i][j] += sum;
       }
   }

  /* Sigmoid */
  {  int i,j;
     for (j=0; j<40; j++) 
       for (i=0; i<1; i++)
          output[i][j] = squash(output[i][j]);
  }
}




/**** Here is the DX interface function */

#include "header.h"

DX(xfprop)
{
  ARG_NUMBER(3);
  ALL_ARGS_EVAL;
  fprop( get_std_matrix(APOINTER(1),20,20),
         get_std_matrix(APOINTER(2),40,1),
         get_std_vector(APOINTER(3),17680) );
  return NIL;
}

