|
realroot_doc 0.1.1
|
Box representation. More...
#include <solver_mv_monomial_box_rep.hpp>
Box representation.
Definition at line 41 of file solver_mv_monomial_box_rep.hpp.
| box_rep | ( | ) | [inline] |
Definition at line 89 of file solver_mv_monomial_box_rep.hpp.
Referenced by box_rep< POL >::safe_split(), and box_rep< POL >::subdivide().
{};
| box_rep | ( | Seq< POL > & | sys, |
| homography_mv< C > & | h | ||
| ) | [inline] |
Definition at line 91 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::S, homography_mv< real >::size(), and box_rep< POL >::update_data().
{
hg = h ;
dim= h.size();
S= sys;
update_data();
};
Definition at line 101 of file solver_mv_monomial_box_rep.hpp.
References homography_mv< real >::colapse(), box_rep< POL >::homography(), box_rep< POL >::middle(), box_rep< POL >::nbvar(), box_rep< POL >::S, homography_mv< real >::shift_hom(), and box_rep< POL >::system().
{
dim= b.nbvar();
hg = b.homography();
hg.shift_hom(b.middle(i) ,i);
hg.colapse();
S= b.system();
};
Definition at line 113 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::S.
{
dim=d;
hg = homography_mv<C>(dim) ;
//hg = homography_mv<int>(dim) ;
S= sys;
}
| ~box_rep | ( | ) | [inline] |
Definition at line 122 of file solver_mv_monomial_box_rep.hpp.
{};
| void contract_box | ( | const C & | t, |
| const int & | v | ||
| ) | [inline] |
x_v = t*x_v
Definition at line 504 of file solver_mv_monomial_box_rep.hpp.
References homography_mv< real >::contract_hom(), mmx::tensor::contraction(), mmx::rep(), box_rep< POL >::S, and Seq< C, R >::size().
Referenced by box_rep< POL >::subdivide().
{
unsigned i;
for (i = 0; i < S.size() ; ++i)
contraction( S[i].rep() , t, v);
//update homography
hg.contract_hom(t,v);
};
| C det | ( | C ** | matrix, |
| int | order | ||
| ) | [inline] |
Definition at line 204 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::submatrix().
Definition at line 236 of file solver_mv_monomial_box_rep.hpp.
{
FT l, r;
Seq<Interval<FT> > s ;
for ( unsigned i=0; i!=dim; ++i )
{
//lim to 0
if ( hg[i].b!=0 && hg[i].d!=0 )
l= as<FT>(hg[i].b)/as<FT>(hg[i].d);
else if ( hg[i].d==0 )
l= 10000000;
else if ( hg[i].b==0 )
l= 0 ;
else
l= as<FT>(hg[i].a)/as<FT>(hg[i].c) ;
//lim to inf
if ( hg[i].a!=0 && hg[i].c!=0 )
r= as<FT>(hg[i].a)/as<FT>(hg[i].c);
else if ( hg[i].c==0 )
r=10000000;
else if ( hg[i].a==0 )
r= 0 ;
else
r= as<FT>(hg[i].b)/as<FT>(hg[i].d);
if ( l<=r ) s << Interval<FT>(l,r);
else s << Interval<FT>(r,l);
}
return s;
}
Definition at line 313 of file solver_mv_monomial_box_rep.hpp.
References assert, mmx::rep(), box_rep< POL >::S, and Seq< C, R >::size().
Referenced by box_rep< POL >::exclude1(), box_rep< POL >::include1(), box_rep< POL >::include2(), box_rep< POL >::include3(), box_rep< POL >::is_root(), and box_rep< POL >::signof().
{
assert( t.size()==dim );
Seq<FT> res;
FT ev;
for ( unsigned i=0; i!=S.size() ; ++i )
{
tensor::eval( ev , S[i].rep(), t, dim );
res<< ev;
}
return res;
}
| bool exclude1 | ( | Seq< POL * > & | S0 | ) | [inline] |
Exclusion criteria (inteval arithmetic)
Definition at line 642 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::eval(), Interval< T, r >::M, Interval< T, r >::m, box_rep< POL >::nbpol(), and mmx::rep().
{
Interval<FT> ev;
Seq<Interval<FT> > dom;
dom= domain<FT>();
for (unsigned i=0; i!=nbpol(); ++i)
{
tensor::eval( ev , S0[i]->rep(),
dom , dim );
if ( ev.m*ev.M > 0 )
{
// std::cout<<i<<" ev"<<
// dom<<"\nf= "<< *(S0[1])<<
// "\n f([])= " <<ev<<std::endl;
// if (td!=0)
// std::cout<<"!!!!!!----td: "<<td <<std::endl;
return true;
}
}
return false;
};
| homography_mv<C> hom | ( | ) | [inline] |
Definition at line 232 of file solver_mv_monomial_box_rep.hpp.
{ return hg; }
| homography_mv<C> homography | ( | ) | [inline] |
Definition at line 152 of file solver_mv_monomial_box_rep.hpp.
Referenced by box_rep< POL >::box_rep().
{ return this->hg; }
| bool include1 | ( | polynomial< double, with< MonomialTensor > > * | J | ) | [inline] |
Inclusion criteria (Miranda Test)
Definition at line 555 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::eval(), Interval< T, r >::M, Interval< T, r >::m, box_rep< POL >::miranda_test(), and POL.
{
Interval<double> ev;
unsigned i,j,c,r ;
POL u,l;
bool t[dim][dim];
tensor::eval( ev , J->rep() ,
this->template domain<double>() , dim );
if ( ev.m*ev.M < 0 )
return false;
for (i=0; i!=dim;++i)
for (j=0; j!=dim;++j)
t[i][j]= miranda_test(i,j);
c=0;
for (i=0; i!=dim;++i)
for (j=0; j!=dim;++j)
if (t[i][j]==true)
{
c++; break;
}
if (c<dim) return false;
c=0;
for (i=0; i!=dim;++i)
for (j=0; j!=dim;++j)
if (t[j][i]==true)
{
c++; break;
}
if (c<dim) return false;
// std::cout<<"INCLUDE. ev="<<ev<<", c="<<c <<std::endl;
return true;
};
| bool include2 | ( | polynomial< double, with< MonomialTensor > > * | J | ) | [inline] |
Inclusion criteria (Jacobian+Topological Degree)
Definition at line 596 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::eval(), Interval< T, r >::M, and Interval< T, r >::m.
{
Interval<double> ev;
tensor::eval( ev , J->rep() ,
this->domain<double>(), dim );
// if ( this->width<double>() > 0.001 )
if ( ev.m*ev.M < 0 )
return false;
//td= this->topological_degree_2d<double>();
//if ( (td==-1 || td==1) )
//{ std::cout<<"INCLUDE. ev="<<ev<<", td="<<td <<std::endl;
//this->print(); }
return ( 0 );
}
| bool include3 | ( | polynomial< double, with< MonomialTensor > > * | J | ) | [inline] |
Inclusion criteria based on Rump's test.
Definition at line 616 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::eval(), Interval< T, r >::M, and Interval< T, r >::m.
{
//evaluate df_i(B) of the box = M_i
// check if -Ji(c)*f(c) + (I-Ji(c)*M)*B
// is contaied in B.
Interval<double> ev;
tensor::eval( ev , J->rep() ,
this->domain<double>(), dim );
// if ( this->width<double>() > 0.001 )
if ( ev.m*ev.M < 0 )
return false;
//td= this->topological_degree_2d<double>();
//if ( (td==-1 || td==1) )
//{ std::cout<<"INCLUDE. ev="<<ev<<", td="<<td <<std::endl;
//this->print(); }
return ( 0 );
}
| bool is_root | ( | Seq< C > | t | ) | [inline] |
Definition at line 327 of file solver_mv_monomial_box_rep.hpp.
References assert, box_rep< POL >::eval(), mmx::rep(), box_rep< POL >::S, and Seq< C, R >::size().
{
assert( t.size()==dim );
C ev;
for ( unsigned i=0; i!=S.size() ; ++i )
{
tensor::eval( ev , S[i].rep() , t , dim );
if ( ev != 0 )
return false;
}
return true;
}
| C l_bound | ( | const int | v | ) | [inline] |
Lower integer bound for v-th coords of the positive roots.
Definition at line 366 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::maxs(), box_rep< POL >::mins(), POL, box_rep< POL >::S, and Seq< C, R >::size().
Referenced by box_rep< POL >::reduce_domain().
{
C l(0) ;
unsigned i;
POL m0, m1 ;
for (i=0; i!=S.size(); ++i ) // for all polys
{
m1= maxs( & S[i] , v);
m0= mins( & S[i] , v);
//std::cout<< m1<< " , "<< m0 << std::endl;
if ( m0( C(0) ) > 0 )
l= solver<ring<C,MonomialTensor>, CFfirstFloor>::template solve<C>(m0);
// l= as<C>( solver<ring<double,Bernstein>, Bspline>::first_root(m0) );
else if ( m1( C(0) ) < 0 )
l= solver<ring<C,MonomialTensor>, CFfirstFloor>::template solve<C>(m1);
// l= as<C>( solver<ring<double,Bernstein>, Bspline>::first_root(m1) );
}
return l;
};
| POL lface | ( | const int & | i, |
| const int & | v | ||
| ) | [inline] |
Definition at line 694 of file solver_mv_monomial_box_rep.hpp.
References mmx::tensor::face(), POL, mmx::tensor::rename_var(), and box_rep< POL >::S.
{
POL t;
tensor::face(t, S[i], v , 0 );
rename_var( t.rep() , 1-v, 0 ) ; //1-v works for 2D only
return t;
};
| POL maxs | ( | POL * | f, |
| int | v | ||
| ) | [inline] |
Definition at line 397 of file solver_mv_monomial_box_rep.hpp.
References POL.
Referenced by box_rep< POL >::l_bound().
{
POL h(0,f->rep().szs()[v]-1,0) ;//var is always x0
tensor::maxs(h.rep(), f->rep(), v );
return h;
};
| Seq<C> middle | ( | ) | [inline] |
Definition at line 269 of file solver_mv_monomial_box_rep.hpp.
Referenced by box_rep< POL >::box_rep(), box_rep< POL >::subdiv_center(), and box_rep< POL >::update_data().
{
Seq<C> m;
for ( unsigned i=0; i!=dim; ++i )
m << as<C>( floor( as<double>(hg[i].d/hg[i].c) )) ; //floor
return (m);
}
| C middle | ( | int | i | ) | [inline] |
Definition at line 277 of file solver_mv_monomial_box_rep.hpp.
{
C t;
t= as<C>( floor( as<double>(hg[i].d/hg[i].c) )); //floor
//if ( t==C(0) ) t=t+1;
return (t+1);
}
| POL mins | ( | POL * | f, |
| int | v | ||
| ) | [inline] |
Definition at line 389 of file solver_mv_monomial_box_rep.hpp.
References POL.
Referenced by box_rep< POL >::l_bound().
{
POL h(0,f->rep().szs()[v]-1,0) ;//var is always x0
tensor::mins(h.rep(), f->rep(), v );
return h;
};
| bool miranda_test | ( | const int | i, |
| const int | j | ||
| ) | [inline] |
Definition at line 540 of file solver_mv_monomial_box_rep.hpp.
References mmx::tensor::face(), mmx::realroot::no_variation(), POL, and box_rep< POL >::S.
Referenced by box_rep< POL >::include1().
{
POL u,l;
tensor::face(l, S[i], j, 0);
tensor::face(u, S[i], j, 1);
return ( no_variation(l) &&
no_variation(u) &&
(l[0]>0)!=(u[0]>0) );
};
| unsigned nbpol | ( | ) | [inline] |
Definition at line 155 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::S, and Seq< C, R >::size().
Referenced by box_rep< POL >::exclude1().
{ return S.size(); }
| unsigned nbvar | ( | ) | [inline] |
Definition at line 154 of file solver_mv_monomial_box_rep.hpp.
Referenced by box_rep< POL >::box_rep().
{ return dim; }
Definition at line 287 of file solver_mv_monomial_box_rep.hpp.
References assert, and Seq< C, R >::size().
Referenced by box_rep< POL >::update_data().
{
assert( t.size()==dim );
Seq<FT> m;
for ( unsigned i=0; i!=dim; ++i )
m << ( as<FT>(hg[i].a)*(t[i]) + as<FT>(hg[i].b) ) /
( as<FT>(hg[i].c)*(t[i]) + as<FT>(hg[i].d) ) ;
return m;
}
| void print | ( | ) | [inline] |
Definition at line 713 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::system().
{
std::cout << "-------------Box---------------" << "\n" ;
std::cout << system() << "\n";
for (unsigned i=0; i!=dim;++i)
std::cout<< "("<<hg[i].a <<"x + " << hg[i].b<<")/("<<hg[i].c<<"x+ "<<hg[i].d << ")"<<std::endl; ;
//std::cout<<"td="<<tdeg()<<std::endl;
// std::cout << this->template domain<QQ>()<<"\n" ;
std::cout << this->template domain<double>()<<"\n" ;
std::cout << "-------------------------------" << "\n" ;
};
| bool reduce_domain | ( | ) | [inline] |
Reduce the domain from below using integer lower bound.
Definition at line 342 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::l_bound(), box_rep< POL >::shift_box(), and box_rep< POL >::update_data().
{
C lb;
unsigned i;
bool flag= false; // true iff reduction takes place
Seq<C> track;
//Compute lower bound and shift system
for ( i=0; i<dim ;++i) // for all vars
{
lb= l_bound(i);
track<< lb;
if ( lb!=0 )
{
this->shift_box(lb,i);
update_data();
flag= true;
}
}
return flag;
};
Definition at line 124 of file solver_mv_monomial_box_rep.hpp.
References homography_mv< real >::contract_hom(), mmx::tensor::contraction(), mmx::reciprocal(), homography_mv< real >::reciprocal_hom(), mmx::rep(), box_rep< POL >::S, mmx::shift(), homography_mv< real >::shift_hom(), Seq< C, R >::size(), box_rep< POL >::update_data(), and box_rep< POL >::width().
{
//Seq<Interval<int> > dom;
//let::assign(dom,dom0);
unsigned i,j;
for (i=0; i!=dim; i++)
{
hg.shift_hom ( dom0[i].m , i );
hg.contract_hom ( dom0[i].width(), i );
hg.reciprocal_hom( 1 , i );
hg.shift_hom ( 1 , i );
hg.reciprocal_hom( 1 , i );//mirror again
for (j=0; j!=S.size(); j++)
{
shift ( S[j].rep(), dom0[i].m , i);
contraction( S[j].rep(), dom0[i].width(), i);
reciprocal ( S[j].rep(), i);
shift ( S[j].rep(), C(1), i);
reciprocal ( S[j].rep(), i);//mirror again
}
}
update_data();
}
| void reverse_and_shift_box | ( | const int & | v | ) | [inline] |
Definition at line 526 of file solver_mv_monomial_box_rep.hpp.
References mmx::reciprocal(), homography_mv< real >::reciprocal_hom(), mmx::rep(), box_rep< POL >::S, mmx::shift(), homography_mv< real >::shift_hom(), and Seq< C, R >::size().
Referenced by box_rep< POL >::subdivide().
| void reverse_box | ( | const int & | v | ) | [inline] |
Definition at line 516 of file solver_mv_monomial_box_rep.hpp.
References mmx::reciprocal(), homography_mv< real >::reciprocal_hom(), mmx::rep(), box_rep< POL >::S, and Seq< C, R >::size().
Referenced by box_rep< POL >::subdivide().
{
for (unsigned i = 0; i < S.size() ; ++i) //for all polys
reciprocal( S[i].rep() , v);
//update homography
hg.reciprocal_hom(1,v);
};
| POL rface | ( | const int & | i, |
| const int & | v | ||
| ) | [inline] |
Definition at line 704 of file solver_mv_monomial_box_rep.hpp.
References mmx::tensor::face(), POL, mmx::tensor::rename_var(), and box_rep< POL >::S.
{
POL tmp;
tensor::face(tmp, S[i], v , 1 );
rename_var( tmp.rep() , 1-v, 0 ) ; //1-v works for 2D only
return tmp;
};
| void safe_split | ( | const int & | v, |
| C | m = C(1) |
||
| ) | [inline] |
Subdivide in direction v only.
Definition at line 437 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::box_rep().
| void shift_box | ( | const C & | t, |
| const int & | v = 0 |
||
| ) | [inline] |
Shift the system by t in direction v.
Definition at line 492 of file solver_mv_monomial_box_rep.hpp.
References mmx::rep(), box_rep< POL >::S, mmx::shift(), homography_mv< real >::shift_hom(), and Seq< C, R >::size().
Referenced by box_rep< POL >::reduce_domain(), and box_rep< POL >::subdivide().
| int signof | ( | polynomial< double, with< MonomialTensor > > * | p | ) | [inline] |
Definition at line 217 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::eval().
{
Interval<double> ev;
//int dim= p->nbvar();
tensor::eval( ev , p->rep() ,
this->template domain<double>() , dim );
if (ev< .1e-15) return (0);
return (ev>0?1:-1);
}
| int signof_det | ( | polynomial< double, with< MonomialTensor > > ** | p | ) | [inline] |
Definition at line 172 of file solver_mv_monomial_box_rep.hpp.
{
return p[0];
}
| Seq<C> subdiv_center | ( | const unsigned & | i | ) | [inline] |
Definition at line 297 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::middle(), and Seq< C, R >::resize().
Referenced by box_rep< POL >::subdiv_point().
{
Seq<C> tt;
// Seq<double> t;
tt.resize( dim );
tt[i]= this->middle(i);
return tt;
}
| Seq<double> subdiv_point | ( | const unsigned & | i | ) | [inline] |
Definition at line 307 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::subdiv_center().
{
return this->template point<double>(this->subdiv_center(i));
}
| void subdivide | ( | STACK & | stck | ) | [inline] |
Subdivide in all directions.
Definition at line 406 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::box_rep(), box_rep< POL >::reverse_and_shift_box(), box_rep< POL >::shift_box(), and box_rep< POL >::update_data().
{
int i;
Seq<int> ind(dim);
box_rep * b;
for (;;)
{
// copy box
b = new box_rep( *this ) ;
// transform box
for (i = 0; i < dim ; ++i) // for all vars
if ( ind[i] )
b->shift_box(1,i);
else
b->reverse_and_shift_box(i);
b->update_data();
// push box in stack
stck.push ( b );
// next
for (i = 0; i < dim ; ++i)
if (++ind[i] <2 ) break; else ind[i]=0 ;
if (i == dim ) break;
}
};
| void subdivide | ( | const int & | v, |
| STACK & | stck, | ||
| C | m = C(1) |
||
| ) | [inline] |
Subdivide in direction v only.
Definition at line 451 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::box_rep(), box_rep< POL >::contract_box(), box_rep< POL >::reverse_and_shift_box(), box_rep< POL >::shift_box(), and box_rep< POL >::update_data().
| void subdivide | ( | const int & | v, |
| C & | m, | ||
| STACK & | stck | ||
| ) | [inline] |
Subdivide in direction v and at point x_v=m.
Definition at line 471 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::box_rep(), box_rep< POL >::contract_box(), box_rep< POL >::reverse_and_shift_box(), box_rep< POL >::reverse_box(), box_rep< POL >::shift_box(), and box_rep< POL >::update_data().
| int** submatrix | ( | C ** | matrix, |
| int | order, | ||
| int | i, | ||
| int | j | ||
| ) | [inline] |
Definition at line 179 of file solver_mv_monomial_box_rep.hpp.
Referenced by box_rep< POL >::det().
{
C **subm;
int p, q; // Indexes for matrix
int a = 0, b; // Indexes for subm
subm = new int* [order - 1];
for(p = 0; p < order; p++) {
if(p==i) continue; //Skip ith row
subm[a] = new C[order - 1];
b = 0;
for(q = 0; q< order; q++) {
if(q==j) continue; //Skip jth column
subm[a][b++] = matrix[p][q];
}
a++; //Increment row index
}
return subm;
}
| POL system | ( | const int | i | ) | [inline] |
Definition at line 233 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::S.
{ return S[i]; }
| Seq<POL> system | ( | ) | [inline] |
Accessors.
Definition at line 151 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::S.
Referenced by box_rep< POL >::box_rep(), and box_rep< POL >::print().
{ return S; }
| POL system | ( | unsigned | i | ) | [inline] |
Definition at line 153 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::S.
{ return S[i]; }
| void update_data | ( | ) | [inline] |
Definition at line 58 of file solver_mv_monomial_box_rep.hpp.
References box_rep< POL >::middle(), box_rep< POL >::point(), box_rep< POL >::S, and Seq< C, R >::size().
Referenced by box_rep< POL >::box_rep(), box_rep< POL >::reduce_domain(), box_rep< POL >::restrict(), and box_rep< POL >::subdivide().
{
//C t;
// scale coefficients
#ifdef DIVISION
for( unsigned i=0; i<S.size(); i++ ){
t= *std::max_element( (S[i]).begin(), (S[i]).end() );
S[i]= S[i]/t;
}
#endif
// Precondition
Seq<double> c= this->point( this->middle() ) ;
//double *fc, *jc, *ijc;
Seq<POL> S1= S;
// DPOL * J= jacobian(S1);
// jc= eval_poly_matrix( c, J, dim); // Jacobian evaluated on c
// ijc= new double[dim*dim];
// linear::LUinverse(ijc, jc, dim);
// for( unsigned i=0; i<dim; i++ ){
// S[i]=0;
// for( unsigned j=0; j<dim; j++ )
// S[i] += ijc[i*dim+j] * S1[j] ;
// }
}
| FT volume | ( | ) | [inline] |
Definition at line 158 of file solver_mv_monomial_box_rep.hpp.
References Seq< C, R >::size(), and box_rep< POL >::width().
{
Seq<Interval<FT> > s;
FT v(1);
s= domain<FT>();
for (unsigned i=0; i!=s.size(); i++ )
v *= s[i].width();
return v;
}
| FT width | ( | unsigned & | t | ) | [inline] |
The width, corresponding max projection returned in t.
Definition at line 678 of file solver_mv_monomial_box_rep.hpp.
References Seq< C, R >::size(), and box_rep< POL >::width().
{
unsigned i;
FT w;
Seq<Interval<FT> > s ;
s= domain<FT>();
w= s[0].width(); t= 0;
for ( i=0; i!=s.size(); ++i )
if ( s[i].width() > w)
{ w=s[i].width() ; t=i; }
return w;
};
| FT width | ( | ) | [inline] |
The width of the box (max of projection widths)
Definition at line 668 of file solver_mv_monomial_box_rep.hpp.
Referenced by box_rep< POL >::restrict(), box_rep< POL >::volume(), and box_rep< POL >::width().
{
unsigned i;
FT m=this->width<FT>(i);
return m;
};
Definition at line 56 of file solver_mv_monomial_box_rep.hpp.
Referenced by box_rep< POL >::box_rep(), box_rep< POL >::contract_box(), box_rep< POL >::eval(), box_rep< POL >::is_root(), box_rep< POL >::l_bound(), box_rep< POL >::lface(), box_rep< POL >::miranda_test(), box_rep< POL >::nbpol(), box_rep< POL >::restrict(), box_rep< POL >::reverse_and_shift_box(), box_rep< POL >::reverse_box(), box_rep< POL >::rface(), box_rep< POL >::shift_box(), box_rep< POL >::system(), and box_rep< POL >::update_data().