Update of /cvsroot/quantlibaddin/QuantLibAddin/qlo
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv1747/qlo
Modified Files:
enumclassregistry.cpp interpolation.cpp interpolation.hpp
typefactory.hpp
Log Message:
implement LinearInterpolation as Enumerated Class
Index: interpolation.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/interpolation.hpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** interpolation.hpp 27 Jun 2006 09:53:43 -0000 1.14
--- interpolation.hpp 30 Jun 2006 14:12:05 -0000 1.15
***************
*** 26,35 ****
namespace QuantLibAddin {
- enum LinearInterpolationType {
- Linear,
- BackwardFlat,
- ForwardFlat
- };
-
class Extrapolator :
public ObjHandler::LibraryObject<QuantLib::Extrapolator> {
--- 26,29 ----
***************
*** 40,44 ****
class LinearInterpolation : public Interpolation {
public:
! LinearInterpolation(const LinearInterpolationType t,
const std::vector<double>& x,
const std::vector<double>& y);
--- 34,38 ----
class LinearInterpolation : public Interpolation {
public:
! LinearInterpolation(const std::string &linearInterpolationType,
const std::vector<double>& x,
const std::vector<double>& y);
Index: interpolation.cpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/interpolation.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** interpolation.cpp 27 Jun 2006 09:53:43 -0000 1.11
--- interpolation.cpp 30 Jun 2006 14:12:05 -0000 1.12
***************
*** 30,34 ****
LinearInterpolation::LinearInterpolation(
! const LinearInterpolationType t,
const std::vector<double>& x,
const std::vector<double>& y) : x_(x), y_(y)
--- 30,34 ----
LinearInterpolation::LinearInterpolation(
! const std::string &linearInterpolationType,
const std::vector<double>& x,
const std::vector<double>& y) : x_(x), y_(y)
***************
*** 36,63 ****
QL_REQUIRE(x.size()==y.size(), "unmatched x/y");
! switch (t) {
! case Linear:
! libraryObject_ = boost::shared_ptr<QuantLib::Extrapolator>(
! new QuantLib::LinearInterpolation(x_.begin(),
! x_.end(),
! y_.begin()));
! break;
! case BackwardFlat:
! libraryObject_ = boost::shared_ptr<QuantLib::Extrapolator>(
! new QuantLib::BackwardFlatInterpolation(x_.begin(),
! x_.end(),
! y_.begin()));
! break;
! case ForwardFlat:
! libraryObject_ = boost::shared_ptr<QuantLib::Extrapolator>(
! new QuantLib::ForwardFlatInterpolation(x_.begin(),
! x_.end(),
! y_.begin()));
! break;
! default:
! QL_FAIL("Unknown LinearInterpolationType");
! }
!
!
}
--- 36,41 ----
QL_REQUIRE(x.size()==y.size(), "unmatched x/y");
! libraryObject_ = Create<boost::shared_ptr<QuantLib::Extrapolator> >()
! (linearInterpolationType, x_.begin(), x_.end(), y_.begin());
}
Index: enumclassregistry.cpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/enumclassregistry.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** enumclassregistry.cpp 29 Jun 2006 16:52:12 -0000 1.3
--- enumclassregistry.cpp 30 Jun 2006 14:12:05 -0000 1.4
***************
*** 23,26 ****
--- 23,29 ----
#include <ql/Instruments/quantoforwardvanillaoption.hpp>
#include <ql/PricingEngines/all.hpp>
+ #include <ql/Math/backwardflatinterpolation.hpp>
+ #include <ql/Math/forwardflatinterpolation.hpp>
+ #include <ql/Math/linearinterpolation.hpp>
#include <ql/Math/bilinearinterpolation.hpp>
#include <ql/Math/bicubicsplineinterpolation.hpp>
***************
*** 38,42 ****
namespace QuantLibAddin {
! /* *** StrikedTypePayoff - one input*** */
boost::shared_ptr<QuantLib::StrikedTypePayoff> VANILLA_Payoff(
const QuantLib::Option::Type& optionType,
--- 41,45 ----
namespace QuantLibAddin {
! /* *** StrikedTypePayoff - strike only *** */
boost::shared_ptr<QuantLib::StrikedTypePayoff> VANILLA_Payoff(
const QuantLib::Option::Type& optionType,
***************
*** 57,61 ****
new QuantLib::PercentageStrikePayoff(optionType, moneyness));
}
! /* *** StrikedTypePayoff - two inputs*** */
boost::shared_ptr<QuantLib::StrikedTypePayoff> SUPERSHARE_Payoff(
const QuantLib::Option::Type& optionType,
--- 60,64 ----
new QuantLib::PercentageStrikePayoff(optionType, moneyness));
}
! /* *** StrikedTypePayoff - strike & strikeIncrement *** */
boost::shared_ptr<QuantLib::StrikedTypePayoff> SUPERSHARE_Payoff(
const QuantLib::Option::Type& optionType,
***************
*** 80,84 ****
}
! /* *** PricingEngine - no timesteps *** */
boost::shared_ptr<QuantLib::PricingEngine> AB_Engine() {
return boost::shared_ptr<QuantLib::PricingEngine> (
--- 83,87 ----
}
! /* *** PricingEngine - without timesteps *** */
boost::shared_ptr<QuantLib::PricingEngine> AB_Engine() {
return boost::shared_ptr<QuantLib::PricingEngine> (
***************
*** 165,169 ****
}
! /* *** PricingEngine - timesteps *** */
boost::shared_ptr<QuantLib::PricingEngine> AEQPB_Engine(const long& timeSteps) {
return boost::shared_ptr<QuantLib::PricingEngine> (
--- 168,172 ----
}
! /* *** PricingEngine - with timesteps *** */
boost::shared_ptr<QuantLib::PricingEngine> AEQPB_Engine(const long& timeSteps) {
return boost::shared_ptr<QuantLib::PricingEngine> (
***************
*** 203,212 ****
}
! /* *** Extrapolator *** */
boost::shared_ptr<QuantLib::Extrapolator> BilinearInterpolation_Extrapolator(
! const std::vector<double>::const_iterator& xBegin,
! const std::vector<double>::const_iterator& xEnd,
! const std::vector<double>::const_iterator& yBegin,
! const std::vector<double>::const_iterator& yEnd,
const QuantLib::Matrix& zData) {
return boost::shared_ptr<QuantLib::Extrapolator>(
--- 206,231 ----
}
! /* *** Extrapolator - 1D *** */
! boost::shared_ptr<QuantLib::Extrapolator> LinearInterpolation_Extrapolator(
! dbl_itr& xBegin, dbl_itr& xEnd, dbl_itr& yBegin) {
! return boost::shared_ptr<QuantLib::Extrapolator>(
! new QuantLib::LinearInterpolation(
! xBegin, xEnd, yBegin));
! }
! boost::shared_ptr<QuantLib::Extrapolator> BackwardFlatInterpolation_Extrapolator(
! dbl_itr& xBegin, dbl_itr& xEnd, dbl_itr& yBegin) {
! return boost::shared_ptr<QuantLib::Extrapolator>(
! new QuantLib::BackwardFlatInterpolation(
! xBegin, xEnd, yBegin));
! }
! boost::shared_ptr<QuantLib::Extrapolator> ForwardFlatInterpolation_Extrapolator(
! dbl_itr& xBegin, dbl_itr& xEnd, dbl_itr& yBegin) {
! return boost::shared_ptr<QuantLib::Extrapolator>(
! new QuantLib::ForwardFlatInterpolation(
! xBegin, xEnd, yBegin));
! }
! /* *** Extrapolator - 2D *** */
boost::shared_ptr<QuantLib::Extrapolator> BilinearInterpolation_Extrapolator(
! dbl_itr& xBegin, dbl_itr& xEnd, dbl_itr& yBegin, dbl_itr& yEnd,
const QuantLib::Matrix& zData) {
return boost::shared_ptr<QuantLib::Extrapolator>(
***************
*** 215,222 ****
}
boost::shared_ptr<QuantLib::Extrapolator> BicubicSpline_Extrapolator(
! const std::vector<double>::const_iterator& xBegin,
! const std::vector<double>::const_iterator& xEnd,
! const std::vector<double>::const_iterator& yBegin,
! const std::vector<double>::const_iterator& yEnd,
const QuantLib::Matrix& zData) {
return boost::shared_ptr<QuantLib::Extrapolator>(
--- 234,238 ----
}
boost::shared_ptr<QuantLib::Extrapolator> BicubicSpline_Extrapolator(
! dbl_itr& xBegin, dbl_itr& xEnd, dbl_itr& yBegin, dbl_itr& yEnd,
const QuantLib::Matrix& zData) {
return boost::shared_ptr<QuantLib::Extrapolator>(
***************
*** 267,270 ****
--- 283,289 ----
REG_ENUM(QuantLib::Extrapolator,
+ MAP("Linear", LinearInterpolation_Extrapolator);
+ MAP("BackwardFlat", BackwardFlatInterpolation_Extrapolator);
+ MAP("ForwardFlat", ForwardFlatInterpolation_Extrapolator);
MAP("BiLinear", BilinearInterpolation_Extrapolator);
MAP("BiCubic", BicubicSpline_Extrapolator);
Index: typefactory.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/typefactory.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** typefactory.hpp 30 Jun 2006 13:28:26 -0000 1.10
--- typefactory.hpp 30 Jun 2006 14:12:05 -0000 1.11
***************
*** 119,128 ****
};
! typedef boost::shared_ptr<QuantLib::Extrapolator>(*ExtrapolatorConstructor)(
! const std::vector<double>::const_iterator&,
! const std::vector<double>::const_iterator&,
! const std::vector<double>::const_iterator&,
! const std::vector<double>::const_iterator&,
! const QuantLib::Matrix&);
template<>
--- 119,127 ----
};
! typedef const std::vector<double>::const_iterator dbl_itr;
! typedef boost::shared_ptr<QuantLib::Extrapolator>(*ExtrapolatorConstructor1D)(
! dbl_itr&, dbl_itr&, dbl_itr&);
! typedef boost::shared_ptr<QuantLib::Extrapolator>(*ExtrapolatorConstructor2D)(
! dbl_itr&, dbl_itr&, dbl_itr&, dbl_itr&, const QuantLib::Matrix&);
template<>
***************
*** 132,142 ****
boost::shared_ptr<QuantLib::Extrapolator> operator() (
const std::string& extrapolatorID,
! const std::vector<double>::const_iterator& xBegin,
! const std::vector<double>::const_iterator& xEnd,
! const std::vector<double>::const_iterator& yBegin,
! const std::vector<double>::const_iterator& yEnd,
const QuantLib::Matrix& zData) {
! ExtrapolatorConstructor extrapolatorConstructor =
! static_cast<ExtrapolatorConstructor>(getType(extrapolatorID));
return extrapolatorConstructor(xBegin, xEnd, yBegin, yEnd, zData);
}
--- 131,145 ----
boost::shared_ptr<QuantLib::Extrapolator> operator() (
const std::string& extrapolatorID,
! dbl_itr& xBegin, dbl_itr& xEnd, dbl_itr& yBegin) {
! ExtrapolatorConstructor1D extrapolatorConstructor =
! static_cast<ExtrapolatorConstructor1D>(getType(extrapolatorID));
! return extrapolatorConstructor(xBegin, xEnd, yBegin);
! }
! boost::shared_ptr<QuantLib::Extrapolator> operator() (
! const std::string& extrapolatorID,
! dbl_itr& xBegin, dbl_itr& xEnd, dbl_itr& yBegin, dbl_itr& yEnd,
const QuantLib::Matrix& zData) {
! ExtrapolatorConstructor2D extrapolatorConstructor =
! static_cast<ExtrapolatorConstructor2D>(getType(extrapolatorID));
return extrapolatorConstructor(xBegin, xEnd, yBegin, yEnd, zData);
}
|