/****************************************************************************
 * This file was derived from the CNCL library by the Pablo research group.
 *
 * The complete CNCL library is available at:
 *       http://www.comnets.rwth-aachen.de/doc/cncl.html
 *
 * The CNCL copyright notice is included here:
 *
 * |_|_|_  |_|_    |_    |_|_|_  |_               C O M M U N I C A T I O N
 *|_       |_  |_  |_  |_        |_                         N E T W O R K S
 *|_       |_  |_  |_  |_        |_                               C L A S S
 * |_|_|_  |_    |_|_    |_|_|_  |_|_|_|_                     L I B R A R Y
 *
 *
 *
 * Copyright (C) 1992-1998   Communication Networks
 *                           Aachen University of Technology
 *                           D-52056 Aachen
 *                           Germany
 *                           Email: cncl-adm@comnets.rwth-aachen.de
 *
 *
 * This library is free  software; you can  redistribute it and/or modify
 * it  under   the terms  of the GNU   Library  General Public License as
 * published by the  Free Software Foundation;  either  version 2 of  the
 * License, or  (at  your option)  any  later  version.  This  library is
 * distributed  in the  hope  that  it  will  be useful,  but WITHOUT ANY
 * WARRANTY;  without even the   implied  warranty of MERCHANTABILITY  or
 * FITNESS FOR A PARTICULAR PURPOSE.   See the GNU Library General Public
 * Library General Public License along with  this library; if not, write
 * to the Free Software Foundation,  675  Mass Ave, Cambridge, MA  02139,
 * USA.
 ****************************************************************************/

//   -*- C++ -*-
/*****************************************************************************
 *
 * Class: FlFSetLR --- Fuzzy set with L and R functions
 *
 *****************************************************************************/

#ifndef __FlFSetLR_h
#define __FlFSetLR_h


#include <FlFSet.h>		// Base class

/*
 * Functions
 */
double FlFuncExp (double x);		// exp(-x)
double FlFuncExp2(double x);		// exp(-x^2)
double FlFuncLin (double x);		// 1-x
double FlFuncSqr (double x);		// 1-x^2
double FlFuncHyp (double x);		// 1/(1+x)
double FlFuncHyp2(double x);		// 1/(1+x^2)

typedef double (*FlFuncType)(double x);	// Function pointer



/*
 * The class FlFSetLR
 */

class FlFSetLR : public FlFSet
{
  public:
					// Get membership values for x
    virtual double get_membership(double x) const;
    virtual double highestPoint(double &x, double &y) const;

    double get_m1()    const { return m1;    }
    double get_m2()    const { return m2;    }
    double get_alpha() const { return alpha; }
    double get_beta()  const { return beta;  }

  protected:
    double m1, m2, alpha, beta;		// Parameters
    FlFuncType L, R;			// L, R functions

    /***** Constructors ******************************************************/
  public:
    FlFSetLR();				// Default constructor
    FlFSetLR(double min, double max, 
	     double xm1, double xm2, double xalpha, double xbeta,
	     FlFuncType fL, FlFuncType fR                            );
    FlFSetLR(double xm1, double xm2, double xalpha, double xbeta,
	     FlFuncType fL, FlFuncType fR                            );
    FlFSetLR(FlStringR xname, double min, double max, 
	     double xm1, double xm2, double xalpha, double xbeta,
	     FlFuncType fL, FlFuncType fR                            );
    FlFSetLR(FlStringR xname,
	     double xm1, double xm2, double xalpha, double xbeta,
	     FlFuncType fL, FlFuncType fR                            );

    void init(FlStringR xname,
	      double xm1, double xm2, double xalpha, double xbeta,
	      FlFuncType fL, FlFuncType fR,
	      double min=FSET_MIN, double max=FSET_MAX );

  public:
    // Print/debug output
    virtual void print(ostream &strm = cout) const;
    virtual void dump (ostream &strm = cout) const;

    void update(double xm1, double xm2, double xalpha, double xbeta);
};


#endif /**__FlFSetLR_h**/
