diff -cr oommf12a3/app/oxs/ext/uzeeman.cc oommf/app/oxs/ext/uzeeman.cc *** oommf12a3/app/oxs/ext/uzeeman.cc Tue Jun 18 23:36:00 2002 --- oommf/app/oxs/ext/uzeeman.cc Wed Mar 26 22:00:16 2003 *************** *** 65,79 **** i,hrange[i].c_str()); throw Oxs_Ext::Error(this,buf); } ! h0*=hmult; ! h1*=hmult; ! if(step_count==0 || Happ.size()==0 || Happ.back()!=h0 ) { Happ.push_back(h0); } ! for(UINT4m j=1;j<=step_count;j++) { ! REAL8m t = REAL8m(j)/REAL8m(step_count); Happ.push_back(((1-t)*h0) + (t*h1)); } } DeleteInitValue("Hrange"); VerifyAllInitArgsUsed(); --- 65,98 ---- i,hrange[i].c_str()); throw Oxs_Ext::Error(this,buf); } ! // Note: There is a potential problem comparing Happ.back() to h0 if ! // any floating point operations have occured on either. If those ! // operations are not exactly the same, there may be differences in ! // round-off error. Even if they are written the same in the source ! // code, if the compiler is given license to re-order floating point ! // ops, then the results may differ. Also, there may be differences ! // between values loaded from memory and those stored in registers. ! // The code below attempts to work around these issues. ! if(step_count==0 || Happ.size()==0) { Happ.push_back(h0); + } else { + ThreeVector last_h1 = Happ.back(); + if(fabs(last_h1.x-h0.x)>fabs(h0.x)*REAL8_EPSILON*2 + || fabs(last_h1.y-h0.y)>fabs(h0.y)*REAL8_EPSILON*2 + || fabs(last_h1.z-h0.z)>fabs(h0.z)*REAL8_EPSILON*2) { + Happ.push_back(h0); + } } ! for(UINT4m j=1;j(j)/static_cast(step_count); Happ.push_back(((1-t)*h0) + (t*h1)); } + if(step_count>0) Happ.push_back(h1); + } + vector::iterator it = Happ.begin(); + while(it!=Happ.end()) { + *it *= hmult; + ++it; } DeleteInitValue("Hrange"); VerifyAllInitArgsUsed();