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

ltiLapackInterface.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 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 .......: ltiLapackInterface.h
00027  * authors ....: Jochen Wickel
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 13.11.2002
00030  * revisions ..: $Id: ltiLapackInterface.h,v 1.4 2006/09/11 17:04:26 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_LAPACK_INTERFACE_H_
00034 #define _LTI_LAPACK_INTERFACE_H_
00035 
00036 #include "ltiConfig.h"
00037 
00038 #ifdef HAVE_LAPACK
00039 
00040 #include "ltiException.h"
00041 #include "ltiMutex.h"
00042 
00043 /**
00044  * \file ltiLapackInterface.h Definition of Interface for LAPack based functors
00045  */
00046 
00047 namespace lti {
00048 
00049   /**
00050    * Type of the interger type used in f2c.h. Use this type for all integer
00051    * types connected with LAPACK except error codes.
00052    */
00053   typedef _LTI_F2C_INTEGER integer;
00054 
00055   /**
00056    * @defgroup lapack LAPack based functors
00057    * This group contains all classes and functors that use
00058    * functions from the Linear Algebra Package (LAPack) library.
00059    * See lti::lapackInterface for more information.
00060    *
00061    * @ingroup gMath
00062    */
00063 
00064   /**
00065    * Interface object for LAPACK functions. This class contains
00066    * locking methods for LAPACK.
00067    * If you implement an interface class for a LAPACK method, you
00068    * should inherit from this class. As an example for such a
00069    * method, see the lti::generalEigenVectors class.
00070    *
00071    * When implementing an interface, you obviously need the prototype
00072    * of the LAPACK method. There are two methods for this:
00073    * - download clapack.h from http://www.netlib.org/clapack/clapack.h
00074    *   and simply include it. But: Do not rely on anyone
00075    * - copy and paste the required prototype into your source code.
00076    *
00077    * @ingroup lapack
00078    *
00079    * @see \ref lapack
00080    */
00081   class lapackInterface {
00082   public:
00083 
00084     /**
00085      * Exception class denoting an illegal matrix format (non-connected)
00086      * All matrices used by LAPACK routines must be connected. If
00087      * a matrix is not, the method throws this exception.
00088      */
00089     class matrixNotConnected: public lti::exception {
00090     public:
00091       /**
00092        * Default constructor
00093        */
00094       matrixNotConnected()
00095         : exception("LAPack methods not available fornon-connected matrices") {
00096       };
00097 
00098       /**
00099        * Return the name of this class
00100        */
00101       virtual const char* getTypeName() const {
00102         return "lapackInterface::matrixNotConnected";
00103       };
00104     };
00105 
00106     /**
00107      * returns the name of this type
00108      */
00109     virtual const char* getTypeName() const {
00110       return "lapackInterface";
00111     };
00112 
00113   protected:
00114     /**
00115      * Default constructor
00116      */
00117     lapackInterface();
00118 
00119     /**
00120      * Destructor
00121      */
00122     virtual ~lapackInterface();
00123 
00124     /**
00125      * Lock the LAPack interface
00126      *
00127      * Unfortunately, LAPACK is not thread-safe. Therefore we must
00128      * use a mutex to protect threads from concurrent execution.
00129      */
00130     inline void lockInterface() const {
00131       lola.lock();
00132     }
00133 
00134     /**
00135      * Unlock the LAPack interface
00136      *
00137      * Unfortunately, LAPACK is not thread-safe. Therefore we must
00138      * use a mutex to protect threads from concurrent execution.
00139      */
00140     inline void unlockInterface() const {
00141       lola.unlock();
00142     };
00143 
00144   private:
00145     /**
00146      * the mutex used to protect the interface.
00147      */
00148      static mutex lola;
00149   };
00150 
00151 }
00152 
00153 #endif
00154 
00155 #endif

Generated on Sat Apr 10 15:25:43 2010 for LTI-Lib by Doxygen 1.6.1