|
From: Peter C. <pca...@gm...> - 2020-11-24 11:40:53
|
When using Null<Real>() keep in mind this is defined as std::numeric_limits<float>::max)(), i.e. it is just a valid (yet big) number. So e.g. std::log(Null<Real>()) = 88.7 and not Null<Real>() like you would expect from NAN. For some use cases you might also consider boost::optional<double>. On Mon, 23 Nov 2020 at 19:56, <da...@el...> wrote: > > Thanks for coming back on this Matthias. > > Seems QL_NULL_REAL could be just what I am after. > > Best, > > David > > > > > > 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... <da...@el...> > Sent: Monday, 23 November 2020 18:25 > To: 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 > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |