include/libperiodicfunctions.h

Go to the documentation of this file.
00001 /********************************************************************************
00002  *  Neural Network Framework.                                                   *
00003  *  Copyright (C) 2005-2008 Gianluca Massera <emmegian@yahoo.it>                *
00004  *                                                                              *
00005  *  This program is free software; you can redistribute it and/or modify        *
00006  *  it under the terms of the GNU General Public License as published by        *
00007  *  the Free Software Foundation; either version 2 of the License, or           *
00008  *  (at your option) any later version.                                         *
00009  *                                                                              *
00010  *  This program is distributed in the hope that it will be useful,             *
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
00013  *  GNU General Public License for more details.                                *
00014  *                                                                              *
00015  *  You should have received a copy of the GNU General Public License           *
00016  *  along with this program; if not, write to the Free Software                 *
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  *
00018  ********************************************************************************/
00019 
00020 #ifndef LIBPERIODICFUNCTIONS_H
00021 #define LIBPERIODICFUNCTIONS_H
00022 
00023 #include "types.h"
00024 
00030 #include "outputfunction.h"
00031 
00032 namespace nnfw {
00033 
00045 class NNFW_API PeriodicFunction : public OutputFunction {
00046 public:
00049     
00051     PeriodicFunction( Real phase = 0.0, Real span = 1.0, Real amplitude = 1.0 );
00052     
00054     PeriodicFunction( PropertySettings& prop );
00055     
00057     virtual ~PeriodicFunction() { /* Nothing to do */ };
00058     
00060 
00062     
00064     bool setPhase( const Variant& v );
00066     Variant phase();
00067     
00069     bool setSpan( const Variant& v );
00071     Variant span();
00072     
00074     bool setAmplitude( const Variant& v );
00076     Variant amplitude();
00077     
00079     virtual void apply( RealVec& inputs, RealVec& outputs ) = 0;
00080 
00082     virtual PeriodicFunction* clone() const = 0;
00083     
00085 
00086 protected:
00087     Real phasev;
00088     Real spanv;
00089     Real amplitudev;
00090 };
00091 
00103 class NNFW_API SawtoothFunction : public PeriodicFunction {
00104 public:
00107     
00109     SawtoothFunction( Real phase = 0.0, Real span = 1.0, Real amplitude = 1.0 );
00110     
00112     SawtoothFunction( PropertySettings& prop );
00113     
00115     virtual ~SawtoothFunction() { /* Nothing to do */ };
00116     
00118 
00120     
00122     virtual void apply( RealVec& inputs, RealVec& outputs );
00123 
00125     virtual SawtoothFunction* clone() const;
00126     
00128 };
00129 
00141 class NNFW_API TriangleFunction : public PeriodicFunction {
00142 public:
00145     
00147     TriangleFunction( Real phase = 0.0, Real span = 1.0, Real amplitude = 1.0 );
00148     
00150     TriangleFunction( PropertySettings& prop );
00151     
00153     virtual ~TriangleFunction() { /* Nothing to do */ };
00154     
00156 
00158     
00160     virtual void apply( RealVec& inputs, RealVec& outputs );
00161 
00163     virtual TriangleFunction* clone() const;
00164     
00166 
00167 };
00168 
00180 class NNFW_API SinFunction : public PeriodicFunction {
00181 public:
00184     
00186     SinFunction( Real phase = 0.0, Real span = 1.0, Real amplitude = 1.0 );
00187 
00189     SinFunction( PropertySettings& prop );
00190     
00192     virtual ~SinFunction() { /* Nothing to do */ };
00193     
00195 
00197 
00201     Real frequency();
00202     
00204     virtual void apply( RealVec& inputs, RealVec& outputs );
00205 
00207     virtual SinFunction* clone() const;
00208     
00210 };
00211 
00223 class NNFW_API PseudoGaussFunction : public PeriodicFunction {
00224 public:
00227     
00229     PseudoGaussFunction( Real phase = 0.0, Real span = 1.0, Real amplitude = 1.0 );
00230     
00232     PseudoGaussFunction( PropertySettings& prop );
00233     
00235     virtual ~PseudoGaussFunction() { /* Nothing to do */ };
00236     
00238 
00240     
00242     virtual void apply( RealVec& inputs, RealVec& outputs );
00243 
00245     virtual PseudoGaussFunction* clone() const;
00246     
00248 
00249 };
00250 
00251 }
00252 
00253 #endif
00254 
BerliOS Developer Logo Valid XHTML 1.0 Transitional Valid CSS!