Arbitrary Solvers?

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

Arbitrary Solvers?

Daniel H

Hello All,

 

Would it be possible to genericize CashFlows::yield (and by extension BondFunctions::yield) to take an arbitrary solver, instead of the default NewtonSafe solver?

 

Using a template parameter with a default value would have been backwards compatible but alas, using default template values is not possible pre-C++11 and QuantLib does not currently support dynamic dispatch for solvers so it cannot be passed into the function either.

 

Are there any possibilities of creating a patch to use an arbitrary solver at runtime? I would be happy to code it up.

 

Thanks,

DH


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Arbitrary Solvers?

Luigi Ballabio
Hi,
    you can add a template overload of CashFlows::yield. Since it would take an instance of the solver, it wouldn't cause an ambiguity with the existing method.

Luigi


On Tue, Oct 18, 2016 at 4:24 PM Daniel Hrabovcak <[hidden email]> wrote:

Hello All,

 

Would it be possible to genericize CashFlows::yield (and by extension BondFunctions::yield) to take an arbitrary solver, instead of the default NewtonSafe solver?

 

Using a template parameter with a default value would have been backwards compatible but alas, using default template values is not possible pre-C++11 and QuantLib does not currently support dynamic dispatch for solvers so it cannot be passed into the function either.

 

Are there any possibilities of creating a patch to use an arbitrary solver at runtime? I would be happy to code it up.

 

Thanks,

DH

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev