Posted by
Kakhkhor Abdijalilov on
Jul 05, 2010; 9:51pm
URL: http://quantlib.414.s1.nabble.com/small-improvements-tp13335.html
I was looking into QuantLib implementation recently and noticed
several things which could be improved (IMHO). These aren't really
bugs, more like small issues related to documentation, coding style
and efficiency. Here is my list.
=============================================================
1. generalstatistics.hpp
In reset() method use "the swap trick" to reset the vector of
samples. The assignment
of an empty vector doesn't free the storage. (Item 17 in
"Effective STL").
Doxygen for percentile() should say something like this:
Smallest x from the sample, such that P(X<=x) >= y.
Doxygen for topPercentile() should say somthing like this:
Largest x from the sample, such that P(X>=x) >= y.
2. capfloortermvolcurve.hpp.
Use private inheritance from boost::noncopyable.
3. longstaffschwartzpathpricer.hpp
It is very hard to understand what is going on here.
\code
std::transform(paths_.begin(), paths_.end(), prices.begin(),
boost::bind(&EarlyExercisePathPricer<PathType>
::operator(),
pathPricer_.get(), _1, len-1));
\endcode
Can we replace it with this simple loop?
\code
for(Size i=0; i<n; ++i)
prices[i] = (*pathPricer_)(paths_[i], len-1);
\endcode
At the end of LongstaffSchwartzPathPricer::calibrate() use "the
swap trick" to reset
the vector paths_, instead of using paths_.clear(). Clearing a
vector doesn't free the storage.
The calibration of LongstaffSchwartzPathPricer requires tons of
memory. We better to free
all the memory used by the vector paths_.
5. instrument.hpp
"virtual" can be omitted from the declaration of 'performCalculations'.
6. randomsequencegenerator.hpp
Document that both RNG::next() and RNG::nextInt32() are required.
7. timergrid.cpp
replace times_.reserve(steps) with times_.reserve(steps+1), because times_
stores steps+1 values.
=============================================================
Regards,
Kakhkhor Abdijalilov.
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first --
http://p.sf.net/sfu/sprint-com-first_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev