Skip to content

Commit

Permalink
Merge 70553ab into 15ba009
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Mar 21, 2021
2 parents 15ba009 + 70553ab commit 241773b
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 70 deletions.
4 changes: 2 additions & 2 deletions ql/experimental/barrieroption/doublebarrieroption.cpp
Expand Up @@ -21,7 +21,7 @@
#include <ql/experimental/barrieroption/analyticdoublebarrierengine.hpp>
#include <ql/instruments/impliedvolatility.hpp>
#include <ql/exercise.hpp>
#include <boost/scoped_ptr.hpp>
#include <memory>

namespace QuantLib {

Expand Down Expand Up @@ -65,7 +65,7 @@ namespace QuantLib {
detail::ImpliedVolatilityHelper::clone(process, volQuote);

// engines are built-in for the time being
boost::scoped_ptr<PricingEngine> engine;
std::unique_ptr<PricingEngine> engine;
switch (exercise_->type()) {
case Exercise::European:
engine.reset(new AnalyticDoubleBarrierEngine(newProcess));
Expand Down
5 changes: 3 additions & 2 deletions ql/experimental/mcbasket/longstaffschwartzmultipathpricer.hpp
Expand Up @@ -27,6 +27,7 @@
#include <ql/methods/montecarlo/lsmbasissystem.hpp>
#include <ql/experimental/mcbasket/pathpayoff.hpp>
#include <ql/functional.hpp>
#include <memory>

namespace QuantLib {

Expand Down Expand Up @@ -71,8 +72,8 @@ namespace QuantLib {

const ext::shared_ptr<PathPayoff> payoff_;

boost::scoped_array<Array> coeff_;
boost::scoped_array<Real> lowerBounds_;
std::unique_ptr<Array[]> coeff_;
std::unique_ptr<Real[]> lowerBounds_;

const std::vector<Size> timePositions_;
const std::vector<Handle<YieldTermStructure> > forwardTermStructures_;
Expand Down
4 changes: 2 additions & 2 deletions ql/experimental/models/hestonslvfdmmodel.cpp
Expand Up @@ -43,8 +43,8 @@
#include <ql/termstructures/volatility/equityfx/fixedlocalvolsurface.hpp>
#include <ql/termstructures/volatility/equityfx/localvoltermstructure.hpp>
#include <ql/timegrid.hpp>
#include <boost/scoped_ptr.hpp>
#include <functional>
#include <memory>
#include <utility>

namespace QuantLib {
Expand Down Expand Up @@ -223,7 +223,7 @@ namespace QuantLib {
void setStep(Time dt) override { scheme_->setStep(dt); }

private:
const boost::scoped_ptr<T> scheme_;
const std::unique_ptr<T> scheme_;
};

ext::shared_ptr<FdmScheme> fdmSchemeFactory(
Expand Down
Expand Up @@ -24,9 +24,9 @@
#include <ql/errors.hpp>
#include <ql/experimental/varianceoption/integralhestonvarianceoptionengine.hpp>
#include <ql/functional.hpp>
#include <boost/scoped_array.hpp>
#include <complex>
#include <utility>
#include <memory>

namespace QuantLib {

Expand Down Expand Up @@ -58,14 +58,14 @@ namespace QuantLib {
Real v0, Real eprice, Time tau, Real rtax)
{
Real ss=0.0;
boost::scoped_array<double> xiv(new double[2048*2048+1]);
std::unique_ptr<double[]> xiv(new double[2048*2048+1]);
double nris=0.0;
int j=0,mm=0;
double pi=0,pi2=0;
double dstep=0;
Real option=0, impart=0;

boost::scoped_array<Complex> ff(new Complex[2048*2048]);
std::unique_ptr<Complex[]> ff(new Complex[2048*2048]);
Complex xi;
Complex ui,beta,zita,gamma,csum,vero;
Complex contrib, caux, caux1,caux2,caux3;
Expand Down Expand Up @@ -203,8 +203,8 @@ namespace QuantLib {
const ext::function<Real(Real)>& payoff) {

Real ss=0.0;
boost::scoped_array<double> xiv(new double[2048*2048+1]);
boost::scoped_array<double> ivet(new double[2048 * 2048 + 1]);
std::unique_ptr<double[]> xiv(new double[2048*2048+1]);
std::unique_ptr<double[]> ivet(new double[2048 * 2048 + 1]);
double nris=0.0;
int j=0,mm=0,k=0;
double pi=0,pi2=0;
Expand All @@ -217,7 +217,7 @@ namespace QuantLib {
Real sumr=0;//,sumi=0;
Complex dxi,z;

boost::scoped_array<Complex> ff(new Complex[2048*2048]);
std::unique_ptr<Complex[]> ff(new Complex[2048*2048]);
Complex xi;
Complex ui,beta,zita,gamma,csum;
Complex caux,caux1,caux2,caux3;
Expand Down
4 changes: 2 additions & 2 deletions ql/instruments/barrieroption.cpp
Expand Up @@ -23,7 +23,7 @@
#include <ql/instruments/impliedvolatility.hpp>
#include <ql/pricingengines/barrier/analyticbarrierengine.hpp>
#include <ql/exercise.hpp>
#include <boost/scoped_ptr.hpp>
#include <memory>

namespace QuantLib {

Expand Down Expand Up @@ -64,7 +64,7 @@ namespace QuantLib {
detail::ImpliedVolatilityHelper::clone(process, volQuote);

// engines are built-in for the time being
boost::scoped_ptr<PricingEngine> engine;
std::unique_ptr<PricingEngine> engine;
switch (exercise_->type()) {
case Exercise::European:
engine.reset(new AnalyticBarrierEngine(newProcess));
Expand Down
4 changes: 2 additions & 2 deletions ql/instruments/dividendvanillaoption.cpp
Expand Up @@ -24,7 +24,7 @@
#include <ql/utilities/dataformatters.hpp>
#include <ql/cashflows/cashflowvectors.hpp>
#include <ql/exercise.hpp>
#include <boost/scoped_ptr.hpp>
#include <memory>

namespace QuantLib {

Expand Down Expand Up @@ -53,7 +53,7 @@ namespace QuantLib {
detail::ImpliedVolatilityHelper::clone(process, volQuote);

// engines are built-in for the time being
boost::scoped_ptr<PricingEngine> engine;
std::unique_ptr<PricingEngine> engine;
switch (exercise_->type()) {
case Exercise::European:
engine.reset(new AnalyticDividendEuropeanEngine(newProcess));
Expand Down
4 changes: 2 additions & 2 deletions ql/instruments/vanillaoption.cpp
Expand Up @@ -24,7 +24,7 @@
#include <ql/pricingengines/vanilla/analyticeuropeanengine.hpp>
#include <ql/pricingengines/vanilla/fdblackscholesvanillaengine.hpp>
#include <ql/exercise.hpp>
#include <boost/scoped_ptr.hpp>
#include <memory>

namespace QuantLib {

Expand All @@ -50,7 +50,7 @@ namespace QuantLib {
detail::ImpliedVolatilityHelper::clone(process, volQuote);

// engines are built-in for the time being
boost::scoped_ptr<PricingEngine> engine;
std::unique_ptr<PricingEngine> engine;
switch (exercise_->type()) {
case Exercise::European:
engine.reset(new AnalyticEuropeanEngine(newProcess));
Expand Down
8 changes: 4 additions & 4 deletions ql/math/array.hpp
Expand Up @@ -32,14 +32,14 @@
#include <ql/utilities/disposable.hpp>
#include <ql/utilities/null.hpp>
#include <boost/iterator/reverse_iterator.hpp>
#include <boost/scoped_array.hpp>
#include <boost/type_traits.hpp>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <initializer_list>
#include <iomanip>
#include <memory>

namespace QuantLib {

Expand Down Expand Up @@ -147,7 +147,7 @@ namespace QuantLib {
//@}

private:
boost::scoped_array<Real> data_;
std::unique_ptr<Real[]> data_;
Size n_;
};

Expand Down Expand Up @@ -260,7 +260,7 @@ namespace QuantLib {

template <class I>
inline void _fill_array_(Array& a,
boost::scoped_array<Real>& data_,
std::unique_ptr<Real[]>& data_,
Size& n_,
I begin, I end,
const boost::true_type&) {
Expand All @@ -277,7 +277,7 @@ namespace QuantLib {

template <class I>
inline void _fill_array_(Array& a,
boost::scoped_array<Real>& data_,
std::unique_ptr<Real[]>& data_,
Size& n_,
I begin, I end,
const boost::false_type&) {
Expand Down
2 changes: 1 addition & 1 deletion ql/math/matrix.hpp
Expand Up @@ -146,7 +146,7 @@ namespace QuantLib {
void swap(Matrix&);
//@}
private:
boost::scoped_array<Real> data_;
std::unique_ptr<Real[]> data_;
Size rows_ = 0, columns_ = 0;
};

Expand Down
13 changes: 7 additions & 6 deletions ql/math/matrixutilities/qrdecomposition.cpp
Expand Up @@ -23,6 +23,7 @@

#include <ql/math/optimization/lmdif.hpp>
#include <ql/math/matrixutilities/qrdecomposition.hpp>
#include <memory>

namespace QuantLib {

Expand All @@ -33,9 +34,9 @@ namespace QuantLib {
const Size m = M.rows();
const Size n = M.columns();

boost::scoped_array<int> lipvt(new int[n]);
boost::scoped_array<Real> rdiag(new Real[n]);
boost::scoped_array<Real> wa(new Real[n]);
std::unique_ptr<int[]> lipvt(new int[n]);
std::unique_ptr<Real[]> rdiag(new Real[n]);
std::unique_ptr<Real[]> wa(new Real[n]);

MINPACK::qrfac(m, n, mT.begin(), 0, (pivot)?1:0,
lipvt.get(), n, rdiag.get(), rdiag.get(), wa.get());
Expand Down Expand Up @@ -133,13 +134,13 @@ namespace QuantLib {

std::vector<Size> lipvt = qrDecomposition(a, q, r, pivot);

boost::scoped_array<int> ipvt(new int[n]);
std::unique_ptr<int[]> ipvt(new int[n]);
std::copy(lipvt.begin(), lipvt.end(), ipvt.get());

Matrix rT = transpose(r);

boost::scoped_array<Real> sdiag(new Real[n]);
boost::scoped_array<Real> wa(new Real[n]);
std::unique_ptr<Real[]> sdiag(new Real[n]);
std::unique_ptr<Real[]> wa(new Real[n]);

Array ld(n, 0.0);
if (!d.empty()) {
Expand Down
21 changes: 11 additions & 10 deletions ql/math/optimization/levenbergmarquardt.cpp
Expand Up @@ -22,6 +22,7 @@
#include <ql/math/optimization/lmdif.hpp>
#include <ql/math/optimization/levenbergmarquardt.hpp>
#include <ql/functional.hpp>
#include <memory>

namespace QuantLib {

Expand Down Expand Up @@ -51,23 +52,23 @@ namespace QuantLib {
initJacobian_ = Matrix(m,n);
P.costFunction().jacobian(initJacobian_, x_);
}
boost::scoped_array<Real> xx(new Real[n]);
std::unique_ptr<Real[]> xx(new Real[n]);
std::copy(x_.begin(), x_.end(), xx.get());
boost::scoped_array<Real> fvec(new Real[m]);
boost::scoped_array<Real> diag(new Real[n]);
std::unique_ptr<Real[]> fvec(new Real[m]);
std::unique_ptr<Real[]> diag(new Real[n]);
int mode = 1;
Real factor = 1;
int nprint = 0;
int info = 0;
int nfev =0;
boost::scoped_array<Real> fjac(new Real[m*n]);
std::unique_ptr<Real[]> fjac(new Real[m*n]);
int ldfjac = m;
boost::scoped_array<int> ipvt(new int[n]);
boost::scoped_array<Real> qtf(new Real[n]);
boost::scoped_array<Real> wa1(new Real[n]);
boost::scoped_array<Real> wa2(new Real[n]);
boost::scoped_array<Real> wa3(new Real[n]);
boost::scoped_array<Real> wa4(new Real[m]);
std::unique_ptr<int[]> ipvt(new int[n]);
std::unique_ptr<Real[]> qtf(new Real[n]);
std::unique_ptr<Real[]> wa1(new Real[n]);
std::unique_ptr<Real[]> wa2(new Real[n]);
std::unique_ptr<Real[]> wa3(new Real[n]);
std::unique_ptr<Real[]> wa4(new Real[m]);
// requirements; check here to get more detailed error messages.
QL_REQUIRE(n > 0, "no variables given");
QL_REQUIRE(m >= n,
Expand Down
3 changes: 2 additions & 1 deletion ql/methods/finitedifferences/meshers/uniformgridmesher.hpp
Expand Up @@ -28,6 +28,7 @@

#include <ql/methods/finitedifferences/meshers/fdmmesher.hpp>
#include <ql/methods/finitedifferences/operators/fdmlinearopiterator.hpp>
#include <memory>

namespace QuantLib {

Expand All @@ -51,7 +52,7 @@ namespace QuantLib {
Disposable<Array> locations(Size direction) const override;

private:
boost::scoped_array<Real> dx_;
std::unique_ptr<Real[]> dx_;
std::vector<std::vector<Real> > locations_;
};
}
Expand Down
9 changes: 9 additions & 0 deletions ql/methods/montecarlo/longstaffschwartzpathpricer.hpp
Expand Up @@ -33,7 +33,11 @@
#include <ql/methods/montecarlo/earlyexercisepathpricer.hpp>
#include <ql/methods/montecarlo/pathpricer.hpp>
#include <ql/termstructures/yieldtermstructure.hpp>
#if !defined(QL_USE_STD_UNIQUE_PTR)
#include <boost/scoped_array.hpp>
#endif
#include <utility>
#include <memory>

namespace QuantLib {

Expand Down Expand Up @@ -74,8 +78,13 @@ namespace QuantLib {

mutable QuantLib::IncrementalStatistics exerciseProbability_;

#if defined(QL_USE_STD_UNIQUE_PTR)
std::unique_ptr<Array[]> coeff_;
std::unique_ptr<DiscountFactor[]> dF_;
#else
boost::scoped_array<Array> coeff_;
boost::scoped_array<DiscountFactor> dF_;
#endif

mutable std::vector<PathType> paths_;
const std::vector<ext::function<Real(StateType)> > v_;
Expand Down
10 changes: 2 additions & 8 deletions ql/pricingengines/swaption/fdg2swaptionengine.cpp
Expand Up @@ -17,9 +17,6 @@
FOR A PARTICULAR PURPOSE. See the license for more details.
*/

/*! \file fdg2swaptionengine.cpp
*/

#include <ql/exercise.hpp>
#include <ql/indexes/iborindex.hpp>
#include <ql/processes/ornsteinuhlenbeckprocess.hpp>
Expand All @@ -32,8 +29,6 @@
#include <ql/methods/finitedifferences/utilities/fdmaffinemodelswapinnervalue.hpp>
#include <ql/methods/finitedifferences/stepconditions/fdmstepconditioncomposite.hpp>

#include <boost/scoped_ptr.hpp>

namespace QuantLib {

FdG2SwaptionEngine::FdG2SwaptionEngine(
Expand Down Expand Up @@ -119,9 +114,8 @@ namespace QuantLib {
calculator, maturity,
tGrid_, dampingSteps_ };

const boost::scoped_ptr<FdmG2Solver> solver(
new FdmG2Solver(model_, solverDesc, schemeDesc_));
FdmG2Solver solver(model_, solverDesc, schemeDesc_);

results_.value = solver->valueAt(0.0, 0.0);
results_.value = solver.valueAt(0.0, 0.0);
}
}
10 changes: 2 additions & 8 deletions ql/pricingengines/swaption/fdhullwhiteswaptionengine.cpp
Expand Up @@ -17,9 +17,6 @@
FOR A PARTICULAR PURPOSE. See the license for more details.
*/

/*! \file fdhullwhiteswaptionengine.cpp
*/

#include <ql/exercise.hpp>
#include <ql/indexes/iborindex.hpp>
#include <ql/processes/ornsteinuhlenbeckprocess.hpp>
Expand All @@ -32,8 +29,6 @@
#include <ql/methods/finitedifferences/utilities/fdmaffinemodelswapinnervalue.hpp>
#include <ql/methods/finitedifferences/stepconditions/fdmstepconditioncomposite.hpp>

#include <boost/scoped_ptr.hpp>

namespace QuantLib {

FdHullWhiteSwaptionEngine::FdHullWhiteSwaptionEngine(
Expand Down Expand Up @@ -112,9 +107,8 @@ namespace QuantLib {
calculator, maturity,
tGrid_, dampingSteps_ };

const boost::scoped_ptr<FdmHullWhiteSolver> solver(
new FdmHullWhiteSolver(model_, solverDesc, schemeDesc_));
FdmHullWhiteSolver solver(model_, solverDesc, schemeDesc_);

results_.value = solver->valueAt(0.0);
results_.value = solver.valueAt(0.0);
}
}

0 comments on commit 241773b

Please sign in to comment.