Hi,
I have been messing around with QuantLib for a while now and have decided to join the mailing lists. I have a few questions: What is the anticipated use of some of the structure classes (ie ZeroYieldStructure, the date stuff). Should people use these classes in their programs to create new products etc, or do people generally stick to using classes like Option etc. Do you plan to include things like modelling vanilla bonds, futures contracts etc for completeness? What are the customer iterators used for?? I cant work out what they do! Same goes for the index class! That's all for now I think!! Regards Ben |
Ben wrote:
>I have been messing around with QuantLib for a while now and have decided >to join the mailing lists. welcome aboard >What is the anticipated use of some of the structure classes (ie >ZeroYieldStructure, the date stuff). Should people use these classes in >their programs to create new products etc, or do people generally stick to >using classes like Option etc. Please use all QuantLib classes! Low level classes are probably better for a gradual introduction of QuantLib into an existing environment. QuantLib last releases is 0.2.1 and is marked as beta, so you can expect some class refactoring while approaching QuantLib 1.0. We will do our best to be backward compatible at least on a release-by-release level. The worse you can expect is the deprecation of a feature you're using: in this case you know the next release will not support that feature and take your action. Using the Nightly Build link on the quantlib site you can take a look at the forthcoming 0.3.0 release >Do you plan to include things like modelling vanilla bonds, futures >contracts etc for completeness? Sure! Unfortunately I cannot commit to a deadline .... always looking for volunteers >What are the customer iterators used for?? I cant work out what they do! I wouldn't dare to answer this on a mailing list subscribed by Luigi Ballabio ;-) Luigi please .... >Same goes for the index class! The index class should/will handle indexes like Euribor 3M, Libor 6M, etc. We may need a better name. The index class is/should-be/wiil-be able to calculate forecast based on a term structure and provide past fixings while taking care of all the index conventions (day count, following, etc) ciao -- Nando |
Hi all and welcome Ben,
At 10:24 AM 1/9/02 +0100, Ferdinando Ametrano wrote: >Ben wrote: >>What are the customer iterators used for?? I cant work out what they do! >I wouldn't dare to answer this on a mailing list subscribed by Luigi >Ballabio ;-) >Luigi please .... Well, well. You know adulation will lead you nowhere :) However: those iterators are meant to build a sequence on the fly from one or more other sequences, without having to allocate place for storing it. A couple of examples: suppose we have a function which calculates the average of a sequence, and that for genericity we have implemented it as a template function which takes the beginning and the end of the sequence, so that its declaration is: template <class Iterator> typename Iterator::value_type average(const Iterator& begin, const Iterator& end) This kind of genericity allows one to use the same function to calculate the average of a std::vector, a std::list, a QuantLib::History, any other container, of a subset of any of the former. Now let's say we have two sequences of numbers, and we want to calculate the average of their products. One approach could be to store the products in another sequence, and to calculate the average of the latter, as in: // we have sequence1 and sequence2 and assume equal size: // first we store their product in a vector... std::vector<double> products; std::transform(sequence1.begin(),sequence1.end(), // first sequence sequence2.begin(), // second sequence std::back_inserter(products), // where to put the output std::multiplies<double>()); // what operation to perform // ...then we calculate the average double result = average(products.begin(),products.end()); The above works, however, it might be not particularly efficient since we have to allocate the product vector, quite possibly just to throw it away when the calculation is done. QuantLib::Utilities::coupling_iterator allows us to do the same thing without allocating the extra vector: what we do is simply: // we have sequence1 and sequence2 and assume equal size: double result = average( make_coupling_iterator(sequence1.begin(), sequence2.begin(), std::multiplies<double()), make_coupling_iterator(sequence1.end(), sequence2.end(), std::multiplies<double())); The call to make_coupling_iterator creates an iterator which is really a reference to the two iterators and the operation we passed. Dereferencing such iterator returns the result of applying such operation to the values pointed to by the two contained iterators. Advancing the coupling iterator advances the two underlying ones. You can see how iterating on such iterator is quite an alliteration but generates the products one by one so that they can be processed by average(), but does not need allocating memory for storing the results. The product sequence is generated on the fly. The other iterators share the same principle but have different functionalities: - combining_iterator is the same of coupling_iterator, but works on N sequences while the latter works on 2; - filtering_iterator generates the elements of a given sequence which satisfy a given predicate, i.e., it takes a sequence [x_0,x_1,...] and a predicate p and generates the sequence of those x_i for which p(x_i) returns true; - processing_iterator takes a sequence [x_0,x_1,...] and a function f and generates the sequence [f(x_0),f(x_1),...]; - stepping_iterator takes a sequence [x_0,x_1,...] and a step m and generates the sequence [x_0,x_m,x_2m,...] Hope this helped, Luigi |
Free forum by Nabble | Edit this page |