[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How do I fix gsl: evolve.c:317: ERROR: step dimension must match evoluti
From: |
Bo Johnson |
Subject: |
How do I fix gsl: evolve.c:317: ERROR: step dimension must match evolution size |
Date: |
Mon, 11 Nov 2019 17:06:10 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 |
I'm writing a class to generalize solving differential equations.
However, I'm getting an error I don't think should be happening. My
class looks as follows
|classDynSys{public:DynSys(constsize_tsize,doublestartTime,doubleendTime,doublestepSize,double*iState,int(*func)(double,constdouble*,double*,void*),int(*jac)(double,constdouble*,double*,double*,void*),constgsl_odeiv2_step_type*T
=gsl_odeiv2_step_rk8pd):T(T),size(size),t(startTime),t1(endTime),h(stepSize){y
=newdouble[size];y =iState;yPrev =newdouble[size];s
=gsl_odeiv2_step_alloc(T,size);c
=gsl_odeiv2_control_y_new(1e-6,0.0);e
=gsl_odeiv2_evolve_alloc(size);sys
={func,jac,size,0};}~DynSys(){delete[]y;delete[]yPrev;gsl_odeiv2_evolve_free(e);gsl_odeiv2_control_free(c);gsl_odeiv2_step_free(s);}voidstep(){printf("e
dim: %ld\n",e->dimension);printf("s dim:
%ld\n",s->dimension);printf("y: %.5f %.5f %.5f %.5f %.5f
%.5f\n",y[0],y[1],y[2],y[3],y[4],y[5]);tPrev =t;yPrev
=std::copy(y,y+size,yPrev);intstatus
=gsl_odeiv2_evolve_apply_fixed_step(e,c,s,&sys,&t,h,y);if(status
!=GSL_SUCCESS){printf("Error:
%s\n",gsl_strerror(status));throwstd::logic_error(gsl_strerror(status));}}doublegetT(){returnt;}voidsetY(double*y){y
=y;}private:constgsl_odeiv2_step_type*T;gsl_odeiv2_step*s;gsl_odeiv2_control*c;gsl_odeiv2_evolve*e;gsl_odeiv2_system
sys;constsize_tsize;doublet;doublet1;doubleh;double*y;doubletPrev;double*yPrev;};
|
||
||And in my test code for stepping
|intmain(){doublestate[]={1.0,0.0,0.0,0.796975,0.11637,0.0185312};constsize_tsize
=6;DynSyssystem(size,0.0,40.0,1e-3,state,func,jac);system.step();printf("t:
%.5f\n",system.getT());system.step();printf("t:
%.5f\n",system.getT());return0;}|
I get the error that the "step dimension must match the evolution size."
But based on my initialization and the output of the code when run, the
step dimension matches the evolution size. Any help on understanding
what's happening is appreciated.
||
--
Bo Johnson
(801) 503-2043
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- How do I fix gsl: evolve.c:317: ERROR: step dimension must match evolution size,
Bo Johnson <=