source: trunk/yat/utility/SVD.cc @ 687

Last change on this file since 687 was 687, checked in by Jari Häkkinen, 16 years ago

Clean up of namespace comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1// $Id: SVD.cc 687 2006-10-16 23:51:10Z jari $
2
3/*
4  Copyright (C) The authors contributing to this file.
5
6  This file is part of the yat library, http://lev.thep.lu.se/trac/yat
7
8  The yat library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12
13  The yat library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "SVD.h"
25
26namespace theplu {
27namespace yat {
28namespace utility {
29
30
31  int SVD::decompose(SVDalgorithm algo)
32  {
33    switch (algo) {
34        case GolubReinsch:
35          return golub_reinsch();
36        case ModifiedGolubReinsch:
37          return modified_golub_reinsch();
38        case Jacobi:
39          return jacobi();
40    }
41    // the program should never end up here, return values should be
42    // something different from normal GSL return values, or maybe
43    // throw an exception.
44    return 0;
45  }
46
47
48
49  int SVD::golub_reinsch(void)
50  {
51    utility::vector w(U_.columns());
52    return gsl_linalg_SV_decomp(U_.gsl_matrix_p(), V_.gsl_matrix_p(),
53                                s_.gsl_vector_p(), w.gsl_vector_p());
54  }
55
56
57
58  int SVD::modified_golub_reinsch(void)
59  {
60    utility::vector w(U_.columns());
61    utility::matrix X(U_.columns(),U_.columns());
62    return gsl_linalg_SV_decomp_mod(U_.gsl_matrix_p(), X.gsl_matrix_p(), 
63                                    V_.gsl_matrix_p(), s_.gsl_vector_p(),
64                                    w.gsl_vector_p());
65  }
66
67
68}}} // of namespace utility, yat, and theplu
Note: See TracBrowser for help on using the repository browser.