realroot_doc 0.1.1
|
Go to the source code of this file.
#define REP poly.rep() |
Definition at line 5 of file fatarcs_fcts.hpp.
Referenced by max_coeff(), min_coeff(), and pint().
#define SIZE poly.size() |
Definition at line 6 of file fatarcs_fcts.hpp.
Referenced by max_coeff(), min_coeff(), and pint().
#define SMALL C(10e-20) |
Definition at line 4 of file fatarcs_fcts.hpp.
C abs_max_coeff | ( | polynomial< C, with< Bernstein > > | poly | ) |
Definition at line 239 of file fatarcs_fcts.hpp.
References mmx::max(), max_coeff(), mmx::min(), and min_coeff().
Referenced by box_rep< C >::max_eval().
std::vector<C> approx | ( | polynomial< C, with< Bernstein > > | poly, |
std::vector< C > | ep1, | ||
std::vector< C > | ep2, | ||
int | MTH | ||
) |
Definition at line 267 of file fatarcs_fcts.hpp.
References mmx::tensor::assign(), mmx::tensor::eval(), is_unit1(), mmx::mul(), pint(), seq2b(), solve2(), and vec().
Referenced by interval_newton< INT, CT >::bisection_iteration(), median(), and interval_newton< INT, CT >::newton_iteration().
{ polynomial< C ,with<MonomialTensor> > xt, yt, res, monp, mp("x0-x0^2"); polynomial< C ,with<Bernstein> > bxt, byt; C t, I; Seq<C> sols; std::vector<C> movec; if (ep2.size()==0 ){movec=ep1;} else{ tensor::assign(monp.rep(),poly.rep()); Seq<C> endptsx,endptsy; endptsx<<ep2[0]<<ep1[0]; endptsy<<ep2[1]<<ep1[1]; bxt=seq2b(endptsx); tensor::assign(xt.rep(),bxt.rep()); byt=seq2b(endptsy); tensor::assign(yt.rep(),byt.rep()); Seq<polynomial< C ,with<MonomialTensor> > > param; param<<xt<<yt; tensor::eval(res, monp.rep(), param, 1); C c0,c1; tensor::eval(c0,res.rep(),C(0)); tensor::eval(c1,res.rep(),C(1)); mul(res,mp); I=pint(res); C u=C(15)*I-C(0.75)*(c0+c1); sols=solve2(c0+c1-C(2)*u,C(2)*(u-c0),c0); if(is_unit1(sols[0])) {t=sols[0]; movec=vec(ep1[0]*t+ep2[0]*(C(1)-t),ep1[1]*t+ep2[1]*(C(1)-t));} else if(is_unit1(sols[1])) {t=sols[1]; movec=vec(ep1[0]*t+ep2[0]*(C(1)-t),ep1[1]*t+ep2[1]*(C(1)-t));} else{movec=std::vector<C>();} } return movec; }; /*approx bivar bbpoly along line*/
polynomial< C ,with<Bernstein> > bbasis | ( | C | co, |
int | n, | ||
int | deg | ||
) |
Definition at line 159 of file fatarcs_fcts.hpp.
References mmx::binomial(), and mmx::mul().
Referenced by seq2b().
int binomial | ( | int | n, |
int | p | ||
) |
Definition at line 145 of file fatarcs_fcts.hpp.
{ int n1=1; if(p!=0) { if((n-p)<p){ p=n-p;}; int n2=n; for(int i=1;i<=p;i++){ n1=n1*n2/i; n2--;}; } return(n1); }/*binomials*/
Definition at line 360 of file fatarcs_fcts.hpp.
References arc_rep< C >::arc_eq(), is_small(), solve2(), and vec().
Referenced by extpts().
{ Seq<C> eh1= c1.arc_eq(), eh2= c2.arc_eq(), sx, a; C Aeh,Ceh; if(!is_small(eh1[1]) && !is_small(eh1[2]) && !is_small(eh2[1]) && !is_small(eh2[2])){ if(is_small(eh1[0]) && is_small(eh2[0])){ Aeh=(C(-1)*eh2[1])/(eh2[2]); Ceh=(C(-1)*eh2[3])/(eh2[2]); sx[0]=(C(-1)*eh1[2]*Ceh-eh1[3])/(eh1[2]*Aeh+eh1[1]); ispts[0]=vec(sx[0],Aeh*sx[0]+Ceh); ispts[1]=vec(sx[0],Aeh*sx[0]+Ceh); } else{ if(!is_small(eh1[0]) && !is_small(eh2[0])){ eh1=eh1/eh1[0]; eh2=eh2/eh2[0]; Aeh=(eh2[1]-eh1[1])/(eh1[2]-eh2[2]); Ceh=(eh2[3]-eh1[3])/(eh1[2]-eh2[2]);} else{ if(is_small(eh1[0]) && !is_small(eh2[0])){a=eh1; eh1=eh2; eh2=a;}; eh1=eh1/eh1[0]; Aeh=(C(-1)*eh2[1])/(eh2[2]); Ceh=(C(-1)*eh2[3])/(eh2[2]);}; sx=solve2(C(1)+Aeh*Aeh, C(2)*Aeh*Ceh+eh1[1]+eh1[2]*Aeh, Ceh*Ceh+eh1[2]*Ceh+eh1[3]); ispts[0]=vec(sx[0],Aeh*sx[0]+Ceh); ispts[1]=vec(sx[1],Aeh*sx[1]+Ceh); } } else{ ispts[0]=vec(C(-1),C(-1)); ispts[1]=vec(C(-1),C(-1)); }; };/*cicrcle intersections (numerical behaviour!)*/
Definition at line 251 of file fatarcs_fcts.hpp.
References mmx::eval(), and vec().
std::vector<C> crossrat | ( | std::vector< C > | v1, |
std::vector< C > | v2, | ||
std::vector< C > | v3, | ||
std::vector< C > | v4 | ||
) |
C dot | ( | std::vector< C > | p, |
std::vector< C > | q | ||
) |
Definition at line 28 of file fatarcs_fcts.hpp.
Referenced by arc_rep< C >::arc_eq(), arc_rep< C >::midc(), v_length(), and arc_rep< C >::weight().
{ C v=C(0); for(unsigned i=0; i<p.size(); i++){ v +=p[i]*q[i]; } return(v); };
Definition at line 423 of file fatarcs_fcts.hpp.
References circ_is(), arc_rep< C >::critpt(), is_arc(), is_infatarc(), is_unit2(), arc_rep< C >::offset(), arc_rep< C >::pts, Seq< C, R >::size(), and vec().
Referenced by solver_mv_fatarcs< C >::box_gen().
{ arc_rep<C> c1p=mc1.offset(r1),c1m=mc1.offset(C(-1)*r1), c2p=mc2.offset(r2),c2m=mc2.offset(C(-1)*r2); std::vector<C> p[2]; Seq< std::vector<C> > ispts; if(is_arc(c1p) && is_arc(c2p)){ circ_is(p,c1p,c2p); if(is_unit2(p[0])){ispts<<p[0];}; if(is_unit2(p[1])){ispts<<p[1];};}; if(is_arc(c1p) && is_arc(c2m)){ circ_is(p,c1p,c2m); if(is_unit2(p[0])){ispts<<p[0];}; if(is_unit2(p[1])){ispts<<p[1];};}; if(is_arc(c1m) && is_arc(c2m)){ circ_is(p,c1m,c2m); if(is_unit2(p[0])){ispts<<p[0];}; if(is_unit2(p[1])){ispts<<p[1];};}; if(is_arc(c1m) && is_arc(c2p)){ circ_is(p,c1m,c2p); if(is_unit2(p[0])){ispts<<p[0];}; if(is_unit2(p[1])){ispts<<p[1];};}; if(is_arc(c1p) && is_infatarc(c1p.pts[0],c2m,c2p)){ispts<<c1p.pts[0];}; if(is_arc(c1p) && is_infatarc(c1p.pts[2],c2m,c2p)){ispts<<c1p.pts[2];}; if(is_arc(c1m) && is_infatarc(c1m.pts[0],c2m,c2p)){ispts<<c1m.pts[0];}; if(is_arc(c1m) && is_infatarc(c1m.pts[2],c2m,c2p)){ispts<<c1m.pts[2];}; if(is_arc(c2p) && is_infatarc(c2p.pts[0],c1m,c1p)){ispts<<c2p.pts[0];}; if(is_arc(c2p) && is_infatarc(c2p.pts[2],c1m,c1p)){ispts<<c2p.pts[2];}; if(is_arc(c2m) && is_infatarc(c2m.pts[0],c1m,c1p)){ispts<<c2m.pts[0];}; if(is_arc(c2m) && is_infatarc(c2m.pts[2],c1m,c1p)){ispts<<c2m.pts[2];}; if(is_arc(c1p) && is_infatarc(c1p.critpt(0),c2m,c2p)){ispts<<c1p.critpt(0);}; if(is_arc(c1p) && is_infatarc(c1p.critpt(1),c2m,c2p)){ispts<<c1p.critpt(1);}; if(is_arc(c1m) && is_infatarc(c1m.critpt(0),c2m,c2p)){ispts<<c1m.critpt(0);}; if(is_arc(c1m) && is_infatarc(c1m.critpt(1),c2m,c2p)){ispts<<c1m.critpt(1);}; if(is_arc(c2p) && is_infatarc(c2p.critpt(0),c1m,c1p)){ispts<<c2p.critpt(0);}; if(is_arc(c2p) && is_infatarc(c2p.critpt(1),c1m,c1p)){ispts<<c2p.critpt(1);}; if(is_arc(c2m) && is_infatarc(c2m.critpt(0),c1m,c1p)){ispts<<c2m.critpt(0);}; if(is_arc(c2m) && is_infatarc(c2m.critpt(1),c1m,c1p)){ispts<<c2m.critpt(1);}; Seq< std::vector<C> > cpts; cpts<<vec(C(0),C(0));cpts<<vec(C(0),C(1));cpts<<vec(C(1),C(0));cpts<<vec(C(1),C(1)); for(unsigned i=0; i<cpts.size(); i++){ if( is_infatarc(cpts[i],c1m,c1p) && is_infatarc(cpts[i],c2m,c2p) ){ ispts<<cpts[i]; }; }; return ispts; };
bool is_arc | ( | arc_rep< C > | c | ) |
Definition at line 406 of file fatarcs_fcts.hpp.
References arc_rep< C >::pts.
Referenced by solver_mv_fatarcs< C >::box_gen(), extpts(), is_infatarc(), and arc_rep< C >::offset().
Definition at line 413 of file fatarcs_fcts.hpp.
References crossrat(), is_arc(), and arc_rep< C >::pts.
Referenced by extpts().
bool is_small | ( | C | p | ) |
Definition at line 101 of file fatarcs_fcts.hpp.
Referenced by circ_is(), box_rep< C >::corner_event(), median(), and solve2().
{ if(p==C(0)){return true;} else{return false;} };
bool is_unit1 | ( | C | p | ) |
Definition at line 129 of file fatarcs_fcts.hpp.
Referenced by approx(), arc_rep< C >::critpt(), is_unit2(), median(), and arc_rep< C >::offset().
{ if(p<C(0) || p>C(1) ){return false;} else{return true;} };/*1dim unit test*/
bool is_unit2 | ( | std::vector< C > | p | ) |
bool is_zero | ( | C | p | ) |
Definition at line 95 of file fatarcs_fcts.hpp.
{ if(p==C(0)){return true;} else{return false;} };
std::vector<C> matrat | ( | std::vector< C > | v1, |
std::vector< C > | v2 | ||
) |
Definition at line 80 of file fatarcs_fcts.hpp.
References vec().
Referenced by arc_rep< C >::arc_eq(), arc_rep< C >::arc_rep(), and crossrat().
{ std::vector<C> mm; mm=vec(v1[0]*v2[0]+v1[1]*v2[1],v1[0]*v2[1]-v2[0]*v1[1]); return(mm); };
C max_coeff | ( | polynomial< C, with< Bernstein > > | poly | ) |
Definition at line 223 of file fatarcs_fcts.hpp.
References mmx::max(), REP, and SIZE.
Referenced by abs_max_coeff(), and box_rep< C >::not_empty().
Definition at line 314 of file fatarcs_fcts.hpp.
References approx(), is_small(), is_unit1(), box_rep< C >::poly, rotl(), mmx::size(), v_div(), v_minus(), v_plus(), and vec().
{ std::vector<C> endp[2], mpts[3]; int s=0; arc_rep<C> medc; for(int i=0; i<3; i++){mpts[i]=std::vector<C>();}; mpts[0]=approx(box.poly, list[0], list[1], MTH); mpts[1]=approx(box.poly, list[2], list[3], MTH); if( mpts[0].size()!=0 && mpts[1].size()!=0 ){ std::vector<C> mid, rvec, v; mid=v_div(v_plus(mpts[0],mpts[1]),C(2)); rvec=rotl(v_minus(mpts[0],mpts[1])); C bval[4]; if(!is_small(rvec[0])){ bval[0]=rvec[1]*C(-1)*mid[0]/rvec[0]+mid[1]; bval[1]=rvec[1]*(C(1)-mid[0])/rvec[0]+mid[1];}else{ bval[0]=C(-1); bval[1]=C(-1);} if(!is_small(rvec[1])){ bval[2]=rvec[0]*C(-1)*mid[1]/rvec[1]+mid[0]; bval[3]=rvec[0]*(C(1)-mid[1])/rvec[1]+mid[0];}else{ bval[2]=C(-1); bval[3]=C(-1);} if(is_unit1(bval[0]) && s<2){endp[s]= vec(C(0),bval[0]); s++;}; if(is_unit1(bval[1]) && s<2){endp[s]= vec(C(1),bval[1]); s++;}; if(is_unit1(bval[2]) && s<2){endp[s]= vec(bval[2],C(0)); s++;}; if(is_unit1(bval[3]) && s<2){endp[s]= vec(bval[3],C(1)); s++;}; mpts[2]=mpts[1]; if(s==2){ mpts[1]=approx(box.poly, endp[0], endp[1], MTH);} if(mpts[1].size()!=0){ medc=arc_rep<C>(mpts);}else{medc=arc_rep<C>();} //else{ for(int i=0; i<3; i++){mpts[i]= vec(C(-1),C(-1));};} }else{ medc=arc_rep<C>(); }; //std::cout <<"med: "<<mpts[0]<<" "<<mpts[1]<<" "<<mpts[2]<<std::endl; return(medc); }; /*median arc computation*/
C min_coeff | ( | polynomial< C, with< Bernstein > > | poly | ) |
Definition at line 208 of file fatarcs_fcts.hpp.
References mmx::min(), REP, and SIZE.
Referenced by abs_max_coeff(), box_rep< C >::max_eval(), box_rep< C >::min_grad(), and box_rep< C >::not_empty().
Definition at line 467 of file fatarcs_fcts.hpp.
References domain< C >::delta(), and domain< C >::I.
Referenced by solver_mv_fatarcs< C >::box_gen().
{ domain<C> newbox=box; C minx,maxx,miny,maxy; if(ispts.size()==0){newbox=domain<C>(int(0));}else{ int k=0; for(unsigned i=0; i<ispts.size(); i++){ if(k==0){ minx=ispts[i][0]; maxx=ispts[i][0]; miny=ispts[i][1]; maxy=ispts[i][1]; k++;}; if(ispts[i][0]>maxx){maxx=ispts[i][0];}; if(ispts[i][0]<minx){minx=ispts[i][0];}; if(ispts[i][1]>maxy){maxy=ispts[i][1];}; if(ispts[i][1]<miny){miny=ispts[i][1];}; }; Interval<C> Jx( minx, maxx), Jy( miny, maxy) ; if((maxx-minx)>C(0) && (maxy-miny)>C(0)) { newbox= domain<C>( box.I[0].m + box.delta()[0]*Jx , box.I[1].m + box.delta()[1]*Jy ); }; } return(newbox); };/*minmax box for the arc intersection points and arc end points*/
C pint | ( | polynomial< C, with< MonomialTensor > > | poly | ) |
void pow | ( | polynomial< C, with< Bernstein > > & | poly, |
int | n | ||
) |
Definition at line 171 of file fatarcs_fcts.hpp.
References mmx::mul().
{ polynomial< C ,with<Bernstein> > t=poly; for(int i=1; i<n; i++){ mul(poly, t); }; }/*nth power of a bbpoly*/
std::vector<C> rotl | ( | std::vector< C > | p | ) |
Definition at line 23 of file fatarcs_fcts.hpp.
References vec().
Referenced by median(), arc_rep< C >::midc(), and arc_rep< C >::offset().
{ std::vector<C> v; v=vec(C(-1)*p[1],p[0]); return(v); }; /*rotate left*/
Definition at line 181 of file fatarcs_fcts.hpp.
References mmx::add(), bbasis(), and Seq< C, R >::size().
Referenced by approx(), arc_rep< C >::critpt(), and box_rep< C >::max_eval().
Seq<C> solve2 | ( | C | a, |
C | b, | ||
C | c | ||
) |
Definition at line 115 of file fatarcs_fcts.hpp.
References is_small(), mmx::sign(), and mmx::sqrt().
Referenced by approx(), circ_is(), and arc_rep< C >::offset().
std::vector<C> v_div | ( | std::vector< C > | p, |
C | q | ||
) |
Definition at line 57 of file fatarcs_fcts.hpp.
Referenced by median(), arc_rep< C >::midc(), and arc_rep< C >::offset().
{ if (q!=C(0)){ std::vector<C> v(p.size(),C(0)); for(unsigned i=0; i<p.size(); i++){ v[i]=p[i]/q;}; return(v);}else{return std::vector<C>();} };
C v_length | ( | std::vector< C > | p | ) |
Definition at line 75 of file fatarcs_fcts.hpp.
References dot(), and mmx::sqrt().
Referenced by arc_rep< C >::offset(), and arc_rep< C >::weight().
std::vector<C> v_minus | ( | std::vector< C > | p, |
std::vector< C > | q | ||
) |
Definition at line 47 of file fatarcs_fcts.hpp.
References assert.
Referenced by arc_rep< C >::arc_eq(), arc_rep< C >::arc_rep(), crossrat(), median(), arc_rep< C >::midc(), arc_rep< C >::offset(), and arc_rep< C >::weight().
{ std::vector<C> v(p.size(),C(0)); assert( p.size()==q.size() ); for(unsigned i=0; i<p.size(); i++){ v[i]=p[i]-q[i]; } return(v); };
std::vector<C> v_mul | ( | C | q, |
std::vector< C > | p | ||
) |
Definition at line 66 of file fatarcs_fcts.hpp.
Referenced by arc_rep< C >::midc(), and arc_rep< C >::offset().
{ std::vector<C> v(p.size(),C(0)); for(unsigned i=0; i<p.size(); i++){ v[i]=p[i]*q; } return(v); };
std::vector<C> v_plus | ( | std::vector< C > | p, |
std::vector< C > | q | ||
) |
Definition at line 37 of file fatarcs_fcts.hpp.
References assert.
Referenced by median(), arc_rep< C >::midc(), and arc_rep< C >::offset().
{ std::vector<C> v(p.size(),C(0)); assert( p.size()==q.size() ); for(unsigned i=0; i<p.size(); i++){ v[i]=p[i]+q[i]; } return(v); };
std::vector<C> vec | ( | const C | c1, |
const C | c2 | ||
) |
Definition at line 16 of file fatarcs_fcts.hpp.
Referenced by approx(), arc_rep< C >::arc_eq(), circ_is(), box_rep< C >::corner_event(), corner_values(), arc_rep< C >::critpt(), box_rep< C >::event_list(), extpts(), matrat(), median(), arc_rep< C >::offset(), and rotl().
{
std::vector<C> a(2, C(0));
a[0]= c1; a[1]= c2;
return a;
}