ebertolazzi / Splines

Various Splines Interpolation classes
Other
140 stars 23 forks source link

runtime_error #6

Closed LiJiangnanBit closed 5 years ago

LiJiangnanBit commented 5 years ago

If I uncomment the line

#define SPLINES_DO_NOT_USE_GENERIC_CONTAINER 1

There will be a runtime_error when running the codes on README

terminate called after throwing an instance of 'std::runtime_error' what(): In spline: CubicSpline line: 506 file: src/Splines.hh search(1.1) empty spline Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

Here's my code

#include <iostream>
#include "Splines.hh"
using namespace SplinesLoad ;
using namespace std;
int main() {
    CubicSpline spline ;

    spline . pushBack( 1, 3 ) ;
    spline . pushBack( 2, 1 ) ;
    spline . pushBack( 3, 1 ) ;
    spline . pushBack( 4, 3 ) ;
    spline . build() ;

    cout << spline(1.1) << '\n';     // spline at x = 1.1
    cout << spline.D(1.1) << '\n';   // spline first derivative at x = 1.1
    cout << spline.DD(1.1) << '\n';  // spline second derivative at x = 1.1
    cout << spline.DDD(1.1) << '\n'; // spline third derivative at x = 1.1
    return 0;
}

It works fine if the line is kept commented.

ebertolazzi commented 5 years ago

On 4 Jan 2019, at 03:30, Li Jiangnan notifications@github.com wrote:

If I uncomment the line

define SPLINES_DO_NOT_USE_GENERIC_CONTAINER 1

There will be a runtime_error when running the codes on README

terminate called after throwing an instance of 'std::runtime_error' what(): In spline: CubicSpline line: 506 file: src/Splines.hh search(1.1) empty spline Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

Compiled with clang++ and g++ (version 8) I have no problem.

I suppose that you have compiled the library with

define SPLINES_DO_NOT_USE_GENERIC_CONTAINER 1

commented and then linked with your code compiled with

define SPLINES_DO_NOT_USE_GENERIC_CONTAINER 1

commented. This cannoet be done. In the new version I added a file SplineConfig.hh to be more clear. If you change SplineConfig.hh you must recompile the library.

regards,

Here's my code

include

# include "Splines.hh" using namespace SplinesLoad ; using namespace std; int main () { CubicSpline spline ;

spline . 

pushBack( 1, 3 ) ; spline . pushBack( 2, 1 ) ; spline . pushBack( 3, 1 ) ; spline . pushBack( 4, 3 ) ; spline . build () ;

cout << 

spline(1.1) << '\n'; // spline at x = 1.1

cout << spline.

D(1.1) << '\n'; // spline first derivative at x = 1.1

cout << spline.

DD(1.1) << '\n'; // spline second derivative at x = 1.1

cout << spline.

DDD(1.1) << '\n'; // spline third derivative at x = 1.1

return 0 ; }

It works fine if the line is kept commented.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Enrico Bertolazzi


Dipartimento di Ingegneria Industriale
Università degli Studi di Trento http://www.ing.unitn.it/~bertolaz