BPFTmplDec.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 
00023 #ifndef _BPFTmplDec_
00024 #define _BPFTmplDec_
00025 
00026 #include <iosfwd>
00027 
00028 #include "PointTmpl.hxx" // for point functionality
00029 #include "Err.hxx"//for Exception handling
00030 #include "Array.hxx" // array functionality
00031 #include "SearchArray.hxx" //array searches
00032 #include "Enum.hxx"
00033 #include "Component.hxx"
00034 #include "GlobalEnums.hxx"
00035 
00036 namespace CLAM
00037 {
00038         class EInterpolation;
00039 
00040         template <class TX,class TY> class BPFTmpl:public Component
00041         {
00042                 static const TData Infinity;
00043 
00044         public:
00048                 BPFTmpl();
00049 
00054                 BPFTmpl(const EInterpolation& eInterpolation);
00055 
00063                 BPFTmpl(TSize size);
00064 
00065                 BPFTmpl(TSize size,
00066                         const EInterpolation& eInterpolation);
00067 
00072                 BPFTmpl(const BPFTmpl<TX,TY>& orig);
00073 
00078                 void Init();
00079 
00083                 const char * GetClassName() const {return "BPF";}
00084 
00090                 TSize AllocatedSize(void) const {return mArray.AllocatedSize();}
00091 
00098                 TSize Size(void) const {return mArray.Size();}
00099 
00107                 void SetSize (TSize newSize){mArray.SetSize(newSize);}
00108 
00116                 void Resize (TSize newSize){mArray.Resize(newSize);}
00117 
00124                 TIndex Insert(const PointTmpl<TX,TY> &point);
00125 
00134                 TIndex Insert(const TX &x,const TX &y);
00135 
00140                 void DeleteIndex(TIndex index);
00141 
00146                 void DeleteThroughXValue(const TX& x);
00147 
00153                 void DeleteBetweenIndex(TIndex leftIndex,TIndex rightIndex);
00154         
00160                 void DeleteBetweenXValues(const TX& leftX,const TX& rightX);
00161 
00167                 void SetValue(TIndex index,const TY &y)
00168                 {
00169                         mArray[index].SetY(y);
00170                         mIsSplineUpdated=false;
00171                 }
00172 
00173                 void SetXValue(TIndex index,const TX &x){
00174                         mArray[index].SetX(x);
00175                         mIsSplineUpdated=false;
00176                 }
00177 
00183                 void SetIntpType(const EInterpolation& eInterpolation);
00184                 
00190                 void SetStep(TSize step){mArray.SetStep(step);}
00196                 TSize GetStep() {return mArray.GetStep();}
00197 
00203                 TY GetValueFromIndex(TIndex index) const {
00204                         return mArray[index].GetY();
00205                 }
00206 
00214                 TY GetValue(const TX& x)        const {
00215                         return GetValue(x,meInterpolation);
00216                 }
00217 
00225                 TY GetValue (const TX& x,const EInterpolation& eInterpolation) const;
00226 
00232                 const TX& GetXValue(TIndex index) const 
00233                 {
00234                         return mArray[index].GetX();
00235                 }
00236 
00242                 TIndex GetPosition(const TX& x) const;
00243 
00244 
00254                 void GetnClosest(TIndex foundIndex) const;
00255 
00259                 BPFTmpl<TX, TY>& operator=(const BPFTmpl<TX, TY> &originalBPF);
00260 
00264                 void UpdateSplineTable();
00265 
00269                 void SetLeftDerivative(TData val);
00270                 void UnsetLeftDerivative(void);
00271                 void SetRightDerivative(TData val);
00272                 void UnsetRightDerivative(void);
00273         
00277                 const EInterpolation    &GetInterpolation() const {
00278                         return meInterpolation; 
00279                 }
00280 
00284                 Array<PointTmpl<TX,TY> > &GetPointArray() {
00285                         return mArray;
00286                 }
00287                 
00288 protected:
00289         /*Member variables*/
00294                 EInterpolation meInterpolation;
00298                 TSize mnPoints;
00303                 Array<PointTmpl<TX,TY> > mArray;
00308                 SearchArray<PointTmpl<TX,TY> > mSearch;//search functionality for array
00313                 mutable Array<TIndex> mClosestPoints;
00318                 mutable Array<TY> mc,md;
00323                 int mOrder; //interpolation order for polynomic interp.
00328                 mutable TIndex mLastIndex; 
00333                 mutable TX mLastX; 
00334 
00339                 Array<TY> mSplineTable;
00344                 bool mIsSplineUpdated;
00345 
00353                 TData mLeftDerivative;
00354 
00362                 TData mRightDerivative;
00363                 
00368         TY BPFPolInt(const TX& x,const Array<TIndex>& closestPointsIndex,
00369                 TData &errorEstimate) const;
00370         void CreateSplineTable();
00371         TY BPFSplineInt(const TX& x) const;
00372         void StoreOn(Storage & storage) const;
00373         void LoadFrom(Storage & storage);
00374 
00375         };
00376 
00377 } // namespace CLAM
00378 
00379 #endif // _BPFTmplDec_
00380 
Generated by  doxygen 1.6.3