Developer documentation

system_support.hpp
Go to the documentation of this file.
1 /********************************************************************
2  * This file is part of the source code of the realroot library.
3  * Author(s): J.P. Pavone, GALAAD, INRIA
4  * $Id: support.hpp,v 1.1 2005/07/11 10:03:55 jppavone Exp $
5  ********************************************************************/
6 #ifndef realroot_SOLVE_SBDSLV_SUPPORT_HPP
7 #define realroot_SOLVE_SBDSLV_SUPPORT_HPP
8 //--------------------------------------------------------------------
9 namespace mmx {
10 //--------------------------------------------------------------------
11 namespace realroot
12 {
13  template<class V>
14  struct system_ctrl
15  {
16  typedef int sz_t;
17  V& m_v;
18  system_ctrl( V& v ): m_v(v) {};
19  template< class _interval_ > static inline
20  bool check( _interval_ const * const, int ) { return true; };
21  template< class _interval_ > inline
22  void output( _interval_ const * const dmns, sz_t nvars )
23  {
24  // std::cout << "OUTPUT\n";
25  // vctops::print(dmns,nvars);
26  // std::cout << std::endl;
27  for ( sz_t i = 0; i < nvars; i ++ )
28  m_v.push_back( dmns[i].lower() ),
29  m_v.push_back( dmns[i].upper() );
30  };
31  };
32 
33  template< class real_t >
34  unsigned clean_result( real_t * isols, int nvars, int nsols, const real_t& prec )
35  {
36  int a,c,n,i;
37  real_t cd;
38  if ( nsols == 0 ) return 0;
39  for ( a = 0; a < nsols*nvars; isols[a] = (isols[2*a]+isols[2*a+1])/2.0, a ++ ) ;
40 
41  for ( n = 1, c = 0, a = 0; a < nsols*nvars; a += nvars )
42  {
43  for ( cd = 0, i = 0; i < nvars; cd = std::max(cd,std::abs((isols+c)[i]-(isols+a)[i])), i ++ ) ;
44  if ( cd < prec )
45  {
46  double fa = ((double)n)/(n+1);
47  double fb = ((double)1.0)/(n+1);
48  for ( int i = 0; i < nvars; i ++ ) (isols+c)[i] = fa*(isols+c)[i]+fb*(isols+a)[i];
49  n ++;
50  }
51  else
52  {
53  c += nvars;
54  std::copy(isols+a,isols+a+nvars,isols+c);
55  n = 1;
56  };
57  };
58  return (c+nvars)/nvars;
59  };
60 };
61 //--------------------------------------------------------------------
62 } //namespace mmx
63 /********************************************************************/
64 #endif //
system_ctrl(V &v)
Definition: system_support.hpp:18
Definition: system_support.hpp:14
static bool check(_interval_ const *const, int)
Definition: system_support.hpp:20
TMPL void copy(Polynomial &r, const Polynomial &a)
Copy of a in r.
Definition: sparse_monomials.hpp:613
void output(_interval_ const *const dmns, sz_t nvars)
Definition: system_support.hpp:22
int sz_t
Definition: system_support.hpp:16
unsigned clean_result(real_t *isols, int nvars, int nsols, const real_t &prec)
Definition: system_support.hpp:34
void abs(Interval< C, r > &x, const Interval< C, r > &a)
Definition: Interval_fcts.hpp:185
V & m_v
Definition: system_support.hpp:17
const C & c
Definition: Interval_glue.hpp:45
Interval< T, r > max(const Interval< T, r > &a, const Interval< T, r > &b)
Definition: Interval_fcts.hpp:135
Definition: array.hpp:12
Home