Skip to content

Commit

Permalink
Remove check on Boost::uBLAS availability.
Browse files Browse the repository at this point in the history
It was meant for gcc 3.x, which can't support C++11 anyway.
  • Loading branch information
lballabio committed Jun 28, 2021
1 parent d2dd2df commit 39e8cbe
Show file tree
Hide file tree
Showing 62 changed files with 46 additions and 315 deletions.
26 changes: 0 additions & 26 deletions acinclude.m4
Expand Up @@ -100,31 +100,6 @@ AC_DEFUN([QL_CHECK_BOOST_VERSION_1_59_OR_HIGHER],
])
])



# QL_CHECK_BOOST_UBLAS
# --------------------
# Check whether the Boost headers are available
AC_DEFUN([QL_CHECK_BOOST_UBLAS],
[AC_MSG_CHECKING([for Boost::uBLAS support])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[@%:@include <boost/version.hpp>
@%:@if BOOST_VERSION > 106300
@%:@include <boost/serialization/array_wrapper.hpp>
@%:@endif
@%:@include <boost/numeric/ublas/vector_proxy.hpp>
@%:@include <boost/numeric/ublas/triangular.hpp>
@%:@include <boost/numeric/ublas/lu.hpp>]],
[[]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_WARN([Some functionality will be disabled.])
AC_DEFINE([QL_NO_UBLAS_SUPPORT],[],
[Define this if your compiler does not support Boost::uBLAS.])
])
])

