last update 20 Sep 2009 |
00001 /* 00002 * Copyright (C) 1998-2004 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * 00006 * This file is part of the Computer Vision and Robotics Library (CVR-Lib) 00007 * 00008 * The CVR-Lib is free software; you can redistribute it and/or 00009 * modify it under the terms of the BSD License. 00010 * 00011 * All rights reserved. 00012 * 00013 * Redistribution and use in source and binary forms, with or without 00014 * modification, are permitted provided that the following conditions are met: 00015 * 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 00023 * 3. Neither the name of the authors nor the names of its contributors may be 00024 * used to endorse or promote products derived from this software without 00025 * specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00028 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00029 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00030 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00031 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00032 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00033 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00034 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00035 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00036 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00037 * POSSIBILITY OF SUCH DAMAGE. 00038 */ 00039 00040 00041 00042 /** 00043 * \file cvrLapackInterface.h 00044 * Definition of interface for LAPACK based functors 00045 * \author Jochen Wickel 00046 * \date 13.11.2002 00047 * 00048 * $Id: cvrLapackInterface.h,v 1.2 2004/07/25 18:29:12 alvarado Exp $ 00049 */ 00050 00051 #ifndef _CVR_LAPACK_INTERFACE_H_ 00052 #define _CVR_LAPACK_INTERFACE_H_ 00053 00054 #include "cvrConfig.h" 00055 00056 #ifdef HAVE_LAPACK 00057 00058 #include "cvrException.h" 00059 #include "cvrMutex.h" 00060 00061 namespace cvr { 00062 00063 /** 00064 * @defgroup lapack LAPack based functors 00065 * This group contains all classes and functors that use 00066 * functions from the Linear Algebra Package (LAPack) library. 00067 * See cvr::lapackInterface for more information. 00068 * 00069 * @ingroup gMath 00070 */ 00071 00072 /** 00073 * Interface object for LAPACK functions. This class contains 00074 * locking methods for LAPACK. 00075 * If you implement an interface class for a LAPACK method, you 00076 * should inherit from this class. As an example for such a 00077 * method, see the cvr::generalEigenVectors class. 00078 * 00079 * When implementing an interface, you obviously need the prototype 00080 * of the LAPACK method. There are two methods for this: 00081 * - download clapack.h from http://www.netlib.org/clapack/clapack.h 00082 * and simply include it. But: Do not rely on anyone 00083 * - copy and paste the required prototype into your source code. 00084 * 00085 * @ingroup lapack 00086 * 00087 * @see \ref lapack 00088 */ 00089 class lapackInterface { 00090 public: 00091 /** 00092 * returns the name of this type 00093 */ 00094 virtual const std::string& name() const { 00095 static const std::string theName = "cvr::lapackInterface"; 00096 return theName; 00097 }; 00098 00099 protected: 00100 /** 00101 * Default constructor 00102 */ 00103 lapackInterface(); 00104 00105 /** 00106 * Destructor 00107 */ 00108 virtual ~lapackInterface(); 00109 00110 /** 00111 * Lock the LAPack interface 00112 * 00113 * Unfortunately, LAPACK is not thread-safe. Therefore we must 00114 * use a mutex to protect threads from concurrent execution. 00115 */ 00116 inline void lockInterface() const { 00117 lola_->lock(); 00118 } 00119 00120 /** 00121 * Unlock the LAPack interface 00122 * 00123 * Unfortunately, LAPACK is not thread-safe. Therefore we must 00124 * use a mutex to protect threads from concurrent execution. 00125 */ 00126 inline void unlockInterface() const { 00127 lola_->unlock(); 00128 }; 00129 00130 private: 00131 /** 00132 * the mutex used to protect the interface. 00133 */ 00134 static mutex* lola_; 00135 }; 00136 00137 } 00138 00139 #endif 00140 00141 #endif