So-Bogus
A c++ sparse block matrix library aimed at Second Order cone problems
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
NonSmoothNewton.hpp
1 /*
2  * This file is part of bogus, a C++ sparse block matrix library.
3  *
4  * Copyright 2013 Gilles Daviet <gdaviet@gmail.com>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
10 
11 
12 #ifndef BOGUS_NS_NETWON_HPP
13 #define BOGUS_NS_NETWON_HPP
14 
15 namespace bogus {
16 
18 
24 template < typename NSFunction >
26 {
27 public:
28  typedef typename NSFunction::Traits Traits ;
29  typedef typename Traits::Scalar Scalar ;
30  typedef typename Traits::Vector Vector ;
31  typedef typename Traits::Matrix Matrix ;
32 
33  NonSmoothNewton( const NSFunction &func, Scalar tol )
34  : m_func( func ), m_tol( tol ), m_maxIters( 20 )
35  {}
36 
38 
42  Scalar solve ( Vector &x ) const ;
43 
45  void setMaxIters( unsigned maxIters ) { m_maxIters = maxIters ; }
46 
48  void setTol( Scalar tol ) { m_tol = tol ; }
49 
50 private:
51  const NSFunction& m_func ;
52  Scalar m_tol ;
53  unsigned m_maxIters ;
54 
55 } ;
56 
57 
58 }
59 
60 #endif
void setMaxIters(unsigned maxIters)
Sets the maximum number of iterations.
Definition: NonSmoothNewton.hpp:45
void setTol(Scalar tol)
Sets the solver tolerance.
Definition: NonSmoothNewton.hpp:48
Dense, naive Newton implementation.
Definition: NonSmoothNewton.hpp:25
Scalar solve(Vector &x) const
Tries to find x such that m_func( x ) = 0.