CVR-Lib last update 20 Sep 2009

cvrQrSolution.h

Go to the documentation of this file.
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   cvrQrSolution.h
00043  * \author Thomas Rusert
00044  * \date   02.06.1999
00045  *
00046  * $Id: cvrQrSolution.h,v 1.1 2005/04/21 13:11:20 gquiros Exp $
00047  */
00048 
00049 #ifndef _CVR_QR_SOLUTION_H_
00050 #define _CVR_QR_SOLUTION_H_
00051 
00052 #include "cvrDecompositionSolution.h"
00053 
00054 namespace cvr {
00055 
00056   /**
00057    * QR solution functor.
00058    *
00059    * Solves the linear equation Ax=b as a least-squares problem using QR
00060    * decomposition A=QR  (Householder transformation) of the given
00061    * (m,n)-matrix A.
00062    *
00063    * @see decompositionSolution::parameters
00064    * @ingroup gCVR-Lib FormatRequired
00065    */
00066   template<class T>
00067   class qrSolution : public decompositionSolution<T> {
00068   public:
00069     /**
00070      * qrSolution parameter class
00071      */
00072     class parameters : public decompositionSolution<T>::parameters {
00073     public:
00074       /**
00075        * default constructor
00076        */
00077       parameters();
00078 
00079       /**
00080        * copy constructor
00081        */
00082       parameters(const parameters& other);
00083 
00084       /**
00085        * copy member.
00086        */
00087       parameters& copy(const parameters& other);
00088 
00089       /**
00090        * Returns the name of this class.
00091        */
00092       const std::string& name() const;
00093 
00094       /**
00095        * returns a pointer to a clone of the parameters.
00096        */
00097       virtual parameters* clone() const;
00098 
00099       /**
00100        * Returns a pointer to a new instance of the parameters.
00101        */
00102       virtual parameters* newInstance() const;
00103 
00104       // the parameters
00105 
00106       /**
00107        * compute residuum?
00108        */
00109       bool computeResiduum;
00110     };
00111 
00112     /**
00113      * default constructor
00114      */
00115     qrSolution();
00116 
00117     /**
00118      * copy constructor
00119      */
00120     qrSolution(const qrSolution& other);
00121 
00122     /**
00123      * constructor, sets the parameters
00124      */
00125     qrSolution(const parameters& theParams);
00126 
00127     /**
00128      * constructor, sets the matrix A
00129      */
00130     qrSolution(const matrix<T>& theMatrix);
00131 
00132     /**
00133      * returns the current parameters.
00134      */
00135     const parameters& getParameters() const;
00136 
00137     /** Apply on place.
00138      *
00139      *  Solves the least-squares problem Ax=b and returns the residuum if
00140      *  computeResiduum==true.
00141      *
00142      *  WARNING: For use with multiple right sides b of a set of
00143      *  equation systems Ax=b, the matrix decomposition is computed
00144      *  only on calling <em>apply()</em> the first time. After that
00145      *  the existing decomposition will be used until calling
00146      *  <em>setParameters()</em>.
00147      */
00148     double apply(vector<T>& b);
00149 
00150     /** Apply on copy.
00151      *
00152      *  Solves the least-squares problem Ax=b and returns the residuum if
00153      *  computeResiduum==true.
00154      *
00155      *  WARNING: For use with multiple right sides b of a set of
00156      *  equation systems Ax=b, the matrix decomposition is computed
00157      *  only on calling <em>apply()</em> the first time. After that
00158      *  the existing decomposition will be used until calling
00159      *  <em>setParameters()</em>.
00160      */
00161     double apply(const vector<T>& b,vector<T>& x);
00162 
00163     /**
00164      * Copy data of "other" functor.
00165      */
00166     qrSolution& copy(const qrSolution& other);
00167 
00168     /**
00169      * Returns the name of this class.
00170      */
00171     const std::string& name() const;
00172 
00173     /**
00174      * Returns a pointer to a clone of this functor.
00175      */
00176     virtual qrSolution* clone() const;
00177 
00178     /**
00179      * Returns a pointer to a new instance of this functor.
00180      */
00181     virtual qrSolution* newInstance() const;
00182 
00183   protected:
00184     /**
00185      * Decomposed vector
00186      */
00187     vector<double> dcmpVec_;
00188     /**
00189      * Helper vector
00190      */
00191     vector<double> helpVec_;
00192   };
00193 
00194 }
00195 
00196 #endif

Generated on Sun Sep 20 22:08:00 2009 for CVR-Lib by Doxygen 1.5.8