LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiScramble.h

00001 /*
00002  * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  *
00005  * This file is part of the LTI-Computer Vision Library (LTI-Lib)
00006  *
00007  * The LTI-Lib is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License (LGPL)
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * The LTI-Lib is distributed in the hope that it will be
00013  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00014  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with the LTI-Lib; see the file LICENSE.  If
00019  * not, write to the Free Software Foundation, Inc., 59 Temple Place -
00020  * Suite 330, Boston, MA 02111-1307, USA.
00021  */
00022 
00023 
00024 /*----------------------------------------------------------------
00025  * project ....: LTI Digital Image/Signal Processing Library
00026  * file .......: ltiScramble.h
00027  * authors ....: Pablo Alvarado
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 17.8.2000
00030  * revisions ..: $Id: ltiScramble.h,v 1.8 2006/02/08 12:42:36 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_SCRAMBLE_H_
00034 #define _LTI_SCRAMBLE_H_
00035 
00036 #include "ltiVector.h"
00037 #include "ltiMatrix.h"
00038 #include "ltiFunctor.h"
00039 #include "ltiContinuousRandDist.h"
00040 
00041 namespace lti {
00042   /**
00043    * This class is used to scramble the elements of a given vector or
00044    * matrix. To this end two random indices of the vector or matrix
00045    * are chosen and their contents swapped. This operation is
00046    * performed N times, with N the number of elements.
00047    */
00048   template <class T>
00049   class scramble : public functor {
00050   public:
00051     /**
00052      * the parameters for the class scramble (empty)
00053      */
00054     class parameters : public functor::parameters {
00055     public:
00056       /**
00057        * default constructor
00058        */
00059       parameters() 
00060         : functor::parameters() {};
00061 
00062       /**
00063        * copy constructor
00064        * @param other the parameters object to be copied
00065        */
00066       parameters(const parameters& other) 
00067         : functor::parameters() {
00068         copy(other);
00069       };
00070 
00071       /**
00072        * destructor
00073        */
00074       ~parameters() {};
00075 
00076       /**
00077        * returns name of this type
00078        */
00079       const char* getTypeName() const {
00080         return "scramble<T>::parameters";
00081       }
00082 
00083       /**
00084        * copy the contents of a parameters object
00085        * @param other the parameters object to be copied
00086        * @return a reference to this parameters object
00087        */
00088       parameters& copy(const parameters& other) {
00089 #       ifndef _LTI_MSC_6
00090         // MS Visual C++ 6 is not able to compile this...
00091           functor::parameters::copy(other);
00092 #       else
00093         // ...so we have to use this workaround.
00094         // Conditional on that, copy may not be virtual.
00095         functor::parameters& (functor::parameters::* p_copy)
00096           (const functor::parameters&) =
00097           functor::parameters::copy;
00098           (this->*p_copy)(other);
00099 #       endif
00100         return *this;
00101       };
00102 
00103       /**
00104        * returns a pointer to a clone of the parameters
00105        */
00106       virtual functor::parameters* clone() const {
00107         return new parameters(*this);
00108       };
00109     };
00110 
00111     /**
00112      * default constructor
00113      */
00114     scramble();
00115 
00116     /**
00117      * copy constructor
00118      * @param other the object to be copied
00119      */
00120     scramble(const scramble& other);
00121 
00122     /**
00123      * destructor
00124      */
00125     virtual ~scramble();
00126 
00127     /**
00128      * returns the name of this type ("scramble")
00129      */
00130     virtual const char* getTypeName() const;
00131 
00132     /**
00133      * Scramble the elements of \a srcdest.
00134      * @param srcdest matrix<T> with the source data.  The result
00135      *                 will be left here too.
00136      * @return true if operation was successfull
00137      */
00138     bool apply(matrix<T>& srcdest) const;
00139 
00140     /**
00141      * Scramble the elements of \a srcdest.
00142      * @param srcdest vector<T> with the source data.  The result
00143      *                 will be left here too.
00144      * @return true if operation was successfull
00145      */
00146     bool apply(vector<T>& srcdest) const;
00147 
00148     /**
00149      * Makes a scrambled copy from \a src to \a dest.
00150      * @param src matrix<T> with the source data.
00151      * @param dest matrix<T> where the result will be left.
00152      * @return true if operation was successfull
00153      */
00154     bool apply(const matrix<T>& src,matrix<T>& dest) const;
00155 
00156     /**
00157      * Makes a scrambled copy from \a src to \a dest.
00158      * @param src vector<T> with the source data.
00159      * @param dest vector<T> where the result will be left.
00160      * @return a reference to the <code>dest</code>.
00161      */
00162     bool apply(const vector<T>& src,vector<T>& dest) const;
00163 
00164     /**
00165      * copy data of "other" functor.
00166      * @param other the functor to be copied
00167      * @return a reference to this functor object
00168      */
00169     scramble& copy(const scramble& other);
00170 
00171     /**
00172      * returns a pointer to a clone of this functor.
00173      */
00174     virtual functor* clone() const;
00175 
00176     /**
00177      * returns used parameters
00178      */
00179     const parameters& getParameters() const;
00180 
00181   protected:
00182     
00183     continuousRandomDistribution randomizer;
00184 
00185   };
00186 
00187 }
00188 #include "ltiScramble_template.h"
00189 
00190 #endif

Generated on Sat Apr 10 15:26:08 2010 for LTI-Lib by Doxygen 1.6.1