#ifndef __FEEDFORWARDNN_H
#define __FEEDFORWARDNN_H

#include <matrix.h>
#include "configurable.h"
#include <math.h>

typedef double (*ActivationFunction) (double);

/// abstract class (interface) for feed forward rate based neural networks
class FeedForwardNN : public Configurable {
 public: 
  FeedForwardNN(){};
  virtual ~FeedForwardNN(){};

  /// initialisation of the network with the given number of input and output units
  virtual void init(unsigned int inputDim, unsigned  int outputDim) = 0;
  /// passive processing of the input
  virtual const matrix::Matrix process (const matrix::Matrix& input) const = 0;
  /* performs learning and returns the network output before learning
     learnRateFactor can be given to modify eps for this learning step
  */
  virtual const matrix::Matrix learn (const matrix::Matrix& input, 
				      const matrix::Matrix& nom_output, 
				      double learnRateFactor = 1) = 0;

  /// damps the weights and the biases by multiplying (1-damping)
  virtual void damp(double damping) =0 ;

  /// returns the number of input neurons
  virtual unsigned int getInputDim() const = 0;
  /// returns the number of output neurons
  virtual unsigned int getOutputDim() const = 0;

  static double linear(double x)   { return x;}
  static double dlinear(double )   { return 1;}
  static double tanh(double x)     { return ::tanh(x); } 
  static double dtanh(double x)    { double k = ::tanh(x); return 1.01-k*k; } 
  static double sigmoid(double x)  { return 1/(1+exp(-x)); } 
  static double dsigmoid(double x) { double k = sigmoid(x); return k*(1-k); } 

};


#endif
