mirror of https://github.com/CGAL/cgal
the ultimate fix
This commit is contained in:
parent
5cf6d40842
commit
ddc70eb66c
|
|
@ -70,11 +70,11 @@ solve_1(const NT &a_, const NT &b_, const NT &c_, OutputIterator oit)
|
||||||
Root_of_1 a(cast(a_)), b(cast(b_)), c(cast(c_));
|
Root_of_1 a(cast(a_)), b(cast(b_)), c(cast(c_));
|
||||||
|
|
||||||
if ( a != 0 ) {
|
if ( a != 0 ) {
|
||||||
Root_of_1 a0_ (-b/2*a);
|
Root_of_1 a0_ (-b/(2*a));
|
||||||
Root_of_1 root_(CGAL_NTS square(a0_) - c/a);
|
Root_of_1 root_(CGAL_NTS square(a0_) - c/a);
|
||||||
switch(CGAL::sign(root_)){
|
switch(CGAL::sign(root_)){
|
||||||
case CGAL::NEGATIVE: return oit;
|
case CGAL::NEGATIVE: return oit;
|
||||||
case CGAL::ZERO: return *oit++ = Root_of_2(a0_);
|
case CGAL::ZERO: *oit++ = Root_of_2(a0_); return oit;
|
||||||
default:
|
default:
|
||||||
// two roots
|
// two roots
|
||||||
*oit++ = make_root_of_2(a0_,Root_of_1(-1),root_);
|
*oit++ = make_root_of_2(a0_,Root_of_1(-1),root_);
|
||||||
|
|
@ -83,7 +83,7 @@ solve_1(const NT &a_, const NT &b_, const NT &c_, OutputIterator oit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return *oit++ = -c/b;
|
*oit++ = -c/b; return oit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,12 @@ void test_root_of_traits(){
|
||||||
assert(roots.size()==2);
|
assert(roots.size()==2);
|
||||||
assert(roots[0]==-CGAL::make_sqrt(T(2)) || is_not_exact );
|
assert(roots[0]==-CGAL::make_sqrt(T(2)) || is_not_exact );
|
||||||
assert(roots[1]== CGAL::make_sqrt(T(2)) || is_not_exact );
|
assert(roots[1]== CGAL::make_sqrt(T(2)) || is_not_exact );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Root_of_2 roots[2]= {Root_of_2(1),Root_of_2(1)};
|
||||||
|
CGAL::solve_1(T(13),T(4),T(-23),roots);
|
||||||
|
assert(roots[0]==CGAL::make_root_of_2(T(13),T(4),T(-23),true) || is_not_exact );
|
||||||
|
assert(roots[1]==CGAL::make_root_of_2(T(13),T(4),T(-23),false) || is_not_exact );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::vector<Root_of_2> roots;
|
std::vector<Root_of_2> roots;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue