PLearn 0.1
Cholesky_utils.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // PLearn (A C++ Machine Learning Library)
00004 // Copyright (C) 1998 Pascal Vincent
00005 // Copyright (C) 1999-2002 Pascal Vincent, Yoshua Bengio and University of
00006 //                         Montreal, all rights reserved
00007 // Copyright (C) 2006 Olivier Delalleau
00008 //
00009 
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are met:
00012 // 
00013 //  1. Redistributions of source code must retain the above copyright
00014 //     notice, this list of conditions and the following disclaimer.
00015 // 
00016 //  2. Redistributions in binary form must reproduce the above copyright
00017 //     notice, this list of conditions and the following disclaimer in the
00018 //     documentation and/or other materials provided with the distribution.
00019 // 
00020 //  3. The name of the authors may not be used to endorse or promote
00021 //     products derived from this software without specific prior written
00022 //     permission.
00023 // 
00024 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
00025 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00026 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
00027 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00028 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00029 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00030 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00031 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00032 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00033 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 // 
00035 // This file is part of the PLearn library. For more information on the PLearn
00036 // library, go to the PLearn Web site at www.plearn.org
00037 
00038 
00039 #ifndef Cholesky_utils_INC
00040 #define Cholesky_utils_INC
00041 
00042 #include <plearn/math/Mat.h>
00043 
00044 namespace PLearn {
00045 
00055 void choleskyAppendDimension(Mat& L, const Vec& new_row);
00056 
00059 void choleskyRemoveDimension(Mat& L, int i);
00060 
00061 // L (n_active x n_active) is lower-diagonal and is such that A = L L' = lambda I + sum_t phi_t(x_t) phi_t(x_t)'
00062 // where the sum runs until 'now' and phi_t is the 'current' active basis set. 
00063 // In this function we update L so as to incorporate a new basis, i.e. n_active is incremented,
00064 // using a new basis whose outputs on all the examples up to 'now' are given in new_basis_outputs.
00065 // The dimensions of L are changed as a result. Note that L must have been pre-allocated
00066 // with dimensions max_n_active x max_n_active. The matrix active_bases_outputs (n_active x n_examples)
00067 // contains the outputs of the active bases that are in phi up to now.
00068 // Computational cost is O(n_active * n_examples).
00069 void choleskyInsertBasis(Mat& L, Mat active_bases_outputs, Vec new_basis_outputs, real lambda, real min_Lii=1e-10);
00070 
00071 // Given a current Cholesky decomposition of A = L L' = sum_t v_t v_t'
00072 // add an extra v_t v_t' term to the matrix A (i.e. upgrade lower-diagonal L accordingly).
00073 // computational cost: O(n^2)
00074 void choleskyUpgrade(Mat& L, Vec v);
00075 
00076 /****** Utility functions ******/
00077 
00079 void chol_dxch(Mat& R, int l, int m);
00080 void chol_rotapp(real c, real s, const Vec& x, const Vec& y);
00081 void chol_rotgen(real& a, real& b, real& c, real& s);
00082 
00087 void chol_dxch_tr(Mat& R_t, int l, int m);
00088 void chol_rotapp_tr(real c, real s, const Mat& x, const Mat& y);
00089 
00092 void chol_rotapp_tr_opt(real c, real s, const Mat& R,
00093                         int i, int j, int k, int m);
00094 
00095 // debugging / test program for the above functions
00096 void testCholeskyRoutines();
00097 
00098 
00099 } // end of namespace PLearn
00100 
00101 #endif 
00102 
00103 
00104 /*
00105   Local Variables:
00106   mode:c++
00107   c-basic-offset:4
00108   c-file-style:"stroustrup"
00109   c-file-offsets:((innamespace . 0)(inline-open . 0))
00110   indent-tabs-mode:nil
00111   fill-column:79
00112   End:
00113 */
00114 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines