Return an error code instead of asserting to please CGAL test suite

This commit is contained in:
Laurent Saboret 2006-03-28 10:07:13 +00:00
parent d5f6332ecf
commit e2e4323dd7
2 changed files with 10 additions and 5 deletions

View File

@ -137,7 +137,8 @@ public:
while ( rTr>err && its < max_iter) {
mult(A,d,Ad);
rTAd=BLAS<Vector>::dot(rT,Ad);
assert( ! IsZero(rTAd) );
if (IsZero(rTAd))
break; // stop if bad conditioning
alpha=rTh/rTAd;
BLAS<Vector>::axpy(-alpha,Ad,r);
BLAS<Vector>::copy(h,s);
@ -156,8 +157,10 @@ public:
BLAS<Vector>::axpy(-omega,s,x);
BLAS<Vector>::copy(s,h);
BLAS<Vector>::axpy(-omega,t,h);
assert( ! IsZero(omega) );
assert( ! IsZero(rTh) );
if (IsZero(omega))
break; // stop if bad conditioning
if (IsZero(rTh))
break; // stop if bad conditioning
beta=(alpha/omega)/rTh; rTh=BLAS<Vector>::dot(rT,h); beta*=rTh;
BLAS<Vector>::scal(beta,d);
BLAS<Vector>::axpy(1,h,d);

View File

@ -136,11 +136,13 @@ public:
rho=BLAS<Vector>::dot(p,p);
sig=BLAS<Vector>::dot(r,p);
tau=BLAS<Vector>::dot(g,r);
assert( ! IsZero(sig) );
if (IsZero(sig))
break; // stop if bad conditioning
t=tau/sig;
BLAS<Vector>::axpy(t,r,x);
BLAS<Vector>::axpy(-t,p,g);
assert( ! IsZero(tau) );
if (IsZero(tau))
break; // stop if bad conditioning
gam=(t*t*rho-tau)/tau;
BLAS<Vector>::scal(gam,r);
BLAS<Vector>::axpy(1,g,r);