Developer documentation

subdivisor.hpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * M a t h e m a g i x
3  *****************************************************************************
4  * Subdivisor
5  * 2010-05-16
6  *****************************************************************************
7  * Copyright (C) 2010 INRIA Sophia-Antipolis
8  *****************************************************************************
9  * Comments :
10  ****************************************************************************/
11 # ifndef realroot_solver_subdivisor_hpp
12 # define realroot_solver_subdivisor_hpp
13 
14 # include <stack>
15 # include <realroot/Seq.hpp>
16 
17 # define TMPL template<class CELL, class V>
18 # define SELF subdivisor<CELL, V>
19 # define Stack std::stack<Cell*>
20 //====================================================================
21 namespace mmx {
22 
23 TMPL
24 class subdivisor {
25 
26 public:
27  typedef CELL Cell;
28  subdivisor(Cell* c) ;
29  ~subdivisor(void) ;
30 
31  void run(void) ;
32 
33  Seq<Cell*> solutions() {return m_sols;}
34 private:
35  Stack* m_stack ;
36  Seq<Cell*> m_sols;
37 };
38 
39 //--------------------------------------------------------------------
40 TMPL
41 SELF::subdivisor(CELL * object) {
42  m_stack = new Stack ;
43  m_stack -> push(object);
44 }
45 
46 TMPL
47 SELF::~subdivisor(void) {
48  delete m_stack ;
49 }
50 
51 TMPL void
52 SELF::run() {
53 
54  Cell* cl=NULL;
55  while( !m_stack->empty() ) {
56 
57  cl = m_stack->top(); m_stack->pop();
58 
59  if(V::reduce(cl)) {
60  V::subdivide(cl,m_stack) ;
61  delete cl;
62  } else if(V::regular(cl)) {
63  m_sols<<cl;
64  } else
65  delete cl;
66 
67 
68  }
69 }
70 //====================================================================
71 } // namespace mmx
72 //====================================================================
73 # undef TMPL
74 # undef SELF
75 # undef Stack
76 # endif
#define TMPL
Definition: subdivisor.hpp:17
Seq< Cell * > solutions()
Definition: subdivisor.hpp:33
CELL Cell
Definition: subdivisor.hpp:27
subdivisor(Cell *c)
Definition: subdivisor.hpp:24
void reduce(R &p, const typename R::size_type &e)
void run(void)
const C & c
Definition: Interval_glue.hpp:45
#define Stack
Definition: subdivisor.hpp:19
Definition: array.hpp:12
Home