Changeset 7 for trunk


Ignore:
Timestamp:
Feb 28, 2003, 11:39:35 AM (19 years ago)
Author:
daniel
Message:

* empty log message *

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SVD.cc

    r4 r7  
    66#include <cstdlib> //To include srand() and rand()
    77#include <ctime>
    8 using namespace THEP_CPPTOOLS;
     8using namespace thep_cpp_tools;
    99
    1010//Constructor that can only be used for test-method
  • trunk/src/SVD.h

    r6 r7  
    1010
    1111
    12 
    13 //////////////////////////////////////////////////
    14 //Class encapsulating methods for
    15 //Singular Value Decomposition
    16 //
    17 //A = Matrix to be decomposed, size MxN
    18 //U = Orthogonal matrix, size MxN
    19 //S = Diagonal matrix of singular values, size NxN
    20 //V = Orthogonal matrix, size NxN
    21 //A = U S V' = (MxN)(NxN)(NxN) = (MxN)
    22 //Note: The matrix A_ is replaced by U on
    23 //      output from gsl_linalg_* method
    24 //////////////////////////////////////////////////
    25 
    26 namespace THEP_CPPTOOLS
     12namespace thep_cpp_tools
    2713
    2814
    29     /**
    30        Class encapsulating methods for Singular Value Decomposition
    31 
    32        @version $Revision$ $Date$
    33     */
     15  /**
     16     Class encapsulating methods for Singular Value Decomposition.
     17     \n\n
     18     A = Matrix to be decomposed, size MxN\n
     19     U = Orthogonal matrix, size MxN\n
     20     S = Diagonal matrix of singular values, size NxN\n
     21     V = Orthogonal matrix, size NxN\n
     22     A = U S V' = (MxN)(NxN)(NxN) = (MxN)\n   
     23     @version 1.0 $Revision$ $Date$
     24  */
    3425
    3526  class SVD
     
    4637
    4738  public:
    48     SVD();
    4939    /**
    50        Constructs a SVD object and initializes it to proper matrix
    51        sizes. The input matrix is copied for further use in the
     40       Constructs an SVD object using the matrix A as only
     41       input. The input matrix is copied for further use in the
    5242       object.
    5343    */
    5444    SVD( const gsl::matrix& );
     45   
    5546    /**
    56        Constructor initializing the SVD object for Solver.  Solver
    57        requires an extra-vector paramter \a b: $Ax = b$ The $x$ vector
    58        will be reached using the get_x() function.
    59 
     47       Constructor initializing the SVD object for Solver. 
     48       Solver requires an extra-vector paramter \a b: $Ax = b$
     49       The $x$ vector will be reached using the get_x()
     50       function.
    6051       @see get_x() function.
    6152    */
     53
    6254    SVD( const gsl::matrix&, const gsl::vector& b);
    6355    ~SVD();
     56
     57    /**
     58       This function will run the method specified by the SVDtypes. Precently
     59       there are 3 SVD methods implemented and one solver. These are: \n\n
     60       Unmodified: (see GSL documentation about gsl_linalg_SV_decomp function)\n
     61       Modified: This method is faster when M>>N. (see GSL documentation
     62       about gsl_linalg_SV_decomp_mod function)\n
     63       Jakoby: Computes singular values to higer accuracy than default method
     64       (see GSL documentation about gsl_linalg_SV_decomp_jacobi.\n
     65       Solver: Using Unmodified to perform SVD and then solves the system \f$Ax=b\f$
     66    */
    6467    bool process( SVDtypes stype = Unmodified );
    65    
    66     //The result is obtained from the Get functions below:
     68
     69    /**
     70       Function will return the matrix U. Require that process() has been
     71       executed.
     72    */
    6773    gsl::matrix get_u() const { return A_; }
     74
     75    /**
     76       Function will return the matrix V. Require that process() has been
     77       executed.
     78    */
    6879    gsl::matrix get_v() const { return V_; }
     80
     81
     82    /**
     83       Function will return the vector x containing the solution
     84       \f$ x=A^{-1}b \f$. Require that process( Solver ) has been
     85       executed. 
     86       @see Read about Solver in the bool process() function.
     87    */
     88
    6989    gsl::vector get_x() const { return x_; }
     90
     91    /**
     92       Function returning diagonal matrix S. Require that process() has been
     93       executed.
     94    */
    7095    gsl::matrix get_s() const;
    7196
    72     //Test-method
     97    /**
     98       This method will execute Default, Unmodified and Jakoby methods one at a time
     99       and calculate the error, \f$ e = \left\Vert A - USV^{T} \right\Vert_{2} \f$.
     100       The method will return "true" if \f$e < 10^{-10}\f$ else false. A test program
     101       is available that executes this method, c++_tools/test/svd_test. No test is
     102       performed for solver but the aim is to add one in the future.
     103    */
    73104    bool test();
    74105   
    75106  private:
     107    SVD();
     108
    76109    gsl::matrix A_, V_;   
    77110    gsl::vector s_, b_, x_;
Note: See TracChangeset for help on using the changeset viewer.