Commit 237eb47b by Francois Gygi

### Use Context pointer. Null pointer for local use. Changed default value of theta…

Use Context pointer. Null pointer for local use. Changed default value of theta for negative curvature case to 0.0 (more conservative).

git-svn-id: http://qboxcode.org/svn/qb/trunk@310 cba15fb0-1239-40c8-b417-11db7ca47a34
parent 98ede4fb
 ... @@ -3,7 +3,7 @@ ... @@ -3,7 +3,7 @@ // AndersonMixer.C // AndersonMixer.C // // //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // $Id: AndersonMixer.C,v 1.1 2004-12-02 22:24:16 fgygi Exp$ // $Id: AndersonMixer.C,v 1.2 2004-12-10 01:04:06 fgygi Exp$ #include "AndersonMixer.h" #include "AndersonMixer.h" #include "blas.h" #include "blas.h" ... @@ -34,10 +34,13 @@ void AndersonMixer::update(const double* f, double* theta, double* fbar) ... @@ -34,10 +34,13 @@ void AndersonMixer::update(const double* f, double* theta, double* fbar) // b = delta_F * delta_F // b = delta_F * delta_F double b = ddot(&n_, &tmp0[0], &ione, &tmp0[0], &ione); double b = ddot(&n_, &tmp0[0], &ione, &tmp0[0], &ione); if ( pctxt_ != 0 ) { double work[2] = { a, b }; double work[2] = { a, b }; ctxt_.dsum(2,1,work,2); pctxt_->dsum(2,1,work,2); a = work[0]; a = work[0]; b = work[1]; b = work[1]; } if ( b != 0.0 ) if ( b != 0.0 ) *theta = - a / b; *theta = - a / b; ... @@ -47,7 +50,7 @@ void AndersonMixer::update(const double* f, double* theta, double* fbar) ... @@ -47,7 +50,7 @@ void AndersonMixer::update(const double* f, double* theta, double* fbar) // test if residual has increased // test if residual has increased if ( *theta <= -1.0 ) if ( *theta <= -1.0 ) { { *theta = 1.0; *theta = 0.0; } } *theta = min(theta_max_,*theta); *theta = min(theta_max_,*theta); ... ...
 ... @@ -3,7 +3,7 @@ ... @@ -3,7 +3,7 @@ // AndersonMixer.h // AndersonMixer.h // // //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // $Id: AndersonMixer.h,v 1.1 2004-12-02 22:24:16 fgygi Exp$ // $Id: AndersonMixer.h,v 1.2 2004-12-10 01:04:06 fgygi Exp$ #ifndef ANDERSONMIXER_H #ifndef ANDERSONMIXER_H #define ANDERSONMIXER_H #define ANDERSONMIXER_H ... @@ -17,7 +17,7 @@ using namespace std; ... @@ -17,7 +17,7 @@ using namespace std; class AndersonMixer class AndersonMixer { { int n_; // size of vectors int n_; // size of vectors const Context ctxt_; const Context* const pctxt_; // pointer to relevant Context, null if local double theta_max_; double theta_max_; valarray flast_; // last residual valarray flast_; // last residual ... @@ -25,8 +25,8 @@ class AndersonMixer ... @@ -25,8 +25,8 @@ class AndersonMixer public: public: AndersonMixer(const int n, const Context& ctxt) : AndersonMixer(const int n, const Context* const pctxt) : n_(n), ctxt_(ctxt), extrapolate_(false), theta_max_(2.0) n_(n), pctxt_(pctxt), extrapolate_(false), theta_max_(2.0) { { assert( n > 0 ); assert( n > 0 ); flast_.resize(n); flast_.resize(n); ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!