ianbe
09-01-2009, 08:18 AM
Hi
i used Dave's test spline program in this thread
http://www.nr.com/forum/showthread.php?t=1693&highlight=spline_interp
which worked fine in a VS C++ project on its own. However, ramp up the samples and it fails beyond 2^10 ( 1024). I also implemented the struct in my existing project which compiled ok, and cout'd the ff double being passed to it before the return, but fails to seek the value in the input VecDoub xx failing at Base_interp.locate(Base_interp* , Double x)
line 25. with a memory violation error.
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other me
mory is corrupt.
Below is the struct
struct Spline_wrapper {
Spline_interp* my_func;
Doub lam;
Spline_wrapper(VecDoub xx, VecDoub yy) {
static Spline_interp my_funcc(xx,yy);
my_func = &my_funcc;
}
double operator()(const double ff ) {
return log(exp(my_func->interp(ff)))+ lam ;
}
};
and below is the implementation extract in my main
for (int k=0; k < n ; k++) {
spline.lam = lambda[n+1-k] ;
pactual = log(exp(x[k]))+lambda[n+1-k];
pinterp = spline(x[k]) ;
perror = pinterp - pactual ;
the funny things with this error was that when i change the length of the VecDoub x(2^16) to x(2^8) I get a different error
ERROR: Bad input to routine splint
in file c:\dissertation\code\cppdev\dissertation_07050466\ dissertation_07050466\interp_1d.h at line 214
Unhandled Exception: System.Runtime.InteropServices.SEHException: External component has thrown an exception.
at _CxxThrowException(Void* , _s__ThrowInfo* )
at Spline_interp.rawinterp(Spline_interp* , Int32 jl, Double xv) in c:\dissertation\code\cppdev\dissertation_07050466\ dissertation_070504
66\interp_1d.h:line 214
at Base_interp.interp(Base_interp* , Double x) in c:\dissertation\code\cppdev\dissertation_07050466\ dissertation_07050466\interp_1d.h:lin
e 12
at Spline_wrapper.()(Spline_wrapper* , Double ff) in c:\dissertation\code\cppdev\dissertation_07050466\ dissertation_07050466\dissertation
_07050466.cpp:line 75
at main(String[] args) in c:\dissertation\code\cppdev\dissertation_07050466\ dissertation_07050466\dissertation_07050466.cpp:li ne 454
at mainCRTStartupStrArray(String[] arguments) in f:\dd\vctools\crt_bld\self_x86\crt\src\mcrtexe.cpp :line 309
it just doesn't like this line
spline(x[k])
and complains about access to the value. probably because the Spline routine cannot read in the 2^16 values in the VecDoub "x" given in the call to the struct
Spline_wrapper spline(x,q);
any ideas on how I can fix this ?
Thanks
Ian
i used Dave's test spline program in this thread
http://www.nr.com/forum/showthread.php?t=1693&highlight=spline_interp
which worked fine in a VS C++ project on its own. However, ramp up the samples and it fails beyond 2^10 ( 1024). I also implemented the struct in my existing project which compiled ok, and cout'd the ff double being passed to it before the return, but fails to seek the value in the input VecDoub xx failing at Base_interp.locate(Base_interp* , Double x)
line 25. with a memory violation error.
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other me
mory is corrupt.
Below is the struct
struct Spline_wrapper {
Spline_interp* my_func;
Doub lam;
Spline_wrapper(VecDoub xx, VecDoub yy) {
static Spline_interp my_funcc(xx,yy);
my_func = &my_funcc;
}
double operator()(const double ff ) {
return log(exp(my_func->interp(ff)))+ lam ;
}
};
and below is the implementation extract in my main
for (int k=0; k < n ; k++) {
spline.lam = lambda[n+1-k] ;
pactual = log(exp(x[k]))+lambda[n+1-k];
pinterp = spline(x[k]) ;
perror = pinterp - pactual ;
the funny things with this error was that when i change the length of the VecDoub x(2^16) to x(2^8) I get a different error
ERROR: Bad input to routine splint
in file c:\dissertation\code\cppdev\dissertation_07050466\ dissertation_07050466\interp_1d.h at line 214
Unhandled Exception: System.Runtime.InteropServices.SEHException: External component has thrown an exception.
at _CxxThrowException(Void* , _s__ThrowInfo* )
at Spline_interp.rawinterp(Spline_interp* , Int32 jl, Double xv) in c:\dissertation\code\cppdev\dissertation_07050466\ dissertation_070504
66\interp_1d.h:line 214
at Base_interp.interp(Base_interp* , Double x) in c:\dissertation\code\cppdev\dissertation_07050466\ dissertation_07050466\interp_1d.h:lin
e 12
at Spline_wrapper.()(Spline_wrapper* , Double ff) in c:\dissertation\code\cppdev\dissertation_07050466\ dissertation_07050466\dissertation
_07050466.cpp:line 75
at main(String[] args) in c:\dissertation\code\cppdev\dissertation_07050466\ dissertation_07050466\dissertation_07050466.cpp:li ne 454
at mainCRTStartupStrArray(String[] arguments) in f:\dd\vctools\crt_bld\self_x86\crt\src\mcrtexe.cpp :line 309
it just doesn't like this line
spline(x[k])
and complains about access to the value. probably because the Spline routine cannot read in the 2^16 values in the VecDoub "x" given in the call to the struct
Spline_wrapper spline(x,q);
any ideas on how I can fix this ?
Thanks
Ian