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_));
|
||||
|
||||
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);
|
||||
switch(CGAL::sign(root_)){
|
||||
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:
|
||||
// two roots
|
||||
*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 {
|
||||
return *oit++ = -c/b;
|
||||
*oit++ = -c/b; return oit;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,12 @@ void test_root_of_traits(){
|
|||
assert(roots[0]==-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;
|
||||
CGAL::solve_1(T(1),T(-6),T(9),std::back_inserter(roots));
|
||||
|
|
|
|||
Loading…
Reference in New Issue