QuantLib causing Python kernel restart

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

QuantLib causing Python kernel restart

net316
Hi,

Thanks in advance for your help and I apologize if the issue is trivial/obvious to everyone but me.

I am trying to run the below in python and the kernel shuts down everytime. 
The e = , f= , g= lines cause the problem.

from QuantLib import *
a = [1,2,3,4,5]
b = [11,12,13,14,15]
a= DoubleVector(a)
b = DoubleVector(b)
e = LinearInterpolation (a,b)
f = BicubicSpline(a.begin() , a.end() , b.begin())
g = CubicNaturalSpline(a , b)

Flannery O'Connor

------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib causing Python kernel restart

Luigi Ballabio
Hello,
    DoubleVector is the wrong type; it should be Array (truth be told,
I'm not sure how SWIG allows you to pass it at all; it should give a
type error).
Anyway: you can use the right type, but it's also possible to pass
lists directly. Code like

from QuantLib import *
a = [1,2,3,4,5]
b = [11,12,13,14,15]
e = LinearInterpolation(a,b)

will work without forcing the types. As for BicubicSplines, it doesn't
want iterators. It's a 2-d interpolation, so the three arguments
should be the array of the x, the array of the y, and the matrix of
the corresponding z defined so that z[i][j] = f(x[i], y[j]). Again, no
need to force the types: you can write

x = [1,2,3]
y = [1,2]
z = [[1,2,3],
     [4,5,6]]
f = BicubicSpline(x,y,z)

Luigi



On Thu, Aug 14, 2014 at 6:42 AM,  <[hidden email]> wrote:

> Hi,
>
> Thanks in advance for your help and I apologize if the issue is
> trivial/obvious to everyone but me.
>
> I am trying to run the below in python and the kernel shuts down everytime.
> The e = , f= , g= lines cause the problem.
>
> from QuantLib import *
> a = [1,2,3,4,5]
> b = [11,12,13,14,15]
> a= DoubleVector(a)
> b = DoubleVector(b)
> e = LinearInterpolation (a,b)
> f = BicubicSpline(a.begin() , a.end() , b.begin())
> g = CubicNaturalSpline(a , b)
>
> Flannery O'Connor
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>



--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users