last update 20 Sep 2009 |
00001 /* 00002 * Copyright (C) 1998 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 * \file cvrDecompositionSolution.h 00043 * \author Thomas Rusert 00044 * \date 02.06.1999 00045 * 00046 * $Id: cvrDecompositionSolution.h,v 1.1 2005/04/21 13:11:20 gquiros Exp $ 00047 */ 00048 00049 #ifndef _CVR_DECOMPOSITION_SOLUTION_H_ 00050 #define _CVR_DECOMPOSITION_SOLUTION_H_ 00051 00052 #include "cvrLinearAlgebraFunctor.h" 00053 #include "cvrMatrix.h" 00054 00055 namespace cvr { 00056 00057 /** 00058 * Abstract base class for all lti linear equation system solution functors 00059 * using matrix decomposition to solve Ax=b. 00060 * 00061 * Methods to give the matrix A are provided. 00062 * 00063 * @ingroup gCVR-Lib FormatRequired 00064 */ 00065 template<class T> 00066 class decompositionSolution : public linearAlgebraFunctor { 00067 00068 public: 00069 /** 00070 * Parameters of class decompositionSolution 00071 */ 00072 class parameters : public linearAlgebraFunctor::parameters { 00073 00074 public: 00075 /** 00076 * Default constructor 00077 */ 00078 parameters(); 00079 00080 /** 00081 * Copy constructor 00082 */ 00083 parameters(const parameters& other); 00084 00085 /** 00086 * Copy member. 00087 * 00088 * if the system-matrix of the other object is a normal matrix, 00089 * its contents will be copied to the system-matrix of this 00090 * parameters-object. If the other system-matrix contains just 00091 * a reference to external data, then the system-matrix of this 00092 * object will contain the same reference to the data! The 00093 * reason for this is to allow the use of this functor with huge 00094 * matrices without the need of duplication. Use this data 00095 * referencing option carefully! 00096 */ 00097 parameters& copy(const parameters& other); 00098 00099 /** 00100 * Returns the name of this class. 00101 */ 00102 const std::string& name() const; 00103 00104 /** 00105 * Returns a pointer to a clone of the parameters. 00106 */ 00107 virtual parameters* clone() const; 00108 00109 /** 00110 * Returns a pointer to a new instance of the parameters. 00111 */ 00112 virtual parameters* newInstance() const; 00113 00114 // ------------------------------------------------------- 00115 // the parameters 00116 // ------------------------------------------------------- 00117 }; 00118 00119 /** 00120 * Default constructor 00121 */ 00122 decompositionSolution(); 00123 00124 /** 00125 * Constructor, sets the matrix A 00126 */ 00127 decompositionSolution(const matrix<T>& theMatrix); 00128 00129 /** 00130 * Destructor 00131 */ 00132 virtual ~decompositionSolution(); 00133 00134 /** 00135 * Returns the current parameters. 00136 */ 00137 const parameters& getParameters() const; 00138 00139 /** 00140 * Copy data of "other" functor. 00141 */ 00142 decompositionSolution<T>& copy(const decompositionSolution<T>& other); 00143 00144 /** 00145 * Returns the name of this class. 00146 */ 00147 const std::string& name() const; 00148 00149 /** 00150 * Use the given matrix as is. 00151 * 00152 * This matrix will not be copied and you have to ensure that the given 00153 * instance exists as long as this functor uses it. 00154 */ 00155 virtual bool use(matrix<T>& A); 00156 00157 /** 00158 * Use the given matrix and take care of its memory management. 00159 * 00160 * The given matrix will be empty after calling this method. 00161 */ 00162 virtual bool attach(matrix<T>& A); 00163 00164 /** 00165 * Copy the given matrix for internal use. 00166 */ 00167 virtual bool set(const matrix<T>& A); 00168 00169 00170 protected: 00171 /** 00172 * Matrix A. 00173 * 00174 * The linear system to be solved is Ax=b. 00175 * 00176 * Default value: empty matrix. 00177 */ 00178 matrix<T> systemMatrix_; 00179 00180 /** 00181 * Flag to indicate if the system matrix has been decomposed. 00182 */ 00183 bool decomposed_; 00184 00185 /** 00186 * Decomposed matrix. 00187 */ 00188 matrix<T> dcmpMat_; 00189 }; 00190 00191 } 00192 00193 #endif