diff --git a/src/math/math_FunctionRoots.cxx b/src/math/math_FunctionRoots.cxx index f25b8c3a0b..7610829d87 100755 --- a/src/math/math_FunctionRoots.cxx +++ b/src/math/math_FunctionRoots.cxx @@ -9,6 +9,7 @@ #include #include #include +#include //#ifdef WNT #include //#endif @@ -236,14 +237,14 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, Standard_Real X=X0; Standard_Boolean Ok; double dx = (XN-X0)/N; - double *ptrval = new Standard_Real [N+1]; + TColStd_Array1OfReal ptrval(0, N); Standard_Integer Nvalid = -1; Standard_Real aux = 0; for(i=0; i<=N ; i++,X+=dx) { if( X > XN) X=XN; Ok=F.Value(X,aux); - if(Ok) ptrval[++Nvalid] = aux - K; -// ptrval[i]-=K; + if(Ok) ptrval(++Nvalid) = aux - K; +// ptrval(i)-=K; } //-- Toute la fonction est nulle ? @@ -255,7 +256,7 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, AllNull=Standard_True; // for(i=0;AllNull && i<=N;i++) { for(i=0;AllNull && i<=N;i++) { - if(ptrval[i]>EpsNull || ptrval[i]<-EpsNull) { + if(ptrval(i)>EpsNull || ptrval(i)<-EpsNull) { AllNull=Standard_False; } } @@ -273,18 +274,18 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, for(i=0,ip1=1,X=X0;i XN) X2 = XN; - if(ptrval[i]<0.0) { - if(ptrval[ip1]>0.0) { + if(ptrval(i)<0.0) { + if(ptrval(ip1)>0.0) { //-- -------------------------------------------------- //-- changement de signe dans Xi Xi+1 - Solve(F,K,X,ptrval[i],X2,ptrval[ip1],tol,NEpsX,Sol,NbStateSol); + Solve(F,K,X,ptrval(i),X2,ptrval(ip1),tol,NEpsX,Sol,NbStateSol); } } else { - if(ptrval[ip1]<0.0) { + if(ptrval(ip1)<0.0) { //-- -------------------------------------------------- //-- changement de signe dans Xi Xi+1 - Solve(F,K,X,ptrval[i],X2,ptrval[ip1],tol,NEpsX,Sol,NbStateSol); + Solve(F,K,X,ptrval(i),X2,ptrval(ip1),tol,NEpsX,Sol,NbStateSol); } } } @@ -295,7 +296,7 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, //-- Si (F(u0)-K)*(F(u1)-K) <0 on lance une recherche //-- Sinon si (F(u0)-K)*(F(u1)-K) !=0 on insere le point X for(i=0; i<=N; i++) { - if(ptrval[i]==0) { + if(ptrval(i)==0) { // Standard_Real Val,Deriv; X=X0+i*dx; if (X>XN) X=XN; @@ -321,10 +322,10 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, } //-- -------------------------------------------------------------------------------- //-- Il faut traiter differement le cas des points en bout : - if(ptrval[0]<=EpsF && ptrval[0]>=-EpsF) { + if(ptrval(0)<=EpsF && ptrval(0)>=-EpsF) { AppendRoot(Sol,NbStateSol,X0,F,K,NEpsX); } - if(ptrval[N]<=EpsF && ptrval[N]>=-EpsF) { + if(ptrval(N)<=EpsF && ptrval(N)>=-EpsF) { AppendRoot(Sol,NbStateSol,XN,F,K,NEpsX); } @@ -344,8 +345,8 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, for(i=1,xm=X0+dx; i XN) xm=XN; - if(ptrval[i]>0.0) { - if((ptrval[im1]>ptrval[i]) && (ptrval[ip1]>ptrval[i])) { + if(ptrval(i)>0.0) { + if((ptrval(im1)>ptrval(i)) && (ptrval(ip1)>ptrval(i))) { //-- Peut on traverser l axe Ox //-- -------------- Estimation a partir de Xim1 xm1=xm-dx; @@ -371,8 +372,8 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, } } } - else if(ptrval[i]<0.0) { - if((ptrval[im1]