/* *************************************************************

        Final Project                                 MMU 1996

        ######################################################
        #                                                    #
        #               A Modular Neural Network             #   
        #                                                    #
        #          A Class for the Support Functions         #   
        #                                                    #
        ######################################################

        Albrecht Schmidt                              17.09.96

        FILE: CSupport.h                           Version 1.0

   ************************************************************* */

#ifndef _CSupport_h
#define _CSupport_h

#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include "global.h"

#define TRUE 1


class CSupport{
public:
        // make a random mapping from inVect -> randVect with start
        // value rndStart for Random generator
	double *CSupport::randVector(double *randVect , double *inVect, 
                                     int len, int rndStart);
        // make a mapping from inVect -> randVect using the array mix
	double *CSupport::randVector(double *randVect , double *inVect, 
                             int len, int* mix);
        // enlarge the vector inVect with len inLen to a vector exVect
        // with len exLen, fill the enlarge componets with fillVal
	double *CSupport::extentVector(double *exVect, int exLen, 
                                       double *inVect, int inLen,
                                       double fillVal = 0);
 	// random value in [0,1]
	double CSupport::frand();
	// return the winner number of a vector
	int CSupport::WinnerNo(TVector inV, int len, float diff = 0.01);
	// Write a Vector in a File
	void CSupport::WriteVector(TVector vect, int no_elements, FILE* fh);
	// Write a int Vector in a File
	void CSupport::WriteIntVector(TVector vect, int no_elements, FILE* fh) ;
	// Read a Vector from the File
	TVector CSupport::ReadVector(TVector valueV, int no_elements, FILE* fh);
	// Read a Vector from the File and return 0 for ok, -1 for not ok
	int CSupport::ReadVecCheck(TVector valueV, int no_elements, FILE* fh);
	// make a permutation of the given Vector
	int * CSupport::Mix(int * p, int len,int  change);
	// prints a error message
	void CSupport::FileWarning(char * filename = "");
	// write a vector to file (only 3 digits)
	void CSupport::fPrintV(FILE *fd, TVector v, int len, char* t) ;
	// print a Vector on the screen
	void CSupport::PrintV(TVector v, int len, char* t);
	// initialize the random number generator with the time
	void CSupport::Randomize();
	// generate a random vector
	TVector CSupport::RandomV(TVector returnVector, int no, 
                                  double min, double max);
	// reads the Systemtime and returns a String 
	char *CSupport::Read_SysTime();
	// convert an interger into a binary vector
	TVector CSupport::Int2BinVector(TVector resV, int theInt, int len);
	// convert an interger into a 1-out-of-len coding  vector
	// length for the return vector == max number used
	TVector CSupport::Int2BitVector(TVector resV, int theInt, int len);
	// calculate 2 to the power of i
	int CSupport::pow_2(int i);

};

#endif
