contrib/mul/mbl/mbl_mod_gram_schmidt.h
Go to the documentation of this file.
00001 // This is mul/mbl/mbl_mod_gram_schmidt.h
00002 #ifndef mbl_mod_gram_schmidt_h_
00003 #define mbl_mod_gram_schmidt_h_
00004 //:
00005 // \file
00006 // \brief Orthogonalise a basis using modified Gram-Schmidt (and normalise)
00007 // \author Martin Roberts
00008 //
00009 // Note: Modified Gram-Schmidt is more numerically stable than the classical version
00010 // The partially constructed transformed jth vector is used in the successive projections rather than the untransformed
00011 // \verbatim
00012 // Modifications
00013 // Mar. 2011 - Patrick Sauer - added variant that returns normalisation multipliers
00014 // \endverbatim
00015 
00016 #include <vnl/vnl_matrix.h>
00017 
00018 //=======================================================================
00019 //: Orthogonalise a basis using modified Gram-Schmidt
00020 // Transform basis {vk} to orthonormal basis {ek} with k in range 1..N
00021 // \code
00022 // for j = 1 to N
00023 //     ej = vj
00024 //     for k = 1 to j-1
00025 //         ej = ej - <ej,ek>ek   //NB Classical GS has vj in inner product
00026 //     end
00027 //     ej = ej/|ej|
00028 //  end
00029 // \endcode
00030 
00031 //: Convert input basis {v} to orthonormal basis {e}
00032 // Each basis vector is a column of v, and likewise the orthonormal bases are returned as columns of e
00033 void mbl_mod_gram_schmidt(const vnl_matrix<double>& v,
00034                           vnl_matrix<double>& e);
00035 
00036 //: Convert input basis {v} to orthonormal basis {e}
00037 // Each basis vector is a column of v, and likewise the orthonormal bases are returned as columns of e
00038 // The multipliers used to normalise each vector in {e} are returned in n.
00039 void mbl_mod_gram_schmidt( const vnl_matrix<double>& v, 
00040                            vnl_matrix<double>& e, vnl_vector<double>& n );
00041 
00042 #endif // mbl_mod_gram_schmidt_h_