SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
IterativeLinearSolver.cpp
Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2013 Soumyajit De
00008  */
00009 
00010 #include <shogun/lib/common.h>
00011 #include <shogun/base/Parameter.h>
00012 #include <shogun/mathematics/linalg/linsolver/IterativeLinearSolver.h>
00013 
00014 namespace shogun
00015 {
00016 
00017 template <class T, class ST>
00018 CIterativeLinearSolver<T, ST>::CIterativeLinearSolver()
00019     : CLinearSolver<T, ST>()
00020     {
00021         init();
00022     }
00023 
00024 template <class T, class ST>
00025 CIterativeLinearSolver<T, ST>::CIterativeLinearSolver(bool store_residuals)
00026     : CLinearSolver<T, ST>()
00027     {
00028         init();
00029         m_store_residuals=store_residuals;
00030         if (m_store_residuals)
00031         {
00032             m_residuals=SGVector<float64_t>(m_max_iteration_limit);
00033             m_residuals.set_const(0.0);
00034         }
00035     }
00036 
00037 template <class T, class ST>
00038 void CIterativeLinearSolver<T, ST>::init()
00039     {
00040         m_max_iteration_limit=1000;
00041         m_relative_tolerence=1E-5;
00042         m_absolute_tolerence=1E-5;
00043         m_store_residuals=false;
00044 
00045         this->m_parameters->add(&m_max_iteration_limit, "max_iteration_limit",
00046             "Maximum number of iteration for the solver");
00047 
00048         this->m_parameters->add(&m_relative_tolerence, "relative_tolerence",
00049             "Relative tolerence of solver");
00050 
00051         this->m_parameters->add(&m_absolute_tolerence, "absolute_tolerence",
00052             "Absolute tolerence of solver");
00053 
00054         this->m_parameters->add(&m_store_residuals, "store_residuals",
00055             "Whether to store the residuals");
00056 
00057         this->m_parameters->add(&m_residuals, "residuals",
00058             "Residuals for each iterations");
00059     }
00060 
00061 template <class T, class ST>
00062 CIterativeLinearSolver<T, ST>::~CIterativeLinearSolver()
00063     {
00064     }
00065 
00066 template class CIterativeLinearSolver<float64_t>;
00067 template class CIterativeLinearSolver<complex128_t, float64_t>;
00068 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation