00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00016
00017 #ifndef __CINT__
00018 #include "Api.h"
00019 #endif
00020
00021 #include<sstream>
00022
00023 #include "AltNeuralNetFunc.h"
00024
00025 #include "LeakChecker/Lea.h"
00026 #include "MessageService/MsgService.h"
00027
00028 ClassImp(AltNeuralNetFunc)
00029
00030
00031 CVSID("$Id: AltNeuralNetFunc.cxx,v 1.1 2003/10/22 18:18:01 costas Exp $");
00032
00033 AltNeuralNetFunc::AltNeuralNetFunc() :
00034 TNamed()
00035 {
00036 MSG("AltNeuralNet",Msg::kDebug)
00037 << "Begin of AltNeuralNetFunc::AltNeuralNetFunc() ctor" << endl;
00038 LEA_CTOR;
00039 }
00040
00041 AltNeuralNetFunc::AltNeuralNetFunc(const char * name, const char * title) :
00042 TNamed(name, title)
00043 {
00044 MSG("AltNeuralNet",Msg::kDebug)
00045 << "Begin of AltNeuralNetFunc::AltNeuralNetFunc("
00046 << "const char *, const char * ) ctor" << endl;
00047
00048 fTitle = std::string(title);
00049
00050 LEA_CTOR;
00051 }
00052
00053 AltNeuralNetFunc::~AltNeuralNetFunc()
00054 {
00055 MSG("AltNeuralNet",Msg::kDebug)
00056 << "Begin of AltNeuralNetFunc::~AltNeuralNetFunc() dtor" << endl;
00057
00058 LEA_DTOR;
00059 }
00060
00061 double AltNeuralNetFunc::run(
00062 double (*neural_net)(double *), AltNeuralNetI * pattern )
00063 {
00064 float network_out = -1;
00065
00066 const int kInputs = pattern->getNumberOfInputs();
00067 float * inputs = new float[kInputs];
00068
00069 pattern->copyInputsToArray(inputs);
00070
00071 #ifndef __CINT__
00072 G__CallFunc func;
00073 switch(G__isinterpretedp2f( (void*)neural_net )) {
00074
00075
00076 case G__COMPILEDINTERFACEMETHOD:
00077 func.SetFunc( (G__InterfaceMethod)neural_net );
00078 func.SetArg((long)inputs);
00079 network_out = func.ExecDouble( (void*)NULL );
00080 break;
00081 default:
00082 exit(1);
00083 }
00084 #else
00085 network_out = neural_net(inputs);
00086 #endif
00087
00088 return network_out;
00089 }
00090