|
From: Simon I. <Sim...@fs...> - 2010-12-14 13:48:34
|
Unfortunately not; McSimulation::value() instantiates a result_type (i.e. an Array) from a vector<double> obtained from the sampleAccumulator at several points (also in ::valueWithSamples()). Therefore, Array would need a new constructor either: 1) explicit Array(const std::vector<Real>&); or 2) template<class container> explicit Array(const container&, container::value_type redundant = 0); or 3) template <class T> explicit Array(const T&); plus specialisations for T=Array and T=Size etc. The first works only with a STL vector. The second one allows all STL containers but is opaque because of the redundant second parameter (required to specialise only for STL containers). The third means that the existing constructors are duplicated (or removed entirely). Which would you recommend? Simon -----Original Message----- From: Luigi Ballabio [mailto:lui...@gm...] Sent: 09 December 2010 11:29 To: Simon Ibbotson Cc: qua...@li... Subject: RE: [Quantlib-dev] Returning multiple values from a Monte-Carlo pricing engine On Fri, 2010-12-03 at 15:57 +0000, Simon Ibbotson wrote: > The problem is that MonteCarloModel::addSamples(Size samples) does some > simple arithmetic operations on the result_type. Also, > McSimulation::value() and McSimulation::calculate() do some other simple > operations. Right, I overlooked those. Hmm. As far as I see, MonteCarloModel::addSamples would work if one used Array as the result type (it has algebra, and SequenceStatistics:add takes any container regardless of what it uses internally.) I don't see the calculations in McSimulation::value(), apart from the call to maxError that should work on any container. Does the thing work if you use just use Array as the result type, without other modifications? Luigi -- Better to have an approximate answer to the right question than a precise answer to the wrong question. -- John Tukey as quoted by John Chambers This communication and any attachments contains information which is confidential and may be subject to legal privilege. It is for intended recipients only. If you are not the intended recipient you must not copy, distribute, publish, rely on or otherwise use it without our consent. Some of our communications may contain confidential information which it could be a criminal offence for you to disclose or use without authority. If you have received this email in error please notify pos...@fs... immediately and delete the email from your computer. The FSA reserves the right to monitor all email communications for compliance with legal, regulatory and professional standards. This email is not intended to nor should it be taken to create any legal relations or contractual relationships. This email has originated from The Financial Services Authority (FSA) 25 The North Colonnade, Canary Wharf, London E14 5HS United Kingdom Registered as a Limited Company in England and Wales No.1920623. Registered Office as above Switchboard: 020 7066 1000 Web Site: http://www.fsa.gov.uk ***************************************************************** |