# Changeset 7 for trunk

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

* empty log message *

Location:
trunk/src
Files:
2 edited

### Legend:

Unmodified
 r6 ////////////////////////////////////////////////// //Class encapsulating methods for //Singular Value Decomposition // //A = Matrix to be decomposed, size MxN //U = Orthogonal matrix, size MxN //S = Diagonal matrix of singular values, size NxN //V = Orthogonal matrix, size NxN //A = U S V' = (MxN)(NxN)(NxN) = (MxN) //Note: The matrix A_ is replaced by U on //      output from gsl_linalg_* method ////////////////////////////////////////////////// namespace THEP_CPPTOOLS namespace thep_cpp_tools { /** Class encapsulating methods for Singular Value Decomposition @version $Revision$ $Date$ */ /** Class encapsulating methods for Singular Value Decomposition. \n\n A = Matrix to be decomposed, size MxN\n U = Orthogonal matrix, size MxN\n S = Diagonal matrix of singular values, size NxN\n V = Orthogonal matrix, size NxN\n A = U S V' = (MxN)(NxN)(NxN) = (MxN)\n @version 1.0 $Revision$ $Date$ */ class SVD public: SVD(); /** Constructs a SVD object and initializes it to proper matrix sizes. The input matrix is copied for further use in the Constructs an SVD object using the matrix A as only input. The input matrix is copied for further use in the object. */ SVD( const gsl::matrix& ); /** Constructor initializing the SVD object for Solver.  Solver requires an extra-vector paramter \a b: $Ax = b$ The $x$ vector will be reached using the get_x() function. Constructor initializing the SVD object for Solver. Solver requires an extra-vector paramter \a b: $Ax = b$ The $x$ vector will be reached using the get_x() function. @see get_x() function. */ SVD( const gsl::matrix&, const gsl::vector& b); ~SVD(); /** This function will run the method specified by the SVDtypes. Precently there are 3 SVD methods implemented and one solver. These are: \n\n Unmodified: (see GSL documentation about gsl_linalg_SV_decomp function)\n Modified: This method is faster when M>>N. (see GSL documentation about gsl_linalg_SV_decomp_mod function)\n Jakoby: Computes singular values to higer accuracy than default method (see GSL documentation about gsl_linalg_SV_decomp_jacobi.\n Solver: Using Unmodified to perform SVD and then solves the system \f$Ax=b\f$ */ bool process( SVDtypes stype = Unmodified ); //The result is obtained from the Get functions below: /** Function will return the matrix U. Require that process() has been executed. */ gsl::matrix get_u() const { return A_; } /** Function will return the matrix V. Require that process() has been executed. */ gsl::matrix get_v() const { return V_; } /** Function will return the vector x containing the solution \f$x=A^{-1}b \f$. Require that process( Solver ) has been executed. @see Read about Solver in the bool process() function. */ gsl::vector get_x() const { return x_; } /** Function returning diagonal matrix S. Require that process() has been executed. */ gsl::matrix get_s() const; //Test-method /** This method will execute Default, Unmodified and Jakoby methods one at a time and calculate the error, \f$e = \left\Vert A - USV^{T} \right\Vert_{2} \f$. The method will return "true" if \f$e < 10^{-10}\f$ else false. A test program is available that executes this method, c++_tools/test/svd_test. No test is performed for solver but the aim is to add one in the future. */ bool test(); private: SVD(); gsl::matrix A_, V_; gsl::vector s_, b_, x_;