Rosetta Utilities  2014.35
Public Member Functions | Private Member Functions | Private Attributes | List of all members
basic::svd::SVD_Solver Class Reference

#include <SVD_Solver.hh>

Public Member Functions

 SVD_Solver ()
 
 ~SVD_Solver ()
 
 SVD_Solver (platform::Size const M, platform::Size const N)
 M is the size of vector b (experimental data); N is the size of the vector to optimize M >= N. More...
 
SVD_Solveroperator= (SVD_Solver const &other)
 
 SVD_Solver (SVD_Solver const &other)
 
void set_vector_b (utility::vector1< double > const &b)
 set the vector b of Ax=b More...
 
void set_matrix_A (utility::vector1< utility::vector1< double > > const &A)
 set the matrix A of Ax=b More...
 
void set_vector_b (FArray1D< double > const &b)
 set the vector b of Ax=b (FArray1D version) More...
 
void set_matrix_A (FArray2D< double > const &A)
 set the matrix A of Ax=b (FArray2D version) More...
 
void run_decomp_svd ()
 decompose the matrix A. Can be called after the matrix A and vector b are set (with set_matrix_A and set_vector_b) More...
 
void run_solve_svd ()
 minimize the cost sqrt( ||A x - b||^2 ) (but doesn't calculate it) Can be called after run_decomp_svd() More...
 
double run_score_svd_on_matrix (utility::vector1< utility::vector1< double > > const &cppstyle_A) const
 return the score given the matrix A Can be called after run_decomp_svd() More...
 
double run_score_svd_on_matrix (FArray2D< double > const &A) const
 return the score given the matrix A (FArray2D version) Can be called after run_decomp_svd() More...
 
double run_score_svd_without_solving ()
 return the minimzed score without the need to call run_solve_svd() Can be called after run_decomp_svd() More...
 
utility::vector1< double > const & get_svd_solution () const
 return the vector x that minimize ||Ax - b||^2 Can be called after run_solve_svd() More...
 

Private Member Functions

double pythag (double const &a, double const &b) const
 
void svdcmp ()
 
void svbksb ()
 

Private Attributes

utility::vector1< double > cstyle_b_
 
utility::vector1
< utility::vector1< double > > 
cstyle_A_decomp_
 
utility::vector1
< utility::vector1< double > > 
cstyle_v_
 
utility::vector1< double > cstyle_x_
 
utility::vector1< double > cstyle_w_
 
utility::vector1< double > cstyle_tmp_
 
platform::Size M_
 
platform::Size N_
 
bool b_is_set_
 
bool A_is_set_
 
bool A_is_decomp_
 
bool x_is_solved_
 

Constructor & Destructor Documentation

basic::svd::SVD_Solver::SVD_Solver ( )
basic::svd::SVD_Solver::~SVD_Solver ( )
basic::svd::SVD_Solver::SVD_Solver ( platform::Size const  M,
platform::Size const  N 
)

M is the size of vector b (experimental data); N is the size of the vector to optimize M >= N.

References A_is_decomp_, A_is_set_, b_is_set_, cstyle_A_decomp_, cstyle_b_, cstyle_tmp_, cstyle_v_, cstyle_w_, cstyle_x_, M_, N_, utility_exit_with_message, and x_is_solved_.

basic::svd::SVD_Solver::SVD_Solver ( SVD_Solver const &  other)

Member Function Documentation

utility::vector1< double > const & basic::svd::SVD_Solver::get_svd_solution ( ) const

return the vector x that minimize ||Ax - b||^2 Can be called after run_solve_svd()

Return the optimized vector x. Can be called only when ||Ax-b||^2 has been minimized.

References cstyle_x_, utility_exit_with_message, and x_is_solved_.

SVD_Solver & basic::svd::SVD_Solver::operator= ( SVD_Solver const &  other)
double basic::svd::SVD_Solver::pythag ( double const &  a,
double const &  b 
) const
private

Referenced by svdcmp().

void basic::svd::SVD_Solver::run_decomp_svd ( )

decompose the matrix A. Can be called after the matrix A and vector b are set (with set_matrix_A and set_vector_b)

Decomposition of the matrix A. Can be called only when A is set. You can't decompose twice in a row without reseting the matrix A.

References A_is_decomp_, A_is_set_, svdcmp(), and utility_exit_with_message.

double basic::svd::SVD_Solver::run_score_svd_on_matrix ( utility::vector1< utility::vector1< double > > const &  cppstyle_A) const

return the score given the matrix A Can be called after run_decomp_svd()

Return the score SQRT(||Ax-b||^2). Can be called only when ||Ax-b||^2 has been minimized. You need the give the original A matrix as argument.

References cstyle_b_, cstyle_x_, M_, N_, basic::options::OptionKeys::AnchoredDesign::filters::score, utility_exit_with_message, and x_is_solved_.

double basic::svd::SVD_Solver::run_score_svd_on_matrix ( FArray2D< double > const &  A) const

return the score given the matrix A (FArray2D version) Can be called after run_decomp_svd()

Return the score SQRT(||Ax-b||^2). Can be called only when ||Ax-b||^2 has been minimized. You need the give the original A matrix as argument.

References cstyle_b_, cstyle_x_, M_, N_, basic::options::OptionKeys::AnchoredDesign::filters::score, utility_exit_with_message, and x_is_solved_.

double basic::svd::SVD_Solver::run_score_svd_without_solving ( )

return the minimzed score without the need to call run_solve_svd() Can be called after run_decomp_svd()

Attempt to speed up calculation of the cost without actually solving Ax = b The routine works, but is not faster (nor slower)

References A_is_decomp_, b_is_set_, cstyle_A_decomp_, cstyle_b_, cstyle_tmp_, M_, N_, basic::options::OptionKeys::AnchoredDesign::filters::score, and utility_exit_with_message.

void basic::svd::SVD_Solver::run_solve_svd ( )

minimize the cost sqrt( ||A x - b||^2 ) (but doesn't calculate it) Can be called after run_decomp_svd()

Minimize ||Ax - b||^2. Can be called only when b is set and A is decomposed. You are allowed to update the vector b and minimize again.

References A_is_decomp_, b_is_set_, svbksb(), utility_exit_with_message, and x_is_solved_.

void basic::svd::SVD_Solver::set_matrix_A ( utility::vector1< utility::vector1< double > > const &  A)

set the matrix A of Ax=b

To minimize ||Ax - b||^2, you need to set the matrix A.

References A_is_decomp_, A_is_set_, cstyle_A_decomp_, M_, N_, utility_exit_with_message, and x_is_solved_.

void basic::svd::SVD_Solver::set_matrix_A ( FArray2D< double > const &  A)

set the matrix A of Ax=b (FArray2D version)

To minimize ||Ax - b||^2, you need to set the matrix A.

References A_is_decomp_, A_is_set_, cstyle_A_decomp_, M_, N_, utility_exit_with_message, and x_is_solved_.

void basic::svd::SVD_Solver::set_vector_b ( utility::vector1< double > const &  b)

set the vector b of Ax=b

To minimize ||Ax - b||^2, you need to set the vector b.

References b_is_set_, cstyle_b_, M_, utility_exit_with_message, and x_is_solved_.

void basic::svd::SVD_Solver::set_vector_b ( FArray1D< double > const &  b)

set the vector b of Ax=b (FArray1D version)

To minimize ||Ax - b||^2, you need to set the vector b.

References b_is_set_, cstyle_b_, M_, utility_exit_with_message, and x_is_solved_.

void basic::svd::SVD_Solver::svbksb ( )
private
void basic::svd::SVD_Solver::svdcmp ( )
private

Member Data Documentation

bool basic::svd::SVD_Solver::A_is_decomp_
private
bool basic::svd::SVD_Solver::A_is_set_
private
bool basic::svd::SVD_Solver::b_is_set_
private
utility::vector1< utility::vector1<double> > basic::svd::SVD_Solver::cstyle_A_decomp_
private
utility::vector1<double> basic::svd::SVD_Solver::cstyle_b_
private
utility::vector1<double> basic::svd::SVD_Solver::cstyle_tmp_
private
utility::vector1< utility::vector1<double> > basic::svd::SVD_Solver::cstyle_v_
private

Referenced by operator=(), svbksb(), SVD_Solver(), and svdcmp().

utility::vector1<double> basic::svd::SVD_Solver::cstyle_w_
private

Referenced by operator=(), svbksb(), SVD_Solver(), and svdcmp().

utility::vector1<double> basic::svd::SVD_Solver::cstyle_x_
private
platform::Size basic::svd::SVD_Solver::M_
private
platform::Size basic::svd::SVD_Solver::N_
private
bool basic::svd::SVD_Solver::x_is_solved_
private

The documentation for this class was generated from the following files: