📄 nrlnet.hpp
字号:
//Header: NrlNet.hpp
//Language: Borland C++ 3.1
//Version: 1.0
//Environ: Any
//Author: LiuKang
//Date: 3/1996
//Purpose: Provide a base class for neural network
#ifndef __NRLNET__HPP
#define __NRLNET__HPP
#include "matrix.hpp"
#include "nrlnode.hpp"
#include "dblarr.hpp"
enum NtErrType { NT_NOERR =0, //no error mode
NT_MEM =1, //memery allocation failure
NT_FILEERR =2, //file operation failure
NT_INITERR =4, //network initialization failure
NT_FAIL =8 }; //network run failure
typedef int LoadType;
#define OLD 0
#define INITIAL 1
static char *ErrMsg[]={ "",
"\nClass NrlNet: memory allocation failure!",
"\nClass NrlNet: file operation error!",
"\nClass NrlNet: network initialization error!" };
class NrlNet
{
protected:
NrlNode *Node; //array of net's nodes
int NodeNum; //node number of all network
char NetType[30]; //network type
Matrix *Weight; //matrix pointer of network's weight
Matrix *Conect; //matrix pointer of network's connecting
int DataWitch; //weight and threshold data witch
int DataPrec; //weight and threshold data precision
LoadType LdType; //flag of load type
char NtName[10]; //name of the network
int ErrStatus; //error status of network
void WtFlLoad(); //function of weight load from file
void WtFlWrite(); //function of weight write to file
void ThdFlLoad(); //function of threshold load form file
void ThdFlWrite(); //function of threshold write to file
void WtInitial(); //function of weight initial method
void ThdInitial(); //function of threshold initial method
void (*ErrHandler)(NtErrType);//function pointer of error handler
void Init(int); //initial of network
public:
//constructors
NrlNet(void);
NrlNet(int n,char *nn=NULL);
//destructor
~NrlNet(void);
//other methods
const char* IsA(){ return NetType; };
void SetLdType(LoadType lt) { LdType=lt; };
void SetNtName(char *nn);
void SetNdFun(double (*)(double)); //set all node function
void SetErrHandler(void (*uh)(NtErrType)) { ErrHandler=uh; };
//set user's error handler
void SetW(int w){ DataWitch=w;}; //set data witch
void SetP(int p){ DataPrec=p;}; //set data precision
void ErrSet(NtErrType); //error handle function
void ErrClear(){ ErrStatus=NT_NOERR; }; //clear error flag
int GetErr(){ return ErrStatus; }; //get error status
int GetNodeNum(){ return NodeNum; }; //get node number of network
};
void DefaultErr(NtErrType);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -