Update of /cvsroot/quantlibaddin/QuantLibAddin/qlo
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv19116/qlo
Modified Files:
interpolation.cpp interpolation.hpp
Log Message:
add switch for linear interpolation constructor
Index: interpolation.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/interpolation.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** interpolation.hpp 19 Jun 2006 11:07:12 -0000 1.10
--- interpolation.hpp 20 Jun 2006 08:29:54 -0000 1.11
***************
*** 38,62 ****
class Interpolation : public Extrapolator {};
- class BackwardFlatInterpolation : public Interpolation {
- public:
- BackwardFlatInterpolation(const std::vector<double>& x,
- const std::vector<double>& y);
- private:
- std::vector<double> x_, y_;
- };
-
- class ForwardFlatInterpolation : public Interpolation {
- public:
- ForwardFlatInterpolation(const std::vector<double>& x,
- const std::vector<double>& y);
- private:
- std::vector<double> x_, y_;
- };
-
class LinearInterpolation : public Interpolation {
public:
! LinearInterpolation(const std::vector<double>& x,
! const std::vector<double>& y,
! QuantLibAddin::LinearInterpolationType type);
private:
std::vector<double> x_, y_;
--- 38,46 ----
class Interpolation : public Extrapolator {};
class LinearInterpolation : public Interpolation {
public:
! LinearInterpolation(const LinearInterpolationType t,
! const std::vector<double>& x,
! const std::vector<double>& y);
private:
std::vector<double> x_, y_;
Index: interpolation.cpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/interpolation.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** interpolation.cpp 19 Jun 2006 11:07:12 -0000 1.7
--- interpolation.cpp 20 Jun 2006 08:29:53 -0000 1.8
***************
*** 29,65 ****
namespace QuantLibAddin {
! BackwardFlatInterpolation::BackwardFlatInterpolation(
const std::vector<double>& x,
const std::vector<double>& y) : x_(x), y_(y) {
QL_REQUIRE(x.size()==y.size(), "unmatched x/y");
- libraryObject_ = boost::shared_ptr<QuantLib::Interpolation>(
- new QuantLib::BackwardFlatInterpolation(x_.begin(),
- x_.end(),
- y_.begin()));
- }
-
- ForwardFlatInterpolation::ForwardFlatInterpolation(
- const std::vector<double>& x,
- const std::vector<double>& y) : x_(x), y_(y) {
! QL_REQUIRE(x.size()==y.size(), "unmatched x/y");
! libraryObject_ = boost::shared_ptr<QuantLib::Interpolation>(
! new QuantLib::ForwardFlatInterpolation(x_.begin(),
! x_.end(),
! y_.begin()));
! }
!
! LinearInterpolation::LinearInterpolation(
! const std::vector<double>& x,
! const std::vector<double>& y,
! QuantLibAddin::LinearInterpolationType type) : x_(x), y_(y) {
- QL_REQUIRE(x.size()==y.size(), "unmatched x/y");
- libraryObject_ = boost::shared_ptr<QuantLib::Interpolation>(
- new QuantLib::LinearInterpolation(x_.begin(),
- x_.end(),
- y_.begin()));
}
--- 29,63 ----
namespace QuantLibAddin {
! LinearInterpolation::LinearInterpolation(
! const LinearInterpolationType t,
const std::vector<double>& x,
const std::vector<double>& y) : x_(x), y_(y) {
QL_REQUIRE(x.size()==y.size(), "unmatched x/y");
! switch (t) {
! case LinearType:
! libraryObject_ = boost::shared_ptr<QuantLib::Interpolation>(
! new QuantLib::LinearInterpolation(x_.begin(),
! x_.end(),
! y_.begin()));
! break;
! case BackwardFlatType:
! libraryObject_ = boost::shared_ptr<QuantLib::Interpolation>(
! new QuantLib::BackwardFlatInterpolation(x_.begin(),
! x_.end(),
! y_.begin()));
! break;
! case ForwardFlatType:
! libraryObject_ = boost::shared_ptr<QuantLib::Interpolation>(
! new QuantLib::ForwardFlatInterpolation(x_.begin(),
! x_.end(),
! y_.begin()));
! break;
! default:
! QL_FAIL("Unknown LinearInterpolationType");
! }
}
|