# QL_CHECK_BOOST_UNIT_TEST
# ------------------------
# Check whether the Boost unit-test framework is available
Expand Down Expand Up @@ -303,7 +278,6 @@ AC_DEFUN([QL_CHECK_BOOST_TEST_INTERPROCESS],
AC_DEFUN([QL_CHECK_BOOST],
[AC_REQUIRE([QL_CHECK_BOOST_DEVEL])
AC_REQUIRE([QL_CHECK_BOOST_VERSION])
AC_REQUIRE([QL_CHECK_BOOST_UBLAS])
AC_REQUIRE([QL_CHECK_BOOST_UNIT_TEST])
])

3 changes: 1 addition & 2 deletions ql/experimental/finitedifferences/fdmblackscholesfwdop.cpp
Expand Up @@ -121,11 +121,10 @@ namespace QuantLib {
return solve_splitting(direction_, r, dt);
}

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> >
FdmBlackScholesFwdOp::toMatrixDecomp() const {
std::vector<SparseMatrix> retVal(1, mapT_.toMatrix());
return retVal;
}
#endif

}
2 changes: 0 additions & 2 deletions ql/experimental/finitedifferences/fdmblackscholesfwdop.hpp
Expand Up @@ -52,9 +52,7 @@ class FdmBlackScholesFwdOp : public FdmLinearOpComposite {
Disposable<Array> solve_splitting(Size direction, const Array& r, Real s) const override;
Disposable<Array> preconditioner(const Array& r, Real s) const override;

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> > toMatrixDecomp() const override;
#endif
private:
const ext::shared_ptr<FdmMesher> mesher_;
const ext::shared_ptr<YieldTermStructure> rTS_, qTS_;
Expand Down
6 changes: 1 addition & 5 deletions ql/experimental/finitedifferences/fdmdupire1dop.cpp
Expand Up @@ -19,10 +19,7 @@

#include <ql/experimental/finitedifferences/fdmdupire1dop.hpp>
#include <ql/methods/finitedifferences/operators/secondderivativeop.hpp>

#if !defined(QL_NO_UBLAS_SUPPORT)
#include <boost/numeric/ublas/matrix.hpp>
#endif

namespace QuantLib {

Expand Down Expand Up @@ -66,11 +63,10 @@ Disposable<Array> FdmDupire1dOp::preconditioner(const Array &r, Real dt) const {
return solve_splitting(0, r, dt);
}

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> > FdmDupire1dOp::toMatrixDecomp() const {
std::vector<SparseMatrix> retVal(1);
retVal[0] = mapT_.toMatrix();
return retVal;
}
#endif

}
2 changes: 0 additions & 2 deletions ql/experimental/finitedifferences/fdmdupire1dop.hpp
Expand Up @@ -47,9 +47,7 @@ class FdmDupire1dOp : public FdmLinearOpComposite {
Disposable<Array> solve_splitting(Size direction, const Array& r, Real s) const override;
Disposable<Array> preconditioner(const Array& r, Real s) const override;

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> > toMatrixDecomp() const override;
#endif

private:
const ext::shared_ptr<FdmMesher> mesher_;
Expand Down
Expand Up @@ -102,12 +102,10 @@ namespace QuantLib {
return solve_splitting(direction_, r, dt);
}

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> >
FdmExtendedOrnsteinUhlenbeckOp::toMatrixDecomp() const {
std::vector<SparseMatrix> retVal(1, mapX_.toMatrix());
return retVal;
}
#endif

}
Expand Up @@ -54,9 +54,8 @@ namespace QuantLib {
Disposable<Array> solve_splitting(Size direction, const Array& r, Real s) const override;
Disposable<Array> preconditioner(const Array& r, Real s) const override;

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> > toMatrixDecomp() const override;
#endif

private:
const ext::shared_ptr<FdmMesher> mesher_;
const ext::shared_ptr<ExtendedOrnsteinUhlenbeckProcess> process_;
Expand Down
85 changes: 1 addition & 84 deletions ql/experimental/finitedifferences/fdmextoujumpop.cpp
Expand Up @@ -32,12 +32,6 @@
#include <ql/methods/finitedifferences/operators/secondderivativeop.hpp>
#include <ql/experimental/finitedifferences/fdmextendedornsteinuhlenbeckop.hpp>

#if defined(QL_NO_UBLAS_SUPPORT)

#include <ql/methods/finitedifferences/utilities/fdmdirichletboundary.hpp>

#else

#if defined(QL_PATCH_MSVC)
#pragma warning(push)
#pragma warning(disable:4180)
Expand All @@ -59,8 +53,6 @@
#pragma GCC diagnostic pop
#endif

#endif

namespace QuantLib {

FdmExtOUJumpOp::FdmExtOUJumpOp(
Expand All @@ -81,7 +73,6 @@ namespace QuantLib {
dyMap_ (FirstDerivativeOp(1, mesher)
.mult(-process->beta()*mesher->locations(1)))
{
#if !defined(QL_NO_UBLAS_SUPPORT)
const Real eta = process_->eta();
const Real lambda = process_->jumpIntensity();

Expand Down Expand Up @@ -124,7 +115,6 @@ namespace QuantLib {
+= weight*lambda*s;
}
}
#endif
}

Size FdmExtOUJumpOp::size() const {
Expand Down Expand Up @@ -175,79 +165,6 @@ namespace QuantLib {
return ouOp_->solve_splitting(0, r, dt);
}

#if defined(QL_NO_UBLAS_SUPPORT)
FdmExtOUJumpOp::IntegroIntegrand::IntegroIntegrand(
const ext::shared_ptr<LinearInterpolation>& interpl,
const FdmBoundaryConditionSet& bcSet,
Real y, Real eta)
: y_ (y),
eta_ (eta),
bcSet_ (bcSet),
interpl_(interpl) { }

Real FdmExtOUJumpOp::IntegroIntegrand::operator()(Real u) const {
const Real y = y_ + u/eta_;
Real valueOfDerivative = (*interpl_)(y, true);

for (FdmBoundaryConditionSet::const_iterator iter=bcSet_.begin();
iter < bcSet_.end(); ++iter) {
const ext::shared_ptr<FdmDirichletBoundary> dirichletBC =
ext::dynamic_pointer_cast<FdmDirichletBoundary>(*iter);

if (dirichletBC != 0) {
valueOfDerivative=
dirichletBC->applyAfterApplying(y, valueOfDerivative);
}
}

return std::exp(-u)*valueOfDerivative;
}

Disposable<Array> FdmExtOUJumpOp::integro(const Array& r) const {
Array integral(r.size());
const ext::shared_ptr<FdmLinearOpLayout> layout = mesher_->layout();
const Size extraDims=layout->size()/(layout->dim()[0]*layout->dim()[1]);

std::vector<Array> y(extraDims, Array(layout->dim()[1]));
std::vector<Matrix> f(extraDims,
Matrix(layout->dim()[1], layout->dim()[0]));

const FdmLinearOpIterator endIter = layout->end();
for (FdmLinearOpIterator iter = layout->begin(); iter != endIter;
++iter) {
const Size i = iter.coordinates()[0];
const Size j = iter.coordinates()[1];
const Size k = iter.index() / (layout->dim()[0]*layout->dim()[1]);

y[k][j] = mesher_->location(iter, 1);
f[k][j][i] = r[iter.index()];
}
std::vector<std::vector<ext::shared_ptr<LinearInterpolation> > >
interpl(extraDims, std::vector<
ext::shared_ptr<LinearInterpolation> >(f[0].columns()));

for (Size k=0; k < extraDims; ++k) {
for (Size i=0; i < f[k].columns(); ++i) {
interpl[k][i] = ext::shared_ptr<LinearInterpolation>(
new LinearInterpolation(y[k].begin(), y[k].end(),
f[k].column_begin(i)));
}
}

const Real eta = process_->eta();

for (FdmLinearOpIterator iter=layout->begin(); iter!=endIter; ++iter) {
const Size i = iter.coordinates()[0];
const Size j = iter.coordinates()[1];
const Size k = iter.index() / (layout->dim()[0]*layout->dim()[1]);

integral[iter.index()] = gaussLaguerreIntegration_(
IntegroIntegrand(interpl[k][i], bcSet_, y[k][j], eta));
}

return process_->jumpIntensity()*(integral-r);
}
#else
Disposable<Array> FdmExtOUJumpOp::integro(const Array& r) const {
return prod(integroPart_, r);
}
Expand All @@ -262,5 +179,5 @@ namespace QuantLib {

return retVal;
}
#endif

}
18 changes: 0 additions & 18 deletions ql/experimental/finitedifferences/fdmextoujumpop.hpp
Expand Up @@ -61,9 +61,7 @@ namespace QuantLib {
Disposable<Array> solve_splitting(Size direction, const Array& r, Real s) const override;
Disposable<Array> preconditioner(const Array& r, Real s) const override;

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> > toMatrixDecomp() const override;
#endif
private:
Disposable<Array> integro(const Array& r) const;

Expand All @@ -78,23 +76,7 @@ namespace QuantLib {

const TripleBandLinearOp dyMap_;

#if defined(QL_NO_UBLAS_SUPPORT)
class IntegroIntegrand {
public:
IntegroIntegrand(const ext::shared_ptr<LinearInterpolation>& i,
const FdmBoundaryConditionSet& bcSet,
Real y, Real eta);
Real operator()(Real u) const;

private:
const Real y_, eta_;
const FdmBoundaryConditionSet& bcSet_;
const ext::shared_ptr<LinearInterpolation>& interpl_;
};

#else
SparseMatrix integroPart_;
#endif
};
}

Expand Down
3 changes: 1 addition & 2 deletions ql/experimental/finitedifferences/fdmhestonfwdop.cpp
Expand Up @@ -224,7 +224,6 @@ namespace QuantLib {
return v;
}

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> > FdmHestonFwdOp::toMatrixDecomp()
const {

Expand All @@ -236,5 +235,5 @@ namespace QuantLib {

return retVal;
}
#endif

}
2 changes: 0 additions & 2 deletions ql/experimental/finitedifferences/fdmhestonfwdop.hpp
Expand Up @@ -58,9 +58,7 @@ namespace QuantLib {
Disposable<Array> solve_splitting(Size direction, const Array& r, Real s) const override;
Disposable<Array> preconditioner(const Array& r, Real s) const override;

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> > toMatrixDecomp() const override;
#endif
private:
Disposable<Array> getLeverageFctSlice(Time t1, Time t2) const;
const FdmSquareRootFwdOp::TransformationType type_;
Expand Down
3 changes: 1 addition & 2 deletions ql/experimental/finitedifferences/fdmklugeextouop.cpp
Expand Up @@ -108,7 +108,6 @@ namespace QuantLib {
return klugeOp_->solve_splitting(0, r, dt);
}

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> >
FdmKlugeExtOUOp::toMatrixDecomp() const {
const std::vector<SparseMatrix> klugeDecomp
Expand All @@ -122,5 +121,5 @@ namespace QuantLib {

return retVal;
}
#endif

}
3 changes: 1 addition & 2 deletions ql/experimental/finitedifferences/fdmklugeextouop.hpp
Expand Up @@ -80,9 +80,8 @@ namespace QuantLib {
Disposable<Array> solve_splitting(Size direction, const Array& r, Real s) const override;
Disposable<Array> preconditioner(const Array& r, Real s) const override;

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> > toMatrixDecomp() const override;
#endif

private:

const ext::shared_ptr<FdmMesher> mesher_;
Expand Down
3 changes: 1 addition & 2 deletions ql/experimental/finitedifferences/fdmsquarerootfwdop.cpp
Expand Up @@ -332,11 +332,10 @@ namespace QuantLib {
return solve_splitting(direction_, r, dt);
}

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> >
FdmSquareRootFwdOp::toMatrixDecomp() const {
std::vector<SparseMatrix> retVal(1, mapX_->toMatrix());
return retVal;
}
#endif

}
3 changes: 1 addition & 2 deletions ql/experimental/finitedifferences/fdmsquarerootfwdop.hpp
Expand Up @@ -52,9 +52,8 @@ namespace QuantLib {
Disposable<Array> solve_splitting(Size direction, const Array& r, Real s) const override;
Disposable<Array> preconditioner(const Array& r, Real s) const override;

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> > toMatrixDecomp() const override;
#endif

Real lowerBoundaryFactor(TransformationType type = Plain) const;
Real upperBoundaryFactor(TransformationType type = Plain) const;
Real v(Size i) const;
Expand Down
3 changes: 1 addition & 2 deletions ql/experimental/finitedifferences/fdmzabrop.cpp
Expand Up @@ -107,13 +107,12 @@ Disposable<Array> FdmZabrOp::preconditioner(const Array &r, Real dt) const {
return solve_splitting(0, r, dt);
}

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> > FdmZabrOp::toMatrixDecomp() const {
std::vector<SparseMatrix> retVal(3);
retVal[0] = dxMap_.getMap().toMatrix();
retVal[1] = dyMap_.getMap().toMatrix();
retVal[2] = dxyMap_.toMatrix();
return retVal;
}
#endif

}
2 changes: 0 additions & 2 deletions ql/experimental/finitedifferences/fdmzabrop.hpp
Expand Up @@ -82,9 +82,7 @@ class FdmZabrOp : public FdmLinearOpComposite {
Disposable<Array> solve_splitting(Size direction, const Array& r, Real s) const override;
Disposable<Array> preconditioner(const Array& r, Real s) const override;

#if !defined(QL_NO_UBLAS_SUPPORT)
Disposable<std::vector<SparseMatrix> > toMatrixDecomp() const override;
#endif

private:
const Array volatilityValues_;
Expand Down
3 changes: 0 additions & 3 deletions ql/experimental/math/laplaceinterpolation.hpp
Expand Up @@ -24,8 +24,6 @@
#ifndef quantlib_laplace_interpolation
#define quantlib_laplace_interpolation

#if !defined(QL_NO_UBLAS_SUPPORT)

#include <ql/math/matrixutilities/bicgstab.hpp>
#include <ql/math/matrixutilities/sparsematrix.hpp>

Expand Down Expand Up @@ -162,5 +160,4 @@ template <class M> void laplaceInterpolation(M &A, Real relTol = 1E-6) {

} // namespace QuantLib

#endif // QL_NO_UBLAS_SUPPORT
#endif // include guard

0 comments on commit 39e8cbe

Please sign in to comment.