CVR-Lib last update 20 Sep 2009

cvrMathLA.h

Go to the documentation of this file.
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   cvrMathLA.h
00044  *         Definition of some useful global functions which are often needed
00045  *         in Linear Algebra Algorithms. These include:
00046  *         - householder: calculates householder vector and beta
00047  *         - givens: calculates cos and sin values for Givens rotations
00048  * \author Peter Doerfler
00049  * \date   27.04.2004
00050  *
00051  * $Id: cvrMathLA.h,v 1.4 2005/01/21 17:05:36 alvarado Exp $
00052  */
00053 
00054 #ifndef _CVR_MATH_LA_H_
00055 #define _CVR_MATH_LA_H_
00056 
00057 #include "cvrVector.h"
00058 
00059 
00060 namespace cvr {
00061 
00062   /**
00063    * Calculates the Householder vector \c v and the factor \c beta for
00064    * a %vector \c x (given as input in \c v).
00065    *
00066    * The resulting n-dimensional %vector \c v has the following properties:
00067    * - v[0] = 1,
00068    * - \f$ P = I_n - \beta v v^T\f$ is orthogonal, and
00069    * - /f$ Px=||x||_2e_1
00070    * , where I_n is the n-by-n identity matrix and e_1 the first
00071    * canonical vector.
00072    *
00073    * For more details see:<br>
00074    * Gene H. Golub and Charles F. Van Loan, "Matrix Computations",
00075    * 1996, The John Hopkins University Press, Baltimore and London
00076    *
00077    * @param v input: vector \c x; output: householder vector \c v
00078    * @param beta factor needed for householder transform
00079    *
00080    * @ingroup gUnassigned
00081    */
00082   template<typename T>
00083   inline void householder(vector<T>& v, T& beta);
00084 
00085   /**
00086    * Calculates the Householder vector \c v and the factor \c beta for
00087    * a %vector \c src.
00088    *
00089    * The resulting n-dimensional %vector \c v has the following properties:
00090    * - v[0] = 1,
00091    * - \f$ P = I_n - \beta v v^T\f$ is orthogonal, and
00092    * - /f$ Px=||x||_2e_1
00093    * , where I_n is the n-by-n identity matrix and e_1 the first
00094    * canonical vector.
00095    *
00096    * \b Note: The on-place version of householder(vector<T>&, T&) is
00097    * faster since the input vector is not copied first.
00098    *
00099    * For more details see:<br>
00100    * Gene H. Golub and Charles F. Van Loan, "Matrix Computations",
00101    * 1996, The John Hopkins University Press, Baltimore and London
00102    *
00103    * @param src vector \c x used to form the householder vector
00104    * @param v householder vector \c v
00105    * @param beta factor needed for householder transform
00106    *
00107    * @ingroup gUnassigned
00108    */
00109   template<typename T>
00110   inline void householder(const vector<T>& src, vector<T>& v, T& beta);
00111 
00112   /**
00113    * Calculates the cos (\c c) and sin (\c s) values needed for Givens
00114    * Rotations.
00115    *
00116    * The values \c c and \c s have the following property:
00117    * \f[
00118    * \begin{bmatrix} c & s \\ -s & c \end{bmatrix}^T
00119    * \begin{bmatrix} a \\ b \end{bmatrix} =
00120    * \begin{bmatrix} r \\ 0 \end{bmatrix}.
00121    * \f]
00122    *
00123    * For more details see:<br>
00124    * Gene H. Golub and Charles F. Van Loan, "Matrix Computations",
00125    * 1996, The John Hopkins University Press, Baltimore and London
00126    *
00127    * @param a first scalar
00128    * @param b second scalar
00129    * @param c cos value for Givens Rotation
00130    * @param s sin value for Givens Rotation
00131    *
00132    * @ingroup gUnassigned
00133    */
00134   template<typename T>
00135   inline void givens(const T& a, const T& b, T& c, T& s);
00136 
00137 }
00138 
00139 #include "cvrMathLA_inline.h"
00140 
00141 #endif

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