|
From: Tom A. <tw...@ur...> - 2020-11-23 23:49:46
|
On Mon, 23 Nov 2020, da...@el... wrote:
> Thanks for coming back on this Matthias.
>
> Seems QL_NULL_REAL could be just what I am after.
Or an instance of a more general method:
Real x = Null<Real>();
The point being that you can write the same thing but for other types, eg
i think this is meaningful:
Date d = Null<Date>();
If you really just want a NaN, you can also write std::nan(""); no need to
involve QuantLib there.
tom
> From: mat...@gm... <mat...@gm...>
> Sent: Monday, 23 November 2020 18:18
> To: da...@el...; qua...@li...
> Subject: RE: [Quantlib-users] Using NaN in Quantlib
>
>
>
> Hi David,
>
>
>
> Because of (c), I assume you are talking about the C++ version of QuantLib.
>
>
>
> There is, for example, this: https://github.com/lballabio/QuantLib/blob/60afa352713bac2b759332686ed3070d357cfde8/ql/utilities/null.hpp#L76
>
> Referencing: https://github.com/lballabio/QuantLib/blob/60afa352713bac2b759332686ed3070d357cfde8/ql/qldefines.hpp#L181
>
>
>
> I see there is also https://github.com/lballabio/QuantLib/blob/60afa352713bac2b759332686ed3070d357cfde8/ql/math/matrixutilities/sparsematrix.hpp#L68
>
> Maybe a similar wrapper for something like vector_sparse.hpp in boost/uBLAS could also work (better) for your use case?
>
>
>
> Best regards,
>
> Matthias
>
>
>
>
>
> From: da...@el... <mailto:da...@el...> <da...@el... <mailto:da...@el...> >
> Sent: Monday, 23 November 2020 18:25
> To: qua...@li... <mailto:qua...@li...>
> Subject: [Quantlib-users] Using NaN in Quantlib
>
>
>
> Hi, hope everyone is well.
>
>
>
> A simple question: does QuantLib define NaN somewhere? I have a sparse QuantLib::Array and want to set un-used elements to NaN so I can see which elements are valid and which aren’t.
>
> a) Is there any conceptual problem with this?
> b) how do I set a Real to NaN in QL?
> c) should I be using a std::vector instead, which could hold a pair<bool,Real> with the bool used to denote a valid value?
>
>
>
>
> Thanks
>
> David Sansom
>
>
--
I wish I had a cool hobby but I don't care about anything, anyway good
job. -- IceWizard9000 |