ADMB Documentation  11.1.1916
 All Classes Files Functions Variables Typedefs Friends Defines
svdcmp.h
Go to the documentation of this file.
00001 /*
00002  * $Id: svdcmp.h 1730 2014-03-04 01:30:47Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  *
00007  * ADModelbuilder and associated libraries and documentations are
00008  * provided under the general terms of the "BSD" license.
00009  *
00010  * License:
00011  *
00012  * Redistribution and use in source and binary forms, with or without
00013  * modification, are permitted provided that the following conditions are
00014  * met:
00015  *
00016  * 1. Redistributions of source code must retain the above copyright
00017  * notice, this list of conditions and the following disclaimer.
00018  *
00019  * 2.  Redistributions in binary form must reproduce the above copyright
00020  * notice, this list of conditions and the following disclaimer in the
00021  * documentation and/or other materials provided with the distribution.
00022  *
00023  * 3.  Neither the name of the  University of California, Otter Research,
00024  * nor the ADMB Foundation nor the names of its contributors may be used
00025  * to endorse or promote products derived from this software without
00026  * specific prior written permission.
00027  *
00028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00029  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00030  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00031  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00032  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00033  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00034  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00035  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00036  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00037  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00038  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  *
00040  */
00045 #if !defined(_SVDCMP_)
00046 #define _SVDCMP_
00047 
00048 #include <fvar.hpp>
00049 
00050 
00051 double pythag(double a, double b);
00052 double fmax(double a,double b) { if (a>b) return a; else return b;}
00053 double imin(int a,int b) { if (a>b) return b; else return a;}
00054 double sign(double a,double b){ if (b>0) return fabs(a); else return -fabs(a);}
00055 
00056 dvariable pythag(const prevariable& a, double b);
00057 dvariable pythag(const prevariable& a, const prevariable& b);
00058 dvariable fmax(const prevariable& a, const prevariable& b)
00059   { return a > b ? a : b; }
00060 dvariable sign(const prevariable& a, const prevariable& b)
00061   { if (b>0) return fabs(a); else return -fabs(a);}
00062 
00067 class d_singular_value_decomposition
00068 {
00069 public:
00070   dmatrix a;
00071   dvector w;
00072   dmatrix v;
00073   d_singular_value_decomposition(int m,int n) :
00074     a(1,m,1,n), w(1,n), v(1,n,1,n) {}
00075 };
00076 
00081 class dvar_singular_value_decomposition
00082 {
00083 public:
00084   dvar_matrix a;
00085   dvar_vector w;
00086   dvar_matrix v;
00087   dvar_singular_value_decomposition(int m,int n) :
00088     a(1,m,1,n), w(1,n), v(1,n,1,n) {}
00089 };
00090 
00091 d_singular_value_decomposition svdcmp(const dmatrix& a1);
00092 dvar_singular_value_decomposition svdcmp(const dvar_matrix& a1);
00093 
00094 #endif