source: branches/better_matrix_class/lib/utility/SVD.cc @ 415

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

Removed some gslapi copy intensive operators.
Made gslapi assignment operators ignore views, and change them
into normal vectors if assigned.
Cleaning up of code aswell.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.0 KB
Line 
1// $Id: SVD.cc 415 2005-12-01 15:52:36Z jari $
2
3#include <c++_tools/utility/SVD.h>
4
5
6namespace theplu {
7namespace utility {
8
9
10  int SVD::decompose(SVDalgorithm algo)
11  {
12    switch (algo) {
13        case GolubReinsch:
14          return golub_reinsch();
15        case ModifiedGolubReinsch:
16          return modified_golub_reinsch();
17        case Jacobi:
18          return jacobi();
19    }
20    // the program should never end up here, return values should be
21    // something different from normal GSL return values, or maybe
22    // throw an exception.
23    return 0;
24  }
25
26
27
28  int SVD::golub_reinsch(void)
29  {
30    gslapi::vector w(U_.columns());
31    return gsl_linalg_SV_decomp(U_.gsl_matrix_p(), V_.gsl_matrix_p(),
32                                s_.gsl_vector_p(), w.gsl_vector_p());
33  }
34
35
36
37  int SVD::modified_golub_reinsch(void)
38  {
39    gslapi::vector w(U_.columns());
40    gslapi::matrix X(U_.columns(),U_.columns());
41    return gsl_linalg_SV_decomp_mod(U_.gsl_matrix_p(), X.gsl_matrix_p(), 
42                                    V_.gsl_matrix_p(), s_.gsl_vector_p(),
43                                    w.gsl_vector_p());
44  }
45
46
47}} // of namespace utility and namespace theplu
Note: See TracBrowser for help on using the repository browser.