home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
APPS
/
ant.ytar
/
ant
/
ANT
/
ant_xor.c
< prev
next >
Wrap
Text File
|
1995-07-15
|
2KB
|
72 lines
/*************************************************************************
* Program: ant_xor.c this is an application program for the xor example
* it shows how to include ant computation in any user
* program once the ant net is trained
* To compile this program use the command:
*
* $cc -v=<ant_directory>/defs -l=<ant_directory>/lib/antlib.l ant_xor.c
*
* Version Date Author Comments & modif.
* -------- --------- ---------------------------- -------------------
* V1.00 13-Jun-95 I. Labrador, R. Carrasco, LML Very first version
*/
#include <stdio.h>
#include <math.h>
#include <strings.h>
#include "ant.h" /* neural net header */
#include "antlib.h" /* functions prototypes */
main ()
{
ant_neuron **ant_neuronD; /* declare net structures */
ant_net ant_netD;
int l,n; /* layer and neuron index */
double *input_vector, /* user input and output vector */
*output_vector;
strcpy( (ant_netD.init),"ant_init.xor"); /* get init file name */
ant_neuronD = ant_init(&ant_netD); /* fill paramter of the net data structure, layers neurons , weights ...*/
input_vector = ( double *) calloc( ant_netD.n[0] , sizeof(double)); /* allocate vector size = number of input of the net (layer 0)*/
/* . */
/* . */
/* user code */
/* . */
/* . */
input_vector[0]=1.; /* ant computation of an input vector */
input_vector[1]=1.;
output_vector=ant_process(input_vector,&ant_netD,ant_neuronD); /* propagate and compute the net output*/
/* ant_process() return the pointer to the vector results*/
/* */
/* user code where the ant result is applied */
/* */
/* in this example we just print out the results */
printf("INPUTS: ");
for(n = 1; n < ant_netD.n[0];n++) /* per each input */
printf("%12.4lf ",input_vector[n-1]);
printf("\n");
printf("OUTPUTS: ");
l=ant_netD.l - 1; /* output layer */
for(n = 1; n < ant_netD.n[l];n++) /* per each output */
printf("%12.4lf", output_vector[n-1]);
printf("\n");
}