From 9573573027747b029bdf4c99a126c7625bddd610 Mon Sep 17 00:00:00 2001 From: Julian Valentin Date: Fri, 12 Feb 2016 17:33:25 +0100 Subject: [PATCH] Manual merge (= file copying) sgopt into master. This revision also compiles on my laptop. --- .clang-format | 3 +- .gitignore | 3 + SConstruct | 34 + base/SConscript | 27 +- .../code_examples_continued_learning.doxy | 112 -- .../doxygen/code_examples_quick_start.doxy | 431 ----- base/doc/doxygen/styleguide.doxy | 64 - base/doc/doxygen/windows.doxy | 280 --- base/examples/all_simple.output.txt | 6 - .../examples/all_simple_quadrature.output.txt | 7 - base/examples/c++_simple.cpp | 73 - .../c++_simple_predictive_refinement.cpp | 130 -- base/examples/c++_simple_quadrature.cpp | 80 - base/examples/c++_simple_refinement.cpp | 74 - base/examples/matlab_simple.m | 58 - base/examples/python_simple.py | 43 - ...ython_simple_predictive_ANOVArefinement.py | 134 -- .../python_simple_predictive_refinement.py | 133 -- base/examples/python_simple_refinement.py | 44 - .../grid/generation/BoundaryGridGenerator.hpp | 7 +- .../grid/generation/hashmap/HashGenerator.hpp | 83 +- .../base/grid/type/BsplineBoundaryGrid.hpp | 9 +- .../grid/type/BsplineClenshawCurtisGrid.hpp | 9 +- .../base/grid/type/LinearBoundaryGrid.hpp | 16 +- .../grid/type/LinearClenshawCurtisGrid.hpp | 16 +- .../sgpp/base/grid/type/PolyBoundaryGrid.hpp | 9 +- .../base/grid/type/WaveletBoundaryGrid.hpp | 9 +- base/src/sgpp/base/opencl/SConscript | 14 +- .../basis/BsplineClenshawCurtisBasis.hpp | 20 +- .../BsplineModifiedClenshawCurtisBasis.hpp | 21 +- .../basis/LinearClenshawCurtisBasis.hpp | 14 +- .../sgpp/base/tools/ClenshawCurtisTable.cpp | 5 + .../sgpp/base/tools/ClenshawCurtisTable.hpp | 5 +- base/src/sgpp/globaldef.hpp | 2 +- base/tests/test_HashGridStorage.cpp | 12 +- combigrid/SConscript | 20 +- combigrid/src/combigrid.hpp | 7 +- .../basisfunction/CombiBasisFunctionBasis.hpp | 14 +- .../CombiLinearBasisFunction.cpp | 17 +- .../CombiLinearBasisFunction.hpp | 14 +- .../sgpp/combigrid/combigrid/CombiGrid.hpp | 90 +- .../combigrid/combigrid/SerialCombiGrid.cpp | 8 +- .../combigrid/combigrid/SerialCombiGrid.hpp | 17 +- .../combischeme/AbstractCombiScheme.hpp | 56 +- .../combischeme/CombiArbitraryScheme.cpp | 32 +- .../combischeme/CombiArbitraryScheme.hpp | 25 +- .../sgpp/combigrid/combischeme/CombiS_CT.cpp | 67 +- .../sgpp/combigrid/combischeme/CombiS_CT.hpp | 34 +- .../sgpp/combigrid/combischeme/CombiTS_CT.cpp | 45 +- .../sgpp/combigrid/combischeme/CombiTS_CT.hpp | 28 +- .../domain/AbstractStretchingMaker.hpp | 27 +- .../domain/CombiAtanSpecialStretching.cpp | 30 +- .../domain/CombiAtanSpecialStretching.hpp | 17 +- .../combigrid/domain/CombiBasuStretching.cpp | 19 +- .../combigrid/domain/CombiBasuStretching.hpp | 18 +- .../domain/CombiChebyshevStretching.cpp | 20 +- .../domain/CombiChebyshevStretching.hpp | 13 +- .../sgpp/combigrid/domain/CombiDomain1D.cpp | 53 +- .../sgpp/combigrid/domain/CombiDomain1D.hpp | 27 +- .../domain/CombiEquidistantStretching.cpp | 21 +- .../domain/CombiEquidistantStretching.hpp | 34 +- .../sgpp/combigrid/domain/CombiGridDomain.cpp | 48 +- .../sgpp/combigrid/domain/CombiGridDomain.hpp | 31 +- .../domain/CombiLegendreStretching.cpp | 1610 +++++++++++------ .../domain/CombiLegendreStretching.hpp | 17 +- .../combigrid/domain/CombiTanStretching.cpp | 27 +- .../combigrid/domain/CombiTanStretching.hpp | 20 +- .../combigrid/domain/StretchingFactory.cpp | 17 +- .../combigrid/domain/StretchingFactory.hpp | 12 +- .../sgpp/combigrid/fullgrid/CombiFullGrid.hpp | 135 +- .../sgpp/combigrid/fullgrid/GridContainer.hpp | 27 +- .../sgpp/combigrid/plotter/GridPlotter.hpp | 88 +- .../quadratures/AbstractQuadrature.hpp | 44 +- .../combigrid/quadratures/BasuQuadrature.cpp | 38 +- .../combigrid/quadratures/BasuQuadrature.hpp | 14 +- .../quadratures/ClenshawCurtisQuadrature.cpp | 44 +- .../quadratures/ClenshawCurtisQuadrature.hpp | 13 +- .../quadratures/GaussPattersonQuadrature.cpp | 1584 ++++++++++------ .../quadratures/GaussPattersonQuadrature.hpp | 13 +- .../combigrid/quadratures/QuadratureRule.cpp | 63 +- .../combigrid/quadratures/QuadratureRule.hpp | 16 +- .../combigrid/quadratures/TrapezoidalRule.cpp | 33 +- .../combigrid/quadratures/TrapezoidalRule.hpp | 14 +- .../combigrid/utils/CombigridLevelVector.cpp | 50 +- .../combigrid/utils/CombigridLevelVector.hpp | 30 +- .../sgpp/combigrid/utils/combigrid_utils.hpp | 108 +- datadriven/SConscript | 26 +- .../SConscript | 15 +- .../OperationMultiEvalStreaming/SConscript | 15 +- .../SConscript | 15 +- .../SConscript | 15 +- .../SConscript | 15 +- .../SConscript | 15 +- .../SConscript | 15 +- .../SConscript | 15 +- .../SConscript | 15 +- .../SConscript | 15 +- .../SConscript | 15 +- .../SConscript | 15 +- .../OperationMultipleEvalSubspace/SConscript | 15 +- finance/SConscript | 25 +- ...lackScholesPATParabolicPDESolverSystem.cpp | 100 +- ...lackScholesPATParabolicPDESolverSystem.hpp | 48 +- ...lesPATParabolicPDESolverSystemEuroAmer.cpp | 145 +- ...lesPATParabolicPDESolverSystemEuroAmer.hpp | 46 +- ...olicPDESolverSystemEuroAmerParallelOMP.cpp | 265 ++- ...olicPDESolverSystemEuroAmerParallelOMP.hpp | 49 +- .../BlackScholesParabolicPDESolverSystem.cpp | 174 +- .../BlackScholesParabolicPDESolverSystem.hpp | 46 +- ...cholesParabolicPDESolverSystemEuroAmer.cpp | 270 ++- ...cholesParabolicPDESolverSystemEuroAmer.hpp | 49 +- ...olicPDESolverSystemEuroAmerParallelOMP.cpp | 273 ++- ...olicPDESolverSystemEuroAmerParallelOMP.hpp | 50 +- ...HestonParabolicPDESolverSystemEuroAmer.cpp | 292 ++- ...HestonParabolicPDESolverSystemEuroAmer.hpp | 127 +- .../HullWhiteParabolicPDESolverSystem.cpp | 82 +- .../HullWhiteParabolicPDESolverSystem.hpp | 37 +- ...edBlackScholesParabolicPDESolverSystem.cpp | 94 +- ...edBlackScholesParabolicPDESolverSystem.hpp | 40 +- .../BlackScholesHullWhiteSolver.cpp | 261 ++- .../BlackScholesHullWhiteSolver.hpp | 64 +- .../application/BlackScholesSolver.cpp | 937 +++++----- .../application/BlackScholesSolver.hpp | 209 ++- .../BlackScholesSolverWithStretching.cpp | 248 +-- .../BlackScholesSolverWithStretching.hpp | 117 +- .../sgpp/finance/application/HestonSolver.cpp | 817 ++++----- .../sgpp/finance/application/HestonSolver.hpp | 214 ++- .../finance/application/HullWhiteSolver.cpp | 195 +- .../finance/application/HullWhiteSolver.hpp | 45 +- .../DPhiPhiDownBBLinearBoundary.cpp | 26 +- .../DPhiPhiDownBBLinearBoundary.hpp | 23 +- .../DPhiPhiUpBBLinearBoundary.cpp | 24 +- .../DPhiPhiUpBBLinearBoundary.hpp | 23 +- .../PhidPhiDownBBLinearBoundary.cpp | 25 +- .../PhidPhiDownBBLinearBoundary.hpp | 23 +- .../PhidPhiUpBBLinearBoundary.cpp | 24 +- .../PhidPhiUpBBLinearBoundary.hpp | 23 +- .../SqXdPhidPhiDownBBLinearBoundary.cpp | 28 +- .../SqXdPhidPhiDownBBLinearBoundary.hpp | 23 +- .../SqXdPhidPhiUpBBLinearBoundary.cpp | 28 +- .../SqXdPhidPhiUpBBLinearBoundary.hpp | 23 +- .../SqrtXPhiPhiDownBBLinearBoundary.cpp | 44 +- .../SqrtXPhiPhiDownBBLinearBoundary.hpp | 23 +- .../SqrtXPhiPhiUpBBLinearBoundary.cpp | 48 +- .../SqrtXPhiPhiUpBBLinearBoundary.hpp | 23 +- .../XPhiPhiDownBBLinearBoundary.cpp | 28 +- .../XPhiPhiDownBBLinearBoundary.hpp | 23 +- .../XPhiPhiUpBBLinearBoundary.cpp | 32 +- .../XPhiPhiUpBBLinearBoundary.hpp | 23 +- .../XPhidPhiDownBBLinearBoundary.cpp | 28 +- .../XPhidPhiDownBBLinearBoundary.hpp | 23 +- .../XPhidPhiUpBBLinearBoundary.cpp | 28 +- .../XPhidPhiUpBBLinearBoundary.hpp | 23 +- .../XdPhiPhiDownBBLinearBoundary.cpp | 28 +- .../XdPhiPhiDownBBLinearBoundary.hpp | 23 +- .../XdPhiPhiUpBBLinearBoundary.cpp | 28 +- .../XdPhiPhiUpBBLinearBoundary.hpp | 23 +- .../XdPhidPhiDownBBLinearBoundary.cpp | 44 +- .../XdPhidPhiDownBBLinearBoundary.hpp | 23 +- .../XdPhidPhiUpBBLinearBoundary.cpp | 44 +- .../XdPhidPhiUpBBLinearBoundary.hpp | 23 +- .../algorithm_sweep/DPhiPhiDownBBLinear.cpp | 28 +- .../algorithm_sweep/DPhiPhiDownBBLinear.hpp | 26 +- .../algorithm_sweep/DPhiPhiUpBBLinear.cpp | 28 +- .../algorithm_sweep/DPhiPhiUpBBLinear.hpp | 26 +- .../algorithm_sweep/DPhidPhiDownBBLinear.cpp | 32 +- .../algorithm_sweep/DPhidPhiDownBBLinear.hpp | 29 +- .../algorithm_sweep/DPhidPhiUpBBLinear.cpp | 34 +- .../algorithm_sweep/DPhidPhiUpBBLinear.hpp | 31 +- .../algorithm_sweep/PhidPhiDownBBLinear.cpp | 28 +- .../algorithm_sweep/PhidPhiDownBBLinear.hpp | 25 +- .../algorithm_sweep/PhidPhiUpBBLinear.cpp | 26 +- .../algorithm_sweep/PhidPhiUpBBLinear.hpp | 25 +- .../SqXdPhidPhiDownBBLinear.cpp | 48 +- .../SqXdPhidPhiDownBBLinear.hpp | 29 +- .../algorithm_sweep/SqXdPhidPhiUpBBLinear.cpp | 42 +- .../algorithm_sweep/SqXdPhidPhiUpBBLinear.hpp | 31 +- .../SqrtXPhiPhiDownBBLinear.cpp | 125 +- .../SqrtXPhiPhiDownBBLinear.hpp | 29 +- .../algorithm_sweep/SqrtXPhiPhiUpBBLinear.cpp | 108 +- .../algorithm_sweep/SqrtXPhiPhiUpBBLinear.hpp | 30 +- .../algorithm_sweep/XPhiPhiDownBBLinear.cpp | 43 +- .../algorithm_sweep/XPhiPhiDownBBLinear.hpp | 29 +- .../algorithm_sweep/XPhiPhiUpBBLinear.cpp | 57 +- .../algorithm_sweep/XPhiPhiUpBBLinear.hpp | 30 +- .../algorithm_sweep/XPhidPhiDownBBLinear.cpp | 45 +- .../algorithm_sweep/XPhidPhiDownBBLinear.hpp | 29 +- .../algorithm_sweep/XPhidPhiUpBBLinear.cpp | 35 +- .../algorithm_sweep/XPhidPhiUpBBLinear.hpp | 26 +- .../algorithm_sweep/XdPhiPhiDownBBLinear.cpp | 48 +- .../algorithm_sweep/XdPhiPhiDownBBLinear.hpp | 26 +- .../algorithm_sweep/XdPhiPhiUpBBLinear.cpp | 38 +- .../algorithm_sweep/XdPhiPhiUpBBLinear.hpp | 26 +- .../algorithm_sweep/XdPhidPhiDownBBLinear.cpp | 41 +- .../algorithm_sweep/XdPhidPhiDownBBLinear.hpp | 29 +- .../algorithm_sweep/XdPhidPhiUpBBLinear.cpp | 34 +- .../algorithm_sweep/XdPhidPhiUpBBLinear.hpp | 31 +- .../DPhiPhiDownBBLinearStretchedBoundary.cpp | 27 +- .../DPhiPhiDownBBLinearStretchedBoundary.hpp | 26 +- .../DPhiPhiUpBBLinearStretchedBoundary.cpp | 25 +- .../DPhiPhiUpBBLinearStretchedBoundary.hpp | 23 +- .../PhidPhiDownBBLinearStretchedBoundary.cpp | 26 +- .../PhidPhiDownBBLinearStretchedBoundary.hpp | 26 +- .../PhidPhiUpBBLinearStretchedBoundary.cpp | 25 +- .../PhidPhiUpBBLinearStretchedBoundary.hpp | 23 +- ...XdPhidPhiDownBBLinearStretchedBoundary.cpp | 31 +- ...XdPhidPhiDownBBLinearStretchedBoundary.hpp | 26 +- ...SqXdPhidPhiUpBBLinearStretchedBoundary.cpp | 29 +- ...SqXdPhidPhiUpBBLinearStretchedBoundary.hpp | 26 +- .../XPhidPhiDownBBLinearStretchedBoundary.cpp | 32 +- .../XPhidPhiDownBBLinearStretchedBoundary.hpp | 26 +- .../XPhidPhiUpBBLinearStretchedBoundary.cpp | 34 +- .../XPhidPhiUpBBLinearStretchedBoundary.hpp | 23 +- .../XdPhiPhiDownBBLinearStretchedBoundary.cpp | 30 +- .../XdPhiPhiDownBBLinearStretchedBoundary.hpp | 26 +- .../XdPhiPhiUpBBLinearStretchedBoundary.cpp | 31 +- .../XdPhiPhiUpBBLinearStretchedBoundary.hpp | 23 +- .../DPhiPhiDownBBLinearStretched.cpp | 33 +- .../DPhiPhiDownBBLinearStretched.hpp | 29 +- .../DPhiPhiUpBBLinearStretched.cpp | 29 +- .../DPhiPhiUpBBLinearStretched.hpp | 26 +- .../PhidPhiDownBBLinearStretched.cpp | 35 +- .../PhidPhiDownBBLinearStretched.hpp | 25 +- .../PhidPhiUpBBLinearStretched.cpp | 28 +- .../PhidPhiUpBBLinearStretched.hpp | 25 +- .../SqXdPhidPhiDownBBLinearStretched.cpp | 42 +- .../SqXdPhidPhiDownBBLinearStretched.hpp | 25 +- .../SqXdPhidPhiUpBBLinearStretched.cpp | 32 +- .../SqXdPhidPhiUpBBLinearStretched.hpp | 26 +- .../XPhidPhiDownBBLinearStretched.cpp | 43 +- .../XPhidPhiDownBBLinearStretched.hpp | 26 +- .../XPhidPhiUpBBLinearStretched.cpp | 31 +- .../XPhidPhiUpBBLinearStretched.hpp | 22 +- .../XdPhiPhiDownBBLinearStretched.cpp | 46 +- .../XdPhiPhiDownBBLinearStretched.hpp | 22 +- .../XdPhiPhiUpBBLinearStretched.cpp | 40 +- .../XdPhiPhiUpBBLinearStretched.hpp | 22 +- .../finance/operation/FinanceOpFactory.cpp | 240 ++- .../finance/operation/FinanceOpFactory.hpp | 75 +- .../operation/hash/OperationDeltaLinear.cpp | 29 +- .../operation/hash/OperationDeltaLinear.hpp | 26 +- .../hash/OperationDeltaLinearBoundary.cpp | 24 +- .../hash/OperationDeltaLinearBoundary.hpp | 28 +- .../hash/OperationDeltaLinearStretched.cpp | 25 +- .../hash/OperationDeltaLinearStretched.hpp | 26 +- .../OperationDeltaLinearStretchedBoundary.cpp | 32 +- .../OperationDeltaLinearStretchedBoundary.hpp | 25 +- .../hash/OperationDeltaLogLinear.cpp | 28 +- .../hash/OperationDeltaLogLinear.hpp | 28 +- .../hash/OperationDeltaLogLinearBoundary.cpp | 24 +- .../hash/OperationDeltaLogLinearBoundary.hpp | 28 +- .../hash/OperationDeltaLogLinearStretched.cpp | 27 +- .../hash/OperationDeltaLogLinearStretched.hpp | 28 +- ...erationDeltaLogLinearStretchedBoundary.cpp | 35 +- ...erationDeltaLogLinearStretchedBoundary.hpp | 29 +- .../operation/hash/OperationGammaLinear.cpp | 37 +- .../operation/hash/OperationGammaLinear.hpp | 47 +- .../hash/OperationGammaLinearBoundary.cpp | 40 +- .../hash/OperationGammaLinearBoundary.hpp | 49 +- .../hash/OperationGammaLinearStretched.cpp | 41 +- .../hash/OperationGammaLinearStretched.hpp | 48 +- .../OperationGammaLinearStretchedBoundary.cpp | 60 +- .../OperationGammaLinearStretchedBoundary.hpp | 46 +- .../hash/OperationGammaLogLinear.cpp | 42 +- .../hash/OperationGammaLogLinear.hpp | 49 +- .../hash/OperationGammaLogLinearBoundary.cpp | 44 +- .../hash/OperationGammaLogLinearBoundary.hpp | 49 +- .../hash/OperationGammaLogLinearStretched.cpp | 47 +- .../hash/OperationGammaLogLinearStretched.hpp | 49 +- ...erationGammaLogLinearStretchedBoundary.cpp | 55 +- ...erationGammaLogLinearStretchedBoundary.hpp | 50 +- .../operation/hash/OperationHestonBLinear.cpp | 62 +- .../operation/hash/OperationHestonBLinear.hpp | 48 +- .../hash/OperationHestonBLinearBoundary.cpp | 64 +- .../hash/OperationHestonBLinearBoundary.hpp | 48 +- .../operation/hash/OperationHestonCLinear.cpp | 62 +- .../operation/hash/OperationHestonCLinear.hpp | 48 +- .../hash/OperationHestonCLinearBoundary.cpp | 64 +- .../hash/OperationHestonCLinearBoundary.hpp | 48 +- .../operation/hash/OperationHestonDLinear.cpp | 25 +- .../operation/hash/OperationHestonDLinear.hpp | 27 +- .../hash/OperationHestonDLinearBoundary.cpp | 22 +- .../hash/OperationHestonDLinearBoundary.hpp | 27 +- .../operation/hash/OperationHestonELinear.cpp | 27 +- .../operation/hash/OperationHestonELinear.hpp | 27 +- .../hash/OperationHestonELinearBoundary.cpp | 24 +- .../hash/OperationHestonELinearBoundary.hpp | 27 +- .../operation/hash/OperationHestonFLinear.cpp | 25 +- .../operation/hash/OperationHestonFLinear.hpp | 29 +- .../hash/OperationHestonFLinearBoundary.cpp | 22 +- .../hash/OperationHestonFLinearBoundary.hpp | 29 +- .../operation/hash/OperationHestonGLinear.cpp | 25 +- .../operation/hash/OperationHestonGLinear.hpp | 27 +- .../hash/OperationHestonGLinearBoundary.cpp | 22 +- .../hash/OperationHestonGLinearBoundary.hpp | 27 +- .../operation/hash/OperationHestonHLinear.cpp | 62 +- .../operation/hash/OperationHestonHLinear.hpp | 48 +- .../hash/OperationHestonHLinearBoundary.cpp | 64 +- .../hash/OperationHestonHLinearBoundary.hpp | 48 +- .../operation/hash/OperationHestonKLinear.cpp | 133 +- .../operation/hash/OperationHestonKLinear.hpp | 176 +- .../hash/OperationHestonKLinearBoundary.cpp | 122 +- .../hash/OperationHestonKLinearBoundary.hpp | 177 +- .../operation/hash/OperationHestonWLinear.cpp | 62 +- .../operation/hash/OperationHestonWLinear.hpp | 48 +- .../hash/OperationHestonWLinearBoundary.cpp | 64 +- .../hash/OperationHestonWLinearBoundary.hpp | 48 +- .../operation/hash/OperationHestonXLinear.cpp | 62 +- .../operation/hash/OperationHestonXLinear.hpp | 48 +- .../hash/OperationHestonXLinearBoundary.cpp | 67 +- .../hash/OperationHestonXLinearBoundary.hpp | 48 +- .../operation/hash/OperationHestonYLinear.cpp | 66 +- .../operation/hash/OperationHestonYLinear.hpp | 48 +- .../hash/OperationHestonYLinearBoundary.cpp | 71 +- .../hash/OperationHestonYLinearBoundary.hpp | 48 +- .../operation/hash/OperationHestonZLinear.cpp | 28 +- .../operation/hash/OperationHestonZLinear.hpp | 27 +- .../hash/OperationHestonZLinearBoundary.cpp | 25 +- .../hash/OperationHestonZLinearBoundary.hpp | 27 +- .../operation/hash/OperationLBLinear.cpp | 22 +- .../operation/hash/OperationLBLinear.hpp | 18 +- .../hash/OperationLBLinearBoundary.cpp | 22 +- .../hash/OperationLBLinearBoundary.hpp | 18 +- .../operation/hash/OperationLDLinear.cpp | 22 +- .../operation/hash/OperationLDLinear.hpp | 18 +- .../hash/OperationLDLinearBoundary.cpp | 22 +- .../hash/OperationLDLinearBoundary.hpp | 18 +- .../operation/hash/OperationLELinear.cpp | 28 +- .../operation/hash/OperationLELinear.hpp | 18 +- .../hash/OperationLELinearBoundary.cpp | 24 +- .../hash/OperationLELinearBoundary.hpp | 18 +- .../operation/hash/OperationLFLinear.cpp | 22 +- .../operation/hash/OperationLFLinear.hpp | 18 +- .../hash/OperationLFLinearBoundary.cpp | 22 +- .../hash/OperationLFLinearBoundary.hpp | 18 +- finance/src/sgpp/finance/tools/Hedging.cpp | 43 +- finance/src/sgpp/finance/tools/Hedging.hpp | 17 +- .../finance/tools/VariableDiscountFactor.cpp | 24 +- .../finance/tools/VariableDiscountFactor.hpp | 16 +- finance/src/sgpp_finance.hpp | 1 - misc/SConscript | 25 +- .../src/sgpp/misc/operation/MiscOpFactory.cpp | 11 +- .../src/sgpp/misc/operation/MiscOpFactory.hpp | 8 +- .../pde/algorithm/UpDownOneOpDimEnhanced.cpp | 60 +- .../pde/algorithm/UpDownOneOpDimEnhanced.hpp | 36 +- optimization/SConscript | 26 +- .../scalar/ComponentScalarFunction.hpp | 81 +- .../ComponentScalarFunctionGradient.hpp | 86 +- .../scalar/ComponentScalarFunctionHessian.hpp | 94 +- .../scalar/InterpolantScalarFunction.hpp | 35 +- .../InterpolantScalarFunctionGradient.hpp | 38 +- .../InterpolantScalarFunctionHessian.hpp | 41 +- .../function/scalar/ScalarFunction.hpp | 18 +- .../scalar/ScalarFunctionGradient.hpp | 24 +- .../function/scalar/ScalarFunctionHessian.hpp | 26 +- .../function/scalar/WrapperScalarFunction.hpp | 22 +- .../scalar/WrapperScalarFunctionGradient.hpp | 26 +- .../scalar/WrapperScalarFunctionHessian.hpp | 28 +- .../function/vector/EmptyVectorFunction.cpp | 18 + .../function/vector/EmptyVectorFunction.hpp | 13 +- .../vector/EmptyVectorFunctionGradient.cpp | 18 + .../vector/EmptyVectorFunctionGradient.hpp | 14 +- .../vector/InterpolantVectorFunction.hpp | 36 +- .../InterpolantVectorFunctionGradient.hpp | 40 +- .../InterpolantVectorFunctionHessian.hpp | 46 +- .../function/vector/VectorFunction.hpp | 25 +- .../vector/VectorFunctionGradient.hpp | 25 +- .../function/vector/VectorFunctionHessian.hpp | 26 +- .../function/vector/WrapperVectorFunction.hpp | 22 +- .../vector/WrapperVectorFunctionGradient.hpp | 30 +- .../vector/WrapperVectorFunctionHessian.hpp | 34 +- .../gridgen/HashRefinementMultiple.hpp | 27 +- .../gridgen/IterativeGridGenerator.cpp | 35 +- .../gridgen/IterativeGridGenerator.hpp | 12 +- .../IterativeGridGeneratorLinearSurplus.cpp | 126 +- .../IterativeGridGeneratorLinearSurplus.hpp | 19 +- .../IterativeGridGeneratorRitterNovak.cpp | 101 +- .../IterativeGridGeneratorRitterNovak.hpp | 27 +- .../gridgen/IterativeGridGeneratorSOO.cpp | 57 +- .../gridgen/IterativeGridGeneratorSOO.hpp | 15 +- .../operation/OptimizationOpFactory.cpp | 46 +- .../operation/OptimizationOpFactory.hpp | 9 +- .../hash/OperationMultipleHierarchisation.hpp | 21 +- ...perationMultipleHierarchisationBspline.cpp | 27 +- ...perationMultipleHierarchisationBspline.hpp | 16 +- ...MultipleHierarchisationBsplineBoundary.cpp | 26 +- ...MultipleHierarchisationBsplineBoundary.hpp | 17 +- ...leHierarchisationBsplineClenshawCurtis.cpp | 32 +- ...leHierarchisationBsplineClenshawCurtis.hpp | 19 +- ...ltipleHierarchisationFundamentalSpline.cpp | 24 +- ...ltipleHierarchisationFundamentalSpline.hpp | 17 +- ...OperationMultipleHierarchisationLinear.cpp | 27 +- ...OperationMultipleHierarchisationLinear.hpp | 16 +- ...nMultipleHierarchisationLinearBoundary.cpp | 25 +- ...nMultipleHierarchisationLinearBoundary.hpp | 17 +- ...pleHierarchisationLinearClenshawCurtis.cpp | 26 +- ...pleHierarchisationLinearClenshawCurtis.hpp | 19 +- ...ationMultipleHierarchisationModBspline.cpp | 27 +- ...ationMultipleHierarchisationModBspline.hpp | 16 +- ...ierarchisationModBsplineClenshawCurtis.cpp | 33 +- ...ierarchisationModBsplineClenshawCurtis.hpp | 19 +- ...pleHierarchisationModFundamentalSpline.cpp | 24 +- ...pleHierarchisationModFundamentalSpline.hpp | 19 +- ...rationMultipleHierarchisationModLinear.cpp | 27 +- ...rationMultipleHierarchisationModLinear.hpp | 16 +- ...ationMultipleHierarchisationModWavelet.cpp | 27 +- ...ationMultipleHierarchisationModWavelet.hpp | 16 +- ...perationMultipleHierarchisationWavelet.cpp | 27 +- ...perationMultipleHierarchisationWavelet.hpp | 16 +- ...MultipleHierarchisationWaveletBoundary.cpp | 26 +- ...MultipleHierarchisationWaveletBoundary.hpp | 17 +- .../constrained/AugmentedLagrangian.cpp | 289 ++- .../constrained/AugmentedLagrangian.hpp | 31 +- .../constrained/ConstrainedOptimizer.hpp | 30 +- .../optimizer/constrained/LogBarrier.cpp | 149 +- .../optimizer/constrained/LogBarrier.hpp | 22 +- .../optimizer/constrained/SquaredPenalty.cpp | 181 +- .../optimizer/constrained/SquaredPenalty.hpp | 31 +- .../least_squares/LeastSquaresOptimizer.hpp | 66 +- .../least_squares/LevenbergMarquardt.cpp | 119 +- .../least_squares/LevenbergMarquardt.hpp | 33 +- .../unconstrained/AdaptiveGradientDescent.cpp | 78 +- .../unconstrained/AdaptiveGradientDescent.hpp | 22 +- .../unconstrained/AdaptiveNewton.cpp | 156 +- .../unconstrained/AdaptiveNewton.hpp | 28 +- .../optimizer/unconstrained/BFGS.cpp | 81 +- .../optimizer/unconstrained/BFGS.hpp | 20 +- .../optimizer/unconstrained/CMAES.cpp | 65 +- .../optimizer/unconstrained/CMAES.hpp | 13 +- .../unconstrained/DifferentialEvolution.cpp | 126 +- .../unconstrained/DifferentialEvolution.hpp | 32 +- .../unconstrained/GradientDescent.cpp | 85 +- .../unconstrained/GradientDescent.hpp | 23 +- .../unconstrained/LineSearchArmijo.hpp | 22 +- .../optimizer/unconstrained/MultiStart.cpp | 86 +- .../optimizer/unconstrained/MultiStart.hpp | 18 +- .../optimizer/unconstrained/NLCG.cpp | 94 +- .../optimizer/unconstrained/NLCG.hpp | 20 +- .../optimizer/unconstrained/NelderMead.cpp | 79 +- .../optimizer/unconstrained/NelderMead.hpp | 19 +- .../optimizer/unconstrained/Newton.cpp | 160 +- .../optimizer/unconstrained/Newton.hpp | 39 +- .../optimizer/unconstrained/Rprop.cpp | 80 +- .../optimizer/unconstrained/Rprop.hpp | 23 +- .../unconstrained/UnconstrainedOptimizer.hpp | 60 +- .../optimization/sle/solver/Armadillo.cpp | 46 +- .../optimization/sle/solver/Armadillo.hpp | 15 +- .../src/sgpp/optimization/sle/solver/Auto.cpp | 47 +- .../src/sgpp/optimization/sle/solver/Auto.hpp | 15 +- .../sgpp/optimization/sle/solver/BiCGStab.cpp | 64 +- .../sgpp/optimization/sle/solver/BiCGStab.hpp | 14 +- .../sgpp/optimization/sle/solver/Eigen.cpp | 63 +- .../sgpp/optimization/sle/solver/Eigen.hpp | 15 +- .../sle/solver/GaussianElimination.cpp | 20 +- .../sle/solver/GaussianElimination.hpp | 11 +- .../sgpp/optimization/sle/solver/Gmmpp.cpp | 76 +- .../sgpp/optimization/sle/solver/Gmmpp.hpp | 11 +- .../optimization/sle/solver/SLESolver.hpp | 20 +- .../sgpp/optimization/sle/solver/UMFPACK.cpp | 110 +- .../sgpp/optimization/sle/solver/UMFPACK.hpp | 18 +- .../optimization/sle/system/CloneableSLE.hpp | 20 +- .../sgpp/optimization/sle/system/FullSLE.hpp | 29 +- .../sle/system/HierarchisationSLE.hpp | 242 +-- .../src/sgpp/optimization/sle/system/SLE.hpp | 22 +- .../test_problems/TestScalarFunction.cpp | 24 +- .../test_problems/TestScalarFunction.hpp | 13 +- .../test_problems/TestVectorFunction.cpp | 27 +- .../test_problems/TestVectorFunction.hpp | 17 +- .../constrained/ConstrainedTestProblem.cpp | 25 +- .../constrained/ConstrainedTestProblem.hpp | 13 +- .../test_problems/constrained/Floudas.cpp | 91 +- .../test_problems/constrained/Floudas.hpp | 34 +- .../test_problems/constrained/G03.cpp | 86 +- .../test_problems/constrained/G03.hpp | 42 +- .../test_problems/constrained/G04.cpp | 111 +- .../test_problems/constrained/G04.hpp | 34 +- .../test_problems/constrained/G05.cpp | 105 +- .../test_problems/constrained/G05.hpp | 34 +- .../test_problems/constrained/G06.cpp | 89 +- .../test_problems/constrained/G06.hpp | 34 +- .../test_problems/constrained/G08.cpp | 90 +- .../test_problems/constrained/G08.hpp | 34 +- .../test_problems/constrained/G09.cpp | 99 +- .../test_problems/constrained/G09.hpp | 34 +- .../test_problems/constrained/G10.cpp | 96 +- .../test_problems/constrained/G10.hpp | 34 +- .../test_problems/constrained/G11.cpp | 86 +- .../test_problems/constrained/G11.hpp | 34 +- .../test_problems/constrained/G12.cpp | 94 +- .../test_problems/constrained/G12.hpp | 34 +- .../test_problems/constrained/G13.cpp | 86 +- .../test_problems/constrained/G13.hpp | 34 +- .../test_problems/constrained/Simionescu.cpp | 88 +- .../test_problems/constrained/Simionescu.hpp | 34 +- .../test_problems/constrained/Soland.cpp | 87 +- .../test_problems/constrained/Soland.hpp | 34 +- .../unconstrained/AbsoluteValue.cpp | 35 +- .../unconstrained/AbsoluteValue.hpp | 20 +- .../test_problems/unconstrained/Ackley.cpp | 40 +- .../test_problems/unconstrained/Ackley.hpp | 20 +- .../test_problems/unconstrained/Beale.cpp | 35 +- .../test_problems/unconstrained/Beale.hpp | 16 +- .../test_problems/unconstrained/Branin.cpp | 41 +- .../test_problems/unconstrained/Branin.hpp | 18 +- .../unconstrained/BubbleWrap.cpp | 35 +- .../unconstrained/BubbleWrap.hpp | 22 +- .../test_problems/unconstrained/EasomYang.cpp | 35 +- .../test_problems/unconstrained/EasomYang.hpp | 22 +- .../test_problems/unconstrained/Eggholder.cpp | 38 +- .../test_problems/unconstrained/Eggholder.hpp | 19 +- .../unconstrained/GoldsteinPrice.cpp | 46 +- .../unconstrained/GoldsteinPrice.hpp | 16 +- .../test_problems/unconstrained/Griewank.cpp | 35 +- .../test_problems/unconstrained/Griewank.hpp | 22 +- .../test_problems/unconstrained/Hartman3.cpp | 35 +- .../test_problems/unconstrained/Hartman3.hpp | 18 +- .../test_problems/unconstrained/Hartman6.cpp | 35 +- .../test_problems/unconstrained/Hartman6.hpp | 18 +- .../unconstrained/Himmelblau.cpp | 35 +- .../unconstrained/Himmelblau.hpp | 16 +- .../unconstrained/HoelderTable.cpp | 43 +- .../unconstrained/HoelderTable.hpp | 18 +- .../unconstrained/IncreasingPower.cpp | 38 +- .../unconstrained/IncreasingPower.hpp | 22 +- .../unconstrained/Michalewicz.cpp | 38 +- .../unconstrained/Michalewicz.hpp | 16 +- .../test_problems/unconstrained/Mladineo.cpp | 42 +- .../test_problems/unconstrained/Mladineo.hpp | 18 +- .../test_problems/unconstrained/Perm.cpp | 38 +- .../test_problems/unconstrained/Perm.hpp | 20 +- .../test_problems/unconstrained/Rastrigin.cpp | 35 +- .../test_problems/unconstrained/Rastrigin.hpp | 22 +- .../unconstrained/Rosenbrock.cpp | 35 +- .../unconstrained/Rosenbrock.hpp | 20 +- .../test_problems/unconstrained/SHCB.cpp | 39 +- .../test_problems/unconstrained/SHCB.hpp | 16 +- .../test_problems/unconstrained/Schwefel.cpp | 35 +- .../test_problems/unconstrained/Schwefel.hpp | 20 +- .../test_problems/unconstrained/Sphere.cpp | 35 +- .../test_problems/unconstrained/Sphere.hpp | 20 +- .../unconstrained/TremblingParabola.cpp | 40 +- .../unconstrained/TremblingParabola.hpp | 16 +- .../UnconstrainedTestProblem.cpp | 25 +- .../UnconstrainedTestProblem.hpp | 13 +- .../src/sgpp/optimization/tools/FileIO.cpp | 40 +- .../src/sgpp/optimization/tools/FileIO.hpp | 40 +- .../src/sgpp/optimization/tools/Math.cpp | 21 +- .../src/sgpp/optimization/tools/Math.hpp | 11 +- .../src/sgpp/optimization/tools/MutexType.hpp | 27 +- .../src/sgpp/optimization/tools/Printer.cpp | 76 +- .../src/sgpp/optimization/tools/Printer.hpp | 40 +- .../tools/RandomNumberGenerator.cpp | 27 +- .../tools/RandomNumberGenerator.hpp | 9 +- .../sgpp/optimization/tools/ScopedLock.hpp | 13 +- parallel/SConscript | 26 +- pde/SConscript | 25 +- .../HeatEquationParabolicPDESolverSystem.cpp | 58 +- .../HeatEquationParabolicPDESolverSystem.hpp | 30 +- ...ionParabolicPDESolverSystemParallelOMP.cpp | 219 +-- ...ionParabolicPDESolverSystemParallelOMP.hpp | 35 +- ...uationEllipticPDESolverSystemDirichlet.cpp | 24 +- ...uationEllipticPDESolverSystemDirichlet.hpp | 20 +- pde/src/sgpp/pde/algorithm/StdUpDown.cpp | 51 +- pde/src/sgpp/pde/algorithm/StdUpDown.hpp | 31 +- .../sgpp/pde/algorithm/UpDownFourOpDims.cpp | 335 ++-- .../sgpp/pde/algorithm/UpDownFourOpDims.hpp | 338 ++-- pde/src/sgpp/pde/algorithm/UpDownOneOpDim.cpp | 105 +- pde/src/sgpp/pde/algorithm/UpDownOneOpDim.hpp | 47 +- .../pde/algorithm/UpDownOneOpDimEnhanced.cpp | 61 +- .../pde/algorithm/UpDownOneOpDimEnhanced.hpp | 37 +- .../algorithm/UpDownOneOpDimWithShadow.cpp | 41 +- .../algorithm/UpDownOneOpDimWithShadow.hpp | 39 +- .../sgpp/pde/algorithm/UpDownTwoOpDims.cpp | 166 +- .../sgpp/pde/algorithm/UpDownTwoOpDims.hpp | 70 +- .../pde/application/EllipticPDESolver.cpp | 12 +- .../pde/application/EllipticPDESolver.hpp | 18 +- .../pde/application/HeatEquationSolver.cpp | 182 +- .../pde/application/HeatEquationSolver.hpp | 36 +- .../HeatEquationSolverWithStretching.cpp | 182 +- .../HeatEquationSolverWithStretching.hpp | 61 +- pde/src/sgpp/pde/application/PDESolver.cpp | 150 +- pde/src/sgpp/pde/application/PDESolver.hpp | 88 +- .../pde/application/ParabolicPDESolver.cpp | 12 +- .../pde/application/ParabolicPDESolver.hpp | 33 +- .../pde/application/PoissonEquationSolver.cpp | 175 +- .../pde/application/PoissonEquationSolver.hpp | 32 +- .../LaplaceEnhancedDownBBLinearBoundary.cpp | 48 +- .../LaplaceEnhancedDownBBLinearBoundary.hpp | 24 +- .../LaplaceEnhancedUpBBLinearBoundary.cpp | 44 +- .../LaplaceEnhancedUpBBLinearBoundary.hpp | 24 +- .../PhiPhiDownBBLinearBoundary.cpp | 30 +- .../PhiPhiDownBBLinearBoundary.hpp | 23 +- .../PhiPhiUpBBLinearBoundary.cpp | 30 +- .../PhiPhiUpBBLinearBoundary.hpp | 23 +- .../DowndPhidPhiBBIterativeLinear.cpp | 20 +- .../DowndPhidPhiBBIterativeLinear.hpp | 19 +- .../LaplaceEnhancedDownBBLinear.cpp | 158 +- .../LaplaceEnhancedDownBBLinear.hpp | 48 +- .../LaplaceEnhancedUpBBLinear.cpp | 129 +- .../LaplaceEnhancedUpBBLinear.hpp | 34 +- .../algorithm_sweep/PhiPhiDownBBLinear.cpp | 39 +- .../algorithm_sweep/PhiPhiDownBBLinear.hpp | 29 +- .../algorithm_sweep/PhiPhiUpBBLinear.cpp | 40 +- .../algorithm_sweep/PhiPhiUpBBLinear.hpp | 30 +- ...dPhiBBIterativeLinearStretchedBoundary.cpp | 37 +- ...dPhiBBIterativeLinearStretchedBoundary.hpp | 18 +- ...dPhiBBIterativeLinearStretchedBoundary.cpp | 19 +- ...dPhiBBIterativeLinearStretchedBoundary.hpp | 17 +- .../PhiPhiDownBBLinearStretchedBoundary.cpp | 28 +- .../PhiPhiDownBBLinearStretchedBoundary.hpp | 24 +- .../PhiPhiUpBBLinearStretchedBoundary.cpp | 30 +- .../PhiPhiUpBBLinearStretchedBoundary.hpp | 23 +- ...DowndPhidPhiBBIterativeLinearStretched.cpp | 25 +- ...DowndPhidPhiBBIterativeLinearStretched.hpp | 17 +- .../PhiPhiDownBBLinearStretched.cpp | 38 +- .../PhiPhiDownBBLinearStretched.hpp | 26 +- .../PhiPhiUpBBLinearStretched.cpp | 40 +- .../PhiPhiUpBBLinearStretched.hpp | 27 +- .../algorithm_sweep/PhiPhiDownModLinear.cpp | 72 +- .../algorithm_sweep/PhiPhiDownModLinear.hpp | 22 +- .../algorithm_sweep/PhiPhiUpModLinear.cpp | 38 +- .../algorithm_sweep/PhiPhiUpModLinear.hpp | 22 +- .../algorithm_sweep/dPhidPhiDownModLinear.cpp | 44 +- .../algorithm_sweep/dPhidPhiDownModLinear.hpp | 28 +- .../algorithm_sweep/dPhidPhiUpModLinear.cpp | 33 +- .../algorithm_sweep/dPhidPhiUpModLinear.hpp | 25 +- .../LaplaceDownGradientPrewavelet.cpp | 169 +- .../LaplaceDownGradientPrewavelet.hpp | 35 +- .../LaplaceUpGradientPrewavelet.cpp | 119 +- .../LaplaceUpGradientPrewavelet.hpp | 24 +- .../algorithm_sweep/LaplaceUpPrewavelet.cpp | 101 +- .../algorithm_sweep/LaplaceUpPrewavelet.hpp | 21 +- pde/src/sgpp/pde/operation/PdeOpFactory.cpp | 78 +- pde/src/sgpp/pde/operation/PdeOpFactory.hpp | 15 +- .../DowndPhidPhiBBIterativeLinearBoundary.cpp | 35 +- .../DowndPhidPhiBBIterativeLinearBoundary.hpp | 19 +- .../hash/OperationEllipticPDESolverSystem.cpp | 17 +- .../hash/OperationEllipticPDESolverSystem.hpp | 17 +- ...rationEllipticPDESolverSystemDirichlet.cpp | 38 +- ...rationEllipticPDESolverSystemDirichlet.hpp | 20 +- ...nEllipticPDESolverSystemFreeBoundaries.cpp | 22 +- ...nEllipticPDESolverSystemFreeBoundaries.hpp | 20 +- .../hash/OperationLTwoDotProductLinear.cpp | 16 +- .../hash/OperationLTwoDotProductLinear.hpp | 18 +- .../OperationLTwoDotProductLinearBoundary.cpp | 17 +- .../OperationLTwoDotProductLinearBoundary.hpp | 18 +- ...OperationLTwoDotProductLinearStretched.cpp | 18 +- ...OperationLTwoDotProductLinearStretched.hpp | 19 +- ...nLTwoDotProductLinearStretchedBoundary.cpp | 24 +- ...nLTwoDotProductLinearStretchedBoundary.hpp | 20 +- .../hash/OperationLaplaceEnhancedLinear.cpp | 25 +- .../hash/OperationLaplaceEnhancedLinear.hpp | 22 +- ...OperationLaplaceEnhancedLinearBoundary.cpp | 22 +- ...OperationLaplaceEnhancedLinearBoundary.hpp | 19 +- .../operation/hash/OperationLaplaceLinear.cpp | 32 +- .../operation/hash/OperationLaplaceLinear.hpp | 34 +- .../hash/OperationLaplaceLinearBoundary.cpp | 27 +- .../hash/OperationLaplaceLinearBoundary.hpp | 31 +- .../hash/OperationLaplaceLinearStretched.cpp | 27 +- .../hash/OperationLaplaceLinearStretched.hpp | 29 +- ...perationLaplaceLinearStretchedBoundary.cpp | 28 +- ...perationLaplaceLinearStretchedBoundary.hpp | 26 +- .../hash/OperationLaplaceModLinear.cpp | 24 +- .../hash/OperationLaplaceModLinear.hpp | 22 +- .../hash/OperationLaplacePrewavelet.cpp | 30 +- .../hash/OperationLaplacePrewavelet.hpp | 30 +- .../OperationMatrixLTwoDotExplicitLinear.cpp | 54 +- .../OperationMatrixLTwoDotExplicitLinear.hpp | 13 +- ...ionMatrixLTwoDotExplicitLinearBoundary.cpp | 39 +- ...ionMatrixLTwoDotExplicitLinearBoundary.hpp | 20 +- ...OperationMatrixLTwoDotExplicitPeriodic.cpp | 63 +- ...OperationMatrixLTwoDotExplicitPeriodic.hpp | 15 +- .../hash/OperationMatrixLTwoDotPeriodic.cpp | 44 +- .../hash/OperationMatrixLTwoDotPeriodic.hpp | 16 +- ...ationParabolicPDESolverSystemDirichlet.cpp | 201 +- ...ationParabolicPDESolverSystemDirichlet.hpp | 16 +- ...ParabolicPDESolverSystemFreeBoundaries.cpp | 36 +- ...ParabolicPDESolverSystemFreeBoundaries.hpp | 19 +- .../UpdPhidPhiBBIterativeLinearBoundary.cpp | 17 +- .../UpdPhidPhiBBIterativeLinearBoundary.hpp | 17 +- pde/src/sgpp_pde.hpp | 1 - quadrature/SConscript | 25 +- .../sgpp/quadrature/QuadratureOpFactory.cpp | 6 +- .../sgpp/quadrature/QuadratureOpFactory.hpp | 7 +- quadrature/src/sgpp/quadrature/Random.cpp | 8 +- quadrature/src/sgpp/quadrature/Random.hpp | 7 +- .../hash/OperationQuadratureMCAdvanced.cpp | 63 +- .../hash/OperationQuadratureMCAdvanced.hpp | 19 +- .../sampling/HaltonSampleGenerator.cpp | 43 +- .../sampling/HaltonSampleGenerator.hpp | 12 +- .../LatinHypercubeSampleGenerator.cpp | 44 +- .../LatinHypercubeSampleGenerator.hpp | 16 +- .../sampling/NaiveSampleGenerator.cpp | 18 +- .../sampling/NaiveSampleGenerator.hpp | 13 +- .../quadrature/sampling/SampleGenerator.cpp | 29 +- .../quadrature/sampling/SampleGenerator.hpp | 16 +- .../sgpp/quadrature/sampling/SamplerTypes.hpp | 7 +- .../sampling/StratifiedSampleGenerator.cpp | 42 +- .../sampling/StratifiedSampleGenerator.hpp | 14 +- solver/SConscript | 26 +- solver/src/sgpp/solver/ODESolver.hpp | 16 +- solver/src/sgpp/solver/SGSolver.hpp | 35 +- solver/src/sgpp/solver/SGSolverSP.hpp | 35 +- solver/src/sgpp/solver/SLESolver.hpp | 21 +- solver/src/sgpp/solver/SLESolverSP.hpp | 20 +- solver/src/sgpp/solver/TypesSolver.hpp | 13 +- solver/src/sgpp/solver/ode/AdamsBashforth.cpp | 41 +- solver/src/sgpp/solver/ode/AdamsBashforth.hpp | 10 +- solver/src/sgpp/solver/ode/CrankNicolson.cpp | 33 +- solver/src/sgpp/solver/ode/CrankNicolson.hpp | 8 +- solver/src/sgpp/solver/ode/Euler.cpp | 41 +- solver/src/sgpp/solver/ode/Euler.hpp | 15 +- .../src/sgpp/solver/ode/StepsizeControl.cpp | 91 +- .../src/sgpp/solver/ode/StepsizeControl.hpp | 17 +- .../sgpp/solver/ode/StepsizeControlBDF.cpp | 27 +- .../sgpp/solver/ode/StepsizeControlBDF.hpp | 15 +- .../src/sgpp/solver/ode/StepsizeControlEJ.cpp | 37 +- .../src/sgpp/solver/ode/StepsizeControlEJ.hpp | 15 +- .../src/sgpp/solver/ode/StepsizeControlH.cpp | 38 +- .../src/sgpp/solver/ode/StepsizeControlH.hpp | 31 +- .../src/sgpp/solver/ode/StepsizeControlMC.cpp | 31 +- .../src/sgpp/solver/ode/StepsizeControlMC.hpp | 14 +- solver/src/sgpp/solver/ode/VarTimestep.cpp | 44 +- solver/src/sgpp/solver/ode/VarTimestep.hpp | 28 +- .../OperationParabolicPDESolverSystem.cpp | 45 +- .../OperationParabolicPDESolverSystem.hpp | 15 +- solver/src/sgpp/solver/sle/BiCGStab.cpp | 40 +- solver/src/sgpp/solver/sle/BiCGStab.hpp | 18 +- solver/src/sgpp/solver/sle/BiCGStabSP.cpp | 41 +- solver/src/sgpp/solver/sle/BiCGStabSP.hpp | 18 +- .../sgpp/solver/sle/ConjugateGradients.cpp | 45 +- .../sgpp/solver/sle/ConjugateGradients.hpp | 18 +- .../sgpp/solver/sle/ConjugateGradientsSP.cpp | 41 +- .../sgpp/solver/sle/ConjugateGradientsSP.hpp | 24 +- solver/src/sgpp_solver.hpp | 1 - tools/cpplint.py | 25 +- 736 files changed, 15643 insertions(+), 20817 deletions(-) delete mode 100644 base/doc/doxygen/code_examples_continued_learning.doxy delete mode 100644 base/doc/doxygen/code_examples_quick_start.doxy delete mode 100644 base/doc/doxygen/styleguide.doxy delete mode 100644 base/doc/doxygen/windows.doxy delete mode 100644 base/examples/all_simple.output.txt delete mode 100644 base/examples/all_simple_quadrature.output.txt delete mode 100644 base/examples/c++_simple.cpp delete mode 100644 base/examples/c++_simple_predictive_refinement.cpp delete mode 100644 base/examples/c++_simple_quadrature.cpp delete mode 100644 base/examples/c++_simple_refinement.cpp delete mode 100644 base/examples/matlab_simple.m delete mode 100644 base/examples/python_simple.py delete mode 100644 base/examples/python_simple_predictive_ANOVArefinement.py delete mode 100644 base/examples/python_simple_predictive_refinement.py delete mode 100644 base/examples/python_simple_refinement.py mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiDownBBLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiDownBBLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiUpBBLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiUpBBLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiDownBBLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiDownBBLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiUpBBLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiUpBBLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiDownBBLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiDownBBLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiUpBBLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiUpBBLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiDownBBLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiDownBBLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiUpBBLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiUpBBLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiDownBBLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiDownBBLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiUpBBLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiUpBBLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiDownBBLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiDownBBLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiUpBBLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiUpBBLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiDownBBLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiDownBBLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiUpBBLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiUpBBLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiDownBBLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiDownBBLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiUpBBLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiUpBBLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinear.cpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinear.hpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretched.cpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretched.hpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretchedBoundary.cpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretchedBoundary.hpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationHestonFLinear.cpp mode change 100755 => 100644 finance/src/sgpp/finance/operation/hash/OperationHestonFLinear.hpp create mode 100644 optimization/src/sgpp/optimization/function/vector/EmptyVectorFunction.cpp create mode 100644 optimization/src/sgpp/optimization/function/vector/EmptyVectorFunctionGradient.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/gridgen/HashRefinementMultiple.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/OptimizationOpFactory.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/OptimizationOpFactory.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisation.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBspline.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBspline.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineBoundary.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineBoundary.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineClenshawCurtis.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineClenshawCurtis.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationFundamentalSpline.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationFundamentalSpline.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinear.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinear.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearBoundary.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearBoundary.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearClenshawCurtis.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearClenshawCurtis.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBspline.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBspline.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBsplineClenshawCurtis.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBsplineClenshawCurtis.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModFundamentalSpline.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModFundamentalSpline.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModLinear.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModLinear.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModWavelet.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModWavelet.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWavelet.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWavelet.hpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWaveletBoundary.cpp mode change 100755 => 100644 optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWaveletBoundary.hpp mode change 100755 => 100644 pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystemParallelOMP.cpp mode change 100755 => 100644 pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystemParallelOMP.hpp mode change 100755 => 100644 pde/src/sgpp/pde/algorithm/PoissonEquationEllipticPDESolverSystemDirichlet.cpp mode change 100755 => 100644 pde/src/sgpp/pde/algorithm/PoissonEquationEllipticPDESolverSystemDirichlet.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedUpBBLinearBoundary.cpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedUpBBLinearBoundary.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/boundary/DowndPhidPhiBBIterativeLinearStretchedBoundary.cpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/boundary/DowndPhidPhiBBIterativeLinearStretchedBoundary.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/boundary/UpdPhidPhiBBIterativeLinearStretchedBoundary.cpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/boundary/UpdPhidPhiBBIterativeLinearStretchedBoundary.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiDownBBLinearStretchedBoundary.cpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiDownBBLinearStretchedBoundary.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiUpBBLinearStretchedBoundary.cpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiUpBBLinearStretchedBoundary.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/noboundary/DowndPhidPhiBBIterativeLinearStretched.cpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/noboundary/DowndPhidPhiBBIterativeLinearStretched.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiDownBBLinearStretched.cpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiDownBBLinearStretched.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiUpBBLinearStretched.cpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiUpBBLinearStretched.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiDownModLinear.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiUpModLinear.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiDownModLinear.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiUpModLinear.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceDownGradientPrewavelet.cpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceDownGradientPrewavelet.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpGradientPrewavelet.cpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpGradientPrewavelet.hpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpPrewavelet.cpp mode change 100755 => 100644 pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpPrewavelet.hpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystem.cpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystem.hpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemDirichlet.cpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemDirichlet.hpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemFreeBoundaries.cpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemFreeBoundaries.hpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretched.cpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretched.hpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretchedBoundary.cpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretchedBoundary.hpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinearBoundary.cpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinearBoundary.hpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLaplaceLinear.hpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearBoundary.hpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretched.cpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretched.hpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretchedBoundary.cpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretchedBoundary.hpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLaplaceModLinear.hpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLaplacePrewavelet.cpp mode change 100755 => 100644 pde/src/sgpp/pde/operation/hash/OperationLaplacePrewavelet.hpp diff --git a/.clang-format b/.clang-format index 2593ef54bd..d79fba453f 100644 --- a/.clang-format +++ b/.clang-format @@ -1 +1,2 @@ -BasedOnStyle: Google \ No newline at end of file +BasedOnStyle: Google +ColumnLimit: 100 \ No newline at end of file diff --git a/.gitignore b/.gitignore index a81c28b52e..289bde467d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ *.so *.exe +#ignoring cpplint files +*.lint + #ignoring swig build files *.jar *doc.i diff --git a/SConstruct b/SConstruct index 700250de3e..b1556cabe5 100644 --- a/SConstruct +++ b/SConstruct @@ -9,6 +9,7 @@ import os import SGppConfigure from SCons.Script.SConscript import SConsEnvironment import warnings +import subprocess from Helper import * @@ -81,6 +82,7 @@ vars.Add('BOOST_LIBRARY_PATH', 'Specifies the location of the boost library.', ' vars.Add(BoolVariable('COMPILE_BOOST_TESTS', 'Compile the test cases written using Boost Test.', True)) vars.Add(BoolVariable('COMPILE_BOOST_PERFORMANCE_TESTS', 'Compile the performance tests written using Boost Test. Currently only buildable with OpenCL enabled', False)) vars.Add(BoolVariable('RUN_BOOST_TESTS', 'Run the test cases written using Boost Test (only if COMPILE_BOOST_TESTS is true).', True)) +vars.Add(BoolVariable('RUN_CPPLINT', 'Check compliance to Google\'s style guide using cpplint.', True)) vars.Add(BoolVariable('USE_DOUBLE_PRECISION', 'If disabled, SG++ will compile using single precision (floats).', True)) vars.Add(BoolVariable('USE_ARMADILLO', 'Sets if Armadillo should be used (only relevant for SGPP::optimization).', False)) @@ -250,6 +252,38 @@ else: PYSGPP_PACKAGE_PATH.abspath]) # ------------------------------------------------------------------------- +def lintAction(target, source, env): + p = subprocess.Popen(["python", "tools/cpplint.py", "--ignorecfg=yes", + "--extensions=cpp,hpp", "--linelength=100", + source[0].abspath], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + # wait for termination and get output on stdout and stderr + stdout, stderr = p.communicate() + # cpplint prints on stderr + for line in stderr.splitlines(): + # skip status lines, empty lines, and some warning types + if ("Done processing " in line) or \ + ("Total errors found: " in line) or \ + ("Is this a non-const reference? " + + "If so, make const or use a pointer:" in line) or \ + ("Consider using rand_r(...) instead of rand(...) for " + + "improved thread safety." in line) or \ + (" is an unapproved C++11 header." in line) or \ + (line == ""): + pass + else: + parts = line.split(": ") + location = parts[0] + message = ": ".join(parts[1:]) + print location + ": warning: " + message + # touch file without writing anything + # (to indicate for the next run of SCons that we already checked this file) + with open(target[0].abspath, "w"): pass + +env.Export('lintAction') + +# ------------------------------------------------------------------------- + # add custom builder to trigger the unittests after the build and to enable a special import test if not env['NO_UNIT_TESTS'] and env['SG_PYTHON']: # do the actual thing diff --git a/base/SConscript b/base/SConscript index 5e4439fdcf..2fa0df8ff8 100755 --- a/base/SConscript +++ b/base/SConscript @@ -6,7 +6,6 @@ import os import fnmatch -import subprocess Import('env') Import('BUILD_DIR') @@ -17,6 +16,7 @@ Import('installTargetList') Import('exampleTargetList') Import('headerSourceList') Import('headerDestList') +Import('lintAction') moduleDependencies = [] Export('moduleDependencies') @@ -27,21 +27,31 @@ if env['USE_OCL']: moduleDependencies = additionalDependencies + moduleDependencies +cpps = [] +hpps = [] objs = [] + for currentFolder, subdirNames, fileNames in os.walk("src", topdown=True): if os.path.exists(os.path.join(currentFolder, "SConscript")): - objsSubmodule = env.SConscript(os.path.join(currentFolder, "SConscript")) + cppsSubmodule, hppsSubmodule, objsSubmodule = \ + env.SConscript(os.path.join(currentFolder, "SConscript")) objs += objsSubmodule + for hpp in hppsSubmodule: + headerSourceList.append(os.path.join(moduleName, hpp)) + headerDestList.append(hpp.split(os.sep, 1)[1]) # remove subfolders from iteration, as they are already processed (this is why topdown=True is also required subdirNames[:] = [] else: for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) if currentFolder != 'src': for fileName in fnmatch.filter(fileNames, '*.hpp'): - headerSourceList.append(os.path.join(moduleName, currentFolder, fileName)) - headerDestList.append(os.path.join(currentFolder, fileName).split(os.sep,1)[1]) + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + headerSourceList.append(os.path.join(moduleName, hpp)) + headerDestList.append(hpp.split(os.sep, 1)[1]) libname = "sgpp%s" % moduleName if env['USE_STATICLIB']: @@ -62,6 +72,11 @@ else: libInstall = env.Install(BUILD_DIR, lib) +if env['RUN_CPPLINT']: + for path in cpps + hpps: + lintCommand = env.Command(path + ".lint", path, lintAction) + env.Depends(lib, lintCommand) + if env["ARCH"] != "mic": for fileName in os.listdir("examples"): if fnmatch.fnmatch(fileName, "*.cpp"): diff --git a/base/doc/doxygen/code_examples_continued_learning.doxy b/base/doc/doxygen/code_examples_continued_learning.doxy deleted file mode 100644 index bd35705db9..0000000000 --- a/base/doc/doxygen/code_examples_continued_learning.doxy +++ /dev/null @@ -1,112 +0,0 @@ -/** -@page code_examples_continued_learning Code Examples: Resuming learning Process - -Sometimes one needs to resume the learning process using the saved grid and alpha -files in order to refine the learner or to use some different learning -parameters. And while the definition of the setup with command line arguments may -be comfortable for the most common tasks, the default behaviour in this case -will result in the recalculating of the last learning iteration. In order to -change this behaviour the direct interaction with Learner object is needed. - -This tutorial shows how to create the Learner object using your command line -arguments as well as how to omit the recomputation of the last iteration resuming -the learning. - -@section continued_learning_examples__overview Overview -- \ref continued_learning_examples__builder_generation -- \ref continued_learning_examples__learning - - -@section continued_learning_examples__builder_generation Automatic Generation of the Builder code - -In order to create a Learner object one should use the @link python.learner.LearnerBuilder.LearnerBuilder LearnerBuilder @endlink. You can let the @link python.controller.TerminalController.TerminalController TerminalController @endlink to generate the code from the command line -arguments. - -Make sure the SG++ project is in your $PYTHONPATH and add it, if it is not -@code -> export PYTHONPATH=$SGPP_PATH:$PYTHONPATH -@endcode - -Let's suppose you learning setup was defined by the following command line -arguments -@code -> python $SGPP_PATH/misc/python/classifier.py -v --mode test --data \ -/path/to/dataset_train.arff.gz --test /path/to/dataset_test.arff.gz --border \ ---level 2 -r 0.0001 -C identity --adapt_points 400 --grid_limit 50000 \ ---regression --checkpoint /path/to/checkpoint_file.checkpoint.gz --stats \ -/path/to/stats_file.stats.gz --grid /path/to/grid_file.grid.gz --adapt_start 9 \ --L 0.0001 -@endcode - -With @link python.controller.TerminalController.TerminalController TerminalController @endlink class you now can automatically generate the code to -create the Learner object using LearnerBuilder. Just call the -%TerminalController.py with all the command line arguments as above and an -additional argument @c --generate - -@code -> python $SGPP_PATH/datadriven/python/controller/TerminalController.py --generate -v --mode \ -test --data /path/to/dataset_train.arff.gz --test /path/to/dataset_test.arff.gz \ ---border --level 2 -r 0.0001 -C identity --adapt_points 400 --grid_limit 50000 \ ---regression --checkpoint /path/to/checkpoint_file.checkpoint.gz --stats \ -/path/to/stats_file.stats.gz --grid /path/to/grid_file.grid.gz --adapt_start 9 \ --L 0.0001 -@endcode - -This will result in the following output: - -@code -builder = LearnerBuilder() -builder.buildRegressor() -builder.withTrainingDataFromARFFFile('/path/to/dataset_train.arff.gz') -builder.withTestingDataFromARFFFile('/path/to/dataset_test.arff.gz') -builder = builder.withGrid() -builder.fromFile('/path/to/grid_file.grid.gz') -builder.withStartingIterationNumber(9) -builder = builder.withSpecification() -builder.withAdaptPoints(400) -builder.withLambda(0.00010000000000000000) -builder.withIdentityOperator() -builder = builder.withStopPolicy() -builder.withGridSizeLimit(50000) -builder = builder.withCGSolver() -builder.withAccuracy(0.000100) -builder.withImax(500) -builder.withProgressPresenter(InfoToScreenRegressor()) -builder.withProgressPresenter(InfoToFile('/path/to/stats_file.stats.gz')) -checkpointController = CheckpointController('checkpoint_file.checkpoint.gz', -'/path/to') -builder.withCheckpointController(checkpointController) -@endcode - -You can then use this output to generate the Learner object. -@dontinclude grid_refinement.py -Firstly, import all classes used in the generated code segment -@until InfoToFile - -Secondly, past the code as a string into your script -@until Controller)""" - -Now you can execute the code and obtain the Learner object with -@until andGetResult() - - - -@section continued_learning_examples__learning Resuming the Learning without Recalculating the last Step - -Usually if you want to restart your classifier from the checkpoint and to -perform some more learning iterations, you had to repeat last iteration step -even so you already have the alpha vector. Depending on the problem size this -recomputation can be very expensive. This section shows how you can omit it. - -Once the Learner object is loaded, e.g., as showed above, update results -to recalculate errors per grid points and refine the grid - -@until .refineGrid() - -And continue the learning process - -@until .learnDataWithTest() - -The example script can be found in the file @c examples/grid_refinement.py. - -**/ diff --git a/base/doc/doxygen/code_examples_quick_start.doxy b/base/doc/doxygen/code_examples_quick_start.doxy deleted file mode 100644 index a75468e0b8..0000000000 --- a/base/doc/doxygen/code_examples_quick_start.doxy +++ /dev/null @@ -1,431 +0,0 @@ -/** -@page code_examples_quick_start Quick-Start: Short Code Examples - -To be able to quickly start with a toolkit, it is often advantageous -(not only for the impatient users), to look at some code examples -first. As SG++ can be used from within different programming -languages, we provide a short example for some of them. They show -nicely the differences between the different types of usage. Sooner or -later they will be extended to additional functionality and more -programming languages. - -To this end, we create a regular sparse grid with level three in two dimensions -using piecewise linear basis functions without gridpoints on the -boundary. We then interpolate the function -@f[ f(x_0,x_1) := 16 * (x_0-1)*x_0 * (x_1-1)*x_1 @f] -with -@f[ u(x_0,x_1) := \sum_{j=1}^N \alpha_j \varphi_j(x_0,x_1) @f] -by setting the coefficients @f$\alpha_j@f$ to the function values of -@f$f@f$ at the corresponding grid points. Then we hierarchize it, -transforming the function values at the grid points into hierarchical -coefficients. Finally, we evaluate the sparse grid function @f$u@f$ at -@f$(0.52,0.73)@f$. - - - -@section code_examples__overview Overview -- \ref code_examples__python - - \ref code_examples__python_linebyline -- \ref code_examples__cpp - - \ref code_examples__cpp_linebyline -- \ref code_examples__java - - \ref code_examples__java_linebyline -- \ref code_examples__matlab - - \ref code_examples__matlab_linebyline - - - -@section code_examples__python Python - -First, the whole code of file python_simple.py at once, as it can be -found in the directory @c base/examples/, which we then discuss line by line. - -@include python_simple.py -which can be executed by -@code -export LD_LIBRARY_PATH="/path/to/SGpp/trunk/lib/sgpp" -export PYTHONPATH="/path/to/SGpp/trunk/lib" -python python_simple.py -@endcode -in the directory @c base/examples/. -Keep in mind that you need to seed the @c LD_LIBRARY_PATH and @c PYTHONPATH -environment variables correctly, allowing Python to find pysgpp and SG++. - -This results in the output -@include all_simple.output.txt -It can be clearly seen that the surplusses decay with a factor of 1/4: -On the first level, we obtain 1, on the second 1/4, and on the third -1/16 as surplusses. - - - -@subsection code_examples__python_linebyline Explanations line by line - -@dontinclude python_simple.py -@until pysgpp -We import the pysgpp classes which we require afterwards, -with the most important being SGPP::base::DataVector and SGPP::base::Grid. - -@until dimensionality -creates a two-dimensional grid object with piecewise bilinear basis -functions with the help of the factory method -SGPP::base::Grid.createLinearGrid(). -Then we obtain a reference to the Grid's -GridStorage object which allows us, e.g., to access grid -points, to obtain the dimensionality (which we print) and the -number of grid points. - -@until number -Here, we use a SGPP::base::GridGenerator to -create a regular sparse grid of level 3. -Thus, @c gridStorage.size() returns 17, the number of grid points -of a two-dimensional regular sparse grid of level 3. - -@until length -Now we create an object of type SGPP::base::DataVector which has as many -entries as there are grid points. It serves as a coefficient vector for the -sparse grid interpolant we want to construct. As the entries of a -freshly created DataVector are not initialized, we set them to -0.0. (This is superfluous here as we initialize them in the -next few lines anyway.) - -@until alpha before hierarchization -Here, the function @f$f@f$, which we want to interpolate, is defined. -The @c for loop iterates over all grid points: For each grid -point @c gp, the corresponding coefficient @f$\alpha_j@f$ is set to the -function value at the grid point's coordinates which are obtained by -@c getCoord(dim). -The current coefficient vector is then printed. - -@until alpha after hierarchization -An object SGPP::base::OperationHierarchisation is created and used to -hierarchize the coefficient vector, which we print. - -@until u( -Finally, a second DataVector is created which is used as a point to -evaluate the sparse grid function. An object is obtained which -provides an evaluation operation, and the sparse grid interpolant is -evaluated close to (but not exactly at) a grid point. - - - -@section code_examples__cpp C++ - -Again, we first show the whole code of file c++_simple.cpp at once, -as it can be found in the directory @c base/examples/, which we then discuss -line by line. - -@include c++_simple.cpp - -The example can be compiled, linked, and executed by -@code -g++ -o c++_simple.o -c -std=c++11 -I../src c++_simple.cpp -g++ -o c++_simple -fopenmp c++_simple.o -L/path/to/SGpp/trunk/lib/sgpp -lsgppbase -export LD_LIBRARY_PATH="/path/to/SGpp/trunk/lib/sgpp" -./c++_simple -@endcode -running in the directory @c base/examples/. -Note that you have to set the @c LD_LIBRARY_PATH -environment variable to be able to use the shared library. - -This results in the same output as before: - -@include all_simple.output.txt - - - -@subsection code_examples__cpp_linebyline Explanations line by line - -@dontinclude c++_simple.cpp -@until SGPP::base; -Apart from iostream, we have to include the header files of all -classes we are using. Finally, we import the namespaces @c std and (to -simplify the example) SGPP::base. - -@until } -defines the function @f$f@f$ we want to interpolate. - -@until dimensionality -creates a two-dimensional grid object with piecewise bilinear basis -functions with the help of the factory method -SGPP::base::Grid.createLinearGrid(). -Then we obtain a reference to the Grid's -GridStorage object which allows us, e.g., to access grid -points, to obtain the dimensionality (which we print) and the -number of grid points. - -@until number -Here, we use a SGPP::base::GridGenerator to -create a regular sparse grid of level 3. -Thus, @c gridStorage.size() returns 17, the number of grid points -of a two-dimensional regular sparse grid of level 3. - -@until length -Now we create an object of type SGPP::base::DataVector which has as many -entries as there are grid points. It serves as a coefficient vector for the -sparse grid interpolant we want to construct. As the entries of a -freshly created DataVector are not initialized, we set them to -0.0. (This is superfluous here as we initialize them in the -next few lines anyway.) - -@until alpha before hierarchization -The @c for loop iterates over all grid points: For each grid -point @c gp, the corresponding coefficient @f$\alpha_j@f$ is set to the -function value at the grid point's coordinates which are obtained by -@c getCoord(dim). -The current coefficient vector is then printed. - -@until alpha after hierarchization -An object SGPP::base::OperationHierarchisation is created and used to -hierarchize the coefficient vector, which we print. - -@until u( -Finally, a second DataVector is created which is used as a point to -evaluate the sparse grid function. An object is obtained which -provides an evaluation operation, and the sparse grid interpolant is -evaluated close to (but not exactly at) a grid point. - - - -@section code_examples__java Java - -Again, we first show the whole code of file java_simple.java at once, as it -can be -found in the directory @c base/examples/, which we then discuss line by line. - -@include java_simple.java - -For the compilation and execution of the example, -we change to the directory @c base/examples/ and run -@code -javac -cp .:/path/to/SGpp/trunk/lib/jsgpp/jsgpp.jar java_simple.java -export LD_LIBRARY_PATH="/path/to/SGpp/trunk/lib/sgpp:/path/to/SGpp/trunk/lib/jsgpp" -java -cp .:/path/to/SGpp/trunk/lib/jsgpp/jsgpp.jar java_simple -@endcode -Note that you have to set the @c LD_LIBRARY_PATH -environment variable to be able to use the shared library. - -This results in (nearly) the same output as before: - -@include all_simple.output.txt - - - -@subsection code_examples__java_linebyline Explanations line by line - -@dontinclude java_simple.java -@until sgpp.OperationEval; -We can import the whole @c .jar file as in the second line or, better, -just import the class files we use. - -@until } -defines the function @f$f@f$ we want to interpolate. - -@until loadJSGPPLib -Two possibilities of loading the libjsgpp.so shared object library file, -which is needed to find the methods. - -@until dimensionality -creates a two-dimensional grid object with piecewise bi-linear basis -functions with the help of the factory method -SGPP::base::Grid.createLinearGrid(). -Then we obtain a reference to the Grid's -GridStorage object which allows us, e.g., to access grid -points, to obtain the dimensionality (which we print) and the -number of grid points. - -@until number -Here, we use a SGPP::base::GridGenerator to -create a regular sparse grid of level 3. -Thus, @c gridStorage.size() returns 17, the number of grid points -of a two-dimensional regular sparse grid of level 3. - -@until length -Now we create an object of type SGPP::base::DataVector which has as many -entries as there are grid points. It serves as a coefficient vector for the -sparse grid interpolant we want to construct. As the entries of a -freshly created DataVector are not initialized, we set them to -0.0. (This is superfluous here as we initialize them in the -next few lines anyway.) - -@until alpha before hierarchization -The @c for loop iterates over all grid points: For each grid -point @c gp, the corresponding coefficient @f$\alpha_j@f$ is set to the -function value at the grid point's coordinates which are obtained by -@c getCoord(dim). -The current coefficient vector is then printed. - -@until alpha after hierarchization -An object sgpp.jsgpp.OperationHierarchisation is created and used to -hierarchize the coefficient vector, which we print. - -@until u( -Finally, a second DataVector is created which is used as a point to -evaluate the sparse grid function. An object is obtained which -provides an evaluation operation, and the sparse grid interpolant is -evaluated close to (but not exactly at) a grid point. - - - -@section code_examples__matlab MATLAB - -As in the previous sections, we first show the whole code of file -matlab_simple.m at once, as it can be -found in the directory @c base/examples/, which we then discuss line by line. - -@include matlab_simple.m - -MATLAB can use SGpp via Java, i.e. we use the Java library of SGpp and import -it to MATLAB. -Before we can use these methods in MATLAB, we have to add the path to the -@c libjsgpp.so file to the librarypath.txt file of MATLAB. -(Hint: Typing @c matlabroot in MATLAB returns the path to your MATLAB -installation.) -Open the file @c /path/to/MATLAB/toolbox/local/librarypath.txt in a text editor -and add the line -@code -/path/to/SGpp/trunk/lib/jsgpp -@endcode -at the end of the file. -After adding this line, we can start MATLAB. -However, we have to set the environment variables @c LD_LIBRARY_PATH and -@c LD_PRELOAD: -@code -export LD_LIBRARY_PATH="/path/to/SGpp/trunk/lib/sgpp:/path/to/SGpp/trunk/lib/jsgpp" -export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libstdc++.so.6" -matlab -@endcode -The variable @c LD_LIBRARY_PATH has to be set to allow MATLAB to find -the shared libraries. -However, MATLAB ships its own version of @c libstdc++ -(usually in @c /path/to/MATLAB/sys/os/glnxa64) and adds its location -to MATLAB's internal @c LD_LIBRARY_PATH. -Since this version of @c libstdc++ is most likely incompatible with the -version used to compile SG++, you will get errors like this -when executing matlab_simple in MATLAB: -@code -Error using matlab_simple (line 5) -Java exception occurred: -java.lang.UnsatisfiedLinkError: /path/to/SGpp/trunk/lib/jsgpp/libjsgpp.so: -/path/to/MATLAB/bin/glnxa64/libstdc++.so.6: version -`GLIBCXX_3.4.20' not found (required by /path/to/SGpp/trunk/lib/jsgpp/libjsgpp.so) - at java.lang.ClassLoader$NativeLibrary.load(Native Method) - at java.lang.ClassLoader.loadLibrary1(Unknown Source) - at java.lang.ClassLoader.loadLibrary0(Unknown Source) - at java.lang.ClassLoader.loadLibrary(Unknown Source) - at java.lang.Runtime.loadLibrary0(Unknown Source) - at java.lang.System.loadLibrary(Unknown Source) - at sgpp.LoadJSGPPLib.loadJSGPPLib(LoadJSGPPLib.java:10) -@endcode -To work around this issue, set the @c LD_PRELOAD variable -to load the correct version @c libstdc++ before calling MATLAB. -You can find the correct version by examining the output of -@code -ldd /path/to/SGpp/trunk/lib/jsgpp/libjsgpp.so -@endcode -and searching for a line containing @c libstdc++. -On my Ubuntu system, it was located in -@c /usr/lib/x86_64-linux-gnu/libstdc++.so.6, -but it can differ on other systems. - -In MATLAB, we have to add the @c jsgpp.jar file, doing this with -the command -@code -javaaddpath('/path/to/SGpp/trunk/lib/jsgpp/jsgpp.jar') -@endcode -We can now change to the directory @c base/examples/ and run the matlab_simple -example with -@code -matlab_simple -@endcode - -This results in the same output as before: - -@include all_simple.output.txt - - - -@subsection code_examples__matlab_hints Hints -Use -@code -javaclasspath -@endcode -to see the loaded jar files (upper part static, lower -part dynamic; our jsgpp.jar should be in the latter part). -Write -@code -import sgpp.* -@endcode -in MATLAB to not have to write @c sgpp. in front of every method. -Call -@code -methods('sgpp.Classname') -@endcode -to see all methods of the class "Classname" (e.g. @c Grid). -The methods itself can now also be called like Java methods in the MATLAB -command window, e.g. -@code -dataVector = sgpp.DataVector(10) -dataVector.setAll(0) -dataVector -@endcode - - - -@subsection code_examples__matlab_linebyline Explanations line by line - -@dontinclude matlab_simple.m -@until loadJSGPPLib -Method to load the libjsgpp.so library. -As you can see, the methods are called in Java syntax. - -@until sgpp.OperationEval; -We can import the whole @c .jar file as in the second line or, better, -just import the class files we use. - -@until x1 -defines the function @f$f@f$ we want to interpolate. - -@until dimensionality -creates a two-dimensional grid object with piecewise bi-linear basis -functions with the help of the factory method -SGPP::base::Grid.createLinearGrid(). -Then we obtain a reference to the Grid's -GridStorage object which allows us, e.g., to access grid -points, to obtain the dimensionality (which we print) and the -number of grid points. - -@until number -Here, we use a sgpp.GridGenerator to -create a regular sparse grid of level 3. -Thus, @c gridStorage.size() returns 17, the number of grid points -of a two-dimensional regular sparse grid of level 3. - -@until length -Now we create an object of type SGPP::base::DataVector which has as many -entries as there are grid points. It serves as a coefficient vector for the -sparse grid interpolant we want to construct. As the entries of a -freshly created DataVector are not initialized, we set them to -0.0. (This is superfluous here as we initialize them in the -next few lines anyway.) - -@until alpha before hierarchization -The @c for loop iterates over all grid points: For each grid -point @c gp, the corresponding coefficient @f$\alpha_j@f$ is set to the -function value at the grid point's coordinates which are obtained by -@c getCoord(dim). -The current coefficient vector is then printed. -Attention has to be paid on the different syntax in indexing the array between -MATLAB and Java. -Java starts with 0, MATLAB with 1! - -@until alpha after hierarchization -An object sgpp.jsgpp.OperationHierarchisation is created and used to -hierarchize the coefficient vector, which we print. - -@until u( -Finally, a second DataVector is created which is used as a point to -evaluate the sparse grid function. An object is obtained which -provides an evaluation operation, and the sparse grid interpolant is -evaluated close to (but not exactly at) a grid point. -*/ diff --git a/base/doc/doxygen/styleguide.doxy b/base/doc/doxygen/styleguide.doxy deleted file mode 100644 index 8223abdd6b..0000000000 --- a/base/doc/doxygen/styleguide.doxy +++ /dev/null @@ -1,64 +0,0 @@ -/** -@page styleguide Styleguide for SG++ - -@section intro Introduction -Please read through this before starting to code! -(The styleguide has been partially adapted from [1]) - -@section comments Comments -The complete code has to be commented elaborately. The comments, -together with the identifiers, have to enable others to familiarize -with the code quickly. Header files have to be commented -completely. In source files it suffices to comment the codelines. The -comments have to be verbose enough so that one can understand what is -going on without reading the code! Please keep in mind using Doxygen compatible -comments for classes and methods. -@verbatim -// Thread .h - -/** - * Class description - */ -class Thread { -public : - /** - * Method description - */ - void wakeUp (); - - State state ; // Variable description -}; - - -// Thread .cc - -void Thread :: wakeUp () -{ - // Description of implementation details - if ( ... ) { - ... - } -} -@endverbatim - -@section naming Naming - -Naming: -- directories: all lowercase -- classes: starting uppercase, camel case (upper camel case) -- functions, variables: starting lowercase, camel case (lower camel case) -- constants, defines: all uppercase, _ separated -- nothing starts with underscores (only system/builtin/compiler) - - -Don't -- include sgpp.hpp - only include the header files you require. Reason: faster compilation times -- use "using namespace"s -- use tabs, use four (4) space instead! Please configure your editor in order to do so! - - -@section refs References -[1] http://www-bs.informatik.tu-cottbus.de/fileadmin/user_upload/lehre/bs1/styleguide.pdf - -[2] http://bel.gsi.de/mk/sty/cstyle.html#tth_sEc2 -*/ diff --git a/base/doc/doxygen/windows.doxy b/base/doc/doxygen/windows.doxy deleted file mode 100644 index 81b0fa528b..0000000000 --- a/base/doc/doxygen/windows.doxy +++ /dev/null @@ -1,280 +0,0 @@ -/** -@page installationWindows Installation and Compilation on Windows - -We do not officially support the Windows platform. We do not guarantee -that all the features provided on a Unix platform are available on -Windows platforms, but most of them will. Nevertheless, by following -the instructions below you will be able to build SG++ also on Windows -and use the Python and Java/Matlab interface. - -@section installationWindowsOverview Overview -- \ref installationWindowsRequirements -- \ref howtoinstallonwindows -- \ref installationWindowsCompilation_scons -- \ref installationWindowsTroubleshooting - - -@section installationWindowsRequirements Requirements and Recommendations -@subsection installationWindowsRequirements_necessary Required - -- Visual Studio (>= 14), https://www.visualstudio.com/, is -recommended -- SCons (>= 2.4.0), http://www.scons.org/, is required for -compilation. SCons is a Makefile replacement that facilitates quite -a few things. If you want to enable parallel builds you need -to install the pywin32 package. -- swig (>= 3.0.7), http://www.swig.org/, if you want to use SGpp within python -or java, this program creates bindings from C/C++ functions in order to make -them available as a python module or prepare them to be called from -java code. -- python 2.7 (32 Bit version), this is a current (2015) restriction -of SCons on Windows; additionally install numpy to enable the python -interface -- doxygen, http://www.doxygen.nl/index.html, is required to create and compile -the documentation. Essentially, what can be found at -http://sgpp.sparsegrids.org -@subsection installationWindowsRequirements_optional Optional packages -- swig, for generating the interfaces to python and java/Matlab, -http://www.swig.org/download.html -- numpy, for python support, http://sourceforge.net/projects/numpy/files/NumPy/1.10.1/ -- dot, in the Graphviz package, http://www.graphviz.org/, is optional -for inheritance diagrams in the documentation generated by doxygen. -- matplotlib, http://matplotlib.sourceforge.net/, is optional snd enables SGpp to -generate progress information graphs. -- boost (unit test framework) for unit tests - -@section howtoinstallonwindows How to install all the packages you need to compile SG++ - -@subsection Required - -- install Visual Studio (11GB): make sure that Visual C++ and the - python tools are installed -- install Python2.7 (32 Bit) to a folder to which - you have full access (C:\\local for example). Add python.exe to the - system path variable (=PATH) -- the next step consists in installing SCons. Note that with the - current version of SCons (2.4.0) a 32 Bit installation of is - required. - -@subsection Optional -- install the boost library to run the boost unit tests. The unit test -framework needs to be available, the path to the libs needs to be -added to PATH. -- interfaces to python and java - - install swig and add it to PATH - - python - - you need to install numpy - - java - - install jdk and jre for java support. Please check the platform - (x86 or amd64). Add javac.exe (you find it in the installation - of the jdk) to PATH. -- documentation: - - install doxygen to create the documentation of SG++ - - install graphviz for beautiful images in the documentation ;) - - Make sure that both paths to the executables of doxygen and graphviz - are available in the system path variable (PATH) - -@section installationWindowsCompilation_scons Compilation with SCons - -Compilation of the C++ libraries is done with SCons. Execute -@verbatim - scons -j -@endverbatim -in the main folder. For configuration and optimization, see below. - -To obtain help on parameters for compilation, type -@verbatim - scons --help -@endverbatim - -After compilation just the unit-tests (located in the -tests-folder of each module) are executed. - -@subsection installationWindowsSconsConfiguration Configuration for compilation - -SCons uses the file SConstruct. This file contains all -information for compiling SGpp. To build SG++ under Windows you need -to specify the Visual Studio compiler. However, Visual Studio provides -a variety of different compilers depending on the architecture you are -working on. To prepare the environment (path variables, etc.) you need -to specify the correct script, which is also provided by Visual -Studio. On a standard Windows 7 installation this is usually - -"C:\path\to\Visual Studio\VC\bin\vcvars32.bat" - -for building x86 code on a amd64 machine. Moreover, to tell scons that -you want to use the Visual Studio compiler set - -TARGETCPU=VCC - -If you want to build a static library you can now proceed by executing -@code{bash} - scons SG_PARALLEL=0 SG_COMBIGRID=0 USE_STATIC=1 TARGETCPU=VCC MSVC_USE_SCRIPT="C:\path\to\Visual Studio\VC\bin\vcvars32.bat" -@endcode - -The library is installed to - -lib/sgpp/sgppstatic.lib - -@subsection installationWindowsBuilding Building dlls and bindexplib - -However, if you want to build a dynamic library just 32 Bit is -supported. The issue here is that the default behavior of a dll is to -export no symbols at all. The default behavior of a SG++ library, -however, is the opposite, export all the available symbols. To do that -we need an external application called bindexplib, which -generates a module definition file that contains all the available -symbols in the source files. This so called def-file can be forwarded -to the dll linker, which now exports all the symbols defined in the -def-file. The source code for bindexplib is available in -tools/bindexplib and needs to be compiled on your Windows -machine and the path of the exe added to the path variable. The -bindexplib application just supports 32 Bit compiled object files. - -Generate another Visual Studio project to compile the -bindexplib as follow -Create a new project by - - File -> New -> Project from existing code; select Visual C++ as - project type (-> Next) specify the path to bindexplib - (/path/to/SG++/tools/bindexplib), give some unique name to the - project (-> Next) Check "Use Visual Studio" and select "Console - application project" as project type. - - Click Next -> Finish -Build the project and add /path/to/SG++/tools/bindexplib to -PATH - -Please execute -@code{bash} - scons SG_PARALLEL=0 SG_COMBIGRID=0 USE_STATICLIB=0 TARGETCPU=VCC MSVC_USE_SCRIPT="C:\path\to\Visual Studio\VC\bin\vcvars32.bat" -@endcode -to obtain the dynamic library. The library is installed to - -lib/sgpp/sgpp.{lib|dll} - -@subsection installationWindowsCleaning Cleaning the project - -Please execute -@code{bash} - scons SG_PARALLEL=0 SG_COMBIGRID=0 MSVC_USE_SCRIPT="C:\path\to\Visual Studio\VC\bin\vcvars32.bat" -c -@endcode - -@subsection installationWindowsAvailable Available modules - -You are able to compile different SG++ modules independently. However, you should take into account the dependencies between the modules to -avoid "undefined symbol" errors: When using them, depending on the dependencies, other modules might have to be included, too. The currently available modules are (see the @ref modules page): -- SG_BASE basic functionality -- SG_DATADRIVEN operations on data -- SG_SOLVER classes for solving the systems of equations -- SG_PDE partial differential equations -- SG_FINANCE financial module -- SG_OPTIMIZATION optimization of objective functions -- SG_QUADRATURE Monte Carlo sampler for higher-dimensional integrals -- SG_MISC miscellaneous functionality - -Note that you need to disable the following two packages on Windows -due to major compatibility issues in the C++ source code -- SG_PARALLEL classes for parallel computing -- SG_COMBIGRID combigrid classes - -Then there are two switches for supported high-level back-ends: -- SG_PYTHON integration of SG++ in Python -- SG_JAVA corresponding JAVA bindings - -For example, the command -@code{bash} - scons SG_MISC=0 SG_QUADRATURE=0 SG_DATADRIVEN=0 SG_SOLVER=0 SG_FINANCE=0 SG_PDE=0 SG_OPTIMIZATION=0 SG_PARALLEL=0 SG_COMBIGRID=0 TARGETCPU=VCC MSVC_USE_SCRIPT="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat" -@endcode -will create the shared library sgppbase.dll and the corresponding -import library sgppbase.lib. - -@subsection installationWindowsPysgpp Building the python bindings - -The pything bindings are built if the SG_PYTHON=1 flag is -set. After compilation, two files, pysgpp.py and _pysgpp_swig.dll are -copied to the lib/pysgpp folder, which define the python -interface. If you want to use them, you need to install the package to -your either a local or a system wide site-package location. To use -your local folder execute - -@code{bash} -python setup.py install --user -@endcode -from the root directory of SG++. - -Note, that in Unix the lib directory has implicitly the -structure of a valid python package and contains the full capabilities -of SG++. This is not the case for Windows since the -extensions are missing due to missing rights to create -symlinks to the corresponding subfolders of the SG++ packages, for -example base/python. - -However, you can import and print contents via -@code{.py} - import pysgpp - dir(pysgpp) -@endcode - -Note, that package specific functionality is available as an extension -to the C++ code, for example write -@code{.py} - from pysgpp.extensions.datadriven import uq -@endcode -to use the uncertainty quantification python package. - -@subsection installationWindowsJsgpp Building the jsgpp library for use with Java - -For the use of SGpp with Java, you have to generate the jsgpp. It can be generated with -@code{bash} - scons SG_JAVA=1 SG_PYTHON=1 SG_PARALLEL=0 SG_COMBIGRID=0 TARGETCPU=VCC MSVC_USE_SCRIPT="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat" -@endcode - -@subsection installationWindowsSconsVisualStudio Configuration for use of Scons within Visual Studio - -Create a new project by - - File -> New -> Project from existing code; select Visual C++ as - project type (-> Next) specify the path to SG++, give some unique name to the - project (-> Next) Check "use external build system" and add the - scons build command line above in the field "Build command line" (-> - Finish) - - To make the symbols visible to the indexer add the include paths - of every SG++ package you want to use to the VC++ directories - available in the properties of the project -> VC++ Directories -> - Include Directories. - - If you want to adjust the build command, go to the properties of - the project -> NMake -> Build Command Line. - -@section installationWindowsTroubleshooting Troubleshooting -A few helpful hints for what has caused trouble before -(or might cause trouble in the future...) - -- Building shared libraries for amd64 is not supported due to missing - functionality of the bindexplib application. -- In general, amd64 architecture is causing trouble with the java and - the python interface due to non consistent handling of the size_t - type in swig. It does not work out of the box and no automatic - solution is available at the moment. -- Make the variable JAVA_HOME available globally so that SCons finds the - headers for the Java interface. -- Make sure that Python 2.7 is installed in a folder with full access (do - not use "Program Data" or comparable system folders), otherwise - SCons won't install. -- The Python interface on Windows does not provide enum types from - C++. This does restrict its usability significantly but currently - there is no solution to that issue available. -- Running boost tests automatically does not work. You can compile - them by specifying COMPILE_BOOST_TESTS=1 but you need to set - RUN_BOOST_TESTS=0 otherwise the build will fail. -- To run the Python unit tests one needs to make the full Python - package available. This can be done in Unix either by installation - of the package via the setup.py script or via setting - the python path to lib. However, in Windows, just the first - approach is available currently. To make sure that pysgpp - is available in the PYTHONPATH, one needs to install it - somewhere. Currently, SCons installs it to some temporary folder and - adds this very folder to the Python path. To avoid conflicts with - other installed versions of pysgpp, the temporary folder is - added as first element to the PYTHONPATH. This is a bit - hacky but works with current Python releases. To make the user aware - of this problem a warning is shown if more than one pysgpp - installations are detected. -*/ diff --git a/base/examples/all_simple.output.txt b/base/examples/all_simple.output.txt deleted file mode 100644 index 6993e68743..0000000000 --- a/base/examples/all_simple.output.txt +++ /dev/null @@ -1,6 +0,0 @@ -dimensionality: 2 -number of grid points: 17 -length of alpha vector: 17 -alpha before hierarchization: [1, 0.75, 0.75, 0.4375, 0.9375, 0.9375, 0.4375, 0.75, 0.75, 0.4375, 0.9375, 0.9375, 0.4375, 0.5625, 0.5625, 0.5625, 0.5625] -alpha after hierarchization: [1, 0.25, 0.25, 0.0625, 0.0625, 0.0625, 0.0625, 0.25, 0.25, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625, 0.0625] -u(0.52, 0.73) = 0.7696 diff --git a/base/examples/all_simple_quadrature.output.txt b/base/examples/all_simple_quadrature.output.txt deleted file mode 100644 index c56ef0c4b7..0000000000 --- a/base/examples/all_simple_quadrature.output.txt +++ /dev/null @@ -1,7 +0,0 @@ -dimensionality: 2 -number of grid points: 17 -exact integral value: 0.421875 -Monte Carlo value: 0.421298 -Monte Carlo value: 0.421971 -MC value: 0.444917 -MC L2-error: 0.0242639 diff --git a/base/examples/c++_simple.cpp b/base/examples/c++_simple.cpp deleted file mode 100644 index 45dbccf82d..0000000000 --- a/base/examples/c++_simple.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2008-today The SG++ project -// This file is part of the SG++ project. For conditions of distribution and -// use, please see the copyright notice provided with SG++ or at -// sgpp.sparsegrids.org - -#include -// All SG++ headers -// #include getStorage(); - cout << "dimensionality: " << gridStorage->dim() << endl; - - // create regular grid, level 3 - size_t level = 3; - GridGenerator* gridGen = grid->createGridGenerator(); - gridGen->regular(level); - cout << "number of grid points: " << gridStorage->size() << endl; - - // create coefficient vector - DataVector alpha(gridStorage->size()); - alpha.setAll(0.0); - cout << "length of alpha vector: " << alpha.getSize() << endl; - - // set function values in alpha - SGPP::base::GridIndex* gp; - - for (size_t i = 0; i < gridStorage->size(); i++) { - gp = gridStorage->get(i); - alpha[i] = f(gp->getCoord(0), gp->getCoord(1)); - } - - cout << "alpha before hierarchization: " << alpha.toString() << endl; - - // hierarchize - SGPP::op_factory::createOperationHierarchisation(*grid) - ->doHierarchisation(alpha); - cout << "alpha after hierarchization: " << alpha.toString() << endl; - - // evaluate - DataVector p(dim); - p[0] = 0.52; - p[1] = 0.73; - SGPP::base::OperationEval* opEval = - SGPP::op_factory::createOperationEval(*grid); - cout << "u(0.52, 0.73) = " << opEval->eval(alpha, p) << endl; - - delete grid; -} diff --git a/base/examples/c++_simple_predictive_refinement.cpp b/base/examples/c++_simple_predictive_refinement.cpp deleted file mode 100644 index 2be412f144..0000000000 --- a/base/examples/c++_simple_predictive_refinement.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2008-today The SG++ project -// This file is part of the SG++ project. For conditions of distribution and -// use, please see the copyright notice provided with SG++ or at -// sgpp.sparsegrids.org - -#include -#include - -// All SG++ headers -// #include eval(alpha, vec), 2); - } - - return error; -} - -int main() { - // create a two-dimensional piecewise bilinear grid - size_t dim = 2; - Grid* grid = Grid::createModLinearGrid(dim); - GridStorage* hashGridStorage = grid->getStorage(); - cout << "dimensionality: " << hashGridStorage->dim() - << endl; - - // create regular grid, level 3 - size_t level = 1; - GridGenerator* gridGen = grid->createGridGenerator(); - gridGen->regular(level); - cout << "number of initial grid points: " << hashGridStorage->size() - << endl; - - // create coefficient vector - DataVector alpha(hashGridStorage->size()); - alpha.setAll(0.0); - cout << "length of alpha vector: " << alpha.getSize() << endl; - - int rows = 100; - int cols = 100; - - DataMatrix dataSet(rows * cols, dim); - DataVector vals(rows * cols); - - // Create a "List" of points where the error should be calculated. - // This represents a regular 2d grid with a step size of 1 / rows and 1 / - // cols. - for (int i = 0; i < rows; i++) { - for (int j = 0; j < cols; j++) { - // xcoord - dataSet.set(i * cols + j, 0, i * 1.0 / rows); - // ycoord - dataSet.set(i * cols + j, 1, j * 1.0 / cols); - vals[i * cols + j] = f(i * 1.0 / rows, j * 1.0 / cols); - } - } - - // refine adaptively 20 times - for (int step = 0; step < 20; step++) { - // set function values in alpha - DataVector gridPointCoordinates(dim); - - for (size_t i = 0; i < hashGridStorage->size(); i++) { - hashGridStorage->get(i)->getCoords(gridPointCoordinates); - alpha[i] = f(gridPointCoordinates[0], gridPointCoordinates[1]); - } - - // hierarchize - SGPP::op_factory::createOperationHierarchisation(*grid) - ->doHierarchisation(alpha); - - // calculate squared offset - DataVector errorVector(dataSet.getNrows()); - calculateError(dataSet, *grid, alpha, errorVector); - - // refinement stuff - SGPP::base::HashRefinement refinement; - SGPP::base::PredictiveRefinement decorator(&refinement); - - // refine a single grid point each time - cout << "Error over all = " << errorVector.sum() << endl; - SGPP::base::PredictiveRefinementIndicator indicator(grid, &dataSet, - &errorVector, 1); - decorator.free_refine(hashGridStorage, &indicator); - - cout << "Refinement step " << step + 1 - << ", new grid size: " << hashGridStorage->size() << endl; - - // plot grid - - // extend alpha vector (new entries uninitialized) - alpha.resize(hashGridStorage->size()); - } - - delete grid; -} diff --git a/base/examples/c++_simple_quadrature.cpp b/base/examples/c++_simple_quadrature.cpp deleted file mode 100644 index 85097bb073..0000000000 --- a/base/examples/c++_simple_quadrature.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2008-today The SG++ project -// This file is part of the SG++ project. For conditions of distribution and -// use, please see the copyright notice provided with SG++ or at -// sgpp.sparsegrids.org - -#include -// All SG++ base headers -#include "sgpp_base.hpp" - -using std::cout; -using std::endl; -using SGPP::base::Grid; -using SGPP::base::GridStorage; -using SGPP::base::GridGenerator; -using SGPP::base::DataVector; -using SGPP::base::DataMatrix; - -// function to interpolate -SGPP::float_t f(int dim, SGPP::float_t* x, void* clientdata) { - SGPP::float_t res = 1.0; - - for (int i = 0; i < dim; i++) { - res *= 4.0 * x[i] * (1.0 - x[i]); - } - - return res; -} - -int main() { - // create a two-dimensional piecewise bi-linear grid - int dim = 2; - Grid* grid = Grid::createLinearGrid(dim); - GridStorage* gridStorage = grid->getStorage(); - cout << "dimensionality: " << gridStorage->dim() << endl; - - // create regular grid, level 3 - int level = 3; - GridGenerator* gridGen = grid->createGridGenerator(); - gridGen->regular(level); - cout << "number of grid points: " << gridStorage->size() << endl; - - // create coefficient vector - DataVector alpha(gridStorage->size()); - SGPP::base::GridIndex* gp; - SGPP::float_t p[2]; - - for (size_t i = 0; i < gridStorage->size(); i++) { - gp = gridStorage->get(i); - p[0] = gp->getCoord(0); - p[1] = gp->getCoord(1); - alpha[i] = f(2, p, NULL); - } - - SGPP::op_factory::createOperationHierarchisation(*grid) - ->doHierarchisation(alpha); - - // direct quadrature - SGPP::base::OperationQuadrature* opQ = - SGPP::op_factory::createOperationQuadrature(*grid); - SGPP::float_t res = opQ->doQuadrature(alpha); - cout << "exact integral value: " << res << endl; - delete opQ; - - // Monte Carlo quadrature using 100000 paths - SGPP::base::OperationQuadratureMC opMC(*grid, 100000); - res = opMC.doQuadrature(alpha); - cout << "Monte Carlo value: " << res << endl; - res = opMC.doQuadrature(alpha); - cout << "Monte Carlo value: " << res << endl; - - // Monte Carlo quadrature of a function - res = opMC.doQuadratureFunc(f, NULL); - cout << "MC value: " << res << endl; - - // Monte Carlo quadrature of error - res = opMC.doQuadratureL2Error(f, NULL, alpha); - cout << "MC L2-error: " << res << endl; - - delete grid; -} diff --git a/base/examples/c++_simple_refinement.cpp b/base/examples/c++_simple_refinement.cpp deleted file mode 100644 index 6ba6f4715e..0000000000 --- a/base/examples/c++_simple_refinement.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2008-today The SG++ project -// This file is part of the SG++ project. For conditions of distribution and -// use, please see the copyright notice provided with SG++ or at -// sgpp.sparsegrids.org - -#include -// All SG++ headers -// #include getStorage(); - cout << "dimensionality: " << gridStorage->dim() << endl; - - // create regular grid, level 3 - size_t level = 3; - GridGenerator* gridGen = grid->createGridGenerator(); - gridGen->regular(level); - cout << "number of initial grid points: " << gridStorage->size() << endl; - - // create coefficient vector - DataVector alpha(gridStorage->size()); - alpha.setAll(0.0); - cout << "length of alpha vector: " << alpha.getSize() << endl; - - SGPP::base::GridIndex* gp; - - // refine adaptively 5 times - for (int step = 0; step < 5; step++) { - // set function values in alpha - for (size_t i = 0; i < gridStorage->size(); i++) { - gp = gridStorage->get(i); - alpha[i] = f(gp->getCoord(0), gp->getCoord(1)); - } - - // hierarchize - SGPP::op_factory::createOperationHierarchisation(*grid) - ->doHierarchisation(alpha); - - // refine a single grid point each time - gridGen->refine(new SGPP::base::SurplusRefinementFunctor(&alpha, 1)); - cout << "refinement step " << step + 1 - << ", new grid size: " << alpha.getSize() << endl; - - // extend alpha vector (new entries uninitialized) - alpha.resize(gridStorage->size()); - } - - delete grid; -} diff --git a/base/examples/matlab_simple.m b/base/examples/matlab_simple.m deleted file mode 100644 index 2629312ee3..0000000000 --- a/base/examples/matlab_simple.m +++ /dev/null @@ -1,58 +0,0 @@ -% Copyright (C) 2008-today The SG++ project -% This file is part of the SG++ project. For conditions of distribution and -% use, please see the copyright notice provided with SG++ or at -% sgpp.sparsegrids.org -sgpp.LoadJSGPPLib.loadJSGPPLib(); - -% import all packages -%import sgpp.*; - -% or, better, include only the ones needed -import sgpp.DataVector; -import sgpp.GridGenerator; -import sgpp.GridStorage; -import sgpp.Grid; -import sgpp.GridIndex; -import sgpp.jsgpp; -import sgpp.OperationEval; - -% define the function f -f = @(x0,x1) (16.0*(x0-1.0)*x0 * (x1-1.0)*x1); - -% create a two-dimensional piecewise bilinear grid -dim = 2; -fprintf('dimensionality: %u\n', dim); -grid = Grid.createLinearGrid(dim); -gridStorage = grid.getStorage(); - -% create regular grid, level 3 -level = 3; -gridGen = grid.createGridGenerator(); -gridGen.regular(level); -fprintf('number of grid points: %u\n', gridStorage.size()); - -% create coefficient vector -alpha = DataVector(gridStorage.size()); -alpha.setAll(0); -fprintf('length of alpha vector: %u\n', alpha.getSize()); - -% set function values in alpha -for i = 0:gridStorage.size()-1 - gp = gridStorage.get(i); - alpha.set(i,f(gp.getCoord(0), gp.getCoord(1))); -end - -fprintf('alpha before hierarchization: %s\n', char(alpha.toString())); - -% hierarchize -operationHierarchisation = jsgpp.createOperationHierarchisation(grid); -operationHierarchisation.doHierarchisation(alpha); -fprintf('alpha after hierarchization: %s\n', char(alpha.toString())); - -% evaluate -p = DataVector(dim); -p.set(0, 0.52); -p.set(1, 0.73); -opEval = jsgpp.createOperationEval(grid); - -fprintf('u(0.52, 0.73) = %.4f\n', opEval.eval(alpha,p)); diff --git a/base/examples/python_simple.py b/base/examples/python_simple.py deleted file mode 100644 index 02b8b9a7c2..0000000000 --- a/base/examples/python_simple.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2008-today The SG++ project -# This file is part of the SG++ project. For conditions of distribution and -# use, please see the copyright notice provided with SG++ or at -# sgpp.sparsegrids.org - -# import modules -from pysgpp import DataVector, Grid, createOperationHierarchisation, createOperationEval - -# create a two-dimensional piecewise bilinear grid -dim = 2 -grid = Grid.createLinearGrid(dim) -gridStorage = grid.getStorage() -print "dimensionality: {}".format(gridStorage.dim()) - -# create regular grid, level 3 -level = 3 -gridGen = grid.createGridGenerator() -gridGen.regular(level) -print "number of grid points: {}".format(gridStorage.size()) - -# create coefficient vector -alpha = DataVector(gridStorage.size()) -alpha.setAll(0.0) -print "length of alpha vector: {}".format(len(alpha)) - -# set function values in alpha -f = lambda x0, x1: 16.0 * (x0-1.0)*x0 * (x1-1.0)*x1 -for i in xrange(gridStorage.size()): - gp = gridStorage.get(i) - alpha[i] = f(gp.getCoord(0), gp.getCoord(1)) -print "alpha before hierarchization: {}".format(alpha) - -# hierarchize -createOperationHierarchisation(grid).doHierarchisation(alpha) -print "alpha after hierarchization: {}".format(alpha) - -# evaluate -p = DataVector(dim) -p[0] = 0.52 -p[1] = 0.73 -opEval = createOperationEval(grid) -print "u(0.52, 0.73) = {}".format(opEval.eval(alpha, p)) diff --git a/base/examples/python_simple_predictive_ANOVArefinement.py b/base/examples/python_simple_predictive_ANOVArefinement.py deleted file mode 100644 index dced256a47..0000000000 --- a/base/examples/python_simple_predictive_ANOVArefinement.py +++ /dev/null @@ -1,134 +0,0 @@ -# Copyright (C) 2008-today The SG++ project -# This file is part of the SG++ project. For conditions of distribution and -# use, please see the copyright notice provided with SG++ or at -# sgpp.sparsegrids.org - -#!/usr/bin/python - -# import modules -import sys -import math - -from pysgpp import * -import matplotlib.pyplot as plotter -from mpl_toolkits.mplot3d import Axes3D - -# create a two-dimensional piecewise bi-linear grid -dim = 2 -grid = Grid.createLinearGrid(dim) -HashGridStorage = grid.getStorage() -print "dimensionality: {}".format(dim) - -# create regular grid, level 3 -level = 3 -gridGen = grid.createGridGenerator() -gridGen.regular(level) -print "number of initial grid points: {}".format(HashGridStorage.size()) - -# definition of function to interpolate - nonsymmetric(!) -#f = lambda x0, x1: 16.0 * (x0-1)*x0 * (x1-1)*x1-x1 -f = lambda x0, x1: math.sin(x0*10)+x1 - -# create coefficient vectors -alpha = DataVector(HashGridStorage.size()) -print "length of alpha vector: {}".format(alpha.getSize()) - - -#dataPoints - -rows = 100 -cols = 100 - -dataSet = DataMatrix(rows*cols,dim) -vals = DataVector(rows*cols) - -# Create a "List" of points where the error should be calculated. -# This represents a regular 2d grid with a step size of 1 / rows and 1 / cols. -for i in xrange(rows): - for j in xrange(cols): - #xcoord - dataSet.set(i*cols+j,0,i*1.0/rows) - #ycoord - dataSet.set(i*cols+j,1,j*1.0/cols) - vals[i*cols+j] = f(i*1.0/rows,j*1.0/cols) - -def calculateError(dataSet,f,grid,alpha,error): - print "calculating error" - #traverse dataSet - vec = DataVector(2) - opEval = createOperationEval(grid) - for i in xrange(dataSet.getNrows()): - dataSet.getRow(i,vec) - error[i] = pow(f(dataSet.get(i,0),dataSet.get(i,1))-opEval.eval(alpha,vec),2) - return error - -#store old files -xCoordsOld = [] -yCoordsOld = [] - -opEval = createOperationEval(grid) -for i in xrange(HashGridStorage.size()): - gridPointCoordinates = DataVector(dim) - HashGridStorage.get(i).getCoords(gridPointCoordinates) - xCoordsOld.append(gridPointCoordinates[0]) - yCoordsOld.append(gridPointCoordinates[1]) - -# now refine adaptively 20 times -for refnum in range(20): - # set function values in alpha - for i in xrange(HashGridStorage.size()): - gp = HashGridStorage.get(i) - alpha[i] = f(gp.getCoord(0), gp.getCoord(1)) - - # hierarchize - createOperationHierarchisation(grid).doHierarchisation(alpha) - - #initialize plotter - plotter.hold(True) - - - xCoordinates = [] - yCoordinates = [] - - #print all points - - opEval = createOperationEval(grid) - - for i in xrange(HashGridStorage.size()): - gridPointCoordinates = DataVector(dim) - HashGridStorage.get(i).getCoords(gridPointCoordinates) - xCoordinates.append(gridPointCoordinates[0]) - yCoordinates.append(gridPointCoordinates[1]) - bla = opEval.eval(alpha,gridPointCoordinates) - - plotter.scatter(xCoordinates, yCoordinates, c='b') - plotter.scatter(xCoordsOld, yCoordsOld, c='r') - xCoordsOld = xCoordinates - yCoordsOld = yCoordinates - - #show plot - - plotter.hold(False) - plotter.show() - - #calculate squared offset - errorVector = DataVector(dataSet.getNrows()) - calculateError(dataSet, f, grid, alpha, errorVector) - - #refinement stuff - refinement = HashRefinement() - decorator = PredictiveANOVARefinement(refinement) - # refine a single grid point each time - print "Error over all = %s" % errorVector.sum() - indicator = PredictiveRefinementIndicator(grid,dataSet,errorVector,1) - decorator.free_refine(HashGridStorage,indicator) - - print "Refinement step %d, new grid size: %d" % (refnum+1, HashGridStorage.size()) - - # - #plot grid - # - - - # extend alpha vector (new entries uninitialized) - alpha.resize(HashGridStorage.size()) \ No newline at end of file diff --git a/base/examples/python_simple_predictive_refinement.py b/base/examples/python_simple_predictive_refinement.py deleted file mode 100644 index 20a4bf578a..0000000000 --- a/base/examples/python_simple_predictive_refinement.py +++ /dev/null @@ -1,133 +0,0 @@ -# Copyright (C) 2008-today The SG++ project -# This file is part of the SG++ project. For conditions of distribution and -# use, please see the copyright notice provided with SG++ or at -# sgpp.sparsegrids.org - -#!/usr/bin/python - -# import modules -import sys -import math - -from pysgpp import * -import matplotlib.pyplot as plotter -from mpl_toolkits.mplot3d import Axes3D - -# create a two-dimensional piecewise bi-linear grid -dim = 2 -grid = Grid.createModLinearGrid(dim) -HashGridStorage = grid.getStorage() -print "dimensionality: {}".format(dim) - -# create regular grid, level 3 -level = 1 -gridGen = grid.createGridGenerator() -gridGen.regular(level) -print "number of initial grid points: {}".format(HashGridStorage.size()) - -# definition of function to interpolate - nonsymmetric(!) -#f = lambda x0, x1: 16.0 * (x0-1)*x0 * (x1-1)*x1-x1 -f = lambda x0, x1: math.sin(x0*math.pi) - -# create coefficient vectors -alpha = DataVector(HashGridStorage.size()) -print "length of alpha vector: {}".format(alpha.getSize()) - -#dataPoints - -rows = 100 -cols = 100 - -dataSet = DataMatrix(rows*cols,dim) -vals = DataVector(rows*cols) - -# Create a "List" of points where the error should be calculated. -# This represents a regular 2d grid with a step size of 1 / rows and 1 / cols. -for i in xrange(rows): - for j in xrange(cols): - #xcoord - dataSet.set(i*cols+j,0,i*1.0/rows) - #ycoord - dataSet.set(i*cols+j,1,j*1.0/cols) - vals[i*cols+j] = f(i*1.0/rows,j*1.0/cols) - -def calculateError(dataSet,f,grid,alpha,error): - print "calculating error" - #traverse dataSet - vec = DataVector(2) - opEval = createOperationEval(grid) - for i in xrange(dataSet.getNrows()): - dataSet.getRow(i,vec) - error[i] = pow(f(dataSet.get(i,0),dataSet.get(i,1))-opEval.eval(alpha,vec),2) - return error - -#store old files -xCoordsOld = [] -yCoordsOld = [] - -opEval = createOperationEval(grid) -for i in xrange(HashGridStorage.size()): - gridPointCoordinates = DataVector(dim) - HashGridStorage.get(i).getCoords(gridPointCoordinates) - xCoordsOld.append(gridPointCoordinates[0]) - yCoordsOld.append(gridPointCoordinates[1]) - -# now refine adaptively 20 times -for refnum in range(20): - # set function values in alpha - for i in xrange(HashGridStorage.size()): - gp = HashGridStorage.get(i) - alpha[i] = f(gp.getCoord(0), gp.getCoord(1)) - - # hierarchize - createOperationHierarchisation(grid).doHierarchisation(alpha) - - #initialize plotter - plotter.hold(True) - - - xCoordinates = [] - yCoordinates = [] - - #print all points - - opEval = createOperationEval(grid) - - for i in xrange(HashGridStorage.size()): - gridPointCoordinates = DataVector(dim) - HashGridStorage.get(i).getCoords(gridPointCoordinates) - xCoordinates.append(gridPointCoordinates[0]) - yCoordinates.append(gridPointCoordinates[1]) - bla = opEval.eval(alpha,gridPointCoordinates) - - plotter.scatter(xCoordinates, yCoordinates, c='b') - plotter.scatter(xCoordsOld, yCoordsOld, c='r') - xCoordsOld = xCoordinates - yCoordsOld = yCoordinates - - #show plot - - plotter.hold(False) - plotter.show() - - #calculate squared offset - errorVector = DataVector(dataSet.getNrows()) - calculateError(dataSet, f, grid, alpha, errorVector) - - #refinement stuff - refinement = HashRefinement() - decorator = PredictiveRefinement(refinement) - # refine a single grid point each time - print "Error over all = %s" % errorVector.sum() - indicator = PredictiveRefinementIndicator(grid,dataSet,errorVector,1) - decorator.free_refine(HashGridStorage,indicator) - - print "Refinement step %d, new grid size: %d" % (refnum+1, HashGridStorage.size()) - - # - #plot grid - # - - - # extend alpha vector (new entries uninitialized) - alpha.resize(HashGridStorage.size()) \ No newline at end of file diff --git a/base/examples/python_simple_refinement.py b/base/examples/python_simple_refinement.py deleted file mode 100644 index dc11bd5eb2..0000000000 --- a/base/examples/python_simple_refinement.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2008-today The SG++ project -# This file is part of the SG++ project. For conditions of distribution and -# use, please see the copyright notice provided with SG++ or at -# sgpp.sparsegrids.org - -# import modules -from pysgpp import DataVector, Grid, createOperationHierarchisation, SurplusRefinementFunctor - -# create a two-dimensional piecewise bi-linear grid -dim = 2 -grid = Grid.createLinearGrid(dim) -gridStorage = grid.getStorage() -print "dimensionality: {}".format(dim) - -# create regular grid, level 3 -level = 3 -gridGen = grid.createGridGenerator() -gridGen.regular(level) -print "number of initial grid points: {}".format(gridStorage.size()) - -# definition of function to interpolate - nonsymmetric(!) -f = lambda x0, x1: 16.0 * (x0-1)*x0 * (x1-1)*x1*x1 -# create coefficient vector -alpha = DataVector(gridStorage.size()) -print "length of alpha vector: {}".format(alpha.getSize()) - - -# now refine adaptively 5 times -for refnum in range(5): - # set function values in alpha - for i in xrange(gridStorage.size()): - gp = gridStorage.get(i) - alpha[i] = f(gp.getCoord(0), gp.getCoord(1)) - - # hierarchize - createOperationHierarchisation(grid).doHierarchisation(alpha) - - # refine a single grid point each time - gridGen.refine(SurplusRefinementFunctor(alpha, 1)) - print "refinement step {}, new grid size: {}".format(refnum+1, gridStorage.size()) - - # extend alpha vector (new entries uninitialized) - alpha.resize(gridStorage.size()) \ No newline at end of file diff --git a/base/src/sgpp/base/grid/generation/BoundaryGridGenerator.hpp b/base/src/sgpp/base/grid/generation/BoundaryGridGenerator.hpp index 368a1ebb8a..355fcd372d 100644 --- a/base/src/sgpp/base/grid/generation/BoundaryGridGenerator.hpp +++ b/base/src/sgpp/base/grid/generation/BoundaryGridGenerator.hpp @@ -25,9 +25,10 @@ class BoundaryGridGenerator : public GridGenerator { * Constructor * * @param storage template type that holds the grid points - * @param boundaryLevel level at which the boundary points should be - * inserted (default = 1: boundary has same level - * as main axes) + * @param boundaryLevel 1 + how much levels the boundary is coarser than + * the main axes, 0 means one level finer, + * 1 means same level, + * 2 means one level coarser, etc. */ explicit BoundaryGridGenerator(GridStorage* storage, level_t boundaryLevel = 1); diff --git a/base/src/sgpp/base/grid/generation/hashmap/HashGenerator.hpp b/base/src/sgpp/base/grid/generation/hashmap/HashGenerator.hpp index 3795c10735..3d2b38474d 100755 --- a/base/src/sgpp/base/grid/generation/hashmap/HashGenerator.hpp +++ b/base/src/sgpp/base/grid/generation/hashmap/HashGenerator.hpp @@ -387,14 +387,42 @@ class HashGenerator { /** * Generate a regular sparse grid iteratively (much faster than - * recursively) with truncated boundary, i.e., the boundary grid points - * are inserted at a higher level > 0. + * recursively) with truncated boundary, i.e., + * the sparse grid on the \f$(d-1)\f$-dimensional faces of + * \f$[0, 1]^d\f$ has a coarser level than the main axes + * \f$x_t = 0.5, t = 1, ..., d\f$. + * + * The function adds all hierarchical subspaces \f$W_{\vec{\ell}}\f$ + * where + * * \f$\norm{\vec{\ell}}_1 \le n + d - 1\f$ with + * \f$\forall_t\; \ell_t \ge 1\f$, + * * \f$\norm{\vec{\ell}}_1 \le n + d - b - N_{\vec{\ell}}\f$ with + * \f$N_{\vec{\ell}} := |\{t \mid \ell_t = 0\}| \ge 1\f$, or + * * \f$\vec{\ell} = \vec{0}\f$. + * + * The previous implementation inserted the 1D boundary grid points + * at higher levels (e.g., at boundaryLevel = 2), which + * led to the effect that corner points were missing in + * higher-dimensional grids: For example, if \f$d = 2\f$, + * \f$n = 3\f$, and \f$\mathtt{boundaryLevel} = 3\f$, + * then the four corners had level sum + * \f$2 \cdot \mathtt{boundaryLevel} = 6\f$ (which is greater than + * \f$n + d - 1 = 4\f$), thus they were missing in the sparse grid. + * The midpoints of the four edges, however, had level sum + * \f$\mathtt{boundaryLevel} + 1 = 4 \le n + d - 1\f$ + * and were thus included in the grid. To get the corners into the + * grid, too, one would have to choose \f$n \ge 4\f$. + * + * In contrast, the new implementation makes sure that the corners + * will always appear first in the grid when increasing the level + * \f$n = 1, 2, 3, \dotsc\f$ of the regular grid. * * @param storage pointer to storage object into which * the grid points should be stored * @param n level of regular sparse grid - * @param boundaryLevel level at which the boundary points should be - * inserted; must be >= 1 + * @param boundaryLevel 1 + how much levels the boundary is coarser than + * the main axes, 1 means same level, + * 2 means one level coarser, etc.; must be >= 1 */ void regular_boundary_truncated_iter(GridStorage* storage, level_t n, @@ -412,7 +440,7 @@ class HashGenerator { } // generate boundary basis functions - if (boundaryLevel <= n) { + { idx_1d.push(0, 0, 0, false); storage->insert(idx_1d); @@ -440,29 +468,34 @@ class HashGenerator { for (size_t d = 1; d < dim; d++) { // current size const size_t gridSize = storage->size(); + // curDim is new dimension of the grid points to be inserted + const level_t curDim = static_cast(d + 1); // loop over all current grid points for (size_t g = 0; g < gridSize; g++) { - // add missing level 1 - level_t levelSum = static_cast((dim - 1) - d); - bool hasLevelZero = false; + level_t levelSum = 0; + level_t numberOfZeroLevels = 0; index_type idx(*storage->get(g)); bool firstPoint = true; - // calculate level sum + // calculate level sum and count number of zero levels for (size_t sd = 0; sd < d; sd++) { level_t tmp = idx.getLevel(sd); if (tmp == 0) { - tmp = boundaryLevel; - hasLevelZero = true; + numberOfZeroLevels++; } levelSum += tmp; } - // generate boundary basis functions - if (boundaryLevel + levelSum <= n + dim - 1) { + // generate boundary basis functions, + // but only if levelSum <= + // n + curDim - boundaryLevel - (numberOfZeroLevels + 1) + // (the +1 comes from the fact that the newly generated functions + // will have an additional zero in the d-th dimension) + if ((levelSum + boundaryLevel + numberOfZeroLevels + 1 <= + n + curDim) || (numberOfZeroLevels == curDim - 1)) { idx.push(d, 0, 0, false); storage->update(idx, g); @@ -472,11 +505,31 @@ class HashGenerator { firstPoint = false; } - for (level_t l = 1; l + levelSum <= n + dim - 1; l++) { + level_t upperBound; + + // choose upper bound of level sum according whether + // the new basis function is an interior or a boundary function + // (the loop below skips l = 0 as the boundary points + // have been inserted a few lines above) + if (numberOfZeroLevels > 0) { + // check if upperBound would be negative + // (we're working with unsigned integers here) + if (n + curDim < boundaryLevel + numberOfZeroLevels) { + continue; + } else { + // upper bound for boundary basis functions + upperBound = n + curDim - numberOfZeroLevels - boundaryLevel; + } + } else { + // upper bound for interior basis functions + upperBound = n + curDim - 1; + } + + for (level_t l = 1; l + levelSum <= upperBound; l++) { // generate inner basis functions for (index_t i = 1; i < static_cast(1) << l; i += 2) { if ((l + levelSum) == n + dim - 1) { - idx.push(d, l, i, !hasLevelZero); + idx.push(d, l, i, (numberOfZeroLevels == 0)); } else { idx.push(d, l, i, false); } diff --git a/base/src/sgpp/base/grid/type/BsplineBoundaryGrid.hpp b/base/src/sgpp/base/grid/type/BsplineBoundaryGrid.hpp index 87d98ccea5..3a66b122e2 100755 --- a/base/src/sgpp/base/grid/type/BsplineBoundaryGrid.hpp +++ b/base/src/sgpp/base/grid/type/BsplineBoundaryGrid.hpp @@ -33,9 +33,10 @@ class BsplineBoundaryGrid : public Grid { * * @param dim the dimension of the grid * @param degree the bspline's degree - * @param boundaryLevel level at which the boundary points should be - * inserted (default = 1: boundary has same level - * as main axes) + * @param boundaryLevel 1 + how much levels the boundary is coarser than + * the main axes, 0 means one level finer, + * 1 means same level, + * 2 means one level coarser, etc. */ BsplineBoundaryGrid(size_t dim, size_t degree, @@ -86,7 +87,7 @@ class BsplineBoundaryGrid : public Grid { size_t degree; /// B-spline basis const SBsplineBoundaryBase* basis_; - /// level at which the boundary points should be inserted + /// 1 + how much levels the boundary is coarser than the main axes level_t boundaryLevel; }; diff --git a/base/src/sgpp/base/grid/type/BsplineClenshawCurtisGrid.hpp b/base/src/sgpp/base/grid/type/BsplineClenshawCurtisGrid.hpp index fa238045fc..60f00a5a18 100755 --- a/base/src/sgpp/base/grid/type/BsplineClenshawCurtisGrid.hpp +++ b/base/src/sgpp/base/grid/type/BsplineClenshawCurtisGrid.hpp @@ -33,9 +33,10 @@ class BsplineClenshawCurtisGrid : public Grid { * * @param dim the dimension of the grid * @param degree the bspline's degree - * @param boundaryLevel level at which the boundary points should be - * inserted (default = 1: boundary has same level - * as main axes) + * @param boundaryLevel 1 + how much levels the boundary is coarser than + * the main axes, 0 means one level finer, + * 1 means same level, + * 2 means one level coarser, etc. */ BsplineClenshawCurtisGrid(size_t dim, size_t degree, @@ -86,7 +87,7 @@ class BsplineClenshawCurtisGrid : public Grid { size_t degree; /// B-spline basis const SBsplineClenshawCurtisBase* basis_; - /// level at which the boundary points should be inserted + /// 1 + how much levels the boundary is coarser than the main axes level_t boundaryLevel; }; diff --git a/base/src/sgpp/base/grid/type/LinearBoundaryGrid.hpp b/base/src/sgpp/base/grid/type/LinearBoundaryGrid.hpp index 7375d69830..25766e1ea6 100755 --- a/base/src/sgpp/base/grid/type/LinearBoundaryGrid.hpp +++ b/base/src/sgpp/base/grid/type/LinearBoundaryGrid.hpp @@ -26,9 +26,10 @@ class LinearBoundaryGrid : public Grid { * Constructor Linear Truncated Boundary Grid * * @param dim the dimension of the grid - * @param boundaryLevel level at which the boundary points should be - * inserted (default = 1: boundary has same level - * as main axes) + * @param boundaryLevel 1 + how much levels the boundary is coarser than + * the main axes, 0 means one level finer, + * 1 means same level, + * 2 means one level coarser, etc. */ explicit LinearBoundaryGrid(size_t dim, level_t boundaryLevel = 1); @@ -36,9 +37,10 @@ class LinearBoundaryGrid : public Grid { * Constructor Linear Truncated Boundary Grid * * @param BB the BoundingBox of the grid - * @param boundaryLevel level at which the boundary points should be - * inserted (default = 1: boundary has same level - * as main axes) + * @param boundaryLevel 1 + how much levels the boundary is coarser than + * the main axes, 0 means one level finer, + * 1 means same level, + * 2 means one level coarser, etc. */ explicit LinearBoundaryGrid(BoundingBox& BB, level_t boundaryLevel = 1); @@ -58,7 +60,7 @@ class LinearBoundaryGrid : public Grid { void serialize(std::ostream& ostr) override; protected: - /// level at which the boundary points should be inserted + /// 1 + how much levels the boundary is coarser than the main axes level_t boundaryLevel; }; diff --git a/base/src/sgpp/base/grid/type/LinearClenshawCurtisGrid.hpp b/base/src/sgpp/base/grid/type/LinearClenshawCurtisGrid.hpp index 130dc64665..c7c27e3e7f 100644 --- a/base/src/sgpp/base/grid/type/LinearClenshawCurtisGrid.hpp +++ b/base/src/sgpp/base/grid/type/LinearClenshawCurtisGrid.hpp @@ -26,9 +26,10 @@ class LinearClenshawCurtisGrid : public Grid { * Constructor Linear Truncated Boundary Clenshaw-Curtis Grid * * @param dim the dimension of the grid - * @param boundaryLevel level at which the boundary points should be - * inserted (default = 1: boundary has same level - * as main axes) + * @param boundaryLevel 1 + how much levels the boundary is coarser than + * the main axes, 0 means one level finer, + * 1 means same level, + * 2 means one level coarser, etc. */ explicit LinearClenshawCurtisGrid(size_t dim, level_t boundaryLevel = 1); @@ -36,9 +37,10 @@ class LinearClenshawCurtisGrid : public Grid { * Constructor Linear Truncated Boundary Clenshaw-Curtis Grid * * @param BB the BoundingBox of the grid - * @param boundaryLevel level at which the boundary points should be - * inserted (default = 1: boundary has same level - * as main axes) + * @param boundaryLevel 1 + how much levels the boundary is coarser than + * the main axes, 0 means one level finer, + * 1 means same level, + * 2 means one level coarser, etc. */ explicit LinearClenshawCurtisGrid(BoundingBox& BB, level_t boundaryLevel = 1); @@ -58,7 +60,7 @@ class LinearClenshawCurtisGrid : public Grid { void serialize(std::ostream& ostr) override; protected: - /// level at which the boundary points should be inserted + /// 1 + how much levels the boundary is coarser than the main axes level_t boundaryLevel; }; diff --git a/base/src/sgpp/base/grid/type/PolyBoundaryGrid.hpp b/base/src/sgpp/base/grid/type/PolyBoundaryGrid.hpp index f9bc7e8f32..7957c0d9d5 100755 --- a/base/src/sgpp/base/grid/type/PolyBoundaryGrid.hpp +++ b/base/src/sgpp/base/grid/type/PolyBoundaryGrid.hpp @@ -28,9 +28,10 @@ class PolyBoundaryGrid : public Grid { * * @param dim the dimension of the grid * @param degree the max. polynom's degree - * @param boundaryLevel level at which the boundary points should be - * inserted (default = 1: boundary has same level - * as main axes) + * @param boundaryLevel 1 + how much levels the boundary is coarser than + * the main axes, 0 means one level finer, + * 1 means same level, + * 2 means one level coarser, etc. */ PolyBoundaryGrid(size_t dim, size_t degree, level_t boundaryLevel = 1); @@ -53,7 +54,7 @@ class PolyBoundaryGrid : public Grid { size_t degree; /// polynomial basis const SPolyBoundaryBase* basis_; - /// level at which the boundary points should be inserted + /// 1 + how much levels the boundary is coarser than the main axes level_t boundaryLevel; }; diff --git a/base/src/sgpp/base/grid/type/WaveletBoundaryGrid.hpp b/base/src/sgpp/base/grid/type/WaveletBoundaryGrid.hpp index 40f53545b1..89512deb60 100755 --- a/base/src/sgpp/base/grid/type/WaveletBoundaryGrid.hpp +++ b/base/src/sgpp/base/grid/type/WaveletBoundaryGrid.hpp @@ -26,9 +26,10 @@ class WaveletBoundaryGrid : public Grid { * Constructor of grid with wavelet base functions with boundaries, pentagon cut * * @param dim the dimension of the grid - * @param boundaryLevel level at which the boundary points should be - * inserted (default = 1: boundary has same level - * as main axes) + * @param boundaryLevel 1 + how much levels the boundary is coarser than + * the main axes, 0 means one level finer, + * 1 means same level, + * 2 means one level coarser, etc. */ explicit WaveletBoundaryGrid(size_t dim, level_t boundaryLevel = 1); @@ -46,7 +47,7 @@ class WaveletBoundaryGrid : public Grid { static Grid* unserialize(std::istream& istr); protected: - /// level at which the boundary points should be inserted + /// 1 + how much levels the boundary is coarser than the main axes level_t boundaryLevel; }; diff --git a/base/src/sgpp/base/opencl/SConscript b/base/src/sgpp/base/opencl/SConscript index 650cf0fbf3..a08c598e98 100644 --- a/base/src/sgpp/base/opencl/SConscript +++ b/base/src/sgpp/base/opencl/SConscript @@ -3,11 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] if env['USE_OCL']: for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/base/src/sgpp/base/operation/hash/common/basis/BsplineClenshawCurtisBasis.hpp b/base/src/sgpp/base/operation/hash/common/basis/BsplineClenshawCurtisBasis.hpp index d8e57d46cf..35e3b749e7 100755 --- a/base/src/sgpp/base/operation/hash/common/basis/BsplineClenshawCurtisBasis.hpp +++ b/base/src/sgpp/base/operation/hash/common/basis/BsplineClenshawCurtisBasis.hpp @@ -28,7 +28,7 @@ class BsplineClenshawCurtisBasis: public Basis { * Default constructor. */ BsplineClenshawCurtisBasis() - : bsplineBasis(BsplineBasis()) { + : BsplineClenshawCurtisBasis(0) { } /** @@ -39,7 +39,8 @@ class BsplineClenshawCurtisBasis: public Basis { */ explicit BsplineClenshawCurtisBasis(size_t degree) : bsplineBasis(BsplineBasis(degree)), - xi(std::vector(degree + 2, 0.0)) { + xi(std::vector(degree + 2, 0.0)), + clenshawCurtisTable(ClenshawCurtisTable::getInstance()) { } /** @@ -129,7 +130,7 @@ class BsplineClenshawCurtisBasis: public Basis { * @return i-th Clenshaw-Curtis grid point with level l */ inline float_t clenshawCurtisPoint(LT l, IT i) const { - return ClenshawCurtisTable::getInstance().getPoint(l, i); + return clenshawCurtisTable.getPoint(l, i); } /** @@ -143,7 +144,7 @@ class BsplineClenshawCurtisBasis: public Basis { const IT hInv = static_cast(1) << l; const size_t& p = bsplineBasis.getDegree(); - xi[(p + 1) / 2] = ClenshawCurtisTable::getInstance().getPoint(l, i); + xi[(p + 1) / 2] = clenshawCurtisTable.getPoint(l, i); if (i < (p + 1) / 2) { // grid point index is too far on the left @@ -151,8 +152,7 @@ class BsplineClenshawCurtisBasis: public Basis { size_t a = (p + 1) / 2 - i; for (size_t j = a; j < (p + 1) / 2; j++) { - xi[j] = ClenshawCurtisTable:: - getInstance().getPoint(l, static_cast(j - a)); + xi[j] = clenshawCurtisTable.getPoint(l, static_cast(j - a)); } float_t h = xi[a + 1] - xi[a]; @@ -164,7 +164,7 @@ class BsplineClenshawCurtisBasis: public Basis { } else { // all grid points on the left can be calculated for (size_t j = 0; j < (p + 1) / 2; j++) { - xi[j] = ClenshawCurtisTable::getInstance().getPoint( + xi[j] = clenshawCurtisTable.getPoint( l, static_cast(i - (p + 1) / 2 + j)); } } @@ -175,7 +175,7 @@ class BsplineClenshawCurtisBasis: public Basis { size_t b = hInv + (p + 1) / 2 - i; for (size_t j = (p + 1) / 2 + 1; j <= b; j++) { - xi[j] = ClenshawCurtisTable::getInstance().getPoint( + xi[j] = clenshawCurtisTable.getPoint( l, static_cast(i - (p + 1) / 2 + j)); } @@ -187,7 +187,7 @@ class BsplineClenshawCurtisBasis: public Basis { } else { // all grid points on the right can be calculated for (size_t j = (p + 1) / 2 + 1; j < p + 2; j++) { - xi[j] = ClenshawCurtisTable::getInstance().getPoint( + xi[j] = clenshawCurtisTable.getPoint( l, static_cast(i - (p + 1) / 2 + j)); } } @@ -261,6 +261,8 @@ class BsplineClenshawCurtisBasis: public Basis { BsplineBasis bsplineBasis; /// temporary helper vector of fixed size p+2 containing B-spline knots std::vector xi; + /// reference to the Clenshaw-Curtis cache table + ClenshawCurtisTable& clenshawCurtisTable; }; // default type-def (unsigned int for level and index) diff --git a/base/src/sgpp/base/operation/hash/common/basis/BsplineModifiedClenshawCurtisBasis.hpp b/base/src/sgpp/base/operation/hash/common/basis/BsplineModifiedClenshawCurtisBasis.hpp index d172641f93..85a9ebed76 100755 --- a/base/src/sgpp/base/operation/hash/common/basis/BsplineModifiedClenshawCurtisBasis.hpp +++ b/base/src/sgpp/base/operation/hash/common/basis/BsplineModifiedClenshawCurtisBasis.hpp @@ -39,7 +39,8 @@ class BsplineModifiedClenshawCurtisBasis : public Basis { */ explicit BsplineModifiedClenshawCurtisBasis(size_t degree) : degree(degree), - xi(std::vector(degree + 2, 0.0)) { + xi(std::vector(degree + 2, 0.0)), + clenshawCurtisTable(ClenshawCurtisTable::getInstance()) { if (degree < 1) { this->degree = 1; } else if (degree % 2 == 0) { @@ -157,6 +158,8 @@ class BsplineModifiedClenshawCurtisBasis : public Basis { size_t degree; /// temporary helper vector of fixed size p+2 containing B-spline knots std::vector xi; + /// reference to the Clenshaw-Curtis cache table + ClenshawCurtisTable& clenshawCurtisTable; /** * @param l level of the grid point @@ -169,18 +172,16 @@ class BsplineModifiedClenshawCurtisBasis : public Basis { return static_cast(i) / 2.0; } else if (i == 0) { // = x_{l,1} - (x_{l,2} - x_{l,1}) - return 2.0 * ClenshawCurtisTable::getInstance().getPoint(l, 1, hInv) - - ClenshawCurtisTable::getInstance().getPoint(l, 2, hInv); + return 2.0 * clenshawCurtisTable.getPoint(l, 1, hInv) - + clenshawCurtisTable.getPoint(l, 2, hInv); } else if (i >= hInv) { - const float_t x1 = ClenshawCurtisTable:: - getInstance().getPoint(l, 1, hInv); - const float_t x2 = ClenshawCurtisTable:: - getInstance().getPoint(l, 2, hInv); + const float_t x1 = clenshawCurtisTable.getPoint(l, 1, hInv); + const float_t x2 = clenshawCurtisTable.getPoint(l, 2, hInv); const float_t hBoundary = x2 - x1; return (1.0 - x1) + hBoundary * static_cast(i - hInv + 1); } else { - return ClenshawCurtisTable::getInstance().getPoint(l, i, hInv); + return clenshawCurtisTable.getPoint(l, i, hInv); } } @@ -191,8 +192,8 @@ class BsplineModifiedClenshawCurtisBasis : public Basis { * @return (-ni)-th Clenshaw-Curtis grid point with level l */ inline float_t clenshawCurtisPointNegativeIndex(LT l, IT ni, IT hInv) const { - const float_t x1 = ClenshawCurtisTable::getInstance().getPoint(l, 1, hInv); - const float_t x2 = ClenshawCurtisTable::getInstance().getPoint(l, 2, hInv); + const float_t x1 = clenshawCurtisTable.getPoint(l, 1, hInv); + const float_t x2 = clenshawCurtisTable.getPoint(l, 2, hInv); const float_t hBoundary = x2 - x1; return x1 - hBoundary * static_cast(ni + 1); diff --git a/base/src/sgpp/base/operation/hash/common/basis/LinearClenshawCurtisBasis.hpp b/base/src/sgpp/base/operation/hash/common/basis/LinearClenshawCurtisBasis.hpp index 49e39b7a8e..21c3d0451c 100755 --- a/base/src/sgpp/base/operation/hash/common/basis/LinearClenshawCurtisBasis.hpp +++ b/base/src/sgpp/base/operation/hash/common/basis/LinearClenshawCurtisBasis.hpp @@ -22,6 +22,10 @@ namespace base { template class LinearClenshawCurtisBasis: public Basis { public: + LinearClenshawCurtisBasis() : + clenshawCurtisTable(ClenshawCurtisTable::getInstance()) { + } + /** * Destructor. */ @@ -44,8 +48,8 @@ class LinearClenshawCurtisBasis: public Basis { } } else { // endpoints of support - const float_t x0 = ClenshawCurtisTable::getInstance().getPoint(l, i - 1); - const float_t x2 = ClenshawCurtisTable::getInstance().getPoint(l, i + 1); + const float_t x0 = clenshawCurtisTable.getPoint(l, i - 1); + const float_t x2 = clenshawCurtisTable.getPoint(l, i + 1); if ((x <= x0) || (x >= x2)) { // point out of support @@ -53,7 +57,7 @@ class LinearClenshawCurtisBasis: public Basis { } // peak of basis function - const float_t x1 = ClenshawCurtisTable::getInstance().getPoint(l, i); + const float_t x1 = clenshawCurtisTable.getPoint(l, i); // linear interpolation between (x0, x1, x2), (0, 1, 0) if (x < x1) { @@ -63,6 +67,10 @@ class LinearClenshawCurtisBasis: public Basis { } } } + + protected: + /// reference to the Clenshaw-Curtis cache table + ClenshawCurtisTable& clenshawCurtisTable; }; // default type-def (unsigned int for level and index) diff --git a/base/src/sgpp/base/tools/ClenshawCurtisTable.cpp b/base/src/sgpp/base/tools/ClenshawCurtisTable.cpp index 8bf0523eac..23f6262258 100644 --- a/base/src/sgpp/base/tools/ClenshawCurtisTable.cpp +++ b/base/src/sgpp/base/tools/ClenshawCurtisTable.cpp @@ -28,5 +28,10 @@ ClenshawCurtisTable::ClenshawCurtisTable(level_type maxLevel) } } +ClenshawCurtisTable& ClenshawCurtisTable::getInstance() { + static ClenshawCurtisTable clenshawCurtisTable; + return clenshawCurtisTable; +} + } // namespace base } // namespace SGPP diff --git a/base/src/sgpp/base/tools/ClenshawCurtisTable.hpp b/base/src/sgpp/base/tools/ClenshawCurtisTable.hpp index 0d5f467db4..807e77493e 100644 --- a/base/src/sgpp/base/tools/ClenshawCurtisTable.hpp +++ b/base/src/sgpp/base/tools/ClenshawCurtisTable.hpp @@ -29,10 +29,7 @@ class ClenshawCurtisTable { /// default number of intervals static const level_type DEFAULT_MAX_LEVEL = 16; - inline static ClenshawCurtisTable& getInstance() { - static ClenshawCurtisTable clenshawCurtisTable; - return clenshawCurtisTable; - } + static ClenshawCurtisTable& getInstance(); /** * @param l level of the grid point diff --git a/base/src/sgpp/globaldef.hpp b/base/src/sgpp/globaldef.hpp index 8ceee5bc8b..e3f316fc12 100644 --- a/base/src/sgpp/globaldef.hpp +++ b/base/src/sgpp/globaldef.hpp @@ -102,7 +102,7 @@ namespace std { // it doesn't contain this function. (see std::make_shared) // This function is part of the C++14 (and newer) standard. template -std::unique_ptr make_unique(Args&& ...args) { +std::unique_ptr make_unique(Args&& ...args) { // NOLINT(build/c++11) return std::unique_ptr(new T(std::forward(args)...)); } diff --git a/base/tests/test_HashGridStorage.cpp b/base/tests/test_HashGridStorage.cpp index 07f6c05f07..f6307d3317 100644 --- a/base/tests/test_HashGridStorage.cpp +++ b/base/tests/test_HashGridStorage.cpp @@ -319,7 +319,7 @@ BOOST_AUTO_TEST_CASE(testRegularTruncatedBoundaries1D) { HashGridStorage s(1); HashGenerator g; - g.regularWithBoundaries(&s, 2, true); + g.regularWithBoundaries(&s, 2, 1); BOOST_CHECK_EQUAL(s.size(), 5U); } @@ -328,12 +328,12 @@ BOOST_AUTO_TEST_CASE(testRegularTruncatedBoundaries2D) { HashGridStorage s(2); HashGenerator g; - g.regularWithBoundaries(&s, 2, true); + g.regularWithBoundaries(&s, 2, 1); BOOST_CHECK_EQUAL(s.size(), 21U); HashGridStorage s2(2); - g.regularWithBoundaries(&s2, 3, true); + g.regularWithBoundaries(&s2, 3, 1); BOOST_CHECK_EQUAL(s2.size(), 49U); @@ -366,7 +366,7 @@ BOOST_AUTO_TEST_CASE(testRegularTruncatedBoundaries3D) { HashGridStorage s(3); HashGenerator g; - g.regularWithBoundaries(&s, 2, true); + g.regularWithBoundaries(&s, 2, 1); BOOST_CHECK_EQUAL(s.size(), 81U); } @@ -395,7 +395,7 @@ BOOST_AUTO_TEST_CASE(testFreeRefineTruncatedBoundaries) { HashGridStorage s(2); HashGenerator g; - g.regularWithBoundaries(&s, 1, true); + g.regularWithBoundaries(&s, 1, 1); DataVector d(9); d[0] = 0.0; @@ -421,7 +421,7 @@ BOOST_AUTO_TEST_CASE(testFreeRefineTruncatedBoundaries2) { HashGridStorage s(2); HashGenerator g; - g.regularWithBoundaries(&s, 2, false); + g.regularWithBoundaries(&s, 2, 0); DataVector d(17); diff --git a/combigrid/SConscript b/combigrid/SConscript index 23ec1f0a5c..f759babba2 100755 --- a/combigrid/SConscript +++ b/combigrid/SConscript @@ -17,6 +17,7 @@ Import('installTargetList') Import('exampleTargetList') Import('headerSourceList') Import('headerDestList') +Import('lintAction') #moduleDependencies = ['sgppbase'] moduleDependencies = [] @@ -33,7 +34,10 @@ if env['USE_STATICLIB']: moduleDependencies[i] = "%sstatic" % moduleDependencies[i] Export('libname') +cpps = [] +hpps = [] objs = [] + for currentFolder, subdirNames, fileNames in os.walk("src"): if currentFolder.startswith(os.path.join( "src", "sgpp", "combigrid", "test")) or \ @@ -45,12 +49,15 @@ for currentFolder, subdirNames, fileNames in os.walk("src"): "src","sgpp","combigrid_old")): continue for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) if currentFolder != 'src': for fileName in fnmatch.filter(fileNames, '*.hpp'): - headerSourceList.append(os.path.join(moduleName, currentFolder, fileName)) - headerDestList.append(os.path.join(currentFolder, fileName).split(os.sep,1)[1]) + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + headerSourceList.append(os.path.join(moduleName, hpp)) + headerDestList.append(hpp.split(os.sep, 1)[1]) if env['USE_STATICLIB']: libsuffix = env['LIBSUFFIX'] @@ -73,6 +80,11 @@ for lib_str in moduleDependencies: libInstall = env.Install(BUILD_DIR, lib) +if env['RUN_CPPLINT']: + for path in cpps + hpps: + lintCommand = env.Command(path + ".lint", path, lintAction) + env.Depends(lib, lintCommand) + if not env['NO_UNIT_TESTS'] and env['SG_PYTHON']: Import('testTargetList') py_test_env = env.Clone() diff --git a/combigrid/src/combigrid.hpp b/combigrid/src/combigrid.hpp index 3054b0fb58..2596b19317 100644 --- a/combigrid/src/combigrid.hpp +++ b/combigrid/src/combigrid.hpp @@ -1,6 +1,9 @@ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #ifdef COMBIGRID_HPP_ #define COMBIGRID_HPP_ - - #endif diff --git a/combigrid/src/sgpp/combigrid/basisfunction/CombiBasisFunctionBasis.hpp b/combigrid/src/sgpp/combigrid/basisfunction/CombiBasisFunctionBasis.hpp index 6270175dc2..a03fd04d0c 100644 --- a/combigrid/src/sgpp/combigrid/basisfunction/CombiBasisFunctionBasis.hpp +++ b/combigrid/src/sgpp/combigrid/basisfunction/CombiBasisFunctionBasis.hpp @@ -1,14 +1,12 @@ -/* **************************************************************************** -* Copyright (C) 2011 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef COMBIBASISFUNCTION_HPP_ #define COMBIBASISFUNCTION_HPP_ -#include "../utils/combigrid_utils.hpp" +#include namespace combigrid { @@ -37,6 +35,6 @@ class BasisFunctionBasis { * could be different [-1,2]*/ virtual double functionEval2(double coord) const = 0; }; -} +} // namespace combigrid #endif /* COMBIBASISFUNCTION_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/basisfunction/CombiLinearBasisFunction.cpp b/combigrid/src/sgpp/combigrid/basisfunction/CombiLinearBasisFunction.cpp index 38045edf1f..23f7e0842e 100644 --- a/combigrid/src/sgpp/combigrid/basisfunction/CombiLinearBasisFunction.cpp +++ b/combigrid/src/sgpp/combigrid/basisfunction/CombiLinearBasisFunction.cpp @@ -1,14 +1,9 @@ -/* **************************************************************************** -* Copyright (C) 2011 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include -using namespace std; - -const combigrid::BasisFunctionBasis* - combigrid::LinearBasisFunction::defaultBasis_ = - new combigrid::LinearBasisFunction(); +const combigrid::BasisFunctionBasis* combigrid::LinearBasisFunction::defaultBasis_ = + new combigrid::LinearBasisFunction(); diff --git a/combigrid/src/sgpp/combigrid/basisfunction/CombiLinearBasisFunction.hpp b/combigrid/src/sgpp/combigrid/basisfunction/CombiLinearBasisFunction.hpp index 5c5a4594ec..41477bb841 100644 --- a/combigrid/src/sgpp/combigrid/basisfunction/CombiLinearBasisFunction.hpp +++ b/combigrid/src/sgpp/combigrid/basisfunction/CombiLinearBasisFunction.hpp @@ -1,15 +1,13 @@ -/* **************************************************************************** -* Copyright (C) 2011 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef COMBILINEARBASISFUNCTION_HPP_ #define COMBILINEARBASISFUNCTION_HPP_ #include -#include "../utils/combigrid_utils.hpp" +#include namespace combigrid { @@ -38,6 +36,6 @@ class LinearBasisFunction : public combigrid::BasisFunctionBasis { /** default basis function */ static const BasisFunctionBasis* defaultBasis_; }; -} +} // namespace combigrid #endif /* COMBILINEARBASISFUNCTION_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/combigrid/CombiGrid.hpp b/combigrid/src/sgpp/combigrid/combigrid/CombiGrid.hpp index f5e7731c53..f3847e7288 100644 --- a/combigrid/src/sgpp/combigrid/combigrid/CombiGrid.hpp +++ b/combigrid/src/sgpp/combigrid/combigrid/CombiGrid.hpp @@ -1,9 +1,7 @@ -/* - * CombiGrid.hpp - * - * Created on: May 22, 2014 - * Author: petzko - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef COMBIGRID_HPP_ #define COMBIGRID_HPP_ @@ -12,13 +10,14 @@ #include // ------ SGpp includes ------------- -//#include "base/datatypes/DataVector.hpp" -//#include "base/grid/GridStorage.hpp" +// #include "base/datatypes/DataVector.hpp" +// #include "base/grid/GridStorage.hpp" #include #include +#include + #include -#include "../utils/combigrid_utils.hpp" -#include "../utils/combigrid_utils.hpp" +#include namespace combigrid { @@ -54,8 +53,7 @@ class CombiGrid { _Tp res = 0.0; if (_combischeme == NULL) { - COMBIGRID_OUT_WRN("Combigrid Evaluation failed! Combischeme not set.", - __FILE__, __LINE__) + COMBIGRID_OUT_WRN("Combigrid Evaluation failed! Combischeme not set.", __FILE__, __LINE__) } else { res = _combischeme->evalCombiGrid(_fgrids, coords); @@ -69,11 +67,9 @@ class CombiGrid { * @param coords - a list of coordinates to evaluate the grid on * @param results the result vector */ - virtual void eval(std::vector >& coords, - std::vector<_Tp>& results) const { + virtual void eval(std::vector >& coords, std::vector<_Tp>& results) const { if (_combischeme == NULL) { - COMBIGRID_OUT_WRN("Combigrid Evaluation failed! Combischeme not set.", - __FILE__, __LINE__) + COMBIGRID_OUT_WRN("Combigrid Evaluation failed! Combischeme not set.", __FILE__, __LINE__) } else { _combischeme->evalCombiGrid(_fgrids, coords, results); } @@ -108,9 +104,8 @@ class CombiGrid { // on state change --> call the combischeme recompute coefficients method! if (_combischeme != NULL) - COMBIGRID_OUT_WRN( - "Combigrid coefficients recalculation failed! Combischeme not set.", - __FILE__, __LINE__) + COMBIGRID_OUT_WRN("Combigrid coefficients recalculation failed! Combischeme not set.", + __FILE__, __LINE__) else _combischeme->recomputeCoefficients(_dim, _fgrids); } @@ -122,17 +117,15 @@ class CombiGrid { * @param hasBoundaryPts for each dimension if the full grid should have * boundary points * @param coef the coeficient in the combination scheme */ - void addFullGrid(const std::vector& levels, - const std::vector& hasBoundaryPts, _Tp coef) { - combigrid::FGridContainer<_Tp>* grid = - new FGridContainer<_Tp>(levels, hasBoundaryPts, coef); + void addFullGrid(const std::vector& levels, const std::vector& hasBoundaryPts, + _Tp coef) { + combigrid::FGridContainer<_Tp>* grid = new FGridContainer<_Tp>(levels, hasBoundaryPts, coef); _fgrids.push_back(grid); // on state change --> call the combischeme recalculate coefficients method! if (_combischeme == NULL) - COMBIGRID_OUT_WRN( - "Combigrid coefficients recalculation failed! Combischeme not set.", - __FILE__, __LINE__) + COMBIGRID_OUT_WRN("Combigrid coefficients recalculation failed! Combischeme not set.", + __FILE__, __LINE__) else _combischeme->recomputeCoefficients(_dim, _fgrids); } @@ -149,8 +142,7 @@ class CombiGrid { */ void init() { if (_combischeme == NULL) { - COMBIGRID_OUT_WRN("Combigrid Evaluation failed! Combischeme not set.", - __FILE__, __LINE__) + COMBIGRID_OUT_WRN("Combigrid Evaluation failed! Combischeme not set.", __FILE__, __LINE__) return; } @@ -164,8 +156,8 @@ class CombiGrid { // create add all full grids to the fullgrid container. for (unsigned int i = 0; i < tmp_levels_vtr.size(); i++) { - FGridContainer<_Tp>* fg = new FGridContainer<_Tp>( - tmp_levels_vtr[i], _hasBoundaryPts, tmp_cf_vector[i]); + FGridContainer<_Tp>* fg = + new FGridContainer<_Tp>(tmp_levels_vtr[i], _hasBoundaryPts, tmp_cf_vector[i]); _fgrids.push_back(fg); } } @@ -188,8 +180,7 @@ class CombiGrid { void re_init() { if (_combischeme == NULL) { - COMBIGRID_OUT_WRN("Combigrid Evaluation failed! Combischeme not set.", - __FILE__, __LINE__) + COMBIGRID_OUT_WRN("Combigrid Evaluation failed! Combischeme not set.", __FILE__, __LINE__) return; } @@ -198,26 +189,23 @@ class CombiGrid { std::vector<_Tp> tmp_cf_vector; // then reinitialize the levels vector and the coefs vector; - _combischeme->re_initCombiGrid(_dim, _fgrids, tmp_levels_vtr, - tmp_cf_vector); + _combischeme->re_initCombiGrid(_dim, _fgrids, tmp_levels_vtr, tmp_cf_vector); // create add all full grids to the fullgrid container. for (unsigned int i = 0; i < tmp_levels_vtr.size(); i++) { - FGridContainer<_Tp>* fg = new FGridContainer<_Tp>( - tmp_levels_vtr[i], _hasBoundaryPts, tmp_cf_vector[i]); + FGridContainer<_Tp>* fg = + new FGridContainer<_Tp>(tmp_levels_vtr[i], _hasBoundaryPts, tmp_cf_vector[i]); _fgrids.push_back(fg); } } /////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////Getters & - ///Setters////////////////////////////////////// + //////////////////////////////// Getters & Setters //////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////// std::vector<_Tp> getCoefs() { std::vector<_Tp> vect; - for (unsigned int i = 0; i < _fgrids.size(); i++) - vect.push_back(_fgrids[i]->getCoef()); + for (unsigned int i = 0; i < _fgrids.size(); i++) vect.push_back(_fgrids[i]->getCoef()); return vect; } @@ -225,8 +213,7 @@ class CombiGrid { std::vector > getLevelsVector() { std::vector > vect; - for (unsigned int i = 0; i < _fgrids.size(); i++) - vect.push_back(_fgrids[i]->getFGLevels()); + for (unsigned int i = 0; i < _fgrids.size(); i++) vect.push_back(_fgrids[i]->getFGLevels()); return vect; } @@ -246,9 +233,8 @@ class CombiGrid { * @param stretching - a pointer to a stretching class instance * * */ - void initializeActiveGridsDomain( - std::vector min, std::vector max, - combigrid::AbstractStretchingMaker* stretching) { + void initializeActiveGridsDomain(std::vector min, std::vector max, + combigrid::AbstractStretchingMaker* stretching) { for (unsigned int g = 0; g < this->getNrFullGrids(); g++) { if (getFullGrid(g)->isActive()) { FullGrid<_Tp>* fg = getFullGrid(g)->fg(); @@ -256,8 +242,7 @@ class CombiGrid { if (domain != NULL) delete domain; - fg->setDomain( - new GridDomain(_dim, fg->getLevels(), min, max, *stretching)); + fg->setDomain(new GridDomain(_dim, fg->getLevels(), min, max, *stretching)); } } @@ -303,9 +288,7 @@ class CombiGrid { Stretching getStretchingType() { return _stretchingType; } /** return the combi scheme */ - const AbstractCombiScheme<_Tp>* getCombiScheme() const { - return _combischeme; - } + const AbstractCombiScheme<_Tp>* getCombiScheme() const { return _combischeme; } /** * Attach a new combischeme to this grid! An combischeme captures the @@ -317,9 +300,7 @@ class CombiGrid { * are delegated to the underlying combischeme! * */ - void attachCombiScheme(AbstractCombiScheme<_Tp>* scheme) { - this->_combischeme = scheme; - } + void attachCombiScheme(AbstractCombiScheme<_Tp>* scheme) { this->_combischeme = scheme; } /* * Detach the current combischeme, and return it to the user! @@ -338,8 +319,7 @@ class CombiGrid { unsigned int getNrActiveFullGrids() { unsigned int ctr = 0; - for (unsigned int i = 0; i < _fgrids.size(); i++) - ctr += _fgrids[i]->isActive() ? 1 : 0; + for (unsigned int i = 0; i < _fgrids.size(); i++) ctr += _fgrids[i]->isActive() ? 1 : 0; return ctr; } diff --git a/combigrid/src/sgpp/combigrid/combigrid/SerialCombiGrid.cpp b/combigrid/src/sgpp/combigrid/combigrid/SerialCombiGrid.cpp index 69b05ac20e..754dcfd3c7 100644 --- a/combigrid/src/sgpp/combigrid/combigrid/SerialCombiGrid.cpp +++ b/combigrid/src/sgpp/combigrid/combigrid/SerialCombiGrid.cpp @@ -1,12 +1,14 @@ - +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include /** sets the domain of all the full grids, this is the correct way for * extrapolation */ template -void combigrid::SerialCombiGrid<_Tp>::setDomainAllFG( - GridDomain* gridDomain) const { +void combigrid::SerialCombiGrid<_Tp>::setDomainAllFG(GridDomain* gridDomain) const { for (unsigned int i = 0; i < this->_fgrids.size(); i++) { this->_fgrids[i]->fg()->setDomain(gridDomain); } diff --git a/combigrid/src/sgpp/combigrid/combigrid/SerialCombiGrid.hpp b/combigrid/src/sgpp/combigrid/combigrid/SerialCombiGrid.hpp index ac7562100a..493cd15a29 100644 --- a/combigrid/src/sgpp/combigrid/combigrid/SerialCombiGrid.hpp +++ b/combigrid/src/sgpp/combigrid/combigrid/SerialCombiGrid.hpp @@ -1,15 +1,16 @@ -/* - * SerialCombiGrid.hpp - * - * Created on: May 22, 2014 - * Author: petzko - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #ifndef SERIALCOMBIGRID_HPP_ #define SERIALCOMBIGRID_HPP_ #include #include -#include "../utils/combigrid_utils.hpp" +#include + +#include namespace combigrid { template @@ -28,6 +29,6 @@ class SerialCombiGrid : public CombiGrid<_Tp> { * This is be different for serial and parallel implementations */ void createFullGrids(); }; -} +} // namespace combigrid #endif /* SERIALCOMBIGRID_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/combischeme/AbstractCombiScheme.hpp b/combigrid/src/sgpp/combigrid/combischeme/AbstractCombiScheme.hpp index ba15f15c10..8dcd1197b0 100644 --- a/combigrid/src/sgpp/combigrid/combischeme/AbstractCombiScheme.hpp +++ b/combigrid/src/sgpp/combigrid/combischeme/AbstractCombiScheme.hpp @@ -1,9 +1,7 @@ -/* - * AbstractCombiScheme.hpp - * - * Created on: May 22, 2014 - * Author: petzko - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef ABSTRACTCOMBISCHEME_HPP_ #define ABSTRACTCOMBISCHEME_HPP_ @@ -11,8 +9,10 @@ #include #include #include +#include + #include -#include "../utils/combigrid_utils.hpp" +#include namespace combigrid { @@ -35,9 +35,7 @@ class AbstractCombiScheme { * @param trunc_levels: a vector(list) of intergers specifying the truncation * level per dimension * */ - void setTruncationLevels(std::vector trunc_levels) { - _levels_truncation = trunc_levels; - } + void setTruncationLevels(std::vector trunc_levels) { _levels_truncation = trunc_levels; } /** * Default destructor @@ -70,8 +68,7 @@ class AbstractCombiScheme { * * */ - virtual void initCombiGrid(int in_dim, - std::vector >& out_levels_vector, + virtual void initCombiGrid(int in_dim, std::vector >& out_levels_vector, std::vector<_Tp>& out_coefs) = 0; /** @@ -96,10 +93,9 @@ class AbstractCombiScheme { * * */ - virtual void re_initCombiGrid( - int in_dim, const std::vector*> in_grids, - std::vector >& out_levels_vector, - std::vector<_Tp>& out_coefs) = 0; + virtual void re_initCombiGrid(int in_dim, const std::vector*> in_grids, + std::vector >& out_levels_vector, + std::vector<_Tp>& out_coefs) = 0; /** Implement this method with desired logic to handle situations when * recomputation of the coefficients might be necessary. @@ -110,8 +106,7 @@ class AbstractCombiScheme { * current combigrid- will be updated with the newly recomputed * coefficients * */ - virtual void recomputeCoefficients( - int in_dim, std::vector*>& out_fgrids) = 0; + virtual void recomputeCoefficients(int in_dim, std::vector*>& out_fgrids) = 0; /** * Evaluate the combi grid at one specified point. Buffered evaluation @@ -164,7 +159,7 @@ class AbstractCombiScheme { out_results.resize(in_coords.size()); // just iterate over each point and call the serial evaluation function - for (int i = 0; i < (int)out_results.size(); i++) { + for (int i = 0; i < static_cast(out_results.size()); i++) { out_results[i] = evalCombiGrid(in_fgrids, in_coords[i]); } } @@ -176,8 +171,7 @@ class AbstractCombiScheme { *is to be evaluated onto the in_coords * @param in_coords the coordinate points to evaluate */ - _Tp evalSingleGrid(const int index, - const std::vector*>& in_fgrids, + _Tp evalSingleGrid(const int index, const std::vector*>& in_fgrids, const std::vector& in_coords) const { std::vector coords_temp = in_coords; // do not check if the current grid is active within the combigrid !!! @@ -195,17 +189,18 @@ class AbstractCombiScheme { int size_fg = static_cast(out_levels_vector.size()); - while ((int)i < size_fg - 1) { + while (static_cast(i) < size_fg - 1) { j = i + 1; - while ((int)j < size_fg) { + while (static_cast(j) < size_fg) { if (out_levels_vector[i] == out_levels_vector[j]) { out_levels_vector.erase(gt + j); out_coefs[i] += out_coefs[j]; out_coefs.erase(ct + j); size_fg--; - } else + } else { j++; + } } if (out_coefs[i] == 0.0) { @@ -217,15 +212,16 @@ class AbstractCombiScheme { gt = out_levels_vector.begin(); ct = out_coefs.begin(); } - } else + } else { i++; + } } } - std::vector updateScheme( - std::vector > levelsNew, std::vector<_Tp> coefs_new, - std::vector >& out_levels_vector, - std::vector<_Tp>& out_coefs) { + std::vector updateScheme(std::vector > levelsNew, + std::vector<_Tp> coefs_new, + std::vector >& out_levels_vector, + std::vector<_Tp>& out_coefs) { removeDuplicates(out_levels_vector, out_coefs); std::vector result(0); @@ -263,5 +259,5 @@ class AbstractCombiScheme { return result; } }; -} +} // namespace combigrid #endif /* ABSTRACTCOMBISCHEME_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/combischeme/CombiArbitraryScheme.cpp b/combigrid/src/sgpp/combigrid/combischeme/CombiArbitraryScheme.cpp index 60daca4ed6..dbb7ca73cc 100644 --- a/combigrid/src/sgpp/combigrid/combischeme/CombiArbitraryScheme.cpp +++ b/combigrid/src/sgpp/combigrid/combischeme/CombiArbitraryScheme.cpp @@ -1,11 +1,12 @@ -/* - * CombiArbitraryScheme_demo.cpp - * - * Created on: 29 Jun 2014 - * Author: kenny - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include + +#include + // using namespace combigrid; template combigrid::CombiArbitraryScheme<_Tp>::CombiArbitraryScheme( @@ -16,23 +17,19 @@ combigrid::CombiArbitraryScheme<_Tp>::CombiArbitraryScheme( template void combigrid::CombiArbitraryScheme<_Tp>::initCombiGrid( - int in_dim, std::vector >& out_levels_vector, - std::vector<_Tp>& out_coefs) { + int in_dim, std::vector >& out_levels_vector, std::vector<_Tp>& out_coefs) { // acta simplitica! - CombigridLevelVector buffer = - CombigridLevelVector::getCombiLevels(_levels_vector); + CombigridLevelVector buffer = CombigridLevelVector::getCombiLevels(_levels_vector); out_levels_vector = buffer.getLevelVec(); std::vector tmp_coef = buffer.getCoef(); out_coefs.clear(); - for (unsigned int i = 0; i < tmp_coef.size(); i++) - out_coefs.push_back((_Tp)tmp_coef[i]); + for (unsigned int i = 0; i < tmp_coef.size(); i++) out_coefs.push_back((_Tp)tmp_coef[i]); } template void combigrid::CombiArbitraryScheme<_Tp>::re_initCombiGrid( int in_dim, const std::vector*> in_grids, - std::vector >& out_levels_vector, - std::vector<_Tp>& out_coefs) { + std::vector >& out_levels_vector, std::vector<_Tp>& out_coefs) { std::vector<_Tp> tmp_coefs; std::vector > tmp_levels_vector; initCombiGrid(in_dim, tmp_levels_vector, tmp_coefs); @@ -40,8 +37,7 @@ void combigrid::CombiArbitraryScheme<_Tp>::re_initCombiGrid( // examine what vectors do we have in the in_grids vector.... // 1) first deactivate all existing grids - for (unsigned int i = 0; i < in_grids.size(); i++) - in_grids[i]->deactivateGrid(); + for (unsigned int i = 0; i < in_grids.size(); i++) in_grids[i]->deactivateGrid(); // 2) if the scheme attempts to create an already existing grid, change the // coeffs and activate it. @@ -51,9 +47,7 @@ void combigrid::CombiArbitraryScheme<_Tp>::re_initCombiGrid( while (j < tmp_levels_vector.size()) { // if the grid vector i's levels vector == temp_levels_vector[j] and the // coeffs are the same - if (in_grids[i]->getFGLevels() == tmp_levels_vector[j]) - - { + if (in_grids[i]->getFGLevels() == tmp_levels_vector[j]) { // if true leave the grid as activated..change its coefficient // and remove the record from the list of grids to be created. in_grids[i]->setCoef(tmp_coefs[j]); diff --git a/combigrid/src/sgpp/combigrid/combischeme/CombiArbitraryScheme.hpp b/combigrid/src/sgpp/combigrid/combischeme/CombiArbitraryScheme.hpp index 1f8a9d9b91..73aa3ed12e 100644 --- a/combigrid/src/sgpp/combigrid/combischeme/CombiArbitraryScheme.hpp +++ b/combigrid/src/sgpp/combigrid/combischeme/CombiArbitraryScheme.hpp @@ -1,9 +1,7 @@ -/* - * CombiArbitraryScheme_demo.hpp - * - * Created on: 29 Jun 2014 - * Author: kenny - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef COMBIARBITRARYSCHEME_HPP_ #define COMBIARBITRARYSCHEME_HPP_ @@ -11,6 +9,8 @@ #include #include +#include + namespace combigrid { /** Combischeme created with from an arbitrary active set of full grids. Missing * subgrids for the creation of a valid combi solution are automatically added. @@ -21,7 +21,7 @@ class CombiArbitraryScheme : public combigrid::AbstractCombiScheme<_Tp> { std::vector > _levels_vector; public: - CombiArbitraryScheme(std::vector > levels_vector); + explicit CombiArbitraryScheme(std::vector > levels_vector); /** * do nothing constructor @@ -50,8 +50,7 @@ class CombiArbitraryScheme : public combigrid::AbstractCombiScheme<_Tp> { * * */ - void initCombiGrid(int in_dim, - std::vector >& out_levels_vector, + void initCombiGrid(int in_dim, std::vector >& out_levels_vector, std::vector<_Tp>& out_coefs); /** @@ -76,8 +75,7 @@ class CombiArbitraryScheme : public combigrid::AbstractCombiScheme<_Tp> { * * */ - void re_initCombiGrid(int in_dim, - const std::vector*> in_grids, + void re_initCombiGrid(int in_dim, const std::vector*> in_grids, std::vector >& out_levels_vector, std::vector<_Tp>& out_coefs); @@ -90,9 +88,8 @@ class CombiArbitraryScheme : public combigrid::AbstractCombiScheme<_Tp> { * current combigrid- will be updated with the newly recomputed * coefficients * */ - void recomputeCoefficients(int in_dim, - std::vector*>& out_fgrids); + void recomputeCoefficients(int in_dim, std::vector*>& out_fgrids); }; -} +} // namespace combigrid #endif /* COMBIARBITRARYSCHEME_DEMO_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/combischeme/CombiS_CT.cpp b/combigrid/src/sgpp/combigrid/combischeme/CombiS_CT.cpp index 338f745b59..6d8f6efae9 100644 --- a/combigrid/src/sgpp/combigrid/combischeme/CombiS_CT.cpp +++ b/combigrid/src/sgpp/combigrid/combischeme/CombiS_CT.cpp @@ -1,24 +1,29 @@ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #include +#include + template -combigrid::CombiS_CT<_Tp>::CombiS_CT(std::vector levels, - int trunc_levels) { +combigrid::CombiS_CT<_Tp>::CombiS_CT(std::vector levels, int trunc_levels) { this->_levels = levels; unsigned int dim = (unsigned int)levels.size(); this->_levels_truncation.resize(dim, trunc_levels); } template -combigrid::CombiS_CT<_Tp>::CombiS_CT(std::vector levels, - std::vector trunc_levels) { +combigrid::CombiS_CT<_Tp>::CombiS_CT(std::vector levels, std::vector trunc_levels) { this->_levels = levels; this->_levels_truncation = trunc_levels; } template -void combigrid::CombiS_CT<_Tp>::initCombiGrid( - int in_dim, std::vector >& out_levels_vector, - std::vector<_Tp>& out_coefs) { +void combigrid::CombiS_CT<_Tp>::initCombiGrid(int in_dim, + std::vector >& out_levels_vector, + std::vector<_Tp>& out_coefs) { std::vector levels_tmp = this->_levels; // the rations for the dimension adaptive case std::vector ratio_(in_dim, 1.0); @@ -26,23 +31,21 @@ void combigrid::CombiS_CT<_Tp>::initCombiGrid( // trapezoidal ) for l_user = 0 (linear) std::vector l_user_ = this->_levels_truncation; // call the init function - applyScheme(in_dim, levels_tmp, ratio_, l_user_, out_levels_vector, - out_coefs); + applyScheme(in_dim, levels_tmp, ratio_, l_user_, out_levels_vector, out_coefs); } template -void combigrid::CombiS_CT<_Tp>::re_initCombiGrid( - int in_dim, const std::vector*> in_grids, - std::vector >& out_levels_vector, - std::vector<_Tp>& out_coefs) { +void combigrid::CombiS_CT<_Tp>::re_initCombiGrid(int in_dim, + const std::vector*> in_grids, + std::vector >& out_levels_vector, + std::vector<_Tp>& out_coefs) { std::vector > tmp_levels_vector; std::vector<_Tp> tmp_coefs; initCombiGrid(in_dim, tmp_levels_vector, tmp_coefs); // examine what vectors do we have in the in_grids vector.... // 1) first deactivate all existing grids - for (unsigned int i = 0; i < in_grids.size(); i++) - in_grids[i]->deactivateGrid(); + for (unsigned int i = 0; i < in_grids.size(); i++) in_grids[i]->deactivateGrid(); // 2) if the scheme attempts to create an already existing grid, change the // coeffs and activate it. @@ -52,9 +55,7 @@ void combigrid::CombiS_CT<_Tp>::re_initCombiGrid( while (j < tmp_levels_vector.size()) { // if the grid vector i's levels vector == temp_levels_vector[j] and the // coeffs are the same - if (in_grids[i]->getFGLevels() == tmp_levels_vector[j]) - - { + if (in_grids[i]->getFGLevels() == tmp_levels_vector[j]) { // if true leave the grid as activated..change its coefficient // and remove the record from the list of grids to be created. in_grids[i]->setCoef(tmp_coefs[j]); @@ -78,10 +79,7 @@ void combigrid::CombiS_CT<_Tp>::re_initCombiGrid( template void combigrid::CombiS_CT<_Tp>::recomputeCoefficients( int in_dim, std::vector*>& out_fgrids) { - { - std::cout - << " combiS_CT scheme -> recomputeCoefficients has been invoked \n"; - } + { std::cout << " combiS_CT scheme -> recomputeCoefficients has been invoked \n"; } } // do nothing? /** utility functions for the current implementation of the combination scheme @@ -89,21 +87,20 @@ void combigrid::CombiS_CT<_Tp>::recomputeCoefficients( template void combigrid::CombiS_CT<_Tp>::getTrapezoidsums( std::vector& v, size_t dim, int sum, std::vector& ratio_, - std::vector& l_user_, - std::vector >& out_levels_vector) { + std::vector& l_user_, std::vector >& out_levels_vector) { /* Takes recursively every possible combination of numbers which add up to sum * creating a linear boundary grid for each one * The levels of the full grids must be greater than l_user*/ // code from Aliz if (dim == 1) { - int tmp = int(sum / ratio_[v.size()]) + l_user_[v.size()]; + int tmp = static_cast(sum / ratio_[v.size()]) + l_user_[v.size()]; v.push_back(tmp); // add v to the level vectors out_levels_vector.push_back(v); v.pop_back(); } else { for (int i = 0; i <= sum; i++) { - int tmp = (int)(i / ratio_[v.size()]) + l_user_[v.size()]; + int tmp = static_cast(i / ratio_[v.size()]) + l_user_[v.size()]; v.push_back(tmp); getTrapezoidsums(v, dim - 1, sum - i, ratio_, l_user_, out_levels_vector); v.pop_back(); @@ -112,11 +109,11 @@ void combigrid::CombiS_CT<_Tp>::getTrapezoidsums( } template -void combigrid::CombiS_CT<_Tp>::applyScheme( - int in_dim, const std::vector& in_levels, - std::vector& in_ratio_, std::vector& in_l_user_, - std::vector >& out_levels_vector, - std::vector<_Tp>& out_coefs) { +void combigrid::CombiS_CT<_Tp>::applyScheme(int in_dim, const std::vector& in_levels, + std::vector& in_ratio_, + std::vector& in_l_user_, + std::vector >& out_levels_vector, + std::vector<_Tp>& out_coefs) { std::vector v(0); // the ratio for dimension adaptivity @@ -132,7 +129,7 @@ void combigrid::CombiS_CT<_Tp>::applyScheme( } for (int i = 0; i < in_dim; i++) { - in_ratio_[i] = (double)n / (double)in_levels[i]; + in_ratio_[i] = static_cast(n) / static_cast(in_levels[i]); } n = n - max; @@ -147,12 +144,12 @@ void combigrid::CombiS_CT<_Tp>::applyScheme( if (d % 2 != 0) combi = -combi; // call the recursive function to add the spaces - this->getTrapezoidsums(v, in_dim, n - d, in_ratio_, in_l_user_, - out_levels_vector); + this->getTrapezoidsums(v, in_dim, n - d, in_ratio_, in_l_user_, out_levels_vector); // add the coefficients - for (int i = oldsize; i < (int)out_levels_vector.size(); i++) + for (int i = oldsize; i < static_cast(out_levels_vector.size()); i++) { out_coefs.push_back(combi); + } } // remove the duplicated spaces -- > implemented in CombiSchemeBasis... diff --git a/combigrid/src/sgpp/combigrid/combischeme/CombiS_CT.hpp b/combigrid/src/sgpp/combigrid/combischeme/CombiS_CT.hpp index 99ef3c0a09..18f24494c4 100644 --- a/combigrid/src/sgpp/combigrid/combischeme/CombiS_CT.hpp +++ b/combigrid/src/sgpp/combigrid/combischeme/CombiS_CT.hpp @@ -1,30 +1,28 @@ -/* - * CombiS_CT_demo.hpp - * - * Created on: May 22, 2014 - * Author: petzko - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef COMBIS_CT_HPP_ #define COMBIS_CT_HPP_ #include +#include + namespace combigrid { template class CombiS_CT : public AbstractCombiScheme<_Tp> { public: - CombiS_CT(std::vector levels, int trunc_levels = 1); + explicit CombiS_CT(std::vector levels, int trunc_levels = 1); CombiS_CT(std::vector levels, std::vector trunc_levels); - void initCombiGrid(int in_dim, - std::vector >& out_levels_vector, + void initCombiGrid(int in_dim, std::vector >& out_levels_vector, std::vector<_Tp>& out_coefs); - void re_initCombiGrid(int in_dim, - const std::vector*> in_grids, + void re_initCombiGrid(int in_dim, const std::vector*> in_grids, std::vector >& out_levels_vector, std::vector<_Tp>& out_coefs); @@ -37,23 +35,21 @@ class CombiS_CT : public AbstractCombiScheme<_Tp> { * current combigrid- will be updated with the newly recomputed * coefficients * */ - void recomputeCoefficients(int in_dim, - std::vector*>& out_fgrids); + void recomputeCoefficients(int in_dim, std::vector*>& out_fgrids); ~CombiS_CT() {} private: /** utility functions for the current implementation of the combination scheme **/ - void getTrapezoidsums(std::vector& v, size_t dim, int sum, - std::vector& ratio_, std::vector& l_user_, + void getTrapezoidsums(std::vector& v, size_t dim, int sum, std::vector& ratio_, + std::vector& l_user_, std::vector >& out_levels_vector); - void applyScheme(int in_dim, const std::vector& in_levels, - std::vector& in_ratio_, std::vector& in_l_user_, - std::vector >& out_levels_vector, + void applyScheme(int in_dim, const std::vector& in_levels, std::vector& in_ratio_, + std::vector& in_l_user_, std::vector >& out_levels_vector, std::vector<_Tp>& out_coefs); }; -} +} // namespace combigrid #endif /* COMBIS_CT_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/combischeme/CombiTS_CT.cpp b/combigrid/src/sgpp/combigrid/combischeme/CombiTS_CT.cpp index 1a2a94c644..48eabacd75 100644 --- a/combigrid/src/sgpp/combigrid/combischeme/CombiTS_CT.cpp +++ b/combigrid/src/sgpp/combigrid/combischeme/CombiTS_CT.cpp @@ -1,17 +1,22 @@ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #include +#include + template -combigrid::CombiTS_CT<_Tp>::CombiTS_CT(std::vector minlevels, - std::vector maxlevels) { +combigrid::CombiTS_CT<_Tp>::CombiTS_CT(std::vector minlevels, std::vector maxlevels) { _levels_small = minlevels; this->_levels = maxlevels; this->_makeCombiInDimension.clear(); } template -combigrid::CombiTS_CT<_Tp>::CombiTS_CT( - const std::vector& in_levels, - const std::vector& makeCombiInDimension) { +combigrid::CombiTS_CT<_Tp>::CombiTS_CT(const std::vector& in_levels, + const std::vector& makeCombiInDimension) { // set the makeCombiIndimensions flag vector this->_makeCombiInDimension = makeCombiInDimension; // set the small levels vector to be 0.5*in_levels_vector @@ -38,9 +43,9 @@ combigrid::CombiTS_CT<_Tp>::CombiTS_CT(std::vector in_max_levels) { } template -void combigrid::CombiTS_CT<_Tp>::initCombiGrid( - int in_dim, std::vector >& out_levels_vector, - std::vector<_Tp>& out_coefs) { +void combigrid::CombiTS_CT<_Tp>::initCombiGrid(int in_dim, + std::vector >& out_levels_vector, + std::vector<_Tp>& out_coefs) { // initiate a duplicate // of the vectors with max and min levels values std::vector levels_big = this->_levels; @@ -67,9 +72,9 @@ void combigrid::CombiTS_CT<_Tp>::initCombiGrid( if (_makeCombiInDimension.size() != 0) { active_dim = _makeCombiInDimension; } else { - if (levels_small.size() > 0 && levels_big.size() > 0) - for (int i = 0; i < in_dim; i++) - active_dim[i] = (levels_small[i] != levels_big[i]); + if (levels_small.size() > 0 && levels_big.size() > 0) { + for (int i = 0; i < in_dim; i++) active_dim[i] = (levels_small[i] != levels_big[i]); + } } std::vector level_tmp; @@ -93,10 +98,10 @@ void combigrid::CombiTS_CT<_Tp>::initCombiGrid( } template -void combigrid::CombiTS_CT<_Tp>::re_initCombiGrid( - int in_dim, const std::vector*> in_grids, - std::vector >& out_levels_vector, - std::vector<_Tp>& out_coefs) { +void combigrid::CombiTS_CT<_Tp>::re_initCombiGrid(int in_dim, + const std::vector*> in_grids, + std::vector >& out_levels_vector, + std::vector<_Tp>& out_coefs) { std::vector > tmp_levels_vector; std::vector<_Tp> tmp_coefs; initCombiGrid(in_dim, tmp_levels_vector, tmp_coefs); @@ -104,8 +109,7 @@ void combigrid::CombiTS_CT<_Tp>::re_initCombiGrid( // examine what vectors do we have in the in_grids vector.... // 1) first deactivate all existing grids - for (unsigned int i = 0; i < in_grids.size(); i++) - in_grids[i]->deactivateGrid(); + for (unsigned int i = 0; i < in_grids.size(); i++) in_grids[i]->deactivateGrid(); // 2) if the scheme attempts to create an already existing grid, change the // coeffs and activate it. @@ -115,9 +119,7 @@ void combigrid::CombiTS_CT<_Tp>::re_initCombiGrid( while (j < tmp_levels_vector.size()) { // if the grid vector i's levels vector == temp_levels_vector[j] and the // coeffs are the same - if (in_grids[i]->getFGLevels() == tmp_levels_vector[j]) - - { + if (in_grids[i]->getFGLevels() == tmp_levels_vector[j]) { // if true leave the grid as activated..change its coefficient // and remove the record from the list of grids to be created. in_grids[i]->setCoef(tmp_coefs[j]); @@ -148,8 +150,7 @@ void combigrid::CombiTS_CT<_Tp>::re_initCombiGrid( template void combigrid::CombiTS_CT<_Tp>::recomputeCoefficients( int in_dim, std::vector*>& out_fgrids) { - std::cout - << " combiTS_CT scheme -> recomputeCoefficients has been invoked \n"; + std::cout << " combiTS_CT scheme -> recomputeCoefficients has been invoked \n"; } // action template class combigrid::CombiTS_CT; diff --git a/combigrid/src/sgpp/combigrid/combischeme/CombiTS_CT.hpp b/combigrid/src/sgpp/combigrid/combischeme/CombiTS_CT.hpp index b53ae65464..042d4e47d4 100644 --- a/combigrid/src/sgpp/combigrid/combischeme/CombiTS_CT.hpp +++ b/combigrid/src/sgpp/combigrid/combischeme/CombiTS_CT.hpp @@ -1,15 +1,15 @@ -/* - * CombiTS_CT.hpp - * - * Created on: 6 Jun 2014 - * Author: kenny - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef COMBITS_CT_HPP_ #define COMBITS_CT_HPP_ #include +#include + namespace combigrid { template @@ -37,14 +37,13 @@ class CombiTS_CT : public AbstractCombiScheme<_Tp> { * @param in_levels the level vector for the dimension adaptive case * @param makeCombiInDimension * */ - CombiTS_CT(const std::vector& in_levels, - const std::vector& makeCombiInDimension); + CombiTS_CT(const std::vector& in_levels, const std::vector& makeCombiInDimension); /** Simple constructor taking only the levels vector. * @param in_max_levels the level vector for the dimension adaptive case * */ - CombiTS_CT(std::vector in_max_levels); + explicit CombiTS_CT(std::vector in_max_levels); /** * Set which dimensions should the combischeme be applied to. Default is all @@ -81,8 +80,7 @@ class CombiTS_CT : public AbstractCombiScheme<_Tp> { * * */ - void initCombiGrid(int in_dim, - std::vector >& out_levels_vector, + void initCombiGrid(int in_dim, std::vector >& out_levels_vector, std::vector<_Tp>& out_coefs); /** @@ -106,8 +104,7 @@ class CombiTS_CT : public AbstractCombiScheme<_Tp> { *for each level... * * */ - void re_initCombiGrid(int in_dim, - const std::vector*> in_grids, + void re_initCombiGrid(int in_dim, const std::vector*> in_grids, std::vector >& out_levels_vector, std::vector<_Tp>& out_coefs); @@ -120,8 +117,7 @@ class CombiTS_CT : public AbstractCombiScheme<_Tp> { * current combigrid- will be updated with the newly recomputed * coefficients * */ - void recomputeCoefficients(int in_dim, - std::vector*>& out_fgrids); + void recomputeCoefficients(int in_dim, std::vector*>& out_fgrids); virtual ~CombiTS_CT() { // not strictly necessary since memory will automatically be freed once the @@ -132,6 +128,6 @@ class CombiTS_CT : public AbstractCombiScheme<_Tp> { _makeCombiInDimension.clear(); } }; -} +} // namespace combigrid #endif /* COMBITS_CT_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/domain/AbstractStretchingMaker.hpp b/combigrid/src/sgpp/combigrid/domain/AbstractStretchingMaker.hpp index 6c37d42853..e78788a0c4 100644 --- a/combigrid/src/sgpp/combigrid/domain/AbstractStretchingMaker.hpp +++ b/combigrid/src/sgpp/combigrid/domain/AbstractStretchingMaker.hpp @@ -1,9 +1,8 @@ -/* **************************************************************************** - * Copyright (C) 2011 Technische Universitaet Muenchen * - * This file is part of the SG++ project. For conditions of distribution and * - * use, please see the copyright notice at http://www5.in.tum.de/SGpp * - **************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #ifndef ABSTRACTSTRETCHINGMAKER_HPP_ #define ABSTRACTSTRETCHINGMAKER_HPP_ @@ -20,12 +19,7 @@ enum Stretching { EQUIDISTANT, CHEBYSHEV, LEGENDRE, BASU, UNKNOWN, ATAN, TAN }; * map the actual coordinates to the [-1;1] interval * */ -enum TRANSFORMATION_TYPE { - FINITE, - SEMI_INFINITE_NINF, - SEMI_INFINITE_PINF, - INFINITE -}; +enum TRANSFORMATION_TYPE { FINITE, SEMI_INFINITE_NINF, SEMI_INFINITE_PINF, INFINITE }; /** class to create stretching in 1D*/ class AbstractStretchingMaker { @@ -41,16 +35,14 @@ class AbstractStretchingMaker { * size of the interval and underlying tranformations. */ - virtual void get1DStretching(int level, double min, double max, - std::vector* stretching, + virtual void get1DStretching(int level, double min, double max, std::vector* stretching, std::vector* jacobian) const = 0; virtual ~AbstractStretchingMaker() {} virtual Stretching getStretchingType() const = 0; - double transforminterval(double min, double max, double point, - TRANSFORMATION_TYPE tp) const { + double transforminterval(double min, double max, double point, TRANSFORMATION_TYPE tp) const { double result = point; switch (tp) { @@ -82,8 +74,7 @@ class AbstractStretchingMaker { return result; } - double transformationJacobian(double min, double max, double pt, - TRANSFORMATION_TYPE type) const { + double transformationJacobian(double min, double max, double pt, TRANSFORMATION_TYPE type) const { double result = 1.0; // the if's are in order to avoid singularities diff --git a/combigrid/src/sgpp/combigrid/domain/CombiAtanSpecialStretching.cpp b/combigrid/src/sgpp/combigrid/domain/CombiAtanSpecialStretching.cpp index 419b36fcd9..c84b5c589b 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiAtanSpecialStretching.cpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiAtanSpecialStretching.cpp @@ -1,40 +1,38 @@ -/* **************************************************************************** -* Copyright (C) 2011 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include #include -void combigrid::AtanSpecialStretching::get1DStretching( - int level, double min, double max, std::vector* stretching, - std::vector* jacobian) const { +#include + +void combigrid::AtanSpecialStretching::get1DStretching(int level, double min, double max, + std::vector* stretching, + std::vector* jacobian) const { int nrPoints = combigrid::powerOfTwo[level] + 1; stretching->resize(nrPoints); std::vector tmpPoints(nrPoints); for (int ii = 0; ii < nrPoints; ii++) - tmpPoints[ii] = (double)(2 * ii - combigrid::powerOfTwo[level]) / - (double)(combigrid::powerOfTwo[level]); + tmpPoints[ii] = static_cast(2 * ii - combigrid::powerOfTwo[level]) / + static_cast(combigrid::powerOfTwo[level]); for (int ii = 0; ii < nrPoints; ii++) (*stretching)[ii] = std::pow(tmpPoints[ii], 5) + 0.1 * tmpPoints[ii]; // calculate grading - for (int ii = 0; ii < nrPoints; ii++) - (*stretching)[ii] = 3.0 * std::atan((*stretching)[ii]); + for (int ii = 0; ii < nrPoints; ii++) (*stretching)[ii] = 3.0 * std::atan((*stretching)[ii]); // do the scaling for (int ii = 0; ii < nrPoints; ii++) (*stretching)[ii] = - min + - (max - min) * 0.5 * (1 + ((*stretching)[ii] / (*stretching)[nrPoints - 1])); + min + (max - min) * 0.5 * (1 + ((*stretching)[ii] / (*stretching)[nrPoints - 1])); /*** * * TODO: initialize and populate the jacobian vector! * */ -} +} // namespace combigrid diff --git a/combigrid/src/sgpp/combigrid/domain/CombiAtanSpecialStretching.hpp b/combigrid/src/sgpp/combigrid/domain/CombiAtanSpecialStretching.hpp index 5a9f866f75..f37020351e 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiAtanSpecialStretching.hpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiAtanSpecialStretching.hpp @@ -1,15 +1,15 @@ -/* **************************************************************************** -* Copyright (C) 2011 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef COMBIATANSPECIALSTRETCHING_HPP_ #define COMBIATANSPECIALSTRETCHING_HPP_ #include +#include + namespace combigrid { /** Stretching formula with the following matlab formula:
@@ -27,12 +27,11 @@ class AtanSpecialStretching : public AbstractStretchingMaker { virtual ~AtanSpecialStretching() { ; } - void get1DStretching(int level, double min, double max, - std::vector* stretching, + void get1DStretching(int level, double min, double max, std::vector* stretching, std::vector* jacobian) const; Stretching getStretchingType() const { return ATAN; } }; -} +} // namespace combigrid #endif /* COMBIATANSPECIALSTRETCHING_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/domain/CombiBasuStretching.cpp b/combigrid/src/sgpp/combigrid/domain/CombiBasuStretching.cpp index dcb99f9167..226efef9e9 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiBasuStretching.cpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiBasuStretching.cpp @@ -1,16 +1,15 @@ -/* - * CombiBasuStretching.cpp - * - * Created on: 26 Sep 2014 - * Author: kenny - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include -#include -void combigrid::CombiBasuStretching::get1DStretching( - int level, double min, double max, std::vector* stretching, - std::vector* jacobian) const { +#include + +void combigrid::CombiBasuStretching::get1DStretching(int level, double min, double max, + std::vector* stretching, + std::vector* jacobian) const { int N = powerOfTwo[level]; // N is the number of subintervals... N+1 the // number of points! jacobian->clear(); diff --git a/combigrid/src/sgpp/combigrid/domain/CombiBasuStretching.hpp b/combigrid/src/sgpp/combigrid/domain/CombiBasuStretching.hpp index 8aa6014757..5dac8a9ab0 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiBasuStretching.hpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiBasuStretching.hpp @@ -1,13 +1,14 @@ -/* - * CombiBasiStretching.hpp - * - * Created on: 26 Sep 2014 - * Author: kenny - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef COMBIBASISTRETCHING_HPP_ #define COMBIBASISTRETCHING_HPP_ #include + +#include + /** * Implement a point stretching * @@ -37,12 +38,11 @@ class CombiBasuStretching : public AbstractStretchingMaker { * size of the interval and underlying tranformations. */ - void get1DStretching(int level, double min, double max, - std::vector* stretching, + void get1DStretching(int level, double min, double max, std::vector* stretching, std::vector* jacobian) const; Stretching getStretchingType() const { return BASU; } }; -} +} // namespace combigrid #endif /* COMBIBASISTRETCHING_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/domain/CombiChebyshevStretching.cpp b/combigrid/src/sgpp/combigrid/domain/CombiChebyshevStretching.cpp index afeb02c025..3239ccbad7 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiChebyshevStretching.cpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiChebyshevStretching.cpp @@ -1,12 +1,12 @@ -/* - * CombiChebyshevStretching.cpp - * - * Created on: 28 Jul 2014 - * Author: kenny - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include -#include +#include + +#include /** * Implements a simple coordinate transform : @@ -21,9 +21,9 @@ *beautifully as T_N(x) = cos(N*arcos(x)) **/ -void combigrid::CombiChebyshevStretching::get1DStretching( - int level, double min, double max, std::vector* stretching, - std::vector* jacobian) const { +void combigrid::CombiChebyshevStretching::get1DStretching(int level, double min, double max, + std::vector* stretching, + std::vector* jacobian) const { int nr_pts = powerOfTwo[level] + 1; // resize the stretching vector... stretching->resize(nr_pts); diff --git a/combigrid/src/sgpp/combigrid/domain/CombiChebyshevStretching.hpp b/combigrid/src/sgpp/combigrid/domain/CombiChebyshevStretching.hpp index 76809f36c0..7905f8efa3 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiChebyshevStretching.hpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiChebyshevStretching.hpp @@ -1,9 +1,7 @@ -/* **************************************************************************** -* Copyright (C) 2015 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Petar Tzenov +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef COMBICHEBYSHEVSTRETCHING_HPP_ #define COMBICHEBYSHEVSTRETCHING_HPP_ @@ -43,8 +41,7 @@ class CombiChebyshevStretching : public AbstractStretchingMaker { * size of the interval and underlying tranformations. * */ - void get1DStretching(int level, double min, double max, - std::vector* stretching, + void get1DStretching(int level, double min, double max, std::vector* stretching, std::vector* jacobian) const; Stretching getStretchingType() const { return CHEBYSHEV; } diff --git a/combigrid/src/sgpp/combigrid/domain/CombiDomain1D.cpp b/combigrid/src/sgpp/combigrid/domain/CombiDomain1D.cpp index 008d5abb9f..bb2b85daf8 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiDomain1D.cpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiDomain1D.cpp @@ -1,10 +1,8 @@ -/* **************************************************************************** - * Copyright (C) 2011 Technische Universitaet Muenchen * - * This file is part of the SG++ project. For conditions of distribution and * - * use, please see the copyright notice at http://www5.in.tum.de/SGpp * - **************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) -// @author Christoph Kowitz (kowitz@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #include #include #include @@ -35,8 +33,7 @@ combigrid::Domain1D::Domain1D(const Domain1D& domain) { _jacobian = domain.axisJacobian(); } -void combigrid::Domain1D::transformRealToUnit(double coordReal, - double& coordUnit, int level_in, +void combigrid::Domain1D::transformRealToUnit(double coordReal, double& coordUnit, int level_in, bool noBoundary) const { // int verb = 6; if (_isStretched) { @@ -58,11 +55,10 @@ void combigrid::Domain1D::transformRealToUnit(double coordReal, } // startInd should be now at the beginning of the cell - intersec = (_stretching[endInd] - coordReal) / - (_stretching[endInd] - _stretching[startInd]); + intersec = (_stretching[endInd] - coordReal) / (_stretching[endInd] - _stretching[startInd]); // - make the transformation to the unit domain -> unitCoords coordUnit = - (((double)endInd) * combigrid::oneOverPowOfTwo[level_diff] - intersec) / + ((static_cast(endInd)) * combigrid::oneOverPowOfTwo[level_diff] - intersec) / combigrid::powerOfTwo[_level - level_diff]; if (noBoundary) { @@ -72,17 +68,16 @@ void combigrid::Domain1D::transformRealToUnit(double coordReal, if (startInd == 0) { double h = _stretching[endInd + offs] - _stretching[startInd + offs]; intersec = (_stretching[endInd] - coordReal) / h; - coordUnit = (((double)endInd) * combigrid::oneOverPowOfTwo[level_diff] - - intersec) / - combigrid::powerOfTwo[_level - level_diff]; + coordUnit = + ((static_cast(endInd)) * combigrid::oneOverPowOfTwo[level_diff] - intersec) / + combigrid::powerOfTwo[_level - level_diff]; // COMBIGRID_OUT_LEVEL3( verb , " combigrid::Domain1D::tran 1"); } - if (endInd == (int)_stretching.size() - 1) { + if (endInd == static_cast(_stretching.size()) - 1) { double h = _stretching[startInd] - _stretching[startInd - offs]; intersec = (coordReal - _stretching[startInd]) / h; - coordUnit = (((double)(endInd - offs)) * - combigrid::oneOverPowOfTwo[level_diff] + + coordUnit = ((static_cast(endInd - offs)) * combigrid::oneOverPowOfTwo[level_diff] + intersec) / combigrid::powerOfTwo[_level - level_diff]; // COMBIGRID_OUT_LEVEL3( verb , " combigrid::Domain1D::tran 2 , @@ -107,20 +102,19 @@ void combigrid::Domain1D::transformRealToUnit(double coordReal, } } -void combigrid::Domain1D::transformUnitToReal(int level, int index, - double& realCoord) const { +void combigrid::Domain1D::transformUnitToReal(int level, int index, double& realCoord) const { if (_isStretched) { // get the stretched index int level_diff = (_level < level) ? 0 : _level - level; realCoord = _stretching[index * combigrid::powerOfTwo[level_diff]]; } else { // no stretching , just simple scaling - realCoord = _min + (_max - _min) * ((double)index) * oneOverPowOfTwo[level]; + realCoord = _min + (_max - _min) * (static_cast(index)) * oneOverPowOfTwo[level]; } } -void combigrid::Domain1D::findEntry(double coordReal, int level_in, - int& startIndex, double& intersect) const { +void combigrid::Domain1D::findEntry(double coordReal, int level_in, int& startIndex, + double& intersect) const { if (_isStretched) { int startInd = 0, mid = 0; int endInd = static_cast(_stretching.size()) - 1; @@ -147,19 +141,18 @@ void combigrid::Domain1D::findEntry(double coordReal, int level_in, } else { // for the non-stretched case double unitC = (coordReal - _min) / (_max - _min); - startIndex = static_cast( - ::floor((double)combigrid::powerOfTwo[level_in] * unitC)); + startIndex = + static_cast(::floor(static_cast(combigrid::powerOfTwo[level_in]) * unitC)); startIndex = (startIndex < 0) ? 0 : startIndex; startIndex = (startIndex >= combigrid::powerOfTwo[level_in] - 1) ? combigrid::powerOfTwo[level_in] - 1 : startIndex; - intersect = (unitC * (double)combigrid::powerOfTwo[level_in] - - (double)(startIndex)); + intersect = (unitC * static_cast(combigrid::powerOfTwo[level_in]) - + static_cast(startIndex)); } } -void combigrid::Domain1D::getMeshWidth(int index, int level_in, double& h0, - double& h1) const { +void combigrid::Domain1D::getMeshWidth(int index, int level_in, double& h0, double& h1) const { if (_isStretched) { int level_diff = (_level < level_in) ? 0 : _level - level_in; // index checking should be done in the debug mode @@ -168,6 +161,6 @@ void combigrid::Domain1D::getMeshWidth(int index, int level_in, double& h0, h1 = _stretching[(index + 1) * combigrid::powerOfTwo[level_diff]] - _stretching[index * combigrid::powerOfTwo[level_diff]]; } else { - h1 = h0 = (_max - _min) * (1 / (double)combigrid::powerOfTwo[level_in]); + h1 = h0 = (_max - _min) * (1 / static_cast(combigrid::powerOfTwo[level_in])); } } diff --git a/combigrid/src/sgpp/combigrid/domain/CombiDomain1D.hpp b/combigrid/src/sgpp/combigrid/domain/CombiDomain1D.hpp index 267617d9c8..2a0233fac3 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiDomain1D.hpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiDomain1D.hpp @@ -1,15 +1,16 @@ -/* **************************************************************************** - * Copyright (C) 2011 Technische Universitaet Muenchen * - * This file is part of the SG++ project. For conditions of distribution and * - * use, please see the copyright notice at http://www5.in.tum.de/SGpp * - **************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #ifndef COMBIDOMAIN1D_HPP_ #define COMBIDOMAIN1D_HPP_ #include #include -#include "../utils/combigrid_utils.hpp" +#include + +#include namespace combigrid { @@ -17,8 +18,7 @@ namespace combigrid { class Domain1D { public: /** */ - Domain1D(int level, double min, double max, - AbstractStretchingMaker& stretching); + Domain1D(int level, double min, double max, AbstractStretchingMaker& stretching); /** * copy constructor! @@ -55,8 +55,8 @@ class Domain1D { * @param coordUnit coordinates in the unit cube * @param level_in level of the resolution required * @param noBoundary make extrapolation for the boundary cells*/ - void transformRealToUnit(double coordReal, double& coordUnit, - int level_in = 0, bool noBoundary = false) const; + void transformRealToUnit(double coordReal, double& coordUnit, int level_in = 0, + bool noBoundary = false) const; /** transform from unit index to real coordinates * @param level input level @@ -70,8 +70,7 @@ class Domain1D { * @param startIndex the left index of the cell * @param intersect the intersection of the cell */ - void findEntry(double coordReal, int level_in, int& startIndex, - double& intersect) const; + void findEntry(double coordReal, int level_in, int& startIndex, double& intersect) const; /** returns the mesh width /scaling * @param index point index @@ -98,6 +97,6 @@ class Domain1D { std::vector _jacobian; Stretching _stretching_type; }; -} +} // namespace combigrid #endif /* COMBIDOMAIN1D_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/domain/CombiEquidistantStretching.cpp b/combigrid/src/sgpp/combigrid/domain/CombiEquidistantStretching.cpp index 90e04ae46d..475658c618 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiEquidistantStretching.cpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiEquidistantStretching.cpp @@ -1,20 +1,21 @@ -/* - * CombiEquidistantStretching.cpp - * - * Created on: 15 Sep 2014 - * Author: kenny - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #include +#include + /** * * * simple 1D equidistant grid on the interval (min;max) **/ -void combigrid::CombiEquidistantStretching::get1DStretching( - int level, double min, double max, std::vector* stretching, - std::vector* jacobian) const { +void combigrid::CombiEquidistantStretching::get1DStretching(int level, double min, double max, + std::vector* stretching, + std::vector* jacobian) const { int nr_pts = powerOfTwo[level] + 1; // resize the stretching vector... stretching->resize(nr_pts); @@ -34,7 +35,7 @@ void combigrid::CombiEquidistantStretching::get1DStretching( if (min == n_INF && max == p_INF) type = INFINITE; - double dt = (2.0) / double(nr_pts - 1); + double dt = (2.0) / static_cast(nr_pts - 1); // notice that dt is the spacing on the [-1;1] interval... // (*stretching)[0] = min; diff --git a/combigrid/src/sgpp/combigrid/domain/CombiEquidistantStretching.hpp b/combigrid/src/sgpp/combigrid/domain/CombiEquidistantStretching.hpp index 484cbde17c..c3118f8233 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiEquidistantStretching.hpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiEquidistantStretching.hpp @@ -1,21 +1,21 @@ -/* - * CombiEquidistantStretching.hpp - * - * Created on: 15 Sep 2014 - * Author: kenny - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef COMBIEQUIDISTANTSTRETCHING_HPP_ #define COMBIEQUIDISTANTSTRETCHING_HPP_ -/* +/** * * Create an equidistant grid.. * * - */ + **/ #include +#include + namespace combigrid { class CombiEquidistantStretching : public AbstractStretchingMaker { @@ -25,21 +25,21 @@ class CombiEquidistantStretching : public AbstractStretchingMaker { ~CombiEquidistantStretching() {} /** - * - * @param level - integer specifying the current grid level. the - * corresponding nr of points is 2^level + 1 + * @param level - integer specifying the current grid level . the + *corresponding nr of points is 2^level + 1 * @param min - the left boundary of the interval * @param max - the right boundary of the interval - * @param stretching - the output vector of pre-computed grid points - * @param jacobian - the evaluated jacobian at all points of the stretching, - * taking into consideration size of the interval and underlying tranformations + * @param stretching - the output vector of pre-computed grid points... + * @param jacobian - the evaluated jacobian at all points of the stretching , + *taking into consideration + * size of the interval and underlying tranformations. + * */ - void get1DStretching(int level, double min, double max, - std::vector* stretching, + void get1DStretching(int level, double min, double max, std::vector* stretching, std::vector* jacobian) const; Stretching getStretchingType() const { return EQUIDISTANT; } }; -} +} // namespace combigrid #endif /* COMBIEQUIDISTANTSTRETCHING_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/domain/CombiGridDomain.cpp b/combigrid/src/sgpp/combigrid/domain/CombiGridDomain.cpp index 22b338f342..87a4b07b03 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiGridDomain.cpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiGridDomain.cpp @@ -1,15 +1,15 @@ -/* **************************************************************************** - * Copyright (C) 2011 Technische Universitaet Muenchen * - * This file is part of the SG++ project. For conditions of distribution and * - * use, please see the copyright notice at http://www5.in.tum.de/SGpp * - **************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #include -combigrid::GridDomain::GridDomain( - int dim, const std::vector& levels, const std::vector& min, - const std::vector& max, - combigrid::AbstractStretchingMaker& stretchingMaker) { +#include + +combigrid::GridDomain::GridDomain(int dim, const std::vector& levels, + const std::vector& min, const std::vector& max, + combigrid::AbstractStretchingMaker& stretchingMaker) { dim_ = dim; _stretching_type = UNKNOWN; _min = min; @@ -17,17 +17,15 @@ combigrid::GridDomain::GridDomain( // add for each dimension for (int d = 0; d < dim_; d++) { - _axisDomains.push_back( - combigrid::Domain1D(levels[d], _min[d], _max[d], stretchingMaker)); + _axisDomains.push_back(combigrid::Domain1D(levels[d], _min[d], _max[d], stretchingMaker)); } _stretching_type = stretchingMaker.getStretchingType(); } -combigrid::GridDomain::GridDomain( - int dim, const std::vector& levels, const std::vector& min, - const std::vector& max, - std::vector stretchingMaker) { +combigrid::GridDomain::GridDomain(int dim, const std::vector& levels, + const std::vector& min, const std::vector& max, + std::vector stretchingMaker) { dim_ = dim; _stretching_type = UNKNOWN; _min = min; @@ -35,8 +33,7 @@ combigrid::GridDomain::GridDomain( // add for each dimension for (int d = 0; d < dim_; d++) { - _axisDomains.push_back( - combigrid::Domain1D(levels[d], _min[d], _max[d], *stretchingMaker[d])); + _axisDomains.push_back(combigrid::Domain1D(levels[d], _min[d], _max[d], *stretchingMaker[d])); } _stretching_type = UNKNOWN; @@ -50,15 +47,14 @@ combigrid::GridDomain::GridDomain(const GridDomain& domain) { _min = domain.getMin(); for (int d = 0; d < dim_; d++) { - Domain1D newDomain( - domain.get1DDomain(d)); // invoke the copy constructor of + Domain1D newDomain(domain.get1DDomain(d)); // invoke the copy constructor of _axisDomains.push_back(newDomain); } } -void combigrid::GridDomain::transformRealToUnit( - std::vector& coords, const std::vector& levels_in, - const std::vector& boundaryFlag) const { +void combigrid::GridDomain::transformRealToUnit(std::vector& coords, + const std::vector& levels_in, + const std::vector& boundaryFlag) const { // for each dimension make the transformation // int verb = 6; double tmp = 0.0; @@ -66,8 +62,7 @@ void combigrid::GridDomain::transformRealToUnit( // COMBIGRID_OUT_LEVEL3( verb , " combigrid::GridDomain::transformRealToUnit() // "); for (int d = 0; d < dim_; d++) { - _axisDomains[d].transformRealToUnit(coords[d], tmp, levels_in[d], - boundaryFlag[d]); + _axisDomains[d].transformRealToUnit(coords[d], tmp, levels_in[d], boundaryFlag[d]); coords[d] = tmp; } } @@ -76,8 +71,7 @@ void combigrid::GridDomain::printDomain() { std::cout << "------------------" << std::endl; for (int d = 0; d < dim_; d++) { - std::cout << _axisDomains[d].getMinDomain() << "\t" - << _axisDomains[d].getMaxDomain() << "\t" + std::cout << _axisDomains[d].getMinDomain() << "\t" << _axisDomains[d].getMaxDomain() << "\t" << _axisDomains[d].isAxisScaled() << std::endl; } diff --git a/combigrid/src/sgpp/combigrid/domain/CombiGridDomain.hpp b/combigrid/src/sgpp/combigrid/domain/CombiGridDomain.hpp index 82b851832f..7375b61e8f 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiGridDomain.hpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiGridDomain.hpp @@ -1,15 +1,16 @@ -/* **************************************************************************** - * Copyright (C) 2011 Technische Universitaet Muenchen * - * This file is part of the SG++ project. For conditions of distribution and * - * use, please see the copyright notice at http://www5.in.tum.de/SGpp * - **************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #ifndef COMBIGRIDDOMAIN_HPP_ #define COMBIGRIDDOMAIN_HPP_ #include #include -#include "../utils/combigrid_utils.hpp" +#include + +#include namespace combigrid { @@ -17,12 +18,11 @@ namespace combigrid { class GridDomain { public: /** Constructor for homogeneously stretched griddomain*/ - GridDomain(int dim, const std::vector& levels, - const std::vector& min, const std::vector& max, - AbstractStretchingMaker& stretchingMaker); + GridDomain(int dim, const std::vector& levels, const std::vector& min, + const std::vector& max, AbstractStretchingMaker& stretchingMaker); /** constructor for heterogeneously stretched griddomain*/ - GridDomain(int dim, const std::vector& levels, - const std::vector& min, const std::vector& max, + GridDomain(int dim, const std::vector& levels, const std::vector& min, + const std::vector& max, std::vector stretchingMakers); /* copy constructor*/ @@ -33,13 +33,12 @@ class GridDomain { */ virtual ~GridDomain() { ; } - int getDim() const { return (int)_axisDomains.size(); } + int getDim() const { return static_cast(_axisDomains.size()); } /** transform from real coordinate into unit coordinates * @param coords [IN/OUT] * @param levels_in [IN] the required levels * @param boundaryFlag [IN] for each dimensions if there are boundary points*/ - void transformRealToUnit(std::vector& coords, - const std::vector& levels_in, + void transformRealToUnit(std::vector& coords, const std::vector& levels_in, const std::vector& boundaryFlag) const; /** return 1D axis, can be used for back transformation for each dimension @@ -70,6 +69,6 @@ class GridDomain { std::vector _min; std::vector _max; }; -} +} // namespace combigrid #endif /* COMBIGRIDDOMAIN_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/domain/CombiLegendreStretching.cpp b/combigrid/src/sgpp/combigrid/domain/CombiLegendreStretching.cpp index 31e047f026..f1030eaaea 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiLegendreStretching.cpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiLegendreStretching.cpp @@ -1,15 +1,15 @@ -/* - * CombiLegendreStretching.cpp - * - * Created on: 21 Aug 2014 - * Author: kenny - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include -void combigrid::CombiLegendreStretching::get1DStretching( - int level, double min, double max, std::vector* stretching, - std::vector* jacobian) const { +#include + +void combigrid::CombiLegendreStretching::get1DStretching(int level, double min, double max, + std::vector* stretching, + std::vector* jacobian) const { stretching->clear(); jacobian->clear(); @@ -31,8 +31,7 @@ void combigrid::CombiLegendreStretching::get1DStretching( for (int d = 1; d < nr_pts - 1; d++) { stretching->push_back(transforminterval(min, max, abscissas[d], type)); - jacobian->push_back( - transformationJacobian(min, max, abscissas[d], type)); + jacobian->push_back(transformationJacobian(min, max, abscissas[d], type)); } stretching->push_back(max); @@ -43,16 +42,15 @@ void combigrid::CombiLegendreStretching::get1DStretching( case 2: { int nr_pts = 5; - double abscissas[5] = {-1.0, -0.77459666924148337704E+00, 0.0E+00, - 0.77459666924148337704E+00, 1.0}; + double abscissas[5] = {-1.0, -0.77459666924148337704E+00, 0.0E+00, 0.77459666924148337704E+00, + 1.0}; stretching->push_back(min); jacobian->push_back(transformationJacobian(min, max, -1.0, type)); for (int d = 1; d < nr_pts - 1; d++) { stretching->push_back(transforminterval(min, max, abscissas[d], type)); - jacobian->push_back( - transformationJacobian(min, max, abscissas[d], type)); + jacobian->push_back(transformationJacobian(min, max, abscissas[d], type)); } stretching->push_back(max); @@ -63,20 +61,22 @@ void combigrid::CombiLegendreStretching::get1DStretching( case 3: { int nr_pts = 9; - double abscissas[9] = { - -1.0, -0.96049126870802028342E+00, - -0.77459666924148337704E+00, -0.43424374934680255800E+00, - 0.0E+00, 0.43424374934680255800E+00, - 0.77459666924148337704E+00, 0.96049126870802028342E+00, - 1.0}; + double abscissas[9] = {-1.0, + -0.96049126870802028342E+00, + -0.77459666924148337704E+00, + -0.43424374934680255800E+00, + 0.0E+00, + 0.43424374934680255800E+00, + 0.77459666924148337704E+00, + 0.96049126870802028342E+00, + 1.0}; stretching->push_back(min); jacobian->push_back(transformationJacobian(min, max, -1.0, type)); for (int d = 1; d < nr_pts - 1; d++) { stretching->push_back(transforminterval(min, max, abscissas[d], type)); - jacobian->push_back( - transformationJacobian(min, max, abscissas[d], type)); + jacobian->push_back(transformationJacobian(min, max, abscissas[d], type)); } stretching->push_back(max); @@ -87,24 +87,30 @@ void combigrid::CombiLegendreStretching::get1DStretching( case 4: { int nr_pts = 17; - double abscissas[17] = { - -1.0, -0.99383196321275502221E+00, - -0.96049126870802028342E+00, -0.88845923287225699889E+00, - -0.77459666924148337704E+00, -0.62110294673722640294E+00, - -0.43424374934680255800E+00, -0.22338668642896688163E+00, - 0.0E+00, 0.22338668642896688163E+00, - 0.43424374934680255800E+00, 0.62110294673722640294E+00, - 0.77459666924148337704E+00, 0.88845923287225699889E+00, - 0.96049126870802028342E+00, 0.99383196321275502221E+00, - 1.0}; + double abscissas[17] = {-1.0, + -0.99383196321275502221E+00, + -0.96049126870802028342E+00, + -0.88845923287225699889E+00, + -0.77459666924148337704E+00, + -0.62110294673722640294E+00, + -0.43424374934680255800E+00, + -0.22338668642896688163E+00, + 0.0E+00, + 0.22338668642896688163E+00, + 0.43424374934680255800E+00, + 0.62110294673722640294E+00, + 0.77459666924148337704E+00, + 0.88845923287225699889E+00, + 0.96049126870802028342E+00, + 0.99383196321275502221E+00, + 1.0}; stretching->push_back(min); jacobian->push_back(transformationJacobian(min, max, -1.0, type)); for (int d = 1; d < nr_pts - 1; d++) { stretching->push_back(transforminterval(min, max, abscissas[d], type)); - jacobian->push_back( - transformationJacobian(min, max, abscissas[d], type)); + jacobian->push_back(transformationJacobian(min, max, abscissas[d], type)); } stretching->push_back(max); @@ -115,32 +121,46 @@ void combigrid::CombiLegendreStretching::get1DStretching( case 5: { int nr_pts = 33; - double abscissas[33] = { - -1.0, -0.99909812496766759766E+00, - -0.99383196321275502221E+00, -0.98153114955374010687E+00, - -0.96049126870802028342E+00, -0.92965485742974005667E+00, - -0.88845923287225699889E+00, -0.83672593816886873550E+00, - -0.77459666924148337704E+00, -0.70249620649152707861E+00, - -0.62110294673722640294E+00, -0.53131974364437562397E+00, - -0.43424374934680255800E+00, -0.33113539325797683309E+00, - -0.22338668642896688163E+00, -0.11248894313318662575E+00, - 0.0E+00, 0.11248894313318662575E+00, - 0.22338668642896688163E+00, 0.33113539325797683309E+00, - 0.43424374934680255800E+00, 0.53131974364437562397E+00, - 0.62110294673722640294E+00, 0.70249620649152707861E+00, - 0.77459666924148337704E+00, 0.83672593816886873550E+00, - 0.88845923287225699889E+00, 0.92965485742974005667E+00, - 0.96049126870802028342E+00, 0.98153114955374010687E+00, - 0.99383196321275502221E+00, 0.99909812496766759766E+00, - 1.0}; + double abscissas[33] = {-1.0, + -0.99909812496766759766E+00, + -0.99383196321275502221E+00, + -0.98153114955374010687E+00, + -0.96049126870802028342E+00, + -0.92965485742974005667E+00, + -0.88845923287225699889E+00, + -0.83672593816886873550E+00, + -0.77459666924148337704E+00, + -0.70249620649152707861E+00, + -0.62110294673722640294E+00, + -0.53131974364437562397E+00, + -0.43424374934680255800E+00, + -0.33113539325797683309E+00, + -0.22338668642896688163E+00, + -0.11248894313318662575E+00, + 0.0E+00, + 0.11248894313318662575E+00, + 0.22338668642896688163E+00, + 0.33113539325797683309E+00, + 0.43424374934680255800E+00, + 0.53131974364437562397E+00, + 0.62110294673722640294E+00, + 0.70249620649152707861E+00, + 0.77459666924148337704E+00, + 0.83672593816886873550E+00, + 0.88845923287225699889E+00, + 0.92965485742974005667E+00, + 0.96049126870802028342E+00, + 0.98153114955374010687E+00, + 0.99383196321275502221E+00, + 0.99909812496766759766E+00, + 1.0}; stretching->push_back(min); jacobian->push_back(transformationJacobian(min, max, -1.0, type)); for (int d = 1; d < nr_pts - 1; d++) { stretching->push_back(transforminterval(min, max, abscissas[d], type)); - jacobian->push_back( - transformationJacobian(min, max, abscissas[d], type)); + jacobian->push_back(transformationJacobian(min, max, abscissas[d], type)); } stretching->push_back(max); @@ -151,48 +171,78 @@ void combigrid::CombiLegendreStretching::get1DStretching( case 6: { int nr_pts = 65; - double abscissas[65] = { - -1.0, -0.99987288812035761194E+00, - -0.99909812496766759766E+00, -0.99720625937222195908E+00, - -0.99383196321275502221E+00, -0.98868475754742947994E+00, - -0.98153114955374010687E+00, -0.97218287474858179658E+00, - -0.96049126870802028342E+00, -0.94634285837340290515E+00, - -0.92965485742974005667E+00, -0.91037115695700429250E+00, - -0.88845923287225699889E+00, -0.86390793819369047715E+00, - -0.83672593816886873550E+00, -0.80694053195021761186E+00, - -0.77459666924148337704E+00, -0.73975604435269475868E+00, - -0.70249620649152707861E+00, -0.66290966002478059546E+00, - -0.62110294673722640294E+00, -0.57719571005204581484E+00, - -0.53131974364437562397E+00, -0.48361802694584102756E+00, - -0.43424374934680255800E+00, -0.38335932419873034692E+00, - -0.33113539325797683309E+00, -0.27774982202182431507E+00, - -0.22338668642896688163E+00, -0.16823525155220746498E+00, - -0.11248894313318662575E+00, -0.056344313046592789972E+00, - 0.0E+00, 0.056344313046592789972E+00, - 0.11248894313318662575E+00, 0.16823525155220746498E+00, - 0.22338668642896688163E+00, 0.27774982202182431507E+00, - 0.33113539325797683309E+00, 0.38335932419873034692E+00, - 0.43424374934680255800E+00, 0.48361802694584102756E+00, - 0.53131974364437562397E+00, 0.57719571005204581484E+00, - 0.62110294673722640294E+00, 0.66290966002478059546E+00, - 0.70249620649152707861E+00, 0.73975604435269475868E+00, - 0.77459666924148337704E+00, 0.80694053195021761186E+00, - 0.83672593816886873550E+00, 0.86390793819369047715E+00, - 0.88845923287225699889E+00, 0.91037115695700429250E+00, - 0.92965485742974005667E+00, 0.94634285837340290515E+00, - 0.96049126870802028342E+00, 0.97218287474858179658E+00, - 0.98153114955374010687E+00, 0.98868475754742947994E+00, - 0.99383196321275502221E+00, 0.99720625937222195908E+00, - 0.99909812496766759766E+00, 0.99987288812035761194E+00, - +1.0}; + double abscissas[65] = {-1.0, + -0.99987288812035761194E+00, + -0.99909812496766759766E+00, + -0.99720625937222195908E+00, + -0.99383196321275502221E+00, + -0.98868475754742947994E+00, + -0.98153114955374010687E+00, + -0.97218287474858179658E+00, + -0.96049126870802028342E+00, + -0.94634285837340290515E+00, + -0.92965485742974005667E+00, + -0.91037115695700429250E+00, + -0.88845923287225699889E+00, + -0.86390793819369047715E+00, + -0.83672593816886873550E+00, + -0.80694053195021761186E+00, + -0.77459666924148337704E+00, + -0.73975604435269475868E+00, + -0.70249620649152707861E+00, + -0.66290966002478059546E+00, + -0.62110294673722640294E+00, + -0.57719571005204581484E+00, + -0.53131974364437562397E+00, + -0.48361802694584102756E+00, + -0.43424374934680255800E+00, + -0.38335932419873034692E+00, + -0.33113539325797683309E+00, + -0.27774982202182431507E+00, + -0.22338668642896688163E+00, + -0.16823525155220746498E+00, + -0.11248894313318662575E+00, + -0.056344313046592789972E+00, + 0.0E+00, + 0.056344313046592789972E+00, + 0.11248894313318662575E+00, + 0.16823525155220746498E+00, + 0.22338668642896688163E+00, + 0.27774982202182431507E+00, + 0.33113539325797683309E+00, + 0.38335932419873034692E+00, + 0.43424374934680255800E+00, + 0.48361802694584102756E+00, + 0.53131974364437562397E+00, + 0.57719571005204581484E+00, + 0.62110294673722640294E+00, + 0.66290966002478059546E+00, + 0.70249620649152707861E+00, + 0.73975604435269475868E+00, + 0.77459666924148337704E+00, + 0.80694053195021761186E+00, + 0.83672593816886873550E+00, + 0.86390793819369047715E+00, + 0.88845923287225699889E+00, + 0.91037115695700429250E+00, + 0.92965485742974005667E+00, + 0.94634285837340290515E+00, + 0.96049126870802028342E+00, + 0.97218287474858179658E+00, + 0.98153114955374010687E+00, + 0.98868475754742947994E+00, + 0.99383196321275502221E+00, + 0.99720625937222195908E+00, + 0.99909812496766759766E+00, + 0.99987288812035761194E+00, + +1.0}; stretching->push_back(min); jacobian->push_back(transformationJacobian(min, max, -1.0, type)); for (int d = 1; d < nr_pts - 1; d++) { stretching->push_back(transforminterval(min, max, abscissas[d], type)); - jacobian->push_back( - transformationJacobian(min, max, abscissas[d], type)); + jacobian->push_back(transformationJacobian(min, max, abscissas[d], type)); } stretching->push_back(max); @@ -202,79 +252,141 @@ void combigrid::CombiLegendreStretching::get1DStretching( case 7: { int nr_pts = 129; - double abscissas[129] = { - -1.0, -0.99998243035489159858E+00, - -0.99987288812035761194E+00, -0.99959879967191068325E+00, - -0.99909812496766759766E+00, -0.99831663531840739253E+00, - -0.99720625937222195908E+00, -0.99572410469840718851E+00, - -0.99383196321275502221E+00, -0.99149572117810613240E+00, - -0.98868475754742947994E+00, -0.98537149959852037111E+00, - -0.98153114955374010687E+00, -0.97714151463970571416E+00, - -0.97218287474858179658E+00, -0.96663785155841656709E+00, - -0.96049126870802028342E+00, -0.95373000642576113641E+00, - -0.94634285837340290515E+00, -0.93832039777959288365E+00, - -0.92965485742974005667E+00, -0.92034002547001242073E+00, - -0.91037115695700429250E+00, -0.89974489977694003664E+00, - -0.88845923287225699889E+00, -0.87651341448470526974E+00, - -0.86390793819369047715E+00, -0.85064449476835027976E+00, - -0.83672593816886873550E+00, -0.82215625436498040737E+00, - -0.80694053195021761186E+00, -0.79108493379984836143E+00, - -0.77459666924148337704E+00, -0.75748396638051363793E+00, - -0.73975604435269475868E+00, -0.72142308537009891548E+00, - -0.70249620649152707861E+00, -0.68298743109107922809E+00, - -0.66290966002478059546E+00, -0.64227664250975951377E+00, - -0.62110294673722640294E+00, -0.59940393024224289297E+00, - -0.57719571005204581484E+00, -0.55449513263193254887E+00, - -0.53131974364437562397E+00, -0.50768775753371660215E+00, - -0.48361802694584102756E+00, -0.45913001198983233287E+00, - -0.43424374934680255800E+00, -0.40897982122988867241E+00, - -0.38335932419873034692E+00, -0.35740383783153215238E+00, - -0.33113539325797683309E+00, -0.30457644155671404334E+00, - -0.27774982202182431507E+00, -0.25067873030348317661E+00, - -0.22338668642896688163E+00, -0.19589750271110015392E+00, - -0.16823525155220746498E+00, -0.14042423315256017459E+00, - -0.11248894313318662575E+00, -0.084454040083710883710E+00, - -0.056344313046592789972E+00, -0.028184648949745694339E+00, - 0.0E+00, 0.028184648949745694339E+00, - 0.056344313046592789972E+00, 0.084454040083710883710E+00, - 0.11248894313318662575E+00, 0.14042423315256017459E+00, - 0.16823525155220746498E+00, 0.19589750271110015392E+00, - 0.22338668642896688163E+00, 0.25067873030348317661E+00, - 0.27774982202182431507E+00, 0.30457644155671404334E+00, - 0.33113539325797683309E+00, 0.35740383783153215238E+00, - 0.38335932419873034692E+00, 0.40897982122988867241E+00, - 0.43424374934680255800E+00, 0.45913001198983233287E+00, - 0.48361802694584102756E+00, 0.50768775753371660215E+00, - 0.53131974364437562397E+00, 0.55449513263193254887E+00, - 0.57719571005204581484E+00, 0.59940393024224289297E+00, - 0.62110294673722640294E+00, 0.64227664250975951377E+00, - 0.66290966002478059546E+00, 0.68298743109107922809E+00, - 0.70249620649152707861E+00, 0.72142308537009891548E+00, - 0.73975604435269475868E+00, 0.75748396638051363793E+00, - 0.77459666924148337704E+00, 0.79108493379984836143E+00, - 0.80694053195021761186E+00, 0.82215625436498040737E+00, - 0.83672593816886873550E+00, 0.85064449476835027976E+00, - 0.86390793819369047715E+00, 0.87651341448470526974E+00, - 0.88845923287225699889E+00, 0.89974489977694003664E+00, - 0.91037115695700429250E+00, 0.92034002547001242073E+00, - 0.92965485742974005667E+00, 0.93832039777959288365E+00, - 0.94634285837340290515E+00, 0.95373000642576113641E+00, - 0.96049126870802028342E+00, 0.96663785155841656709E+00, - 0.97218287474858179658E+00, 0.97714151463970571416E+00, - 0.98153114955374010687E+00, 0.98537149959852037111E+00, - 0.98868475754742947994E+00, 0.99149572117810613240E+00, - 0.99383196321275502221E+00, 0.99572410469840718851E+00, - 0.99720625937222195908E+00, 0.99831663531840739253E+00, - 0.99909812496766759766E+00, 0.99959879967191068325E+00, - 0.99987288812035761194E+00, 0.99998243035489159858E+00, - 1.0}; + double abscissas[129] = {-1.0, + -0.99998243035489159858E+00, + -0.99987288812035761194E+00, + -0.99959879967191068325E+00, + -0.99909812496766759766E+00, + -0.99831663531840739253E+00, + -0.99720625937222195908E+00, + -0.99572410469840718851E+00, + -0.99383196321275502221E+00, + -0.99149572117810613240E+00, + -0.98868475754742947994E+00, + -0.98537149959852037111E+00, + -0.98153114955374010687E+00, + -0.97714151463970571416E+00, + -0.97218287474858179658E+00, + -0.96663785155841656709E+00, + -0.96049126870802028342E+00, + -0.95373000642576113641E+00, + -0.94634285837340290515E+00, + -0.93832039777959288365E+00, + -0.92965485742974005667E+00, + -0.92034002547001242073E+00, + -0.91037115695700429250E+00, + -0.89974489977694003664E+00, + -0.88845923287225699889E+00, + -0.87651341448470526974E+00, + -0.86390793819369047715E+00, + -0.85064449476835027976E+00, + -0.83672593816886873550E+00, + -0.82215625436498040737E+00, + -0.80694053195021761186E+00, + -0.79108493379984836143E+00, + -0.77459666924148337704E+00, + -0.75748396638051363793E+00, + -0.73975604435269475868E+00, + -0.72142308537009891548E+00, + -0.70249620649152707861E+00, + -0.68298743109107922809E+00, + -0.66290966002478059546E+00, + -0.64227664250975951377E+00, + -0.62110294673722640294E+00, + -0.59940393024224289297E+00, + -0.57719571005204581484E+00, + -0.55449513263193254887E+00, + -0.53131974364437562397E+00, + -0.50768775753371660215E+00, + -0.48361802694584102756E+00, + -0.45913001198983233287E+00, + -0.43424374934680255800E+00, + -0.40897982122988867241E+00, + -0.38335932419873034692E+00, + -0.35740383783153215238E+00, + -0.33113539325797683309E+00, + -0.30457644155671404334E+00, + -0.27774982202182431507E+00, + -0.25067873030348317661E+00, + -0.22338668642896688163E+00, + -0.19589750271110015392E+00, + -0.16823525155220746498E+00, + -0.14042423315256017459E+00, + -0.11248894313318662575E+00, + -0.084454040083710883710E+00, + -0.056344313046592789972E+00, + -0.028184648949745694339E+00, + 0.0E+00, + 0.028184648949745694339E+00, + 0.056344313046592789972E+00, + 0.084454040083710883710E+00, + 0.11248894313318662575E+00, + 0.14042423315256017459E+00, + 0.16823525155220746498E+00, + 0.19589750271110015392E+00, + 0.22338668642896688163E+00, + 0.25067873030348317661E+00, + 0.27774982202182431507E+00, + 0.30457644155671404334E+00, + 0.33113539325797683309E+00, + 0.35740383783153215238E+00, + 0.38335932419873034692E+00, + 0.40897982122988867241E+00, + 0.43424374934680255800E+00, + 0.45913001198983233287E+00, + 0.48361802694584102756E+00, + 0.50768775753371660215E+00, + 0.53131974364437562397E+00, + 0.55449513263193254887E+00, + 0.57719571005204581484E+00, + 0.59940393024224289297E+00, + 0.62110294673722640294E+00, + 0.64227664250975951377E+00, + 0.66290966002478059546E+00, + 0.68298743109107922809E+00, + 0.70249620649152707861E+00, + 0.72142308537009891548E+00, + 0.73975604435269475868E+00, + 0.75748396638051363793E+00, + 0.77459666924148337704E+00, + 0.79108493379984836143E+00, + 0.80694053195021761186E+00, + 0.82215625436498040737E+00, + 0.83672593816886873550E+00, + 0.85064449476835027976E+00, + 0.86390793819369047715E+00, + 0.87651341448470526974E+00, + 0.88845923287225699889E+00, + 0.89974489977694003664E+00, + 0.91037115695700429250E+00, + 0.92034002547001242073E+00, + 0.92965485742974005667E+00, + 0.93832039777959288365E+00, + 0.94634285837340290515E+00, + 0.95373000642576113641E+00, + 0.96049126870802028342E+00, + 0.96663785155841656709E+00, + 0.97218287474858179658E+00, + 0.97714151463970571416E+00, + 0.98153114955374010687E+00, + 0.98537149959852037111E+00, + 0.98868475754742947994E+00, + 0.99149572117810613240E+00, + 0.99383196321275502221E+00, + 0.99572410469840718851E+00, + 0.99720625937222195908E+00, + 0.99831663531840739253E+00, + 0.99909812496766759766E+00, + 0.99959879967191068325E+00, + 0.99987288812035761194E+00, + 0.99998243035489159858E+00, + 1.0}; stretching->push_back(min); jacobian->push_back(transformationJacobian(min, max, -1.0, type)); for (int d = 1; d < nr_pts - 1; d++) { stretching->push_back(transforminterval(min, max, abscissas[d], type)); - jacobian->push_back( - transformationJacobian(min, max, abscissas[d], type)); + jacobian->push_back(transformationJacobian(min, max, abscissas[d], type)); } stretching->push_back(max); @@ -284,144 +396,270 @@ void combigrid::CombiLegendreStretching::get1DStretching( case 8: { int nr_pts = 257; - double abscissas[257] = { - -1.0, -0.99999759637974846462E+00, - -0.99998243035489159858E+00, -0.99994399620705437576E+00, - -0.99987288812035761194E+00, -0.99976049092443204733E+00, - -0.99959879967191068325E+00, -0.99938033802502358193E+00, - -0.99909812496766759766E+00, -0.99874561446809511470E+00, - -0.99831663531840739253E+00, -0.99780535449595727456E+00, - -0.99720625937222195908E+00, -0.99651414591489027385E+00, - -0.99572410469840718851E+00, -0.99483150280062100052E+00, - -0.99383196321275502221E+00, -0.99272134428278861533E+00, - -0.99149572117810613240E+00, -0.99015137040077015918E+00, - -0.98868475754742947994E+00, -0.98709252795403406719E+00, - -0.98537149959852037111E+00, -0.98351865757863272876E+00, - -0.98153114955374010687E+00, -0.97940628167086268381E+00, - -0.97714151463970571416E+00, -0.97473445975240266776E+00, - -0.97218287474858179658E+00, -0.96948465950245923177E+00, - -0.96663785155841656709E+00, -0.96364062156981213252E+00, - -0.96049126870802028342E+00, -0.95718821610986096274E+00, - -0.95373000642576113641E+00, -0.95011529752129487656E+00, - -0.94634285837340290515E+00, -0.94241156519108305981E+00, - -0.93832039777959288365E+00, -0.93406843615772578800E+00, - -0.92965485742974005667E+00, -0.92507893290707565236E+00, - -0.92034002547001242073E+00, -0.91543758715576504064E+00, - -0.91037115695700429250E+00, -0.90514035881326159519E+00, - -0.89974489977694003664E+00, -0.89418456833555902286E+00, - -0.88845923287225699889E+00, -0.88256884024734190684E+00, - -0.87651341448470526974E+00, -0.87029305554811390585E+00, - -0.86390793819369047715E+00, -0.85735831088623215653E+00, - -0.85064449476835027976E+00, -0.84376688267270860104E+00, - -0.83672593816886873550E+00, -0.82952219463740140018E+00, - -0.82215625436498040737E+00, -0.81462878765513741344E+00, - -0.80694053195021761186E+00, -0.79909229096084140180E+00, - -0.79108493379984836143E+00, -0.78291939411828301639E+00, - -0.77459666924148337704E+00, -0.76611781930376009072E+00, - -0.75748396638051363793E+00, -0.74869629361693660282E+00, - -0.73975604435269475868E+00, -0.73066452124218126133E+00, - -0.72142308537009891548E+00, -0.71203315536225203459E+00, - -0.70249620649152707861E+00, -0.69281376977911470289E+00, - -0.68298743109107922809E+00, -0.67301883023041847920E+00, - -0.66290966002478059546E+00, -0.65266166541001749610E+00, - -0.64227664250975951377E+00, -0.63175643771119423041E+00, - -0.62110294673722640294E+00, -0.61031811371518640016E+00, - -0.59940393024224289297E+00, -0.58836243444766254143E+00, - -0.57719571005204581484E+00, -0.56590588542365442262E+00, - -0.55449513263193254887E+00, -0.54296566649831149049E+00, - -0.53131974364437562397E+00, -0.51955966153745702199E+00, - -0.50768775753371660215E+00, -0.49570640791876146017E+00, - -0.48361802694584102756E+00, -0.47142506587165887693E+00, - -0.45913001198983233287E+00, -0.44673538766202847374E+00, - -0.43424374934680255800E+00, -0.42165768662616330006E+00, - -0.40897982122988867241E+00, -0.39621280605761593918E+00, - -0.38335932419873034692E+00, -0.37042208795007823014E+00, - -0.35740383783153215238E+00, -0.34430734159943802278E+00, - -0.33113539325797683309E+00, -0.31789081206847668318E+00, - -0.30457644155671404334E+00, -0.29119514851824668196E+00, - -0.27774982202182431507E+00, -0.26424337241092676194E+00, - -0.25067873030348317661E+00, -0.23705884558982972721E+00, - -0.22338668642896688163E+00, -0.20966523824318119477E+00, - -0.19589750271110015392E+00, -0.18208649675925219825E+00, - -0.16823525155220746498E+00, -0.15434681148137810869E+00, - -0.14042423315256017459E+00, -0.12647058437230196685E+00, - -0.11248894313318662575E+00, -0.098482396598119202090E+00, - -0.084454040083710883710E+00, -0.070406976042855179063E+00, - -0.056344313046592789972E+00, -0.042269164765363603212E+00, - -0.028184648949745694339E+00, -0.014093886410782462614E+00, - 0.0E+00, 0.014093886410782462614E+00, - 0.028184648949745694339E+00, 0.042269164765363603212E+00, - 0.056344313046592789972E+00, 0.070406976042855179063E+00, - 0.084454040083710883710E+00, 0.098482396598119202090E+00, - 0.11248894313318662575E+00, 0.12647058437230196685E+00, - 0.14042423315256017459E+00, 0.15434681148137810869E+00, - 0.16823525155220746498E+00, 0.18208649675925219825E+00, - 0.19589750271110015392E+00, 0.20966523824318119477E+00, - 0.22338668642896688163E+00, 0.23705884558982972721E+00, - 0.25067873030348317661E+00, 0.26424337241092676194E+00, - 0.27774982202182431507E+00, 0.29119514851824668196E+00, - 0.30457644155671404334E+00, 0.31789081206847668318E+00, - 0.33113539325797683309E+00, 0.34430734159943802278E+00, - 0.35740383783153215238E+00, 0.37042208795007823014E+00, - 0.38335932419873034692E+00, 0.39621280605761593918E+00, - 0.40897982122988867241E+00, 0.42165768662616330006E+00, - 0.43424374934680255800E+00, 0.44673538766202847374E+00, - 0.45913001198983233287E+00, 0.47142506587165887693E+00, - 0.48361802694584102756E+00, 0.49570640791876146017E+00, - 0.50768775753371660215E+00, 0.51955966153745702199E+00, - 0.53131974364437562397E+00, 0.54296566649831149049E+00, - 0.55449513263193254887E+00, 0.56590588542365442262E+00, - 0.57719571005204581484E+00, 0.58836243444766254143E+00, - 0.59940393024224289297E+00, 0.61031811371518640016E+00, - 0.62110294673722640294E+00, 0.63175643771119423041E+00, - 0.64227664250975951377E+00, 0.65266166541001749610E+00, - 0.66290966002478059546E+00, 0.67301883023041847920E+00, - 0.68298743109107922809E+00, 0.69281376977911470289E+00, - 0.70249620649152707861E+00, 0.71203315536225203459E+00, - 0.72142308537009891548E+00, 0.73066452124218126133E+00, - 0.73975604435269475868E+00, 0.74869629361693660282E+00, - 0.75748396638051363793E+00, 0.76611781930376009072E+00, - 0.77459666924148337704E+00, 0.78291939411828301639E+00, - 0.79108493379984836143E+00, 0.79909229096084140180E+00, - 0.80694053195021761186E+00, 0.81462878765513741344E+00, - 0.82215625436498040737E+00, 0.82952219463740140018E+00, - 0.83672593816886873550E+00, 0.84376688267270860104E+00, - 0.85064449476835027976E+00, 0.85735831088623215653E+00, - 0.86390793819369047715E+00, 0.87029305554811390585E+00, - 0.87651341448470526974E+00, 0.88256884024734190684E+00, - 0.88845923287225699889E+00, 0.89418456833555902286E+00, - 0.89974489977694003664E+00, 0.90514035881326159519E+00, - 0.91037115695700429250E+00, 0.91543758715576504064E+00, - 0.92034002547001242073E+00, 0.92507893290707565236E+00, - 0.92965485742974005667E+00, 0.93406843615772578800E+00, - 0.93832039777959288365E+00, 0.94241156519108305981E+00, - 0.94634285837340290515E+00, 0.95011529752129487656E+00, - 0.95373000642576113641E+00, 0.95718821610986096274E+00, - 0.96049126870802028342E+00, 0.96364062156981213252E+00, - 0.96663785155841656709E+00, 0.96948465950245923177E+00, - 0.97218287474858179658E+00, 0.97473445975240266776E+00, - 0.97714151463970571416E+00, 0.97940628167086268381E+00, - 0.98153114955374010687E+00, 0.98351865757863272876E+00, - 0.98537149959852037111E+00, 0.98709252795403406719E+00, - 0.98868475754742947994E+00, 0.99015137040077015918E+00, - 0.99149572117810613240E+00, 0.99272134428278861533E+00, - 0.99383196321275502221E+00, 0.99483150280062100052E+00, - 0.99572410469840718851E+00, 0.99651414591489027385E+00, - 0.99720625937222195908E+00, 0.99780535449595727456E+00, - 0.99831663531840739253E+00, 0.99874561446809511470E+00, - 0.99909812496766759766E+00, 0.99938033802502358193E+00, - 0.99959879967191068325E+00, 0.99976049092443204733E+00, - 0.99987288812035761194E+00, 0.99994399620705437576E+00, - 0.99998243035489159858E+00, 0.99999759637974846462E+00, - 1.0}; + double abscissas[257] = {-1.0, + -0.99999759637974846462E+00, + -0.99998243035489159858E+00, + -0.99994399620705437576E+00, + -0.99987288812035761194E+00, + -0.99976049092443204733E+00, + -0.99959879967191068325E+00, + -0.99938033802502358193E+00, + -0.99909812496766759766E+00, + -0.99874561446809511470E+00, + -0.99831663531840739253E+00, + -0.99780535449595727456E+00, + -0.99720625937222195908E+00, + -0.99651414591489027385E+00, + -0.99572410469840718851E+00, + -0.99483150280062100052E+00, + -0.99383196321275502221E+00, + -0.99272134428278861533E+00, + -0.99149572117810613240E+00, + -0.99015137040077015918E+00, + -0.98868475754742947994E+00, + -0.98709252795403406719E+00, + -0.98537149959852037111E+00, + -0.98351865757863272876E+00, + -0.98153114955374010687E+00, + -0.97940628167086268381E+00, + -0.97714151463970571416E+00, + -0.97473445975240266776E+00, + -0.97218287474858179658E+00, + -0.96948465950245923177E+00, + -0.96663785155841656709E+00, + -0.96364062156981213252E+00, + -0.96049126870802028342E+00, + -0.95718821610986096274E+00, + -0.95373000642576113641E+00, + -0.95011529752129487656E+00, + -0.94634285837340290515E+00, + -0.94241156519108305981E+00, + -0.93832039777959288365E+00, + -0.93406843615772578800E+00, + -0.92965485742974005667E+00, + -0.92507893290707565236E+00, + -0.92034002547001242073E+00, + -0.91543758715576504064E+00, + -0.91037115695700429250E+00, + -0.90514035881326159519E+00, + -0.89974489977694003664E+00, + -0.89418456833555902286E+00, + -0.88845923287225699889E+00, + -0.88256884024734190684E+00, + -0.87651341448470526974E+00, + -0.87029305554811390585E+00, + -0.86390793819369047715E+00, + -0.85735831088623215653E+00, + -0.85064449476835027976E+00, + -0.84376688267270860104E+00, + -0.83672593816886873550E+00, + -0.82952219463740140018E+00, + -0.82215625436498040737E+00, + -0.81462878765513741344E+00, + -0.80694053195021761186E+00, + -0.79909229096084140180E+00, + -0.79108493379984836143E+00, + -0.78291939411828301639E+00, + -0.77459666924148337704E+00, + -0.76611781930376009072E+00, + -0.75748396638051363793E+00, + -0.74869629361693660282E+00, + -0.73975604435269475868E+00, + -0.73066452124218126133E+00, + -0.72142308537009891548E+00, + -0.71203315536225203459E+00, + -0.70249620649152707861E+00, + -0.69281376977911470289E+00, + -0.68298743109107922809E+00, + -0.67301883023041847920E+00, + -0.66290966002478059546E+00, + -0.65266166541001749610E+00, + -0.64227664250975951377E+00, + -0.63175643771119423041E+00, + -0.62110294673722640294E+00, + -0.61031811371518640016E+00, + -0.59940393024224289297E+00, + -0.58836243444766254143E+00, + -0.57719571005204581484E+00, + -0.56590588542365442262E+00, + -0.55449513263193254887E+00, + -0.54296566649831149049E+00, + -0.53131974364437562397E+00, + -0.51955966153745702199E+00, + -0.50768775753371660215E+00, + -0.49570640791876146017E+00, + -0.48361802694584102756E+00, + -0.47142506587165887693E+00, + -0.45913001198983233287E+00, + -0.44673538766202847374E+00, + -0.43424374934680255800E+00, + -0.42165768662616330006E+00, + -0.40897982122988867241E+00, + -0.39621280605761593918E+00, + -0.38335932419873034692E+00, + -0.37042208795007823014E+00, + -0.35740383783153215238E+00, + -0.34430734159943802278E+00, + -0.33113539325797683309E+00, + -0.31789081206847668318E+00, + -0.30457644155671404334E+00, + -0.29119514851824668196E+00, + -0.27774982202182431507E+00, + -0.26424337241092676194E+00, + -0.25067873030348317661E+00, + -0.23705884558982972721E+00, + -0.22338668642896688163E+00, + -0.20966523824318119477E+00, + -0.19589750271110015392E+00, + -0.18208649675925219825E+00, + -0.16823525155220746498E+00, + -0.15434681148137810869E+00, + -0.14042423315256017459E+00, + -0.12647058437230196685E+00, + -0.11248894313318662575E+00, + -0.098482396598119202090E+00, + -0.084454040083710883710E+00, + -0.070406976042855179063E+00, + -0.056344313046592789972E+00, + -0.042269164765363603212E+00, + -0.028184648949745694339E+00, + -0.014093886410782462614E+00, + 0.0E+00, + 0.014093886410782462614E+00, + 0.028184648949745694339E+00, + 0.042269164765363603212E+00, + 0.056344313046592789972E+00, + 0.070406976042855179063E+00, + 0.084454040083710883710E+00, + 0.098482396598119202090E+00, + 0.11248894313318662575E+00, + 0.12647058437230196685E+00, + 0.14042423315256017459E+00, + 0.15434681148137810869E+00, + 0.16823525155220746498E+00, + 0.18208649675925219825E+00, + 0.19589750271110015392E+00, + 0.20966523824318119477E+00, + 0.22338668642896688163E+00, + 0.23705884558982972721E+00, + 0.25067873030348317661E+00, + 0.26424337241092676194E+00, + 0.27774982202182431507E+00, + 0.29119514851824668196E+00, + 0.30457644155671404334E+00, + 0.31789081206847668318E+00, + 0.33113539325797683309E+00, + 0.34430734159943802278E+00, + 0.35740383783153215238E+00, + 0.37042208795007823014E+00, + 0.38335932419873034692E+00, + 0.39621280605761593918E+00, + 0.40897982122988867241E+00, + 0.42165768662616330006E+00, + 0.43424374934680255800E+00, + 0.44673538766202847374E+00, + 0.45913001198983233287E+00, + 0.47142506587165887693E+00, + 0.48361802694584102756E+00, + 0.49570640791876146017E+00, + 0.50768775753371660215E+00, + 0.51955966153745702199E+00, + 0.53131974364437562397E+00, + 0.54296566649831149049E+00, + 0.55449513263193254887E+00, + 0.56590588542365442262E+00, + 0.57719571005204581484E+00, + 0.58836243444766254143E+00, + 0.59940393024224289297E+00, + 0.61031811371518640016E+00, + 0.62110294673722640294E+00, + 0.63175643771119423041E+00, + 0.64227664250975951377E+00, + 0.65266166541001749610E+00, + 0.66290966002478059546E+00, + 0.67301883023041847920E+00, + 0.68298743109107922809E+00, + 0.69281376977911470289E+00, + 0.70249620649152707861E+00, + 0.71203315536225203459E+00, + 0.72142308537009891548E+00, + 0.73066452124218126133E+00, + 0.73975604435269475868E+00, + 0.74869629361693660282E+00, + 0.75748396638051363793E+00, + 0.76611781930376009072E+00, + 0.77459666924148337704E+00, + 0.78291939411828301639E+00, + 0.79108493379984836143E+00, + 0.79909229096084140180E+00, + 0.80694053195021761186E+00, + 0.81462878765513741344E+00, + 0.82215625436498040737E+00, + 0.82952219463740140018E+00, + 0.83672593816886873550E+00, + 0.84376688267270860104E+00, + 0.85064449476835027976E+00, + 0.85735831088623215653E+00, + 0.86390793819369047715E+00, + 0.87029305554811390585E+00, + 0.87651341448470526974E+00, + 0.88256884024734190684E+00, + 0.88845923287225699889E+00, + 0.89418456833555902286E+00, + 0.89974489977694003664E+00, + 0.90514035881326159519E+00, + 0.91037115695700429250E+00, + 0.91543758715576504064E+00, + 0.92034002547001242073E+00, + 0.92507893290707565236E+00, + 0.92965485742974005667E+00, + 0.93406843615772578800E+00, + 0.93832039777959288365E+00, + 0.94241156519108305981E+00, + 0.94634285837340290515E+00, + 0.95011529752129487656E+00, + 0.95373000642576113641E+00, + 0.95718821610986096274E+00, + 0.96049126870802028342E+00, + 0.96364062156981213252E+00, + 0.96663785155841656709E+00, + 0.96948465950245923177E+00, + 0.97218287474858179658E+00, + 0.97473445975240266776E+00, + 0.97714151463970571416E+00, + 0.97940628167086268381E+00, + 0.98153114955374010687E+00, + 0.98351865757863272876E+00, + 0.98537149959852037111E+00, + 0.98709252795403406719E+00, + 0.98868475754742947994E+00, + 0.99015137040077015918E+00, + 0.99149572117810613240E+00, + 0.99272134428278861533E+00, + 0.99383196321275502221E+00, + 0.99483150280062100052E+00, + 0.99572410469840718851E+00, + 0.99651414591489027385E+00, + 0.99720625937222195908E+00, + 0.99780535449595727456E+00, + 0.99831663531840739253E+00, + 0.99874561446809511470E+00, + 0.99909812496766759766E+00, + 0.99938033802502358193E+00, + 0.99959879967191068325E+00, + 0.99976049092443204733E+00, + 0.99987288812035761194E+00, + 0.99994399620705437576E+00, + 0.99998243035489159858E+00, + 0.99999759637974846462E+00, + 1.0}; stretching->push_back(min); jacobian->push_back(transformationJacobian(min, max, -1.0, type)); for (int d = 1; d < nr_pts - 1; d++) { stretching->push_back(transforminterval(min, max, abscissas[d], type)); - jacobian->push_back( - transformationJacobian(min, max, abscissas[d], type)); + jacobian->push_back(transformationJacobian(min, max, abscissas[d], type)); } stretching->push_back(max); @@ -432,272 +670,526 @@ void combigrid::CombiLegendreStretching::get1DStretching( case 9: { int nr_pts = 513; - double abscissas[513] = { - -1.0, -0.999999672956734384381E+00, - -0.999997596379748464620E+00, -0.999992298136257588028E+00, - -0.999982430354891598580E+00, -0.999966730098486276883E+00, - -0.999943996207054375764E+00, -0.999913081144678282800E+00, - -0.999872888120357611938E+00, -0.999822363679787739196E+00, - -0.999760490924432047330E+00, -0.999686286448317731776E+00, - -0.999598799671910683252E+00, -0.999497112467187190535E+00, - -0.999380338025023581928E+00, -0.999247618943342473599E+00, - -0.999098124967667597662E+00, -0.998931050830810562236E+00, - -0.998745614468095114704E+00, -0.998541055697167906027E+00, - -0.998316635318407392531E+00, -0.998071634524930323302E+00, - -0.997805354495957274562E+00, -0.997517116063472399965E+00, - -0.997206259372221959076E+00, -0.996872143485260161299E+00, - -0.996514145914890273849E+00, -0.996131662079315037786E+00, - -0.995724104698407188509E+00, -0.995290903148810302261E+00, - -0.994831502800621000519E+00, -0.994345364356723405931E+00, - -0.993831963212755022209E+00, -0.993290788851684966211E+00, - -0.992721344282788615328E+00, -0.992123145530863117683E+00, - -0.991495721178106132399E+00, -0.990838611958294243677E+00, - -0.990151370400770159181E+00, -0.989433560520240838716E+00, - -0.988684757547429479939E+00, -0.987904547695124280467E+00, - -0.987092527954034067190E+00, -0.986248305913007552681E+00, - -0.985371499598520371114E+00, -0.984461737328814534596E+00, - -0.983518657578632728762E+00, -0.982541908851080604251E+00, - -0.981531149553740106867E+00, -0.980486047876721339416E+00, - -0.979406281670862683806E+00, -0.978291538324758539526E+00, - -0.977141514639705714156E+00, -0.975955916702011753129E+00, - -0.974734459752402667761E+00, -0.973476868052506926773E+00, - -0.972182874748581796578E+00, -0.970852221732792443256E+00, - -0.969484659502459231771E+00, -0.968079947017759947964E+00, - -0.966637851558416567092E+00, -0.965158148579915665979E+00, - -0.963640621569812132521E+00, -0.962085061904651475741E+00, - -0.960491268708020283423E+00, -0.958859048710200221356E+00, - -0.957188216109860962736E+00, -0.955478592438183697574E+00, - -0.953730006425761136415E+00, -0.951942293872573589498E+00, - -0.950115297521294876558E+00, -0.948248866934137357063E+00, - -0.946342858373402905148E+00, -0.944397134685866648591E+00, - -0.942411565191083059813E+00, -0.940386025573669721370E+00, - -0.938320397779592883655E+00, -0.936214569916450806625E+00, - -0.934068436157725787999E+00, -0.931881896650953639345E+00, - -0.929654857429740056670E+00, -0.927387230329536696843E+00, - -0.925078932907075652364E+00, -0.922729888363349241523E+00, - -0.920340025470012420730E+00, -0.917909278499077501636E+00, - -0.915437587155765040644E+00, -0.912924896514370590080E+00, - -0.910371156957004292498E+00, -0.907776324115058903624E+00, - -0.905140358813261595189E+00, -0.902463227016165675048E+00, - -0.899744899776940036639E+00, -0.896985353188316590376E+00, - -0.894184568335559022859E+00, -0.891342531251319871666E+00, - -0.888459232872256998890E+00, -0.885534668997285008926E+00, - -0.882568840247341906842E+00, -0.879561752026556262568E+00, - -0.876513414484705269742E+00, -0.873423842480859310192E+00, - -0.870293055548113905851E+00, -0.867121077859315215614E+00, - -0.863907938193690477146E+00, -0.860653669904299969802E+00, - -0.857358310886232156525E+00, -0.854021903545468625813E+00, - -0.850644494768350279758E+00, -0.847226135891580884381E+00, - -0.843766882672708601038E+00, -0.840266795261030442350E+00, - -0.836725938168868735503E+00, -0.833144380243172624728E+00, - -0.829522194637401400178E+00, -0.825859458783650001088E+00, - -0.822156254364980407373E+00, -0.818412667287925807395E+00, - -0.814628787655137413436E+00, -0.810804709738146594361E+00, - -0.806940531950217611856E+00, -0.803036356819268687782E+00, - -0.799092290960841401800E+00, -0.795108445051100526780E+00, - -0.791084933799848361435E+00, -0.787021875923539422170E+00, - -0.782919394118283016385E+00, -0.778777615032822744702E+00, - -0.774596669241483377036E+00, -0.770376691217076824278E+00, - -0.766117819303760090717E+00, -0.761820195689839149173E+00, - -0.757483966380513637926E+00, -0.753109281170558142523E+00, - -0.748696293616936602823E+00, -0.744245161011347082309E+00, - -0.739756044352694758677E+00, -0.735229108319491547663E+00, - -0.730664521242181261329E+00, -0.726062455075389632685E+00, - -0.721423085370098915485E+00, -0.716746591245747095767E+00, - -0.712033155362252034587E+00, -0.707282963891961103412E+00, - -0.702496206491527078610E+00, -0.697673076273711232906E+00, - -0.692813769779114702895E+00, -0.687918486947839325756E+00, - -0.682987431091079228087E+00, -0.678020808862644517838E+00, - -0.673018830230418479199E+00, -0.667981708447749702165E+00, - -0.662909660024780595461E+00, -0.657802904699713735422E+00, - -0.652661665410017496101E+00, -0.647486168263572388782E+00, - -0.642276642509759513774E+00, -0.637033320510492495071E+00, - -0.631756437711194230414E+00, -0.626446232611719746542E+00, - -0.621102946737226402941E+00, -0.615726824608992638014E+00, - -0.610318113715186400156E+00, -0.604877064481584353319E+00, - -0.599403930242242892974E+00, -0.593898967210121954393E+00, - -0.588362434447662541434E+00, -0.582794593837318850840E+00, - -0.577195710052045814844E+00, -0.571566050525742833992E+00, - -0.565905885423654422623E+00, -0.560215487612728441818E+00, - -0.554495132631932548866E+00, -0.548745098662529448608E+00, - -0.542965666498311490492E+00, -0.537157119515795115982E+00, - -0.531319743644375623972E+00, -0.525453827336442687395E+00, - -0.519559661537457021993E+00, -0.513637539655988578507E+00, - -0.507687757533716602155E+00, -0.501710613415391878251E+00, - -0.495706407918761460170E+00, -0.489675444004456155436E+00, - -0.483618026945841027562E+00, -0.477534464298829155284E+00, - -0.471425065871658876934E+00, -0.465290143694634735858E+00, - -0.459130011989832332874E+00, -0.452944987140767283784E+00, - -0.446735387662028473742E+00, -0.440501534168875795783E+00, - -0.434243749346802558002E+00, -0.427962357921062742583E+00, - -0.421657686626163300056E+00, -0.415330064175321663764E+00, - -0.408979821229888672409E+00, -0.402607290368737092671E+00, - -0.396212806057615939183E+00, -0.389796704618470795479E+00, - -0.383359324198730346916E+00, -0.376901004740559344802E+00, - -0.370422087950078230138E+00, -0.363922917266549655269E+00, - -0.357403837831532152376E+00, -0.350865196458001209011E+00, - -0.344307341599438022777E+00, -0.337730623318886219621E+00, - -0.331135393257976833093E+00, -0.324522004605921855207E+00, - -0.317890812068476683182E+00, -0.311242171836871800300E+00, - -0.304576441556714043335E+00, -0.297893980296857823437E+00, - -0.291195148518246681964E+00, -0.284480308042725577496E+00, - -0.277749822021824315065E+00, -0.271004054905512543536E+00, - -0.264243372410926761945E+00, -0.257468141491069790481E+00, - -0.250678730303483176613E+00, -0.243875508178893021593E+00, - -0.237058845589829727213E+00, -0.230229114119222177156E+00, - -0.223386686428966881628E+00, -0.216531936228472628081E+00, - -0.209665238243181194766E+00, -0.202786968183064697557E+00, - -0.195897502711100153915E+00, -0.188997219411721861059E+00, - -0.182086496759252198246E+00, -0.175165714086311475707E+00, - -0.168235251552207464982E+00, -0.161295490111305257361E+00, - -0.154346811481378108692E+00, -0.147389598111939940054E+00, - -0.140424233152560174594E+00, -0.133451100421161601344E+00, - -0.126470584372301966851E+00, -0.119483070065440005133E+00, - -0.112488943133186625746E+00, -0.105488589749541988533E+00, - -0.984823965981192020903E-01, -0.914707508403553909095E-01, - -0.844540400837108837102E-01, -0.774326523498572825675E-01, - -0.704069760428551790633E-01, -0.633773999173222898797E-01, - -0.563443130465927899720E-01, -0.493081047908686267156E-01, - -0.422691647653636032124E-01, -0.352278828084410232603E-01, - -0.281846489497456943394E-01, -0.211398533783310883350E-01, - -0.140938864107824626142E-01, -0.704713845933674648514E-02, - +0.000000000000000000000E+00, +0.704713845933674648514E-02, - +0.140938864107824626142E-01, +0.211398533783310883350E-01, - +0.281846489497456943394E-01, +0.352278828084410232603E-01, - +0.422691647653636032124E-01, +0.493081047908686267156E-01, - +0.563443130465927899720E-01, +0.633773999173222898797E-01, - +0.704069760428551790633E-01, +0.774326523498572825675E-01, - +0.844540400837108837102E-01, +0.914707508403553909095E-01, - +0.984823965981192020903E-01, +0.105488589749541988533E+00, - +0.112488943133186625746E+00, +0.119483070065440005133E+00, - +0.126470584372301966851E+00, +0.133451100421161601344E+00, - +0.140424233152560174594E+00, +0.147389598111939940054E+00, - +0.154346811481378108692E+00, +0.161295490111305257361E+00, - +0.168235251552207464982E+00, +0.175165714086311475707E+00, - +0.182086496759252198246E+00, +0.188997219411721861059E+00, - +0.195897502711100153915E+00, +0.202786968183064697557E+00, - +0.209665238243181194766E+00, +0.216531936228472628081E+00, - +0.223386686428966881628E+00, +0.230229114119222177156E+00, - +0.237058845589829727213E+00, +0.243875508178893021593E+00, - +0.250678730303483176613E+00, +0.257468141491069790481E+00, - +0.264243372410926761945E+00, +0.271004054905512543536E+00, - +0.277749822021824315065E+00, +0.284480308042725577496E+00, - +0.291195148518246681964E+00, +0.297893980296857823437E+00, - +0.304576441556714043335E+00, +0.311242171836871800300E+00, - +0.317890812068476683182E+00, +0.324522004605921855207E+00, - +0.331135393257976833093E+00, +0.337730623318886219621E+00, - +0.344307341599438022777E+00, +0.350865196458001209011E+00, - +0.357403837831532152376E+00, +0.363922917266549655269E+00, - +0.370422087950078230138E+00, +0.376901004740559344802E+00, - +0.383359324198730346916E+00, +0.389796704618470795479E+00, - +0.396212806057615939183E+00, +0.402607290368737092671E+00, - +0.408979821229888672409E+00, +0.415330064175321663764E+00, - +0.421657686626163300056E+00, +0.427962357921062742583E+00, - +0.434243749346802558002E+00, +0.440501534168875795783E+00, - +0.446735387662028473742E+00, +0.452944987140767283784E+00, - +0.459130011989832332874E+00, +0.465290143694634735858E+00, - +0.471425065871658876934E+00, +0.477534464298829155284E+00, - +0.483618026945841027562E+00, +0.489675444004456155436E+00, - +0.495706407918761460170E+00, +0.501710613415391878251E+00, - +0.507687757533716602155E+00, +0.513637539655988578507E+00, - +0.519559661537457021993E+00, +0.525453827336442687395E+00, - +0.531319743644375623972E+00, +0.537157119515795115982E+00, - +0.542965666498311490492E+00, +0.548745098662529448608E+00, - +0.554495132631932548866E+00, +0.560215487612728441818E+00, - +0.565905885423654422623E+00, +0.571566050525742833992E+00, - +0.577195710052045814844E+00, +0.582794593837318850840E+00, - +0.588362434447662541434E+00, +0.593898967210121954393E+00, - +0.599403930242242892974E+00, +0.604877064481584353319E+00, - +0.610318113715186400156E+00, +0.615726824608992638014E+00, - +0.621102946737226402941E+00, +0.626446232611719746542E+00, - +0.631756437711194230414E+00, +0.637033320510492495071E+00, - +0.642276642509759513774E+00, +0.647486168263572388782E+00, - +0.652661665410017496101E+00, +0.657802904699713735422E+00, - +0.662909660024780595461E+00, +0.667981708447749702165E+00, - +0.673018830230418479199E+00, +0.678020808862644517838E+00, - +0.682987431091079228087E+00, +0.687918486947839325756E+00, - +0.692813769779114702895E+00, +0.697673076273711232906E+00, - +0.702496206491527078610E+00, +0.707282963891961103412E+00, - +0.712033155362252034587E+00, +0.716746591245747095767E+00, - +0.721423085370098915485E+00, +0.726062455075389632685E+00, - +0.730664521242181261329E+00, +0.735229108319491547663E+00, - +0.739756044352694758677E+00, +0.744245161011347082309E+00, - +0.748696293616936602823E+00, +0.753109281170558142523E+00, - +0.757483966380513637926E+00, +0.761820195689839149173E+00, - +0.766117819303760090717E+00, +0.770376691217076824278E+00, - +0.774596669241483377036E+00, +0.778777615032822744702E+00, - +0.782919394118283016385E+00, +0.787021875923539422170E+00, - +0.791084933799848361435E+00, +0.795108445051100526780E+00, - +0.799092290960841401800E+00, +0.803036356819268687782E+00, - +0.806940531950217611856E+00, +0.810804709738146594361E+00, - +0.814628787655137413436E+00, +0.818412667287925807395E+00, - +0.822156254364980407373E+00, +0.825859458783650001088E+00, - +0.829522194637401400178E+00, +0.833144380243172624728E+00, - +0.836725938168868735503E+00, +0.840266795261030442350E+00, - +0.843766882672708601038E+00, +0.847226135891580884381E+00, - +0.850644494768350279758E+00, +0.854021903545468625813E+00, - +0.857358310886232156525E+00, +0.860653669904299969802E+00, - +0.863907938193690477146E+00, +0.867121077859315215614E+00, - +0.870293055548113905851E+00, +0.873423842480859310192E+00, - +0.876513414484705269742E+00, +0.879561752026556262568E+00, - +0.882568840247341906842E+00, +0.885534668997285008926E+00, - +0.888459232872256998890E+00, +0.891342531251319871666E+00, - +0.894184568335559022859E+00, +0.896985353188316590376E+00, - +0.899744899776940036639E+00, +0.902463227016165675048E+00, - +0.905140358813261595189E+00, +0.907776324115058903624E+00, - +0.910371156957004292498E+00, +0.912924896514370590080E+00, - +0.915437587155765040644E+00, +0.917909278499077501636E+00, - +0.920340025470012420730E+00, +0.922729888363349241523E+00, - +0.925078932907075652364E+00, +0.927387230329536696843E+00, - +0.929654857429740056670E+00, +0.931881896650953639345E+00, - +0.934068436157725787999E+00, +0.936214569916450806625E+00, - +0.938320397779592883655E+00, +0.940386025573669721370E+00, - +0.942411565191083059813E+00, +0.944397134685866648591E+00, - +0.946342858373402905148E+00, +0.948248866934137357063E+00, - +0.950115297521294876558E+00, +0.951942293872573589498E+00, - +0.953730006425761136415E+00, +0.955478592438183697574E+00, - +0.957188216109860962736E+00, +0.958859048710200221356E+00, - +0.960491268708020283423E+00, +0.962085061904651475741E+00, - +0.963640621569812132521E+00, +0.965158148579915665979E+00, - +0.966637851558416567092E+00, +0.968079947017759947964E+00, - +0.969484659502459231771E+00, +0.970852221732792443256E+00, - +0.972182874748581796578E+00, +0.973476868052506926773E+00, - +0.974734459752402667761E+00, +0.975955916702011753129E+00, - +0.977141514639705714156E+00, +0.978291538324758539526E+00, - +0.979406281670862683806E+00, +0.980486047876721339416E+00, - +0.981531149553740106867E+00, +0.982541908851080604251E+00, - +0.983518657578632728762E+00, +0.984461737328814534596E+00, - +0.985371499598520371114E+00, +0.986248305913007552681E+00, - +0.987092527954034067190E+00, +0.987904547695124280467E+00, - +0.988684757547429479939E+00, +0.989433560520240838716E+00, - +0.990151370400770159181E+00, +0.990838611958294243677E+00, - +0.991495721178106132399E+00, +0.992123145530863117683E+00, - +0.992721344282788615328E+00, +0.993290788851684966211E+00, - +0.993831963212755022209E+00, +0.994345364356723405931E+00, - +0.994831502800621000519E+00, +0.995290903148810302261E+00, - +0.995724104698407188509E+00, +0.996131662079315037786E+00, - +0.996514145914890273849E+00, +0.996872143485260161299E+00, - +0.997206259372221959076E+00, +0.997517116063472399965E+00, - +0.997805354495957274562E+00, +0.998071634524930323302E+00, - +0.998316635318407392531E+00, +0.998541055697167906027E+00, - +0.998745614468095114704E+00, +0.998931050830810562236E+00, - +0.999098124967667597662E+00, +0.999247618943342473599E+00, - +0.999380338025023581928E+00, +0.999497112467187190535E+00, - +0.999598799671910683252E+00, +0.999686286448317731776E+00, - +0.999760490924432047330E+00, +0.999822363679787739196E+00, - +0.999872888120357611938E+00, +0.999913081144678282800E+00, - +0.999943996207054375764E+00, +0.999966730098486276883E+00, - +0.999982430354891598580E+00, +0.999992298136257588028E+00, - +0.999997596379748464620E+00, +0.999999672956734384381E+00, - 1.0}; + double abscissas[513] = {-1.0, + -0.999999672956734384381E+00, + -0.999997596379748464620E+00, + -0.999992298136257588028E+00, + -0.999982430354891598580E+00, + -0.999966730098486276883E+00, + -0.999943996207054375764E+00, + -0.999913081144678282800E+00, + -0.999872888120357611938E+00, + -0.999822363679787739196E+00, + -0.999760490924432047330E+00, + -0.999686286448317731776E+00, + -0.999598799671910683252E+00, + -0.999497112467187190535E+00, + -0.999380338025023581928E+00, + -0.999247618943342473599E+00, + -0.999098124967667597662E+00, + -0.998931050830810562236E+00, + -0.998745614468095114704E+00, + -0.998541055697167906027E+00, + -0.998316635318407392531E+00, + -0.998071634524930323302E+00, + -0.997805354495957274562E+00, + -0.997517116063472399965E+00, + -0.997206259372221959076E+00, + -0.996872143485260161299E+00, + -0.996514145914890273849E+00, + -0.996131662079315037786E+00, + -0.995724104698407188509E+00, + -0.995290903148810302261E+00, + -0.994831502800621000519E+00, + -0.994345364356723405931E+00, + -0.993831963212755022209E+00, + -0.993290788851684966211E+00, + -0.992721344282788615328E+00, + -0.992123145530863117683E+00, + -0.991495721178106132399E+00, + -0.990838611958294243677E+00, + -0.990151370400770159181E+00, + -0.989433560520240838716E+00, + -0.988684757547429479939E+00, + -0.987904547695124280467E+00, + -0.987092527954034067190E+00, + -0.986248305913007552681E+00, + -0.985371499598520371114E+00, + -0.984461737328814534596E+00, + -0.983518657578632728762E+00, + -0.982541908851080604251E+00, + -0.981531149553740106867E+00, + -0.980486047876721339416E+00, + -0.979406281670862683806E+00, + -0.978291538324758539526E+00, + -0.977141514639705714156E+00, + -0.975955916702011753129E+00, + -0.974734459752402667761E+00, + -0.973476868052506926773E+00, + -0.972182874748581796578E+00, + -0.970852221732792443256E+00, + -0.969484659502459231771E+00, + -0.968079947017759947964E+00, + -0.966637851558416567092E+00, + -0.965158148579915665979E+00, + -0.963640621569812132521E+00, + -0.962085061904651475741E+00, + -0.960491268708020283423E+00, + -0.958859048710200221356E+00, + -0.957188216109860962736E+00, + -0.955478592438183697574E+00, + -0.953730006425761136415E+00, + -0.951942293872573589498E+00, + -0.950115297521294876558E+00, + -0.948248866934137357063E+00, + -0.946342858373402905148E+00, + -0.944397134685866648591E+00, + -0.942411565191083059813E+00, + -0.940386025573669721370E+00, + -0.938320397779592883655E+00, + -0.936214569916450806625E+00, + -0.934068436157725787999E+00, + -0.931881896650953639345E+00, + -0.929654857429740056670E+00, + -0.927387230329536696843E+00, + -0.925078932907075652364E+00, + -0.922729888363349241523E+00, + -0.920340025470012420730E+00, + -0.917909278499077501636E+00, + -0.915437587155765040644E+00, + -0.912924896514370590080E+00, + -0.910371156957004292498E+00, + -0.907776324115058903624E+00, + -0.905140358813261595189E+00, + -0.902463227016165675048E+00, + -0.899744899776940036639E+00, + -0.896985353188316590376E+00, + -0.894184568335559022859E+00, + -0.891342531251319871666E+00, + -0.888459232872256998890E+00, + -0.885534668997285008926E+00, + -0.882568840247341906842E+00, + -0.879561752026556262568E+00, + -0.876513414484705269742E+00, + -0.873423842480859310192E+00, + -0.870293055548113905851E+00, + -0.867121077859315215614E+00, + -0.863907938193690477146E+00, + -0.860653669904299969802E+00, + -0.857358310886232156525E+00, + -0.854021903545468625813E+00, + -0.850644494768350279758E+00, + -0.847226135891580884381E+00, + -0.843766882672708601038E+00, + -0.840266795261030442350E+00, + -0.836725938168868735503E+00, + -0.833144380243172624728E+00, + -0.829522194637401400178E+00, + -0.825859458783650001088E+00, + -0.822156254364980407373E+00, + -0.818412667287925807395E+00, + -0.814628787655137413436E+00, + -0.810804709738146594361E+00, + -0.806940531950217611856E+00, + -0.803036356819268687782E+00, + -0.799092290960841401800E+00, + -0.795108445051100526780E+00, + -0.791084933799848361435E+00, + -0.787021875923539422170E+00, + -0.782919394118283016385E+00, + -0.778777615032822744702E+00, + -0.774596669241483377036E+00, + -0.770376691217076824278E+00, + -0.766117819303760090717E+00, + -0.761820195689839149173E+00, + -0.757483966380513637926E+00, + -0.753109281170558142523E+00, + -0.748696293616936602823E+00, + -0.744245161011347082309E+00, + -0.739756044352694758677E+00, + -0.735229108319491547663E+00, + -0.730664521242181261329E+00, + -0.726062455075389632685E+00, + -0.721423085370098915485E+00, + -0.716746591245747095767E+00, + -0.712033155362252034587E+00, + -0.707282963891961103412E+00, + -0.702496206491527078610E+00, + -0.697673076273711232906E+00, + -0.692813769779114702895E+00, + -0.687918486947839325756E+00, + -0.682987431091079228087E+00, + -0.678020808862644517838E+00, + -0.673018830230418479199E+00, + -0.667981708447749702165E+00, + -0.662909660024780595461E+00, + -0.657802904699713735422E+00, + -0.652661665410017496101E+00, + -0.647486168263572388782E+00, + -0.642276642509759513774E+00, + -0.637033320510492495071E+00, + -0.631756437711194230414E+00, + -0.626446232611719746542E+00, + -0.621102946737226402941E+00, + -0.615726824608992638014E+00, + -0.610318113715186400156E+00, + -0.604877064481584353319E+00, + -0.599403930242242892974E+00, + -0.593898967210121954393E+00, + -0.588362434447662541434E+00, + -0.582794593837318850840E+00, + -0.577195710052045814844E+00, + -0.571566050525742833992E+00, + -0.565905885423654422623E+00, + -0.560215487612728441818E+00, + -0.554495132631932548866E+00, + -0.548745098662529448608E+00, + -0.542965666498311490492E+00, + -0.537157119515795115982E+00, + -0.531319743644375623972E+00, + -0.525453827336442687395E+00, + -0.519559661537457021993E+00, + -0.513637539655988578507E+00, + -0.507687757533716602155E+00, + -0.501710613415391878251E+00, + -0.495706407918761460170E+00, + -0.489675444004456155436E+00, + -0.483618026945841027562E+00, + -0.477534464298829155284E+00, + -0.471425065871658876934E+00, + -0.465290143694634735858E+00, + -0.459130011989832332874E+00, + -0.452944987140767283784E+00, + -0.446735387662028473742E+00, + -0.440501534168875795783E+00, + -0.434243749346802558002E+00, + -0.427962357921062742583E+00, + -0.421657686626163300056E+00, + -0.415330064175321663764E+00, + -0.408979821229888672409E+00, + -0.402607290368737092671E+00, + -0.396212806057615939183E+00, + -0.389796704618470795479E+00, + -0.383359324198730346916E+00, + -0.376901004740559344802E+00, + -0.370422087950078230138E+00, + -0.363922917266549655269E+00, + -0.357403837831532152376E+00, + -0.350865196458001209011E+00, + -0.344307341599438022777E+00, + -0.337730623318886219621E+00, + -0.331135393257976833093E+00, + -0.324522004605921855207E+00, + -0.317890812068476683182E+00, + -0.311242171836871800300E+00, + -0.304576441556714043335E+00, + -0.297893980296857823437E+00, + -0.291195148518246681964E+00, + -0.284480308042725577496E+00, + -0.277749822021824315065E+00, + -0.271004054905512543536E+00, + -0.264243372410926761945E+00, + -0.257468141491069790481E+00, + -0.250678730303483176613E+00, + -0.243875508178893021593E+00, + -0.237058845589829727213E+00, + -0.230229114119222177156E+00, + -0.223386686428966881628E+00, + -0.216531936228472628081E+00, + -0.209665238243181194766E+00, + -0.202786968183064697557E+00, + -0.195897502711100153915E+00, + -0.188997219411721861059E+00, + -0.182086496759252198246E+00, + -0.175165714086311475707E+00, + -0.168235251552207464982E+00, + -0.161295490111305257361E+00, + -0.154346811481378108692E+00, + -0.147389598111939940054E+00, + -0.140424233152560174594E+00, + -0.133451100421161601344E+00, + -0.126470584372301966851E+00, + -0.119483070065440005133E+00, + -0.112488943133186625746E+00, + -0.105488589749541988533E+00, + -0.984823965981192020903E-01, + -0.914707508403553909095E-01, + -0.844540400837108837102E-01, + -0.774326523498572825675E-01, + -0.704069760428551790633E-01, + -0.633773999173222898797E-01, + -0.563443130465927899720E-01, + -0.493081047908686267156E-01, + -0.422691647653636032124E-01, + -0.352278828084410232603E-01, + -0.281846489497456943394E-01, + -0.211398533783310883350E-01, + -0.140938864107824626142E-01, + -0.704713845933674648514E-02, + +0.000000000000000000000E+00, + +0.704713845933674648514E-02, + +0.140938864107824626142E-01, + +0.211398533783310883350E-01, + +0.281846489497456943394E-01, + +0.352278828084410232603E-01, + +0.422691647653636032124E-01, + +0.493081047908686267156E-01, + +0.563443130465927899720E-01, + +0.633773999173222898797E-01, + +0.704069760428551790633E-01, + +0.774326523498572825675E-01, + +0.844540400837108837102E-01, + +0.914707508403553909095E-01, + +0.984823965981192020903E-01, + +0.105488589749541988533E+00, + +0.112488943133186625746E+00, + +0.119483070065440005133E+00, + +0.126470584372301966851E+00, + +0.133451100421161601344E+00, + +0.140424233152560174594E+00, + +0.147389598111939940054E+00, + +0.154346811481378108692E+00, + +0.161295490111305257361E+00, + +0.168235251552207464982E+00, + +0.175165714086311475707E+00, + +0.182086496759252198246E+00, + +0.188997219411721861059E+00, + +0.195897502711100153915E+00, + +0.202786968183064697557E+00, + +0.209665238243181194766E+00, + +0.216531936228472628081E+00, + +0.223386686428966881628E+00, + +0.230229114119222177156E+00, + +0.237058845589829727213E+00, + +0.243875508178893021593E+00, + +0.250678730303483176613E+00, + +0.257468141491069790481E+00, + +0.264243372410926761945E+00, + +0.271004054905512543536E+00, + +0.277749822021824315065E+00, + +0.284480308042725577496E+00, + +0.291195148518246681964E+00, + +0.297893980296857823437E+00, + +0.304576441556714043335E+00, + +0.311242171836871800300E+00, + +0.317890812068476683182E+00, + +0.324522004605921855207E+00, + +0.331135393257976833093E+00, + +0.337730623318886219621E+00, + +0.344307341599438022777E+00, + +0.350865196458001209011E+00, + +0.357403837831532152376E+00, + +0.363922917266549655269E+00, + +0.370422087950078230138E+00, + +0.376901004740559344802E+00, + +0.383359324198730346916E+00, + +0.389796704618470795479E+00, + +0.396212806057615939183E+00, + +0.402607290368737092671E+00, + +0.408979821229888672409E+00, + +0.415330064175321663764E+00, + +0.421657686626163300056E+00, + +0.427962357921062742583E+00, + +0.434243749346802558002E+00, + +0.440501534168875795783E+00, + +0.446735387662028473742E+00, + +0.452944987140767283784E+00, + +0.459130011989832332874E+00, + +0.465290143694634735858E+00, + +0.471425065871658876934E+00, + +0.477534464298829155284E+00, + +0.483618026945841027562E+00, + +0.489675444004456155436E+00, + +0.495706407918761460170E+00, + +0.501710613415391878251E+00, + +0.507687757533716602155E+00, + +0.513637539655988578507E+00, + +0.519559661537457021993E+00, + +0.525453827336442687395E+00, + +0.531319743644375623972E+00, + +0.537157119515795115982E+00, + +0.542965666498311490492E+00, + +0.548745098662529448608E+00, + +0.554495132631932548866E+00, + +0.560215487612728441818E+00, + +0.565905885423654422623E+00, + +0.571566050525742833992E+00, + +0.577195710052045814844E+00, + +0.582794593837318850840E+00, + +0.588362434447662541434E+00, + +0.593898967210121954393E+00, + +0.599403930242242892974E+00, + +0.604877064481584353319E+00, + +0.610318113715186400156E+00, + +0.615726824608992638014E+00, + +0.621102946737226402941E+00, + +0.626446232611719746542E+00, + +0.631756437711194230414E+00, + +0.637033320510492495071E+00, + +0.642276642509759513774E+00, + +0.647486168263572388782E+00, + +0.652661665410017496101E+00, + +0.657802904699713735422E+00, + +0.662909660024780595461E+00, + +0.667981708447749702165E+00, + +0.673018830230418479199E+00, + +0.678020808862644517838E+00, + +0.682987431091079228087E+00, + +0.687918486947839325756E+00, + +0.692813769779114702895E+00, + +0.697673076273711232906E+00, + +0.702496206491527078610E+00, + +0.707282963891961103412E+00, + +0.712033155362252034587E+00, + +0.716746591245747095767E+00, + +0.721423085370098915485E+00, + +0.726062455075389632685E+00, + +0.730664521242181261329E+00, + +0.735229108319491547663E+00, + +0.739756044352694758677E+00, + +0.744245161011347082309E+00, + +0.748696293616936602823E+00, + +0.753109281170558142523E+00, + +0.757483966380513637926E+00, + +0.761820195689839149173E+00, + +0.766117819303760090717E+00, + +0.770376691217076824278E+00, + +0.774596669241483377036E+00, + +0.778777615032822744702E+00, + +0.782919394118283016385E+00, + +0.787021875923539422170E+00, + +0.791084933799848361435E+00, + +0.795108445051100526780E+00, + +0.799092290960841401800E+00, + +0.803036356819268687782E+00, + +0.806940531950217611856E+00, + +0.810804709738146594361E+00, + +0.814628787655137413436E+00, + +0.818412667287925807395E+00, + +0.822156254364980407373E+00, + +0.825859458783650001088E+00, + +0.829522194637401400178E+00, + +0.833144380243172624728E+00, + +0.836725938168868735503E+00, + +0.840266795261030442350E+00, + +0.843766882672708601038E+00, + +0.847226135891580884381E+00, + +0.850644494768350279758E+00, + +0.854021903545468625813E+00, + +0.857358310886232156525E+00, + +0.860653669904299969802E+00, + +0.863907938193690477146E+00, + +0.867121077859315215614E+00, + +0.870293055548113905851E+00, + +0.873423842480859310192E+00, + +0.876513414484705269742E+00, + +0.879561752026556262568E+00, + +0.882568840247341906842E+00, + +0.885534668997285008926E+00, + +0.888459232872256998890E+00, + +0.891342531251319871666E+00, + +0.894184568335559022859E+00, + +0.896985353188316590376E+00, + +0.899744899776940036639E+00, + +0.902463227016165675048E+00, + +0.905140358813261595189E+00, + +0.907776324115058903624E+00, + +0.910371156957004292498E+00, + +0.912924896514370590080E+00, + +0.915437587155765040644E+00, + +0.917909278499077501636E+00, + +0.920340025470012420730E+00, + +0.922729888363349241523E+00, + +0.925078932907075652364E+00, + +0.927387230329536696843E+00, + +0.929654857429740056670E+00, + +0.931881896650953639345E+00, + +0.934068436157725787999E+00, + +0.936214569916450806625E+00, + +0.938320397779592883655E+00, + +0.940386025573669721370E+00, + +0.942411565191083059813E+00, + +0.944397134685866648591E+00, + +0.946342858373402905148E+00, + +0.948248866934137357063E+00, + +0.950115297521294876558E+00, + +0.951942293872573589498E+00, + +0.953730006425761136415E+00, + +0.955478592438183697574E+00, + +0.957188216109860962736E+00, + +0.958859048710200221356E+00, + +0.960491268708020283423E+00, + +0.962085061904651475741E+00, + +0.963640621569812132521E+00, + +0.965158148579915665979E+00, + +0.966637851558416567092E+00, + +0.968079947017759947964E+00, + +0.969484659502459231771E+00, + +0.970852221732792443256E+00, + +0.972182874748581796578E+00, + +0.973476868052506926773E+00, + +0.974734459752402667761E+00, + +0.975955916702011753129E+00, + +0.977141514639705714156E+00, + +0.978291538324758539526E+00, + +0.979406281670862683806E+00, + +0.980486047876721339416E+00, + +0.981531149553740106867E+00, + +0.982541908851080604251E+00, + +0.983518657578632728762E+00, + +0.984461737328814534596E+00, + +0.985371499598520371114E+00, + +0.986248305913007552681E+00, + +0.987092527954034067190E+00, + +0.987904547695124280467E+00, + +0.988684757547429479939E+00, + +0.989433560520240838716E+00, + +0.990151370400770159181E+00, + +0.990838611958294243677E+00, + +0.991495721178106132399E+00, + +0.992123145530863117683E+00, + +0.992721344282788615328E+00, + +0.993290788851684966211E+00, + +0.993831963212755022209E+00, + +0.994345364356723405931E+00, + +0.994831502800621000519E+00, + +0.995290903148810302261E+00, + +0.995724104698407188509E+00, + +0.996131662079315037786E+00, + +0.996514145914890273849E+00, + +0.996872143485260161299E+00, + +0.997206259372221959076E+00, + +0.997517116063472399965E+00, + +0.997805354495957274562E+00, + +0.998071634524930323302E+00, + +0.998316635318407392531E+00, + +0.998541055697167906027E+00, + +0.998745614468095114704E+00, + +0.998931050830810562236E+00, + +0.999098124967667597662E+00, + +0.999247618943342473599E+00, + +0.999380338025023581928E+00, + +0.999497112467187190535E+00, + +0.999598799671910683252E+00, + +0.999686286448317731776E+00, + +0.999760490924432047330E+00, + +0.999822363679787739196E+00, + +0.999872888120357611938E+00, + +0.999913081144678282800E+00, + +0.999943996207054375764E+00, + +0.999966730098486276883E+00, + +0.999982430354891598580E+00, + +0.999992298136257588028E+00, + +0.999997596379748464620E+00, + +0.999999672956734384381E+00, + 1.0}; stretching->push_back(min); jacobian->push_back(transformationJacobian(min, max, -1.0, type)); for (int d = 1; d < nr_pts - 1; d++) { stretching->push_back(transforminterval(min, max, abscissas[d], type)); - jacobian->push_back( - transformationJacobian(min, max, abscissas[d], type)); + jacobian->push_back(transformationJacobian(min, max, abscissas[d], type)); } stretching->push_back(max); @@ -707,23 +1199,11 @@ void combigrid::CombiLegendreStretching::get1DStretching( } default: { - COMBIGRID_OUT_WRN( - "\nSorry for the inconvenience\n," - "but I am not such a genius!\n" - "I cannot support the quadrature of Gauss-LEGENDRE (Patterson does " - "not rhyme with surrender),\n" - "cuz to its complexity I do SURRENDER\n, " - "So PLEASE, \n " - "the grid level you DECREASE,\n....(max supported level is 9)....\n" - "for I have only pre-computed\n" - "coefficients up to level NINE INCLUSIVE...\n\n" - "Sincerely yours (since the day you bought me),\n" - "CPU\n", - __FILE__, __LINE__) + COMBIGRID_OUT_WRN("Grid level > 9 unsupported.\n", __FILE__, __LINE__) int nr_pts = powerOfTwo[level] + 1; stretching->resize(nr_pts, 0.0); break; } } -} +} // NOLINT(readability/fn_size) diff --git a/combigrid/src/sgpp/combigrid/domain/CombiLegendreStretching.hpp b/combigrid/src/sgpp/combigrid/domain/CombiLegendreStretching.hpp index 97fcbb468c..11da8de072 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiLegendreStretching.hpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiLegendreStretching.hpp @@ -1,15 +1,15 @@ -/* - * CombiLegendreStretching.hpp - * - * Created on: 21 Aug 2014 - * Author: kenny - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef COMBILEGENDRESTRETCHING_HPP_ #define COMBILEGENDRESTRETCHING_HPP_ #include +#include + namespace combigrid { class CombiLegendreStretching : public AbstractStretchingMaker { @@ -28,12 +28,11 @@ class CombiLegendreStretching : public AbstractStretchingMaker { * size of the interval and underlying tranformations. * */ - void get1DStretching(int level, double min, double max, - std::vector* stretching, + void get1DStretching(int level, double min, double max, std::vector* stretching, std::vector* jacobian) const; Stretching getStretchingType() const { return LEGENDRE; } }; -} +} // namespace combigrid #endif /* COMBILEGENDRESTRETCHING_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/domain/CombiTanStretching.cpp b/combigrid/src/sgpp/combigrid/domain/CombiTanStretching.cpp index 01c2e2125c..c29d954a3a 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiTanStretching.cpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiTanStretching.cpp @@ -1,23 +1,23 @@ -/* **************************************************************************** -* Copyright (C) 2011 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include #include -void combigrid::TanStretching::get1DStretching( - int level, double min, double max, std::vector* stretching, - std::vector* jacobian) const { +#include + +void combigrid::TanStretching::get1DStretching(int level, double min, double max, + std::vector* stretching, + std::vector* jacobian) const { int nrPoints = combigrid::powerOfTwo[level] + 1; stretching->resize(nrPoints); std::vector tmpPoints(nrPoints); for (int ii = 0; ii < nrPoints; ii++) - tmpPoints[ii] = (double)(2 * ii - combigrid::powerOfTwo[level]) / - (double)(combigrid::powerOfTwo[level]); + tmpPoints[ii] = static_cast(2 * ii - combigrid::powerOfTwo[level]) / + static_cast(combigrid::powerOfTwo[level]); for (int ii = 0; ii < nrPoints; ii++) // pi/2 = 1.57079632679490 @@ -26,9 +26,8 @@ void combigrid::TanStretching::get1DStretching( // do the scaling for (int ii = 0; ii < nrPoints; ii++) (*stretching)[ii] = - min + - (max - min) * 0.5 * (1 + ((*stretching)[ii] / (*stretching)[nrPoints - 1])); + min + (max - min) * 0.5 * (1 + ((*stretching)[ii] / (*stretching)[nrPoints - 1])); // PeTz - // TODO:: CALCULATE the tan stretching's JACOBIAN!!! + // TODO(???): CALCULATE the tan stretching's JACOBIAN!!! } diff --git a/combigrid/src/sgpp/combigrid/domain/CombiTanStretching.hpp b/combigrid/src/sgpp/combigrid/domain/CombiTanStretching.hpp index b5047e39f5..c757c250d2 100644 --- a/combigrid/src/sgpp/combigrid/domain/CombiTanStretching.hpp +++ b/combigrid/src/sgpp/combigrid/domain/CombiTanStretching.hpp @@ -1,14 +1,15 @@ -/* **************************************************************************** - * Copyright (C) 2011 Technische Universitaet Muenchen * - * This file is part of the SG++ project. For conditions of distribution and * - * use, please see the copyright notice at http://www5.in.tum.de/SGpp * - **************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #ifndef COMBITANSTRETCHING_HPP_ #define COMBITANSTRETCHING_HPP_ #include +#include + namespace combigrid { /** The stretching function of this class is:
@@ -20,7 +21,7 @@ class TanStretching : public AbstractStretchingMaker { public: /** Ctor * @param intFact must be smaller than one*/ - TanStretching(double intFact = 1.0 / 7.0) + explicit TanStretching(double intFact = 1.0 / 7.0) : AbstractStretchingMaker(), intFact_(intFact) { if (intFact_ > 1.5) intFact_ = 1.0 / 1.5; @@ -29,8 +30,7 @@ class TanStretching : public AbstractStretchingMaker { virtual ~TanStretching() { ; } - void get1DStretching(int level, double min, double max, - std::vector* stretching, + void get1DStretching(int level, double min, double max, std::vector* stretching, std::vector* jacobian) const; Stretching getStretchingType() const { return TAN; } @@ -39,6 +39,6 @@ class TanStretching : public AbstractStretchingMaker { /** internal factor for the formula */ double intFact_; }; -} +} // namespace combigrid #endif /* COMBITANSTRETCHING_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/domain/StretchingFactory.cpp b/combigrid/src/sgpp/combigrid/domain/StretchingFactory.cpp index 945fcd0da4..013251d74a 100644 --- a/combigrid/src/sgpp/combigrid/domain/StretchingFactory.cpp +++ b/combigrid/src/sgpp/combigrid/domain/StretchingFactory.cpp @@ -1,9 +1,7 @@ -/* - * StretchingFactory.cpp - * - * Created on: Jan 19, 2015 - * Author: petz - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include @@ -39,12 +37,11 @@ AbstractStretchingMaker* createStretchingMaker(combigrid::Stretching str) { case UNKNOWN: default: - COMBIGRID_OUT_WRN( - "Input stretching type unknown! Returning a NULL stretching maker!", - __FILE__, __LINE__) + COMBIGRID_OUT_WRN("Input stretching type unknown! Returning a NULL stretching maker!", + __FILE__, __LINE__) break; } return maker; } -} +} // namespace combigrid diff --git a/combigrid/src/sgpp/combigrid/domain/StretchingFactory.hpp b/combigrid/src/sgpp/combigrid/domain/StretchingFactory.hpp index 967274357c..53c77447e8 100644 --- a/combigrid/src/sgpp/combigrid/domain/StretchingFactory.hpp +++ b/combigrid/src/sgpp/combigrid/domain/StretchingFactory.hpp @@ -1,9 +1,7 @@ -/* - * StretchingFactory.hpp - * - * Created on: Jan 19, 2015 - * Author: petz - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef STRETCHINGFACTORY_HPP_ #define STRETCHINGFACTORY_HPP_ @@ -47,6 +45,6 @@ AbstractStretchingMaker* createStretchingMaker(combigrid::Stretching str); // // return maker; // } -} +} // namespace combigrid #endif /* STRETCHINGFACTORY_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/fullgrid/CombiFullGrid.hpp b/combigrid/src/sgpp/combigrid/fullgrid/CombiFullGrid.hpp index 2df8998a58..5cbb1ef0e0 100644 --- a/combigrid/src/sgpp/combigrid/fullgrid/CombiFullGrid.hpp +++ b/combigrid/src/sgpp/combigrid/fullgrid/CombiFullGrid.hpp @@ -1,9 +1,8 @@ -/* **************************************************************************** - * Copyright (C) 2011 Technische Universitaet Muenchen * - * This file is part of the SG++ project. For conditions of distribution and * - * use, please see the copyright notice at http://www5.in.tum.de/SGpp * - **************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #ifndef COMBIFULLGRID_HPP_ #define COMBIFULLGRID_HPP_ @@ -11,7 +10,10 @@ #include #include #include -#include "../utils/combigrid_utils.hpp" +#include + +#include +#include namespace combigrid { @@ -41,8 +43,7 @@ template class FullGrid { public: /** simplest Ctor with homogeneous levels */ - FullGrid(int dim, int level, bool hasBdrPoints = true, - const BasisFunctionBasis* basis = NULL) { + FullGrid(int dim, int level, bool hasBdrPoints = true, const BasisFunctionBasis* basis = NULL) { // set the basis function for the full grid if (basis == NULL) basis_ = LinearBasisFunction::getDefaultBasis(); @@ -67,9 +68,8 @@ class FullGrid { nrPoints_.resize(dim_); for (int j = 0; j < dim_; j++) { - nrPoints_[j] = - ((hasBoundaryPoints_[j] == true) ? (powerOfTwo[levels_[j]] + 1) - : (powerOfTwo[levels_[j]] - 1)); + nrPoints_[j] = ((hasBoundaryPoints_[j] == true) ? (powerOfTwo[levels_[j]] + 1) + : (powerOfTwo[levels_[j]] - 1)); offsets_[j] = nrElements_; nrElements_ = nrElements_ * nrPoints_[j]; } @@ -100,17 +100,15 @@ class FullGrid { nrPoints_.resize(dim_); for (int j = 0; j < dim_; j++) { - nrPoints_[j] = - ((hasBoundaryPoints_[j] == true) ? (powerOfTwo[levels_[j]] + 1) - : (powerOfTwo[levels_[j]] - 1)); + nrPoints_[j] = ((hasBoundaryPoints_[j] == true) ? (powerOfTwo[levels_[j]] + 1) + : (powerOfTwo[levels_[j]] - 1)); offsets_[j] = nrElements_; nrElements_ = nrElements_ * nrPoints_[j]; } } /** dimension adaptive Ctor */ - FullGrid(int dim, const std::vector& levels, - const std::vector& hasBdrPoints, + FullGrid(int dim, const std::vector& levels, const std::vector& hasBdrPoints, const BasisFunctionBasis* basis = NULL) { // set the basis function for the full grid if (basis == NULL) @@ -134,9 +132,8 @@ class FullGrid { nrPoints_.resize(dim_); for (int j = 0; j < dim_; j++) { - nrPoints_[j] = - ((hasBoundaryPoints_[j] == true) ? (powerOfTwo[levels_[j]] + 1) - : (powerOfTwo[levels_[j]] - 1)); + nrPoints_[j] = ((hasBoundaryPoints_[j] == true) ? (powerOfTwo[levels_[j]] + 1) + : (powerOfTwo[levels_[j]] - 1)); offsets_[j] = nrElements_; nrElements_ = nrElements_ * nrPoints_[j]; } @@ -201,16 +198,17 @@ class FullGrid { if (hasBoundaryPoints_[ii] == true) { aindex[ii] = (aindex[ii] < 0) ? 0 : aindex[ii]; - aindex[ii] = (aindex[ii] >= (int)(nrPoints_[ii] - 1)) - ? (int)(nrPoints_[ii] - 2) + aindex[ii] = (aindex[ii] >= static_cast(nrPoints_[ii] - 1)) + ? static_cast(nrPoints_[ii] - 2) : aindex[ii]; // calculate the coordinates - normcoord = normcoord - (double)aindex[ii]; + normcoord = normcoord - static_cast(aindex[ii]); } else { aindex[ii] = (aindex[ii] < 0) ? 0 : aindex[ii]; - aindex[ii] = (aindex[ii] >= (int)(nrPoints_[ii])) ? (int)(nrPoints_[ii]) - : aindex[ii]; - normcoord = normcoord - (double)aindex[ii]; + aindex[ii] = (aindex[ii] >= static_cast(nrPoints_[ii])) + ? static_cast(nrPoints_[ii]) + : aindex[ii]; + normcoord = normcoord - static_cast(aindex[ii]); if (aindex[ii] <= 0) { aindex[ii] = 1; @@ -221,11 +219,11 @@ class FullGrid { } else { // make extrapolation at the last cell (where there is no boundary // point) - if (aindex[ii] >= (int)nrPoints_[ii] - 1) { - aindex[ii] = (int)nrPoints_[ii] - 1; + if (aindex[ii] >= static_cast(nrPoints_[ii]) - 1) { + aindex[ii] = static_cast(nrPoints_[ii]) - 1; // extrapolation to the right this will be a >=1 number normcoord = coords[ii] * powerOfTwo[levels_[ii]] - - (double)aindex[ii]; // this should be 1 + ... + static_cast(aindex[ii]); // this should be 1 + ... // COMBIGRID_OUT_LEVEL3( verb , "FullG R , aindex[ii]:" << // aindex[ii]); } @@ -259,9 +257,8 @@ class FullGrid { // compute the "dim" dimensional basis function value(for one node) and // the corresponding vector index for (jj = dim_ - 1; jj >= 0; jj--) { - vv = (nrPoints_[jj] > 1) - ? (tmp_val & 1) - : 0; // if we have only one point then use the same + vv = + (nrPoints_[jj] > 1) ? (tmp_val & 1) : 0; // if we have only one point then use the same baseVal = baseVal * (FG_ELEMENT)intersect[2 * jj + vv]; i = i * nrPoints_[jj] + aindex[jj] + vv; tmp_val = tmp_val >> 1; @@ -271,8 +268,8 @@ class FullGrid { // the value // COMBIGRID_OUT_LEVEL3( verb , "Vect elem i:" << i << " , vect:" << // fullgridVector_[i]); - ret_val = (ii == 0) ? (baseVal * fullgridVector_[i]) - : (ret_val + baseVal * fullgridVector_[i]); + ret_val = + (ii == 0) ? (baseVal * fullgridVector_[i]) : (ret_val + baseVal * fullgridVector_[i]); } // COMBIGRID_OUT_LEVEL3( verb , "FullGrid::eval RET VAL:" << ret_val); @@ -335,13 +332,12 @@ class FullGrid { std::vector stretchings(dim_, NULL); for (int d = 0; d < dim_; d++) - stretchings[d] = combigrid::createStretchingMaker( - gridDomain_->get1DDomain(d).getStretchingType()); + stretchings[d] = + combigrid::createStretchingMaker(gridDomain_->get1DDomain(d).getStretchingType()); std::vector min = gridDomain_->getMin(); std::vector max = gridDomain_->getMax(); - GridDomain* new_domain = - new GridDomain(dim_, new_levels, min, max, stretchings); + GridDomain* new_domain = new GridDomain(dim_, new_levels, min, max, stretchings); new_grid->setDomain(new_domain); } @@ -349,9 +345,8 @@ class FullGrid { std::vector k_coords(dim_, 0.0); // current point coordinates std::vector k_idx(dim_, 0); - std::vector bb_idx(dim_, 0); // bounding box indices (only left) - std::vector bb_coords(2 * dim_, - 0.0); // bounding box coords (left and right) + std::vector bb_idx(dim_, 0); // bounding box indices (only left) + std::vector bb_coords(2 * dim_, 0.0); // bounding box coords (left and right) // get the next element of the new grid // speed-up somehow :> ??? @@ -372,10 +367,8 @@ class FullGrid { for (int d = 0; d < dim_; d++) { double x_d0 = bb_coords[d * 2]; double x_d1 = bb_coords[d * 2 + 1]; - interpol_coeffs[d * 2] = - calculate_interpolation_coeff(x_d0, x_d1, k_coords[d], -1); - interpol_coeffs[d * 2 + 1] = - calculate_interpolation_coeff(x_d0, x_d1, k_coords[d], +1); + interpol_coeffs[d * 2] = calculate_interpolation_coeff(x_d0, x_d1, k_coords[d], -1); + interpol_coeffs[d * 2 + 1] = calculate_interpolation_coeff(x_d0, x_d1, k_coords[d], +1); } // now perform the interpolation sum! @@ -442,8 +435,7 @@ class FullGrid { inline int bb_left(int j_k, int l, int k) const { int dL = k - l; - return (dL >= 0 ? (j_k / powerOfTwo[dL]) : j_k * powerOfTwo[-dL]) - - j_k / powerOfTwo[k]; + return (dL >= 0 ? (j_k / powerOfTwo[dL]) : j_k * powerOfTwo[-dL]) - j_k / powerOfTwo[k]; // at the end we subtract j_k/powerOfTwo[k] to ensure that points on the // right boundary (i.e. when j_k = 2^k // are mapped onto the point 2^l-1, instead of 2^l!!! this is done because @@ -461,24 +453,22 @@ class FullGrid { int ind = 0; int tmp_add = 0; - if (gridDomain_ == - NULL) { // default we are getting coordinates in the [0;1]^dim cube... + if (gridDomain_ == NULL) { // default we are getting coordinates in the [0;1]^dim cube... for (int j = 0; j < dim_; j++) { - ind = elemIndex % (int)(nrPoints_[j]); - elemIndex = elemIndex / (int)(nrPoints_[j]); + ind = elemIndex % static_cast(nrPoints_[j]); + elemIndex = elemIndex / static_cast(nrPoints_[j]); // set the coordinate based on if we have boundary points tmp_add = (hasBoundaryPoints_[j] == true) ? (0) : (1); - coords[j] = ((double)(ind + tmp_add)) * oneOverPowOfTwo[levels_[j]]; + coords[j] = (static_cast(ind + tmp_add)) * oneOverPowOfTwo[levels_[j]]; } } else { // we have a valid Domain for (int j = 0; j < dim_; j++) { - ind = elemIndex % (int)(nrPoints_[j]); - elemIndex = elemIndex / (int)(nrPoints_[j]); + ind = elemIndex % static_cast(nrPoints_[j]); + elemIndex = elemIndex / static_cast(nrPoints_[j]); // set the coordinate based on if we have boundary points tmp_add = (hasBoundaryPoints_[j] == true) ? (0) : (1); - (gridDomain_->get1DDomain(j)) - .transformUnitToReal(levels_[j], ind + tmp_add, coords[j]); + (gridDomain_->get1DDomain(j)).transformUnitToReal(levels_[j], ind + tmp_add, coords[j]); // COMBIGRID_OUT_LEVEL3( verb , "FullGrid::getCoords j:" << j << " , // coords[j]:" << coords[j]); } @@ -497,8 +487,7 @@ class FullGrid { * @param elementIndex [IN] the linear index of the element * @param levels [OUT] the levels of the point in the LI notation * @param indexes [OUT] the indexes of the point in the LI notation */ - void getLI(int elementIndex, std::vector& levels, - std::vector& indexes) const { + void getLI(int elementIndex, std::vector& levels, std::vector& indexes) const { int k, startindex, tmp_val; tmp_val = elementIndex; @@ -566,8 +555,7 @@ class FullGrid { * * @param linIndex [IN] the linear index * @param axisIndex [OUT] the returned vector index */ - inline void getVectorIndex(const int linIndex, - std::vector& axisIndex) const { + inline void getVectorIndex(const int linIndex, std::vector& axisIndex) const { int tmp = linIndex; for (int i = dim_ - 1; i >= 0; i--) { @@ -607,9 +595,7 @@ class FullGrid { /** the getters for the full grid vector */ inline std::vector& getElementVector() { return fullgridVector_; } - inline const std::vector& getElementVector() const { - return fullgridVector_; - } + inline const std::vector& getElementVector() const { return fullgridVector_; } /** return the offset in the full grid vector of the dimension */ inline int getOffset(int i) const { return offsets_[i]; } @@ -633,9 +619,7 @@ class FullGrid { inline std::vector& getSGppIndex() const { return (*sgppIndex_); } /** vector of flags to show if the dimension has boundary points*/ - inline const std::vector& returnBoundaryFlags() const { - return hasBoundaryPoints_; - } + inline const std::vector& returnBoundaryFlags() const { return hasBoundaryPoints_; } /** copies the input vector to the full grid vector * @param in [IN] input vector*/ @@ -700,13 +684,11 @@ class FullGrid { * */ - double calculate_interpolation_coeff(double x_0, double x_1, double x, - int direction) { + double calculate_interpolation_coeff(double x_0, double x_1, double x, int direction) { // error checking if (direction == 0) { - COMBIGRID_OUT_WRN( - "interpolation direciton parameter = 0. Returning 0.0!!!", __FILE__, - __LINE__) + COMBIGRID_OUT_WRN("interpolation direciton parameter = 0. Returning 0.0!!!", __FILE__, + __LINE__) return 0.0; } @@ -756,8 +738,7 @@ class FullGrid { * */ - void bounding_box(std::vector k_idx, std::vector new_levels, - std::vector& bb_idx, + void bounding_box(std::vector k_idx, std::vector new_levels, std::vector& bb_idx, std::vector& bb_coord) const { if (k_idx.size() != dim_ || bb_idx.size() != dim_) { COMBIGRID_OUT_WRN( @@ -822,14 +803,12 @@ class FullGrid { int binary_search(double x, std::vector grid_line) const { if (grid_line.size() == 0) { - COMBIGRID_OUT_ERR("Cannot search inside an empty array! Aborting!", - __FILE__, __LINE__); + COMBIGRID_OUT_ERR("Cannot search inside an empty array! Aborting!", __FILE__, __LINE__); return 0; } if (x < grid_line[0] || x > grid_line[grid_line.size() - 1]) { - COMBIGRID_OUT_ERR("Input element outside array bounds! Aborting!", - __FILE__, __LINE__); + COMBIGRID_OUT_ERR("Input element outside array bounds! Aborting!", __FILE__, __LINE__); return 0; } @@ -850,6 +829,6 @@ class FullGrid { return m; } }; -} +} // namespace combigrid #endif /* COMBIFULLGRID_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/fullgrid/GridContainer.hpp b/combigrid/src/sgpp/combigrid/fullgrid/GridContainer.hpp index 01be90547c..befaba21ee 100644 --- a/combigrid/src/sgpp/combigrid/fullgrid/GridContainer.hpp +++ b/combigrid/src/sgpp/combigrid/fullgrid/GridContainer.hpp @@ -1,15 +1,15 @@ -/* - * GridContainer.hpp - * - * Created on: 23 Jun 2014 - * Author: kenny - */ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef GRIDCONTAINER_HPP_ #define GRIDCONTAINER_HPP_ #include -#include "../utils/combigrid_utils.hpp" +#include + +#include /*** * @@ -67,10 +67,9 @@ class FGridContainer { int getMaxLevel() { int max = 1; - int DIM = (int)_fullgrid_levels.size(); + int DIM = static_cast(_fullgrid_levels.size()); - for (int d = 0; d < DIM; d++) - max = _fullgrid_levels[d] > max ? _fullgrid_levels[d] : max; + for (int d = 0; d < DIM; d++) max = _fullgrid_levels[d] > max ? _fullgrid_levels[d] : max; return max; } @@ -98,13 +97,11 @@ class FGridContainer { * the default LinearBasisFunction is set! * */ - FGridContainer(const std::vector levels, - const std::vector& hasBoundaryPts, _Tp coef, + FGridContainer(const std::vector levels, const std::vector& hasBoundaryPts, _Tp coef, BasisFunctionBasis* basis = NULL) { int dim = static_cast(levels.size()); - _fullgrid = - new combigrid::FullGrid<_Tp>(dim, levels, hasBoundaryPts, basis); + _fullgrid = new combigrid::FullGrid<_Tp>(dim, levels, hasBoundaryPts, basis); _fullgrid_levels = levels; _coefficient = coef; _active = true; @@ -130,6 +127,6 @@ class FGridContainer { if (_fullgrid != NULL) _fullgrid->createFullGrid(); } }; -} +} // namespace combigrid #endif /* GRIDCONTAINER_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/plotter/GridPlotter.hpp b/combigrid/src/sgpp/combigrid/plotter/GridPlotter.hpp index b36fd41be3..98e1795962 100644 --- a/combigrid/src/sgpp/combigrid/plotter/GridPlotter.hpp +++ b/combigrid/src/sgpp/combigrid/plotter/GridPlotter.hpp @@ -1,9 +1,8 @@ -/* **************************************************************************** - * Copyright (C) 2011 Technische Universitaet Muenchen * - * This file is part of the SG++ project. For conditions of distribution and * - * use, please see the copyright notice at http://www5.in.tum.de/SGpp * - **************************************************************************** */ -// @author Janos Benk (benk@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #ifndef GRIDPLOTTER_HPP_ #define GRIDPLOTTER_HPP_ @@ -51,30 +50,23 @@ class GridPlotter { /** plot one Full grid */ static void plotFullGrid(const std::string& filePath, const FullGrid<_Tp>* fg, - const std::vector& globalCoord_in, - int resolution = 0) { + const std::vector& globalCoord_in, int resolution = 0) { combigrid::Evaluable<_Tp> obj(fg); int dim = fg->getDimension(); - plotObject(dim, filePath, &obj, fg->getDomain(), globalCoord_in, - resolution); + plotObject(dim, filePath, &obj, fg->getDomain(), globalCoord_in, resolution); } /** plot one combination grid */ - static void plotCombiGrid(const std::string& filePath, - const CombiGrid<_Tp>* cg, - const std::vector& globalCoord_in, - int resolution = 0) { + static void plotCombiGrid(const std::string& filePath, const CombiGrid<_Tp>* cg, + const std::vector& globalCoord_in, int resolution = 0) { combigrid::Evaluable<_Tp> obj(cg); int dim = cg->getFullGrid(0)->getDimension(); - plotObject(dim, filePath, &obj, cg->getDomain(), globalCoord_in, - resolution); + plotObject(dim, filePath, &obj, cg->getDomain(), globalCoord_in, resolution); } private: - static void plotObject(int dim, const std::string& filePath, - const combigrid::Evaluable<_Tp>* obj, - const GridDomain* domain, - const std::vector& globalCoord_in, + static void plotObject(int dim, const std::string& filePath, const combigrid::Evaluable<_Tp>* obj, + const GridDomain* domain, const std::vector& globalCoord_in, int resolution) { std::vector<_Tp> result(0); std::vector globalCoord = globalCoord_in; @@ -103,8 +95,7 @@ class GridPlotter { for (int ii = 0; ii < resolution; ii++) { globalCoord[0] = minX + - (maxX - minX) * (static_cast(ii) / - static_cast(resolution - 1)); + (maxX - minX) * (static_cast(ii) / static_cast(resolution - 1)); result[ii] = obj->eval(globalCoord); } @@ -114,10 +105,9 @@ class GridPlotter { myfile << "X = [ " << minX; for (int ii = 1; ii < resolution; ii++) { - myfile << " , " - << (minX + - (maxX - minX) * (static_cast(ii) / - static_cast(resolution - 1))); + myfile << " , " << (minX + + (maxX - minX) * + (static_cast(ii) / static_cast(resolution - 1))); } myfile << "]; \n "; @@ -150,12 +140,10 @@ class GridPlotter { for (int jj = 0; jj < resolution; jj++) { globalCoord[0] = minX + - (maxX - minX) * (static_cast(ii) / - static_cast(resolution - 1)); + (maxX - minX) * (static_cast(ii) / static_cast(resolution - 1)); globalCoord[1] = minY + - (maxY - minY) * (static_cast(jj) / - static_cast(resolution - 1)); + (maxY - minY) * (static_cast(jj) / static_cast(resolution - 1)); result[ii * resolution + jj] = obj->eval(globalCoord); } } @@ -165,20 +153,18 @@ class GridPlotter { myfile << "X = [ " << minX; for (int ii = 1; ii < resolution; ii++) { - myfile << " , " - << (minX + - (maxX - minX) * (static_cast(ii) / - static_cast(resolution - 1))); + myfile << " , " << (minX + + (maxX - minX) * + (static_cast(ii) / static_cast(resolution - 1))); } myfile << "]; \n "; myfile << "Y = [ " << minY; for (int ii = 1; ii < resolution; ii++) { - myfile << " , " - << (minY + - (maxY - minY) * (static_cast(ii) / - static_cast(resolution - 1))); + myfile << " , " << (minY + + (maxY - minY) * + (static_cast(ii) / static_cast(resolution - 1))); } myfile << "]; \n "; @@ -202,8 +188,7 @@ class GridPlotter { result.resize(domain->get1DDomain(0).axisScaling().size()); // loop and evaluate points - for (unsigned int ii = 0; - ii < domain->get1DDomain(0).axisScaling().size(); ii++) { + for (unsigned int ii = 0; ii < domain->get1DDomain(0).axisScaling().size(); ii++) { globalCoord[0] = domain->get1DDomain(0).axisScaling()[ii]; result[ii] = obj->eval(globalCoord); } @@ -213,16 +198,14 @@ class GridPlotter { myfile.open(filePath.c_str()); myfile << "X = [ " << domain->get1DDomain(0).axisScaling()[0]; - for (unsigned int ii = 1; - ii < domain->get1DDomain(0).axisScaling().size(); ii++) { + for (unsigned int ii = 1; ii < domain->get1DDomain(0).axisScaling().size(); ii++) { myfile << " , " << domain->get1DDomain(0).axisScaling()[ii]; } myfile << "]; \n "; myfile << "res = [ " << result[0]; - for (unsigned int ii = 1; - ii < domain->get1DDomain(0).axisScaling().size(); ii++) { + for (unsigned int ii = 1; ii < domain->get1DDomain(0).axisScaling().size(); ii++) { myfile << " , " << result[ii]; } @@ -235,10 +218,8 @@ class GridPlotter { // loop and evaluate points double res = 0.0; - for (unsigned int ii = 0; - ii < domain->get1DDomain(0).axisScaling().size(); ii++) { - for (unsigned int jj = 0; - jj < domain->get1DDomain(1).axisScaling().size(); jj++) { + for (unsigned int ii = 0; ii < domain->get1DDomain(0).axisScaling().size(); ii++) { + for (unsigned int jj = 0; jj < domain->get1DDomain(1).axisScaling().size(); jj++) { globalCoord[0] = domain->get1DDomain(0).axisScaling()[ii]; globalCoord[1] = domain->get1DDomain(1).axisScaling()[jj]; res = obj->eval(globalCoord); @@ -250,25 +231,22 @@ class GridPlotter { myfile.open(filePath.c_str()); myfile << "X = [ " << domain->get1DDomain(0).axisScaling()[0]; - for (unsigned int ii = 1; - ii < domain->get1DDomain(0).axisScaling().size(); ii++) { + for (unsigned int ii = 1; ii < domain->get1DDomain(0).axisScaling().size(); ii++) { myfile << " , " << domain->get1DDomain(0).axisScaling()[ii]; } myfile << "]; \n "; myfile << "Y = [ " << domain->get1DDomain(1).axisScaling()[0]; - for (unsigned int ii = 1; - ii < domain->get1DDomain(1).axisScaling().size(); ii++) { + for (unsigned int ii = 1; ii < domain->get1DDomain(1).axisScaling().size(); ii++) { myfile << " , " << domain->get1DDomain(1).axisScaling()[ii]; } myfile << "]; \n "; myfile << "res = [ " << result[0]; - for (unsigned int ii = 1; - ii < domain->get1DDomain(0).axisScaling().size() * - domain->get1DDomain(1).axisScaling().size(); + for (unsigned int ii = 1; ii < domain->get1DDomain(0).axisScaling().size() * + domain->get1DDomain(1).axisScaling().size(); ii++) { if ((ii % domain->get1DDomain(1).axisScaling().size()) == 0) { myfile << " ; " << result[ii]; diff --git a/combigrid/src/sgpp/combigrid/quadratures/AbstractQuadrature.hpp b/combigrid/src/sgpp/combigrid/quadratures/AbstractQuadrature.hpp index 435fcb3c7a..de0048aee6 100644 --- a/combigrid/src/sgpp/combigrid/quadratures/AbstractQuadrature.hpp +++ b/combigrid/src/sgpp/combigrid/quadratures/AbstractQuadrature.hpp @@ -1,17 +1,16 @@ -/* **************************************************************************** -* Copyright (C) 2015 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Petar Tzenov +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef ABSTRACTQUADRATURE_HPP_ #define ABSTRACTQUADRATURE_HPP_ #include #include +#include + #include -#include "../utils/combigrid_utils.hpp" namespace combigrid { @@ -42,16 +41,13 @@ class AbstractQuadratureRule { *information is stored on the points of the * underlying full grids... */ - virtual _Tp integrate(CombiGrid<_Tp>* grids, - _Tp (*f)(std::vector) = NULL) = 0; + virtual _Tp integrate(CombiGrid<_Tp>* grids, _Tp (*f)(std::vector) = NULL) = 0; virtual ~AbstractQuadratureRule() { ; } protected: - void getGridValues(FullGrid<_Tp>* grid, bool badstretching, - AbstractStretchingMaker* stretching, - std::vector<_Tp>* f_values, - _Tp (*f)(std::vector)) { + void getGridValues(FullGrid<_Tp>* grid, bool badstretching, AbstractStretchingMaker* stretching, + std::vector<_Tp>* f_values, _Tp (*f)(std::vector)) { int dim = grid->getDimension(); std::vector domains; GridDomain* domain = grid->getDomain(); @@ -62,8 +58,7 @@ class AbstractQuadratureRule { } } - unsigned int num_elem = - grid->getNrElements(); // get the total number of grid points + unsigned int num_elem = grid->getNrElements(); // get the total number of grid points // precomupte the function values depending on whether or not the user wants // to integrate an external function @@ -76,14 +71,12 @@ class AbstractQuadratureRule { if (f == NULL) { if (badstretching) { - std::vector > stretchings(dim, - std::vector()); + std::vector > stretchings(dim, std::vector()); std::vector > jacobs(dim, std::vector()); for (int d = 0; d < dim; d++) stretching->get1DStretching(grid->getLevels()[d], domain->getMin()[d], - domain->getMax()[d], &(stretchings[d]), - &(jacobs[d])); + domain->getMax()[d], &(stretchings[d]), &(jacobs[d])); for (unsigned int j = 0; j < num_elem; j++) { grid->getVectorIndex(j, indices); @@ -121,20 +114,17 @@ class AbstractQuadratureRule { } (*f_values)[j] = - grid->getElementVector()[j] * - jacobian_j; // simply pick out the value on the grid... + grid->getElementVector()[j] * jacobian_j; // simply pick out the value on the grid... } } } else { // f !=NULL if (badstretching) { - std::vector > stretchings(dim, - std::vector()); + std::vector > stretchings(dim, std::vector()); std::vector > jacobs(dim, std::vector()); for (int d = 0; d < dim; d++) stretching->get1DStretching(grid->getLevels()[d], domain->getMin()[d], - domain->getMax()[d], &(stretchings[d]), - &(jacobs[d])); + domain->getMax()[d], &(stretchings[d]), &(jacobs[d])); for (unsigned int j = 0; j < num_elem; j++) { grid->getVectorIndex(j, indices); @@ -158,9 +148,7 @@ class AbstractQuadratureRule { jacobian_j *= (_Tp)domains[d].axisJacobian()[indices[d]]; } - (*f_values)[j] = - f(coords) * - jacobian_j; // simply pick out the value on the grid... + (*f_values)[j] = f(coords) * jacobian_j; // simply pick out the value on the grid... } } } diff --git a/combigrid/src/sgpp/combigrid/quadratures/BasuQuadrature.cpp b/combigrid/src/sgpp/combigrid/quadratures/BasuQuadrature.cpp index 94d5f068f1..1e41c86c7a 100644 --- a/combigrid/src/sgpp/combigrid/quadratures/BasuQuadrature.cpp +++ b/combigrid/src/sgpp/combigrid/quadratures/BasuQuadrature.cpp @@ -1,13 +1,10 @@ -/* **************************************************************************** -* Copyright (C) 2015 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Petar Tzenov +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include #include -#include template combigrid::BasuQuadrature<_Tp>::BasuQuadrature(int max_lvl) { @@ -112,8 +109,7 @@ _Tp combigrid::BasuQuadrature<_Tp>::integrate(CombiGrid<_Tp>* grids, error_flag++; } else { result += - (_Tp)grids->getCoef(j) * - basu_full_grid(dim, f, grids->getFullGrid(j), badstretching); + (_Tp)grids->getCoef(j) * basu_full_grid(dim, f, grids->getFullGrid(j), badstretching); } } } @@ -125,16 +121,14 @@ _Tp combigrid::BasuQuadrature<_Tp>::integrate(CombiGrid<_Tp>* grids, } template -_Tp combigrid::BasuQuadrature<_Tp>::basu_full_grid( - int dim, _Tp (*f)(std::vector), FGridContainer<_Tp>* gridContainer, - bool badstretching) { +_Tp combigrid::BasuQuadrature<_Tp>::basu_full_grid(int dim, _Tp (*f)(std::vector), + FGridContainer<_Tp>* gridContainer, + bool badstretching) { _Tp result = 0.0f; - FullGrid<_Tp>* grid = - gridContainer->fg(); // obtain a pointer to the fullgrid + FullGrid<_Tp>* grid = gridContainer->fg(); // obtain a pointer to the fullgrid std::vector<_Tp> f_values; CombiBasuStretching stretching = CombiBasuStretching(); - AbstractQuadratureRule<_Tp>::getGridValues(grid, badstretching, &stretching, - &f_values, f); + AbstractQuadratureRule<_Tp>::getGridValues(grid, badstretching, &stretching, &f_values, f); /**check if we have a fully infinite interval to integrate over!!! */ std::vector domains; @@ -146,8 +140,7 @@ _Tp combigrid::BasuQuadrature<_Tp>::basu_full_grid( for (int d = 0; d < dim; d++) { Domain1D dom = domain->get1DDomain(d); - if (dom.getMinDomain() == n_INF && dom.getMaxDomain() == p_INF) - fully_infinite[d] = true; + if (dom.getMinDomain() == n_INF && dom.getMaxDomain() == p_INF) fully_infinite[d] = true; } } @@ -161,8 +154,7 @@ _Tp combigrid::BasuQuadrature<_Tp>::basu_full_grid( *functional values by the weights * and sum the results up... */ - unsigned int num_elem = - grid->getNrElements(); // get the total number of grid points + unsigned int num_elem = grid->getNrElements(); // get the total number of grid points std::vector indices(dim, 0); std::vector levels = gridContainer->getFGLevels(); @@ -197,8 +189,7 @@ _Tp combigrid::BasuQuadrature<_Tp>::basu_full_grid( } template -void combigrid::BasuQuadrature<_Tp>::calculateCoefficients(int in_level, - _Tp** out_coefs) { +void combigrid::BasuQuadrature<_Tp>::calculateCoefficients(int in_level, _Tp** out_coefs) { int N = powerOfTwo[in_level]; int n = powerOfTwo[in_level - 1]; // is equal to (N-1)/2; *out_coefs = reinterpret_cast<_Tp*>(malloc((N + 1) * sizeof(_Tp))); @@ -207,8 +198,7 @@ void combigrid::BasuQuadrature<_Tp>::calculateCoefficients(int in_level, double factor = 2 * M_PI * s / N; double w_s = 1.0 / N; - for (int p = 1; p < n - 1; p++) - w_s += (2.0 / N) * cos(factor * p) / (1 - 4 * p * p); + for (int p = 1; p < n - 1; p++) w_s += (2.0 / N) * cos(factor * p) / (1 - 4 * p * p); w_s += (1.0 / N) * cos(factor * (n - 1)) / (1 - 4 * (n - 1) * (n - 1)); diff --git a/combigrid/src/sgpp/combigrid/quadratures/BasuQuadrature.hpp b/combigrid/src/sgpp/combigrid/quadratures/BasuQuadrature.hpp index 15f7403cf5..5de9645b2d 100644 --- a/combigrid/src/sgpp/combigrid/quadratures/BasuQuadrature.hpp +++ b/combigrid/src/sgpp/combigrid/quadratures/BasuQuadrature.hpp @@ -1,9 +1,7 @@ -/* **************************************************************************** -* Copyright (C) 2015 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Petar Tzenov +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef BASUQUADRATURE_HPP_ #define BASUQUADRATURE_HPP_ @@ -47,8 +45,8 @@ class BasuQuadrature : public AbstractQuadratureRule<_Tp> { * Do a full grid integration over a single CGF type of grid. * */ - _Tp basu_full_grid(int dim, _Tp (*f)(std::vector), - FGridContainer<_Tp>* gridContainer, bool interpolate); + _Tp basu_full_grid(int dim, _Tp (*f)(std::vector), FGridContainer<_Tp>* gridContainer, + bool interpolate); }; } // namespace combigrid diff --git a/combigrid/src/sgpp/combigrid/quadratures/ClenshawCurtisQuadrature.cpp b/combigrid/src/sgpp/combigrid/quadratures/ClenshawCurtisQuadrature.cpp index f63b2d6765..120401c477 100644 --- a/combigrid/src/sgpp/combigrid/quadratures/ClenshawCurtisQuadrature.cpp +++ b/combigrid/src/sgpp/combigrid/quadratures/ClenshawCurtisQuadrature.cpp @@ -1,18 +1,13 @@ -/* **************************************************************************** -* Copyright (C) 2015 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Petar Tzenov +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include #include -#include - template -combigrid::ClenshawCurtisQuadrature<_Tp>::ClenshawCurtisQuadrature( - int max_lvl) { +combigrid::ClenshawCurtisQuadrature<_Tp>::ClenshawCurtisQuadrature(int max_lvl) { if (max_lvl >= 2) { // 5 pts? MAX_LEVELS = max_lvl; } else { @@ -40,8 +35,7 @@ combigrid::ClenshawCurtisQuadrature<_Tp>::ClenshawCurtisQuadrature( * coefs * we start from level 1, up to level MAX_LEVELS ... * */ - ClenshawCurtisQuadrature<_Tp>::calculateCoefficients(d, - coefficients + d - 1); + ClenshawCurtisQuadrature<_Tp>::calculateCoefficients(d, coefficients + d - 1); } } @@ -59,8 +53,8 @@ combigrid::ClenshawCurtisQuadrature<_Tp>::~ClenshawCurtisQuadrature() { } template -_Tp combigrid::ClenshawCurtisQuadrature<_Tp>::integrate( - CombiGrid<_Tp>* grids, _Tp (*f)(std::vector)) { +_Tp combigrid::ClenshawCurtisQuadrature<_Tp>::integrate(CombiGrid<_Tp>* grids, + _Tp (*f)(std::vector)) { int dim = grids->getDim(); /** @@ -114,8 +108,7 @@ _Tp combigrid::ClenshawCurtisQuadrature<_Tp>::integrate( // if error has occured simply skip through all the iterations until you // reach the end... if (grids->getFullGrid(j)->isActive()) { - if (static_cast(grids->getFullGrid(j)->getMaxLevel()) > - MAX_LEVELS) { + if (static_cast(grids->getFullGrid(j)->getMaxLevel()) > MAX_LEVELS) { // problem with parallelization - if this error occurs // the // end result might not be set @@ -127,8 +120,7 @@ _Tp combigrid::ClenshawCurtisQuadrature<_Tp>::integrate( error_flag++; } else { result += (_Tp)grids->getCoef(j) * - clenshaw_curtis_fullgrid(dim, f, grids->getFullGrid(j), - badstretching); + clenshaw_curtis_fullgrid(dim, f, grids->getFullGrid(j), badstretching); } } } @@ -144,12 +136,10 @@ _Tp combigrid::ClenshawCurtisQuadrature<_Tp>::clenshaw_curtis_fullgrid( int dim, _Tp (*f)(std::vector), FGridContainer<_Tp>* gridContainer, bool badstretching) { _Tp result = 0.0f; - FullGrid<_Tp>* grid = - gridContainer->fg(); // obtain a pointer to the fullgrid + FullGrid<_Tp>* grid = gridContainer->fg(); // obtain a pointer to the fullgrid std::vector<_Tp> f_values; CombiChebyshevStretching stretching = CombiChebyshevStretching(); - AbstractQuadratureRule<_Tp>::getGridValues(grid, badstretching, &stretching, - &f_values, f); + AbstractQuadratureRule<_Tp>::getGridValues(grid, badstretching, &stretching, &f_values, f); /*** * At this point of the evaluation we already have the functional values @@ -161,8 +151,7 @@ _Tp combigrid::ClenshawCurtisQuadrature<_Tp>::clenshaw_curtis_fullgrid( *functional values by the weights * and sum the results up... */ - unsigned int num_elem = - grid->getNrElements(); // get the total number of grid points + unsigned int num_elem = grid->getNrElements(); // get the total number of grid points std::vector indices(dim, 0); std::vector levels = gridContainer->getFGLevels(); @@ -184,8 +173,8 @@ _Tp combigrid::ClenshawCurtisQuadrature<_Tp>::clenshaw_curtis_fullgrid( } template -void combigrid::ClenshawCurtisQuadrature<_Tp>::calculateCoefficients( - int in_level, _Tp** out_coefs) { +void combigrid::ClenshawCurtisQuadrature<_Tp>::calculateCoefficients(int in_level, + _Tp** out_coefs) { int N = powerOfTwo[in_level] + 1; int n = powerOfTwo[in_level - 1]; // is equal to (N-1)/2; @@ -198,8 +187,7 @@ void combigrid::ClenshawCurtisQuadrature<_Tp>::calculateCoefficients( double w_i = 0.0f; double factor = 2.0 * M_PI * (i - 1.0) / (N - 1.0); - for (int j = 1; j < n; j++) - w_i += 2.0 * cos(factor * j) / (1.0 - 4.0 * j * j); + for (int j = 1; j < n; j++) w_i += 2.0 * cos(factor * j) / (1.0 - 4.0 * j * j); w_i += cos(factor * n) / (1.0 - 4.0 * n * n); w_i = 2.0 * (1.0 + w_i) / (N - 1.0); diff --git a/combigrid/src/sgpp/combigrid/quadratures/ClenshawCurtisQuadrature.hpp b/combigrid/src/sgpp/combigrid/quadratures/ClenshawCurtisQuadrature.hpp index d08357e3c6..a533bf4ea0 100644 --- a/combigrid/src/sgpp/combigrid/quadratures/ClenshawCurtisQuadrature.hpp +++ b/combigrid/src/sgpp/combigrid/quadratures/ClenshawCurtisQuadrature.hpp @@ -1,9 +1,7 @@ -/* **************************************************************************** -* Copyright (C) 2015 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Petar Tzenov +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef CLENSHAWCURTISQUADRATURE_HPP_ #define CLENSHAWCURTISQUADRATURE_HPP_ @@ -74,8 +72,7 @@ class ClenshawCurtisQuadrature : public AbstractQuadratureRule<_Tp> { * */ _Tp clenshaw_curtis_fullgrid(int dim, _Tp (*f)(std::vector), - FGridContainer<_Tp> *gridContainer, - bool interpolate); + FGridContainer<_Tp> *gridContainer, bool interpolate); }; } // namespace combigrid diff --git a/combigrid/src/sgpp/combigrid/quadratures/GaussPattersonQuadrature.cpp b/combigrid/src/sgpp/combigrid/quadratures/GaussPattersonQuadrature.cpp index 01f005d82f..e069efef5e 100644 --- a/combigrid/src/sgpp/combigrid/quadratures/GaussPattersonQuadrature.cpp +++ b/combigrid/src/sgpp/combigrid/quadratures/GaussPattersonQuadrature.cpp @@ -1,16 +1,13 @@ -/* **************************************************************************** -* Copyright (C) 2015 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Petar Tzenov +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include #include template -combigrid::GaussPattersonQuadrature<_Tp>::GaussPattersonQuadrature( - int max_lvl) { +combigrid::GaussPattersonQuadrature<_Tp>::GaussPattersonQuadrature(int max_lvl) { if (max_lvl >= 1 && max_lvl <= 9) { MAX_LEVELS = max_lvl; } else { @@ -38,8 +35,7 @@ combigrid::GaussPattersonQuadrature<_Tp>::GaussPattersonQuadrature( * coefs * we start from level 1, up to level MAX_LEVELS ... * */ - GaussPattersonQuadrature<_Tp>::calculateCoefficients(d, - coefficients + d - 1); + GaussPattersonQuadrature<_Tp>::calculateCoefficients(d, coefficients + d - 1); } } @@ -58,8 +54,8 @@ combigrid::GaussPattersonQuadrature<_Tp>::~GaussPattersonQuadrature() { } template -_Tp combigrid::GaussPattersonQuadrature<_Tp>::integrate( - CombiGrid<_Tp>* grids, _Tp (*f)(std::vector)) { +_Tp combigrid::GaussPattersonQuadrature<_Tp>::integrate(CombiGrid<_Tp>* grids, + _Tp (*f)(std::vector)) { _Tp result = 0.0f; int dim = grids->getDim(); /** @@ -117,8 +113,7 @@ _Tp combigrid::GaussPattersonQuadrature<_Tp>::integrate( error_flag++; } else { result += (_Tp)grids->getCoef(j) * - gauss_patterson_fullGrid(dim, f, grids->getFullGrid(j), - badstretching); + gauss_patterson_fullGrid(dim, f, grids->getFullGrid(j), badstretching); } } } @@ -134,12 +129,10 @@ _Tp combigrid::GaussPattersonQuadrature<_Tp>::gauss_patterson_fullGrid( int dim, _Tp (*f)(std::vector), FGridContainer<_Tp>* gridContainer, bool badstretching) { _Tp result = 0.0f; - FullGrid<_Tp>* grid = - gridContainer->fg(); // obtain a pointer to the fullgrid + FullGrid<_Tp>* grid = gridContainer->fg(); // obtain a pointer to the fullgrid std::vector<_Tp> f_values; CombiLegendreStretching stretching = CombiLegendreStretching(); - AbstractQuadratureRule<_Tp>::getGridValues(grid, badstretching, &stretching, - &f_values, f); + AbstractQuadratureRule<_Tp>::getGridValues(grid, badstretching, &stretching, &f_values, f); /*** * At this point of the evaluation we already have the functional values @@ -151,8 +144,7 @@ _Tp combigrid::GaussPattersonQuadrature<_Tp>::gauss_patterson_fullGrid( *functional values by the weights * and sum the results up... */ - unsigned int num_elem = - grid->getNrElements(); // get the total number of grid points + unsigned int num_elem = grid->getNrElements(); // get the total number of grid points std::vector indices(dim, 0); std::vector levels = gridContainer->getFGLevels(); @@ -175,8 +167,8 @@ _Tp combigrid::GaussPattersonQuadrature<_Tp>::gauss_patterson_fullGrid( } template -void combigrid::GaussPattersonQuadrature<_Tp>::calculateCoefficients( - int in_level, _Tp** out_coefs) { +void combigrid::GaussPattersonQuadrature<_Tp>::calculateCoefficients(int in_level, + _Tp** out_coefs) { int N = powerOfTwo[in_level] + 1; *out_coefs = reinterpret_cast<_Tp*>(malloc(N * sizeof(_Tp))); @@ -187,566 +179,1066 @@ void combigrid::GaussPattersonQuadrature<_Tp>::calculateCoefficients( } if (in_level == 2) { - double tmp_coefs[5] = {0.0, 0.555555555555555555556E+00, - 0.888888888888888888889E+00, + double tmp_coefs[5] = {0.0, 0.555555555555555555556E+00, 0.888888888888888888889E+00, 0.555555555555555555556E+00, 0.0}; for (int d = 0; d < N; d++) (*out_coefs)[d] = (_Tp)tmp_coefs[d]; } if (in_level == 3) { - double tmp_coefs[9] = { - 0.0, 0.104656226026467265194E+00, - 0.268488089868333440729E+00, 0.401397414775962222905E+00, - 0.450916538658474142345E+00, 0.401397414775962222905E+00, - 0.268488089868333440729E+00, 0.104656226026467265194E+00, - 0.0}; + double tmp_coefs[9] = {0.0, + 0.104656226026467265194E+00, + 0.268488089868333440729E+00, + 0.401397414775962222905E+00, + 0.450916538658474142345E+00, + 0.401397414775962222905E+00, + 0.268488089868333440729E+00, + 0.104656226026467265194E+00, + 0.0}; for (int d = 0; d < N; d++) (*out_coefs)[d] = (_Tp)tmp_coefs[d]; } if (in_level == 4) { - double tmp_coefs[17] = { - 0.0, 0.0170017196299402603390E+00, - 0.0516032829970797396969E+00, 0.0929271953151245376859E+00, - 0.134415255243784220360E+00, 0.171511909136391380787E+00, - 0.200628529376989021034E+00, 0.219156858401587496404E+00, - 0.225510499798206687386E+00, 0.219156858401587496404E+00, - 0.200628529376989021034E+00, 0.171511909136391380787E+00, - 0.134415255243784220360E+00, 0.0929271953151245376859E+00, - 0.0516032829970797396969E+00, 0.0170017196299402603390E+00, - 0.0}; + double tmp_coefs[17] = {0.0, + 0.0170017196299402603390E+00, + 0.0516032829970797396969E+00, + 0.0929271953151245376859E+00, + 0.134415255243784220360E+00, + 0.171511909136391380787E+00, + 0.200628529376989021034E+00, + 0.219156858401587496404E+00, + 0.225510499798206687386E+00, + 0.219156858401587496404E+00, + 0.200628529376989021034E+00, + 0.171511909136391380787E+00, + 0.134415255243784220360E+00, + 0.0929271953151245376859E+00, + 0.0516032829970797396969E+00, + 0.0170017196299402603390E+00, + 0.0}; for (int d = 0; d < N; d++) (*out_coefs)[d] = (_Tp)tmp_coefs[d]; } if (in_level == 5) { - double tmp_coefs[33] = { - 0.0, 0.00254478079156187441540E+00, - 0.00843456573932110624631E+00, 0.0164460498543878109338E+00, - 0.0258075980961766535646E+00, 0.0359571033071293220968E+00, - 0.0464628932617579865414E+00, 0.0569795094941233574122E+00, - 0.0672077542959907035404E+00, 0.0768796204990035310427E+00, - 0.0857559200499903511542E+00, 0.0936271099812644736167E+00, - 0.100314278611795578771E+00, 0.105669893580234809744E+00, - 0.109578421055924638237E+00, 0.111956873020953456880E+00, - 0.112755256720768691607E+00, 0.111956873020953456880E+00, - 0.109578421055924638237E+00, 0.105669893580234809744E+00, - 0.100314278611795578771E+00, 0.0936271099812644736167E+00, - 0.0857559200499903511542E+00, 0.0768796204990035310427E+00, - 0.0672077542959907035404E+00, 0.0569795094941233574122E+00, - 0.0464628932617579865414E+00, 0.0359571033071293220968E+00, - 0.0258075980961766535646E+00, 0.0164460498543878109338E+00, - 0.00843456573932110624631E+00, 0.00254478079156187441540E+00, - 0.0}; + double tmp_coefs[33] = {0.0, + 0.00254478079156187441540E+00, + 0.00843456573932110624631E+00, + 0.0164460498543878109338E+00, + 0.0258075980961766535646E+00, + 0.0359571033071293220968E+00, + 0.0464628932617579865414E+00, + 0.0569795094941233574122E+00, + 0.0672077542959907035404E+00, + 0.0768796204990035310427E+00, + 0.0857559200499903511542E+00, + 0.0936271099812644736167E+00, + 0.100314278611795578771E+00, + 0.105669893580234809744E+00, + 0.109578421055924638237E+00, + 0.111956873020953456880E+00, + 0.112755256720768691607E+00, + 0.111956873020953456880E+00, + 0.109578421055924638237E+00, + 0.105669893580234809744E+00, + 0.100314278611795578771E+00, + 0.0936271099812644736167E+00, + 0.0857559200499903511542E+00, + 0.0768796204990035310427E+00, + 0.0672077542959907035404E+00, + 0.0569795094941233574122E+00, + 0.0464628932617579865414E+00, + 0.0359571033071293220968E+00, + 0.0258075980961766535646E+00, + 0.0164460498543878109338E+00, + 0.00843456573932110624631E+00, + 0.00254478079156187441540E+00, + 0.0}; for (int d = 0; d < N; d++) (*out_coefs)[d] = (_Tp)tmp_coefs[d]; } if (in_level == 6) { - double tmp_coefs[65] = { - 0.0, 0.000363221481845530659694E+00, - 0.00126515655623006801137E+00, 0.00257904979468568827243E+00, - 0.00421763044155885483908E+00, 0.00611550682211724633968E+00, - 0.00822300795723592966926E+00, 0.0104982469096213218983E+00, - 0.0129038001003512656260E+00, 0.0154067504665594978021E+00, - 0.0179785515681282703329E+00, 0.0205942339159127111492E+00, - 0.0232314466399102694433E+00, 0.0258696793272147469108E+00, - 0.0284897547458335486125E+00, 0.0310735511116879648799E+00, - 0.0336038771482077305417E+00, 0.0360644327807825726401E+00, - 0.0384398102494555320386E+00, 0.0407155101169443189339E+00, - 0.0428779600250077344929E+00, 0.0449145316536321974143E+00, - 0.0468135549906280124026E+00, 0.0485643304066731987159E+00, - 0.0501571393058995374137E+00, 0.0515832539520484587768E+00, - 0.0528349467901165198621E+00, 0.0539054993352660639269E+00, - 0.0547892105279628650322E+00, 0.0554814043565593639878E+00, - 0.0559784365104763194076E+00, 0.0562776998312543012726E+00, - 0.0563776283603847173877E+00, 0.0562776998312543012726E+00, - 0.0559784365104763194076E+00, 0.0554814043565593639878E+00, - 0.0547892105279628650322E+00, 0.0539054993352660639269E+00, - 0.0528349467901165198621E+00, 0.0515832539520484587768E+00, - 0.0501571393058995374137E+00, 0.0485643304066731987159E+00, - 0.0468135549906280124026E+00, 0.0449145316536321974143E+00, - 0.0428779600250077344929E+00, 0.0407155101169443189339E+00, - 0.0384398102494555320386E+00, 0.0360644327807825726401E+00, - 0.0336038771482077305417E+00, 0.0310735511116879648799E+00, - 0.0284897547458335486125E+00, 0.0258696793272147469108E+00, - 0.0232314466399102694433E+00, 0.0205942339159127111492E+00, - 0.0179785515681282703329E+00, 0.0154067504665594978021E+00, - 0.0129038001003512656260E+00, 0.0104982469096213218983E+00, - 0.00822300795723592966926E+00, 0.00611550682211724633968E+00, - 0.00421763044155885483908E+00, 0.00257904979468568827243E+00, - 0.00126515655623006801137E+00, 0.000363221481845530659694E+00, - 0.0}; + double tmp_coefs[65] = {0.0, + 0.000363221481845530659694E+00, + 0.00126515655623006801137E+00, + 0.00257904979468568827243E+00, + 0.00421763044155885483908E+00, + 0.00611550682211724633968E+00, + 0.00822300795723592966926E+00, + 0.0104982469096213218983E+00, + 0.0129038001003512656260E+00, + 0.0154067504665594978021E+00, + 0.0179785515681282703329E+00, + 0.0205942339159127111492E+00, + 0.0232314466399102694433E+00, + 0.0258696793272147469108E+00, + 0.0284897547458335486125E+00, + 0.0310735511116879648799E+00, + 0.0336038771482077305417E+00, + 0.0360644327807825726401E+00, + 0.0384398102494555320386E+00, + 0.0407155101169443189339E+00, + 0.0428779600250077344929E+00, + 0.0449145316536321974143E+00, + 0.0468135549906280124026E+00, + 0.0485643304066731987159E+00, + 0.0501571393058995374137E+00, + 0.0515832539520484587768E+00, + 0.0528349467901165198621E+00, + 0.0539054993352660639269E+00, + 0.0547892105279628650322E+00, + 0.0554814043565593639878E+00, + 0.0559784365104763194076E+00, + 0.0562776998312543012726E+00, + 0.0563776283603847173877E+00, + 0.0562776998312543012726E+00, + 0.0559784365104763194076E+00, + 0.0554814043565593639878E+00, + 0.0547892105279628650322E+00, + 0.0539054993352660639269E+00, + 0.0528349467901165198621E+00, + 0.0515832539520484587768E+00, + 0.0501571393058995374137E+00, + 0.0485643304066731987159E+00, + 0.0468135549906280124026E+00, + 0.0449145316536321974143E+00, + 0.0428779600250077344929E+00, + 0.0407155101169443189339E+00, + 0.0384398102494555320386E+00, + 0.0360644327807825726401E+00, + 0.0336038771482077305417E+00, + 0.0310735511116879648799E+00, + 0.0284897547458335486125E+00, + 0.0258696793272147469108E+00, + 0.0232314466399102694433E+00, + 0.0205942339159127111492E+00, + 0.0179785515681282703329E+00, + 0.0154067504665594978021E+00, + 0.0129038001003512656260E+00, + 0.0104982469096213218983E+00, + 0.00822300795723592966926E+00, + 0.00611550682211724633968E+00, + 0.00421763044155885483908E+00, + 0.00257904979468568827243E+00, + 0.00126515655623006801137E+00, + 0.000363221481845530659694E+00, + 0.0}; for (int d = 0; d < N; d++) (*out_coefs)[d] = (_Tp)tmp_coefs[d]; } if (in_level == 7) { - double tmp_coefs[129] = { - 0.0, 0.0000505360952078625176247E+00, - 0.000180739564445388357820E+00, 0.000377746646326984660274E+00, - 0.000632607319362633544219E+00, 0.000938369848542381500794E+00, - 0.00128952408261041739210E+00, 0.00168114286542146990631E+00, - 0.00210881524572663287933E+00, 0.00256876494379402037313E+00, - 0.00305775341017553113613E+00, 0.00357289278351729964938E+00, - 0.00411150397865469304717E+00, 0.00467105037211432174741E+00, - 0.00524912345480885912513E+00, 0.00584344987583563950756E+00, - 0.00645190005017573692280E+00, 0.00707248999543355546805E+00, - 0.00770337523327974184817E+00, 0.00834283875396815770558E+00, - 0.00898927578406413572328E+00, 0.00964117772970253669530E+00, - 0.0102971169579563555237E+00, 0.0109557333878379016480E+00, - 0.0116157233199551347270E+00, 0.0122758305600827700870E+00, - 0.0129348396636073734547E+00, 0.0135915710097655467896E+00, - 0.0142448773729167743063E+00, 0.0148936416648151820348E+00, - 0.0155367755558439824399E+00, 0.0161732187295777199419E+00, - 0.0168019385741038652709E+00, 0.0174219301594641737472E+00, - 0.0180322163903912863201E+00, 0.0186318482561387901863E+00, - 0.0192199051247277660193E+00, 0.0197954950480974994880E+00, - 0.0203577550584721594669E+00, 0.0209058514458120238522E+00, - 0.0214389800125038672465E+00, 0.0219563663053178249393E+00, - 0.0224572658268160987071E+00, 0.0229409642293877487608E+00, - 0.0234067774953140062013E+00, 0.0238540521060385400804E+00, - 0.0242821652033365993580E+00, 0.0246905247444876769091E+00, - 0.0250785696529497687068E+00, 0.0254457699654647658126E+00, - 0.0257916269760242293884E+00, 0.0261156733767060976805E+00, - 0.0264174733950582599310E+00, 0.0266966229274503599062E+00, - 0.0269527496676330319634E+00, 0.0271855132296247918192E+00, - 0.0273946052639814325161E+00, 0.0275797495664818730349E+00, - 0.0277407021782796819939E+00, 0.0278772514766137016085E+00, - 0.0279892182552381597038E+00, 0.0280764557938172466068E+00, - 0.0281388499156271506363E+00, 0.0281763190330166021307E+00, - 0.0281888141801923586938E+00, 0.0281763190330166021307E+00, - 0.0281388499156271506363E+00, 0.0280764557938172466068E+00, - 0.0279892182552381597038E+00, 0.0278772514766137016085E+00, - 0.0277407021782796819939E+00, 0.0275797495664818730349E+00, - 0.0273946052639814325161E+00, 0.0271855132296247918192E+00, - 0.0269527496676330319634E+00, 0.0266966229274503599062E+00, - 0.0264174733950582599310E+00, 0.0261156733767060976805E+00, - 0.0257916269760242293884E+00, 0.0254457699654647658126E+00, - 0.0250785696529497687068E+00, 0.0246905247444876769091E+00, - 0.0242821652033365993580E+00, 0.0238540521060385400804E+00, - 0.0234067774953140062013E+00, 0.0229409642293877487608E+00, - 0.0224572658268160987071E+00, 0.0219563663053178249393E+00, - 0.0214389800125038672465E+00, 0.0209058514458120238522E+00, - 0.0203577550584721594669E+00, 0.0197954950480974994880E+00, - 0.0192199051247277660193E+00, 0.0186318482561387901863E+00, - 0.0180322163903912863201E+00, 0.0174219301594641737472E+00, - 0.0168019385741038652709E+00, 0.0161732187295777199419E+00, - 0.0155367755558439824399E+00, 0.0148936416648151820348E+00, - 0.0142448773729167743063E+00, 0.0135915710097655467896E+00, - 0.0129348396636073734547E+00, 0.0122758305600827700870E+00, - 0.0116157233199551347270E+00, 0.0109557333878379016480E+00, - 0.0102971169579563555237E+00, 0.00964117772970253669530E+00, - 0.00898927578406413572328E+00, 0.00834283875396815770558E+00, - 0.00770337523327974184817E+00, 0.00707248999543355546805E+00, - 0.00645190005017573692280E+00, 0.00584344987583563950756E+00, - 0.00524912345480885912513E+00, 0.00467105037211432174741E+00, - 0.00411150397865469304717E+00, 0.00357289278351729964938E+00, - 0.00305775341017553113613E+00, 0.00256876494379402037313E+00, - 0.00210881524572663287933E+00, 0.00168114286542146990631E+00, - 0.00128952408261041739210E+00, 0.000938369848542381500794E+00, - 0.000632607319362633544219E+00, 0.000377746646326984660274E+00, - 0.000180739564445388357820E+00, 0.0000505360952078625176247E+00, - 0.0}; + double tmp_coefs[129] = {0.0, + 0.0000505360952078625176247E+00, + 0.000180739564445388357820E+00, + 0.000377746646326984660274E+00, + 0.000632607319362633544219E+00, + 0.000938369848542381500794E+00, + 0.00128952408261041739210E+00, + 0.00168114286542146990631E+00, + 0.00210881524572663287933E+00, + 0.00256876494379402037313E+00, + 0.00305775341017553113613E+00, + 0.00357289278351729964938E+00, + 0.00411150397865469304717E+00, + 0.00467105037211432174741E+00, + 0.00524912345480885912513E+00, + 0.00584344987583563950756E+00, + 0.00645190005017573692280E+00, + 0.00707248999543355546805E+00, + 0.00770337523327974184817E+00, + 0.00834283875396815770558E+00, + 0.00898927578406413572328E+00, + 0.00964117772970253669530E+00, + 0.0102971169579563555237E+00, + 0.0109557333878379016480E+00, + 0.0116157233199551347270E+00, + 0.0122758305600827700870E+00, + 0.0129348396636073734547E+00, + 0.0135915710097655467896E+00, + 0.0142448773729167743063E+00, + 0.0148936416648151820348E+00, + 0.0155367755558439824399E+00, + 0.0161732187295777199419E+00, + 0.0168019385741038652709E+00, + 0.0174219301594641737472E+00, + 0.0180322163903912863201E+00, + 0.0186318482561387901863E+00, + 0.0192199051247277660193E+00, + 0.0197954950480974994880E+00, + 0.0203577550584721594669E+00, + 0.0209058514458120238522E+00, + 0.0214389800125038672465E+00, + 0.0219563663053178249393E+00, + 0.0224572658268160987071E+00, + 0.0229409642293877487608E+00, + 0.0234067774953140062013E+00, + 0.0238540521060385400804E+00, + 0.0242821652033365993580E+00, + 0.0246905247444876769091E+00, + 0.0250785696529497687068E+00, + 0.0254457699654647658126E+00, + 0.0257916269760242293884E+00, + 0.0261156733767060976805E+00, + 0.0264174733950582599310E+00, + 0.0266966229274503599062E+00, + 0.0269527496676330319634E+00, + 0.0271855132296247918192E+00, + 0.0273946052639814325161E+00, + 0.0275797495664818730349E+00, + 0.0277407021782796819939E+00, + 0.0278772514766137016085E+00, + 0.0279892182552381597038E+00, + 0.0280764557938172466068E+00, + 0.0281388499156271506363E+00, + 0.0281763190330166021307E+00, + 0.0281888141801923586938E+00, + 0.0281763190330166021307E+00, + 0.0281388499156271506363E+00, + 0.0280764557938172466068E+00, + 0.0279892182552381597038E+00, + 0.0278772514766137016085E+00, + 0.0277407021782796819939E+00, + 0.0275797495664818730349E+00, + 0.0273946052639814325161E+00, + 0.0271855132296247918192E+00, + 0.0269527496676330319634E+00, + 0.0266966229274503599062E+00, + 0.0264174733950582599310E+00, + 0.0261156733767060976805E+00, + 0.0257916269760242293884E+00, + 0.0254457699654647658126E+00, + 0.0250785696529497687068E+00, + 0.0246905247444876769091E+00, + 0.0242821652033365993580E+00, + 0.0238540521060385400804E+00, + 0.0234067774953140062013E+00, + 0.0229409642293877487608E+00, + 0.0224572658268160987071E+00, + 0.0219563663053178249393E+00, + 0.0214389800125038672465E+00, + 0.0209058514458120238522E+00, + 0.0203577550584721594669E+00, + 0.0197954950480974994880E+00, + 0.0192199051247277660193E+00, + 0.0186318482561387901863E+00, + 0.0180322163903912863201E+00, + 0.0174219301594641737472E+00, + 0.0168019385741038652709E+00, + 0.0161732187295777199419E+00, + 0.0155367755558439824399E+00, + 0.0148936416648151820348E+00, + 0.0142448773729167743063E+00, + 0.0135915710097655467896E+00, + 0.0129348396636073734547E+00, + 0.0122758305600827700870E+00, + 0.0116157233199551347270E+00, + 0.0109557333878379016480E+00, + 0.0102971169579563555237E+00, + 0.00964117772970253669530E+00, + 0.00898927578406413572328E+00, + 0.00834283875396815770558E+00, + 0.00770337523327974184817E+00, + 0.00707248999543355546805E+00, + 0.00645190005017573692280E+00, + 0.00584344987583563950756E+00, + 0.00524912345480885912513E+00, + 0.00467105037211432174741E+00, + 0.00411150397865469304717E+00, + 0.00357289278351729964938E+00, + 0.00305775341017553113613E+00, + 0.00256876494379402037313E+00, + 0.00210881524572663287933E+00, + 0.00168114286542146990631E+00, + 0.00128952408261041739210E+00, + 0.000938369848542381500794E+00, + 0.000632607319362633544219E+00, + 0.000377746646326984660274E+00, + 0.000180739564445388357820E+00, + 0.0000505360952078625176247E+00, + 0.0}; for (int d = 0; d < N; d++) (*out_coefs)[d] = (_Tp)tmp_coefs[d]; } if (in_level == 8) { - double tmp_coefs[257] = { - 0.0, 0.69379364324108267170E-05, - 0.25157870384280661489E-04, 0.53275293669780613125E-04, - 0.90372734658751149261E-04, 0.13575491094922871973E-03, - 0.18887326450650491366E-03, 0.24921240048299729402E-03, - 0.31630366082226447689E-03, 0.38974528447328229322E-03, - 0.46918492424785040975E-03, 0.55429531493037471492E-03, - 0.64476204130572477933E-03, 0.74028280424450333046E-03, - 0.84057143271072246365E-03, 0.94536151685852538246E-03, - 0.10544076228633167722E-02, 0.11674841174299594077E-02, - 0.12843824718970101768E-02, 0.14049079956551446427E-02, - 0.15288767050877655684E-02, 0.16561127281544526052E-02, - 0.17864463917586498247E-02, 0.19197129710138724125E-02, - 0.20557519893273465236E-02, 0.21944069253638388388E-02, - 0.23355251860571608737E-02, 0.24789582266575679307E-02, - 0.26245617274044295626E-02, 0.27721957645934509940E-02, - 0.29217249379178197538E-02, 0.30730184347025783234E-02, - 0.32259500250878684614E-02, 0.33803979910869203823E-02, - 0.35362449977167777340E-02, 0.36933779170256508183E-02, - 0.38516876166398709241E-02, 0.40110687240750233989E-02, - 0.41714193769840788528E-02, 0.43326409680929828545E-02, - 0.44946378920320678616E-02, 0.46573172997568547773E-02, - 0.48205888648512683476E-02, 0.49843645647655386012E-02, - 0.51485584789781777618E-02, 0.53130866051870565663E-02, - 0.54778666939189508240E-02, 0.56428181013844441585E-02, - 0.58078616599775673635E-02, 0.59729195655081658049E-02, - 0.61379152800413850435E-02, 0.63027734490857587172E-02, - 0.64674198318036867274E-02, 0.66317812429018878941E-02, - 0.67957855048827733948E-02, 0.69593614093904229394E-02, - 0.71224386864583871532E-02, 0.72849479805538070639E-02, - 0.74468208324075910174E-02, 0.76079896657190565832E-02, - 0.77683877779219912200E-02, 0.79279493342948491103E-02, - 0.80866093647888599710E-02, 0.82443037630328680306E-02, - 0.84009692870519326354E-02, 0.85565435613076896192E-02, - 0.87109650797320868736E-02, 0.88641732094824942641E-02, - 0.90161081951956431600E-02, 0.91667111635607884067E-02, - 0.93159241280693950932E-02, 0.94636899938300652943E-02, - 0.96099525623638830097E-02, 0.97546565363174114611E-02, - 0.98977475240487497440E-02, 0.10039172044056840798E-01, - 0.10178877529236079733E-01, 0.10316812330947621682E-01, - 0.10452925722906011926E-01, 0.10587167904885197931E-01, - 0.10719490006251933623E-01, 0.10849844089337314099E-01, - 0.10978183152658912470E-01, 0.11104461134006926537E-01, - 0.11228632913408049354E-01, 0.11350654315980596602E-01, - 0.11470482114693874380E-01, 0.11588074033043952568E-01, - 0.11703388747657003101E-01, 0.11816385890830235763E-01, - 0.11927026053019270040E-01, 0.12035270785279562630E-01, - 0.12141082601668299679E-01, 0.12244424981611985899E-01, - 0.12345262372243838455E-01, 0.12443560190714035263E-01, - 0.12539284826474884353E-01, 0.12632403643542078765E-01, - 0.12722884982732382906E-01, 0.12810698163877361967E-01, - 0.12895813488012114694E-01, 0.12978202239537399286E-01, - 0.13057836688353048840E-01, 0.13134690091960152836E-01, - 0.13208736697529129966E-01, 0.13279951743930530650E-01, - 0.13348311463725179953E-01, 0.13413793085110098513E-01, - 0.13476374833816515982E-01, 0.13536035934956213614E-01, - 0.13592756614812395910E-01, 0.13646518102571291428E-01, - 0.13697302631990716258E-01, 0.13745093443001896632E-01, - 0.13789874783240936517E-01, 0.13831631909506428676E-01, - 0.13870351089139840997E-01, 0.13906019601325461264E-01, - 0.13938625738306850804E-01, 0.13968158806516938516E-01, - 0.13994609127619079852E-01, 0.14017968039456608810E-01, - 0.14038227896908623303E-01, 0.14055382072649964277E-01, - 0.14069424957813575318E-01, 0.14080351962553661325E-01, - 0.14088159516508301065E-01, 0.14092845069160408355E-01, - 0.14094407090096179347E-01, 0.14092845069160408355E-01, - 0.14088159516508301065E-01, 0.14080351962553661325E-01, - 0.14069424957813575318E-01, 0.14055382072649964277E-01, - 0.14038227896908623303E-01, 0.14017968039456608810E-01, - 0.13994609127619079852E-01, 0.13968158806516938516E-01, - 0.13938625738306850804E-01, 0.13906019601325461264E-01, - 0.13870351089139840997E-01, 0.13831631909506428676E-01, - 0.13789874783240936517E-01, 0.13745093443001896632E-01, - 0.13697302631990716258E-01, 0.13646518102571291428E-01, - 0.13592756614812395910E-01, 0.13536035934956213614E-01, - 0.13476374833816515982E-01, 0.13413793085110098513E-01, - 0.13348311463725179953E-01, 0.13279951743930530650E-01, - 0.13208736697529129966E-01, 0.13134690091960152836E-01, - 0.13057836688353048840E-01, 0.12978202239537399286E-01, - 0.12895813488012114694E-01, 0.12810698163877361967E-01, - 0.12722884982732382906E-01, 0.12632403643542078765E-01, - 0.12539284826474884353E-01, 0.12443560190714035263E-01, - 0.12345262372243838455E-01, 0.12244424981611985899E-01, - 0.12141082601668299679E-01, 0.12035270785279562630E-01, - 0.11927026053019270040E-01, 0.11816385890830235763E-01, - 0.11703388747657003101E-01, 0.11588074033043952568E-01, - 0.11470482114693874380E-01, 0.11350654315980596602E-01, - 0.11228632913408049354E-01, 0.11104461134006926537E-01, - 0.10978183152658912470E-01, 0.10849844089337314099E-01, - 0.10719490006251933623E-01, 0.10587167904885197931E-01, - 0.10452925722906011926E-01, 0.10316812330947621682E-01, - 0.10178877529236079733E-01, 0.10039172044056840798E-01, - 0.98977475240487497440E-02, 0.97546565363174114611E-02, - 0.96099525623638830097E-02, 0.94636899938300652943E-02, - 0.93159241280693950932E-02, 0.91667111635607884067E-02, - 0.90161081951956431600E-02, 0.88641732094824942641E-02, - 0.87109650797320868736E-02, 0.85565435613076896192E-02, - 0.84009692870519326354E-02, 0.82443037630328680306E-02, - 0.80866093647888599710E-02, 0.79279493342948491103E-02, - 0.77683877779219912200E-02, 0.76079896657190565832E-02, - 0.74468208324075910174E-02, 0.72849479805538070639E-02, - 0.71224386864583871532E-02, 0.69593614093904229394E-02, - 0.67957855048827733948E-02, 0.66317812429018878941E-02, - 0.64674198318036867274E-02, 0.63027734490857587172E-02, - 0.61379152800413850435E-02, 0.59729195655081658049E-02, - 0.58078616599775673635E-02, 0.56428181013844441585E-02, - 0.54778666939189508240E-02, 0.53130866051870565663E-02, - 0.51485584789781777618E-02, 0.49843645647655386012E-02, - 0.48205888648512683476E-02, 0.46573172997568547773E-02, - 0.44946378920320678616E-02, 0.43326409680929828545E-02, - 0.41714193769840788528E-02, 0.40110687240750233989E-02, - 0.38516876166398709241E-02, 0.36933779170256508183E-02, - 0.35362449977167777340E-02, 0.33803979910869203823E-02, - 0.32259500250878684614E-02, 0.30730184347025783234E-02, - 0.29217249379178197538E-02, 0.27721957645934509940E-02, - 0.26245617274044295626E-02, 0.24789582266575679307E-02, - 0.23355251860571608737E-02, 0.21944069253638388388E-02, - 0.20557519893273465236E-02, 0.19197129710138724125E-02, - 0.17864463917586498247E-02, 0.16561127281544526052E-02, - 0.15288767050877655684E-02, 0.14049079956551446427E-02, - 0.12843824718970101768E-02, 0.11674841174299594077E-02, - 0.10544076228633167722E-02, 0.94536151685852538246E-03, - 0.84057143271072246365E-03, 0.74028280424450333046E-03, - 0.64476204130572477933E-03, 0.55429531493037471492E-03, - 0.46918492424785040975E-03, 0.38974528447328229322E-03, - 0.31630366082226447689E-03, 0.24921240048299729402E-03, - 0.18887326450650491366E-03, 0.13575491094922871973E-03, - 0.90372734658751149261E-04, 0.53275293669780613125E-04, - 0.25157870384280661489E-04, 0.69379364324108267170E-05, - 0.0}; + double tmp_coefs[257] = {0.0, + 0.69379364324108267170E-05, + 0.25157870384280661489E-04, + 0.53275293669780613125E-04, + 0.90372734658751149261E-04, + 0.13575491094922871973E-03, + 0.18887326450650491366E-03, + 0.24921240048299729402E-03, + 0.31630366082226447689E-03, + 0.38974528447328229322E-03, + 0.46918492424785040975E-03, + 0.55429531493037471492E-03, + 0.64476204130572477933E-03, + 0.74028280424450333046E-03, + 0.84057143271072246365E-03, + 0.94536151685852538246E-03, + 0.10544076228633167722E-02, + 0.11674841174299594077E-02, + 0.12843824718970101768E-02, + 0.14049079956551446427E-02, + 0.15288767050877655684E-02, + 0.16561127281544526052E-02, + 0.17864463917586498247E-02, + 0.19197129710138724125E-02, + 0.20557519893273465236E-02, + 0.21944069253638388388E-02, + 0.23355251860571608737E-02, + 0.24789582266575679307E-02, + 0.26245617274044295626E-02, + 0.27721957645934509940E-02, + 0.29217249379178197538E-02, + 0.30730184347025783234E-02, + 0.32259500250878684614E-02, + 0.33803979910869203823E-02, + 0.35362449977167777340E-02, + 0.36933779170256508183E-02, + 0.38516876166398709241E-02, + 0.40110687240750233989E-02, + 0.41714193769840788528E-02, + 0.43326409680929828545E-02, + 0.44946378920320678616E-02, + 0.46573172997568547773E-02, + 0.48205888648512683476E-02, + 0.49843645647655386012E-02, + 0.51485584789781777618E-02, + 0.53130866051870565663E-02, + 0.54778666939189508240E-02, + 0.56428181013844441585E-02, + 0.58078616599775673635E-02, + 0.59729195655081658049E-02, + 0.61379152800413850435E-02, + 0.63027734490857587172E-02, + 0.64674198318036867274E-02, + 0.66317812429018878941E-02, + 0.67957855048827733948E-02, + 0.69593614093904229394E-02, + 0.71224386864583871532E-02, + 0.72849479805538070639E-02, + 0.74468208324075910174E-02, + 0.76079896657190565832E-02, + 0.77683877779219912200E-02, + 0.79279493342948491103E-02, + 0.80866093647888599710E-02, + 0.82443037630328680306E-02, + 0.84009692870519326354E-02, + 0.85565435613076896192E-02, + 0.87109650797320868736E-02, + 0.88641732094824942641E-02, + 0.90161081951956431600E-02, + 0.91667111635607884067E-02, + 0.93159241280693950932E-02, + 0.94636899938300652943E-02, + 0.96099525623638830097E-02, + 0.97546565363174114611E-02, + 0.98977475240487497440E-02, + 0.10039172044056840798E-01, + 0.10178877529236079733E-01, + 0.10316812330947621682E-01, + 0.10452925722906011926E-01, + 0.10587167904885197931E-01, + 0.10719490006251933623E-01, + 0.10849844089337314099E-01, + 0.10978183152658912470E-01, + 0.11104461134006926537E-01, + 0.11228632913408049354E-01, + 0.11350654315980596602E-01, + 0.11470482114693874380E-01, + 0.11588074033043952568E-01, + 0.11703388747657003101E-01, + 0.11816385890830235763E-01, + 0.11927026053019270040E-01, + 0.12035270785279562630E-01, + 0.12141082601668299679E-01, + 0.12244424981611985899E-01, + 0.12345262372243838455E-01, + 0.12443560190714035263E-01, + 0.12539284826474884353E-01, + 0.12632403643542078765E-01, + 0.12722884982732382906E-01, + 0.12810698163877361967E-01, + 0.12895813488012114694E-01, + 0.12978202239537399286E-01, + 0.13057836688353048840E-01, + 0.13134690091960152836E-01, + 0.13208736697529129966E-01, + 0.13279951743930530650E-01, + 0.13348311463725179953E-01, + 0.13413793085110098513E-01, + 0.13476374833816515982E-01, + 0.13536035934956213614E-01, + 0.13592756614812395910E-01, + 0.13646518102571291428E-01, + 0.13697302631990716258E-01, + 0.13745093443001896632E-01, + 0.13789874783240936517E-01, + 0.13831631909506428676E-01, + 0.13870351089139840997E-01, + 0.13906019601325461264E-01, + 0.13938625738306850804E-01, + 0.13968158806516938516E-01, + 0.13994609127619079852E-01, + 0.14017968039456608810E-01, + 0.14038227896908623303E-01, + 0.14055382072649964277E-01, + 0.14069424957813575318E-01, + 0.14080351962553661325E-01, + 0.14088159516508301065E-01, + 0.14092845069160408355E-01, + 0.14094407090096179347E-01, + 0.14092845069160408355E-01, + 0.14088159516508301065E-01, + 0.14080351962553661325E-01, + 0.14069424957813575318E-01, + 0.14055382072649964277E-01, + 0.14038227896908623303E-01, + 0.14017968039456608810E-01, + 0.13994609127619079852E-01, + 0.13968158806516938516E-01, + 0.13938625738306850804E-01, + 0.13906019601325461264E-01, + 0.13870351089139840997E-01, + 0.13831631909506428676E-01, + 0.13789874783240936517E-01, + 0.13745093443001896632E-01, + 0.13697302631990716258E-01, + 0.13646518102571291428E-01, + 0.13592756614812395910E-01, + 0.13536035934956213614E-01, + 0.13476374833816515982E-01, + 0.13413793085110098513E-01, + 0.13348311463725179953E-01, + 0.13279951743930530650E-01, + 0.13208736697529129966E-01, + 0.13134690091960152836E-01, + 0.13057836688353048840E-01, + 0.12978202239537399286E-01, + 0.12895813488012114694E-01, + 0.12810698163877361967E-01, + 0.12722884982732382906E-01, + 0.12632403643542078765E-01, + 0.12539284826474884353E-01, + 0.12443560190714035263E-01, + 0.12345262372243838455E-01, + 0.12244424981611985899E-01, + 0.12141082601668299679E-01, + 0.12035270785279562630E-01, + 0.11927026053019270040E-01, + 0.11816385890830235763E-01, + 0.11703388747657003101E-01, + 0.11588074033043952568E-01, + 0.11470482114693874380E-01, + 0.11350654315980596602E-01, + 0.11228632913408049354E-01, + 0.11104461134006926537E-01, + 0.10978183152658912470E-01, + 0.10849844089337314099E-01, + 0.10719490006251933623E-01, + 0.10587167904885197931E-01, + 0.10452925722906011926E-01, + 0.10316812330947621682E-01, + 0.10178877529236079733E-01, + 0.10039172044056840798E-01, + 0.98977475240487497440E-02, + 0.97546565363174114611E-02, + 0.96099525623638830097E-02, + 0.94636899938300652943E-02, + 0.93159241280693950932E-02, + 0.91667111635607884067E-02, + 0.90161081951956431600E-02, + 0.88641732094824942641E-02, + 0.87109650797320868736E-02, + 0.85565435613076896192E-02, + 0.84009692870519326354E-02, + 0.82443037630328680306E-02, + 0.80866093647888599710E-02, + 0.79279493342948491103E-02, + 0.77683877779219912200E-02, + 0.76079896657190565832E-02, + 0.74468208324075910174E-02, + 0.72849479805538070639E-02, + 0.71224386864583871532E-02, + 0.69593614093904229394E-02, + 0.67957855048827733948E-02, + 0.66317812429018878941E-02, + 0.64674198318036867274E-02, + 0.63027734490857587172E-02, + 0.61379152800413850435E-02, + 0.59729195655081658049E-02, + 0.58078616599775673635E-02, + 0.56428181013844441585E-02, + 0.54778666939189508240E-02, + 0.53130866051870565663E-02, + 0.51485584789781777618E-02, + 0.49843645647655386012E-02, + 0.48205888648512683476E-02, + 0.46573172997568547773E-02, + 0.44946378920320678616E-02, + 0.43326409680929828545E-02, + 0.41714193769840788528E-02, + 0.40110687240750233989E-02, + 0.38516876166398709241E-02, + 0.36933779170256508183E-02, + 0.35362449977167777340E-02, + 0.33803979910869203823E-02, + 0.32259500250878684614E-02, + 0.30730184347025783234E-02, + 0.29217249379178197538E-02, + 0.27721957645934509940E-02, + 0.26245617274044295626E-02, + 0.24789582266575679307E-02, + 0.23355251860571608737E-02, + 0.21944069253638388388E-02, + 0.20557519893273465236E-02, + 0.19197129710138724125E-02, + 0.17864463917586498247E-02, + 0.16561127281544526052E-02, + 0.15288767050877655684E-02, + 0.14049079956551446427E-02, + 0.12843824718970101768E-02, + 0.11674841174299594077E-02, + 0.10544076228633167722E-02, + 0.94536151685852538246E-03, + 0.84057143271072246365E-03, + 0.74028280424450333046E-03, + 0.64476204130572477933E-03, + 0.55429531493037471492E-03, + 0.46918492424785040975E-03, + 0.38974528447328229322E-03, + 0.31630366082226447689E-03, + 0.24921240048299729402E-03, + 0.18887326450650491366E-03, + 0.13575491094922871973E-03, + 0.90372734658751149261E-04, + 0.53275293669780613125E-04, + 0.25157870384280661489E-04, + 0.69379364324108267170E-05, + 0.0}; for (int d = 0; d < N; d++) (*out_coefs)[d] = (_Tp)tmp_coefs[d]; } if (in_level == 9) { - double tmp_coefs[513] = { - 0.0, 0.945715933950007048827E-06, - 0.345456507169149134898E-05, 0.736624069102321668857E-05, - 0.125792781889592743525E-04, 0.190213681905875816679E-04, - 0.266376412339000901358E-04, 0.353751372055189588628E-04, - 0.451863674126296143105E-04, 0.560319507856164252140E-04, - 0.678774554733972416227E-04, 0.806899228014035293851E-04, - 0.944366322532705527066E-04, 0.109085545645741522051E-03, - 0.124606200241498368482E-03, 0.140970302204104791413E-03, - 0.158151830411132242924E-03, 0.176126765545083195474E-03, - 0.194872642236641146532E-03, 0.214368090034216937149E-03, - 0.234592462123925204879E-03, 0.255525589595236862014E-03, - 0.277147657465187357459E-03, 0.299439176850911730874E-03, - 0.322381020652862389664E-03, 0.345954492129903871350E-03, - 0.370141402122251665232E-03, 0.394924138246873704434E-03, - 0.420285716355361231823E-03, 0.446209810101403247488E-03, - 0.472680758429262691232E-03, 0.499683553312800484519E-03, - 0.527203811431658386125E-03, 0.555227733977307579715E-03, - 0.583742058714979703847E-03, 0.612734008012225209294E-03, - 0.642191235948505088403E-03, 0.672101776960108194646E-03, - 0.702453997827572321358E-03, 0.733236554224767912055E-03, - 0.764438352543882784191E-03, 0.796048517297550871506E-03, - 0.828056364077226302608E-03, 0.860451377808527848128E-03, - 0.893223195879324912340E-03, 0.926361595613111283368E-03, - 0.959856485506936206261E-03, 0.993697899638760857945E-03, - 0.102787599466367326179E-02, 0.106238104885340071375E-02, - 0.109720346268191941940E-02, 0.113233376051597664917E-02, - 0.116776259302858043685E-02, 0.120348074001265964881E-02, - 0.123947911332878396534E-02, 0.127574875977346947345E-02, - 0.131228086370221478128E-02, 0.134906674928353113127E-02, - 0.138609788229672549700E-02, 0.142336587141720519900E-02, - 0.146086246895890987689E-02, 0.149857957106456636214E-02, - 0.153650921735128916170E-02, 0.157464359003212166189E-02, - 0.161297501254393423070E-02, 0.165149594771914570655E-02, - 0.169019899554346019117E-02, 0.172907689054461607168E-02, - 0.176812249885838886701E-02, 0.180732881501808930079E-02, - 0.184668895851282540913E-02, 0.188619617015808475394E-02, - 0.192584380831993546204E-02, 0.196562534503150547732E-02, - 0.200553436203751169944E-02, 0.204556454679958293446E-02, - 0.208570968849203942640E-02, 0.212596367401472533045E-02, - 0.216632048404649142727E-02, 0.220677418916003329194E-02, - 0.224731894601603393082E-02, 0.228794899365195972378E-02, - 0.232865864987842738864E-02, 0.236944230779380495146E-02, - 0.241029443242563417382E-02, 0.245120955750556483923E-02, - 0.249218228238276930060E-02, 0.253320726907925325750E-02, - 0.257427923948908888092E-02, 0.261539297272236109225E-02, - 0.265654330259352828314E-02, 0.269772511525294586667E-02, - 0.273893334695947541201E-02, 0.278016298199139435045E-02, - 0.282140905069222207923E-02, 0.286266662764757868253E-02, - 0.290393082998878368175E-02, 0.294519681581857582284E-02, - 0.298645978275408290247E-02, 0.302771496658198544480E-02, - 0.306895764002069252174E-02, 0.311018311158427546158E-02, - 0.315138672454287935858E-02, 0.319256385597434736790E-02, - 0.323370991590184336368E-02, 0.327482034651233969564E-02, - 0.331589062145094394706E-02, 0.335691624518616761342E-02, - 0.339789275244138669739E-02, 0.343881570768790591876E-02, - 0.347968070469521146972E-02, 0.352048336613417922682E-02, - 0.356121934322919357659E-02, 0.360188431545532431869E-02, - 0.364247399027690353194E-02, 0.368298410292403911967E-02, - 0.372341041620379550870E-02, 0.376374872034296338241E-02, - 0.380399483285952829161E-02, 0.384414459846013158917E-02, - 0.388419388896099560998E-02, 0.392413860322995774660E-02, - 0.396397466714742455513E-02, 0.400369803358421688562E-02, - 0.404330468239442998549E-02, 0.408279062042157838350E-02, - 0.412215188151643401528E-02, 0.416138452656509745764E-02, - 0.420048464352596631772E-02, 0.423944834747438184434E-02, - 0.427827178065384480959E-02, 0.431695111253279479928E-02, - 0.435548253986604343679E-02, 0.439386228676004195260E-02, - 0.443208660474124713206E-02, 0.447015177282692726900E-02, - 0.450805409759782158001E-02, 0.454578991327213285488E-02, - 0.458335558178039420335E-02, 0.462074749284080687482E-02, - 0.465796206403469754658E-02, 0.469499574088179046532E-02, - 0.473184499691503264714E-02, 0.476850633375474925263E-02, - 0.480497628118194150483E-02, 0.484125139721057135214E-02, - 0.487732826815870573054E-02, 0.491320350871841897367E-02, - 0.494887376202437487201E-02, 0.498433569972103029914E-02, - 0.501958602202842039909E-02, 0.505462145780650125058E-02, - 0.508943876461803986674E-02, 0.512403472879005351831E-02, - 0.515840616547381084096E-02, 0.519254991870341614863E-02, - 0.522646286145300596306E-02, 0.526014189569259311205E-02, - 0.529358395244259896547E-02, 0.532678599182711857974E-02, - 0.535974500312596681161E-02, 0.539245800482555593606E-02, - 0.542492204466865704951E-02, 0.545713419970309863995E-02, - 0.548909157632945623482E-02, 0.552079131034778706457E-02, - 0.555223056700346326850E-02, 0.558340654103215637610E-02, - 0.561431645670402467678E-02, 0.564495756786715368885E-02, - 0.567532715799029830087E-02, 0.570542254020497332312E-02, - 0.573524105734693719020E-02, 0.576478008199711142954E-02, - 0.579403701652197628421E-02, 0.582300929311348057702E-02, - 0.585169437382850155033E-02, 0.588008975062788803205E-02, - 0.590819294541511788161E-02, 0.593600151007459827614E-02, - 0.596351302650963502011E-02, 0.599072510668009471472E-02, - 0.601763539263978131522E-02, 0.604424155657354634589E-02, - 0.607054130083414983949E-02, 0.609653235797888692923E-02, - 0.612221249080599294931E-02, 0.614757949239083790214E-02, - 0.617263118612191922727E-02, 0.619736542573665996342E-02, - 0.622178009535701763157E-02, 0.624587310952490748541E-02, - 0.626964241323744217671E-02, 0.629308598198198836688E-02, - 0.631620182177103938227E-02, 0.633898796917690165912E-02, - 0.636144249136619145314E-02, 0.638356348613413709795E-02, - 0.640534908193868098342E-02, 0.642679743793437438922E-02, - 0.644790674400605734710E-02, 0.646867522080231481688E-02, - 0.648910111976869964292E-02, 0.650918272318071200827E-02, - 0.652891834417652442012E-02, 0.654830632678944064054E-02, - 0.656734504598007641819E-02, 0.658603290766824937794E-02, - 0.660436834876456498276E-02, 0.662234983720168509457E-02, - 0.663997587196526532519E-02, 0.665724498312454708217E-02, - 0.667415573186258997654E-02, 0.669070671050613006584E-02, - 0.670689654255504925648E-02, 0.672272388271144108036E-02, - 0.673818741690825799086E-02, 0.675328586233752529078E-02, - 0.676801796747810680683E-02, 0.678238251212300746082E-02, - 0.679637830740619795480E-02, 0.681000419582894688374E-02, - 0.682325905128564571420E-02, 0.683614177908911221841E-02, - 0.684865131599535812903E-02, 0.686078663022780697951E-02, - 0.687254672150094831613E-02, 0.688393062104341470995E-02, - 0.689493739162046825872E-02, 0.690556612755588354803E-02, - 0.691581595475321433825E-02, 0.692568603071643155621E-02, - 0.693517554456992049848E-02, 0.694428371707782549438E-02, - 0.695300980066273063177E-02, 0.696135307942366551493E-02, - 0.696931286915342540213E-02, 0.697688851735519545845E-02, - 0.698407940325846925786E-02, 0.699088493783425207545E-02, - 0.699730456380953992594E-02, 0.700333775568106572820E-02, - 0.700898401972830440494E-02, 0.701424289402572916425E-02, - 0.701911394845431165171E-02, 0.702359678471225911031E-02, - 0.702769103632498213858E-02, 0.703139636865428709508E-02, - 0.703471247890678765907E-02, 0.703763909614153052319E-02, - 0.704017598127683066242E-02, 0.704232292709631209597E-02, - 0.704407975825415053266E-02, 0.704544633127951476780E-02, - 0.704642253458020417748E-02, 0.704700828844548013730E-02, - 0.704720354504808967346E-02, 0.704700828844548013730E-02, - 0.704642253458020417748E-02, 0.704544633127951476780E-02, - 0.704407975825415053266E-02, 0.704232292709631209597E-02, - 0.704017598127683066242E-02, 0.703763909614153052319E-02, - 0.703471247890678765907E-02, 0.703139636865428709508E-02, - 0.702769103632498213858E-02, 0.702359678471225911031E-02, - 0.701911394845431165171E-02, 0.701424289402572916425E-02, - 0.700898401972830440494E-02, 0.700333775568106572820E-02, - 0.699730456380953992594E-02, 0.699088493783425207545E-02, - 0.698407940325846925786E-02, 0.697688851735519545845E-02, - 0.696931286915342540213E-02, 0.696135307942366551493E-02, - 0.695300980066273063177E-02, 0.694428371707782549438E-02, - 0.693517554456992049848E-02, 0.692568603071643155621E-02, - 0.691581595475321433825E-02, 0.690556612755588354803E-02, - 0.689493739162046825872E-02, 0.688393062104341470995E-02, - 0.687254672150094831613E-02, 0.686078663022780697951E-02, - 0.684865131599535812903E-02, 0.683614177908911221841E-02, - 0.682325905128564571420E-02, 0.681000419582894688374E-02, - 0.679637830740619795480E-02, 0.678238251212300746082E-02, - 0.676801796747810680683E-02, 0.675328586233752529078E-02, - 0.673818741690825799086E-02, 0.672272388271144108036E-02, - 0.670689654255504925648E-02, 0.669070671050613006584E-02, - 0.667415573186258997654E-02, 0.665724498312454708217E-02, - 0.663997587196526532519E-02, 0.662234983720168509457E-02, - 0.660436834876456498276E-02, 0.658603290766824937794E-02, - 0.656734504598007641819E-02, 0.654830632678944064054E-02, - 0.652891834417652442012E-02, 0.650918272318071200827E-02, - 0.648910111976869964292E-02, 0.646867522080231481688E-02, - 0.644790674400605734710E-02, 0.642679743793437438922E-02, - 0.640534908193868098342E-02, 0.638356348613413709795E-02, - 0.636144249136619145314E-02, 0.633898796917690165912E-02, - 0.631620182177103938227E-02, 0.629308598198198836688E-02, - 0.626964241323744217671E-02, 0.624587310952490748541E-02, - 0.622178009535701763157E-02, 0.619736542573665996342E-02, - 0.617263118612191922727E-02, 0.614757949239083790214E-02, - 0.612221249080599294931E-02, 0.609653235797888692923E-02, - 0.607054130083414983949E-02, 0.604424155657354634589E-02, - 0.601763539263978131522E-02, 0.599072510668009471472E-02, - 0.596351302650963502011E-02, 0.593600151007459827614E-02, - 0.590819294541511788161E-02, 0.588008975062788803205E-02, - 0.585169437382850155033E-02, 0.582300929311348057702E-02, - 0.579403701652197628421E-02, 0.576478008199711142954E-02, - 0.573524105734693719020E-02, 0.570542254020497332312E-02, - 0.567532715799029830087E-02, 0.564495756786715368885E-02, - 0.561431645670402467678E-02, 0.558340654103215637610E-02, - 0.555223056700346326850E-02, 0.552079131034778706457E-02, - 0.548909157632945623482E-02, 0.545713419970309863995E-02, - 0.542492204466865704951E-02, 0.539245800482555593606E-02, - 0.535974500312596681161E-02, 0.532678599182711857974E-02, - 0.529358395244259896547E-02, 0.526014189569259311205E-02, - 0.522646286145300596306E-02, 0.519254991870341614863E-02, - 0.515840616547381084096E-02, 0.512403472879005351831E-02, - 0.508943876461803986674E-02, 0.505462145780650125058E-02, - 0.501958602202842039909E-02, 0.498433569972103029914E-02, - 0.494887376202437487201E-02, 0.491320350871841897367E-02, - 0.487732826815870573054E-02, 0.484125139721057135214E-02, - 0.480497628118194150483E-02, 0.476850633375474925263E-02, - 0.473184499691503264714E-02, 0.469499574088179046532E-02, - 0.465796206403469754658E-02, 0.462074749284080687482E-02, - 0.458335558178039420335E-02, 0.454578991327213285488E-02, - 0.450805409759782158001E-02, 0.447015177282692726900E-02, - 0.443208660474124713206E-02, 0.439386228676004195260E-02, - 0.435548253986604343679E-02, 0.431695111253279479928E-02, - 0.427827178065384480959E-02, 0.423944834747438184434E-02, - 0.420048464352596631772E-02, 0.416138452656509745764E-02, - 0.412215188151643401528E-02, 0.408279062042157838350E-02, - 0.404330468239442998549E-02, 0.400369803358421688562E-02, - 0.396397466714742455513E-02, 0.392413860322995774660E-02, - 0.388419388896099560998E-02, 0.384414459846013158917E-02, - 0.380399483285952829161E-02, 0.376374872034296338241E-02, - 0.372341041620379550870E-02, 0.368298410292403911967E-02, - 0.364247399027690353194E-02, 0.360188431545532431869E-02, - 0.356121934322919357659E-02, 0.352048336613417922682E-02, - 0.347968070469521146972E-02, 0.343881570768790591876E-02, - 0.339789275244138669739E-02, 0.335691624518616761342E-02, - 0.331589062145094394706E-02, 0.327482034651233969564E-02, - 0.323370991590184336368E-02, 0.319256385597434736790E-02, - 0.315138672454287935858E-02, 0.311018311158427546158E-02, - 0.306895764002069252174E-02, 0.302771496658198544480E-02, - 0.298645978275408290247E-02, 0.294519681581857582284E-02, - 0.290393082998878368175E-02, 0.286266662764757868253E-02, - 0.282140905069222207923E-02, 0.278016298199139435045E-02, - 0.273893334695947541201E-02, 0.269772511525294586667E-02, - 0.265654330259352828314E-02, 0.261539297272236109225E-02, - 0.257427923948908888092E-02, 0.253320726907925325750E-02, - 0.249218228238276930060E-02, 0.245120955750556483923E-02, - 0.241029443242563417382E-02, 0.236944230779380495146E-02, - 0.232865864987842738864E-02, 0.228794899365195972378E-02, - 0.224731894601603393082E-02, 0.220677418916003329194E-02, - 0.216632048404649142727E-02, 0.212596367401472533045E-02, - 0.208570968849203942640E-02, 0.204556454679958293446E-02, - 0.200553436203751169944E-02, 0.196562534503150547732E-02, - 0.192584380831993546204E-02, 0.188619617015808475394E-02, - 0.184668895851282540913E-02, 0.180732881501808930079E-02, - 0.176812249885838886701E-02, 0.172907689054461607168E-02, - 0.169019899554346019117E-02, 0.165149594771914570655E-02, - 0.161297501254393423070E-02, 0.157464359003212166189E-02, - 0.153650921735128916170E-02, 0.149857957106456636214E-02, - 0.146086246895890987689E-02, 0.142336587141720519900E-02, - 0.138609788229672549700E-02, 0.134906674928353113127E-02, - 0.131228086370221478128E-02, 0.127574875977346947345E-02, - 0.123947911332878396534E-02, 0.120348074001265964881E-02, - 0.116776259302858043685E-02, 0.113233376051597664917E-02, - 0.109720346268191941940E-02, 0.106238104885340071375E-02, - 0.102787599466367326179E-02, 0.993697899638760857945E-03, - 0.959856485506936206261E-03, 0.926361595613111283368E-03, - 0.893223195879324912340E-03, 0.860451377808527848128E-03, - 0.828056364077226302608E-03, 0.796048517297550871506E-03, - 0.764438352543882784191E-03, 0.733236554224767912055E-03, - 0.702453997827572321358E-03, 0.672101776960108194646E-03, - 0.642191235948505088403E-03, 0.612734008012225209294E-03, - 0.583742058714979703847E-03, 0.555227733977307579715E-03, - 0.527203811431658386125E-03, 0.499683553312800484519E-03, - 0.472680758429262691232E-03, 0.446209810101403247488E-03, - 0.420285716355361231823E-03, 0.394924138246873704434E-03, - 0.370141402122251665232E-03, 0.345954492129903871350E-03, - 0.322381020652862389664E-03, 0.299439176850911730874E-03, - 0.277147657465187357459E-03, 0.255525589595236862014E-03, - 0.234592462123925204879E-03, 0.214368090034216937149E-03, - 0.194872642236641146532E-03, 0.176126765545083195474E-03, - 0.158151830411132242924E-03, 0.140970302204104791413E-03, - 0.124606200241498368482E-03, 0.109085545645741522051E-03, - 0.944366322532705527066E-04, 0.806899228014035293851E-04, - 0.678774554733972416227E-04, 0.560319507856164252140E-04, - 0.451863674126296143105E-04, 0.353751372055189588628E-04, - 0.266376412339000901358E-04, 0.190213681905875816679E-04, - 0.125792781889592743525E-04, 0.736624069102321668857E-05, - 0.345456507169149134898E-05, 0.945715933950007048827E-06, - 0.0}; + double tmp_coefs[513] = {0.0, + 0.945715933950007048827E-06, + 0.345456507169149134898E-05, + 0.736624069102321668857E-05, + 0.125792781889592743525E-04, + 0.190213681905875816679E-04, + 0.266376412339000901358E-04, + 0.353751372055189588628E-04, + 0.451863674126296143105E-04, + 0.560319507856164252140E-04, + 0.678774554733972416227E-04, + 0.806899228014035293851E-04, + 0.944366322532705527066E-04, + 0.109085545645741522051E-03, + 0.124606200241498368482E-03, + 0.140970302204104791413E-03, + 0.158151830411132242924E-03, + 0.176126765545083195474E-03, + 0.194872642236641146532E-03, + 0.214368090034216937149E-03, + 0.234592462123925204879E-03, + 0.255525589595236862014E-03, + 0.277147657465187357459E-03, + 0.299439176850911730874E-03, + 0.322381020652862389664E-03, + 0.345954492129903871350E-03, + 0.370141402122251665232E-03, + 0.394924138246873704434E-03, + 0.420285716355361231823E-03, + 0.446209810101403247488E-03, + 0.472680758429262691232E-03, + 0.499683553312800484519E-03, + 0.527203811431658386125E-03, + 0.555227733977307579715E-03, + 0.583742058714979703847E-03, + 0.612734008012225209294E-03, + 0.642191235948505088403E-03, + 0.672101776960108194646E-03, + 0.702453997827572321358E-03, + 0.733236554224767912055E-03, + 0.764438352543882784191E-03, + 0.796048517297550871506E-03, + 0.828056364077226302608E-03, + 0.860451377808527848128E-03, + 0.893223195879324912340E-03, + 0.926361595613111283368E-03, + 0.959856485506936206261E-03, + 0.993697899638760857945E-03, + 0.102787599466367326179E-02, + 0.106238104885340071375E-02, + 0.109720346268191941940E-02, + 0.113233376051597664917E-02, + 0.116776259302858043685E-02, + 0.120348074001265964881E-02, + 0.123947911332878396534E-02, + 0.127574875977346947345E-02, + 0.131228086370221478128E-02, + 0.134906674928353113127E-02, + 0.138609788229672549700E-02, + 0.142336587141720519900E-02, + 0.146086246895890987689E-02, + 0.149857957106456636214E-02, + 0.153650921735128916170E-02, + 0.157464359003212166189E-02, + 0.161297501254393423070E-02, + 0.165149594771914570655E-02, + 0.169019899554346019117E-02, + 0.172907689054461607168E-02, + 0.176812249885838886701E-02, + 0.180732881501808930079E-02, + 0.184668895851282540913E-02, + 0.188619617015808475394E-02, + 0.192584380831993546204E-02, + 0.196562534503150547732E-02, + 0.200553436203751169944E-02, + 0.204556454679958293446E-02, + 0.208570968849203942640E-02, + 0.212596367401472533045E-02, + 0.216632048404649142727E-02, + 0.220677418916003329194E-02, + 0.224731894601603393082E-02, + 0.228794899365195972378E-02, + 0.232865864987842738864E-02, + 0.236944230779380495146E-02, + 0.241029443242563417382E-02, + 0.245120955750556483923E-02, + 0.249218228238276930060E-02, + 0.253320726907925325750E-02, + 0.257427923948908888092E-02, + 0.261539297272236109225E-02, + 0.265654330259352828314E-02, + 0.269772511525294586667E-02, + 0.273893334695947541201E-02, + 0.278016298199139435045E-02, + 0.282140905069222207923E-02, + 0.286266662764757868253E-02, + 0.290393082998878368175E-02, + 0.294519681581857582284E-02, + 0.298645978275408290247E-02, + 0.302771496658198544480E-02, + 0.306895764002069252174E-02, + 0.311018311158427546158E-02, + 0.315138672454287935858E-02, + 0.319256385597434736790E-02, + 0.323370991590184336368E-02, + 0.327482034651233969564E-02, + 0.331589062145094394706E-02, + 0.335691624518616761342E-02, + 0.339789275244138669739E-02, + 0.343881570768790591876E-02, + 0.347968070469521146972E-02, + 0.352048336613417922682E-02, + 0.356121934322919357659E-02, + 0.360188431545532431869E-02, + 0.364247399027690353194E-02, + 0.368298410292403911967E-02, + 0.372341041620379550870E-02, + 0.376374872034296338241E-02, + 0.380399483285952829161E-02, + 0.384414459846013158917E-02, + 0.388419388896099560998E-02, + 0.392413860322995774660E-02, + 0.396397466714742455513E-02, + 0.400369803358421688562E-02, + 0.404330468239442998549E-02, + 0.408279062042157838350E-02, + 0.412215188151643401528E-02, + 0.416138452656509745764E-02, + 0.420048464352596631772E-02, + 0.423944834747438184434E-02, + 0.427827178065384480959E-02, + 0.431695111253279479928E-02, + 0.435548253986604343679E-02, + 0.439386228676004195260E-02, + 0.443208660474124713206E-02, + 0.447015177282692726900E-02, + 0.450805409759782158001E-02, + 0.454578991327213285488E-02, + 0.458335558178039420335E-02, + 0.462074749284080687482E-02, + 0.465796206403469754658E-02, + 0.469499574088179046532E-02, + 0.473184499691503264714E-02, + 0.476850633375474925263E-02, + 0.480497628118194150483E-02, + 0.484125139721057135214E-02, + 0.487732826815870573054E-02, + 0.491320350871841897367E-02, + 0.494887376202437487201E-02, + 0.498433569972103029914E-02, + 0.501958602202842039909E-02, + 0.505462145780650125058E-02, + 0.508943876461803986674E-02, + 0.512403472879005351831E-02, + 0.515840616547381084096E-02, + 0.519254991870341614863E-02, + 0.522646286145300596306E-02, + 0.526014189569259311205E-02, + 0.529358395244259896547E-02, + 0.532678599182711857974E-02, + 0.535974500312596681161E-02, + 0.539245800482555593606E-02, + 0.542492204466865704951E-02, + 0.545713419970309863995E-02, + 0.548909157632945623482E-02, + 0.552079131034778706457E-02, + 0.555223056700346326850E-02, + 0.558340654103215637610E-02, + 0.561431645670402467678E-02, + 0.564495756786715368885E-02, + 0.567532715799029830087E-02, + 0.570542254020497332312E-02, + 0.573524105734693719020E-02, + 0.576478008199711142954E-02, + 0.579403701652197628421E-02, + 0.582300929311348057702E-02, + 0.585169437382850155033E-02, + 0.588008975062788803205E-02, + 0.590819294541511788161E-02, + 0.593600151007459827614E-02, + 0.596351302650963502011E-02, + 0.599072510668009471472E-02, + 0.601763539263978131522E-02, + 0.604424155657354634589E-02, + 0.607054130083414983949E-02, + 0.609653235797888692923E-02, + 0.612221249080599294931E-02, + 0.614757949239083790214E-02, + 0.617263118612191922727E-02, + 0.619736542573665996342E-02, + 0.622178009535701763157E-02, + 0.624587310952490748541E-02, + 0.626964241323744217671E-02, + 0.629308598198198836688E-02, + 0.631620182177103938227E-02, + 0.633898796917690165912E-02, + 0.636144249136619145314E-02, + 0.638356348613413709795E-02, + 0.640534908193868098342E-02, + 0.642679743793437438922E-02, + 0.644790674400605734710E-02, + 0.646867522080231481688E-02, + 0.648910111976869964292E-02, + 0.650918272318071200827E-02, + 0.652891834417652442012E-02, + 0.654830632678944064054E-02, + 0.656734504598007641819E-02, + 0.658603290766824937794E-02, + 0.660436834876456498276E-02, + 0.662234983720168509457E-02, + 0.663997587196526532519E-02, + 0.665724498312454708217E-02, + 0.667415573186258997654E-02, + 0.669070671050613006584E-02, + 0.670689654255504925648E-02, + 0.672272388271144108036E-02, + 0.673818741690825799086E-02, + 0.675328586233752529078E-02, + 0.676801796747810680683E-02, + 0.678238251212300746082E-02, + 0.679637830740619795480E-02, + 0.681000419582894688374E-02, + 0.682325905128564571420E-02, + 0.683614177908911221841E-02, + 0.684865131599535812903E-02, + 0.686078663022780697951E-02, + 0.687254672150094831613E-02, + 0.688393062104341470995E-02, + 0.689493739162046825872E-02, + 0.690556612755588354803E-02, + 0.691581595475321433825E-02, + 0.692568603071643155621E-02, + 0.693517554456992049848E-02, + 0.694428371707782549438E-02, + 0.695300980066273063177E-02, + 0.696135307942366551493E-02, + 0.696931286915342540213E-02, + 0.697688851735519545845E-02, + 0.698407940325846925786E-02, + 0.699088493783425207545E-02, + 0.699730456380953992594E-02, + 0.700333775568106572820E-02, + 0.700898401972830440494E-02, + 0.701424289402572916425E-02, + 0.701911394845431165171E-02, + 0.702359678471225911031E-02, + 0.702769103632498213858E-02, + 0.703139636865428709508E-02, + 0.703471247890678765907E-02, + 0.703763909614153052319E-02, + 0.704017598127683066242E-02, + 0.704232292709631209597E-02, + 0.704407975825415053266E-02, + 0.704544633127951476780E-02, + 0.704642253458020417748E-02, + 0.704700828844548013730E-02, + 0.704720354504808967346E-02, + 0.704700828844548013730E-02, + 0.704642253458020417748E-02, + 0.704544633127951476780E-02, + 0.704407975825415053266E-02, + 0.704232292709631209597E-02, + 0.704017598127683066242E-02, + 0.703763909614153052319E-02, + 0.703471247890678765907E-02, + 0.703139636865428709508E-02, + 0.702769103632498213858E-02, + 0.702359678471225911031E-02, + 0.701911394845431165171E-02, + 0.701424289402572916425E-02, + 0.700898401972830440494E-02, + 0.700333775568106572820E-02, + 0.699730456380953992594E-02, + 0.699088493783425207545E-02, + 0.698407940325846925786E-02, + 0.697688851735519545845E-02, + 0.696931286915342540213E-02, + 0.696135307942366551493E-02, + 0.695300980066273063177E-02, + 0.694428371707782549438E-02, + 0.693517554456992049848E-02, + 0.692568603071643155621E-02, + 0.691581595475321433825E-02, + 0.690556612755588354803E-02, + 0.689493739162046825872E-02, + 0.688393062104341470995E-02, + 0.687254672150094831613E-02, + 0.686078663022780697951E-02, + 0.684865131599535812903E-02, + 0.683614177908911221841E-02, + 0.682325905128564571420E-02, + 0.681000419582894688374E-02, + 0.679637830740619795480E-02, + 0.678238251212300746082E-02, + 0.676801796747810680683E-02, + 0.675328586233752529078E-02, + 0.673818741690825799086E-02, + 0.672272388271144108036E-02, + 0.670689654255504925648E-02, + 0.669070671050613006584E-02, + 0.667415573186258997654E-02, + 0.665724498312454708217E-02, + 0.663997587196526532519E-02, + 0.662234983720168509457E-02, + 0.660436834876456498276E-02, + 0.658603290766824937794E-02, + 0.656734504598007641819E-02, + 0.654830632678944064054E-02, + 0.652891834417652442012E-02, + 0.650918272318071200827E-02, + 0.648910111976869964292E-02, + 0.646867522080231481688E-02, + 0.644790674400605734710E-02, + 0.642679743793437438922E-02, + 0.640534908193868098342E-02, + 0.638356348613413709795E-02, + 0.636144249136619145314E-02, + 0.633898796917690165912E-02, + 0.631620182177103938227E-02, + 0.629308598198198836688E-02, + 0.626964241323744217671E-02, + 0.624587310952490748541E-02, + 0.622178009535701763157E-02, + 0.619736542573665996342E-02, + 0.617263118612191922727E-02, + 0.614757949239083790214E-02, + 0.612221249080599294931E-02, + 0.609653235797888692923E-02, + 0.607054130083414983949E-02, + 0.604424155657354634589E-02, + 0.601763539263978131522E-02, + 0.599072510668009471472E-02, + 0.596351302650963502011E-02, + 0.593600151007459827614E-02, + 0.590819294541511788161E-02, + 0.588008975062788803205E-02, + 0.585169437382850155033E-02, + 0.582300929311348057702E-02, + 0.579403701652197628421E-02, + 0.576478008199711142954E-02, + 0.573524105734693719020E-02, + 0.570542254020497332312E-02, + 0.567532715799029830087E-02, + 0.564495756786715368885E-02, + 0.561431645670402467678E-02, + 0.558340654103215637610E-02, + 0.555223056700346326850E-02, + 0.552079131034778706457E-02, + 0.548909157632945623482E-02, + 0.545713419970309863995E-02, + 0.542492204466865704951E-02, + 0.539245800482555593606E-02, + 0.535974500312596681161E-02, + 0.532678599182711857974E-02, + 0.529358395244259896547E-02, + 0.526014189569259311205E-02, + 0.522646286145300596306E-02, + 0.519254991870341614863E-02, + 0.515840616547381084096E-02, + 0.512403472879005351831E-02, + 0.508943876461803986674E-02, + 0.505462145780650125058E-02, + 0.501958602202842039909E-02, + 0.498433569972103029914E-02, + 0.494887376202437487201E-02, + 0.491320350871841897367E-02, + 0.487732826815870573054E-02, + 0.484125139721057135214E-02, + 0.480497628118194150483E-02, + 0.476850633375474925263E-02, + 0.473184499691503264714E-02, + 0.469499574088179046532E-02, + 0.465796206403469754658E-02, + 0.462074749284080687482E-02, + 0.458335558178039420335E-02, + 0.454578991327213285488E-02, + 0.450805409759782158001E-02, + 0.447015177282692726900E-02, + 0.443208660474124713206E-02, + 0.439386228676004195260E-02, + 0.435548253986604343679E-02, + 0.431695111253279479928E-02, + 0.427827178065384480959E-02, + 0.423944834747438184434E-02, + 0.420048464352596631772E-02, + 0.416138452656509745764E-02, + 0.412215188151643401528E-02, + 0.408279062042157838350E-02, + 0.404330468239442998549E-02, + 0.400369803358421688562E-02, + 0.396397466714742455513E-02, + 0.392413860322995774660E-02, + 0.388419388896099560998E-02, + 0.384414459846013158917E-02, + 0.380399483285952829161E-02, + 0.376374872034296338241E-02, + 0.372341041620379550870E-02, + 0.368298410292403911967E-02, + 0.364247399027690353194E-02, + 0.360188431545532431869E-02, + 0.356121934322919357659E-02, + 0.352048336613417922682E-02, + 0.347968070469521146972E-02, + 0.343881570768790591876E-02, + 0.339789275244138669739E-02, + 0.335691624518616761342E-02, + 0.331589062145094394706E-02, + 0.327482034651233969564E-02, + 0.323370991590184336368E-02, + 0.319256385597434736790E-02, + 0.315138672454287935858E-02, + 0.311018311158427546158E-02, + 0.306895764002069252174E-02, + 0.302771496658198544480E-02, + 0.298645978275408290247E-02, + 0.294519681581857582284E-02, + 0.290393082998878368175E-02, + 0.286266662764757868253E-02, + 0.282140905069222207923E-02, + 0.278016298199139435045E-02, + 0.273893334695947541201E-02, + 0.269772511525294586667E-02, + 0.265654330259352828314E-02, + 0.261539297272236109225E-02, + 0.257427923948908888092E-02, + 0.253320726907925325750E-02, + 0.249218228238276930060E-02, + 0.245120955750556483923E-02, + 0.241029443242563417382E-02, + 0.236944230779380495146E-02, + 0.232865864987842738864E-02, + 0.228794899365195972378E-02, + 0.224731894601603393082E-02, + 0.220677418916003329194E-02, + 0.216632048404649142727E-02, + 0.212596367401472533045E-02, + 0.208570968849203942640E-02, + 0.204556454679958293446E-02, + 0.200553436203751169944E-02, + 0.196562534503150547732E-02, + 0.192584380831993546204E-02, + 0.188619617015808475394E-02, + 0.184668895851282540913E-02, + 0.180732881501808930079E-02, + 0.176812249885838886701E-02, + 0.172907689054461607168E-02, + 0.169019899554346019117E-02, + 0.165149594771914570655E-02, + 0.161297501254393423070E-02, + 0.157464359003212166189E-02, + 0.153650921735128916170E-02, + 0.149857957106456636214E-02, + 0.146086246895890987689E-02, + 0.142336587141720519900E-02, + 0.138609788229672549700E-02, + 0.134906674928353113127E-02, + 0.131228086370221478128E-02, + 0.127574875977346947345E-02, + 0.123947911332878396534E-02, + 0.120348074001265964881E-02, + 0.116776259302858043685E-02, + 0.113233376051597664917E-02, + 0.109720346268191941940E-02, + 0.106238104885340071375E-02, + 0.102787599466367326179E-02, + 0.993697899638760857945E-03, + 0.959856485506936206261E-03, + 0.926361595613111283368E-03, + 0.893223195879324912340E-03, + 0.860451377808527848128E-03, + 0.828056364077226302608E-03, + 0.796048517297550871506E-03, + 0.764438352543882784191E-03, + 0.733236554224767912055E-03, + 0.702453997827572321358E-03, + 0.672101776960108194646E-03, + 0.642191235948505088403E-03, + 0.612734008012225209294E-03, + 0.583742058714979703847E-03, + 0.555227733977307579715E-03, + 0.527203811431658386125E-03, + 0.499683553312800484519E-03, + 0.472680758429262691232E-03, + 0.446209810101403247488E-03, + 0.420285716355361231823E-03, + 0.394924138246873704434E-03, + 0.370141402122251665232E-03, + 0.345954492129903871350E-03, + 0.322381020652862389664E-03, + 0.299439176850911730874E-03, + 0.277147657465187357459E-03, + 0.255525589595236862014E-03, + 0.234592462123925204879E-03, + 0.214368090034216937149E-03, + 0.194872642236641146532E-03, + 0.176126765545083195474E-03, + 0.158151830411132242924E-03, + 0.140970302204104791413E-03, + 0.124606200241498368482E-03, + 0.109085545645741522051E-03, + 0.944366322532705527066E-04, + 0.806899228014035293851E-04, + 0.678774554733972416227E-04, + 0.560319507856164252140E-04, + 0.451863674126296143105E-04, + 0.353751372055189588628E-04, + 0.266376412339000901358E-04, + 0.190213681905875816679E-04, + 0.125792781889592743525E-04, + 0.736624069102321668857E-05, + 0.345456507169149134898E-05, + 0.945715933950007048827E-06, + 0.0}; for (int d = 0; d < N; d++) (*out_coefs)[d] = (_Tp)tmp_coefs[d]; } diff --git a/combigrid/src/sgpp/combigrid/quadratures/GaussPattersonQuadrature.hpp b/combigrid/src/sgpp/combigrid/quadratures/GaussPattersonQuadrature.hpp index 57f528e405..b811b14765 100644 --- a/combigrid/src/sgpp/combigrid/quadratures/GaussPattersonQuadrature.hpp +++ b/combigrid/src/sgpp/combigrid/quadratures/GaussPattersonQuadrature.hpp @@ -1,9 +1,7 @@ -/* **************************************************************************** -* Copyright (C) 2015 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Petar Tzenov +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef GAUSSPATTERSONQUADRATURE_HPP_ #define GAUSSPATTERSONQUADRATURE_HPP_ @@ -77,8 +75,7 @@ class GaussPattersonQuadrature : public AbstractQuadratureRule<_Tp> { */ _Tp gauss_patterson_fullGrid(int dim, _Tp (*f)(std::vector), - FGridContainer<_Tp>* gridContainer, - bool interpolate); + FGridContainer<_Tp>* gridContainer, bool interpolate); }; } // namespace combigrid diff --git a/combigrid/src/sgpp/combigrid/quadratures/QuadratureRule.cpp b/combigrid/src/sgpp/combigrid/quadratures/QuadratureRule.cpp index 6ca24df269..1fe02ff676 100644 --- a/combigrid/src/sgpp/combigrid/quadratures/QuadratureRule.cpp +++ b/combigrid/src/sgpp/combigrid/quadratures/QuadratureRule.cpp @@ -1,9 +1,7 @@ -/* **************************************************************************** -* Copyright (C) 2015 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Petar Tzenov +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include #include @@ -43,8 +41,7 @@ combigrid::QuadratureRule<_Tp>::QuadratureRule(int max_lvl) { #pragma omp parallel for schedule(dynamic, 1) for (int j = 0; j < NUM_QUADS; j++) { - coefficients[j] = - reinterpret_cast<_Tp**>(malloc(sizeof(_Tp*) * MAX_LEVELS[j])); + coefficients[j] = reinterpret_cast<_Tp**>(malloc(sizeof(_Tp*) * MAX_LEVELS[j])); for (int d = 1; d <= MAX_LEVELS[j]; d++) { /** @@ -54,8 +51,7 @@ combigrid::QuadratureRule<_Tp>::QuadratureRule(int max_lvl) { *levels 1,2... MAX_LEVELS's * * */ - QuadratureRule<_Tp>::calculateCoefficients(d, coefficients[j] + d - 1, - tuples[j]); + QuadratureRule<_Tp>::calculateCoefficients(d, coefficients[j] + d - 1, tuples[j]); } } } @@ -67,8 +63,7 @@ combigrid::QuadratureRule<_Tp>::QuadratureRule(std::vector lvls) { #pragma omp parallel for schedule(dynamic, 1) for (int j = 0; j < NUM_QUADS; j++) { - coefficients[j] = - reinterpret_cast<_Tp**>(malloc(sizeof(_Tp*) * MAX_LEVELS[j])); + coefficients[j] = reinterpret_cast<_Tp**>(malloc(sizeof(_Tp*) * MAX_LEVELS[j])); for (int d = 1; d <= MAX_LEVELS[j]; d++) { /** @@ -77,8 +72,7 @@ combigrid::QuadratureRule<_Tp>::QuadratureRule(std::vector lvls) { *levels 1,2... MAX_LEVELS's * * */ - QuadratureRule<_Tp>::calculateCoefficients(d, coefficients[j] + d - 1, - tuples[j]); + QuadratureRule<_Tp>::calculateCoefficients(d, coefficients[j] + d - 1, tuples[j]); } } } @@ -129,9 +123,8 @@ _Tp combigrid::QuadratureRule<_Tp>::integrate(CombiGrid<_Tp>* grids, for (int j = 0; j < nr_fullgrids; j++) { if (grids->getFullGrid(j)->isActive()) { - result += - (_Tp)grids->getCoef(j) * - quadrature_full_grid(dim, f, grids->getFullGrid(j), interpolate); + result += (_Tp)grids->getCoef(j) * + quadrature_full_grid(dim, f, grids->getFullGrid(j), interpolate); } } } @@ -140,12 +133,11 @@ _Tp combigrid::QuadratureRule<_Tp>::integrate(CombiGrid<_Tp>* grids, } template -_Tp combigrid::QuadratureRule<_Tp>::quadrature_full_grid( - int dim, _Tp (*f)(std::vector), FGridContainer<_Tp>* gridContainer, - bool interpolate) { +_Tp combigrid::QuadratureRule<_Tp>::quadrature_full_grid(int dim, _Tp (*f)(std::vector), + FGridContainer<_Tp>* gridContainer, + bool interpolate) { _Tp result = 0.0f; - FullGrid<_Tp>* grid = - gridContainer->fg(); // obtain a pointer to the fullgrid + FullGrid<_Tp>* grid = gridContainer->fg(); // obtain a pointer to the fullgrid /** select which coefficient matrix shall we choose, depending on the * stretching @@ -164,8 +156,7 @@ _Tp combigrid::QuadratureRule<_Tp>::quadrature_full_grid( if (dom_1d.getMinDomain() == n_INF && dom_1d.getMaxDomain() == p_INF) fully_infinite[d] = true; - coef_selector[d] = - stretchingToIdx(dom_1d.getStretchingType(), tuples, NUM_QUADS); + coef_selector[d] = stretchingToIdx(dom_1d.getStretchingType(), tuples, NUM_QUADS); if (dom_1d.getLevel() > MAX_LEVELS[coef_selector[d]]) { COMBIGRID_OUT_ERR( @@ -186,8 +177,7 @@ _Tp combigrid::QuadratureRule<_Tp>::quadrature_full_grid( *domain at that point... */ - unsigned int num_elem = - grid->getNrElements(); // get the total number of grid points + unsigned int num_elem = grid->getNrElements(); // get the total number of grid points // precomupte the function values depending on whether or // not the user wants to integrate an external function @@ -236,8 +226,8 @@ _Tp combigrid::QuadratureRule<_Tp>::quadrature_full_grid( jacobian_j *= (_Tp)domains[d].axisJacobian()[indices[d]]; } - f_values[j] = grid->getElementVector()[j] * - jacobian_j; // simply pick out the value on the grid... + f_values[j] = + grid->getElementVector()[j] * jacobian_j; // simply pick out the value on the grid... } } } else { @@ -261,8 +251,7 @@ _Tp combigrid::QuadratureRule<_Tp>::quadrature_full_grid( jacobian_j *= (_Tp)domains[d].axisJacobian()[indices[d]]; } - f_values[j] = - f(coords) * jacobian_j; // simply pick out the value on the grid... + f_values[j] = f(coords) * jacobian_j; // simply pick out the value on the grid... } } @@ -288,8 +277,7 @@ _Tp combigrid::QuadratureRule<_Tp>::quadrature_full_grid( int idx_d = indices[d]; int level = levels[d]; - if (idxToStretching(coef_selector[d], tuples, NUM_QUADS) == BASU && - fully_infinite[d]) { + if (idxToStretching(coef_selector[d], tuples, NUM_QUADS) == BASU && fully_infinite[d]) { int N_0 = powerOfTwo[level - 1]; if (idx_d <= N_0) @@ -309,9 +297,7 @@ _Tp combigrid::QuadratureRule<_Tp>::quadrature_full_grid( } template -int combigrid::QuadratureRule<_Tp>::stretchingToIdx(Stretching str, - QRtouple* qrtuples, - int size) { +int combigrid::QuadratureRule<_Tp>::stretchingToIdx(Stretching str, QRtouple* qrtuples, int size) { int idx = 0; for (int i = 0; i < size; i++) @@ -324,8 +310,8 @@ int combigrid::QuadratureRule<_Tp>::stretchingToIdx(Stretching str, } template -combigrid::Stretching combigrid::QuadratureRule<_Tp>::idxToStretching( - int idx, QRtouple* qrtuples, int size) { +combigrid::Stretching combigrid::QuadratureRule<_Tp>::idxToStretching(int idx, QRtouple* qrtuples, + int size) { Stretching str = EQUIDISTANT; for (int i = 0; i < size; i++) @@ -338,8 +324,7 @@ combigrid::Stretching combigrid::QuadratureRule<_Tp>::idxToStretching( } template -void combigrid::QuadratureRule<_Tp>::calculateCoefficients(int in_level, - _Tp** out_coefs, +void combigrid::QuadratureRule<_Tp>::calculateCoefficients(int in_level, _Tp** out_coefs, QRtouple rule) { switch (rule.key) { case EQUIDISTANT: // trapezoid diff --git a/combigrid/src/sgpp/combigrid/quadratures/QuadratureRule.hpp b/combigrid/src/sgpp/combigrid/quadratures/QuadratureRule.hpp index 14af259b23..e5a92180a7 100644 --- a/combigrid/src/sgpp/combigrid/quadratures/QuadratureRule.hpp +++ b/combigrid/src/sgpp/combigrid/quadratures/QuadratureRule.hpp @@ -1,9 +1,7 @@ -/* **************************************************************************** -* Copyright (C) 2015 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Petar Tzenov +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef GENERALQUADRATURE_HPP_ #define GENERALQUADRATURE_HPP_ @@ -74,8 +72,7 @@ class QuadratureRule : public AbstractQuadratureRule<_Tp> { _Tp integrate(CombiGrid<_Tp>* grids, _Tp (*f)(std::vector) = NULL); - static void calculateCoefficients(int in_level, _Tp** out_coefs, - QRtouple rule); + static void calculateCoefficients(int in_level, _Tp** out_coefs, QRtouple rule); private: /** @@ -83,8 +80,7 @@ class QuadratureRule : public AbstractQuadratureRule<_Tp> { * */ _Tp quadrature_full_grid(int dim, _Tp (*f)(std::vector), - FGridContainer<_Tp>* gridContainer, - bool interpolate); + FGridContainer<_Tp>* gridContainer, bool interpolate); std::vector MAX_LEVELS; /* Container for the pre-computed coefs for levels 1,2... MAX_LEVELS. diff --git a/combigrid/src/sgpp/combigrid/quadratures/TrapezoidalRule.cpp b/combigrid/src/sgpp/combigrid/quadratures/TrapezoidalRule.cpp index dc82dd859f..d76fe156de 100644 --- a/combigrid/src/sgpp/combigrid/quadratures/TrapezoidalRule.cpp +++ b/combigrid/src/sgpp/combigrid/quadratures/TrapezoidalRule.cpp @@ -1,9 +1,7 @@ -/* **************************************************************************** -* Copyright (C) 2015 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Petar Tzenov +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include #include @@ -118,9 +116,8 @@ _Tp combigrid::TrapezoidalRule<_Tp>::integrate(CombiGrid<_Tp>* grids, __FILE__, __LINE__); error_flag++; } else { - result += - (_Tp)grids->getCoef(j) * - trapz_full_grid(dim, f, grids->getFullGrid(j), badstretching); + result += (_Tp)grids->getCoef(j) * + trapz_full_grid(dim, f, grids->getFullGrid(j), badstretching); } } } @@ -132,16 +129,14 @@ _Tp combigrid::TrapezoidalRule<_Tp>::integrate(CombiGrid<_Tp>* grids, } template -_Tp combigrid::TrapezoidalRule<_Tp>::trapz_full_grid( - int dim, _Tp (*f)(std::vector), FGridContainer<_Tp>* gridContainer, - bool badstretching) { +_Tp combigrid::TrapezoidalRule<_Tp>::trapz_full_grid(int dim, _Tp (*f)(std::vector), + FGridContainer<_Tp>* gridContainer, + bool badstretching) { _Tp result = 0.0f; - FullGrid<_Tp>* grid = - gridContainer->fg(); // obtain a pointer to the fullgrid + FullGrid<_Tp>* grid = gridContainer->fg(); // obtain a pointer to the fullgrid std::vector<_Tp> f_values; CombiEquidistantStretching stretching = CombiEquidistantStretching(); - AbstractQuadratureRule<_Tp>::getGridValues(grid, badstretching, &stretching, - &f_values, f); + AbstractQuadratureRule<_Tp>::getGridValues(grid, badstretching, &stretching, &f_values, f); /*** * At this point of the evaluation we already have the functional values @@ -153,8 +148,7 @@ _Tp combigrid::TrapezoidalRule<_Tp>::trapz_full_grid( *functional values by the weights * and sum the results up... */ - unsigned int num_elem = - grid->getNrElements(); // get the total number of grid points + unsigned int num_elem = grid->getNrElements(); // get the total number of grid points std::vector indices(dim, 0); std::vector levels = gridContainer->getFGLevels(); @@ -177,8 +171,7 @@ _Tp combigrid::TrapezoidalRule<_Tp>::trapz_full_grid( } template -void combigrid::TrapezoidalRule<_Tp>::calculateCoefficients(int in_level, - _Tp** out_coefs) { +void combigrid::TrapezoidalRule<_Tp>::calculateCoefficients(int in_level, _Tp** out_coefs) { int N = powerOfTwo[in_level] + 1; *out_coefs = reinterpret_cast<_Tp*>(malloc(N * sizeof(_Tp))); diff --git a/combigrid/src/sgpp/combigrid/quadratures/TrapezoidalRule.hpp b/combigrid/src/sgpp/combigrid/quadratures/TrapezoidalRule.hpp index 861827cd49..9b724a80ee 100644 --- a/combigrid/src/sgpp/combigrid/quadratures/TrapezoidalRule.hpp +++ b/combigrid/src/sgpp/combigrid/quadratures/TrapezoidalRule.hpp @@ -1,9 +1,7 @@ -/* **************************************************************************** -* Copyright (C) 2015 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Petar Tzenov +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef TRAPEZOIDAL_QUADRATURE__HPP #define TRAPEZOIDAL_QUADRATURE__HPP @@ -73,8 +71,8 @@ class TrapezoidalRule : public AbstractQuadratureRule<_Tp> { * Do a full grid trapezoidal rule over a single dim-dimensional FULL GRID. * */ - _Tp trapz_full_grid(int dim, _Tp (*f)(std::vector), - FGridContainer<_Tp>* gridContainer, bool interpolate); + _Tp trapz_full_grid(int dim, _Tp (*f)(std::vector), FGridContainer<_Tp>* gridContainer, + bool interpolate); int MAX_LEVELS; /* Container for the pre-computed coefs for levels 1,2... MAX_LEVELS. diff --git a/combigrid/src/sgpp/combigrid/utils/CombigridLevelVector.cpp b/combigrid/src/sgpp/combigrid/utils/CombigridLevelVector.cpp index d3b28792d4..41f52d9fde 100644 --- a/combigrid/src/sgpp/combigrid/utils/CombigridLevelVector.cpp +++ b/combigrid/src/sgpp/combigrid/utils/CombigridLevelVector.cpp @@ -1,13 +1,13 @@ -/* **************************************************************************** -* Copyright (C) 2011 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Christoph Kowitz (kowitz@in.tum.de) +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #include -using namespace combigrid; +#include + +namespace combigrid { const int CombigridLevelVector::LEVELMAX = 128; @@ -21,8 +21,7 @@ CombigridLevelVector::CombigridLevelVector(std::vector level) { coef_.push_back(1); } -CombigridLevelVector::CombigridLevelVector(std::vector level, - double coef) { +CombigridLevelVector::CombigridLevelVector(std::vector level, double coef) { levelVec_.push_back(level); coef_.push_back(coef); } @@ -33,8 +32,7 @@ CombigridLevelVector::CombigridLevelVector(std::vector > in, doAddition(); } -CombigridLevelVector& CombigridLevelVector::operator=( - const CombigridLevelVector& rhs) { +CombigridLevelVector& CombigridLevelVector::operator=(const CombigridLevelVector& rhs) { if (this == &rhs) return (*this); levelVec_ = rhs.getLevelVec(); @@ -42,8 +40,7 @@ CombigridLevelVector& CombigridLevelVector::operator=( return (*this); } -const CombigridLevelVector CombigridLevelVector::operator*( - const CombigridLevelVector& b) const { +const CombigridLevelVector CombigridLevelVector::operator*(const CombigridLevelVector& b) const { std::vector > result; std::vector buffer(b.getDim()); std::vector c; @@ -51,8 +48,7 @@ const CombigridLevelVector CombigridLevelVector::operator*( for (int i = 0; i < getN(); ++i) { for (int j = 0; j < b.getN(); ++j) { for (int k = 0; k < b.getDim(); ++k) { - buffer[k] = levelVec_[i][k] < b.levelVec_[j][k] ? levelVec_[i][k] - : b.levelVec_[j][k]; + buffer[k] = levelVec_[i][k] < b.levelVec_[j][k] ? levelVec_[i][k] : b.levelVec_[j][k]; } result.push_back(buffer); @@ -62,8 +58,7 @@ const CombigridLevelVector CombigridLevelVector::operator*( return CombigridLevelVector(result, c); } -const CombigridLevelVector CombigridLevelVector::operator-( - const CombigridLevelVector& b) const { +const CombigridLevelVector CombigridLevelVector::operator-(const CombigridLevelVector& b) const { CombigridLevelVector result(*this), inVec(b); for (int i = 0; i < b.getN(); ++i) { @@ -73,8 +68,7 @@ const CombigridLevelVector CombigridLevelVector::operator-( return result + inVec; } -const CombigridLevelVector CombigridLevelVector::operator+( - const CombigridLevelVector& b) const { +const CombigridLevelVector CombigridLevelVector::operator+(const CombigridLevelVector& b) const { CombigridLevelVector result(*this); for (int i = 0; i < b.getN(); ++i) { @@ -87,8 +81,8 @@ const CombigridLevelVector CombigridLevelVector::operator+( } void CombigridLevelVector::doAddition() { - for (int i = 0; i < (int)levelVec_.size(); ++i) { - for (int j = i + 1; j < (int)levelVec_.size(); ++j) { + for (int i = 0; i < static_cast(levelVec_.size()); ++i) { + for (int j = i + 1; j < static_cast(levelVec_.size()); ++j) { bool same = true; for (int k = 0; k < getDim(); ++k) { @@ -123,12 +117,11 @@ void CombigridLevelVector::printLevelVec() { } } -CombigridLevelVector CombigridLevelVector::getCombiLevels( - std::vector in) { +CombigridLevelVector CombigridLevelVector::getCombiLevels(std::vector in) { CombigridLevelVector unity(in[0].getDim()); CombigridLevelVector erg = unity - in[0]; - for (int i = 1; i < (int)in.size(); ++i) { + for (int i = 1; i < static_cast(in.size()); ++i) { erg = erg * (unity - in[i]); } @@ -136,11 +129,10 @@ CombigridLevelVector CombigridLevelVector::getCombiLevels( return erg; } -CombigridLevelVector CombigridLevelVector::getCombiLevels( - std::vector > in) { +CombigridLevelVector CombigridLevelVector::getCombiLevels(std::vector > in) { std::vector buffer; - for (int i = 0; i < (int)in.size(); ++i) { + for (int i = 0; i < static_cast(in.size()); ++i) { buffer.push_back(CombigridLevelVector(in[i])); } @@ -157,8 +149,7 @@ std::vector CombigridLevelVector::split() { return buffer; } -CombigridLevelVector CombigridLevelVector::getCombiLevels( - CombigridLevelVector in) { +CombigridLevelVector CombigridLevelVector::getCombiLevels(CombigridLevelVector in) { in.doAddition(); // for (int i = 0; i < in.getN(); ++i) { // if(in.getCoef()[i]!=1) { @@ -186,3 +177,4 @@ CombigridLevelVector CombigridLevelVector::getChanges(std::vector in) { void CombigridLevelVector::update(std::vector in) { (*this) = (*this) + (*this).getChanges(in); } +} // namespace combigrid diff --git a/combigrid/src/sgpp/combigrid/utils/CombigridLevelVector.hpp b/combigrid/src/sgpp/combigrid/utils/CombigridLevelVector.hpp index e50322b5a7..efe144d9c7 100644 --- a/combigrid/src/sgpp/combigrid/utils/CombigridLevelVector.hpp +++ b/combigrid/src/sgpp/combigrid/utils/CombigridLevelVector.hpp @@ -1,15 +1,15 @@ -/* **************************************************************************** -* Copyright (C) 2011 Technische Universitaet Muenchen * -* This file is part of the SG++ project. For conditions of distribution and * -* use, please see the copyright notice at http://www5.in.tum.de/SGpp * -**************************************************************************** */ -// @author Christoph Kowitz +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org #ifndef COMBIGRIDLEVELVECTOR_HPP_ #define COMBIGRIDLEVELVECTOR_HPP_ #include +#include + namespace combigrid { /**Levelvector allowing computations done in hegland.2003.adaptive equation (16) @@ -21,23 +21,22 @@ class CombigridLevelVector { public: /**Creates CombigridLevelVector containing the levels of one grid. The * dimension of the grid is determined by the size of the input vector */ - CombigridLevelVector(std::vector level); + explicit CombigridLevelVector(std::vector level); /**Creates an CombiGridLevelVector of a certain dimension, with all levels * having the maximum size. This can be used as a unity operator * for the multiplication.*/ - CombigridLevelVector(int dim); + explicit CombigridLevelVector(int dim); /** Creates an empty CombigridLevelVector*/ CombigridLevelVector() { levelVec_.resize(0); coef_.resize(0); - }; + } /** Creates an CombigridLevelVector with a certain coefficient. Might only * be used in rare cases.*/ CombigridLevelVector(std::vector level, double coef); /** Creates a complete set of fullgrids including their coefficients.*/ - CombigridLevelVector(std::vector > in, - std::vector coef); + CombigridLevelVector(std::vector > in, std::vector coef); /** Returns all full Grid level vectors*/ std::vector > getLevelVec() const { return levelVec_; } @@ -51,10 +50,10 @@ class CombigridLevelVector { std::vector getCoef() const { return coef_; } /** Returns the dimensionality of the grids*/ - int getDim() const { return int(levelVec_[0].size()); } + int getDim() const { return static_cast(levelVec_[0].size()); } /** Returns the number of full grids */ - int getN() const { return int(levelVec_.size()); } + int getN() const { return static_cast(levelVec_.size()); } CombigridLevelVector& operator=(const CombigridLevelVector& rhs); @@ -80,8 +79,7 @@ class CombigridLevelVector { * Function creating the levels of a combigrid containing all subgrids * provided in the Combigridlevelvectors */ - static CombigridLevelVector getCombiLevels( - std::vector in); + static CombigridLevelVector getCombiLevels(std::vector in); /** * Function creating the levels of a combigrid containing all subgrids * provided in the Combigridlevelvectors @@ -105,6 +103,6 @@ class CombigridLevelVector { std::vector > levelVec_; std::vector coef_; }; -} +} // namespace combigrid #endif /* COMBIGRIDLEVELVECTOR_HPP_ */ diff --git a/combigrid/src/sgpp/combigrid/utils/combigrid_utils.hpp b/combigrid/src/sgpp/combigrid/utils/combigrid_utils.hpp index 232a4e3bdd..3e96ce83c5 100644 --- a/combigrid/src/sgpp/combigrid/utils/combigrid_utils.hpp +++ b/combigrid/src/sgpp/combigrid/utils/combigrid_utils.hpp @@ -1,14 +1,19 @@ -/* **************************************************************************** - * Copyright (C) 2010 Technische Universitaet Muenchen * - * This file is part of the SG++ project. For conditions of distribution and * - * use, please see the copyright notice at http://www5.in.tum.de/SGpp * - **************************************************************************** */ -// @author Janos Benk +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + #ifndef COMBIGRID_ULTILS_HPP_ #define COMBIGRID_ULTILS_HPP_ /** In this hpp file we define the utilities for the combination technique */ #include +#include +#include + +// include open mp for shared memory programming +#include + #include #include #include @@ -18,8 +23,6 @@ #include #include #include -#include -#include #define ABS(x) x < 0 ? -x : x #define UNDEFINED_OPERATION_EXCEPTION -1 @@ -32,9 +35,6 @@ #define p_INF DBL_MAX #define n_INF -(DBL_MAX) -// include open mp for shared memory programming -#include - // useful for checking the fullgrid vs coefficient template type precedence.. . /** @@ -53,7 +53,6 @@ *exception (as _FGTp > _CFTp ) * */ -using namespace std; template void check_type_precedence() { @@ -74,17 +73,11 @@ typedef std::vector DVector; typedef std::vector IVector; -#define COMBIGRID_OUT_WRN(str, FILE, LINE) \ - { \ - std::cout << "\nWARNING: (in FILE:" << FILE << "; LINE:" << LINE \ - << ") :\n" << str << "\n"; \ - } +#define COMBIGRID_OUT_WRN(str, FILE, LINE) \ + { std::cout << "\nWARNING: (in FILE:" << FILE << "; LINE:" << LINE << ") :\n" << str << "\n"; } -#define COMBIGRID_OUT_ERR(str, FILE, LINE) \ - { \ - std::cout << "FILE:" << FILE << " LINE:" << LINE << ": \n ERROR:" << str \ - << "\n"; \ - } +#define COMBIGRID_OUT_ERR(str, FILE, LINE) \ + { std::cout << "FILE:" << FILE << " LINE:" << LINE << ": \n ERROR:" << str << "\n"; } #define COMBIGRID_OUT(str) \ { std::cout << str << std::endl; }; @@ -98,8 +91,9 @@ typedef std::vector IVector; #define COMBIGRID_ERROR_TEST_EQUAL(val1, val2, tolerance, str) \ { \ if (fabs(val1 - val2) > tolerance) { \ - std::cout << std::endl << "ERROR: " << str << " , v1:" << val1 \ - << " , v2:" << val2 << " , tol:" << tolerance << std::endl; \ + std::cout << std::endl \ + << "ERROR: " << str << " , v1:" << val1 << " , v2:" << val2 \ + << " , tol:" << tolerance << std::endl; \ assert(false); \ } \ } @@ -143,36 +137,28 @@ typedef std::vector IVector; namespace combigrid { /** vector with power two */ -const int powerOfTwo[30] = {1, 2, 4, 8, 16, - 32, 64, 128, 256, 512, - 1024, 2048, 4096, 8192, 16384, - 32768, 65536, 131072, 262144, 524288, - 1048576, 2097152, 4194304, 8388608, 16777216, - 33554432, 67108864, 134217728, 268435456}; +const int powerOfTwo[30] = { + 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, + 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, + 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456}; /** vector with one over power two */ const double oneOverPowOfTwo[30] = { - 1.0 / 1.0, 1.0 / 2.0, 1.0 / 4.0, 1.0 / 8.0, - 1.0 / 16.0, 1.0 / 32.0, 1.0 / 64.0, 1.0 / 128.0, - 1.0 / 256.0, 1.0 / 512.0, 1.0 / 1024.0, 1.0 / 2048.0, - 1.0 / 4096.0, 1.0 / 8192.0, 1.0 / 16384.0, 1.0 / 32768.0, - 1.0 / 65536.0, 1.0 / 131072.0, 1.0 / 262144.0, 1.0 / 524288.0, - 1.0 / 1048576.0, 1.0 / 2097152.0, 1.0 / 4194304.0, 1.0 / 8388608.0, - 1.0 / 16777216.0, 1.0 / 33554432.0, 1.0 / 67108864.0, 1.0 / 134217728.0, - 1.0 / 268435456.0}; + 1.0 / 1.0, 1.0 / 2.0, 1.0 / 4.0, 1.0 / 8.0, 1.0 / 16.0, + 1.0 / 32.0, 1.0 / 64.0, 1.0 / 128.0, 1.0 / 256.0, 1.0 / 512.0, + 1.0 / 1024.0, 1.0 / 2048.0, 1.0 / 4096.0, 1.0 / 8192.0, 1.0 / 16384.0, + 1.0 / 32768.0, 1.0 / 65536.0, 1.0 / 131072.0, 1.0 / 262144.0, 1.0 / 524288.0, + 1.0 / 1048576.0, 1.0 / 2097152.0, 1.0 / 4194304.0, 1.0 / 8388608.0, 1.0 / 16777216.0, + 1.0 / 33554432.0, 1.0 / 67108864.0, 1.0 / 134217728.0, 1.0 / 268435456.0}; /** the maximum double value */ -inline double COMBIGRID_DMAX(double v1, double v2) { - return (v1 < v2) ? v2 : v1; -} +inline double COMBIGRID_DMAX(double v1, double v2) { return (v1 < v2) ? v2 : v1; } /** the maximum int value */ inline int COMBIGRID_IMAX(int v1, int v2) { return (v1 < v2) ? v2 : v1; } /** the minimum double value */ -inline double COMBIGRID_DMIN(double v1, double v2) { - return (v1 > v2) ? v2 : v1; -} +inline double COMBIGRID_DMIN(double v1, double v2) { return (v1 > v2) ? v2 : v1; } /** the minimum int value */ inline int COMBIGRID_IMIN(int v1, int v2) { return (v1 > v2) ? v2 : v1; } @@ -197,7 +183,7 @@ inline double l2_norm(std::vector* v1) { diff = diff + v1->at(i) * v1->at(i); } - return sqrt(diff / double(v1->size())); + return sqrt(diff / static_cast(v1->size())); } /** calculates the Inf norm of one vector*/ @@ -214,9 +200,9 @@ inline double inf_norm(std::vector* v1) { /** multiply two vectors, result will be in the first vector */ inline void vect_mul(std::vector* v1, std::vector* v2) { - COMBIGRID_ERROR_TEST(v1->size() == v2->size(), - " vect_mul , size do not match v1->size():" - << v1->size() << " , v2->size():" << v2->size()); + COMBIGRID_ERROR_TEST( + v1->size() == v2->size(), + " vect_mul , size do not match v1->size():" << v1->size() << " , v2->size():" << v2->size()); for (unsigned int i = 0; i < v1->size(); i++) { v1->at(i) = v1->at(i) * v2->at(i); @@ -225,9 +211,9 @@ inline void vect_mul(std::vector* v1, std::vector* v2) { /** difference of two vectors, result will be in the first vector */ inline void vect_diff(std::vector* v1, std::vector* v2) { - COMBIGRID_ERROR_TEST(v1->size() == v2->size(), - " vect_diff , size do not match v1->size():" - << v1->size() << " , v2->size():" << v2->size()); + COMBIGRID_ERROR_TEST( + v1->size() == v2->size(), + " vect_diff , size do not match v1->size():" << v1->size() << " , v2->size():" << v2->size()); for (unsigned int i = 0; i < v1->size(); i++) { v1->at(i) = v1->at(i) - v2->at(i); @@ -237,9 +223,9 @@ inline void vect_diff(std::vector* v1, std::vector* v2) { /** v1 = coefv1*v1 + coefv2 * v2 */ inline void vect_add_mul(double coefv1, std::vector* v1, double coefv2, std::vector* v2) { - COMBIGRID_ERROR_TEST(v1->size() == v2->size(), - " vect_add_mul , size do not match v1->size():" - << v1->size() << " , v2->size():" << v2->size()); + COMBIGRID_ERROR_TEST(v1->size() == v2->size(), " vect_add_mul , size do not match v1->size():" + << v1->size() + << " , v2->size():" << v2->size()); for (unsigned int i = 0; i < v1->size(); i++) { v1->at(i) = coefv1 * v1->at(i) + coefv2 * v2->at(i); @@ -247,11 +233,10 @@ inline void vect_add_mul(double coefv1, std::vector* v1, double coefv2, } /** computes the scalar product of two vectors */ -inline void scalar_product(std::vector* v1, std::vector* v2, - double& result) { - COMBIGRID_ERROR_TEST(v1->size() == v2->size(), - " vect_add_mul , size do not match v1->size():" - << v1->size() << " , v2->size():" << v2->size()); +inline void scalar_product(std::vector* v1, std::vector* v2, double& result) { + COMBIGRID_ERROR_TEST(v1->size() == v2->size(), " vect_add_mul , size do not match v1->size():" + << v1->size() + << " , v2->size():" << v2->size()); result = 0.0; for (unsigned int i = 0; i < v1->size(); i++) { @@ -267,8 +252,7 @@ inline void vect_setvalue(std::vector* v1, double newValue) { } /** plot one vector */ -inline void plot_vect(int level, int verb, std::vector* v1, - const char* stri) { +inline void plot_vect(int level, int verb, std::vector* v1, const char* stri) { if (verb > level) { std::cout << stri << "=[" << v1->at(0); @@ -279,6 +263,6 @@ inline void plot_vect(int level, int verb, std::vector* v1, std::cout << "];" << std::endl; } } -} +} // namespace combigrid #endif /* COMBIGRID_ULTILS_HPP_ */ diff --git a/datadriven/SConscript b/datadriven/SConscript index 1e376732e9..3eac875214 100755 --- a/datadriven/SConscript +++ b/datadriven/SConscript @@ -17,6 +17,7 @@ Import('installTargetList') Import('exampleTargetList') Import('headerSourceList') Import('headerDestList') +Import('lintAction') avxFolders = ['src/sgpp/datadriven/operation/hash/OperationMultipleEvalSubspace/', 'src/sgpp/datadriven/operation/hash/OperationMultiEvalStreaming'] @@ -49,21 +50,31 @@ if env['USE_OCL']: moduleDependencies = moduleDependencies + additionalDependencies +cpps = [] +hpps = [] objs = [] + for currentFolder, subdirNames, fileNames in os.walk("src", topdown=True): if os.path.exists(os.path.join(currentFolder, "SConscript")): - objsSubmodule = env.SConscript(os.path.join(currentFolder, "SConscript")) + cppsSubmodule, hppsSubmodule, objsSubmodule = \ + env.SConscript(os.path.join(currentFolder, "SConscript")) objs += objsSubmodule + for hpp in hppsSubmodule: + headerSourceList.append(os.path.join(moduleName, hpp)) + headerDestList.append(hpp.split(os.sep, 1)[1]) # remove subfolders from iteration, as they are already processed (this is why topdown=True is also required subdirNames[:] = [] else: for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) if currentFolder != 'src': for fileName in fnmatch.filter(fileNames, '*.hpp'): - headerSourceList.append(os.path.join(moduleName, currentFolder, fileName)) - headerDestList.append(os.path.join(currentFolder, fileName).split(os.sep,1)[1]) + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + headerSourceList.append(os.path.join(moduleName, hpp)) + headerDestList.append(hpp.split(os.sep, 1)[1]) env.AppendUnique(LIBPATH=[BUILD_DIR]) @@ -90,6 +101,11 @@ for lib_str in moduleDependencies: libInstall = env.Install(BUILD_DIR, lib) +if env['RUN_CPPLINT']: + for path in cpps + hpps: + lintCommand = env.Command(path + ".lint", path, lintAction) + env.Depends(lib, lintCommand) + if not env['NO_UNIT_TESTS'] and env['SG_PYTHON']: Import('testTargetList') py_test_env = env.Clone() diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultiEvalModMaskStreaming/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultiEvalModMaskStreaming/SConscript index 714e9d4a17..4f69e7b4ab 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultiEvalModMaskStreaming/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultiEvalModMaskStreaming/SConscript @@ -3,10 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if not '-msse3' in env['CPPFLAGS'] and env['USE_DOUBLE_PRECISION']: for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') \ No newline at end of file + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultiEvalStreaming/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultiEvalStreaming/SConscript index d428c2d889..ce7ad09568 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultiEvalStreaming/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultiEvalStreaming/SConscript @@ -3,11 +3,20 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if not '-msse3' in env['CPPFLAGS'] and env['USE_DOUBLE_PRECISION']: print "compling with avx+ source!!!" for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') \ No newline at end of file + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalAdaptiveOCL/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalAdaptiveOCL/SConscript index 4dfd44fc89..a08c598e98 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalAdaptiveOCL/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalAdaptiveOCL/SConscript @@ -3,10 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if env['USE_OCL']: for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') \ No newline at end of file + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingBSplineOCL/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingBSplineOCL/SConscript index 4dfd44fc89..a08c598e98 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingBSplineOCL/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingBSplineOCL/SConscript @@ -3,10 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if env['USE_OCL']: for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') \ No newline at end of file + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingMaskOCL/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingMaskOCL/SConscript index 4dfd44fc89..a08c598e98 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingMaskOCL/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingMaskOCL/SConscript @@ -3,10 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if env['USE_OCL']: for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') \ No newline at end of file + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCL/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCL/SConscript index 4dfd44fc89..a08c598e98 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCL/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCL/SConscript @@ -3,10 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if env['USE_OCL']: for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') \ No newline at end of file + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLFast/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLFast/SConscript index 4dfd44fc89..a08c598e98 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLFast/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLFast/SConscript @@ -3,10 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if env['USE_OCL']: for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') \ No newline at end of file + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLFastMultiPlattform/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLFastMultiPlattform/SConscript index 4dfd44fc89..a08c598e98 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLFastMultiPlattform/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLFastMultiPlattform/SConscript @@ -3,10 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if env['USE_OCL']: for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') \ No newline at end of file + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLMask/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLMask/SConscript index 4dfd44fc89..a08c598e98 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLMask/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLMask/SConscript @@ -3,10 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if env['USE_OCL']: for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') \ No newline at end of file + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLMaskMultiPlatform/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLMaskMultiPlatform/SConscript index 4dfd44fc89..a08c598e98 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLMaskMultiPlatform/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingModOCLMaskMultiPlatform/SConscript @@ -3,10 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if env['USE_OCL']: for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') \ No newline at end of file + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingOCL/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingOCL/SConscript index 4dfd44fc89..a08c598e98 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingOCL/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingOCL/SConscript @@ -3,10 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if env['USE_OCL']: for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') \ No newline at end of file + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingOCLMultiPlatform/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingOCLMultiPlatform/SConscript index 4dfd44fc89..a08c598e98 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingOCLMultiPlatform/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalStreamingOCLMultiPlatform/SConscript @@ -3,10 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if env['USE_OCL']: for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') \ No newline at end of file + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalSubspace/SConscript b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalSubspace/SConscript index 8becd640d9..e7cad6b79a 100644 --- a/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalSubspace/SConscript +++ b/datadriven/src/sgpp/datadriven/operation/hash/OperationMultipleEvalSubspace/SConscript @@ -3,10 +3,19 @@ import fnmatch Import('env') +cpps = [] +hpps = [] objs = [] + if env['ARCH'] == "avx" or env['ARCH'] == "avx2" or env['ARCH'] == "avx512": for currentFolder, subdirNames, fileNames in os.walk("."): for fileName in fnmatch.filter(fileNames, '*.cpp'): - sourceFile = os.path.join(currentFolder, fileName) - objs.append(env.SharedObject(sourceFile)) -Return('objs') + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) + for fileName in fnmatch.filter(fileNames, '*.hpp'): + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + +returnTuple = (cpps, hpps, objs) +Return('returnTuple') diff --git a/finance/SConscript b/finance/SConscript index 419743a085..a542d0b602 100755 --- a/finance/SConscript +++ b/finance/SConscript @@ -17,6 +17,7 @@ Import('installTargetList') Import('exampleTargetList') Import('headerSourceList') Import('headerDestList') +Import('lintAction') moduleDependencies = ['sgpppde', 'sgppsolver', 'sgppbase'] Export('moduleDependencies') @@ -28,18 +29,21 @@ if env['USE_STATICLIB']: moduleDependencies[i] = "%sstatic" % moduleDependencies[i] Export('libname') -srcs = [] +cpps = [] +hpps = [] +objs = [] + for currentFolder, subdirNames, fileNames in os.walk("src"): for fileName in fnmatch.filter(fileNames, '*.cpp'): - srcs.append(os.path.join(currentFolder, fileName)) + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) if currentFolder != 'src': for fileName in fnmatch.filter(fileNames, '*.hpp'): - headerSourceList.append(os.path.join(moduleName, currentFolder, fileName)) - headerDestList.append(os.path.join(currentFolder, fileName).split(os.sep,1)[1]) - -objs = [] -for sourceFile in srcs: - objs.append(env.SharedObject(sourceFile)) + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + headerSourceList.append(os.path.join(moduleName, hpp)) + headerDestList.append(hpp.split(os.sep, 1)[1]) if env['USE_STATICLIB']: # building static libraries is the same for unix and windows platforms @@ -64,6 +68,11 @@ for lib_str in moduleDependencies: libInstall = env.Install(BUILD_DIR, lib) +if env['RUN_CPPLINT']: + for path in cpps + hpps: + lintCommand = env.Command(path + ".lint", path, lintAction) + env.Depends(lib, lintCommand) + if not env['NO_UNIT_TESTS'] and env['SG_PYTHON']: Import('testTargetList') py_test_env = env.Clone() diff --git a/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystem.cpp b/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystem.cpp index cbf9b1f6e1..4844674a6c 100644 --- a/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystem.cpp +++ b/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystem.cpp @@ -8,39 +8,36 @@ #include #include #include -#include #include +#include +#include +#include namespace SGPP { namespace finance { BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, - SGPP::base::DataVector& lambda, - SGPP::base::DataMatrix& eigenvecs, SGPP::base::DataVector& mu_hat, - float_t TimestepSize, std::string OperationMode, - float_t dStrike, std::string option_type, - bool useCoarsen, float_t coarsenThreshold, std::string adaptSolveMode, - int numCoarsenPoints, float_t refineThreshold, std::string refineMode, - SGPP::base::GridIndex::level_type refineMaxLevel) { + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& lambda, + SGPP::base::DataMatrix& eigenvecs, SGPP::base::DataVector& mu_hat, float_t TimestepSize, + std::string OperationMode, float_t dStrike, std::string option_type, bool useCoarsen, + float_t coarsenThreshold, std::string adaptSolveMode, int numCoarsenPoints, + float_t refineThreshold, std::string refineMode, + SGPP::base::GridIndex::level_type refineMaxLevel) { this->BoundGrid = &SparseGrid; this->alpha_complete = α this->alpha_complete_old = new SGPP::base::DataVector(*this->alpha_complete); this->alpha_complete_tmp = new SGPP::base::DataVector(*this->alpha_complete); - this->oldGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); - this->secondGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); + this->oldGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); + this->secondGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); this->tOperationMode = OperationMode; this->TimestepSize = TimestepSize; this->TimestepSize_old = TimestepSize; - this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector( - SparseGrid.getStorage()); + this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector(SparseGrid.getStorage()); this->BSalgoDims = this->BoundGrid->getAlgorithmicDimensions(); // set Eigenvalues, Eigenvector of covariance matrix and mu_hat @@ -50,18 +47,25 @@ BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem // throw exception if grid dimensions not equal algorithmic dimensions if (this->BSalgoDims.size() > this->BoundGrid->getStorage()->dim()) { - throw SGPP::base::algorithm_exception("BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystemn : Number of algorithmic dimensions higher than the number of grid's dimensions."); + throw SGPP::base::algorithm_exception( + "BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystemn : " + "Number of algorithmic dimensions higher than the number of grid's dimensions."); } - // test if number of dimensions in the coefficients match the numbers of grid dimensions (mu and sigma) + // test if number of dimensions in the coefficients match the numbers of grid dimensions (mu and + // sigma) if (this->BoundGrid->getStorage()->dim() != this->lambda->getSize()) { - throw SGPP::base::algorithm_exception("BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem : Dimension of mu and sigma parameters don't match the grid's dimensions!"); + throw SGPP::base::algorithm_exception( + "BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem : " + "Dimension of mu and sigma parameters don't match the grid's dimensions!"); } // test if all algorithmic dimensions are inside the grid's dimensions for (size_t i = 0; i < this->BSalgoDims.size(); i++) { if (this->BSalgoDims[i] >= this->BoundGrid->getStorage()->dim()) { - throw SGPP::base::algorithm_exception("BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem : Minimum one algorithmic dimension is not inside the grid's dimensions!"); + throw SGPP::base::algorithm_exception( + "BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem : " + "Minimum one algorithmic dimension is not inside the grid's dimensions!"); } } @@ -78,15 +82,15 @@ BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem } if (dimCount > 1) { - throw SGPP::base::algorithm_exception("BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem : There is minimum one float_td algorithmic dimension!"); + throw SGPP::base::algorithm_exception( + "BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem : " + "There is minimum one float_td algorithmic dimension!"); } } // operations on boundary grid - this->OpLaplaceBound = SGPP::op_factory::createOperationLaplace( - *this->BoundGrid, *this->lambda); - this->OpLTwoBound = SGPP::op_factory::createOperationLTwoDotProduct( - *this->BoundGrid); + this->OpLaplaceBound = SGPP::op_factory::createOperationLaplace(*this->BoundGrid, *this->lambda); + this->OpLTwoBound = SGPP::op_factory::createOperationLTwoDotProduct(*this->BoundGrid); // right hand side if System this->rhs = NULL; @@ -121,8 +125,8 @@ BlackScholesPATParabolicPDESolverSystem::~BlackScholesPATParabolicPDESolverSyste delete this->mu_hat; } -void BlackScholesPATParabolicPDESolverSystem::applyLOperator( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void BlackScholesPATParabolicPDESolverSystem::applyLOperator(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -131,8 +135,8 @@ void BlackScholesPATParabolicPDESolverSystem::applyLOperator( result.axpy(-0.5, temp); } -void BlackScholesPATParabolicPDESolverSystem::applyMassMatrix( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void BlackScholesPATParabolicPDESolverSystem::applyMassMatrix(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -142,12 +146,9 @@ void BlackScholesPATParabolicPDESolverSystem::applyMassMatrix( result.add(temp); } -void BlackScholesPATParabolicPDESolverSystem::finishTimestep() { - -} +void BlackScholesPATParabolicPDESolverSystem::finishTimestep() {} -void BlackScholesPATParabolicPDESolverSystem::coarsenAndRefine( - bool isLastTimestep) { +void BlackScholesPATParabolicPDESolverSystem::coarsenAndRefine(bool isLastTimestep) { // add number of Gridpoints this->numSumGridpointsInner += 0; this->numSumGridpointsComplete += this->BoundGrid->getSize(); @@ -162,15 +163,13 @@ void BlackScholesPATParabolicPDESolverSystem::coarsenAndRefine( // Coarsen the grid SGPP::base::GridGenerator* myGenerator = this->BoundGrid->createGridGenerator(); - //std::cout << "Coarsen Threshold: " << this->coarsenThreshold << std::endl; - //std::cout << "Grid Size: " << originalGridSize << std::endl; + // std::cout << "Coarsen Threshold: " << this->coarsenThreshold << std::endl; + // std::cout << "Grid Size: " << originalGridSize << std::endl; - if (this->adaptSolveMode == "refine" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "refine" || this->adaptSolveMode == "coarsenNrefine") { size_t numRefines = myGenerator->getNumberOfRefinablePoints(); - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(this->alpha_complete, numRefines, - this->refineThreshold); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = new SGPP::base::SurplusRefinementFunctor( + this->alpha_complete, numRefines, this->refineThreshold); if (this->refineMode == "maxLevel") { myGenerator->refineMaxLevel(myRefineFunc, this->refineMaxLevel); @@ -185,14 +184,12 @@ void BlackScholesPATParabolicPDESolverSystem::coarsenAndRefine( delete myRefineFunc; } - if (this->adaptSolveMode == "coarsen" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "coarsen" || this->adaptSolveMode == "coarsenNrefine") { size_t numCoarsen = myGenerator->getNumberOfRemovablePoints(); - SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = new - SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, - this->coarsenThreshold); - myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, - originalGridSize); + SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = + new SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, + this->coarsenThreshold); + myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, originalGridSize); delete myCoarsenFunctor; } @@ -204,9 +201,6 @@ void BlackScholesPATParabolicPDESolverSystem::coarsenAndRefine( } } -void BlackScholesPATParabolicPDESolverSystem::startTimestep() { -} - -} - -} \ No newline at end of file +void BlackScholesPATParabolicPDESolverSystem::startTimestep() {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystem.hpp b/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystem.hpp index 5e6182fba6..31482fdf01 100644 --- a/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystem.hpp +++ b/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystem.hpp @@ -14,6 +14,8 @@ #include +#include +#include namespace SGPP { namespace finance { @@ -25,8 +27,8 @@ namespace finance { * calculation effort for higher dimensional cases. * */ -class BlackScholesPATParabolicPDESolverSystem : public - SGPP::pde::OperationParabolicPDESolverSystemFreeBoundaries { +class BlackScholesPATParabolicPDESolverSystem + : public SGPP::pde::OperationParabolicPDESolverSystemFreeBoundaries { protected: /// the Laplace Operation, on boundary grid SGPP::base::OperationMatrix* OpLaplaceBound; @@ -36,7 +38,8 @@ class BlackScholesPATParabolicPDESolverSystem : public SGPP::base::DataVector* lambda; /// Eigenvectors of the covariance matrix SGPP::base::DataMatrix* eigenvecs; - /// Pointer to the mu_hat (transformed drifts and correlation, needed for constraint of American options) + /// Pointer to the mu_hat (transformed drifts and correlation, needed for constraint of American + /// options) SGPP::base::DataVector* mu_hat; /// use coarsening between timesteps in order to reduce gridsize bool useCoarsen; @@ -57,11 +60,9 @@ class BlackScholesPATParabolicPDESolverSystem : public /// Routine to modify the boundaries/inner points of the grid SGPP::base::DirichletUpdateVector* BoundaryUpdate; - virtual void applyLOperator(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyLOperator(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - virtual void applyMassMatrix(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyMassMatrix(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); public: /** @@ -71,30 +72,30 @@ class BlackScholesPATParabolicPDESolverSystem : public * @param alpha the ansatzfunctions' coefficients * @param lambda eigenvalues of the covariance matrix * @param eigenvecs reference to the eigenvectors of the co-variance matrix - * @param mu_hat reference to transformed drifts and correlation, needed for constraint of American options + * @param mu_hat reference to transformed drifts and correlation, needed for constraint of + * American options * @param TimestepSize the size of one timestep used in the ODE Solver - * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for explicit Euler, + * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for + * explicit Euler, * ImEul for implicit Euler, CrNic for Crank Nicolson solver * @param useCoarsen specifies if the grid should be coarsened between timesteps * @param coarsenThreshold Threshold to decide, if a grid point should be deleted * @param adaptSolveMode adaptive mode during solving: coarsen, refine, coarsenNrefine - * @param numCoarsenPoints number of point that should be coarsened in one coarsening step !CURRENTLY UNUSED PARAMETER! + * @param numCoarsenPoints number of point that should be coarsened in one coarsening step + * !CURRENTLY UNUSED PARAMETER! * @param refineThreshold Threshold to decide, if a grid point should be refined * @param refineMode refineMode during solving Black Scholes Equation: classic or maxLevel * @param refineMaxLevel max. level of refinement during solving * @param dStrike the option's strike value * @param option_type type of option used here */ - BlackScholesPATParabolicPDESolverSystem(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& alpha, SGPP::base::DataVector& lambda, - SGPP::base::DataMatrix& eigenvecs, SGPP::base::DataVector& mu_hat, - float_t TimestepSize, std::string OperationMode, - float_t dStrike, std::string option_type, - bool useCoarsen = false, float_t coarsenThreshold = 0.0, - std::string adaptSolveMode = "none", - int numCoarsenPoints = -1, float_t refineThreshold = 0.0, - std::string refineMode = "classic", - SGPP::base::GridIndex::level_type refineMaxLevel = 0); + BlackScholesPATParabolicPDESolverSystem( + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& lambda, + SGPP::base::DataMatrix& eigenvecs, SGPP::base::DataVector& mu_hat, float_t TimestepSize, + std::string OperationMode, float_t dStrike, std::string option_type, bool useCoarsen = false, + float_t coarsenThreshold = 0.0, std::string adaptSolveMode = "none", + int numCoarsenPoints = -1, float_t refineThreshold = 0.0, std::string refineMode = "classic", + SGPP::base::GridIndex::level_type refineMaxLevel = 0); /** * Std-Destructor @@ -110,8 +111,7 @@ class BlackScholesPATParabolicPDESolverSystem : public virtual void startTimestep(); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* BLACKSCHOLESPATPARABOLICPDESOLVERSYSTEM_HPP */ \ No newline at end of file +#endif /* BLACKSCHOLESPATPARABOLICPDESOLVERSYSTEM_HPP */ diff --git a/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmer.cpp b/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmer.cpp index 6ab300fc92..ba0828ccec 100644 --- a/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmer.cpp +++ b/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmer.cpp @@ -10,40 +10,37 @@ #include #include -#include - #include +#include +#include +#include +#include namespace SGPP { namespace finance { BlackScholesPATParabolicPDESolverSystemEuroAmer::BlackScholesPATParabolicPDESolverSystemEuroAmer( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, - SGPP::base::DataVector& lambda, - SGPP::base::DataMatrix& eigenvecs, SGPP::base::DataVector& mu_hat, - float_t TimestepSize, std::string OperationMode, - float_t dStrike, std::string option_type, float_t r, - bool useCoarsen, float_t coarsenThreshold, std::string adaptSolveMode, - int numCoarsenPoints, float_t refineThreshold, std::string refineMode, - SGPP::base::GridIndex::level_type refineMaxLevel) { + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& lambda, + SGPP::base::DataMatrix& eigenvecs, SGPP::base::DataVector& mu_hat, float_t TimestepSize, + std::string OperationMode, float_t dStrike, std::string option_type, float_t r, bool useCoarsen, + float_t coarsenThreshold, std::string adaptSolveMode, int numCoarsenPoints, + float_t refineThreshold, std::string refineMode, + SGPP::base::GridIndex::level_type refineMaxLevel) { this->BoundGrid = &SparseGrid; this->alpha_complete = α this->alpha_complete_old = new SGPP::base::DataVector(*this->alpha_complete); this->alpha_complete_tmp = new SGPP::base::DataVector(*this->alpha_complete); - this->oldGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); - this->secondGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); + this->oldGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); + this->secondGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); this->InnerGrid = NULL; this->alpha_inner = NULL; this->tOperationMode = OperationMode; this->TimestepSize = TimestepSize; this->TimestepSize_old = TimestepSize; - this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector( - SparseGrid.getStorage()); + this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector(SparseGrid.getStorage()); this->GridConverter = new SGPP::base::DirichletGridConverter(); // set Eigenvalues, Eigenvector of covariance matrix and mu_hat @@ -56,18 +53,25 @@ BlackScholesPATParabolicPDESolverSystemEuroAmer::BlackScholesPATParabolicPDESolv // throw exception if grid dimensions not equal algorithmic dimensions if (this->BSalgoDims.size() > this->BoundGrid->getStorage()->dim()) { - throw SGPP::base::algorithm_exception("BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystemn : Number of algorithmic dimensions higher than the number of grid's dimensions."); + throw SGPP::base::algorithm_exception( + "BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystemn : " + "Number of algorithmic dimensions higher than the number of grid's dimensions."); } - // test if number of dimensions in the coefficients match the numbers of grid dimensions (mu and sigma) + // test if number of dimensions in the coefficients match the numbers of grid dimensions (mu and + // sigma) if (this->BoundGrid->getStorage()->dim() != this->lambda->getSize()) { - throw SGPP::base::algorithm_exception("BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem : Dimension of mu and sigma parameters don't match the grid's dimensions!"); + throw SGPP::base::algorithm_exception( + "BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem : " + "Dimension of mu and sigma parameters don't match the grid's dimensions!"); } // test if all algorithmic dimensions are inside the grid's dimensions for (size_t i = 0; i < this->BSalgoDims.size(); i++) { if (this->BSalgoDims[i] >= this->BoundGrid->getStorage()->dim()) { - throw SGPP::base::algorithm_exception("BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem : Minimum one algorithmic dimension is not inside the grid's dimensions!"); + throw SGPP::base::algorithm_exception( + "BlackScholesPATParabolicPDESolverSystem::BlackScholesPATParabolicPDESolverSystem : " + "Minimum one algorithmic dimension is not inside the grid's dimensions!"); } } @@ -84,24 +88,23 @@ BlackScholesPATParabolicPDESolverSystemEuroAmer::BlackScholesPATParabolicPDESolv } if (dimCount > 1) { - throw SGPP::base::algorithm_exception("BlackScholesPATParabolicPDESolverSystemEuropean::BlackScholesParabolicPDESolverSystemEuropean : There is minimum one float_td algorithmic dimension!"); + throw SGPP::base::algorithm_exception( + "BlackScholesPATParabolicPDESolverSystemEuropean::" + "BlackScholesParabolicPDESolverSystemEuropean : There is minimum one float_td " + "algorithmic dimension!"); } } // create the inner grid - this->GridConverter->buildInnerGridWithCoefs(*this->BoundGrid, - *this->alpha_complete, &this->InnerGrid, &this->alpha_inner); + this->GridConverter->buildInnerGridWithCoefs(*this->BoundGrid, *this->alpha_complete, + &this->InnerGrid, &this->alpha_inner); // Create operations - this->OpLaplaceInner = SGPP::op_factory::createOperationLaplace( - *this->InnerGrid, *this->lambda); - this->OpLaplaceBound = SGPP::op_factory::createOperationLaplace( - *this->BoundGrid, *this->lambda); + this->OpLaplaceInner = SGPP::op_factory::createOperationLaplace(*this->InnerGrid, *this->lambda); + this->OpLaplaceBound = SGPP::op_factory::createOperationLaplace(*this->BoundGrid, *this->lambda); - this->OpLTwoInner = SGPP::op_factory::createOperationLTwoDotProduct( - *this->InnerGrid); - this->OpLTwoBound = SGPP::op_factory::createOperationLTwoDotProduct( - *this->BoundGrid); + this->OpLTwoInner = SGPP::op_factory::createOperationLTwoDotProduct(*this->InnerGrid); + this->OpLTwoBound = SGPP::op_factory::createOperationLTwoDotProduct(*this->BoundGrid); // right hand side if System this->rhs = NULL; @@ -125,7 +128,8 @@ BlackScholesPATParabolicPDESolverSystemEuroAmer::BlackScholesPATParabolicPDESolv this->r = r; } -BlackScholesPATParabolicPDESolverSystemEuroAmer::~BlackScholesPATParabolicPDESolverSystemEuroAmer() { +BlackScholesPATParabolicPDESolverSystemEuroAmer:: + ~BlackScholesPATParabolicPDESolverSystemEuroAmer() { delete this->OpLaplaceBound; delete this->OpLTwoBound; delete this->OpLaplaceInner; @@ -153,7 +157,7 @@ BlackScholesPATParabolicPDESolverSystemEuroAmer::~BlackScholesPATParabolicPDESol } void BlackScholesPATParabolicPDESolverSystemEuroAmer::applyLOperatorComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -164,7 +168,7 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmer::applyLOperatorComplete( } void BlackScholesPATParabolicPDESolverSystemEuroAmer::applyLOperatorInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -175,7 +179,7 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmer::applyLOperatorInner( } void BlackScholesPATParabolicPDESolverSystemEuroAmer::applyMassMatrixComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -187,7 +191,7 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmer::applyMassMatrixComplete( } void BlackScholesPATParabolicPDESolverSystemEuroAmer::applyMassMatrixInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -198,30 +202,26 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmer::applyMassMatrixInner( result.add(temp); } - void BlackScholesPATParabolicPDESolverSystemEuroAmer::finishTimestep() { // Replace the inner coefficients on the boundary grid - this->GridConverter->updateBoundaryCoefs(*this->alpha_complete, - *this->alpha_inner); + this->GridConverter->updateBoundaryCoefs(*this->alpha_complete, *this->alpha_inner); // check if we are doing an American put -> handle early exercise if (this->option_type == "std_amer_put") { - float_t current_time = static_cast(this->nExecTimesteps) * - this->TimestepSize; + float_t current_time = static_cast(this->nExecTimesteps) * this->TimestepSize; SGPP::base::OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->BoundGrid); + SGPP::op_factory::createOperationHierarchisation(*this->BoundGrid); myHierarchisation->doDehierarchisation(*this->alpha_complete); size_t dim = this->BoundGrid->getStorage()->dim(); - SGPP::base::BoundingBox* myBB = new SGPP::base::BoundingBox(* - (this->BoundGrid->getBoundingBox())); + SGPP::base::BoundingBox* myBB = + new SGPP::base::BoundingBox(*(this->BoundGrid->getBoundingBox())); float_t* coords_val = new float_t[dim]; for (size_t i = 0; i < this->BoundGrid->getStorage()->size(); i++) { std::vector eval_point_coord; - std::string coords = this->BoundGrid->getStorage()->get(i)->getCoordsStringBB( - *myBB); + std::string coords = this->BoundGrid->getStorage()->get(i)->getCoordsStringBB(*myBB); std::stringstream coordsStream(coords); float_t tmp; @@ -239,17 +239,16 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmer::finishTimestep() { float_t inner_tmp = 0.0; for (size_t l = 0; l < dim; l++) { - inner_tmp += this->eigenvecs->get(j, - l) * (coords_val[l] - (current_time * this->mu_hat->get(l))); + inner_tmp += + this->eigenvecs->get(j, l) * (coords_val[l] - (current_time * this->mu_hat->get(l))); } tmp += exp(inner_tmp); } - float_t payoff = std::max(this->dStrike - (tmp / static_cast - (dim)), 0.0); - float_t discounted_value = ((*this->alpha_complete)[i]) * exp(((-1.0) * - (this->r * this->TimestepSize))); + float_t payoff = std::max(this->dStrike - (tmp / static_cast(dim)), 0.0); + float_t discounted_value = + ((*this->alpha_complete)[i]) * exp(((-1.0) * (this->r * this->TimestepSize))); (*this->alpha_complete)[i] = std::max(payoff, discounted_value); } @@ -260,10 +259,8 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmer::finishTimestep() { delete myHierarchisation; delete myBB; } - } -void BlackScholesPATParabolicPDESolverSystemEuroAmer::coarsenAndRefine( - bool isLastTimestep) { +void BlackScholesPATParabolicPDESolverSystemEuroAmer::coarsenAndRefine(bool isLastTimestep) { // add number of Gridpoints this->numSumGridpointsInner += this->InnerGrid->getSize(); this->numSumGridpointsComplete += this->BoundGrid->getSize(); @@ -278,15 +275,13 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmer::coarsenAndRefine( // Coarsen the grid SGPP::base::GridGenerator* myGenerator = this->BoundGrid->createGridGenerator(); - //std::cout << "Coarsen Threshold: " << this->coarsenThreshold << std::endl; - //std::cout << "Grid Size: " << originalGridSize << std::endl; + // std::cout << "Coarsen Threshold: " << this->coarsenThreshold << std::endl; + // std::cout << "Grid Size: " << originalGridSize << std::endl; - if (this->adaptSolveMode == "refine" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "refine" || this->adaptSolveMode == "coarsenNrefine") { size_t numRefines = myGenerator->getNumberOfRefinablePoints(); - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(this->alpha_complete, numRefines, - this->refineThreshold); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = new SGPP::base::SurplusRefinementFunctor( + this->alpha_complete, numRefines, this->refineThreshold); if (this->refineMode == "maxLevel") { myGenerator->refineMaxLevel(myRefineFunc, this->refineMaxLevel); @@ -301,14 +296,12 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmer::coarsenAndRefine( delete myRefineFunc; } - if (this->adaptSolveMode == "coarsen" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "coarsen" || this->adaptSolveMode == "coarsenNrefine") { size_t numCoarsen = myGenerator->getNumberOfRemovablePoints(); - SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = new - SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, - this->coarsenThreshold); - myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, - originalGridSize); + SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = + new SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, + this->coarsenThreshold); + myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, originalGridSize); delete myCoarsenFunctor; } @@ -319,15 +312,11 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmer::coarsenAndRefine( /////////////////////////////////////////////////// // rebuild the inner grid + coefficients - this->GridConverter->rebuildInnerGridWithCoefs(*this->BoundGrid, - *this->alpha_complete, &this->InnerGrid, &this->alpha_inner); + this->GridConverter->rebuildInnerGridWithCoefs(*this->BoundGrid, *this->alpha_complete, + &this->InnerGrid, &this->alpha_inner); } - -} - -void BlackScholesPATParabolicPDESolverSystemEuroAmer::startTimestep() { -} - } -} \ No newline at end of file +void BlackScholesPATParabolicPDESolverSystemEuroAmer::startTimestep() {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmer.hpp b/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmer.hpp index 589392cbdd..442dcb522e 100644 --- a/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmer.hpp +++ b/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmer.hpp @@ -13,6 +13,8 @@ #include +#include +#include namespace SGPP { namespace finance { @@ -26,8 +28,8 @@ namespace finance { * In addition a principal axis transformation is performed in order * to reduce the computational effort. */ -class BlackScholesPATParabolicPDESolverSystemEuroAmer : public - SGPP::pde::OperationParabolicPDESolverSystemDirichlet { +class BlackScholesPATParabolicPDESolverSystemEuroAmer + : public SGPP::pde::OperationParabolicPDESolverSystemDirichlet { protected: /// the Laplace Operation, on boundary grid SGPP::base::OperationMatrix* OpLaplaceBound; @@ -41,7 +43,8 @@ class BlackScholesPATParabolicPDESolverSystemEuroAmer : public SGPP::base::DataVector* lambda; /// Eigenvectors of the covariance matrix SGPP::base::DataMatrix* eigenvecs; - /// Pointer to the mu_hat (transformed drifts and correlation, needed for constraint of American options) + /// Pointer to the mu_hat (transformed drifts and correlation, needed for constraint of American + /// options) SGPP::base::DataVector* mu_hat; /// use coarsening between timesteps in order to reduce gridsize bool useCoarsen; @@ -68,14 +71,12 @@ class BlackScholesPATParabolicPDESolverSystemEuroAmer : public /// teh riskfree rate float_t r; - virtual void applyLOperatorInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyLOperatorInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual void applyLOperatorComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - virtual void applyMassMatrixInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyMassMatrixInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual void applyMassMatrixComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); @@ -88,9 +89,11 @@ class BlackScholesPATParabolicPDESolverSystemEuroAmer : public * @param alpha the ansatzfunctions' coefficients * @param lambda reference to the lambdas * @param eigenvecs reference to the eigenvectors of the co-variance matrix - * @param mu_hat reference to transformed drifts and correlation, needed for constraint of American options + * @param mu_hat reference to transformed drifts and correlation, needed for constraint of + * American options * @param TimestepSize the size of one timestep used in the ODE Solver - * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for explicit Euler, + * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for + * explicit Euler, * ImEul for implicit Euler, CrNic for Crank Nicolson solver * @param dStrike the strike of the option * @param option_type the option to be solved std_amer_put as an special case @@ -98,20 +101,18 @@ class BlackScholesPATParabolicPDESolverSystemEuroAmer : public * @param useCoarsen specifies if the grid should be coarsened between timesteps * @param coarsenThreshold Threshold to decide, if a grid point should be deleted * @param adaptSolveMode adaptive mode during solving: coarsen, refine, coarsenNrefine - * @param numCoarsenPoints number of point that should be coarsened in one coarsening step !CURRENTLY UNUSED PARAMETER! + * @param numCoarsenPoints number of point that should be coarsened in one coarsening step + * !CURRENTLY UNUSED PARAMETER! * @param refineThreshold Threshold to decide, if a grid point should be refined * @param refineMode refineMode during solving Black Scholes Equation: classic or maxLevel * @param refineMaxLevel max. level of refinement during solving */ - BlackScholesPATParabolicPDESolverSystemEuroAmer(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& alpha, SGPP::base::DataVector& lambda, - SGPP::base::DataMatrix& eigenvecs, SGPP::base::DataVector& mu_hat, - float_t TimestepSize, std::string OperationMode, - float_t dStrike, std::string option_type, float_t r, - bool useCoarsen = false, float_t coarsenThreshold = 0.0, - std::string adaptSolveMode = "none", - int numCoarsenPoints = -1, float_t refineThreshold = 0.0, - std::string refineMode = "classic", + BlackScholesPATParabolicPDESolverSystemEuroAmer( + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& lambda, + SGPP::base::DataMatrix& eigenvecs, SGPP::base::DataVector& mu_hat, float_t TimestepSize, + std::string OperationMode, float_t dStrike, std::string option_type, float_t r, + bool useCoarsen = false, float_t coarsenThreshold = 0.0, std::string adaptSolveMode = "none", + int numCoarsenPoints = -1, float_t refineThreshold = 0.0, std::string refineMode = "classic", SGPP::base::GridIndex::level_type refineMaxLevel = 0); /** @@ -128,8 +129,7 @@ class BlackScholesPATParabolicPDESolverSystemEuroAmer : public void startTimestep(); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* BLACKSCHOLESPATPARABOLICPDESOLVERSYSTEMEUROAMER_HPP */ \ No newline at end of file +#endif /* BLACKSCHOLESPATPARABOLICPDESOLVERSYSTEMEUROAMER_HPP */ diff --git a/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP.cpp b/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP.cpp index 8ad217796f..43ebcb72be 100644 --- a/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP.cpp +++ b/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP.cpp @@ -18,42 +18,43 @@ #include +#include +#include namespace SGPP { namespace finance { -BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, - SGPP::base::DataVector& lambda, - SGPP::base::DataMatrix& eigenvecs, SGPP::base::DataVector& mu_hat, - float_t TimestepSize, std::string OperationMode, - float_t dStrike, std::string option_type, float_t r, - bool useCoarsen, float_t coarsenThreshold, std::string adaptSolveMode, - int numCoarsenPoints, float_t refineThreshold, std::string refineMode, - SGPP::base::GridIndex::level_type refineMaxLevel) : - BlackScholesPATParabolicPDESolverSystemEuroAmer(SparseGrid, alpha, lambda, - eigenvecs, mu_hat, TimestepSize, OperationMode, dStrike, option_type, r, - useCoarsen, coarsenThreshold, adaptSolveMode, numCoarsenPoints, refineThreshold, - refineMode, refineMaxLevel), rhs_corrector(NULL) { -} - -BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::~BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP() { +BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP:: + BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP( + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& lambda, + SGPP::base::DataMatrix& eigenvecs, SGPP::base::DataVector& mu_hat, float_t TimestepSize, + std::string OperationMode, float_t dStrike, std::string option_type, float_t r, + bool useCoarsen, float_t coarsenThreshold, std::string adaptSolveMode, int numCoarsenPoints, + float_t refineThreshold, std::string refineMode, + SGPP::base::GridIndex::level_type refineMaxLevel) + : BlackScholesPATParabolicPDESolverSystemEuroAmer( + SparseGrid, alpha, lambda, eigenvecs, mu_hat, TimestepSize, OperationMode, dStrike, + option_type, r, useCoarsen, coarsenThreshold, adaptSolveMode, numCoarsenPoints, + refineThreshold, refineMode, refineMaxLevel), + rhs_corrector(NULL) {} + +BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP:: + ~BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP() { if (this->rhs_corrector != NULL) { delete this->rhs_corrector; } } void BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); #ifdef USE_ENHANCED_UPDOWN - ((SGPP::pde::UpDownOneOpDimEnhanced*)( - this->OpLaplaceInner))->multParallelBuildingBlock(alpha, result); + ((SGPP::pde::UpDownOneOpDimEnhanced*)(this->OpLaplaceInner)) + ->multParallelBuildingBlock(alpha, result); result.mult(-0.5); #else - std::vector algoDims = - this->InnerGrid->getStorage()->getAlgorithmicDimensions(); + std::vector algoDims = this->InnerGrid->getStorage()->getAlgorithmicDimensions(); size_t nDims = algoDims.size(); #ifdef _OPENMP @@ -64,14 +65,15 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorI // Apply Laplace for (size_t i = 0; i < nDims; i++) { - #pragma omp task firstprivate(i) shared(alpha, LaplaceMutex, LaplaceResult, result, algoDims) +#pragma omp task firstprivate(i) shared(alpha, LaplaceMutex, LaplaceResult, result, algoDims) { SGPP::base::DataVector myResult(result.getSize()); /// discuss methods in order to avoid this cast - ((SGPP::pde::UpDownOneOpDim*)(this->OpLaplaceInner))->multParallelBuildingBlock(alpha, myResult, algoDims[i]); + ((SGPP::pde::UpDownOneOpDim*)(this->OpLaplaceInner)) + ->multParallelBuildingBlock(alpha, myResult, algoDims[i]); - // semaphore +// semaphore #ifdef _OPENMP omp_set_lock(&LaplaceMutex); #endif @@ -82,7 +84,7 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorI } } - #pragma omp taskwait +#pragma omp taskwait result.axpy(-0.5, LaplaceResult); #ifdef _OPENMP @@ -92,16 +94,15 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorI } void BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); #ifdef USE_ENHANCED_UPDOWN - ((SGPP::pde::UpDownOneOpDimEnhanced*)( - this->OpLaplaceBound))->multParallelBuildingBlock(alpha, result); + ((SGPP::pde::UpDownOneOpDimEnhanced*)(this->OpLaplaceBound)) + ->multParallelBuildingBlock(alpha, result); result.mult(-0.5); #else - std::vector algoDims = - this->BoundGrid->getStorage()->getAlgorithmicDimensions(); + std::vector algoDims = this->BoundGrid->getStorage()->getAlgorithmicDimensions(); size_t nDims = algoDims.size(); #ifdef _OPENMP omp_lock_t LaplaceMutex; @@ -111,14 +112,15 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorC // Apply Laplace for (size_t i = 0; i < nDims; i++) { - #pragma omp task firstprivate(i) shared(alpha, LaplaceMutex, LaplaceResult, result, algoDims) +#pragma omp task firstprivate(i) shared(alpha, LaplaceMutex, LaplaceResult, result, algoDims) { SGPP::base::DataVector myResult(result.getSize()); /// discuss methods in order to avoid this cast - ((SGPP::pde::UpDownOneOpDim*)(this->OpLaplaceBound))->multParallelBuildingBlock(alpha, myResult, algoDims[i]); + ((SGPP::pde::UpDownOneOpDim*)(this->OpLaplaceBound)) + ->multParallelBuildingBlock(alpha, myResult, algoDims[i]); - // semaphore +// semaphore #ifdef _OPENMP omp_set_lock(&LaplaceMutex); #endif @@ -129,7 +131,7 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorC } } - #pragma omp taskwait +#pragma omp taskwait result.axpy(-0.5, LaplaceResult); @@ -140,31 +142,29 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorC } void BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::applyMassMatrixInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); - ((SGPP::pde::StdUpDown*)(this->OpLTwoInner))->multParallelBuildingBlock(alpha, - temp); + ((SGPP::pde::StdUpDown*)(this->OpLTwoInner))->multParallelBuildingBlock(alpha, temp); result.add(temp); } void BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::applyMassMatrixComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); - ((SGPP::pde::StdUpDown*)(this->OpLTwoBound))->multParallelBuildingBlock(alpha, - temp); + ((SGPP::pde::StdUpDown*)(this->OpLTwoBound))->multParallelBuildingBlock(alpha, temp); result.add(temp); } void BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::mult( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); if (this->tOperationMode == "ExEul") { @@ -173,61 +173,54 @@ void BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::mult( SGPP::base::DataVector temp(result.getSize()); SGPP::base::DataVector temp2(result.getSize()); - #pragma omp parallel shared(alpha, result) +#pragma omp parallel shared(alpha, result) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha, temp) - { - applyMassMatrixInner(alpha, temp); - } +#pragma omp task shared(alpha, temp) + { applyMassMatrixInner(alpha, temp); } - #pragma omp task shared (alpha, temp2) - { - applyLOperatorInner(alpha, temp2); - } +#pragma omp task shared(alpha, temp2) + { applyLOperatorInner(alpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result.add(temp); - result.axpy((-1.0)*this->TimestepSize, temp2); + result.axpy((-1.0) * this->TimestepSize, temp2); } else if (this->tOperationMode == "CrNic") { SGPP::base::DataVector temp(result.getSize()); SGPP::base::DataVector temp2(result.getSize()); - #pragma omp parallel shared(alpha, result) +#pragma omp parallel shared(alpha, result) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha, temp) - { - applyMassMatrixInner(alpha, temp); - } +#pragma omp task shared(alpha, temp) + { applyMassMatrixInner(alpha, temp); } - #pragma omp task shared (alpha, temp2) - { - applyLOperatorInner(alpha, temp2); - } +#pragma omp task shared(alpha, temp2) + { applyLOperatorInner(alpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result.add(temp); - result.axpy((-0.5)*this->TimestepSize, temp2); + result.axpy((-0.5) * this->TimestepSize, temp2); } else if (this->tOperationMode == "AdBas") { result.setAll(0.0); applyMassMatrixInner(alpha, result); } else { - throw new SGPP::base::algorithm_exception(" BlackScholesPATParabolicPDESolverSystemEuropeanParallelOMP::mult : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + " BlackScholesPATParabolicPDESolverSystemEuropeanParallelOMP::mult : An unknown operation " + "mode was specified!"); } } -SGPP::base::DataVector* -BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { +SGPP::base::DataVector* BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { SGPP::base::DataVector rhs_complete(this->alpha_complete->getSize()); if (this->tOperationMode == "ExEul") { @@ -237,21 +230,17 @@ BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { SGPP::base::DataVector temp2(rhs_complete.getSize()); SGPP::base::DataVector myAlpha(*this->alpha_complete); - #pragma omp parallel shared(myAlpha, temp, temp2) +#pragma omp parallel shared(myAlpha, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myAlpha, temp) - { - applyMassMatrixComplete(myAlpha, temp); - } +#pragma omp task shared(myAlpha, temp) + { applyMassMatrixComplete(myAlpha, temp); } - #pragma omp task shared (myAlpha, temp2) - { - applyLOperatorComplete(myAlpha, temp2); - } +#pragma omp task shared(myAlpha, temp2) + { applyLOperatorComplete(myAlpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } @@ -262,16 +251,14 @@ BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { SGPP::base::DataVector myAlpha(*this->alpha_complete); - #pragma omp parallel shared (myAlpha, rhs_complete) +#pragma omp parallel shared(myAlpha, rhs_complete) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (rhs_complete) - { - applyMassMatrixComplete(myAlpha, rhs_complete); - } +#pragma omp task shared(rhs_complete) + { applyMassMatrixComplete(myAlpha, rhs_complete); } - #pragma omp taskwait +#pragma omp taskwait } } } else if (this->tOperationMode == "CrNic") { @@ -281,26 +268,22 @@ BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { SGPP::base::DataVector temp2(rhs_complete.getSize()); SGPP::base::DataVector myAlpha(*this->alpha_complete); - #pragma omp parallel shared(myAlpha, temp, temp2) +#pragma omp parallel shared(myAlpha, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myAlpha, temp) - { - applyMassMatrixComplete(myAlpha, temp); - } +#pragma omp task shared(myAlpha, temp) + { applyMassMatrixComplete(myAlpha, temp); } - #pragma omp task shared (myAlpha, temp2) - { - applyLOperatorComplete(myAlpha, temp2); - } +#pragma omp task shared(myAlpha, temp2) + { applyLOperatorComplete(myAlpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } rhs_complete.add(temp); - rhs_complete.axpy((0.5)*this->TimestepSize, temp2); + rhs_complete.axpy((0.5) * this->TimestepSize, temp2); } else if (this->tOperationMode == "AdBas") { rhs_complete.setAll(0.0); @@ -310,16 +293,14 @@ BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { applyMassMatrixComplete(*this->alpha_complete, temp); - #pragma omp parallel shared(myAlpha, temp) +#pragma omp parallel shared(myAlpha, temp) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myAlpha, temp) - { - applyLOperatorComplete(myAlpha, temp); - } +#pragma omp task shared(myAlpha, temp) + { applyLOperatorComplete(myAlpha, temp); } - #pragma omp taskwait +#pragma omp taskwait } } @@ -330,28 +311,28 @@ BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { applyMassMatrixComplete(*this->alpha_complete_old, temp_old); - #pragma omp parallel shared(myOldAlpha, temp_old) +#pragma omp parallel shared(myOldAlpha, temp_old) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myOldAlpha, temp_old) - { - applyLOperatorComplete(myOldAlpha, temp_old); - } +#pragma omp task shared(myOldAlpha, temp_old) + { applyLOperatorComplete(myOldAlpha, temp_old); } - #pragma omp taskwait +#pragma omp taskwait } } temp_old.mult(this->TimestepSize / this->TimestepSize_old); temp.sub(temp_old); - rhs_complete.axpy((0.5)*this->TimestepSize, temp); + rhs_complete.axpy((0.5) * this->TimestepSize, temp); } else { - throw new SGPP::base::algorithm_exception("BlackScholesPATParabolicPDESolverSystemEuropeanParallelOMP::generateRHS : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + "BlackScholesPATParabolicPDESolverSystemEuropeanParallelOMP::generateRHS : An unknown " + "operation mode was specified!"); } - if (this->useCoarsen == true || this->nExecTimesteps == 0 - || this->bnewODESolver == true || this->option_type == "std_amer_put") { + if (this->useCoarsen == true || this->nExecTimesteps == 0 || this->bnewODESolver == true || + this->option_type == "std_amer_put") { this->bnewODESolver = false; // Now apply the boundary ansatzfunctions to the inner ansatzfunctions @@ -369,54 +350,48 @@ BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { SGPP::base::DataVector temp(alpha_bound.getSize()); SGPP::base::DataVector temp2(alpha_bound.getSize()); - #pragma omp parallel shared(alpha_bound, temp, temp2) +#pragma omp parallel shared(alpha_bound, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha_bound, temp) - { - applyMassMatrixComplete(alpha_bound, temp); - } +#pragma omp task shared(alpha_bound, temp) + { applyMassMatrixComplete(alpha_bound, temp); } - #pragma omp task shared (alpha_bound, temp2) - { - applyLOperatorComplete(alpha_bound, temp2); - } +#pragma omp task shared(alpha_bound, temp2) + { applyLOperatorComplete(alpha_bound, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result_complete.add(temp); - result_complete.axpy((-1.0)*this->TimestepSize, temp2); + result_complete.axpy((-1.0) * this->TimestepSize, temp2); } else if (this->tOperationMode == "CrNic") { SGPP::base::DataVector temp(alpha_bound.getSize()); SGPP::base::DataVector temp2(alpha_bound.getSize()); - #pragma omp parallel shared(alpha_bound, temp, temp2) +#pragma omp parallel shared(alpha_bound, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha_bound, temp) - { - applyMassMatrixComplete(alpha_bound, temp); - } +#pragma omp task shared(alpha_bound, temp) + { applyMassMatrixComplete(alpha_bound, temp); } - #pragma omp task shared (alpha_bound, temp2) - { - applyLOperatorComplete(alpha_bound, temp2); - } +#pragma omp task shared(alpha_bound, temp2) + { applyLOperatorComplete(alpha_bound, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result_complete.add(temp); - result_complete.axpy((-0.5)*this->TimestepSize, temp2); + result_complete.axpy((-0.5) * this->TimestepSize, temp2); } else if (this->tOperationMode == "AdBas") { applyMassMatrixComplete(alpha_bound, result_complete); } else { - throw new SGPP::base::algorithm_exception("BlackScholesPATParabolicPDESolverSystemEuropeanParallelOMP::generateRHS : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + "BlackScholesPATParabolicPDESolverSystemEuropeanParallelOMP::generateRHS : An unknown " + "operation mode was specified!"); } // Store right hand side corrector @@ -424,8 +399,7 @@ BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { delete this->rhs_corrector; } - this->rhs_corrector = new SGPP::base::DataVector( - this->alpha_complete->getSize()); + this->rhs_corrector = new SGPP::base::DataVector(this->alpha_complete->getSize()); *(this->rhs_corrector) = result_complete; } @@ -442,6 +416,5 @@ BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { return this->rhs; } - -} -} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP.hpp b/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP.hpp index 4a036ebfc4..eb7eb72329 100644 --- a/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP.hpp +++ b/finance/src/sgpp/finance/algorithm/BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP.hpp @@ -10,6 +10,7 @@ #include +#include namespace SGPP { namespace finance { @@ -25,17 +26,15 @@ namespace finance { * the OMP task concept to enable further parallelization possibilities * in the calculation of the space-discretization operator (L) */ -class BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP : public - BlackScholesPATParabolicPDESolverSystemEuroAmer { +class BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP + : public BlackScholesPATParabolicPDESolverSystemEuroAmer { protected: - virtual void applyLOperatorInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyLOperatorInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual void applyLOperatorComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - virtual void applyMassMatrixInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyMassMatrixInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual void applyMassMatrixComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); @@ -51,9 +50,11 @@ class BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP : public * @param alpha the ansatzfunctions' coefficients * @param lambda reference to the lambdas * @param eigenvecs reference to the eigenvectors of the co-variance matrix - * @param mu_hat reference to transformed drifts and correlation, needed for constraint of American options + * @param mu_hat reference to transformed drifts and correlation, needed for constraint of + * American options * @param TimestepSize the size of one timestep used in the ODE Solver - * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for explicit Euler, + * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for + * explicit Euler, * ImEul for implicit Euler, CrNic for Crank Nicolson solver * @param dStrike the strike of the option * @param option_type the option to be solved std_amer_put as an special case @@ -61,22 +62,19 @@ class BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP : public * @param useCoarsen specifies if the grid should be coarsened between timesteps * @param coarsenThreshold Threshold to decide, if a grid point should be deleted * @param adaptSolveMode adaptive mode during solving: coarsen, refine, coarsenNrefine - * @param numCoarsenPoints number of point that should be coarsened in one coarsening step !CURRENTLY UNUSED PARAMETER! + * @param numCoarsenPoints number of point that should be coarsened in one coarsening step + * !CURRENTLY UNUSED PARAMETER! * @param refineThreshold Threshold to decide, if a grid point should be refined * @param refineMode refineMode during solving Black Scholes Equation: classic or maxLevel * @param refineMaxLevel max. level for refinement during solving */ BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, - SGPP::base::DataVector& lambda, - SGPP::base::DataMatrix& eigenvecs, SGPP::base::DataVector& mu_hat, - float_t TimestepSize, std::string OperationMode, - float_t dStrike, std::string option_type, float_t r, - bool useCoarsen = false, float_t coarsenThreshold = 0.0, - std::string adaptSolveMode = "none", - int numCoarsenPoints = -1, float_t refineThreshold = 0.0, - std::string refineMode = "classic", - SGPP::base::GridIndex::level_type refineMaxLevel = 0); + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& lambda, + SGPP::base::DataMatrix& eigenvecs, SGPP::base::DataVector& mu_hat, float_t TimestepSize, + std::string OperationMode, float_t dStrike, std::string option_type, float_t r, + bool useCoarsen = false, float_t coarsenThreshold = 0.0, std::string adaptSolveMode = "none", + int numCoarsenPoints = -1, float_t refineThreshold = 0.0, std::string refineMode = "classic", + SGPP::base::GridIndex::level_type refineMaxLevel = 0); /** * Std-Destructor @@ -87,10 +85,10 @@ class BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP : public * Multiplicates a vector with the matrix, parallel * * @param alpha SGPP::base::DataVector that contains the ansatzfunctions' coefficients - * @param result SGPP::base::DataVector into which the result of the space discretization operation is stored + * @param result SGPP::base::DataVector into which the result of the space discretization + * operation is stored */ - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** * generates the right hand side of the system, parallel @@ -99,8 +97,7 @@ class BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP : public */ virtual SGPP::base::DataVector* generateRHS(); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* BLACKSCHOLESPATPARABOLICPDESOLVERSYSTEMEUROAMERPARALLELOMP_HPP */ \ No newline at end of file +#endif /* BLACKSCHOLESPATPARABOLICPDESOLVERSYSTEMEUROAMERPARALLELOMP_HPP */ diff --git a/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystem.cpp b/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystem.cpp index 3be6ed0c6b..92b73118b5 100644 --- a/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystem.cpp +++ b/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystem.cpp @@ -9,39 +9,34 @@ #include #include #include -#include #include - +#include +#include +#include namespace SGPP { namespace finance { BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystem( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, - SGPP::base::DataVector& mu, - SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, - float_t TimestepSize, std::string OperationMode, - float_t dStrike, std::string option_type, - bool bLogTransform, bool useCoarsen, float_t coarsenThreshold, - std::string adaptSolveMode, - int numCoarsenPoints, float_t refineThreshold, std::string refineMode, - SGPP::base::GridIndex::level_type refineMaxLevel) { + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& mu, + SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, + std::string OperationMode, float_t dStrike, std::string option_type, bool bLogTransform, + bool useCoarsen, float_t coarsenThreshold, std::string adaptSolveMode, int numCoarsenPoints, + float_t refineThreshold, std::string refineMode, + SGPP::base::GridIndex::level_type refineMaxLevel) { this->BoundGrid = &SparseGrid; this->alpha_complete = α this->alpha_complete_old = new SGPP::base::DataVector(*this->alpha_complete); this->alpha_complete_tmp = new SGPP::base::DataVector(*this->alpha_complete); - this->oldGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); - this->secondGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); + this->oldGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); + this->secondGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); this->tOperationMode = OperationMode; this->TimestepSize = TimestepSize; this->TimestepSize_old = TimestepSize; - this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector( - SparseGrid.getStorage()); + this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector(SparseGrid.getStorage()); this->r = r; this->mus = μ this->sigmas = σ @@ -50,25 +45,34 @@ BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystem( // throw exception if grid dimensions not equal algorithmic dimensions if (this->BSalgoDims.size() > this->BoundGrid->getStorage()->dim()) { - throw SGPP::base::algorithm_exception("BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystemn : Number of algorithmic dimensions higher than the number of grid's dimensions."); + throw SGPP::base::algorithm_exception( + "BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystemn : Number of " + "algorithmic dimensions higher than the number of grid's dimensions."); } - // test if number of dimensions in the coefficients match the numbers of grid dimensions (mu and sigma) - if (this->BoundGrid->getStorage()->dim() != this->mus->getSize() - || this->BoundGrid->getStorage()->dim() != this->sigmas->getSize()) { - throw SGPP::base::algorithm_exception("BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystem : Dimension of mu and sigma parameters don't match the grid's dimensions!"); + // test if number of dimensions in the coefficients match the numbers of grid dimensions (mu and + // sigma) + if (this->BoundGrid->getStorage()->dim() != this->mus->getSize() || + this->BoundGrid->getStorage()->dim() != this->sigmas->getSize()) { + throw SGPP::base::algorithm_exception( + "BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystem : Dimension of " + "mu and sigma parameters don't match the grid's dimensions!"); } // test if number of dimensions in the coefficients match the numbers of grid dimensions (rho) - if (this->BoundGrid->getStorage()->dim() != this->rhos->getNrows() - || this->BoundGrid->getStorage()->dim() != this->rhos->getNcols()) { - throw SGPP::base::algorithm_exception("BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystem : Row or col of rho parameter don't match the grid's dimensions!"); + if (this->BoundGrid->getStorage()->dim() != this->rhos->getNrows() || + this->BoundGrid->getStorage()->dim() != this->rhos->getNcols()) { + throw SGPP::base::algorithm_exception( + "BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystem : Row or col " + "of rho parameter don't match the grid's dimensions!"); } // test if all algorithmic dimensions are inside the grid's dimensions for (size_t i = 0; i < this->BSalgoDims.size(); i++) { if (this->BSalgoDims[i] >= this->BoundGrid->getStorage()->dim()) { - throw SGPP::base::algorithm_exception("BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystem : Minimum one algorithmic dimension is not inside the grid's dimensions!"); + throw SGPP::base::algorithm_exception( + "BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystem : Minimum " + "one algorithmic dimension is not inside the grid's dimensions!"); } } @@ -85,13 +89,14 @@ BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystem( } if (dimCount > 1) { - throw SGPP::base::algorithm_exception("BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystem : There is minimum one float_td algorithmic dimension!"); + throw SGPP::base::algorithm_exception( + "BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystem : There is " + "minimum one float_td algorithmic dimension!"); } } // build the coefficient vectors for the operations - this->gammaCoef = new SGPP::base::DataMatrix(this->BSalgoDims.size(), - this->BSalgoDims.size()); + this->gammaCoef = new SGPP::base::DataMatrix(this->BSalgoDims.size(), this->BSalgoDims.size()); this->deltaCoef = new SGPP::base::DataVector(this->BSalgoDims.size()); if (bLogTransform == false) { @@ -99,25 +104,22 @@ BlackScholesParabolicPDESolverSystem::BlackScholesParabolicPDESolverSystem( buildGammaCoefficients(); // Create needed operations, on boundary grid - this->OpDeltaBound = SGPP::op_factory::createOperationDelta(*this->BoundGrid, - *this->deltaCoef); - this->OpGammaBound = SGPP::op_factory::createOperationGamma(*this->BoundGrid, - *this->gammaCoef); - } - // create needed operations that are different in case of a log-transformed Black-Scholoes equation - else { + this->OpDeltaBound = SGPP::op_factory::createOperationDelta(*this->BoundGrid, *this->deltaCoef); + this->OpGammaBound = SGPP::op_factory::createOperationGamma(*this->BoundGrid, *this->gammaCoef); + } else { + // create needed operations that are different in case of a log-transformed Black-Scholoes + // equation buildDeltaCoefficientsLogTransform(); buildGammaCoefficientsLogTransform(); // operations on boundary grid - this->OpDeltaBound = SGPP::op_factory::createOperationDeltaLog(*this->BoundGrid, - *this->deltaCoef); - this->OpGammaBound = SGPP::op_factory::createOperationGammaLog(*this->BoundGrid, - *this->gammaCoef); + this->OpDeltaBound = + SGPP::op_factory::createOperationDeltaLog(*this->BoundGrid, *this->deltaCoef); + this->OpGammaBound = + SGPP::op_factory::createOperationGammaLog(*this->BoundGrid, *this->gammaCoef); } - this->OpLTwoBound = SGPP::op_factory::createOperationLTwoDotProduct( - *this->BoundGrid); + this->OpLTwoBound = SGPP::op_factory::createOperationLTwoDotProduct(*this->BoundGrid); // right hand side if System this->rhs = NULL; @@ -161,8 +163,8 @@ BlackScholesParabolicPDESolverSystem::~BlackScholesParabolicPDESolverSystem() { delete this->secondGridStorage; } -void BlackScholesParabolicPDESolverSystem::applyLOperator( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void BlackScholesParabolicPDESolverSystem::applyLOperator(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -170,7 +172,7 @@ void BlackScholesParabolicPDESolverSystem::applyLOperator( // Apply the riskfree rate if (this->r != 0.0) { this->OpLTwoBound->mult(alpha, temp); - result.axpy((-1.0)*this->r, temp); + result.axpy((-1.0) * this->r, temp); } // Apply the delta method @@ -182,8 +184,8 @@ void BlackScholesParabolicPDESolverSystem::applyLOperator( result.sub(temp); } -void BlackScholesParabolicPDESolverSystem::applyMassMatrix( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void BlackScholesParabolicPDESolverSystem::applyMassMatrix(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -210,11 +212,9 @@ void BlackScholesParabolicPDESolverSystem::finishTimestep() { // add number of Gridpoints this->numSumGridpointsInner += 0; this->numSumGridpointsComplete += this->BoundGrid->getSize(); - } -void BlackScholesParabolicPDESolverSystem::coarsenAndRefine( - bool isLastTimestep) { +void BlackScholesParabolicPDESolverSystem::coarsenAndRefine(bool isLastTimestep) { if (this->useCoarsen == true && isLastTimestep == false) { /////////////////////////////////////////////////// // Start integrated refinement & coarsening @@ -225,15 +225,13 @@ void BlackScholesParabolicPDESolverSystem::coarsenAndRefine( // Coarsen the grid SGPP::base::GridGenerator* myGenerator = this->BoundGrid->createGridGenerator(); - //std::cout << "Coarsen Threshold: " << this->coarsenThreshold << std::endl; - //std::cout << "Grid Size: " << originalGridSize << std::endl; + // std::cout << "Coarsen Threshold: " << this->coarsenThreshold << std::endl; + // std::cout << "Grid Size: " << originalGridSize << std::endl; - if (this->adaptSolveMode == "refine" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "refine" || this->adaptSolveMode == "coarsenNrefine") { size_t numRefines = myGenerator->getNumberOfRefinablePoints(); - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(this->alpha_complete, numRefines, - this->refineThreshold); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = new SGPP::base::SurplusRefinementFunctor( + this->alpha_complete, numRefines, this->refineThreshold); if (this->refineMode == "maxLevel") { myGenerator->refineMaxLevel(myRefineFunc, this->refineMaxLevel); @@ -248,14 +246,12 @@ void BlackScholesParabolicPDESolverSystem::coarsenAndRefine( delete myRefineFunc; } - if (this->adaptSolveMode == "coarsen" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "coarsen" || this->adaptSolveMode == "coarsenNrefine") { size_t numCoarsen = myGenerator->getNumberOfRemovablePoints(); - SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = new - SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, - this->coarsenThreshold); - myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, - originalGridSize); + SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = + new SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, + this->coarsenThreshold); + myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, originalGridSize); delete myCoarsenFunctor; } @@ -289,14 +285,13 @@ void BlackScholesParabolicPDESolverSystem::buildGammaCoefficients() { // handle diagonal if (i == j) { this->gammaCoef->set(i, j, - 0.5 * ((this->sigmas->get(this->BSalgoDims[i])*this->sigmas->get( - this->BSalgoDims[j]))*this->rhos->get(this->BSalgoDims[i], - this->BSalgoDims[j]))); + 0.5 * ((this->sigmas->get(this->BSalgoDims[i]) * + this->sigmas->get(this->BSalgoDims[j])) * + this->rhos->get(this->BSalgoDims[i], this->BSalgoDims[j]))); } else { - this->gammaCoef->set(i, j, - ((this->sigmas->get(this->BSalgoDims[i])*this->sigmas->get( - this->BSalgoDims[j]))*this->rhos->get(this->BSalgoDims[i], - this->BSalgoDims[j]))); + this->gammaCoef->set(i, j, ((this->sigmas->get(this->BSalgoDims[i]) * + this->sigmas->get(this->BSalgoDims[j])) * + this->rhos->get(this->BSalgoDims[i], this->BSalgoDims[j]))); } } } @@ -312,13 +307,14 @@ void BlackScholesParabolicPDESolverSystem::buildDeltaCoefficients() { for (size_t j = 0; j < dim; j++) { // handle diagonal if (i == j) { - covar_sum += ((this->sigmas->get(this->BSalgoDims[i]) * this->sigmas->get( - this->BSalgoDims[j])) * this->rhos->get(this->BSalgoDims[i], - this->BSalgoDims[j])); + covar_sum += + ((this->sigmas->get(this->BSalgoDims[i]) * this->sigmas->get(this->BSalgoDims[j])) * + this->rhos->get(this->BSalgoDims[i], this->BSalgoDims[j])); } else { - covar_sum += (0.5 * ((this->sigmas->get(this->BSalgoDims[i]) * - this->sigmas->get(this->BSalgoDims[j])) * this->rhos->get(this->BSalgoDims[i], - this->BSalgoDims[j]))); + covar_sum += + (0.5 * + ((this->sigmas->get(this->BSalgoDims[i]) * this->sigmas->get(this->BSalgoDims[j])) * + this->rhos->get(this->BSalgoDims[i], this->BSalgoDims[j]))); } } @@ -334,14 +330,13 @@ void BlackScholesParabolicPDESolverSystem::buildGammaCoefficientsLogTransform() // handle diagonal if (i == j) { this->gammaCoef->set(i, j, - 0.5 * ((this->sigmas->get(this->BSalgoDims[i])*this->sigmas->get( - this->BSalgoDims[j]))*this->rhos->get(this->BSalgoDims[i], - this->BSalgoDims[j]))); + 0.5 * ((this->sigmas->get(this->BSalgoDims[i]) * + this->sigmas->get(this->BSalgoDims[j])) * + this->rhos->get(this->BSalgoDims[i], this->BSalgoDims[j]))); } else { - this->gammaCoef->set(i, j, - ((this->sigmas->get(this->BSalgoDims[i])*this->sigmas->get( - this->BSalgoDims[j]))*this->rhos->get(this->BSalgoDims[i], - this->BSalgoDims[j]))); + this->gammaCoef->set(i, j, ((this->sigmas->get(this->BSalgoDims[i]) * + this->sigmas->get(this->BSalgoDims[j])) * + this->rhos->get(this->BSalgoDims[i], this->BSalgoDims[j]))); } } } @@ -351,11 +346,10 @@ void BlackScholesParabolicPDESolverSystem::buildDeltaCoefficientsLogTransform() size_t dim = this->BSalgoDims.size(); for (size_t i = 0; i < dim; i++) { - this->deltaCoef->set(i, this->mus->get(this->BSalgoDims[i]) - (0.5 * - (this->sigmas->get(this->BSalgoDims[i])*this->sigmas->get( - this->BSalgoDims[i])))); + this->deltaCoef->set( + i, this->mus->get(this->BSalgoDims[i]) - (0.5 * (this->sigmas->get(this->BSalgoDims[i]) * + this->sigmas->get(this->BSalgoDims[i])))); } } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystem.hpp b/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystem.hpp index aa48acabcd..d191e81cd4 100644 --- a/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystem.hpp +++ b/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystem.hpp @@ -15,6 +15,8 @@ #include +#include +#include namespace SGPP { namespace finance { @@ -22,8 +24,8 @@ namespace finance { * This class implements the ParabolicPDESolverSystem for the BlackScholes * Equation. */ -class BlackScholesParabolicPDESolverSystem : public - SGPP::pde::OperationParabolicPDESolverSystemFreeBoundaries { +class BlackScholesParabolicPDESolverSystem + : public SGPP::pde::OperationParabolicPDESolverSystemFreeBoundaries { protected: /// the riskfree interest rate float_t r; @@ -68,11 +70,9 @@ class BlackScholesParabolicPDESolverSystem : public /// store whether log coordinates are used bool b_log_transform; - virtual void applyLOperator(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyLOperator(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - virtual void applyMassMatrix(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyMassMatrix(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** * Build the coefficients for the Gamma Operation, which @@ -117,30 +117,29 @@ class BlackScholesParabolicPDESolverSystem : public * @param rho reference to the rhos * @param r the riskfree interest rate * @param TimestepSize the size of one timestep used in the ODE Solver - * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for explicit Euler, + * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for + * explicit Euler, * ImEul for implicit Euler, CrNic for Crank Nicolson solver - * @param bLogTransform indicates that this system belongs to a log-transformed Black Scholes Equation + * @param bLogTransform indicates that this system belongs to a log-transformed Black Scholes + * Equation * @param useCoarsen specifies if the grid should be coarsened between timesteps * @param coarsenThreshold Threshold to decide, if a grid point should be deleted * @param adaptSolveMode adaptive mode during solving: coarsen, refine, coarsenNrefine - * @param numCoarsenPoints number of point that should be coarsened in one coarsening step !CURRENTLY UNUSED PARAMETER! + * @param numCoarsenPoints number of point that should be coarsened in one coarsening step + * !CURRENTLY UNUSED PARAMETER! * @param refineThreshold Threshold to decide, if a grid point should be refined * @param refineMode refineMode during solving Black Scholes Equation: classic or maxLevel * @param refineMaxLevel max. level of refinement during solving * @param dStrike the option's strike value * @param option_type type of option used here */ - BlackScholesParabolicPDESolverSystem(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& alpha, SGPP::base::DataVector& mu, - SGPP::base::DataVector& sigma, - SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, - std::string OperationMode, - float_t dStrike, std::string option_type, - bool bLogTransform = false, bool useCoarsen = false, - float_t coarsenThreshold = 0.0, std::string adaptSolveMode = "none", - int numCoarsenPoints = -1, float_t refineThreshold = 0.0, - std::string refineMode = "classic", - SGPP::base::GridIndex::level_type refineMaxLevel = 0); + BlackScholesParabolicPDESolverSystem( + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& mu, + SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, + std::string OperationMode, float_t dStrike, std::string option_type, + bool bLogTransform = false, bool useCoarsen = false, float_t coarsenThreshold = 0.0, + std::string adaptSolveMode = "none", int numCoarsenPoints = -1, float_t refineThreshold = 0.0, + std::string refineMode = "classic", SGPP::base::GridIndex::level_type refineMaxLevel = 0); /** * Std-Destructor @@ -151,10 +150,9 @@ class BlackScholesParabolicPDESolverSystem : public virtual void coarsenAndRefine(bool isLastTimestep = false); - virtual void startTimestep(); }; -} -} +} // namespace finance +} // namespace SGPP -#endif /* BLACKSCHOLESPARABOLICPDESOLVERSYSTEM_HPP */ \ No newline at end of file +#endif /* BLACKSCHOLESPARABOLICPDESOLVERSYSTEM_HPP */ diff --git a/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmer.cpp b/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmer.cpp index 4974dfc62c..9fd17bcb47 100644 --- a/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmer.cpp +++ b/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmer.cpp @@ -10,41 +10,37 @@ #include #include #include -#include #include +#include +#include +#include +#include namespace SGPP { namespace finance { BlackScholesParabolicPDESolverSystemEuroAmer::BlackScholesParabolicPDESolverSystemEuroAmer( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, - SGPP::base::DataVector& mu, - SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, - float_t TimestepSize, std::string OperationMode, - float_t dStrike, std::string option_type, - bool bLogTransform, bool useCoarsen, float_t coarsenThreshold, - std::string adaptSolveMode, - int numCoarsenPoints, float_t refineThreshold, std::string refineMode, - SGPP::base::GridIndex::level_type xLevel) { + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& mu, + SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, + std::string OperationMode, float_t dStrike, std::string option_type, bool bLogTransform, + bool useCoarsen, float_t coarsenThreshold, std::string adaptSolveMode, int numCoarsenPoints, + float_t refineThreshold, std::string refineMode, SGPP::base::GridIndex::level_type xLevel) { this->BoundGrid = &SparseGrid; this->alpha_complete = α this->alpha_complete_old = new SGPP::base::DataVector(*this->alpha_complete); this->alpha_complete_tmp = new SGPP::base::DataVector(*this->alpha_complete); - this->oldGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); - this->secondGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); + this->oldGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); + this->secondGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); this->InnerGrid = NULL; this->alpha_inner = NULL; this->tOperationMode = OperationMode; this->TimestepSize = TimestepSize; this->TimestepSize_old = TimestepSize; - this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector( - SparseGrid.getStorage()); + this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector(SparseGrid.getStorage()); this->GridConverter = new SGPP::base::DirichletGridConverter(); this->r = r; this->mus = μ @@ -55,25 +51,38 @@ BlackScholesParabolicPDESolverSystemEuroAmer::BlackScholesParabolicPDESolverSyst // throw exception if grid dimensions not equal algorithmic dimensions if (this->BSalgoDims.size() != this->BoundGrid->getStorage()->dim()) { - throw SGPP::base::algorithm_exception("BlackScholesParabolicPDESolverSystemEuropean::BlackScholesParabolicPDESolverSystemEuropean : Number of algorithmic dimensions is not equal to the number of grid's dimensions."); + throw SGPP::base::algorithm_exception( + "BlackScholesParabolicPDESolverSystemEuropean::" + "BlackScholesParabolicPDESolverSystemEuropean : Number of algorithmic dimensions is not " + "equal to the number of grid's dimensions."); } - // test if number of dimensions in the coefficients match the numbers of grid dimensions (mu and sigma) - if (this->BoundGrid->getStorage()->dim() != this->mus->getSize() - || this->BoundGrid->getStorage()->dim() != this->sigmas->getSize()) { - throw SGPP::base::algorithm_exception("BlackScholesParabolicPDESolverSystemEuropean::BlackScholesParabolicPDESolverSystemEuropean : Dimension of mu and sigma parameters don't match the grid's dimensions!"); + // test if number of dimensions in the coefficients match the numbers of grid dimensions (mu and + // sigma) + if (this->BoundGrid->getStorage()->dim() != this->mus->getSize() || + this->BoundGrid->getStorage()->dim() != this->sigmas->getSize()) { + throw SGPP::base::algorithm_exception( + "BlackScholesParabolicPDESolverSystemEuropean::" + "BlackScholesParabolicPDESolverSystemEuropean : Dimension of mu and sigma parameters don't " + "match the grid's dimensions!"); } // test if number of dimensions in the coefficients match the numbers of grid dimensions (rho) - if (this->BoundGrid->getStorage()->dim() != this->rhos->getNrows() - || this->BoundGrid->getStorage()->dim() != this->rhos->getNcols()) { - throw SGPP::base::algorithm_exception("BlackScholesParabolicPDESolverSystemEuropean::BlackScholesParabolicPDESolverSystemEuropean : Row or col of rho parameter don't match the grid's dimensions!"); + if (this->BoundGrid->getStorage()->dim() != this->rhos->getNrows() || + this->BoundGrid->getStorage()->dim() != this->rhos->getNcols()) { + throw SGPP::base::algorithm_exception( + "BlackScholesParabolicPDESolverSystemEuropean::" + "BlackScholesParabolicPDESolverSystemEuropean : Row or col of rho parameter don't match " + "the grid's dimensions!"); } // test if all algorithmic dimensions are inside the grid's dimensions for (size_t i = 0; i < this->BSalgoDims.size(); i++) { if (this->BSalgoDims[i] >= this->BoundGrid->getStorage()->dim()) { - throw SGPP::base::algorithm_exception("BlackScholesParabolicPDESolverSystemEuropean::BlackScholesParabolicPDESolverSystemEuropean : Minimum one algorithmic dimension is not inside the grid's dimensions!"); + throw SGPP::base::algorithm_exception( + "BlackScholesParabolicPDESolverSystemEuropean::" + "BlackScholesParabolicPDESolverSystemEuropean : Minimum one algorithmic dimension is not " + "inside the grid's dimensions!"); } } @@ -90,56 +99,52 @@ BlackScholesParabolicPDESolverSystemEuroAmer::BlackScholesParabolicPDESolverSyst } if (dimCount > 1) { - throw SGPP::base::algorithm_exception("BlackScholesParabolicPDESolverSystemEuropean::BlackScholesParabolicPDESolverSystemEuropean : There is minimum one float_td algorithmic dimension!"); + throw SGPP::base::algorithm_exception( + "BlackScholesParabolicPDESolverSystemEuropean::" + "BlackScholesParabolicPDESolverSystemEuropean : There is minimum one float_td " + "algorithmic dimension!"); } } // build the coefficient vectors for the operations - this->gammaCoef = new SGPP::base::DataMatrix(this->BSalgoDims.size(), - this->BSalgoDims.size()); + this->gammaCoef = new SGPP::base::DataMatrix(this->BSalgoDims.size(), this->BSalgoDims.size()); this->deltaCoef = new SGPP::base::DataVector(this->BSalgoDims.size()); // create the inner grid - this->GridConverter->buildInnerGridWithCoefs(*this->BoundGrid, - *this->alpha_complete, &this->InnerGrid, &this->alpha_inner); + this->GridConverter->buildInnerGridWithCoefs(*this->BoundGrid, *this->alpha_complete, + &this->InnerGrid, &this->alpha_inner); if (bLogTransform == false) { buildDeltaCoefficients(); buildGammaCoefficients(); - //Create needed operations, on inner grid - this->OpDeltaInner = SGPP::op_factory::createOperationDelta(*this->InnerGrid, - *this->deltaCoef); - this->OpGammaInner = SGPP::op_factory::createOperationGamma(*this->InnerGrid, - *this->gammaCoef); + // Create needed operations, on inner grid + this->OpDeltaInner = SGPP::op_factory::createOperationDelta(*this->InnerGrid, *this->deltaCoef); + this->OpGammaInner = SGPP::op_factory::createOperationGamma(*this->InnerGrid, *this->gammaCoef); // Create needed operations, on boundary grid - this->OpDeltaBound = SGPP::op_factory::createOperationDelta(*this->BoundGrid, - *this->deltaCoef); - this->OpGammaBound = SGPP::op_factory::createOperationGamma(*this->BoundGrid, - *this->gammaCoef); - } - // create needed operations that are different in case of a log-transformed Black-Scholoes equation - else { + this->OpDeltaBound = SGPP::op_factory::createOperationDelta(*this->BoundGrid, *this->deltaCoef); + this->OpGammaBound = SGPP::op_factory::createOperationGamma(*this->BoundGrid, *this->gammaCoef); + } else { + // create needed operations that are different in case of a log-transformed Black-Scholoes + // equation buildDeltaCoefficientsLogTransform(); buildGammaCoefficientsLogTransform(); // operations on boundary grid - this->OpDeltaBound = SGPP::op_factory::createOperationDeltaLog(*this->BoundGrid, - *this->deltaCoef); - this->OpGammaBound = SGPP::op_factory::createOperationGammaLog(*this->BoundGrid, - *this->gammaCoef); - //operations on inner grid - this->OpDeltaInner = SGPP::op_factory::createOperationDeltaLog(*this->InnerGrid, - *this->deltaCoef); - this->OpGammaInner = SGPP::op_factory::createOperationGammaLog(*this->InnerGrid, - *this->gammaCoef); + this->OpDeltaBound = + SGPP::op_factory::createOperationDeltaLog(*this->BoundGrid, *this->deltaCoef); + this->OpGammaBound = + SGPP::op_factory::createOperationGammaLog(*this->BoundGrid, *this->gammaCoef); + // operations on inner grid + this->OpDeltaInner = + SGPP::op_factory::createOperationDeltaLog(*this->InnerGrid, *this->deltaCoef); + this->OpGammaInner = + SGPP::op_factory::createOperationGammaLog(*this->InnerGrid, *this->gammaCoef); } // Create operations, independent bLogTransform - this->OpLTwoInner = SGPP::op_factory::createOperationLTwoDotProduct( - *this->InnerGrid); - this->OpLTwoBound = SGPP::op_factory::createOperationLTwoDotProduct( - *this->BoundGrid); + this->OpLTwoInner = SGPP::op_factory::createOperationLTwoDotProduct(*this->InnerGrid); + this->OpLTwoBound = SGPP::op_factory::createOperationLTwoDotProduct(*this->BoundGrid); // right hand side if System this->rhs = NULL; @@ -166,37 +171,32 @@ BlackScholesParabolicPDESolverSystemEuroAmer::BlackScholesParabolicPDESolverSyst #ifdef HEDGE SGPP::base::BoundingBox* grid_bb = this->BoundGrid->getBoundingBox(); - SGPP::base::DimensionBoundary* myBoundaries = new - SGPP::base::DimensionBoundary[grid_bb->getDimensions()]; + SGPP::base::DimensionBoundary* myBoundaries = + new SGPP::base::DimensionBoundary[grid_bb->getDimensions()]; for (size_t d = 0; d < grid_bb->getDimensions(); d++) { if (bLogTransform == true) { - float_t interval_width = exp(grid_bb->getBoundary(d).rightBoundary) - exp( - grid_bb->getBoundary(d).leftBoundary); - float_t hedge_offset = (interval_width - (interval_width * - HEDGE_WIDTH_PERCENT)) / 2.0; - myBoundaries[d].leftBoundary = exp(grid_bb->getBoundary( - d).leftBoundary) + hedge_offset; - myBoundaries[d].rightBoundary = exp(grid_bb->getBoundary( - d).rightBoundary) - hedge_offset; + float_t interval_width = + exp(grid_bb->getBoundary(d).rightBoundary) - exp(grid_bb->getBoundary(d).leftBoundary); + float_t hedge_offset = (interval_width - (interval_width * HEDGE_WIDTH_PERCENT)) / 2.0; + myBoundaries[d].leftBoundary = exp(grid_bb->getBoundary(d).leftBoundary) + hedge_offset; + myBoundaries[d].rightBoundary = exp(grid_bb->getBoundary(d).rightBoundary) - hedge_offset; } else { - float_t hedge_offset = (grid_bb->getIntervalWidth(d) - - (grid_bb->getIntervalWidth(d) * HEDGE_WIDTH_PERCENT)) / 2.0; - myBoundaries[d].leftBoundary = grid_bb->getBoundary(d).leftBoundary + - hedge_offset; - myBoundaries[d].rightBoundary = grid_bb->getBoundary(d).rightBoundary - - hedge_offset; + float_t hedge_offset = + (grid_bb->getIntervalWidth(d) - (grid_bb->getIntervalWidth(d) * HEDGE_WIDTH_PERCENT)) / + 2.0; + myBoundaries[d].leftBoundary = grid_bb->getBoundary(d).leftBoundary + hedge_offset; + myBoundaries[d].rightBoundary = grid_bb->getBoundary(d).rightBoundary - hedge_offset; } myBoundaries[d].bDirichletLeft = true; myBoundaries[d].bDirichletRight = true; } - SGPP::base::BoundingBox* myHedgeBB = new SGPP::base::BoundingBox( - grid_bb->getDimensions(), myBoundaries); + SGPP::base::BoundingBox* myHedgeBB = + new SGPP::base::BoundingBox(grid_bb->getDimensions(), myBoundaries); // hedging - myHedge = new SGPP::finance::Hedging(*myHedgeBB, HEDGE_POINTS_PER_DIM, - HEDGE_EPS, bLogTransform); + myHedge = new SGPP::finance::Hedging(*myHedgeBB, HEDGE_POINTS_PER_DIM, HEDGE_EPS, bLogTransform); delete myHedgeBB; delete[] myBoundaries; @@ -236,7 +236,7 @@ BlackScholesParabolicPDESolverSystemEuroAmer::~BlackScholesParabolicPDESolverSys } void BlackScholesParabolicPDESolverSystemEuroAmer::applyLOperatorComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -244,7 +244,7 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::applyLOperatorComplete( // Apply the riskfree rate if (this->r != 0.0) { this->OpLTwoBound->mult(alpha, temp); - result.axpy((-1.0)*this->r, temp); + result.axpy((-1.0) * this->r, temp); } // Apply the delta method @@ -257,7 +257,7 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::applyLOperatorComplete( } void BlackScholesParabolicPDESolverSystemEuroAmer::applyLOperatorInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -265,7 +265,7 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::applyLOperatorInner( // Apply the riskfree rate if (this->r != 0.0) { this->OpLTwoInner->mult(alpha, temp); - result.axpy((-1.0)*this->r, temp); + result.axpy((-1.0) * this->r, temp); } // Apply the delta method @@ -278,7 +278,7 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::applyLOperatorInner( } void BlackScholesParabolicPDESolverSystemEuroAmer::applyMassMatrixComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -290,7 +290,7 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::applyMassMatrixComplete( } void BlackScholesParabolicPDESolverSystemEuroAmer::applyMassMatrixInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -305,8 +305,7 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::finishTimestep() { this->nExecTimesteps++; // Replace the inner coefficients on the boundary grid - this->GridConverter->updateBoundaryCoefs(*this->alpha_complete, - *this->alpha_inner); + this->GridConverter->updateBoundaryCoefs(*this->alpha_complete, *this->alpha_inner); #ifndef NOBOUNDARYDISCOUNT @@ -323,17 +322,16 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::finishTimestep() { // check if we are doing an American put -> handle early exercise if (this->option_type == "std_amer_put") { SGPP::base::OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->BoundGrid); + SGPP::op_factory::createOperationHierarchisation(*this->BoundGrid); myHierarchisation->doDehierarchisation(*this->alpha_complete); size_t dim = this->BoundGrid->getStorage()->dim(); - SGPP::base::BoundingBox* myBB = new SGPP::base::BoundingBox(* - (this->BoundGrid->getBoundingBox())); + SGPP::base::BoundingBox* myBB = + new SGPP::base::BoundingBox(*(this->BoundGrid->getBoundingBox())); float_t* dblFuncValues = new float_t[dim]; for (size_t i = 0; i < this->BoundGrid->getStorage()->size(); i++) { - std::string coords = this->BoundGrid->getStorage()->get(i)->getCoordsStringBB( - *myBB); + std::string coords = this->BoundGrid->getStorage()->get(i)->getCoordsStringBB(*myBB); std::stringstream coordsStream(coords); float_t tmp; @@ -357,9 +355,13 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::finishTimestep() { } } - // (*this->alpha_complete)[i] = std::max((*this->alpha_complete)[i], (std::max(this->dStrike-((tmp/static_cast(dim))), 0.0))*exp(((-1.0)*(this->r*static_cast(this->nExecTimesteps)*this->TimestepSize)))); - (*this->alpha_complete)[i] = std::max((*this->alpha_complete)[i], - (std::max(this->dStrike - ((tmp / static_cast(dim))), 0.0))); + // (*this->alpha_complete)[i] = std::max((*this->alpha_complete)[i], + // (std::max(this->dStrike-((tmp/static_cast(dim))), + // 0.0))*exp(((-1.0)*(this->r* + // static_cast(this->nExecTimesteps)*this->TimestepSize)))); + (*this->alpha_complete)[i] = std::max( + (*this->alpha_complete)[i], + (std::max(this->dStrike - ((tmp / static_cast(dim))), 0.0))); } delete[] dblFuncValues; @@ -370,8 +372,7 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::finishTimestep() { } } -void BlackScholesParabolicPDESolverSystemEuroAmer::coarsenAndRefine( - bool isLastTimestep) { +void BlackScholesParabolicPDESolverSystemEuroAmer::coarsenAndRefine(bool isLastTimestep) { // add number of Gridpoints this->numSumGridpointsInner += this->InnerGrid->getSize(); this->numSumGridpointsComplete += this->BoundGrid->getSize(); @@ -386,15 +387,13 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::coarsenAndRefine( // Coarsen the grid SGPP::base::GridGenerator* myGenerator = this->BoundGrid->createGridGenerator(); - //std::cout << "Coarsen Threshold: " << this->coarsenThreshold << std::endl; - //std::cout << "Grid Size: " << originalGridSize << std::endl; + // std::cout << "Coarsen Threshold: " << this->coarsenThreshold << std::endl; + // std::cout << "Grid Size: " << originalGridSize << std::endl; - if (this->adaptSolveMode == "refine" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "refine" || this->adaptSolveMode == "coarsenNrefine") { size_t numRefines = myGenerator->getNumberOfRefinablePoints(); - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(this->alpha_complete, numRefines, - this->refineThreshold); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = new SGPP::base::SurplusRefinementFunctor( + this->alpha_complete, numRefines, this->refineThreshold); if (this->refineMode == "maxLevel") { myGenerator->refineMaxLevel(myRefineFunc, this->refineMaxLevel); @@ -409,14 +408,12 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::coarsenAndRefine( delete myRefineFunc; } - if (this->adaptSolveMode == "coarsen" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "coarsen" || this->adaptSolveMode == "coarsenNrefine") { size_t numCoarsen = myGenerator->getNumberOfRemovablePoints(); - SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = new - SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, - this->coarsenThreshold); - myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, - originalGridSize); + SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = + new SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, + this->coarsenThreshold); + myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, originalGridSize); delete myCoarsenFunctor; } @@ -427,16 +424,15 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::coarsenAndRefine( /////////////////////////////////////////////////// // rebuild the inner grid + coefficients - this->GridConverter->rebuildInnerGridWithCoefs(*this->BoundGrid, - *this->alpha_complete, &this->InnerGrid, &this->alpha_inner); + this->GridConverter->rebuildInnerGridWithCoefs(*this->BoundGrid, *this->alpha_complete, + &this->InnerGrid, &this->alpha_inner); } #ifdef HEDGE std::stringstream filename_ext; - filename_ext << ((this->nExecTimesteps)*this->TimestepSize); + filename_ext << ((this->nExecTimesteps) * this->TimestepSize); - myHedge->calc_hedging(*this->BoundGrid, *this->alpha_complete, - filename_ext.str()); + myHedge->calc_hedging(*this->BoundGrid, *this->alpha_complete, filename_ext.str()); #endif } @@ -462,14 +458,13 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::buildGammaCoefficients() { // handle diagonal if (i == j) { this->gammaCoef->set(i, j, - 0.5 * ((this->sigmas->get(this->BSalgoDims[i])*this->sigmas->get( - this->BSalgoDims[j]))*this->rhos->get(this->BSalgoDims[i], - this->BSalgoDims[j]))); + 0.5 * ((this->sigmas->get(this->BSalgoDims[i]) * + this->sigmas->get(this->BSalgoDims[j])) * + this->rhos->get(this->BSalgoDims[i], this->BSalgoDims[j]))); } else { - this->gammaCoef->set(i, j, - ((this->sigmas->get(this->BSalgoDims[i])*this->sigmas->get( - this->BSalgoDims[j]))*this->rhos->get(this->BSalgoDims[i], - this->BSalgoDims[j]))); + this->gammaCoef->set(i, j, ((this->sigmas->get(this->BSalgoDims[i]) * + this->sigmas->get(this->BSalgoDims[j])) * + this->rhos->get(this->BSalgoDims[i], this->BSalgoDims[j]))); } } } @@ -485,13 +480,14 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::buildDeltaCoefficients() { for (size_t j = 0; j < dim; j++) { // handle diagonal if (i == j) { - covar_sum += ((this->sigmas->get(this->BSalgoDims[i]) * this->sigmas->get( - this->BSalgoDims[j])) * this->rhos->get(this->BSalgoDims[i], - this->BSalgoDims[j])); + covar_sum += + ((this->sigmas->get(this->BSalgoDims[i]) * this->sigmas->get(this->BSalgoDims[j])) * + this->rhos->get(this->BSalgoDims[i], this->BSalgoDims[j])); } else { - covar_sum += (0.5 * ((this->sigmas->get(this->BSalgoDims[i]) * - this->sigmas->get(this->BSalgoDims[j])) * this->rhos->get(this->BSalgoDims[i], - this->BSalgoDims[j]))); + covar_sum += + (0.5 * + ((this->sigmas->get(this->BSalgoDims[i]) * this->sigmas->get(this->BSalgoDims[j])) * + this->rhos->get(this->BSalgoDims[i], this->BSalgoDims[j]))); } } @@ -507,14 +503,13 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::buildGammaCoefficientsLogTran // handle diagonal if (i == j) { this->gammaCoef->set(i, j, - 0.5 * ((this->sigmas->get(this->BSalgoDims[i])*this->sigmas->get( - this->BSalgoDims[j]))*this->rhos->get(this->BSalgoDims[i], - this->BSalgoDims[j]))); + 0.5 * ((this->sigmas->get(this->BSalgoDims[i]) * + this->sigmas->get(this->BSalgoDims[j])) * + this->rhos->get(this->BSalgoDims[i], this->BSalgoDims[j]))); } else { - this->gammaCoef->set(i, j, - ((this->sigmas->get(this->BSalgoDims[i])*this->sigmas->get( - this->BSalgoDims[j]))*this->rhos->get(this->BSalgoDims[i], - this->BSalgoDims[j]))); + this->gammaCoef->set(i, j, ((this->sigmas->get(this->BSalgoDims[i]) * + this->sigmas->get(this->BSalgoDims[j])) * + this->rhos->get(this->BSalgoDims[i], this->BSalgoDims[j]))); } } } @@ -524,11 +519,10 @@ void BlackScholesParabolicPDESolverSystemEuroAmer::buildDeltaCoefficientsLogTran size_t dim = this->BSalgoDims.size(); for (size_t i = 0; i < dim; i++) { - this->deltaCoef->set(i, this->mus->get(this->BSalgoDims[i]) - (0.5 * - (this->sigmas->get(this->BSalgoDims[i])*this->sigmas->get( - this->BSalgoDims[i])))); + this->deltaCoef->set( + i, this->mus->get(this->BSalgoDims[i]) - (0.5 * (this->sigmas->get(this->BSalgoDims[i]) * + this->sigmas->get(this->BSalgoDims[i])))); } } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmer.hpp b/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmer.hpp index e459451488..c08f8a01a4 100644 --- a/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmer.hpp +++ b/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmer.hpp @@ -12,13 +12,15 @@ #include #include -//#define HEDGE +// #define HEDGE #define HEDGE_EPS 0.05 #define HEDGE_WIDTH_PERCENT 0.95 #define HEDGE_POINTS_PER_DIM 75 #include +#include +#include namespace SGPP { namespace finance { @@ -29,8 +31,8 @@ namespace finance { * * Here European or American Options with fix Dirichlet boundaries are solved. */ -class BlackScholesParabolicPDESolverSystemEuroAmer : public - SGPP::pde::OperationParabolicPDESolverSystemDirichlet { +class BlackScholesParabolicPDESolverSystemEuroAmer + : public SGPP::pde::OperationParabolicPDESolverSystemDirichlet { protected: /// the riskfree interest rate float_t r; @@ -85,14 +87,12 @@ class BlackScholesParabolicPDESolverSystemEuroAmer : public SGPP::finance::Hedging* myHedge; #endif - virtual void applyLOperatorInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyLOperatorInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual void applyLOperatorComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - virtual void applyMassMatrixInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyMassMatrixInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual void applyMassMatrixComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); @@ -140,30 +140,29 @@ class BlackScholesParabolicPDESolverSystemEuroAmer : public * @param rho reference to the rhos * @param r the riskfree interest rate * @param TimestepSize the size of one timestep used in the ODE Solver - * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for explicit Euler, + * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for + * explicit Euler, * ImEul for implicit Euler, CrNic for Crank Nicolson solver * @param dStrike the strike of the current options * @param option_type the type of the current option - * @param bLogTransform indicates that this system belongs to a log-transformed Black Scholes Equation + * @param bLogTransform indicates that this system belongs to a log-transformed Black Scholes + * Equation * @param useCoarsen specifies if the grid should be coarsened between timesteps * @param coarsenThreshold Threshold to decide, if a grid point should be deleted * @param adaptSolveMode adaptive mode during solving: coarsen, refine, coarsenNrefine - * @param numCoarsenPoints number of point that should be coarsened in one coarsening step !CURRENTLY UNUSED PARAMETER! + * @param numCoarsenPoints number of point that should be coarsened in one coarsening step + * !CURRENTLY UNUSED PARAMETER! * @param refineThreshold Threshold to decide, if a grid point should be refined * @param refineMode refineMode during solving Black Scholes Equation: classic or maxLevel * @param refineMaxLevel max. level of refinement during solving */ - BlackScholesParabolicPDESolverSystemEuroAmer(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& alpha, SGPP::base::DataVector& mu, - SGPP::base::DataVector& sigma, - SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, - std::string OperationMode, - float_t dStrike, std::string option_type, - bool bLogTransform = false, bool useCoarsen = false, - float_t coarsenThreshold = 0.0, std::string adaptSolveMode = "none", - int numCoarsenPoints = -1, float_t refineThreshold = 0.0, - std::string refineMode = "classic", - SGPP::base::GridIndex::level_type refineMaxLevel = 0); + BlackScholesParabolicPDESolverSystemEuroAmer( + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& mu, + SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, + std::string OperationMode, float_t dStrike, std::string option_type, + bool bLogTransform = false, bool useCoarsen = false, float_t coarsenThreshold = 0.0, + std::string adaptSolveMode = "none", int numCoarsenPoints = -1, float_t refineThreshold = 0.0, + std::string refineMode = "classic", SGPP::base::GridIndex::level_type refineMaxLevel = 0); /** * Std-Destructor @@ -176,9 +175,7 @@ class BlackScholesParabolicPDESolverSystemEuroAmer : public void startTimestep(); }; +} // namespace finance +} // namespace SGPP -} - -} - -#endif /* BLACKSCHOLESPARABOLICPDESOLVERSYSTEMEUROAMER_HPP */ \ No newline at end of file +#endif /* BLACKSCHOLESPARABOLICPDESOLVERSYSTEMEUROAMER_HPP */ diff --git a/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP.cpp b/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP.cpp index e5baf3e920..3e9a689e19 100644 --- a/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP.cpp +++ b/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP.cpp @@ -16,35 +16,33 @@ #include +#include +#include namespace SGPP { namespace finance { -BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, - SGPP::base::DataVector& mu, - SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, - float_t TimestepSize, std::string OperationMode, float_t dStrike, - std::string option_type, - bool bLogTransform, bool useCoarsen, float_t coarsenThreshold, - std::string adaptSolveMode, - int numCoarsenPoints, float_t refineThreshold, std::string refineMode, - SGPP::base::GridIndex::level_type refineMaxLevel) : - BlackScholesParabolicPDESolverSystemEuroAmer(SparseGrid, alpha, mu, sigma, rho, - r, TimestepSize, OperationMode, dStrike, option_type, bLogTransform, useCoarsen, - coarsenThreshold, adaptSolveMode, numCoarsenPoints, refineThreshold, refineMode, - refineMaxLevel) { -} - -BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::~BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP() { -} +BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP:: + BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP( + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& mu, + SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, + std::string OperationMode, float_t dStrike, std::string option_type, bool bLogTransform, + bool useCoarsen, float_t coarsenThreshold, std::string adaptSolveMode, int numCoarsenPoints, + float_t refineThreshold, std::string refineMode, + SGPP::base::GridIndex::level_type refineMaxLevel) + : BlackScholesParabolicPDESolverSystemEuroAmer( + SparseGrid, alpha, mu, sigma, rho, r, TimestepSize, OperationMode, dStrike, option_type, + bLogTransform, useCoarsen, coarsenThreshold, adaptSolveMode, numCoarsenPoints, + refineThreshold, refineMode, refineMaxLevel) {} + +BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP:: + ~BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP() {} void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); - std::vector algoDims = - this->InnerGrid->getStorage()->getAlgorithmicDimensions(); + std::vector algoDims = this->InnerGrid->getStorage()->getAlgorithmicDimensions(); size_t nDims = algoDims.size(); #ifdef _OPENMP omp_lock_t DeltaMutex; @@ -55,31 +53,31 @@ void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorInne SGPP::base::DataVector DeltaResult(result); SGPP::base::DataVector GammaResult(result); - // Apply the riskfree rate - #pragma omp task shared(alpha, result) +// Apply the riskfree rate +#pragma omp task shared(alpha, result) { if (this->r != 0.0) { SGPP::base::DataVector myResult(result.getSize()); /// discuss methods in order to avoid this cast - ((SGPP::pde::StdUpDown*)(this->OpLTwoInner))->multParallelBuildingBlock(alpha, - myResult); + ((SGPP::pde::StdUpDown*)(this->OpLTwoInner))->multParallelBuildingBlock(alpha, myResult); // no semaphore needed - result.axpy((-1.0)*this->r, myResult); + result.axpy((-1.0) * this->r, myResult); } } // Apply the delta method for (size_t i = 0; i < nDims; i++) { - #pragma omp task firstprivate(i) shared(alpha, DeltaMutex, DeltaResult, result, algoDims) +#pragma omp task firstprivate(i) shared(alpha, DeltaMutex, DeltaResult, result, algoDims) { SGPP::base::DataVector myResult(result.getSize()); /// discuss methods in order to avoid this cast - ((SGPP::pde::UpDownOneOpDim*)(this->OpDeltaInner))->multParallelBuildingBlock(alpha, myResult, algoDims[i]); + ((SGPP::pde::UpDownOneOpDim*)(this->OpDeltaInner)) + ->multParallelBuildingBlock(alpha, myResult, algoDims[i]); - // semaphore +// semaphore #ifdef _OPENMP omp_set_lock(&DeltaMutex); #endif @@ -95,14 +93,15 @@ void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorInne for (size_t j = 0; j < nDims; j++) { // symmetric if (j <= i) { - #pragma omp task firstprivate(i, j) shared(alpha, GammaMutex, GammaResult, result, algoDims) +#pragma omp task firstprivate(i, j) shared(alpha, GammaMutex, GammaResult, result, algoDims) { SGPP::base::DataVector myResult(result.getSize()); /// discuss methods in order to avoid this cast - ((SGPP::pde::UpDownTwoOpDims*)(this->OpGammaInner))->multParallelBuildingBlock(alpha, myResult, algoDims[i], algoDims[j]); + ((SGPP::pde::UpDownTwoOpDims*)(this->OpGammaInner)) + ->multParallelBuildingBlock(alpha, myResult, algoDims[i], algoDims[j]); - // semaphore +// semaphore #ifdef _OPENMP omp_set_lock(&GammaMutex); #endif @@ -115,7 +114,7 @@ void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorInne } } - #pragma omp taskwait +#pragma omp taskwait #ifdef _OPENMP omp_destroy_lock(&GammaMutex); @@ -128,11 +127,10 @@ void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorInne } void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); - std::vector algoDims = - this->BoundGrid->getStorage()->getAlgorithmicDimensions(); + std::vector algoDims = this->BoundGrid->getStorage()->getAlgorithmicDimensions(); size_t nDims = algoDims.size(); #ifdef _OPENMP omp_lock_t DeltaMutex; @@ -143,31 +141,31 @@ void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorComp SGPP::base::DataVector DeltaResult(result); SGPP::base::DataVector GammaResult(result); - // Apply the riskfree rate - #pragma omp task shared(alpha, result) +// Apply the riskfree rate +#pragma omp task shared(alpha, result) { if (this->r != 0.0) { SGPP::base::DataVector myResult(result.getSize()); /// discuss methods in order to avoid this cast - ((SGPP::pde::StdUpDown*)(this->OpLTwoBound))->multParallelBuildingBlock(alpha, - myResult); + ((SGPP::pde::StdUpDown*)(this->OpLTwoBound))->multParallelBuildingBlock(alpha, myResult); // no semaphore needed - result.axpy((-1.0)*this->r, myResult); + result.axpy((-1.0) * this->r, myResult); } } // Apply the delta method for (size_t i = 0; i < nDims; i++) { - #pragma omp task firstprivate(i) shared(alpha, DeltaMutex, DeltaResult, result, algoDims) +#pragma omp task firstprivate(i) shared(alpha, DeltaMutex, DeltaResult, result, algoDims) { SGPP::base::DataVector myResult(result.getSize()); /// discuss methods in order to avoid this cast - ((SGPP::pde::UpDownOneOpDim*)(this->OpDeltaBound))->multParallelBuildingBlock(alpha, myResult, algoDims[i]); + ((SGPP::pde::UpDownOneOpDim*)(this->OpDeltaBound)) + ->multParallelBuildingBlock(alpha, myResult, algoDims[i]); - // semaphore +// semaphore #ifdef _OPENMP omp_set_lock(&DeltaMutex); #endif @@ -183,14 +181,15 @@ void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorComp for (size_t j = 0; j < nDims; j++) { // symmetric if (j <= i) { - #pragma omp task firstprivate(i, j) shared(alpha, GammaMutex, GammaResult, result, algoDims) +#pragma omp task firstprivate(i, j) shared(alpha, GammaMutex, GammaResult, result, algoDims) { SGPP::base::DataVector myResult(result.getSize()); /// discuss methods in order to avoid this cast - ((SGPP::pde::UpDownTwoOpDims*)(this->OpGammaBound))->multParallelBuildingBlock(alpha, myResult, algoDims[i], algoDims[j]); + ((SGPP::pde::UpDownTwoOpDims*)(this->OpGammaBound)) + ->multParallelBuildingBlock(alpha, myResult, algoDims[i], algoDims[j]); - // semaphore +// semaphore #ifdef _OPENMP omp_set_lock(&GammaMutex); #endif @@ -203,7 +202,7 @@ void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorComp } } - #pragma omp taskwait +#pragma omp taskwait #ifdef _OPENMP omp_destroy_lock(&GammaMutex); @@ -216,31 +215,29 @@ void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::applyLOperatorComp } void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::applyMassMatrixInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); - ((SGPP::pde::StdUpDown*)(this->OpLTwoInner))->multParallelBuildingBlock(alpha, - temp); + ((SGPP::pde::StdUpDown*)(this->OpLTwoInner))->multParallelBuildingBlock(alpha, temp); result.add(temp); } void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::applyMassMatrixComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); - ((SGPP::pde::StdUpDown*)(this->OpLTwoBound))->multParallelBuildingBlock(alpha, - temp); + ((SGPP::pde::StdUpDown*)(this->OpLTwoBound))->multParallelBuildingBlock(alpha, temp); result.add(temp); } -void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::mult( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::mult(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { if (this->tOperationMode == "ExEul") { applyMassMatrixInner(alpha, result); } else if (this->tOperationMode == "ImEul") { @@ -249,63 +246,56 @@ void BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::mult( SGPP::base::DataVector temp(result.getSize()); SGPP::base::DataVector temp2(result.getSize()); - #pragma omp parallel shared(alpha, result) +#pragma omp parallel shared(alpha, result) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha, temp) - { - applyMassMatrixInner(alpha, temp); - } +#pragma omp task shared(alpha, temp) + { applyMassMatrixInner(alpha, temp); } - #pragma omp task shared (alpha, temp2) - { - applyLOperatorInner(alpha, temp2); - } +#pragma omp task shared(alpha, temp2) + { applyLOperatorInner(alpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result.add(temp); - result.axpy((-1.0)*this->TimestepSize, temp2); + result.axpy((-1.0) * this->TimestepSize, temp2); } else if (this->tOperationMode == "CrNic") { result.setAll(0.0); SGPP::base::DataVector temp(result.getSize()); SGPP::base::DataVector temp2(result.getSize()); - #pragma omp parallel shared(alpha, result) +#pragma omp parallel shared(alpha, result) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha, temp) - { - applyMassMatrixInner(alpha, temp); - } +#pragma omp task shared(alpha, temp) + { applyMassMatrixInner(alpha, temp); } - #pragma omp task shared (alpha, temp2) - { - applyLOperatorInner(alpha, temp2); - } +#pragma omp task shared(alpha, temp2) + { applyLOperatorInner(alpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result.add(temp); - result.axpy((-0.5)*this->TimestepSize, temp2); + result.axpy((-0.5) * this->TimestepSize, temp2); } else if (this->tOperationMode == "AdBas") { result.setAll(0.0); applyMassMatrixInner(alpha, result); } else { - throw new SGPP::base::algorithm_exception(" BlackScholesParabolicPDESolverSystemEuropeanParallelOMP::mult : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + " BlackScholesParabolicPDESolverSystemEuropeanParallelOMP::mult : An unknown operation " + "mode was specified!"); } } -SGPP::base::DataVector* -BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { +SGPP::base::DataVector* BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { SGPP::base::DataVector rhs_complete(this->alpha_complete->getSize()); if (this->tOperationMode == "ExEul") { @@ -315,21 +305,17 @@ BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { SGPP::base::DataVector temp2(rhs_complete.getSize()); SGPP::base::DataVector myAlpha(*this->alpha_complete); - #pragma omp parallel shared(myAlpha, temp, temp2) +#pragma omp parallel shared(myAlpha, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myAlpha, temp) - { - applyMassMatrixComplete(myAlpha, temp); - } +#pragma omp task shared(myAlpha, temp) + { applyMassMatrixComplete(myAlpha, temp); } - #pragma omp task shared (myAlpha, temp2) - { - applyLOperatorComplete(myAlpha, temp2); - } +#pragma omp task shared(myAlpha, temp2) + { applyLOperatorComplete(myAlpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } @@ -346,26 +332,22 @@ BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { SGPP::base::DataVector temp2(rhs_complete.getSize()); SGPP::base::DataVector myAlpha(*this->alpha_complete); - #pragma omp parallel shared(myAlpha, temp, temp2) +#pragma omp parallel shared(myAlpha, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myAlpha, temp) - { - applyMassMatrixComplete(myAlpha, temp); - } +#pragma omp task shared(myAlpha, temp) + { applyMassMatrixComplete(myAlpha, temp); } - #pragma omp task shared (myAlpha, temp2) - { - applyLOperatorComplete(myAlpha, temp2); - } +#pragma omp task shared(myAlpha, temp2) + { applyLOperatorComplete(myAlpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } rhs_complete.add(temp); - rhs_complete.axpy((0.5)*this->TimestepSize, temp2); + rhs_complete.axpy((0.5) * this->TimestepSize, temp2); } else if (this->tOperationMode == "AdBas") { rhs_complete.setAll(0.0); @@ -375,16 +357,14 @@ BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { applyMassMatrixComplete(*this->alpha_complete, temp); - #pragma omp parallel shared(myAlpha, temp) +#pragma omp parallel shared(myAlpha, temp) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myAlpha, temp) - { - applyLOperatorComplete(myAlpha, temp); - } +#pragma omp task shared(myAlpha, temp) + { applyLOperatorComplete(myAlpha, temp); } - #pragma omp taskwait +#pragma omp taskwait } } @@ -395,24 +375,24 @@ BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { applyMassMatrixComplete(*this->alpha_complete_old, temp_old); - #pragma omp parallel shared(myOldAlpha, temp_old) +#pragma omp parallel shared(myOldAlpha, temp_old) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myOldAlpha, temp_old) - { - applyLOperatorComplete(myOldAlpha, temp_old); - } +#pragma omp task shared(myOldAlpha, temp_old) + { applyLOperatorComplete(myOldAlpha, temp_old); } - #pragma omp taskwait +#pragma omp taskwait } } temp_old.mult(this->TimestepSize / this->TimestepSize_old); temp.sub(temp_old); - rhs_complete.axpy((0.5)*this->TimestepSize, temp); + rhs_complete.axpy((0.5) * this->TimestepSize, temp); } else { - throw new SGPP::base::algorithm_exception("BlackScholesParabolicPDESolverSystemEuropeanParallelOMP::generateRHS : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + "BlackScholesParabolicPDESolverSystemEuropeanParallelOMP::generateRHS : An unknown " + "operation mode was specified!"); } // Now we have the right hand side, lets apply the riskfree rate for the next timestep @@ -433,54 +413,48 @@ BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { SGPP::base::DataVector temp(alpha_bound.getSize()); SGPP::base::DataVector temp2(alpha_bound.getSize()); - #pragma omp parallel shared(alpha_bound, temp, temp2) +#pragma omp parallel shared(alpha_bound, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha_bound, temp) - { - applyMassMatrixComplete(alpha_bound, temp); - } +#pragma omp task shared(alpha_bound, temp) + { applyMassMatrixComplete(alpha_bound, temp); } - #pragma omp task shared (alpha_bound, temp2) - { - applyLOperatorComplete(alpha_bound, temp2); - } +#pragma omp task shared(alpha_bound, temp2) + { applyLOperatorComplete(alpha_bound, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result_complete.add(temp); - result_complete.axpy((-1.0)*this->TimestepSize, temp2); + result_complete.axpy((-1.0) * this->TimestepSize, temp2); } else if (this->tOperationMode == "CrNic") { SGPP::base::DataVector temp(alpha_bound.getSize()); SGPP::base::DataVector temp2(alpha_bound.getSize()); - #pragma omp parallel shared(alpha_bound, temp, temp2) +#pragma omp parallel shared(alpha_bound, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha_bound, temp) - { - applyMassMatrixComplete(alpha_bound, temp); - } +#pragma omp task shared(alpha_bound, temp) + { applyMassMatrixComplete(alpha_bound, temp); } - #pragma omp task shared (alpha_bound, temp2) - { - applyLOperatorComplete(alpha_bound, temp2); - } +#pragma omp task shared(alpha_bound, temp2) + { applyLOperatorComplete(alpha_bound, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result_complete.add(temp); - result_complete.axpy((-0.5)*this->TimestepSize, temp2); + result_complete.axpy((-0.5) * this->TimestepSize, temp2); } else if (this->tOperationMode == "AdBas") { applyMassMatrixComplete(alpha_bound, result_complete); } else { - throw new SGPP::base::algorithm_exception("BlackScholesParabolicPDESolverSystemEuropeanParallelOMP::generateRHS : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + "BlackScholesParabolicPDESolverSystemEuropeanParallelOMP::generateRHS : An unknown " + "operation mode was specified!"); } rhs_complete.sub(result_complete); @@ -494,6 +468,5 @@ BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP::generateRHS() { return this->rhs; } - -} -} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP.hpp b/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP.hpp index ee9dfc6c76..b2be1874e6 100644 --- a/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP.hpp +++ b/finance/src/sgpp/finance/algorithm/BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP.hpp @@ -10,6 +10,7 @@ #include +#include namespace SGPP { namespace finance { @@ -25,17 +26,15 @@ namespace finance { * the OMP task concept to enable further parallelization possibilities * in the calculation of the space-discretization operator (L) */ -class BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP : public - BlackScholesParabolicPDESolverSystemEuroAmer { +class BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP + : public BlackScholesParabolicPDESolverSystemEuroAmer { protected: - virtual void applyLOperatorInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyLOperatorInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual void applyLOperatorComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - virtual void applyMassMatrixInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyMassMatrixInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual void applyMassMatrixComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); @@ -51,30 +50,29 @@ class BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP : public * @param rho reference to the rhos * @param r the riskfree interest rate * @param TimestepSize the size of one timestep used in the ODE Solver - * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for explicit Euler, + * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for + * explicit Euler, * ImEul for implicit Euler, CrNic for Crank Nicolson solver * @param dStrike strike * @param option_type type of option - * @param bLogTransform indicates that this system belongs to a log-transformed Black Scholes Equation + * @param bLogTransform indicates that this system belongs to a log-transformed Black Scholes + * Equation * @param useCoarsen specifies if the grid should be coarsened between timesteps * @param coarsenThreshold Threshold to decide, if a grid point should be deleted * @param adaptSolveMode adaptive mode during solving: coarsen, refine, coarsenNrefine - * @param numCoarsenPoints number of point that should be coarsened in one coarsening step !CURRENTLY UNUSED PARAMETER! + * @param numCoarsenPoints number of point that should be coarsened in one coarsening step + * !CURRENTLY UNUSED PARAMETER! * @param refineThreshold Threshold to decide, if a grid point should be refined * @param refineMode refineMode during solving Black Scholes Equation: classic or maxLevel * @param refineMaxLevel max. level for refinement during solving */ BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, - SGPP::base::DataVector& mu, SGPP::base::DataVector& sigma, - SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, - std::string OperationMode, - float_t dStrike, std::string option_type, - bool bLogTransform = false, bool useCoarsen = false, - float_t coarsenThreshold = 0.0, std::string adaptSolveMode = "none", - int numCoarsenPoints = -1, float_t refineThreshold = 0.0, - std::string refineMode = "classic", - SGPP::base::GridIndex::level_type refineMaxLevel = 0); + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& mu, + SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, + std::string OperationMode, float_t dStrike, std::string option_type, + bool bLogTransform = false, bool useCoarsen = false, float_t coarsenThreshold = 0.0, + std::string adaptSolveMode = "none", int numCoarsenPoints = -1, float_t refineThreshold = 0.0, + std::string refineMode = "classic", SGPP::base::GridIndex::level_type refineMaxLevel = 0); /** * Std-Destructor @@ -85,10 +83,10 @@ class BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP : public * Multiplicates a vector with the matrix, parallel * * @param alpha SGPP::base::DataVector that contains the ansatzfunctions' coefficients - * @param result SGPP::base::DataVector into which the result of the space discretization operation is stored + * @param result SGPP::base::DataVector into which the result of the space discretization + * operation is stored */ - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** * generates the right hand side of the system, parallel @@ -97,9 +95,7 @@ class BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP : public */ virtual SGPP::base::DataVector* generateRHS(); }; +} // namespace finance +} // namespace SGPP -} - -} - -#endif /* BLACKSCHOLESPARABOLICPDESOLVERSYSTEMEUROAMERPARALLELOMP_HPP */ \ No newline at end of file +#endif /* BLACKSCHOLESPARABOLICPDESOLVERSYSTEMEUROAMERPARALLELOMP_HPP */ diff --git a/finance/src/sgpp/finance/algorithm/HestonParabolicPDESolverSystemEuroAmer.cpp b/finance/src/sgpp/finance/algorithm/HestonParabolicPDESolverSystemEuroAmer.cpp index 8ffb1c1949..f235bf486b 100644 --- a/finance/src/sgpp/finance/algorithm/HestonParabolicPDESolverSystemEuroAmer.cpp +++ b/finance/src/sgpp/finance/algorithm/HestonParabolicPDESolverSystemEuroAmer.cpp @@ -11,44 +11,39 @@ #include #include #include -#include -//#define NOBOUNDARYDISCOUNT +// #define NOBOUNDARYDISCOUNT #include +#include +#include +#include namespace SGPP { namespace finance { HestonParabolicPDESolverSystemEuroAmer::HestonParabolicPDESolverSystemEuroAmer( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, - SGPP::base::DataVector& thetas, SGPP::base::DataVector& volvols, - SGPP::base::DataVector& kappas, - SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, - std::string OperationMode, - float_t dStrike, std::string option_type, - bool bLogTransform, bool useCoarsen, float_t coarsenThreshold, - std::string adaptSolveMode, - int numCoarsenPoints, float_t refineThreshold, std::string refineMode, - SGPP::base::GridIndex::level_type refineMaxLevel) { + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& thetas, + SGPP::base::DataVector& volvols, SGPP::base::DataVector& kappas, SGPP::base::DataMatrix& rho, + float_t r, float_t TimestepSize, std::string OperationMode, float_t dStrike, + std::string option_type, bool bLogTransform, bool useCoarsen, float_t coarsenThreshold, + std::string adaptSolveMode, int numCoarsenPoints, float_t refineThreshold, + std::string refineMode, SGPP::base::GridIndex::level_type refineMaxLevel) { this->BoundGrid = &SparseGrid; this->alpha_complete = α this->alpha_complete_old = new SGPP::base::DataVector(*this->alpha_complete); this->alpha_complete_tmp = new SGPP::base::DataVector(*this->alpha_complete); - this->oldGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); - this->secondGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); + this->oldGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); + this->secondGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); this->InnerGrid = NULL; this->alpha_inner = NULL; this->tOperationMode = OperationMode; this->TimestepSize = TimestepSize; this->TimestepSize_old = TimestepSize; - this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector( - SparseGrid.getStorage()); + this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector(SparseGrid.getStorage()); this->GridConverter = new SGPP::base::DirichletGridConverter(); this->r = r; this->thetas = &thetas; @@ -61,36 +56,49 @@ HestonParabolicPDESolverSystemEuroAmer::HestonParabolicPDESolverSystemEuroAmer( // throw an exception if we're not using Log coordinates and there is more than one asset if (this->nAssets > 1 && !bLogTransform) { - throw SGPP::base::application_exception("HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : Cartesian coordinates are not supported for the basket case."); + throw SGPP::base::application_exception( + "HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : " + "Cartesian coordinates are not supported for the basket case."); } // throw exception if algorithmic dimensions isn't even - if ((this->HestonAlgoDims.size() % 2) != 0 ) { - throw SGPP::base::algorithm_exception("HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : Number of algorithmic dimensions is not even."); + if ((this->HestonAlgoDims.size() % 2) != 0) { + throw SGPP::base::algorithm_exception( + "HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : Number " + "of algorithmic dimensions is not even."); } // throw exception if grid dimensions not equal algorithmic dimensions if (this->HestonAlgoDims.size() != this->BoundGrid->getStorage()->dim()) { - throw SGPP::base::algorithm_exception("HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : Number of algorithmic dimensions is not equal to the number of grid's dimensions."); + throw SGPP::base::algorithm_exception( + "HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : Number " + "of algorithmic dimensions is not equal to the number of grid's dimensions."); } - // Test if 2*dimC = dimG, where dimC is the number of dimensions in the coefficient vectors and dimG is the number of grid dimensions - if (this->BoundGrid->getStorage()->dim() != (2 * this->thetas->getSize()) - || this->BoundGrid->getStorage()->dim() != (2 * this->kappas->getSize()) - || this->BoundGrid->getStorage()->dim() != (2 * this->volvols->getSize())) { - throw SGPP::base::algorithm_exception("HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : Dimension of theta/volvol/kappa parameters != half of grid's dimensions!"); + // Test if 2*dimC = dimG, where dimC is the number of dimensions in the coefficient vectors and + // dimG is the number of grid dimensions + if (this->BoundGrid->getStorage()->dim() != (2 * this->thetas->getSize()) || + this->BoundGrid->getStorage()->dim() != (2 * this->kappas->getSize()) || + this->BoundGrid->getStorage()->dim() != (2 * this->volvols->getSize())) { + throw SGPP::base::algorithm_exception( + "HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : " + "Dimension of theta/volvol/kappa parameters != half of grid's dimensions!"); } // Test if number of dimensions in the coefficients match the numbers of grid dimensions (hmatrix) - if (this->BoundGrid->getStorage()->dim() != this->hMatrix->getNrows() - || this->BoundGrid->getStorage()->dim() != this->hMatrix->getNcols()) { - throw SGPP::base::algorithm_exception("HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : Row or col of hmatrix parameter don't match the grid's dimensions!"); + if (this->BoundGrid->getStorage()->dim() != this->hMatrix->getNrows() || + this->BoundGrid->getStorage()->dim() != this->hMatrix->getNcols()) { + throw SGPP::base::algorithm_exception( + "HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : Row or " + "col of hmatrix parameter don't match the grid's dimensions!"); } // Test if all algorithmic dimensions are inside the grid's dimensions for (size_t i = 0; i < this->HestonAlgoDims.size(); i++) { if (this->HestonAlgoDims[i] >= this->BoundGrid->getStorage()->dim()) { - throw SGPP::base::algorithm_exception("HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : Minimum one algorithmic dimension is not inside the grid's dimensions!"); + throw SGPP::base::algorithm_exception( + "HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : " + "Minimum one algorithmic dimension is not inside the grid's dimensions!"); } } @@ -107,36 +115,33 @@ HestonParabolicPDESolverSystemEuroAmer::HestonParabolicPDESolverSystemEuroAmer( } if (dimCount > 1) { - throw SGPP::base::algorithm_exception("HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : There is minimum one float_td algorithmic dimension!"); + throw SGPP::base::algorithm_exception( + "HestonParabolicPDESolverSystemEuropean::HestonParabolicPDESolverSystemEuropean : There " + "is minimum one float_td algorithmic dimension!"); } } // Build the coefficient collections for the operations - // Some of the coefficient collections are vectors, some are matrices and one is a tensor (for the Up/Down Four Op Dim case) + // Some of the coefficient collections are vectors, some are matrices and one is a tensor (for the + // Up/Down Four Op Dim case) size_t coefficientVectorSize = this->HestonAlgoDims.size(); this->dCoeff = new SGPP::base::DataVector(coefficientVectorSize); this->eCoeff = new SGPP::base::DataVector(coefficientVectorSize); this->fCoeff = new SGPP::base::DataVector(coefficientVectorSize); this->gCoeff = new SGPP::base::DataVector(coefficientVectorSize); this->zCoeff = new SGPP::base::DataVector(coefficientVectorSize); - this->bCoeff = new SGPP::base::DataMatrix(coefficientVectorSize, - coefficientVectorSize); - this->cCoeff = new SGPP::base::DataMatrix(coefficientVectorSize, - coefficientVectorSize); - this->hCoeff = new SGPP::base::DataMatrix(coefficientVectorSize, - coefficientVectorSize); - this->xCoeff = new SGPP::base::DataMatrix(coefficientVectorSize, - coefficientVectorSize); - this->yCoeff = new SGPP::base::DataMatrix(coefficientVectorSize, - coefficientVectorSize); - this->wCoeff = new SGPP::base::DataMatrix(coefficientVectorSize, - coefficientVectorSize); + this->bCoeff = new SGPP::base::DataMatrix(coefficientVectorSize, coefficientVectorSize); + this->cCoeff = new SGPP::base::DataMatrix(coefficientVectorSize, coefficientVectorSize); + this->hCoeff = new SGPP::base::DataMatrix(coefficientVectorSize, coefficientVectorSize); + this->xCoeff = new SGPP::base::DataMatrix(coefficientVectorSize, coefficientVectorSize); + this->yCoeff = new SGPP::base::DataMatrix(coefficientVectorSize, coefficientVectorSize); + this->wCoeff = new SGPP::base::DataMatrix(coefficientVectorSize, coefficientVectorSize); create4dEqualDimSizeArray(coefficientVectorSize, &(this->kCoeff)); // create the inner grid // Here we have to make sure that the alpha_inner doesn't come out with zeros at the other end. - this->GridConverter->buildInnerGridWithCoefs(*this->BoundGrid, - *this->alpha_complete, &this->InnerGrid, &this->alpha_inner); + this->GridConverter->buildInnerGridWithCoefs(*this->BoundGrid, *this->alpha_complete, + &this->InnerGrid, &this->alpha_inner); if (bLogTransform == false) { // Build coefficients @@ -149,34 +154,20 @@ HestonParabolicPDESolverSystemEuroAmer::HestonParabolicPDESolverSystemEuroAmer( buildDCoefficients(); // Create operators - this->OpXBound = SGPP::op_factory::createOperationHestonX(*this->BoundGrid, - *this->xCoeff); - this->OpXInner = SGPP::op_factory::createOperationHestonX(*this->InnerGrid, - *this->xCoeff); - this->OpYBound = SGPP::op_factory::createOperationHestonY(*this->BoundGrid, - *this->yCoeff); - this->OpYInner = SGPP::op_factory::createOperationHestonY(*this->InnerGrid, - *this->yCoeff); - this->OpWBound = SGPP::op_factory::createOperationHestonW(*this->BoundGrid, - *this->wCoeff); - this->OpWInner = SGPP::op_factory::createOperationHestonW(*this->InnerGrid, - *this->wCoeff); - this->OpZBound = SGPP::op_factory::createOperationHestonZ(*this->BoundGrid, - *this->zCoeff); - this->OpZInner = SGPP::op_factory::createOperationHestonZ(*this->InnerGrid, - *this->zCoeff); - this->OpGBound = SGPP::op_factory::createOperationHestonGLog(*this->BoundGrid, - *this->gCoeff); - this->OpGInner = SGPP::op_factory::createOperationHestonGLog(*this->InnerGrid, - *this->gCoeff); - this->OpDBound = SGPP::op_factory::createOperationHestonDLog(*this->BoundGrid, - *this->dCoeff); - this->OpDInner = SGPP::op_factory::createOperationHestonDLog(*this->InnerGrid, - *this->dCoeff); - this->OpFBound = SGPP::op_factory::createOperationHestonFLog(*this->BoundGrid, - *this->fCoeff); - this->OpFInner = SGPP::op_factory::createOperationHestonFLog(*this->InnerGrid, - *this->fCoeff); + this->OpXBound = SGPP::op_factory::createOperationHestonX(*this->BoundGrid, *this->xCoeff); + this->OpXInner = SGPP::op_factory::createOperationHestonX(*this->InnerGrid, *this->xCoeff); + this->OpYBound = SGPP::op_factory::createOperationHestonY(*this->BoundGrid, *this->yCoeff); + this->OpYInner = SGPP::op_factory::createOperationHestonY(*this->InnerGrid, *this->yCoeff); + this->OpWBound = SGPP::op_factory::createOperationHestonW(*this->BoundGrid, *this->wCoeff); + this->OpWInner = SGPP::op_factory::createOperationHestonW(*this->InnerGrid, *this->wCoeff); + this->OpZBound = SGPP::op_factory::createOperationHestonZ(*this->BoundGrid, *this->zCoeff); + this->OpZInner = SGPP::op_factory::createOperationHestonZ(*this->InnerGrid, *this->zCoeff); + this->OpGBound = SGPP::op_factory::createOperationHestonGLog(*this->BoundGrid, *this->gCoeff); + this->OpGInner = SGPP::op_factory::createOperationHestonGLog(*this->InnerGrid, *this->gCoeff); + this->OpDBound = SGPP::op_factory::createOperationHestonDLog(*this->BoundGrid, *this->dCoeff); + this->OpDInner = SGPP::op_factory::createOperationHestonDLog(*this->InnerGrid, *this->dCoeff); + this->OpFBound = SGPP::op_factory::createOperationHestonFLog(*this->BoundGrid, *this->fCoeff); + this->OpFInner = SGPP::op_factory::createOperationHestonFLog(*this->InnerGrid, *this->fCoeff); } else { // Log-transformed case // Build coefficients @@ -190,45 +181,27 @@ HestonParabolicPDESolverSystemEuroAmer::HestonParabolicPDESolverSystemEuroAmer( buildKCoefficientsLogTransform(); // Create operators - this->OpBBound = SGPP::op_factory::createOperationHestonBLog(*this->BoundGrid, - *this->bCoeff); - this->OpBInner = SGPP::op_factory::createOperationHestonBLog(*this->InnerGrid, - *this->bCoeff); - this->OpCBound = SGPP::op_factory::createOperationHestonCLog(*this->BoundGrid, - *this->cCoeff); - this->OpCInner = SGPP::op_factory::createOperationHestonCLog(*this->InnerGrid, - *this->cCoeff); - this->OpDBound = SGPP::op_factory::createOperationHestonDLog(*this->BoundGrid, - *this->dCoeff); - this->OpDInner = SGPP::op_factory::createOperationHestonDLog(*this->InnerGrid, - *this->dCoeff); - this->OpEBound = SGPP::op_factory::createOperationHestonELog(*this->BoundGrid, - *this->eCoeff); - this->OpEInner = SGPP::op_factory::createOperationHestonELog(*this->InnerGrid, - *this->eCoeff); - this->OpFBound = SGPP::op_factory::createOperationHestonFLog(*this->BoundGrid, - *this->fCoeff); - this->OpFInner = SGPP::op_factory::createOperationHestonFLog(*this->InnerGrid, - *this->fCoeff); - this->OpGBound = SGPP::op_factory::createOperationHestonGLog(*this->BoundGrid, - *this->gCoeff); - this->OpGInner = SGPP::op_factory::createOperationHestonGLog(*this->InnerGrid, - *this->gCoeff); - this->OpHBound = SGPP::op_factory::createOperationHestonHLog(*this->BoundGrid, - *this->hCoeff); - this->OpHInner = SGPP::op_factory::createOperationHestonHLog(*this->InnerGrid, - *this->hCoeff); - this->OpKBound = SGPP::op_factory::createOperationHestonKLog(*this->BoundGrid, - &(this->kCoeff)); - this->OpKInner = SGPP::op_factory::createOperationHestonKLog(*this->InnerGrid, - &(this->kCoeff)); + this->OpBBound = SGPP::op_factory::createOperationHestonBLog(*this->BoundGrid, *this->bCoeff); + this->OpBInner = SGPP::op_factory::createOperationHestonBLog(*this->InnerGrid, *this->bCoeff); + this->OpCBound = SGPP::op_factory::createOperationHestonCLog(*this->BoundGrid, *this->cCoeff); + this->OpCInner = SGPP::op_factory::createOperationHestonCLog(*this->InnerGrid, *this->cCoeff); + this->OpDBound = SGPP::op_factory::createOperationHestonDLog(*this->BoundGrid, *this->dCoeff); + this->OpDInner = SGPP::op_factory::createOperationHestonDLog(*this->InnerGrid, *this->dCoeff); + this->OpEBound = SGPP::op_factory::createOperationHestonELog(*this->BoundGrid, *this->eCoeff); + this->OpEInner = SGPP::op_factory::createOperationHestonELog(*this->InnerGrid, *this->eCoeff); + this->OpFBound = SGPP::op_factory::createOperationHestonFLog(*this->BoundGrid, *this->fCoeff); + this->OpFInner = SGPP::op_factory::createOperationHestonFLog(*this->InnerGrid, *this->fCoeff); + this->OpGBound = SGPP::op_factory::createOperationHestonGLog(*this->BoundGrid, *this->gCoeff); + this->OpGInner = SGPP::op_factory::createOperationHestonGLog(*this->InnerGrid, *this->gCoeff); + this->OpHBound = SGPP::op_factory::createOperationHestonHLog(*this->BoundGrid, *this->hCoeff); + this->OpHInner = SGPP::op_factory::createOperationHestonHLog(*this->InnerGrid, *this->hCoeff); + this->OpKBound = SGPP::op_factory::createOperationHestonKLog(*this->BoundGrid, &(this->kCoeff)); + this->OpKInner = SGPP::op_factory::createOperationHestonKLog(*this->InnerGrid, &(this->kCoeff)); } // Create operations that are needed by both the log-transformed and Cartesian case - this->OpAInner = SGPP::op_factory::createOperationLTwoDotProduct( - *this->InnerGrid); - this->OpABound = SGPP::op_factory::createOperationLTwoDotProduct( - *this->BoundGrid); + this->OpAInner = SGPP::op_factory::createOperationLTwoDotProduct(*this->InnerGrid); + this->OpABound = SGPP::op_factory::createOperationLTwoDotProduct(*this->BoundGrid); // right hand side if System this->rhs = NULL; @@ -327,7 +300,7 @@ HestonParabolicPDESolverSystemEuroAmer::~HestonParabolicPDESolverSystemEuroAmer( } void HestonParabolicPDESolverSystemEuroAmer::applyLOperatorComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -335,7 +308,7 @@ void HestonParabolicPDESolverSystemEuroAmer::applyLOperatorComplete( // Apply the riskfree rate if (this->r != 0.0) { this->OpABound->mult(alpha, temp); - result.axpy((-1.0)*this->r, temp); + result.axpy((-1.0) * this->r, temp); } if (this->b_log_transform) { @@ -406,8 +379,8 @@ void HestonParabolicPDESolverSystemEuroAmer::applyLOperatorComplete( } } -void HestonParabolicPDESolverSystemEuroAmer::applyLOperatorInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void HestonParabolicPDESolverSystemEuroAmer::applyLOperatorInner(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -415,7 +388,7 @@ void HestonParabolicPDESolverSystemEuroAmer::applyLOperatorInner( // Apply the riskfree rate if (this->r != 0.0) { this->OpAInner->mult(alpha, temp); - result.axpy((-1.0)*this->r, temp); + result.axpy((-1.0) * this->r, temp); } if (this->b_log_transform) { @@ -486,7 +459,7 @@ void HestonParabolicPDESolverSystemEuroAmer::applyLOperatorInner( } void HestonParabolicPDESolverSystemEuroAmer::applyMassMatrixComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -497,8 +470,8 @@ void HestonParabolicPDESolverSystemEuroAmer::applyMassMatrixComplete( result.add(temp); } -void HestonParabolicPDESolverSystemEuroAmer::applyMassMatrixInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void HestonParabolicPDESolverSystemEuroAmer::applyMassMatrixInner(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -513,8 +486,7 @@ void HestonParabolicPDESolverSystemEuroAmer::finishTimestep() { this->nExecTimesteps++; // Replace the inner coefficients on the boundary grid - this->GridConverter->updateBoundaryCoefs(*this->alpha_complete, - *this->alpha_inner); + this->GridConverter->updateBoundaryCoefs(*this->alpha_complete, *this->alpha_inner); #ifndef NOBOUNDARYDISCOUNT @@ -529,8 +501,7 @@ void HestonParabolicPDESolverSystemEuroAmer::finishTimestep() { #endif } -void HestonParabolicPDESolverSystemEuroAmer::coarsenAndRefine( - bool isLastTimestep) { +void HestonParabolicPDESolverSystemEuroAmer::coarsenAndRefine(bool isLastTimestep) { // add number of Gridpoints this->numSumGridpointsInner += this->InnerGrid->getSize(); this->numSumGridpointsComplete += this->BoundGrid->getSize(); @@ -545,12 +516,10 @@ void HestonParabolicPDESolverSystemEuroAmer::coarsenAndRefine( // Coarsen the grid SGPP::base::GridGenerator* myGenerator = this->BoundGrid->createGridGenerator(); - if (this->adaptSolveMode == "refine" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "refine" || this->adaptSolveMode == "coarsenNrefine") { size_t numRefines = myGenerator->getNumberOfRefinablePoints(); - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(this->alpha_complete, numRefines, - this->refineThreshold); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = new SGPP::base::SurplusRefinementFunctor( + this->alpha_complete, numRefines, this->refineThreshold); if (this->refineMode == "maxLevel") { myGenerator->refineMaxLevel(myRefineFunc, this->refineMaxLevel); @@ -565,14 +534,12 @@ void HestonParabolicPDESolverSystemEuroAmer::coarsenAndRefine( delete myRefineFunc; } - if (this->adaptSolveMode == "coarsen" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "coarsen" || this->adaptSolveMode == "coarsenNrefine") { size_t numCoarsen = myGenerator->getNumberOfRemovablePoints(); - SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = new - SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, - this->coarsenThreshold); - myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, - originalGridSize); + SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = + new SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, + this->coarsenThreshold); + myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, originalGridSize); delete myCoarsenFunctor; } @@ -583,8 +550,8 @@ void HestonParabolicPDESolverSystemEuroAmer::coarsenAndRefine( /////////////////////////////////////////////////// // rebuild the inner grid + coefficients - this->GridConverter->rebuildInnerGridWithCoefs(*this->BoundGrid, - *this->alpha_complete, &this->InnerGrid, &this->alpha_inner); + this->GridConverter->rebuildInnerGridWithCoefs(*this->BoundGrid, *this->alpha_complete, + &this->InnerGrid, &this->alpha_inner); } } @@ -594,7 +561,6 @@ void HestonParabolicPDESolverSystemEuroAmer::startTimestep() { // Adjust the boundaries with the riskfree rate if (this->r != 0.0) { if (this->tOperationMode == "CrNic" || this->tOperationMode == "ImEul") { - SGPP::base::GridStorage* storage = this->BoundGrid->getStorage(); for (size_t i = 0; i < storage->size(); i++) { @@ -605,8 +571,8 @@ void HestonParabolicPDESolverSystemEuroAmer::startTimestep() { // Discount the boundary points if (!curPoint->isInnerPoint()) { - this->alpha_complete->set(i, - this->alpha_complete->get(i)*exp(((-1.0) * (this->r * this->TimestepSize)))); + this->alpha_complete->set( + i, this->alpha_complete->get(i) * exp(((-1.0) * (this->r * this->TimestepSize)))); } } } @@ -633,21 +599,18 @@ void HestonParabolicPDESolverSystemEuroAmer::buildFCoefficients() { this->fCoeff->set(1, kappa * theta - 0.5 * pow(volvol, 2.0)); } - void HestonParabolicPDESolverSystemEuroAmer::buildDCoefficients() { float_t volvol = volvols->get(0); this->dCoeff->setAll(0.0); - this->dCoeff->set(1, (0.5)*pow(volvol, 2.0)); + this->dCoeff->set(1, (0.5) * pow(volvol, 2.0)); } - void HestonParabolicPDESolverSystemEuroAmer::buildXCoefficients() { this->xCoeff->setAll(0.0); this->xCoeff->set(0, 1, 1.0); } - void HestonParabolicPDESolverSystemEuroAmer::buildWCoefficients() { float_t volvol = volvols->get(0); float_t rho = this->hMatrix->get(0, 1); @@ -670,7 +633,7 @@ void HestonParabolicPDESolverSystemEuroAmer::buildBCoefficientsLogTransform() { this->bCoeff->setAll(0.0); for (size_t i = 0; i < this->nAssets; i++) { - this->bCoeff->set(2 * i, 2 * i + 1, 0.5); // Coefficient is a constant of 0.5 + this->bCoeff->set(2 * i, 2 * i + 1, 0.5); // Coefficient is a constant of 0.5 } } @@ -692,7 +655,7 @@ void HestonParabolicPDESolverSystemEuroAmer::buildDCoefficientsLogTransform() { for (size_t i = 0; i < this->nAssets; i++) { // Determine and set the coefficient for this asset float_t volvol = volvols->get(i); - this->dCoeff->set(2 * i + 1, (0.5)*pow(volvol, 2.0)); + this->dCoeff->set(2 * i + 1, (0.5) * pow(volvol, 2.0)); } } @@ -700,8 +663,7 @@ void HestonParabolicPDESolverSystemEuroAmer::buildECoefficientsLogTransform() { this->eCoeff->setAll(0.0); for (size_t i = 0; i < this->nAssets; i++) { - this->eCoeff->set(2 * i, - this->r); // Coefficient is independent of which asset it is. + this->eCoeff->set(2 * i, this->r); // Coefficient is independent of which asset it is. } } @@ -747,18 +709,18 @@ void HestonParabolicPDESolverSystemEuroAmer::buildKCoefficientsLogTransform() { } } -void HestonParabolicPDESolverSystemEuroAmer::create4dEqualDimSizeArray( - size_t dimSize, float_t**** * array) { - (*array) = (float_t****) calloc(dimSize, sizeof(float_t***)); +void HestonParabolicPDESolverSystemEuroAmer::create4dEqualDimSizeArray(size_t dimSize, + float_t***** array) { + (*array) = reinterpret_cast(calloc(dimSize, sizeof(float_t***))); for (size_t i = 0; i < dimSize; i++) { - (*array)[i] = (float_t***) calloc(dimSize, sizeof(float_t**)); + (*array)[i] = reinterpret_cast(calloc(dimSize, sizeof(float_t**))); for (size_t j = 0; j < dimSize; j++) { - (*array)[i][j] = (float_t**) calloc(dimSize, sizeof(float_t*)); + (*array)[i][j] = reinterpret_cast(calloc(dimSize, sizeof(float_t*))); for (size_t k = 0; k < dimSize; k++) { - (*array)[i][j][k] = (float_t*) calloc(dimSize, sizeof(float_t)); + (*array)[i][j][k] = reinterpret_cast(calloc(dimSize, sizeof(float_t))); for (size_t m = 0; m < dimSize; m++) { (*array)[i][j][k][m] = 0.0; @@ -768,25 +730,26 @@ void HestonParabolicPDESolverSystemEuroAmer::create4dEqualDimSizeArray( } } -void HestonParabolicPDESolverSystemEuroAmer::delete4dEqualDimSizeArray( - size_t dimSize, float_t**** * array) { +void HestonParabolicPDESolverSystemEuroAmer::delete4dEqualDimSizeArray(size_t dimSize, + float_t***** array) { for (size_t i = 0; i < dimSize; i++) { for (size_t j = 0; j < dimSize; j++) { for (size_t k = 0; k < dimSize; k++) { - delete[] (*array)[i][j][k]; + delete[](*array)[i][j][k]; } - delete[] (*array)[i][j]; + delete[](*array)[i][j]; } - delete[] (*array)[i]; + delete[](*array)[i]; } - delete[] (*array); + delete[](*array); } -void HestonParabolicPDESolverSystemEuroAmer::setAll4dEqualDimSizeArray( - size_t dimSize, float_t**** * array, float_t value) { +void HestonParabolicPDESolverSystemEuroAmer::setAll4dEqualDimSizeArray(size_t dimSize, + float_t***** array, + float_t value) { for (size_t i = 0; i < dimSize; i++) { for (size_t j = 0; j < dimSize; j++) { for (size_t k = 0; k < dimSize; k++) { @@ -797,6 +760,5 @@ void HestonParabolicPDESolverSystemEuroAmer::setAll4dEqualDimSizeArray( } } } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/algorithm/HestonParabolicPDESolverSystemEuroAmer.hpp b/finance/src/sgpp/finance/algorithm/HestonParabolicPDESolverSystemEuroAmer.hpp index 7e40861af0..6090bdeb38 100644 --- a/finance/src/sgpp/finance/algorithm/HestonParabolicPDESolverSystemEuroAmer.hpp +++ b/finance/src/sgpp/finance/algorithm/HestonParabolicPDESolverSystemEuroAmer.hpp @@ -15,6 +15,8 @@ #include +#include +#include namespace SGPP { namespace finance { @@ -25,10 +27,9 @@ namespace finance { * * Here European or American Options with fix Dirichlet boundaries are solved. */ -class HestonParabolicPDESolverSystemEuroAmer : public - SGPP::pde::OperationParabolicPDESolverSystemDirichlet { +class HestonParabolicPDESolverSystemEuroAmer + : public SGPP::pde::OperationParabolicPDESolverSystemDirichlet { protected: - /// the riskfree interest rate float_t r; @@ -122,37 +123,48 @@ class HestonParabolicPDESolverSystemEuroAmer : public /// Pointer to the rhos SGPP::base::DataMatrix* hMatrix; - /// Coefficient collection for the D operator. Only one custom up/down operator, so it's just a vector of coefficients. + /// Coefficient collection for the D operator. Only one custom up/down operator, so it's just a + /// vector of coefficients. SGPP::base::DataVector* dCoeff; - /// Coefficient collection for the E operator. Only one custom up/down operator, so it's just a vector of coefficients. + /// Coefficient collection for the E operator. Only one custom up/down operator, so it's just a + /// vector of coefficients. SGPP::base::DataVector* eCoeff; - /// Coefficient collection for the F operator. Only one custom up/down operator, so it's just a vector of coefficients. + /// Coefficient collection for the F operator. Only one custom up/down operator, so it's just a + /// vector of coefficients. SGPP::base::DataVector* fCoeff; - /// Coefficient collection for the G operator. Only one custom up/down operator, so it's just a vector of coefficients. + /// Coefficient collection for the G operator. Only one custom up/down operator, so it's just a + /// vector of coefficients. SGPP::base::DataVector* gCoeff; - /// Coefficient collection for the Z operator. Only one custom up/down operator, so it's just a vector of coefficients. + /// Coefficient collection for the Z operator. Only one custom up/down operator, so it's just a + /// vector of coefficients. SGPP::base::DataVector* zCoeff; - /// Coefficient collection for the B operator. Two custom up/down operators, so it's a matrix of coefficients. + /// Coefficient collection for the B operator. Two custom up/down operators, so it's a matrix of + /// coefficients. SGPP::base::DataMatrix* bCoeff; - /// Coefficient collection for the C operator. Two custom up/down operators, so it's a matrix of coefficients. + /// Coefficient collection for the C operator. Two custom up/down operators, so it's a matrix of + /// coefficients. SGPP::base::DataMatrix* cCoeff; - /// Coefficient collection for the H operator. Two custom up/down operators, so it's a matrix of coefficients. + /// Coefficient collection for the H operator. Two custom up/down operators, so it's a matrix of + /// coefficients. SGPP::base::DataMatrix* hCoeff; - /// Coefficient collection for the X operator. Two custom up/down operators, so it's a matrix of coefficients. + /// Coefficient collection for the X operator. Two custom up/down operators, so it's a matrix of + /// coefficients. SGPP::base::DataMatrix* xCoeff; - /// Coefficient collection for the Y operator. Two custom up/down operators, so it's a matrix of coefficients. + /// Coefficient collection for the Y operator. Two custom up/down operators, so it's a matrix of + /// coefficients. SGPP::base::DataMatrix* yCoeff; - /// Coefficient collection for the W operator. Two custom up/down operators, so it's a matrix of coefficients. + /// Coefficient collection for the W operator. Two custom up/down operators, so it's a matrix of + /// coefficients. SGPP::base::DataMatrix* wCoeff; /// Up/down four op dims @@ -197,12 +209,10 @@ class HestonParabolicPDESolverSystemEuroAmer : public /// Store whether log coordinates are used bool b_log_transform; - virtual void applyLOperatorInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyLOperatorInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual void applyLOperatorComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - virtual void applyMassMatrixInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyMassMatrixInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual void applyMassMatrixComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); @@ -251,83 +261,92 @@ class HestonParabolicPDESolverSystemEuroAmer : public /** * Builds the coefficients object for the B operator. * Operator B has two custom 1D operators, so the coefficients object is a matrix. - * The operator has a non-zero coefficient for each pairing of a stock and its variance, e.g. elements (1,2), (3,4), (5,6) etc. (zero-based array elements (0,1), (2,3), (4,5) etc.) + * The operator has a non-zero coefficient for each pairing of a stock and its variance, e.g. + * elements (1,2), (3,4), (5,6) etc. (zero-based array elements (0,1), (2,3), (4,5) etc.) */ void buildBCoefficientsLogTransform(); - /** * Builds the coefficients object for the C operator. * Operator C has two custom 1D operators, so the coefficients object is a matrix. - * The operator has a non-zero coefficient for each pairing of a stock and its variance, e.g. elements (1,2), (3,4), (5,6) etc. (zero-based array elements (0,1), (2,3), (4,5) etc.) + * The operator has a non-zero coefficient for each pairing of a stock and its variance, e.g. + * elements (1,2), (3,4), (5,6) etc. (zero-based array elements (0,1), (2,3), (4,5) etc.) */ void buildCCoefficientsLogTransform(); /** * Builds the coefficients object for the D operator. * The D operator is oneOpDim, so there is only a vector of coefficients to set. - * Only the variance dimensions are active in this operator, i.e. elements 2, 4, 6, 8 etc. (zero-based array elements 1, 3, 5, 7 etc.) + * Only the variance dimensions are active in this operator, i.e. elements 2, 4, 6, 8 etc. + * (zero-based array elements 1, 3, 5, 7 etc.) */ void buildDCoefficientsLogTransform(); /** * Builds the coefficients object for the E operator. * The E operator is oneOpDim, so there is only a vector of coefficients to set. - * Only the stock-price dimensions are active in this operator, i.e. elements 1, 3, 5, 7 etc. (zero-based array elements 0, 2, 4, 6 etc.) + * Only the stock-price dimensions are active in this operator, i.e. elements 1, 3, 5, 7 etc. + * (zero-based array elements 0, 2, 4, 6 etc.) */ void buildECoefficientsLogTransform(); /** * Builds the coefficients object for the F operator. * The F operator is oneOpDim, so there is only a vector of coefficients to set. - * Only the variance elements are active in this operator, i.e. elements 2, 4, 6, 8 etc. (zero-based array elements 1, 3, 5, 7 etc.) + * Only the variance elements are active in this operator, i.e. elements 2, 4, 6, 8 etc. + * (zero-based array elements 1, 3, 5, 7 etc.) */ void buildFCoefficientsLogTransform(); /** * Builds the coefficients object for the G operator. * The G operator is oneOpDim, so there is only a vector of coefficients to set. - * Only the variance elements are active in this operator, i.e. elements 2, 4, 6, 8 etc. (zero-based vector elements 1, 3, 5, 7 etc.) + * Only the variance elements are active in this operator, i.e. elements 2, 4, 6, 8 etc. + * (zero-based vector elements 1, 3, 5, 7 etc.) */ void buildGCoefficientsLogTransform(); /** * Builds the coefficients object for the H operator. * Operator H has two custom 1D operators, so the coefficients object is a matrix. - * The operator has a non-zero coefficient for each pairing of a stock and its variance, e.g. elements (1,2), (3,4), (5,6) etc. (zero-based array elements (0,1), (2,3), (4,5) etc.) + * The operator has a non-zero coefficient for each pairing of a stock and its variance, e.g. + * elements (1,2), (3,4), (5,6) etc. (zero-based array elements (0,1), (2,3), (4,5) etc.) */ void buildHCoefficientsLogTransform(); /** * Builds the coefficients object for the K operator. - * This operator is more exciting. It has four custom 1D operators, so the coefficients object is a 4d array. - * The operator has a non-zero coefficient for each quad-pairing of a stock and its variance, and a DIFFERENT stock and its variance, e.g. for three assets: (1,2,3,4), (1,2,5,6), (3,4,5,6). (zero-based array elements (0,1,2,3), (0,1,4,5), (2,3,4,5)) + * This operator is more exciting. It has four custom 1D operators, so the coefficients object is + * a 4d array. + * The operator has a non-zero coefficient for each quad-pairing of a stock and its variance, and + * a DIFFERENT stock and its variance, e.g. for three assets: (1,2,3,4), (1,2,5,6), (3,4,5,6). + * (zero-based array elements (0,1,2,3), (0,1,4,5), (2,3,4,5)) */ void buildKCoefficientsLogTransform(); /** - * Utility method for creating a 4d array of equal size in each dimension. The array is allocated dynamically based on the provided size. + * Utility method for creating a 4d array of equal size in each dimension. The array is allocated + * dynamically based on the provided size. * @param dimSize The number of elements in each dimension of the array. * @param array Pointer to the first element of the 4d array. */ - void create4dEqualDimSizeArray(size_t dimSize, float_t**** * array); - + void create4dEqualDimSizeArray(size_t dimSize, float_t***** array); /** * Utility method to free the memory allocated to a 4d array of equal size in each dimension. * @param dimSize The number of elements in each dimension of the array. * @param array Pointer to the first element of the 4d array. */ - void delete4dEqualDimSizeArray(size_t dimSize, float_t**** * array); + void delete4dEqualDimSizeArray(size_t dimSize, float_t***** array); /** - * Utility method to set all values in a 4d array of equal size to one value (e.g. this method can be used to set all the values to zero). + * Utility method to set all values in a 4d array of equal size to one value (e.g. this method can + * be used to set all the values to zero). * @param dimSize The number of elements in each dimension of the array. * @param array Pointer to the first element of the 4d array. * @param value Value that each of the array elements will be set to. */ - void setAll4dEqualDimSizeArray(size_t dimSize, float_t**** * array, - float_t value); + void setAll4dEqualDimSizeArray(size_t dimSize, float_t***** array, float_t value); public: /** @@ -338,13 +357,16 @@ class HestonParabolicPDESolverSystemEuroAmer : public * @param thetas collection of theta values, one for each asset * @param volvols collection of the volatility of the volatility values, one for each asset * @param kappas collection of the kappa values, one for each asset - * @param rho collection of the correlation values between the Wiener processes. The matrix size must be twice the number of assets to encompass the correlation between the stock price and variance processes. + * @param rho collection of the correlation values between the Wiener processes. The matrix size + * must be twice the number of assets to encompass the correlation between the stock price and + * variance processes. * @param r market risk-free interest rate * @param TimestepSize size of the timestep used in the ODE solver * @param OperationMode the solver used for solving the ODE, e.g. "CrNic" * @param dStrike strike price of the option * @param option_type option flavour specifier, e.g. "std_euro_call" - * @param bLogTransform true if log-transformed stock-price coordinates are used, false otherwise. The variance coordinates are always linear. + * @param bLogTransform true if log-transformed stock-price coordinates are used, false otherwise. + * The variance coordinates are always linear. * @param useCoarsen true if coarsening should be used * @param coarsenThreshold threshold value from which coarsening is applied * @param adaptSolveMode specifies the type of adaptivity used @@ -353,18 +375,14 @@ class HestonParabolicPDESolverSystemEuroAmer : public * @param refineMode mode of refinement * @param refineMaxLevel maximum sparse grid level above which no refinement is performed */ - HestonParabolicPDESolverSystemEuroAmer(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& alpha, SGPP::base::DataVector& thetas, - SGPP::base::DataVector& volvols, - SGPP::base::DataVector& kappas, - SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, - std::string OperationMode, - float_t dStrike, std::string option_type, - bool bLogTransform = false, bool useCoarsen = false, - float_t coarsenThreshold = 0.0, std::string adaptSolveMode = "none", - int numCoarsenPoints = -1, float_t refineThreshold = 0.0, - std::string refineMode = "classic", - SGPP::base::GridIndex::level_type refineMaxLevel = 0); + HestonParabolicPDESolverSystemEuroAmer( + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& thetas, + SGPP::base::DataVector& volvols, SGPP::base::DataVector& kappas, SGPP::base::DataMatrix& rho, + float_t r, float_t TimestepSize, std::string OperationMode, float_t dStrike, + std::string option_type, bool bLogTransform = false, bool useCoarsen = false, + float_t coarsenThreshold = 0.0, std::string adaptSolveMode = "none", + int numCoarsenPoints = -1, float_t refineThreshold = 0.0, std::string refineMode = "classic", + SGPP::base::GridIndex::level_type refineMaxLevel = 0); /** * Destructor. Just does the usual...releases all allocated memory. @@ -375,15 +393,14 @@ class HestonParabolicPDESolverSystemEuroAmer : public /** * Coarsens and refines the sparse grid based on the relevant thresholds. - * @param isLastTimestep true if the current timestep is the last. If this is true, integrated coarsening is not performed. + * @param isLastTimestep true if the current timestep is the last. If this is true, integrated + * coarsening is not performed. */ virtual void coarsenAndRefine(bool isLastTimestep = false); void startTimestep(); }; +} // namespace finance +} // namespace SGPP -} - -} - -#endif /* HESTONPARABOLICPDESOLVERSYSTEMEUROAMER_HPP */ \ No newline at end of file +#endif /* HESTONPARABOLICPDESOLVERSYSTEMEUROAMER_HPP */ diff --git a/finance/src/sgpp/finance/algorithm/HullWhiteParabolicPDESolverSystem.cpp b/finance/src/sgpp/finance/algorithm/HullWhiteParabolicPDESolverSystem.cpp index 028078f23c..6066d1e3e5 100644 --- a/finance/src/sgpp/finance/algorithm/HullWhiteParabolicPDESolverSystem.cpp +++ b/finance/src/sgpp/finance/algorithm/HullWhiteParabolicPDESolverSystem.cpp @@ -11,40 +11,33 @@ #include #include -#include - #include +#include +#include namespace SGPP { namespace finance { HullWhiteParabolicPDESolverSystem::HullWhiteParabolicPDESolverSystem( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, float_t sigma, - float_t theta, float_t a, float_t TimestepSize, std::string OperationMode, - bool useCoarsen, float_t coarsenThreshold, std::string adaptSolveMode, - int numCoarsenPoints, float_t refineThreshold, std::string refineMode, - SGPP::base::GridIndex::level_type refineMaxLevel, - int dim_HW) { + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, float_t sigma, float_t theta, + float_t a, float_t TimestepSize, std::string OperationMode, bool useCoarsen, + float_t coarsenThreshold, std::string adaptSolveMode, int numCoarsenPoints, + float_t refineThreshold, std::string refineMode, + SGPP::base::GridIndex::level_type refineMaxLevel, int dim_HW) { this->BoundGrid = &SparseGrid; this->alpha_complete = α - this->alpha_complete_old = new SGPP::base::DataVector( - this->alpha_complete->getSize()); - this->alpha_complete_tmp = new SGPP::base::DataVector( - this->alpha_complete->getSize()); - this->oldGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); - this->secondGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); + this->alpha_complete_old = new SGPP::base::DataVector(this->alpha_complete->getSize()); + this->alpha_complete_tmp = new SGPP::base::DataVector(this->alpha_complete->getSize()); + this->oldGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); + this->secondGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); this->tOperationMode = OperationMode; this->TimestepSize = TimestepSize; this->TimestepSize_old = TimestepSize; - this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector( - SparseGrid.getStorage()); - this->variableDiscountFactor = new VariableDiscountFactor( - SparseGrid.getStorage(), dim_HW); + this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector(SparseGrid.getStorage()); + this->variableDiscountFactor = new VariableDiscountFactor(SparseGrid.getStorage(), dim_HW); this->a = a; this->theta = theta; this->sigma = sigma; @@ -57,8 +50,7 @@ HullWhiteParabolicPDESolverSystem::HullWhiteParabolicPDESolverSystem( this->OpFBound = SGPP::op_factory::createOperationLF(*this->BoundGrid); // Create operations, independent bLogTransform - this->OpLTwoBound = SGPP::op_factory::createOperationLTwoDotProduct( - *this->BoundGrid); + this->OpLTwoBound = SGPP::op_factory::createOperationLTwoDotProduct(*this->BoundGrid); // right hand side if System this->rhs = NULL; @@ -97,8 +89,8 @@ HullWhiteParabolicPDESolverSystem::~HullWhiteParabolicPDESolverSystem() { delete this->secondGridStorage; } -void HullWhiteParabolicPDESolverSystem::applyLOperator(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result) { +void HullWhiteParabolicPDESolverSystem::applyLOperator(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -110,21 +102,20 @@ void HullWhiteParabolicPDESolverSystem::applyLOperator(SGPP::base::DataVector& if (this->sigma != 0.0) { this->OpEBound->mult(alpha, temp); - result.axpy((-1.0 / 2.0)*pow((this->sigma), 2.0), temp); + result.axpy((-1.0 / 2.0) * pow((this->sigma), 2.0), temp); } if (this->a != 0.0) { this->OpFBound->mult(alpha, temp); - result.axpy((-1.0)*this->a, temp); + result.axpy((-1.0) * this->a, temp); } - this->OpDBound->mult(alpha, temp); result.sub(temp); } -void HullWhiteParabolicPDESolverSystem::applyMassMatrix( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void HullWhiteParabolicPDESolverSystem::applyMassMatrix(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -147,12 +138,11 @@ void HullWhiteParabolicPDESolverSystem::finishTimestep() { // add number of Gridpoints this->numSumGridpointsInner += 0; this->numSumGridpointsComplete += this->BoundGrid->getSize(); - } void HullWhiteParabolicPDESolverSystem::coarsenAndRefine(bool isLastTimestep) { if (this->useCoarsen == - true) { // && isLastTimestep == false) // do it always as mostly only 1 timestep is executed + true) { // && isLastTimestep == false) // do it always as mostly only 1 timestep is executed /////////////////////////////////////////////////// // Start integrated refinement & coarsening /////////////////////////////////////////////////// @@ -162,15 +152,13 @@ void HullWhiteParabolicPDESolverSystem::coarsenAndRefine(bool isLastTimestep) { // Coarsen the grid SGPP::base::GridGenerator* myGenerator = this->BoundGrid->createGridGenerator(); - //std::cout << "Coarsen Threshold: " << this->coarsenThreshold << std::endl; - //std::cout << "Grid Size: " << originalGridSize << std::endl; + // std::cout << "Coarsen Threshold: " << this->coarsenThreshold << std::endl; + // std::cout << "Grid Size: " << originalGridSize << std::endl; - if (this->adaptSolveMode == "refine" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "refine" || this->adaptSolveMode == "coarsenNrefine") { size_t numRefines = myGenerator->getNumberOfRefinablePoints(); - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(this->alpha_complete, numRefines, - this->refineThreshold); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = new SGPP::base::SurplusRefinementFunctor( + this->alpha_complete, numRefines, this->refineThreshold); if (this->refineMode == "maxLevel") { myGenerator->refineMaxLevel(myRefineFunc, this->refineMaxLevel); @@ -185,14 +173,12 @@ void HullWhiteParabolicPDESolverSystem::coarsenAndRefine(bool isLastTimestep) { delete myRefineFunc; } - if (this->adaptSolveMode == "coarsen" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "coarsen" || this->adaptSolveMode == "coarsenNrefine") { size_t numCoarsen = myGenerator->getNumberOfRemovablePoints(); - SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = new - SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, - this->coarsenThreshold); - myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, - originalGridSize); + SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = + new SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, + this->coarsenThreshold); + myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, originalGridSize); delete myCoarsenFunctor; } @@ -212,8 +198,6 @@ void HullWhiteParabolicPDESolverSystem::startTimestep() { if (this->tOperationMode == "CrNic" || this->tOperationMode == "ImEul") { this->BoundaryUpdate->multiplyBoundaryVector(*this->alpha_complete, factor); } - -} - } -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/algorithm/HullWhiteParabolicPDESolverSystem.hpp b/finance/src/sgpp/finance/algorithm/HullWhiteParabolicPDESolverSystem.hpp index ee5abb0156..ace0e83921 100644 --- a/finance/src/sgpp/finance/algorithm/HullWhiteParabolicPDESolverSystem.hpp +++ b/finance/src/sgpp/finance/algorithm/HullWhiteParabolicPDESolverSystem.hpp @@ -15,6 +15,8 @@ #include +#include +#include namespace SGPP { namespace finance { @@ -23,8 +25,8 @@ namespace finance { * This class implements the ParabolicPDESolverSystem for the HullWhite * Equation. */ -class HullWhiteParabolicPDESolverSystem : public - SGPP::pde::OperationParabolicPDESolverSystemFreeBoundaries { +class HullWhiteParabolicPDESolverSystem + : public SGPP::pde::OperationParabolicPDESolverSystemFreeBoundaries { protected: /// theta float_t theta; @@ -66,11 +68,9 @@ class HullWhiteParabolicPDESolverSystem : public /// access to the variable discount factor VariableDiscountFactor* variableDiscountFactor; - virtual void applyLOperator(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyLOperator(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - virtual void applyMassMatrix(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyMassMatrix(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); public: /** @@ -82,7 +82,8 @@ class HullWhiteParabolicPDESolverSystem : public * @param sigma reference to the sigma * @param a reference to the a * @param TimestepSize the size of one timestep used in the ODE Solver - * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for explicit Euler, + * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for + * explicit Euler, * ImEul for implicit Euler, CrNic for Crank Nicolson solver * @param useCoarsen specifies if the grid should be coarsened between timesteps * @param coarsenThreshold Threshold to decide, if a grid point should be deleted @@ -93,14 +94,12 @@ class HullWhiteParabolicPDESolverSystem : public * @param refineMaxLevel max. refinement level * @param dim_HW dimension of Hull-White (dimension of risk-free rate) */ - HullWhiteParabolicPDESolverSystem(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& alpha, float_t sigma, float_t theta, - float_t a, float_t TimestepSize, std::string OperationMode = "ExEul", - bool useCoarsen = false, float_t coarsenThreshold = 0.0, - std::string adaptSolveMode = "none", - int numCoarsenPoints = -1, float_t refineThreshold = 0.0, - std::string refineMode = "classic", - SGPP::base::GridIndex::level_type refineMaxLevel = 0, int dim_HW = 1); + HullWhiteParabolicPDESolverSystem( + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, float_t sigma, float_t theta, + float_t a, float_t TimestepSize, std::string OperationMode = "ExEul", bool useCoarsen = false, + float_t coarsenThreshold = 0.0, std::string adaptSolveMode = "none", + int numCoarsenPoints = -1, float_t refineThreshold = 0.0, std::string refineMode = "classic", + SGPP::base::GridIndex::level_type refineMaxLevel = 0, int dim_HW = 1); /** * Std-Destructor @@ -117,12 +116,10 @@ class HullWhiteParabolicPDESolverSystem : public void startTimestep(); private: - /// the dimension of the risk-free rate (Hull-White dimension) int dim_r; }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* HULLWHITEPARABOLICPDESOLVERSYSTEM_HPP */ \ No newline at end of file +#endif /* HULLWHITEPARABOLICPDESOLVERSYSTEM_HPP */ diff --git a/finance/src/sgpp/finance/algorithm/ModifiedBlackScholesParabolicPDESolverSystem.cpp b/finance/src/sgpp/finance/algorithm/ModifiedBlackScholesParabolicPDESolverSystem.cpp index f5102dc109..23242ed929 100644 --- a/finance/src/sgpp/finance/algorithm/ModifiedBlackScholesParabolicPDESolverSystem.cpp +++ b/finance/src/sgpp/finance/algorithm/ModifiedBlackScholesParabolicPDESolverSystem.cpp @@ -11,55 +11,37 @@ #include #include -#include - #include +#include +#include namespace SGPP { namespace finance { ModifiedBlackScholesParabolicPDESolverSystem::ModifiedBlackScholesParabolicPDESolverSystem( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, - SGPP::base::DataVector& mu, - SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, - float_t TimestepSize, std::string OperationMode, - bool bLogTransform, bool useCoarsen, float_t coarsenThreshold, - std::string adaptSolveMode, - int numCoarsenPoints, float_t refineThreshold, std::string refineMode, - SGPP::base::GridIndex::level_type refineMaxLevel, int dim_HW) - : BlackScholesParabolicPDESolverSystem(SparseGrid, - alpha, - mu, - sigma, - rho, - r, - TimestepSize, - OperationMode, - 0.0, - "nothing", - bLogTransform, - useCoarsen, - coarsenThreshold, - adaptSolveMode, - numCoarsenPoints, - refineThreshold, - refineMode, - refineMaxLevel) { + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& mu, + SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, + std::string OperationMode, bool bLogTransform, bool useCoarsen, float_t coarsenThreshold, + std::string adaptSolveMode, int numCoarsenPoints, float_t refineThreshold, + std::string refineMode, SGPP::base::GridIndex::level_type refineMaxLevel, int dim_HW) + : BlackScholesParabolicPDESolverSystem(SparseGrid, alpha, mu, sigma, rho, r, TimestepSize, + OperationMode, 0.0, "nothing", bLogTransform, useCoarsen, + coarsenThreshold, adaptSolveMode, numCoarsenPoints, + refineThreshold, refineMode, refineMaxLevel) { this->OpFBound = SGPP::op_factory::createOperationLF(*this->BoundGrid); this->dim_r = dim_HW; - this->variableDiscountFactor = new VariableDiscountFactor( - SparseGrid.getStorage(), dim_HW); + this->variableDiscountFactor = new VariableDiscountFactor(SparseGrid.getStorage(), dim_HW); } void ModifiedBlackScholesParabolicPDESolverSystem::multiplyrBSHW( - SGPP::base::DataVector& updateVector) { + SGPP::base::DataVector& updateVector) { float_t tmp; for (size_t i = 0; i < this->BoundGrid->getStorage()->size(); i++) { - //std::string coords = (*storage)[i]->getCoordsStringBB(*this->myBoundingBox); + // std::string coords = (*storage)[i]->getCoordsStringBB(*this->myBoundingBox); std::string coords = this->BoundGrid->getStorage()->get(i)->getCoordsStringBB( - *this->BoundGrid->getBoundingBox()); + *this->BoundGrid->getBoundingBox()); std::stringstream coordsStream(coords); float_t dblFuncValues[2]; @@ -69,8 +51,8 @@ void ModifiedBlackScholesParabolicPDESolverSystem::multiplyrBSHW( } // std::cout<< dblFuncValues[1]<< std::endl; - //updateVector.set(i, updateVector.get(i)* dblFuncValues[1]); - updateVector.set(i, updateVector.get(i)* dblFuncValues[this->dim_r]); + // updateVector.set(i, updateVector.get(i)* dblFuncValues[1]); + updateVector.set(i, updateVector.get(i) * dblFuncValues[this->dim_r]); } } @@ -79,8 +61,8 @@ ModifiedBlackScholesParabolicPDESolverSystem::~ModifiedBlackScholesParabolicPDES delete this->variableDiscountFactor; } -void ModifiedBlackScholesParabolicPDESolverSystem::applyLOperator( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void ModifiedBlackScholesParabolicPDESolverSystem::applyLOperator(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { SGPP::base::DataVector temp(alpha.getSize()); result.setAll(0.0); @@ -88,7 +70,7 @@ void ModifiedBlackScholesParabolicPDESolverSystem::applyLOperator( // Apply the riskfree rate if (this->r != 0.0) { this->OpLTwoBound->mult(alpha, temp); - result.axpy((-1.0)*this->r, temp); + result.axpy((-1.0) * this->r, temp); } // Apply the delta method @@ -118,10 +100,9 @@ void ModifiedBlackScholesParabolicPDESolverSystem::finishTimestep() { this->numSumGridpointsComplete += this->BoundGrid->getSize(); } -void ModifiedBlackScholesParabolicPDESolverSystem::coarsenAndRefine( - bool isLastTimestep) { - if (this->useCoarsen == - true) { // && isLastTimestep == false) // do it always as mostly only 1 timestep is executed +void ModifiedBlackScholesParabolicPDESolverSystem::coarsenAndRefine(bool isLastTimestep) { + if (this->useCoarsen == true) { // && isLastTimestep == false) // do it always as mostly only 1 + // timestep is executed /////////////////////////////////////////////////// // Start integrated refinement & coarsening /////////////////////////////////////////////////// @@ -131,15 +112,13 @@ void ModifiedBlackScholesParabolicPDESolverSystem::coarsenAndRefine( // Coarsen the grid SGPP::base::GridGenerator* myGenerator = this->BoundGrid->createGridGenerator(); - //std::cout << "Coarsen Threshold: " << this->coarsenThreshold << std::endl; - //std::cout << "Grid Size: " << originalGridSize << std::endl; + // std::cout << "Coarsen Threshold: " << this->coarsenThreshold << std::endl; + // std::cout << "Grid Size: " << originalGridSize << std::endl; - if (this->adaptSolveMode == "refine" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "refine" || this->adaptSolveMode == "coarsenNrefine") { size_t numRefines = myGenerator->getNumberOfRefinablePoints(); - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(this->alpha_complete, numRefines, - this->refineThreshold); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = new SGPP::base::SurplusRefinementFunctor( + this->alpha_complete, numRefines, this->refineThreshold); if (this->refineMode == "maxLevel") { myGenerator->refineMaxLevel(myRefineFunc, this->refineMaxLevel); @@ -154,14 +133,12 @@ void ModifiedBlackScholesParabolicPDESolverSystem::coarsenAndRefine( delete myRefineFunc; } - if (this->adaptSolveMode == "coarsen" - || this->adaptSolveMode == "coarsenNrefine") { + if (this->adaptSolveMode == "coarsen" || this->adaptSolveMode == "coarsenNrefine") { size_t numCoarsen = myGenerator->getNumberOfRemovablePoints(); - SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = new - SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, - this->coarsenThreshold); - myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, - originalGridSize); + SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = + new SGPP::base::SurplusCoarseningFunctor(this->alpha_complete, numCoarsen, + this->coarsenThreshold); + myGenerator->coarsenNFirstOnly(myCoarsenFunctor, this->alpha_complete, originalGridSize); delete myCoarsenFunctor; } @@ -182,7 +159,6 @@ void ModifiedBlackScholesParabolicPDESolverSystem::startTimestep() { if (this->tOperationMode == "CrNic" || this->tOperationMode == "ImEul") { this->BoundaryUpdate->multiplyBoundaryVector(*this->alpha_complete, factor); } - -} } -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/algorithm/ModifiedBlackScholesParabolicPDESolverSystem.hpp b/finance/src/sgpp/finance/algorithm/ModifiedBlackScholesParabolicPDESolverSystem.hpp index fc54d81629..009309631e 100644 --- a/finance/src/sgpp/finance/algorithm/ModifiedBlackScholesParabolicPDESolverSystem.hpp +++ b/finance/src/sgpp/finance/algorithm/ModifiedBlackScholesParabolicPDESolverSystem.hpp @@ -14,6 +14,7 @@ #include +#include namespace SGPP { namespace finance { @@ -21,14 +22,11 @@ namespace finance { * This class implements the Modified ParabolicPDESolverSystem for the BlackScholes * Equation just use for combination of BlackScholes and HullWhite. */ -class ModifiedBlackScholesParabolicPDESolverSystem : public - BlackScholesParabolicPDESolverSystem { +class ModifiedBlackScholesParabolicPDESolverSystem : public BlackScholesParabolicPDESolverSystem { protected: - SGPP::base::OperationMatrix* OpFBound; - virtual void applyLOperator(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void applyLOperator(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); public: /** @@ -41,27 +39,27 @@ class ModifiedBlackScholesParabolicPDESolverSystem : public * @param rho reference to the rhos * @param r the riskfree interest rate * @param TimestepSize the size of one timestep used in the ODE Solver - * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for explicit Euler, + * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for + * explicit Euler, * ImEul for implicit Euler, CrNic for Crank Nicolson solver - * @param bLogTransform indicates that this system belongs to a log-transformed Black Scholes Equation + * @param bLogTransform indicates that this system belongs to a log-transformed Black Scholes + * Equation * @param useCoarsen specifies if the grid should be coarsened between timesteps * @param coarsenThreshold Threshold to decide, if a grid point should be deleted * @param adaptSolveMode adaptive mode during solving: coarsen, refine, coarsenNrefine - * @param numCoarsenPoints number of point that should be coarsened in one coarsening step !CURRENTLY UNUSED PARAMETER! + * @param numCoarsenPoints number of point that should be coarsened in one coarsening step + * !CURRENTLY UNUSED PARAMETER! * @param refineThreshold Threshold to decide, if a grid point should be refined * @param refineMode refineMode during solving Black Scholes Equation: classic or maxLevel * @param refineMaxLevel max. level of refinement during solving * @param dim_HW of Hull-White (= where r value is taken) */ - ModifiedBlackScholesParabolicPDESolverSystem(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& alpha, SGPP::base::DataVector& mu, - SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, - float_t TimestepSize, std::string OperationMode, - bool bLogTransform, bool useCoarsen, float_t coarsenThreshold, - std::string adaptSolveMode, - int numCoarsenPoints, float_t refineThreshold, std::string refineMode, - SGPP::base::GridIndex::level_type refineMaxLevel, - int dim_HW); + ModifiedBlackScholesParabolicPDESolverSystem( + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, SGPP::base::DataVector& mu, + SGPP::base::DataVector& sigma, SGPP::base::DataMatrix& rho, float_t r, float_t TimestepSize, + std::string OperationMode, bool bLogTransform, bool useCoarsen, float_t coarsenThreshold, + std::string adaptSolveMode, int numCoarsenPoints, float_t refineThreshold, + std::string refineMode, SGPP::base::GridIndex::level_type refineMaxLevel, int dim_HW); /** * Multiplies the corresponding r coordinates with the whole grid value @@ -82,15 +80,13 @@ class ModifiedBlackScholesParabolicPDESolverSystem : public virtual void startTimestep(); protected: - /// the dimension of the risk-free rate (Hull-White dimension) int dim_r; /// access to the variable discount factor VariableDiscountFactor* variableDiscountFactor; }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* MODIFIEDBLACKSCHOLESParabolicPDESolverSystem_HPP */ \ No newline at end of file +#endif /* MODIFIEDBLACKSCHOLESParabolicPDESolverSystem_HPP */ diff --git a/finance/src/sgpp/finance/application/BlackScholesHullWhiteSolver.cpp b/finance/src/sgpp/finance/application/BlackScholesHullWhiteSolver.cpp index 2a44a4758c..b6b85bf786 100644 --- a/finance/src/sgpp/finance/application/BlackScholesHullWhiteSolver.cpp +++ b/finance/src/sgpp/finance/application/BlackScholesHullWhiteSolver.cpp @@ -14,23 +14,23 @@ #include #include #include + +#include + #include #include #include #include #include -using namespace SGPP::pde; -using namespace SGPP::solver; -using namespace SGPP::base; - -#include - +#include +#include +#include namespace SGPP { namespace finance { -BlackScholesHullWhiteSolver::BlackScholesHullWhiteSolver( - bool useLogTransform) : ParabolicPDESolver() { +BlackScholesHullWhiteSolver::BlackScholesHullWhiteSolver(bool useLogTransform) + : ParabolicPDESolver() { this->bStochasticDataAlloc = false; this->bGridConstructed = false; this->myScreen = NULL; @@ -75,34 +75,32 @@ BlackScholesHullWhiteSolver::~BlackScholesHullWhiteSolver() { } } -void BlackScholesHullWhiteSolver::constructGrid(BoundingBox& BoundingBox, - int level) { +void BlackScholesHullWhiteSolver::constructGrid(base::BoundingBox& BoundingBox, int level) { this->dim = BoundingBox.getDimensions(); this->levels = level; - this->myGrid = new LinearBoundaryGrid(BoundingBox); + this->myGrid = new base::LinearBoundaryGrid(BoundingBox); - GridGenerator* myGenerator = this->myGrid->createGridGenerator(); + base::GridGenerator* myGenerator = this->myGrid->createGridGenerator(); myGenerator->regular(this->levels); delete myGenerator; this->myBoundingBox = this->myGrid->getBoundingBox(); this->myGridStorage = this->myGrid->getStorage(); - //std::string serGrid; - //myGrid->serialize(serGrid); - //std::cout << serGrid << std::endl; + // std::string serGrid; + // myGrid->serialize(serGrid); + // std::cout << serGrid << std::endl; this->bGridConstructed = true; } - -void BlackScholesHullWhiteSolver::setStochasticData(DataVector& mus, - DataVector& sigmas, DataMatrix& rhos, float_t r, float_t theta, float_t sigma, - float_t a) { - this->mus = new DataVector(mus); - this->sigmas = new DataVector(sigmas); - this->rhos = new DataMatrix(rhos); +void BlackScholesHullWhiteSolver::setStochasticData(base::DataVector& mus, base::DataVector& sigmas, + base::DataMatrix& rhos, float_t r, + float_t theta, float_t sigma, float_t a) { + this->mus = new base::DataVector(mus); + this->sigmas = new base::DataVector(sigmas); + this->rhos = new base::DataMatrix(rhos); this->r = r; this->theta = theta; this->sigma = sigma; @@ -111,46 +109,46 @@ void BlackScholesHullWhiteSolver::setStochasticData(DataVector& mus, bStochasticDataAlloc = true; } - void BlackScholesHullWhiteSolver::setProcessDimensions(int dim_BS, int dim_HW) { this->dim_BS = dim_BS; this->dim_HW = dim_HW; } -void BlackScholesHullWhiteSolver::solveExplicitEuler(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose, bool generateAnimation, - size_t numEvalsAnimation) { - throw new application_exception("BlackScholesHullWhiteSolver::solveExplicitEuler : explicit Euler is not supported for BlackScholesHullWhiteSolver!"); +void BlackScholesHullWhiteSolver::solveExplicitEuler(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose, + bool generateAnimation, + size_t numEvalsAnimation) { + throw new base::application_exception( + "BlackScholesHullWhiteSolver::solveExplicitEuler : explicit Euler is not supported for " + "BlackScholesHullWhiteSolver!"); } -void BlackScholesHullWhiteSolver::solveImplicitEuler(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose, bool generateAnimation, - size_t numEvalsAnimation) { +void BlackScholesHullWhiteSolver::solveImplicitEuler(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose, + bool generateAnimation, + size_t numEvalsAnimation) { if (this->bGridConstructed && this->bStochasticDataAlloc) { - Euler* myEuler = new Euler("ImEul", numTimesteps, timestepsize, - generateAnimation, numEvalsAnimation, myScreen); - BiCGStab* myCG = new BiCGStab(maxCGIterations, epsilonCG); + solver::Euler* myEuler = new solver::Euler("ImEul", numTimesteps, timestepsize, + generateAnimation, numEvalsAnimation, myScreen); + solver::BiCGStab* myCG = new solver::BiCGStab(maxCGIterations, epsilonCG); - SGppStopwatch* myStopwatch = new SGppStopwatch(); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); this->staInnerGridSize = getNumberInnerGridPoints(); - std::cout << "Using Implicit Euler to solve " << numTimesteps << " timesteps:" - << std::endl; + std::cout << "Using Implicit Euler to solve " << numTimesteps << " timesteps:" << std::endl; myStopwatch->start(); - //DimensionBoundary* myBoundaries = new DimensionBoundary[2]; - BoundingBox* t = this->myGrid->getBoundingBox(); + // DimensionBoundary* myBoundaries = new DimensionBoundary[2]; + base::BoundingBox* t = this->myGrid->getBoundingBox(); - DimensionBoundary* myBoundaries = new DimensionBoundary[dim]; + base::DimensionBoundary* myBoundaries = new base::DimensionBoundary[dim]; myBoundaries[0].leftBoundary = t->getIntervalOffset(0); - myBoundaries[0].rightBoundary = t->getIntervalOffset(0) + t->getIntervalWidth( - 0); + myBoundaries[0].rightBoundary = t->getIntervalOffset(0) + t->getIntervalWidth(0); myBoundaries[1].leftBoundary = t->getIntervalOffset(1); - myBoundaries[1].rightBoundary = t->getIntervalOffset(1) + t->getIntervalWidth( - 1); + myBoundaries[1].rightBoundary = t->getIntervalOffset(1) + t->getIntervalWidth(1); // step 1: do BS along dimension dim_BS myBoundaries[this->dim_BS].bDirichletLeft = true; @@ -160,19 +158,19 @@ void BlackScholesHullWhiteSolver::solveImplicitEuler(size_t numTimesteps, t->setBoundary(0, myBoundaries[0]); t->setBoundary(1, myBoundaries[1]); - //this->myGrid->setBoundingBox(*t);*/ + // this->myGrid->setBoundingBox(*t);*/ std::vector newAlgoDimsBS(1); newAlgoDimsBS[0] = this->dim_BS; setAlgorithmicDimensions(newAlgoDimsBS); - ModifiedBlackScholesParabolicPDESolverSystem* myBSSystem = new - ModifiedBlackScholesParabolicPDESolverSystem(*this->myGrid, alpha, *this->mus, - *this->sigmas, *this->rhos, this->r, timestepsize, "ImEul", - this->useLogTransform, this->useCoarsen, this->coarsenThreshold, - this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, - this->refineMode, this->refineMaxLevel, this->dim_HW); - //std::cout << alpha.toString() << std::endl; + ModifiedBlackScholesParabolicPDESolverSystem* myBSSystem = + new ModifiedBlackScholesParabolicPDESolverSystem( + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + "ImEul", this->useLogTransform, this->useCoarsen, this->coarsenThreshold, + this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, this->refineMode, + this->refineMaxLevel, this->dim_HW); + // std::cout << alpha.toString() << std::endl; myEuler->solve(*myCG, *myBSSystem, true, verbose); // step 2: do HW along dim_HW @@ -184,32 +182,35 @@ void BlackScholesHullWhiteSolver::solveImplicitEuler(size_t numTimesteps, t->setBoundary(0, myBoundaries[0]); t->setBoundary(1, myBoundaries[1]); - //this->myGrid->setBoundingBox(*t);*/ + // this->myGrid->setBoundingBox(*t);*/ std::vector newAlgoDimsHW(1); newAlgoDimsHW[0] = this->dim_HW; setAlgorithmicDimensions(newAlgoDimsHW); - HullWhiteParabolicPDESolverSystem* myHWSystem = new - HullWhiteParabolicPDESolverSystem(*this->myGrid, alpha, this->sigma, - this->theta, this->a, timestepsize, "ImEul", this->useCoarsen, - this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, - this->refineThreshold, this->refineMode, this->refineMaxLevel, this->dim_HW); + HullWhiteParabolicPDESolverSystem* myHWSystem = new HullWhiteParabolicPDESolverSystem( + *this->myGrid, alpha, this->sigma, this->theta, this->a, timestepsize, "ImEul", + this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel, this->dim_HW); myEuler->solve(*myCG, *myHWSystem, true, verbose); this->dNeededTime = myStopwatch->stop(); - std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << - std::endl; - std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << - std::endl << std::endl << std::endl; + std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << std::endl; + std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << std::endl + << std::endl + << std::endl; - std::cout << "Average Grid size: " << static_cast - (myBSSystem->getSumGridPointsComplete()) / static_cast - (numTimesteps) << std::endl; - std::cout << "Average Grid size (Inner): " << static_cast - (myBSSystem->getSumGridPointsInner()) / static_cast - (numTimesteps) << std::endl << std::endl << std::endl; + std::cout << "Average Grid size: " + << static_cast(myBSSystem->getSumGridPointsComplete()) / + static_cast(numTimesteps) + << std::endl; + std::cout << "Average Grid size (Inner): " + << static_cast(myBSSystem->getSumGridPointsInner()) / + static_cast(numTimesteps) + << std::endl + << std::endl + << std::endl; if (this->myScreen != NULL) { std::cout << "Time to solve: " << this->dNeededTime << " seconds" << std::endl; @@ -217,9 +218,10 @@ void BlackScholesHullWhiteSolver::solveImplicitEuler(size_t numTimesteps, } this->finInnerGridSize = getNumberInnerGridPoints(); - this->avgInnerGridSize = static_cast((static_cast - (myBSSystem->getSumGridPointsInner()) / static_cast - (numTimesteps)) + 0.5); + this->avgInnerGridSize = + static_cast((static_cast(myBSSystem->getSumGridPointsInner()) / + static_cast(numTimesteps)) + + 0.5); this->nNeededIterations = myEuler->getNumberIterations(); delete myBSSystem; delete myHWSystem; @@ -228,37 +230,39 @@ void BlackScholesHullWhiteSolver::solveImplicitEuler(size_t numTimesteps, delete myStopwatch; delete myBoundaries; } else { - throw new application_exception("BlackScholesHullWhiteSolver::solveImplicitEuler : A grid wasn't constructed before or stochastic parameters weren't set!"); + throw new base::application_exception( + "BlackScholesHullWhiteSolver::solveImplicitEuler : A grid wasn't constructed before or " + "stochastic parameters weren't set!"); } - } -void BlackScholesHullWhiteSolver::solveCrankNicolson(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, size_t NumImEul) { - throw new application_exception("BlackScholesHullWhiteSolver::solveCrankNicolson : Crank-Nicloson is not supported for BlackScholesHullWhiteSolver!"); +void BlackScholesHullWhiteSolver::solveCrankNicolson(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, size_t NumImEul) { + throw new base::application_exception( + "BlackScholesHullWhiteSolver::solveCrankNicolson : Crank-Nicloson is not supported for " + "BlackScholesHullWhiteSolver!"); } std::vector BlackScholesHullWhiteSolver::getAlgorithmicDimensions() { return this->myGrid->getAlgorithmicDimensions(); } -void BlackScholesHullWhiteSolver::setAlgorithmicDimensions( - std::vector newAlgoDims) { +void BlackScholesHullWhiteSolver::setAlgorithmicDimensions(std::vector newAlgoDims) { this->myGrid->setAlgorithmicDimensions(newAlgoDims); } void BlackScholesHullWhiteSolver::initScreen() { - this->myScreen = new ScreenOutput(); - this->myScreen->writeTitle("SG++ - combine black scholes and Hull White Solver, 1.3.0" - , "The SG++ Project (C) 2009-2010, by Chao qi"); + this->myScreen = new base::ScreenOutput(); + this->myScreen->writeTitle("SG++ - combine black scholes and Hull White Solver, 1.3.0", + "The SG++ Project (C) 2009-2010, by Chao qi"); this->myScreen->writeStartSolve("combine Black Scholes and Hull White Solver"); } void BlackScholesHullWhiteSolver::setEnableCoarseningData( - std::string adaptSolveMode, std::string refineMode, - SGPP::base::GridIndex::level_type refineMaxLevel, int numCoarsenPoints, - float_t coarsenThreshold, float_t refineThreshold) { + std::string adaptSolveMode, std::string refineMode, + SGPP::base::GridIndex::level_type refineMaxLevel, int numCoarsenPoints, + float_t coarsenThreshold, float_t refineThreshold) { this->useCoarsen = true; this->coarsenThreshold = coarsenThreshold; this->refineThreshold = refineThreshold; @@ -268,28 +272,28 @@ void BlackScholesHullWhiteSolver::setEnableCoarseningData( this->numCoarsenPoints = numCoarsenPoints; } -size_t BlackScholesHullWhiteSolver::getGridPointsAtMoney(std::string payoffType, - float_t strike, float_t eps) { +size_t BlackScholesHullWhiteSolver::getGridPointsAtMoney(std::string payoffType, float_t strike, + float_t eps) { size_t nPoints = 0; if (this->useLogTransform == false) { if (this->bGridConstructed) { for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { bool isAtMoney = true; - DataVector coords(this->dim); + base::DataVector coords(this->dim); this->myGridStorage->get(i)->getCoordsBB(coords, *this->myBoundingBox); - if (payoffType == "std_euro_call" || payoffType == "std_euro_put" - || payoffType == "GMIB") { + if (payoffType == "std_euro_call" || payoffType == "std_euro_put" || payoffType == "GMIB") { for (size_t d = 0; d < this->dim; d++) { - if ( ((coords.sum() / static_cast(this->dim)) < (strike - eps)) - || ((coords.sum() / static_cast(this->dim)) > (strike + eps)) ) { + if (((coords.sum() / static_cast(this->dim)) < (strike - eps)) || + ((coords.sum() / static_cast(this->dim)) > (strike + eps))) { isAtMoney = false; } - } } else { - throw new application_exception("BlackScholesHullWhiteSolver::getGridPointsAtMoney : An unknown payoff-type was specified!"); + throw new base::application_exception( + "BlackScholesHullWhiteSolver::getGridPointsAtMoney : An unknown payoff-type was " + "specified!"); } if (isAtMoney == true) { @@ -297,29 +301,27 @@ size_t BlackScholesHullWhiteSolver::getGridPointsAtMoney(std::string payoffType, } } } else { - throw new application_exception("BlackScholesHullWhiteSolver::getGridPointsAtMoney : A grid wasn't constructed before!"); + throw new base::application_exception( + "BlackScholesHullWhiteSolver::getGridPointsAtMoney : A grid wasn't constructed before!"); } } return nPoints; } - -void BlackScholesHullWhiteSolver::initGridWithPayoffBSHW(DataVector& alpha, - float_t strike, std::string payoffType, float_t a, float_t sigma) { +void BlackScholesHullWhiteSolver::initGridWithPayoffBSHW(base::DataVector& alpha, float_t strike, + std::string payoffType, float_t a, + float_t sigma) { float_t tmp; int timeT = 12; int endtime = 32; float_t c = 0.06; - - if (this->bGridConstructed) { float_t* dblFuncValues = new float_t[dim]; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); for (size_t j = 0; j < this->dim; j++) { @@ -337,55 +339,44 @@ void BlackScholesHullWhiteSolver::initGridWithPayoffBSHW(DataVector& alpha, float_t PT = 0; for (int k = (timeT + 1); k <= endtime; k++) { - PT = exp(0.04 * (timeT - k) + 0.04 * (1 - exp(-a * static_cast - (k - timeT))) / a - pow(sigma, - 2.0) * pow((exp(-a * static_cast(k)) - exp(-a * static_cast - (timeT))), 2.0) * (exp(2 * a * static_cast(timeT)) - 1) / (4 * pow(a, - 3.0)) - (1 - exp(-a * static_cast(k - timeT))) * - dblFuncValues[this->dim_HW] / a); + PT = exp( + 0.04 * (timeT - k) + 0.04 * (1 - exp(-a * static_cast(k - timeT))) / a - + pow(sigma, 2.0) * + pow((exp(-a * static_cast(k)) - exp(-a * static_cast(timeT))), + 2.0) * + (exp(2 * a * static_cast(timeT)) - 1) / (4 * pow(a, 3.0)) - + (1 - exp(-a * static_cast(k - timeT))) * dblFuncValues[this->dim_HW] / a); PB = PB + c * PT; } - //std::cout << "r=" << dblFuncValues[this->dim_HW] << " PB=" <myGrid); + base::OperationHierarchisation* myHierarchisation = + SGPP::op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("BlackScholesSolver::initGridWithPayoffBSHW : A grid wasn't constructed before!"); + throw new base::application_exception( + "BlackScholesSolver::initGridWithPayoffBSHW : A grid wasn't constructed before!"); } } -size_t BlackScholesHullWhiteSolver::getNeededIterationsToSolve() { - return this->nNeededIterations; -} - -float_t BlackScholesHullWhiteSolver::getNeededTimeToSolve() { - return this->dNeededTime; -} +size_t BlackScholesHullWhiteSolver::getNeededIterationsToSolve() { return this->nNeededIterations; } -size_t BlackScholesHullWhiteSolver::getStartInnerGridSize() { - return this->staInnerGridSize; -} +float_t BlackScholesHullWhiteSolver::getNeededTimeToSolve() { return this->dNeededTime; } -size_t BlackScholesHullWhiteSolver::getFinalInnerGridSize() { - return this->finInnerGridSize; -} +size_t BlackScholesHullWhiteSolver::getStartInnerGridSize() { return this->staInnerGridSize; } -size_t BlackScholesHullWhiteSolver::getAverageInnerGridSize() { - return this->avgInnerGridSize; -} +size_t BlackScholesHullWhiteSolver::getFinalInnerGridSize() { return this->finInnerGridSize; } -} -} +size_t BlackScholesHullWhiteSolver::getAverageInnerGridSize() { return this->avgInnerGridSize; } +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/application/BlackScholesHullWhiteSolver.hpp b/finance/src/sgpp/finance/application/BlackScholesHullWhiteSolver.hpp index c10e8fd762..296148bbe1 100644 --- a/finance/src/sgpp/finance/application/BlackScholesHullWhiteSolver.hpp +++ b/finance/src/sgpp/finance/application/BlackScholesHullWhiteSolver.hpp @@ -6,7 +6,6 @@ #ifndef BLACKSCHOLESHULLWHITESOLVER_HPP #define BLACKSCHOLESHULLWHITESOLVER_HPP - #include #include @@ -16,6 +15,9 @@ #include +#include +#include + #include #include #include @@ -23,10 +25,6 @@ #include #include -#include -#include - - namespace SGPP { namespace finance { @@ -96,7 +94,7 @@ class BlackScholesHullWhiteSolver : public SGPP::pde::ParabolicPDESolver { /** * Std-Constructor of the solver */ - BlackScholesHullWhiteSolver(bool useLogTransform = false); + explicit BlackScholesHullWhiteSolver(bool useLogTransform = false); /** * Std-Destructor of the solver @@ -106,7 +104,8 @@ class BlackScholesHullWhiteSolver : public SGPP::pde::ParabolicPDESolver { void constructGrid(SGPP::base::BoundingBox& myBoundingBox, int level); /** - * In order to combine the Black Scholes Equation with the Hull White Equation you have to provided + * In order to combine the Black Scholes Equation with the Hull White Equation you have to + * provided * some statistical data about the underlying (assets' weight, standard deviation * and the correlation between them). This function allows you to set this data for Black-Scholes. * @@ -118,9 +117,9 @@ class BlackScholesHullWhiteSolver : public SGPP::pde::ParabolicPDESolver { * @param sigma the sigma of HullWhite PDE (vola) * @param a the a of HullWhite PDE (mean reversion rate) */ - void setStochasticData(SGPP::base::DataVector& mus, - SGPP::base::DataVector& sigmas, SGPP::base::DataMatrix& rhos, float_t r, - float_t theta, float_t sigma, float_t a); + void setStochasticData(SGPP::base::DataVector& mus, SGPP::base::DataVector& sigmas, + SGPP::base::DataMatrix& rhos, float_t r, float_t theta, float_t sigma, + float_t a); /** * defines the dimension of the stoch. processes (BS and HW). default is BS:0, HW:1 @@ -130,31 +129,29 @@ class BlackScholesHullWhiteSolver : public SGPP::pde::ParabolicPDESolver { */ void setProcessDimensions(int dim_BS, int dim_HW); - void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false, bool generateAnimation = false, - size_t numEvalsAnimation = 20); + void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, + bool generateAnimation = false, size_t numEvalsAnimation = 20); - void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false, bool generateAnimation = false, - size_t numEvalsAnimation = 20); + void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, + bool generateAnimation = false, size_t numEvalsAnimation = 20); - void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - size_t NumImEul = 0); + void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, size_t NumImEul = 0); /** * Inits the alpha vector with a payoff function of an European call option or put option * * @param alpha the coefficient vector of the grid's ansatzfunctions * @param strike the option's strike - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available * @param a is the mean reversion rate * @param sigma is the volatility */ - void initGridWithPayoffBSHW(SGPP::base::DataVector& alpha, float_t strike, - std::string payoffType, float_t a, float_t sigma); + void initGridWithPayoffBSHW(SGPP::base::DataVector& alpha, float_t strike, std::string payoffType, + float_t a, float_t sigma); /** * Inits the screen object @@ -190,8 +187,9 @@ class BlackScholesHullWhiteSolver : public SGPP::pde::ParabolicPDESolver { * @param refineThreshold Threshold needed to determine if a grid point should be refined */ void setEnableCoarseningData(std::string adaptSolveMode, std::string refineMode, - SGPP::base::GridIndex::level_type refineMaxLevel, int numCoarsenPoints, - float_t coarsenThreshold, float_t refineThreshold); + SGPP::base::GridIndex::level_type refineMaxLevel, + int numCoarsenPoints, float_t coarsenThreshold, + float_t refineThreshold); /** * gets the number of gridpoints at the money @@ -202,20 +200,21 @@ class BlackScholesHullWhiteSolver : public SGPP::pde::ParabolicPDESolver { * @param strike the option's strike * @param eps epsilon to determine the gridpoints, use if at the money is not exactly on grid */ - size_t getGridPointsAtMoney(std::string payoffType, float_t strike, - float_t eps = 0.0); + size_t getGridPointsAtMoney(std::string payoffType, float_t strike, float_t eps = 0.0); /** * gets the number needed iterations to solve Black Scholes Equation * - * @return number of iterations needed to solve Black Scholes Equation, if called before solving 0 is returned + * @return number of iterations needed to solve Black Scholes Equation, if called before solving 0 + * is returned */ size_t getNeededIterationsToSolve(); /** * gets needed time in seconds to solve Black Scholes Equation * - * @return needed time in seconds to solve Black Scholes Equation, if called before solving 0 is returned + * @return needed time in seconds to solve Black Scholes Equation, if called before solving 0 is + * returned */ float_t getNeededTimeToSolve(); @@ -240,8 +239,7 @@ class BlackScholesHullWhiteSolver : public SGPP::pde::ParabolicPDESolver { */ size_t getAverageInnerGridSize(); }; - -} -} +} // namespace finance +} // namespace SGPP #endif /* BLACKSCHOLESHULLWHITESOLVER_HPP */ diff --git a/finance/src/sgpp/finance/application/BlackScholesSolver.cpp b/finance/src/sgpp/finance/application/BlackScholesSolver.cpp index af20ced092..c077119be7 100644 --- a/finance/src/sgpp/finance/application/BlackScholesSolver.cpp +++ b/finance/src/sgpp/finance/application/BlackScholesSolver.cpp @@ -26,24 +26,22 @@ #include #include +#include + #include #include #include #include #include - -using namespace SGPP::pde; -using namespace SGPP::solver; -using namespace SGPP::base; - -#include - +#include +#include +#include +#include namespace SGPP { namespace finance { -BlackScholesSolver::BlackScholesSolver(bool useLogTransform, bool usePAT) - : ParabolicPDESolver() { +BlackScholesSolver::BlackScholesSolver(bool useLogTransform, bool usePAT) : ParabolicPDESolver() { this->bStochasticDataAlloc = false; this->bGridConstructed = false; this->myScreen = NULL; @@ -93,16 +91,16 @@ BlackScholesSolver::~BlackScholesSolver() { } } -void BlackScholesSolver::getGridNormalDistribution(DataVector& alpha, - std::vector& norm_mu, std::vector& norm_sigma) { +void BlackScholesSolver::getGridNormalDistribution(base::DataVector& alpha, + std::vector& norm_mu, + std::vector& norm_sigma) { if (this->bGridConstructed) { float_t value; - StdNormalDistribution myNormDistr; + base::StdNormalDistribution myNormDistr; float_t* s_coords = new float_t[this->dim]; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(* - (this->myBoundingBox)); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*(this->myBoundingBox)); std::stringstream coordsStream(coords); for (size_t j = 0; j < this->dim; j++) { @@ -121,8 +119,8 @@ void BlackScholesSolver::getGridNormalDistribution(DataVector& alpha, float_t inner_tmp = 0.0; for (size_t l = 0; l < dim; l++) { - inner_tmp += this->eigvec_covar->get(j, - l) * (s_coords[l] - (this->current_time * this->mu_hat->get(l))); + inner_tmp += this->eigvec_covar->get(j, l) * + (s_coords[l] - (this->current_time * this->mu_hat->get(l))); } value *= myNormDistr.getDensity(exp(inner_tmp), norm_mu[j], norm_sigma[j]); @@ -137,32 +135,34 @@ void BlackScholesSolver::getGridNormalDistribution(DataVector& alpha, delete[] s_coords; } else { - throw new application_exception("BlackScholesSolver::getGridNormalDistribution : The grid wasn't initialized before!"); + throw new base::application_exception( + "BlackScholesSolver::getGridNormalDistribution : The grid wasn't initialized before!"); } } -void BlackScholesSolver::constructGrid(BoundingBox& BoundingBox, int level) { +void BlackScholesSolver::constructGrid(base::BoundingBox& BoundingBox, int level) { this->dim = BoundingBox.getDimensions(); this->levels = level; - this->myGrid = new LinearBoundaryGrid(BoundingBox); + this->myGrid = new base::LinearBoundaryGrid(BoundingBox); - GridGenerator* myGenerator = this->myGrid->createGridGenerator(); + base::GridGenerator* myGenerator = this->myGrid->createGridGenerator(); myGenerator->regular(this->levels); delete myGenerator; this->myBoundingBox = this->myGrid->getBoundingBox(); this->myGridStorage = this->myGrid->getStorage(); - //std::string serGrid; - //myGrid->serialize(serGrid); - //std::cout << serGrid << std::endl; + // std::string serGrid; + // myGrid->serialize(serGrid); + // std::cout << serGrid << std::endl; this->bGridConstructed = true; } -void BlackScholesSolver::refineInitialGridWithPayoff(DataVector& alpha, - float_t strike, std::string payoffType, float_t dStrikeDistance) { +void BlackScholesSolver::refineInitialGridWithPayoff(base::DataVector& alpha, float_t strike, + std::string payoffType, + float_t dStrikeDistance) { size_t nRefinements = 0; this->dStrike = strike; @@ -170,19 +170,18 @@ void BlackScholesSolver::refineInitialGridWithPayoff(DataVector& alpha, if (this->useLogTransform == false) { if (this->bGridConstructed) { + base::DataVector refineVector(alpha.getSize()); - DataVector refineVector(alpha.getSize()); - - if (payoffType == "std_euro_call" || payoffType == "std_euro_put" - || payoffType == "std_amer_put") { + if (payoffType == "std_euro_call" || payoffType == "std_euro_put" || + payoffType == "std_amer_put") { this->tBoundaryType = "Dirichlet"; float_t tmp; float_t* dblFuncValues = new float_t[dim]; float_t dDistance = 0.0; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(* - (this->myBoundingBox)); + std::string coords = + this->myGridStorage->get(i)->getCoordsStringBB(*(this->myBoundingBox)); std::stringstream coordsStream(coords); for (size_t j = 0; j < this->dim; j++) { @@ -215,8 +214,8 @@ void BlackScholesSolver::refineInitialGridWithPayoff(DataVector& alpha, delete[] dblFuncValues; - SurplusRefinementFunctor* myRefineFunc = new SurplusRefinementFunctor( - &refineVector, nRefinements, 0.0); + base::SurplusRefinementFunctor* myRefineFunc = + new base::SurplusRefinementFunctor(&refineVector, nRefinements, 0.0); this->myGrid->createGridGenerator()->refine(myRefineFunc); @@ -227,17 +226,20 @@ void BlackScholesSolver::refineInitialGridWithPayoff(DataVector& alpha, // reinit the grid with the payoff function initGridWithPayoff(alpha, strike, payoffType); } else { - throw new application_exception("BlackScholesSolver::refineInitialGridWithPayoff : An unsupported payoffType was specified!"); + throw new base::application_exception( + "BlackScholesSolver::refineInitialGridWithPayoff : An unsupported payoffType was " + "specified!"); } } else { - throw new application_exception("BlackScholesSolver::refineInitialGridWithPayoff : The grid wasn't initialized before!"); + throw new base::application_exception( + "BlackScholesSolver::refineInitialGridWithPayoff : The grid wasn't initialized before!"); } } } void BlackScholesSolver::refineInitialGridWithPayoffToMaxLevel( - DataVector& alpha, float_t strike, std::string payoffType, - float_t dStrikeDistance, SGPP::base::GridIndex::level_type maxLevel) { + base::DataVector& alpha, float_t strike, std::string payoffType, float_t dStrikeDistance, + base::GridIndex::level_type maxLevel) { size_t nRefinements = 0; this->dStrike = strike; @@ -245,11 +247,10 @@ void BlackScholesSolver::refineInitialGridWithPayoffToMaxLevel( if (this->useLogTransform == false) { if (this->bGridConstructed) { + base::DataVector refineVector(alpha.getSize()); - DataVector refineVector(alpha.getSize()); - - if (payoffType == "std_euro_call" || payoffType == "std_euro_put" - || payoffType == "std_amer_put") { + if (payoffType == "std_euro_call" || payoffType == "std_euro_put" || + payoffType == "std_amer_put") { float_t tmp; float_t* dblFuncValues = new float_t[dim]; float_t dDistance = 0.0; @@ -257,8 +258,7 @@ void BlackScholesSolver::refineInitialGridWithPayoffToMaxLevel( this->tBoundaryType = "Dirichlet"; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); for (size_t j = 0; j < this->dim; j++) { @@ -291,8 +291,8 @@ void BlackScholesSolver::refineInitialGridWithPayoffToMaxLevel( delete[] dblFuncValues; - SurplusRefinementFunctor* myRefineFunc = new SurplusRefinementFunctor( - &refineVector, nRefinements, 0.0); + base::SurplusRefinementFunctor* myRefineFunc = + new base::SurplusRefinementFunctor(&refineVector, nRefinements, 0.0); this->myGrid->createGridGenerator()->refineMaxLevel(myRefineFunc, maxLevel); @@ -303,30 +303,34 @@ void BlackScholesSolver::refineInitialGridWithPayoffToMaxLevel( // reinit the grid with the payoff function initGridWithPayoff(alpha, strike, payoffType); } else { - throw new application_exception("BlackScholesSolver::refineInitialGridWithPayoffToMaxLevel : An unsupported payoffType was specified!"); + throw new base::application_exception( + "BlackScholesSolver::refineInitialGridWithPayoffToMaxLevel : An unsupported payoffType " + "was specified!"); } } else { - throw new application_exception("BlackScholesSolver::refineInitialGridWithPayoffToMaxLevel : The grid wasn't initialized before!"); + throw new base::application_exception( + "BlackScholesSolver::refineInitialGridWithPayoffToMaxLevel : The grid wasn't initialized " + "before!"); } } } -void BlackScholesSolver::setStochasticData(DataVector& mus, DataVector& sigmas, - DataMatrix& rhos, float_t r) { - this->mus = new SGPP::base::DataVector(mus); - this->sigmas = new SGPP::base::DataVector(sigmas); - this->rhos = new SGPP::base::DataMatrix(rhos); +void BlackScholesSolver::setStochasticData(base::DataVector& mus, base::DataVector& sigmas, + base::DataMatrix& rhos, float_t r) { + this->mus = new base::DataVector(mus); + this->sigmas = new base::DataVector(sigmas); + this->rhos = new base::DataMatrix(rhos); this->r = r; // calculate eigenvalues, eigenvectors and mu_hat from stochastic data for PAT size_t mydim = this->mus->getSize(); - this->eigval_covar = new SGPP::base::DataVector(mydim); - this->eigvec_covar = new SGPP::base::DataMatrix(mydim, mydim); - this->mu_hat = new SGPP::base::DataVector(mydim); + this->eigval_covar = new base::DataVector(mydim); + this->eigvec_covar = new base::DataMatrix(mydim, mydim); + this->mu_hat = new base::DataVector(mydim); // 1d test case if (mydim == 1) { - this->eigval_covar->set(0, this->sigmas->get(0)*this->sigmas->get(0)); + this->eigval_covar->set(0, this->sigmas->get(0) * this->sigmas->get(0)); this->eigvec_covar->set(0, 0, 1.0); } @@ -393,7 +397,6 @@ void BlackScholesSolver::setStochasticData(DataVector& mus, DataVector& sigmas, this->eigval_covar->set(1, 0.109759129882028184); this->eigval_covar->set(2, 0.164125663850937770); - this->eigvec_covar->set(0, 0, -0.869836297894464927); this->eigvec_covar->set(0, 1, -0.472520156399458380); this->eigvec_covar->set(0, 2, -0.141808027493095845); @@ -450,7 +453,6 @@ void BlackScholesSolver::setStochasticData(DataVector& mus, DataVector& sigmas, this->eigval_covar->set(2, 0.0369289052706551282); this->eigval_covar->set(3, 0.884454475165345477e-1); - this->eigvec_covar->set(0, 0, -0.758784156527507303); this->eigvec_covar->set(0, 1, -0.441609644035335480); this->eigvec_covar->set(0, 2, -0.329723883556484409); @@ -480,7 +482,6 @@ void BlackScholesSolver::setStochasticData(DataVector& mus, DataVector& sigmas, this->eigval_covar->set(3, 0.0939549786605669707); this->eigval_covar->set(4, 0.0587331447155870698); - this->eigvec_covar->set(0, 0, 0.263790550378285305); this->eigvec_covar->set(0, 1, 0.859923642135395405); this->eigvec_covar->set(0, 2, 0.334323851170300113); @@ -521,7 +522,6 @@ void BlackScholesSolver::setStochasticData(DataVector& mus, DataVector& sigmas, this->eigval_covar->set(4, 0.0774284377364329035); this->eigval_covar->set(5, 0.110834499602274789); - this->eigvec_covar->set(0, 0, 0.0901970509435878476); this->eigvec_covar->set(0, 1, 0.825424523396568799); this->eigvec_covar->set(0, 2, 0.355559506316694030); @@ -575,7 +575,6 @@ void BlackScholesSolver::setStochasticData(DataVector& mus, DataVector& sigmas, this->eigval_covar->set(5, 0.0811043629942213989); this->eigval_covar->set(6, 0.0590670833426543418); - this->eigvec_covar->set(0, 0, 0.0843288248079574199); this->eigvec_covar->set(0, 1, 0.825397719934479079); this->eigvec_covar->set(0, 2, -0.168709288751078074); @@ -637,8 +636,8 @@ void BlackScholesSolver::setStochasticData(DataVector& mus, DataVector& sigmas, float_t tmp = 0.0; for (size_t j = 0; j < mydim; j++) { - tmp += ((this->mus->get(j) - (0.5 * this->sigmas->get(j) * this->sigmas->get( - j))) * this->eigvec_covar->get(j, i)); + tmp += ((this->mus->get(j) - (0.5 * this->sigmas->get(j) * this->sigmas->get(j))) * + this->eigvec_covar->get(j, i)); } this->mu_hat->set(i, tmp); @@ -647,88 +646,89 @@ void BlackScholesSolver::setStochasticData(DataVector& mus, DataVector& sigmas, bStochasticDataAlloc = true; } -void BlackScholesSolver::solveExplicitEuler(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose, bool generateAnimation, - size_t numEvalsAnimation) { +void BlackScholesSolver::solveExplicitEuler(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose, + bool generateAnimation, size_t numEvalsAnimation) { if (this->bGridConstructed && this->bStochasticDataAlloc) { - Euler* myEuler = new Euler("ExEul", numTimesteps, timestepsize, - generateAnimation, numEvalsAnimation, myScreen); - SLESolver* myCG = NULL; - OperationParabolicPDESolverSystem* myBSSystem = NULL; + solver::Euler* myEuler = new solver::Euler("ExEul", numTimesteps, timestepsize, + generateAnimation, numEvalsAnimation, myScreen); + solver::SLESolver* myCG = NULL; + solver::OperationParabolicPDESolverSystem* myBSSystem = NULL; if (this->tBoundaryType == "Dirichlet") { if (this->usePAT == true) { - myCG = new ConjugateGradients(maxCGIterations, epsilonCG); + myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); #ifdef _OPENMP myBSSystem = new BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP( - *this->myGrid, alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, - timestepsize, "ExEul", this->dStrike, this->payoffType, this->r, - this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, - this->numCoarsenPoints, this->refineThreshold, this->refineMode, - this->refineMaxLevel); + *this->myGrid, alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, + timestepsize, "ExEul", this->dStrike, this->payoffType, this->r, this->useCoarsen, + this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); #else - myBSSystem = new BlackScholesPATParabolicPDESolverSystemEuroAmer(*this->myGrid, - alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, timestepsize, - "ExEul", this->dStrike, this->payoffType, this->r, this->useCoarsen, + myBSSystem = new BlackScholesPATParabolicPDESolverSystemEuroAmer( + *this->myGrid, alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, + timestepsize, "ExEul", this->dStrike, this->payoffType, this->r, this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, this->refineMode, this->refineMaxLevel); #endif } else { - myCG = new BiCGStab(maxCGIterations, epsilonCG); + myCG = new solver::BiCGStab(maxCGIterations, epsilonCG); #ifdef _OPENMP myBSSystem = new BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP( - *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, - timestepsize, "ExEul", this->dStrike, this->payoffType, this->useLogTransform, - this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, - this->numCoarsenPoints, this->refineThreshold, this->refineMode, - this->refineMaxLevel); + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + "ExEul", this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, + this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); #else - myBSSystem = new BlackScholesParabolicPDESolverSystemEuroAmer(*this->myGrid, - alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, "ExEul", - this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, + myBSSystem = new BlackScholesParabolicPDESolverSystemEuroAmer( + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + "ExEul", this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, this->refineMode, this->refineMaxLevel); #endif } } else { if (this->usePAT == true) { - myCG = new ConjugateGradients(maxCGIterations, epsilonCG); - myBSSystem = new BlackScholesPATParabolicPDESolverSystem(*this->myGrid, alpha, - *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, timestepsize, "ExEul", - this->dStrike, this->payoffType, this->useCoarsen, this->coarsenThreshold, - this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, - this->refineMode, this->refineMaxLevel); + myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); + myBSSystem = new BlackScholesPATParabolicPDESolverSystem( + *this->myGrid, alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, + timestepsize, "ExEul", this->dStrike, this->payoffType, this->useCoarsen, + this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); } else { - myCG = new BiCGStab(maxCGIterations, epsilonCG); - myBSSystem = new BlackScholesParabolicPDESolverSystem(*this->myGrid, alpha, - *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, "ExEul", - this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, + myCG = new solver::BiCGStab(maxCGIterations, epsilonCG); + myBSSystem = new BlackScholesParabolicPDESolverSystem( + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + "ExEul", this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, this->refineMode, this->refineMaxLevel); } } - SGppStopwatch* myStopwatch = new SGppStopwatch(); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); this->staInnerGridSize = getNumberInnerGridPoints(); - std::cout << "Using Explicit Euler to solve " << numTimesteps << " timesteps:" - << std::endl; + std::cout << "Using Explicit Euler to solve " << numTimesteps << " timesteps:" << std::endl; myStopwatch->start(); myEuler->solve(*myCG, *myBSSystem, true, verbose); this->dNeededTime = myStopwatch->stop(); - std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << - std::endl; - std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << - std::endl << std::endl << std::endl; + std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << std::endl; + std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << std::endl + << std::endl + << std::endl; - std::cout << "Average Grid size: " << static_cast - (myBSSystem->getSumGridPointsComplete()) / static_cast - (numTimesteps) << std::endl; - std::cout << "Average Grid size (Inner): " << static_cast - (myBSSystem->getSumGridPointsInner()) / static_cast - (numTimesteps) << std::endl << std::endl << std::endl; + std::cout << "Average Grid size: " + << static_cast(myBSSystem->getSumGridPointsComplete()) / + static_cast(numTimesteps) + << std::endl; + std::cout << "Average Grid size (Inner): " + << static_cast(myBSSystem->getSumGridPointsInner()) / + static_cast(numTimesteps) + << std::endl + << std::endl + << std::endl; if (this->myScreen != NULL) { std::cout << "Time to solve: " << this->dNeededTime << " seconds" << std::endl; @@ -736,9 +736,10 @@ void BlackScholesSolver::solveExplicitEuler(size_t numTimesteps, } this->finInnerGridSize = getNumberInnerGridPoints(); - this->avgInnerGridSize = static_cast((static_cast - (myBSSystem->getSumGridPointsInner()) / static_cast - (numTimesteps)) + 0.5); + this->avgInnerGridSize = + static_cast((static_cast(myBSSystem->getSumGridPointsInner()) / + static_cast(numTimesteps)) + + 0.5); this->nNeededIterations = myEuler->getNumberIterations(); delete myBSSystem; @@ -748,92 +749,95 @@ void BlackScholesSolver::solveExplicitEuler(size_t numTimesteps, this->current_time += (static_cast(numTimesteps) * timestepsize); } else { - throw new application_exception("BlackScholesSolver::solveExplicitEuler : A grid wasn't constructed before or stochastic parameters weren't set!"); + throw new base::application_exception( + "BlackScholesSolver::solveExplicitEuler : A grid wasn't constructed before or stochastic " + "parameters weren't set!"); } } -void BlackScholesSolver::solveImplicitEuler(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose, bool generateAnimation, - size_t numEvalsAnimation) { +void BlackScholesSolver::solveImplicitEuler(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose, + bool generateAnimation, size_t numEvalsAnimation) { if (this->bGridConstructed && this->bStochasticDataAlloc) { - Euler* myEuler = new Euler("ImEul", numTimesteps, timestepsize, - generateAnimation, numEvalsAnimation, myScreen); - SLESolver* myCG = NULL; - OperationParabolicPDESolverSystem* myBSSystem = NULL; + solver::Euler* myEuler = new solver::Euler("ImEul", numTimesteps, timestepsize, + generateAnimation, numEvalsAnimation, myScreen); + solver::SLESolver* myCG = NULL; + solver::OperationParabolicPDESolverSystem* myBSSystem = NULL; if (this->tBoundaryType == "Dirichlet") { if (this->usePAT == true) { - myCG = new ConjugateGradients(maxCGIterations, epsilonCG); + myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); #ifdef _OPENMP myBSSystem = new BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP( - *this->myGrid, alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, - timestepsize, "ImEul", this->dStrike, this->payoffType, this->r, - this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, - this->numCoarsenPoints, this->refineThreshold, this->refineMode, - this->refineMaxLevel); + *this->myGrid, alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, + timestepsize, "ImEul", this->dStrike, this->payoffType, this->r, this->useCoarsen, + this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); #else - myBSSystem = new BlackScholesPATParabolicPDESolverSystemEuroAmer(*this->myGrid, - alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, timestepsize, - "ImEul", this->dStrike, this->payoffType, this->r, this->useCoarsen, + myBSSystem = new BlackScholesPATParabolicPDESolverSystemEuroAmer( + *this->myGrid, alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, + timestepsize, "ImEul", this->dStrike, this->payoffType, this->r, this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, this->refineMode, this->refineMaxLevel); #endif } else { - myCG = new BiCGStab(maxCGIterations, epsilonCG); + myCG = new solver::BiCGStab(maxCGIterations, epsilonCG); #ifdef _OPENMP myBSSystem = new BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP( - *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, - timestepsize, "ImEul", this->dStrike, this->payoffType, this->useLogTransform, - this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, - this->numCoarsenPoints, this->refineThreshold, this->refineMode, - this->refineMaxLevel); + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + "ImEul", this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, + this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); #else - myBSSystem = new BlackScholesParabolicPDESolverSystemEuroAmer(*this->myGrid, - alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, "ImEul", - this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, + myBSSystem = new BlackScholesParabolicPDESolverSystemEuroAmer( + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + "ImEul", this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, this->refineMode, this->refineMaxLevel); #endif } } else { if (this->usePAT == true) { - myCG = new ConjugateGradients(maxCGIterations, epsilonCG); - myBSSystem = new BlackScholesPATParabolicPDESolverSystem(*this->myGrid, alpha, - *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, timestepsize, "ImEul", - this->dStrike, this->payoffType, this->useCoarsen, this->coarsenThreshold, - this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, - this->refineMode, this->refineMaxLevel); + myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); + myBSSystem = new BlackScholesPATParabolicPDESolverSystem( + *this->myGrid, alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, + timestepsize, "ImEul", this->dStrike, this->payoffType, this->useCoarsen, + this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); } else { - myCG = new BiCGStab(maxCGIterations, epsilonCG); - myBSSystem = new BlackScholesParabolicPDESolverSystem(*this->myGrid, alpha, - *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, "ImEul", - this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, + myCG = new solver::BiCGStab(maxCGIterations, epsilonCG); + myBSSystem = new BlackScholesParabolicPDESolverSystem( + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + "ImEul", this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, this->refineMode, this->refineMaxLevel); } } - SGppStopwatch* myStopwatch = new SGppStopwatch(); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); this->staInnerGridSize = getNumberInnerGridPoints(); - std::cout << "Using Implicit Euler to solve " << numTimesteps << " timesteps:" - << std::endl; + std::cout << "Using Implicit Euler to solve " << numTimesteps << " timesteps:" << std::endl; myStopwatch->start(); myEuler->solve(*myCG, *myBSSystem, true, verbose); this->dNeededTime = myStopwatch->stop(); - std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << - std::endl; - std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << - std::endl << std::endl << std::endl; + std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << std::endl; + std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << std::endl + << std::endl + << std::endl; - std::cout << "Average Grid size: " << static_cast - (myBSSystem->getSumGridPointsComplete()) / static_cast - (numTimesteps) << std::endl; - std::cout << "Average Grid size (Inner): " << static_cast - (myBSSystem->getSumGridPointsInner()) / static_cast - (numTimesteps) << std::endl << std::endl << std::endl; + std::cout << "Average Grid size: " + << static_cast(myBSSystem->getSumGridPointsComplete()) / + static_cast(numTimesteps) + << std::endl; + std::cout << "Average Grid size (Inner): " + << static_cast(myBSSystem->getSumGridPointsInner()) / + static_cast(numTimesteps) + << std::endl + << std::endl + << std::endl; if (this->myScreen != NULL) { std::cout << "Time to solve: " << this->dNeededTime << " seconds" << std::endl; @@ -841,9 +845,10 @@ void BlackScholesSolver::solveImplicitEuler(size_t numTimesteps, } this->finInnerGridSize = getNumberInnerGridPoints(); - this->avgInnerGridSize = static_cast((static_cast - (myBSSystem->getSumGridPointsInner()) / static_cast - (numTimesteps)) + 0.5); + this->avgInnerGridSize = + static_cast((static_cast(myBSSystem->getSumGridPointsInner()) / + static_cast(numTimesteps)) + + 0.5); this->nNeededIterations = myEuler->getNumberIterations(); delete myBSSystem; @@ -853,70 +858,70 @@ void BlackScholesSolver::solveImplicitEuler(size_t numTimesteps, this->current_time += (static_cast(numTimesteps) * timestepsize); } else { - throw new application_exception("BlackScholesSolver::solveImplicitEuler : A grid wasn't constructed before or stochastic parameters weren't set!"); + throw new base::application_exception( + "BlackScholesSolver::solveImplicitEuler : A grid wasn't constructed before or stochastic " + "parameters weren't set!"); } } -void BlackScholesSolver::solveCrankNicolson(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, size_t NumImEul) { +void BlackScholesSolver::solveCrankNicolson(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, size_t NumImEul) { if (this->bGridConstructed && this->bStochasticDataAlloc) { - SLESolver* myCG = NULL; - OperationParabolicPDESolverSystem* myBSSystem = NULL; + solver::SLESolver* myCG = NULL; + solver::OperationParabolicPDESolverSystem* myBSSystem = NULL; if (this->tBoundaryType == "Dirichlet") { if (this->usePAT == true) { - myCG = new ConjugateGradients(maxCGIterations, epsilonCG); + myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); #ifdef _OPENMP myBSSystem = new BlackScholesPATParabolicPDESolverSystemEuroAmerParallelOMP( - *this->myGrid, alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, - timestepsize, "ImEul", this->dStrike, this->payoffType, this->r, - this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, - this->numCoarsenPoints, this->refineThreshold, this->refineMode, - this->refineMaxLevel); + *this->myGrid, alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, + timestepsize, "ImEul", this->dStrike, this->payoffType, this->r, this->useCoarsen, + this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); #else - myBSSystem = new BlackScholesPATParabolicPDESolverSystemEuroAmer(*this->myGrid, - alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, timestepsize, - "ImEul", this->dStrike, this->payoffType, this->r, this->useCoarsen, + myBSSystem = new BlackScholesPATParabolicPDESolverSystemEuroAmer( + *this->myGrid, alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, + timestepsize, "ImEul", this->dStrike, this->payoffType, this->r, this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, this->refineMode, this->refineMaxLevel); #endif } else { - myCG = new BiCGStab(maxCGIterations, epsilonCG); + myCG = new solver::BiCGStab(maxCGIterations, epsilonCG); #ifdef _OPENMP myBSSystem = new BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP( - *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, - timestepsize, "ImEul", this->dStrike, this->payoffType, this->useLogTransform, - this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, - this->numCoarsenPoints, this->refineThreshold, this->refineMode, - this->refineMaxLevel); + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + "ImEul", this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, + this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); #else - myBSSystem = new BlackScholesParabolicPDESolverSystemEuroAmer(*this->myGrid, - alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, "ImEul", - this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, + myBSSystem = new BlackScholesParabolicPDESolverSystemEuroAmer( + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + "ImEul", this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, this->refineMode, this->refineMaxLevel); #endif } } else { if (this->usePAT == true) { - myCG = new ConjugateGradients(maxCGIterations, epsilonCG); - myBSSystem = new BlackScholesPATParabolicPDESolverSystem(*this->myGrid, alpha, - *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, timestepsize, "ImEul", - this->dStrike, this->payoffType, this->useCoarsen, this->coarsenThreshold, - this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, - this->refineMode, this->refineMaxLevel); + myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); + myBSSystem = new BlackScholesPATParabolicPDESolverSystem( + *this->myGrid, alpha, *this->eigval_covar, *this->eigvec_covar, *this->mu_hat, + timestepsize, "ImEul", this->dStrike, this->payoffType, this->useCoarsen, + this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); } else { - myCG = new BiCGStab(maxCGIterations, epsilonCG); - myBSSystem = new BlackScholesParabolicPDESolverSystem(*this->myGrid, alpha, - *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, "ImEul", - this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, + myCG = new solver::BiCGStab(maxCGIterations, epsilonCG); + myBSSystem = new BlackScholesParabolicPDESolverSystem( + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + "ImEul", this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, this->refineMode, this->refineMaxLevel); } } - SGppStopwatch* myStopwatch = new SGppStopwatch(); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); this->staInnerGridSize = getNumberInnerGridPoints(); size_t numCNSteps; @@ -930,37 +935,42 @@ void BlackScholesSolver::solveCrankNicolson(size_t numTimesteps, numIESteps = NumImEul; - Euler* myEuler = new Euler("ImEul", numIESteps, timestepsize, false, 0, - this->myScreen); - CrankNicolson* myCN = new CrankNicolson(numCNSteps, timestepsize, - this->myScreen); + solver::Euler* myEuler = + new solver::Euler("ImEul", numIESteps, timestepsize, false, 0, this->myScreen); + solver::CrankNicolson* myCN = + new solver::CrankNicolson(numCNSteps, timestepsize, this->myScreen); myStopwatch->start(); if (numIESteps > 0) { - std::cout << "Using Implicit Euler to solve " << numIESteps << " timesteps:" << - std::endl; + std::cout << "Using Implicit Euler to solve " << numIESteps << " timesteps:" << std::endl; myBSSystem->setODESolver("ImEul"); myEuler->solve(*myCG, *myBSSystem, false, false); } myBSSystem->setODESolver("CrNic"); - std::cout << "Using Crank Nicolson to solve " << numCNSteps << " timesteps:" << - std::endl << std::endl << std::endl << std::endl; + std::cout << "Using Crank Nicolson to solve " << numCNSteps << " timesteps:" << std::endl + << std::endl + << std::endl + << std::endl; myCN->solve(*myCG, *myBSSystem, true, false); this->dNeededTime = myStopwatch->stop(); - std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << - std::endl; - std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << - std::endl << std::endl << std::endl; + std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << std::endl; + std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << std::endl + << std::endl + << std::endl; - std::cout << "Average Grid size: " << static_cast - (myBSSystem->getSumGridPointsComplete()) / static_cast - (numTimesteps) << std::endl; - std::cout << "Average Grid size (Inner): " << static_cast - (myBSSystem->getSumGridPointsInner()) / static_cast - (numTimesteps) << std::endl << std::endl << std::endl; + std::cout << "Average Grid size: " + << static_cast(myBSSystem->getSumGridPointsComplete()) / + static_cast(numTimesteps) + << std::endl; + std::cout << "Average Grid size (Inner): " + << static_cast(myBSSystem->getSumGridPointsInner()) / + static_cast(numTimesteps) + << std::endl + << std::endl + << std::endl; if (this->myScreen != NULL) { std::cout << "Time to solve: " << this->dNeededTime << " seconds" << std::endl; @@ -968,11 +978,11 @@ void BlackScholesSolver::solveCrankNicolson(size_t numTimesteps, } this->finInnerGridSize = getNumberInnerGridPoints(); - this->avgInnerGridSize = static_cast((static_cast - (myBSSystem->getSumGridPointsInner()) / static_cast - (numTimesteps)) + 0.5); - this->nNeededIterations = myEuler->getNumberIterations() + - myCN->getNumberIterations(); + this->avgInnerGridSize = + static_cast((static_cast(myBSSystem->getSumGridPointsInner()) / + static_cast(numTimesteps)) + + 0.5); + this->nNeededIterations = myEuler->getNumberIterations() + myCN->getNumberIterations(); delete myBSSystem; delete myCG; @@ -982,29 +992,29 @@ void BlackScholesSolver::solveCrankNicolson(size_t numTimesteps, this->current_time += (static_cast(numTimesteps) * timestepsize); } else { - throw new application_exception("BlackScholesSolver::solveCrankNicolson : A grid wasn't constructed before or stochastic parameters weren't set!"); + throw new base::application_exception( + "BlackScholesSolver::solveCrankNicolson : A grid wasn't constructed before or stochastic " + "parameters weren't set!"); } } - -void BlackScholesSolver::solveAdamsBashforth(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose) { - ODESolver* myODESolver = new AdamsBashforth(numTimesteps, timestepsize, - myScreen); - BlackScholesSolver::solveX(numTimesteps, timestepsize, maxCGIterations, - epsilonCG, alpha, verbose, myODESolver, "AdBas"); +void BlackScholesSolver::solveAdamsBashforth(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose) { + solver::ODESolver* myODESolver = new solver::AdamsBashforth(numTimesteps, timestepsize, myScreen); + BlackScholesSolver::solveX(numTimesteps, timestepsize, maxCGIterations, epsilonCG, alpha, verbose, + myODESolver, "AdBas"); delete myODESolver; } -void BlackScholesSolver::solveSC(std::string Solver, size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose) { +void BlackScholesSolver::solveSC(std::string Solver, size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, base::DataVector& alpha, + bool verbose) { std::string tmp; - float epsilon = float(0.001); + float epsilon = 0.001f; float sc = 1; float gamma = 0.5; - ODESolver* myODESolver = NULL; + solver::ODESolver* myODESolver = NULL; std::istringstream iss(Solver); if (Solver[2] == '2') { @@ -1013,10 +1023,13 @@ void BlackScholesSolver::solveSC(std::string Solver, size_t numTimesteps, std::istringstream qwe(tmp); qwe >> epsilon; iss >> gamma; - std::cout << "2 " << "AdBas" << ", " << "CrNic" << " Epsilon: " << epsilon << - " Gamma: " << gamma << std::endl; - myODESolver = new VarTimestep("AdBas", "CrNic", numTimesteps, timestepsize, - epsilon, myScreen, gamma); + std::cout << "2 " + << "AdBas" + << ", " + << "CrNic" + << " Epsilon: " << epsilon << " Gamma: " << gamma << std::endl; + myODESolver = new solver::VarTimestep("AdBas", "CrNic", numTimesteps, timestepsize, epsilon, + myScreen, gamma); } else if (Solver[2] == 'H') { getline(iss, tmp, ':'); @@ -1024,11 +1037,11 @@ void BlackScholesSolver::solveSC(std::string Solver, size_t numTimesteps, std::istringstream qwe(tmp); qwe >> epsilon; iss >> gamma; - std::cout << "H " << "CrNic" << " Epsilon: " << epsilon << " Gamma: " << - gamma << std::endl; - myODESolver = new StepsizeControlH("CrNic", numTimesteps, timestepsize, epsilon, - myScreen, gamma); - + std::cout << "H " + << "CrNic" + << " Epsilon: " << epsilon << " Gamma: " << gamma << std::endl; + myODESolver = + new solver::StepsizeControlH("CrNic", numTimesteps, timestepsize, epsilon, myScreen, gamma); } else if (Solver[2] == 'I') { getline(iss, tmp, ':'); @@ -1039,93 +1052,94 @@ void BlackScholesSolver::solveSC(std::string Solver, size_t numTimesteps, std::istringstream qwe2(tmp); qwe >> sc; iss >> gamma; - std::cout << "I " << " Epsilon: " << epsilon << " SC: " << sc << " Gamma: " - << gamma << std::endl; - myODESolver = new StepsizeControlEJ("CrNic", numTimesteps, timestepsize, - epsilon, sc, myScreen, gamma); + std::cout << "I " + << " Epsilon: " << epsilon << " SC: " << sc << " Gamma: " << gamma << std::endl; + myODESolver = new solver::StepsizeControlEJ("CrNic", numTimesteps, timestepsize, epsilon, sc, + myScreen, gamma); - } else std::cerr << "BlackScholesSolver::solveSC(): Unknown Stepsize Control #" - << Solver[3] << "#" << Solver << std::endl; + } else { + std::cerr << "BlackScholesSolver::solveSC(): Unknown Stepsize Control #" << Solver[3] << "#" + << Solver << std::endl; + } - BlackScholesSolver::solveX(numTimesteps, timestepsize, maxCGIterations, - epsilonCG, alpha, verbose, myODESolver, "CrNic"); + BlackScholesSolver::solveX(numTimesteps, timestepsize, maxCGIterations, epsilonCG, alpha, verbose, + myODESolver, "CrNic"); - if (myODESolver != NULL) - delete myODESolver; + if (myODESolver != NULL) delete myODESolver; } -void BlackScholesSolver::solveSCAC(size_t numTimesteps, float_t timestepsize, - float_t epsilon, size_t maxCGIterations, float_t epsilonCG, DataVector& alpha, - bool verbose) { - ODESolver* myODESolver = new VarTimestep("AdBasC", "CrNic", numTimesteps, - timestepsize, epsilon, myScreen, -1); - BlackScholesSolver::solveX(numTimesteps, timestepsize, maxCGIterations, - epsilonCG, alpha, verbose, myODESolver, "CrNic"); +void BlackScholesSolver::solveSCAC(size_t numTimesteps, float_t timestepsize, float_t epsilon, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose) { + solver::ODESolver* myODESolver = + new solver::VarTimestep("AdBasC", "CrNic", numTimesteps, timestepsize, epsilon, myScreen, -1); + BlackScholesSolver::solveX(numTimesteps, timestepsize, maxCGIterations, epsilonCG, alpha, verbose, + myODESolver, "CrNic"); delete myODESolver; } -void BlackScholesSolver::solveSCH(size_t numTimesteps, float_t timestepsize, - float_t epsilon, size_t maxCGIterations, float_t epsilonCG, DataVector& alpha, - bool verbose) { - ODESolver* myODESolver = new StepsizeControlH("CrNic", numTimesteps, - timestepsize, epsilon, myScreen, 0.9); - BlackScholesSolver::solveX(numTimesteps, timestepsize, maxCGIterations, - epsilonCG, alpha, verbose, myODESolver, "CrNic"); +void BlackScholesSolver::solveSCH(size_t numTimesteps, float_t timestepsize, float_t epsilon, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose) { + solver::ODESolver* myODESolver = + new solver::StepsizeControlH("CrNic", numTimesteps, timestepsize, epsilon, myScreen, 0.9); + BlackScholesSolver::solveX(numTimesteps, timestepsize, maxCGIterations, epsilonCG, alpha, verbose, + myODESolver, "CrNic"); delete myODESolver; } -void BlackScholesSolver::solveSCBDF(size_t numTimesteps, float_t timestepsize, - float_t epsilon, size_t maxCGIterations, float_t epsilonCG, DataVector& alpha, - bool verbose) { - ODESolver* myODESolver = new StepsizeControlBDF(numTimesteps, timestepsize, - epsilon, myScreen); - BlackScholesSolver::solveX(numTimesteps, timestepsize, maxCGIterations, - epsilonCG, alpha, verbose, myODESolver, "SCBDF"); +void BlackScholesSolver::solveSCBDF(size_t numTimesteps, float_t timestepsize, float_t epsilon, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose) { + solver::ODESolver* myODESolver = + new solver::StepsizeControlBDF(numTimesteps, timestepsize, epsilon, myScreen); + BlackScholesSolver::solveX(numTimesteps, timestepsize, maxCGIterations, epsilonCG, alpha, verbose, + myODESolver, "SCBDF"); delete myODESolver; } -void BlackScholesSolver::solveSCEJ(size_t numTimesteps, float_t timestepsize, - float_t epsilon, float_t myAlpha, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose) { - ODESolver* myODESolver = new StepsizeControlEJ("CrNic", numTimesteps, - timestepsize, epsilon, myAlpha, myScreen, 0.5); - BlackScholesSolver::solveX(numTimesteps, timestepsize, maxCGIterations, - epsilonCG, alpha, verbose, myODESolver, "SCEJ"); +void BlackScholesSolver::solveSCEJ(size_t numTimesteps, float_t timestepsize, float_t epsilon, + float_t myAlpha, size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose) { + solver::ODESolver* myODESolver = new solver::StepsizeControlEJ( + "CrNic", numTimesteps, timestepsize, epsilon, myAlpha, myScreen, 0.5); + BlackScholesSolver::solveX(numTimesteps, timestepsize, maxCGIterations, epsilonCG, alpha, verbose, + myODESolver, "SCEJ"); delete myODESolver; } -void BlackScholesSolver::solveX(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, DataVector& alpha, bool verbose, +void BlackScholesSolver::solveX(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, base::DataVector& alpha, bool verbose, void* myODESolverV, std::string Solver) { - ODESolver* myODESolver = (ODESolver*)myODESolverV; + solver::ODESolver* myODESolver = reinterpret_cast(myODESolverV); if (this->bGridConstructed && this->bStochasticDataAlloc) { - BiCGStab* myCG = new BiCGStab(maxCGIterations, epsilonCG); - OperationParabolicPDESolverSystem* myBSSystem = NULL; + solver::BiCGStab* myCG = new solver::BiCGStab(maxCGIterations, epsilonCG); + solver::OperationParabolicPDESolverSystem* myBSSystem = NULL; if (this->tBoundaryType == "Dirichlet") { #ifdef _OPENMP myBSSystem = new BlackScholesParabolicPDESolverSystemEuroAmerParallelOMP( - *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, - timestepsize, Solver, this->dStrike, this->payoffType, this->useLogTransform, - false, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, - this->refineThreshold, this->refineMode, this->refineMaxLevel); + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + Solver, this->dStrike, this->payoffType, this->useLogTransform, false, + this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); #else - myBSSystem = new BlackScholesParabolicPDESolverSystemEuroAmer(*this->myGrid, - alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, Solver, - this->dStrike, this->payoffType, this->useLogTransform, false, + myBSSystem = new BlackScholesParabolicPDESolverSystemEuroAmer( + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + Solver, this->dStrike, this->payoffType, this->useLogTransform, false, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, this->refineMode, this->refineMaxLevel); #endif } else { - myBSSystem = new BlackScholesParabolicPDESolverSystem(*this->myGrid, alpha, - *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, Solver, - this->dStrike, this->payoffType, this->useLogTransform, false, + myBSSystem = new BlackScholesParabolicPDESolverSystem( + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + Solver, this->dStrike, this->payoffType, this->useLogTransform, false, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, this->refineThreshold, this->refineMode, this->refineMaxLevel); } - SGppStopwatch* myStopwatch = new SGppStopwatch(); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); this->staInnerGridSize = getNumberInnerGridPoints(); myStopwatch->start(); @@ -1138,9 +1152,10 @@ void BlackScholesSolver::solveX(size_t numTimesteps, float_t timestepsize, } this->finInnerGridSize = getNumberInnerGridPoints(); - this->avgInnerGridSize = static_cast((static_cast - (myBSSystem->getSumGridPointsInner()) / static_cast - (numTimesteps)) + 0.5); + this->avgInnerGridSize = + static_cast((static_cast(myBSSystem->getSumGridPointsInner()) / + static_cast(numTimesteps)) + + 0.5); this->nNeededIterations = myODESolver->getNumberIterations(); delete myBSSystem; @@ -1148,18 +1163,19 @@ void BlackScholesSolver::solveX(size_t numTimesteps, float_t timestepsize, this->current_time += (static_cast(numTimesteps) * timestepsize); } else { - throw new application_exception("BlackScholesSolver::solveX : A grid wasn't constructed before or stochastic parameters weren't set!"); + throw new base::application_exception( + "BlackScholesSolver::solveX : A grid wasn't constructed before or stochastic parameters " + "weren't set!"); } } - -void BlackScholesSolver::initGridWithPayoff(DataVector& alpha, float_t strike, - std::string payoffType) { +void BlackScholesSolver::initGridWithPayoff(base::DataVector& alpha, float_t strike, + std::string payoffType) { this->dStrike = strike; this->payoffType = payoffType; - if (payoffType == "std_euro_call" || payoffType == "std_euro_put" - || payoffType == "std_amer_put") { + if (payoffType == "std_euro_call" || payoffType == "std_euro_put" || + payoffType == "std_amer_put") { this->tBoundaryType = "Dirichlet"; } @@ -1174,8 +1190,7 @@ void BlackScholesSolver::initGridWithPayoff(DataVector& alpha, float_t strike, } } -float_t BlackScholesSolver::get1DEuroCallPayoffValue(float_t assetValue, - float_t strike) { +float_t BlackScholesSolver::get1DEuroCallPayoffValue(float_t assetValue, float_t strike) { if (assetValue <= strike) { return 0.0; } else { @@ -1183,27 +1198,25 @@ float_t BlackScholesSolver::get1DEuroCallPayoffValue(float_t assetValue, } } -float_t BlackScholesSolver::getAnalyticSolution1D(float_t stock, bool isCall, - float_t t, float_t vola, float_t r, float_t strike) { - StdNormalDistribution myStdNDis; +float_t BlackScholesSolver::getAnalyticSolution1D(float_t stock, bool isCall, float_t t, + float_t vola, float_t r, float_t strike) { + base::StdNormalDistribution myStdNDis; - float_t dOne = (log((stock / strike)) + ((r + (vola * vola * 0.5)) * (t))) / - (vola * sqrt(t)); + float_t dOne = (log((stock / strike)) + ((r + (vola * vola * 0.5)) * (t))) / (vola * sqrt(t)); float_t dTwo = dOne - (vola * sqrt(t)); if (isCall) { return (stock * myStdNDis.getCumulativeDensity(dOne)) - (strike * myStdNDis.getCumulativeDensity(dTwo) * (exp((-1.0) * r * t))); } else { - return (strike * myStdNDis.getCumulativeDensity(dTwo * (-1.0)) * (exp(( - -1.0) * r * t))) - (stock * myStdNDis.getCumulativeDensity(dOne * (-1.0))); + return (strike * myStdNDis.getCumulativeDensity(dTwo * (-1.0)) * (exp((-1.0) * r * t))) - + (stock * myStdNDis.getCumulativeDensity(dOne * (-1.0))); } } - -void BlackScholesSolver::solve1DAnalytic( - std::vector< std::pair >& premiums, float_t minStock, - float_t maxStock, float_t StockInc, float_t strike, float_t t, bool isCall) { +void BlackScholesSolver::solve1DAnalytic(std::vector >& premiums, + float_t minStock, float_t maxStock, float_t StockInc, + float_t strike, float_t t, bool isCall) { if (bStochasticDataAlloc) { float_t stock = 0.0; float_t vola = this->sigmas->get(0); @@ -1213,42 +1226,42 @@ void BlackScholesSolver::solve1DAnalytic( premiums.push_back(std::make_pair(stock, prem)); } } else { - throw new application_exception("BlackScholesSolver::solve1DAnalytic : Stochastic parameters weren't set!"); + throw new base::application_exception( + "BlackScholesSolver::solve1DAnalytic : Stochastic parameters weren't set!"); } } -void BlackScholesSolver::print1DAnalytic( - std::vector< std::pair >& premiums, std::string tfilename) { - typedef std::vector< std::pair > printVector; +void BlackScholesSolver::print1DAnalytic(std::vector >& premiums, + std::string tfilename) { + typedef std::vector > printVector; std::ofstream fileout; fileout.open(tfilename.c_str()); - for (printVector::iterator iter = premiums.begin(); iter != premiums.end(); - iter++) { + for (printVector::iterator iter = premiums.begin(); iter != premiums.end(); iter++) { fileout << iter->first << " " << iter->second << " " << std::endl; } fileout.close(); } - -void BlackScholesSolver::getAnalyticAlpha1D(DataVector& alpha_analytic, - float_t strike, float_t t, std::string payoffType, bool hierarchized) { +void BlackScholesSolver::getAnalyticAlpha1D(base::DataVector& alpha_analytic, float_t strike, + float_t t, std::string payoffType, bool hierarchized) { float_t coord; if (dim != 1) { - throw new application_exception("BlackScholesSolver::getAnalyticAlpha1D : A grid wasn't constructed before!"); + throw new base::application_exception( + "BlackScholesSolver::getAnalyticAlpha1D : A grid wasn't constructed before!"); } if (!this->bGridConstructed) { - throw new application_exception("BlackScholesSolver::getAnalyticAlpha1D : function only available for dim = 1!"); + throw new base::application_exception( + "BlackScholesSolver::getAnalyticAlpha1D : function only available for dim = 1!"); } // compute values of analytic solution on given grid for (size_t i = 0; i < this->myGridStorage->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); coordsStream >> coord; @@ -1257,36 +1270,38 @@ void BlackScholesSolver::getAnalyticAlpha1D(DataVector& alpha_analytic, } if (payoffType == "std_euro_call") { - alpha_analytic[i] = getAnalyticSolution1D(coord, true, t, this->sigmas->get(0), - this->r, strike); + alpha_analytic[i] = + getAnalyticSolution1D(coord, true, t, this->sigmas->get(0), this->r, strike); } else if (payoffType == "std_euro_put") { - alpha_analytic[i] = getAnalyticSolution1D(coord, false, t, this->sigmas->get(0), - this->r, strike); + alpha_analytic[i] = + getAnalyticSolution1D(coord, false, t, this->sigmas->get(0), this->r, strike); } } if (hierarchized) { // hierarchize computed values - OperationHierarchisation* myHier = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHier = + op_factory::createOperationHierarchisation(*this->myGrid); myHier->doHierarchisation(alpha_analytic); delete myHier; } } - -void BlackScholesSolver::evaluate1DAnalyticCuboid(SGPP::base::DataVector& - AnalyticOptionPrices, SGPP::base::DataMatrix& EvaluationPoints, float_t strike, - float_t vola, float_t r, float_t t, bool isCall) { +void BlackScholesSolver::evaluate1DAnalyticCuboid(base::DataVector& AnalyticOptionPrices, + base::DataMatrix& EvaluationPoints, + float_t strike, float_t vola, float_t r, + float_t t, bool isCall) { size_t n = EvaluationPoints.getNrows(); if (AnalyticOptionPrices.getSize() != n) { - throw new SGPP::base::application_exception("PDESolver::evaluate1DAnalyticCuboid : The size of the price vector doesn't match the size of the evaluation points' vector!"); + throw new base::application_exception( + "PDESolver::evaluate1DAnalyticCuboid : The size of the price vector doesn't match the size " + "of the evaluation points' vector!"); } for (size_t k = 0; k < n; k++) { - float_t x = EvaluationPoints.get(k, 0); // get first coordinate + float_t x = EvaluationPoints.get(k, 0); // get first coordinate if (this->useLogTransform) { x = exp(x); @@ -1301,25 +1316,27 @@ std::vector BlackScholesSolver::getAlgorithmicDimensions() { return this->myGrid->getAlgorithmicDimensions(); } -void BlackScholesSolver::setAlgorithmicDimensions(std::vector - newAlgoDims) { +void BlackScholesSolver::setAlgorithmicDimensions(std::vector newAlgoDims) { if (this->tBoundaryType == "freeBoundaries") { this->myGrid->setAlgorithmicDimensions(newAlgoDims); } else { - throw new application_exception("BlackScholesSolver::setAlgorithmicDimensions : Set algorithmic dimensions is only supported when choosing option type all!"); + throw new base::application_exception( + "BlackScholesSolver::setAlgorithmicDimensions : Set algorithmic dimensions is only " + "supported when choosing option type all!"); } } void BlackScholesSolver::initScreen() { - this->myScreen = new ScreenOutput(); + this->myScreen = new base::ScreenOutput(); this->myScreen->writeTitle("SGpp - Black Scholes Solver, 2.0.0", "The SG++ Project (C) 2009-2010, by Alexander Heinecke"); this->myScreen->writeStartSolve("Multidimensional Black Scholes Solver"); } -void BlackScholesSolver::setEnableCoarseningData(std::string adaptSolveMode, - std::string refineMode, SGPP::base::GridIndex::level_type refineMaxLevel, - int numCoarsenPoints, float_t coarsenThreshold, float_t refineThreshold) { +void BlackScholesSolver::setEnableCoarseningData(std::string adaptSolveMode, std::string refineMode, + base::GridIndex::level_type refineMaxLevel, + int numCoarsenPoints, float_t coarsenThreshold, + float_t refineThreshold) { this->useCoarsen = true; this->coarsenThreshold = coarsenThreshold; this->refineThreshold = refineThreshold; @@ -1329,13 +1346,13 @@ void BlackScholesSolver::setEnableCoarseningData(std::string adaptSolveMode, this->numCoarsenPoints = numCoarsenPoints; } -void BlackScholesSolver::printPayoffInterpolationError2D(DataVector& alpha, - std::string tFilename, size_t numTestpoints, float_t strike) { +void BlackScholesSolver::printPayoffInterpolationError2D(base::DataVector& alpha, + std::string tFilename, + size_t numTestpoints, float_t strike) { if (this->useLogTransform == false) { if (this->bGridConstructed) { if (this->myGrid->getStorage()->getBoundingBox()->getDimensions() == 2) { - if (numTestpoints < 2) - numTestpoints = 2; + if (numTestpoints < 2) numTestpoints = 2; float_t dInc = (2.0 * strike) / static_cast(numTestpoints - 1); @@ -1345,7 +1362,7 @@ void BlackScholesSolver::printPayoffInterpolationError2D(DataVector& alpha, std::ofstream file; file.open(tFilename.c_str()); - OperationEval* myEval = SGPP::op_factory::createOperationEval(*this->myGrid); + base::OperationEval* myEval = op_factory::createOperationEval(*this->myGrid); for (size_t i = 0; i < numTestpoints; i++) { std::vector point; @@ -1355,8 +1372,8 @@ void BlackScholesSolver::printPayoffInterpolationError2D(DataVector& alpha, float_t result = myEval->eval(alpha, point); - file << std::scientific << std::setprecision( 16 ) << dX << " " << dY << " " << - result << std::endl; + file << std::scientific << std::setprecision(16) << dX << " " << dY << " " << result + << std::endl; dX += dInc; dY -= dInc; @@ -1367,33 +1384,34 @@ void BlackScholesSolver::printPayoffInterpolationError2D(DataVector& alpha, file.close(); } } else { - throw new application_exception("BlackScholesSolver::getPayoffInterpolationError : A grid wasn't constructed before!"); + throw new base::application_exception( + "BlackScholesSolver::getPayoffInterpolationError : A grid wasn't constructed before!"); } } } -size_t BlackScholesSolver::getGridPointsAtMoney(std::string payoffType, - float_t strike, float_t eps) { +size_t BlackScholesSolver::getGridPointsAtMoney(std::string payoffType, float_t strike, + float_t eps) { size_t nPoints = 0; if (this->useLogTransform == false) { if (this->bGridConstructed) { for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { bool isAtMoney = true; - DataVector coords(this->dim); + base::DataVector coords(this->dim); this->myGridStorage->get(i)->getCoordsBB(coords, *this->myBoundingBox); - if (payoffType == "std_euro_call" || payoffType == "std_euro_put" - || payoffType == "std_amer_put") { + if (payoffType == "std_euro_call" || payoffType == "std_euro_put" || + payoffType == "std_amer_put") { for (size_t d = 0; d < this->dim; d++) { - if ( ((coords.sum() / static_cast(this->dim)) < (strike - eps)) - || ((coords.sum() / static_cast(this->dim)) > (strike + eps)) ) { + if (((coords.sum() / static_cast(this->dim)) < (strike - eps)) || + ((coords.sum() / static_cast(this->dim)) > (strike + eps))) { isAtMoney = false; } - } } else { - throw new application_exception("BlackScholesSolver::getGridPointsAtMoney : An unknown payoff-type was specified!"); + throw new base::application_exception( + "BlackScholesSolver::getGridPointsAtMoney : An unknown payoff-type was specified!"); } if (isAtMoney == true) { @@ -1401,21 +1419,21 @@ size_t BlackScholesSolver::getGridPointsAtMoney(std::string payoffType, } } } else { - throw new application_exception("BlackScholesSolver::getGridPointsAtMoney : A grid wasn't constructed before!"); + throw new base::application_exception( + "BlackScholesSolver::getGridPointsAtMoney : A grid wasn't constructed before!"); } } return nPoints; } -void BlackScholesSolver::initCartesianGridWithPayoff(DataVector& alpha, - float_t strike, std::string payoffType) { +void BlackScholesSolver::initCartesianGridWithPayoff(base::DataVector& alpha, float_t strike, + std::string payoffType) { float_t tmp; if (this->bGridConstructed) { for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); float_t* dblFuncValues = new float_t[dim]; @@ -1442,29 +1460,31 @@ void BlackScholesSolver::initCartesianGridWithPayoff(DataVector& alpha, alpha[i] = std::max(strike - ((tmp / static_cast(dim))), 0.0); } else { - throw new application_exception("BlackScholesSolver::initCartesianGridWithPayoff : An unknown payoff-type was specified!"); + throw new base::application_exception( + "BlackScholesSolver::initCartesianGridWithPayoff : An unknown payoff-type was " + "specified!"); } delete[] dblFuncValues; } - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("BlackScholesSolver::initCartesianGridWithPayoff : A grid wasn't constructed before!"); + throw new base::application_exception( + "BlackScholesSolver::initCartesianGridWithPayoff : A grid wasn't constructed before!"); } } -void BlackScholesSolver::initLogTransformedGridWithPayoff(DataVector& alpha, - float_t strike, std::string payoffType) { +void BlackScholesSolver::initLogTransformedGridWithPayoff(base::DataVector& alpha, float_t strike, + std::string payoffType) { float_t tmp; if (this->bGridConstructed) { for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); float_t* dblFuncValues = new float_t[dim]; @@ -1491,29 +1511,31 @@ void BlackScholesSolver::initLogTransformedGridWithPayoff(DataVector& alpha, alpha[i] = std::max(strike - ((tmp / static_cast(dim))), 0.0); } else { - throw new application_exception("BlackScholesSolver::initLogTransformedGridWithPayoff : An unknown payoff-type was specified!"); + throw new base::application_exception( + "BlackScholesSolver::initLogTransformedGridWithPayoff : An unknown payoff-type was " + "specified!"); } delete[] dblFuncValues; } - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("BlackScholesSolver::initLogTransformedGridWithPayoff : A grid wasn't constructed before!"); + throw new base::application_exception( + "BlackScholesSolver::initLogTransformedGridWithPayoff : A grid wasn't constructed before!"); } } -void BlackScholesSolver::initPATTransformedGridWithPayoff(DataVector& alpha, - float_t strike, std::string payoffType) { +void BlackScholesSolver::initPATTransformedGridWithPayoff(base::DataVector& alpha, float_t strike, + std::string payoffType) { float_t tmp; if (this->bGridConstructed) { for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); float_t* dblFuncValues = new float_t[dim]; @@ -1552,23 +1574,25 @@ void BlackScholesSolver::initPATTransformedGridWithPayoff(DataVector& alpha, alpha[i] = std::max(strike - ((tmp / static_cast(dim))), 0.0); } else { - throw new application_exception("BlackScholesSolver::initPATTransformedGridWithPayoff : An unknown payoff-type was specified!"); + throw new base::application_exception( + "BlackScholesSolver::initPATTransformedGridWithPayoff : An unknown payoff-type was " + "specified!"); } delete[] dblFuncValues; } - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("BlackScholesSolver::initPATTransformedGridWithPayoff : A grid wasn't constructed before!"); + throw new base::application_exception( + "BlackScholesSolver::initPATTransformedGridWithPayoff : A grid wasn't constructed before!"); } } -float_t BlackScholesSolver::evalOption(std::vector& eval_point, - SGPP::base::DataVector& alpha) { +float_t BlackScholesSolver::evalOption(std::vector& eval_point, base::DataVector& alpha) { std::vector trans_eval = eval_point; // apply needed coordinate transformations @@ -1592,8 +1616,7 @@ float_t BlackScholesSolver::evalOption(std::vector& eval_point, } } - SGPP::base::OperationEval* myEval = SGPP::op_factory::createOperationEval( - *this->myGrid); + base::OperationEval* myEval = op_factory::createOperationEval(*this->myGrid); float_t result = myEval->eval(alpha, trans_eval); delete myEval; @@ -1605,8 +1628,8 @@ float_t BlackScholesSolver::evalOption(std::vector& eval_point, return result; } -void BlackScholesSolver::transformPoint(SGPP::base::DataVector& point) { - SGPP::base::DataVector tmp_point(point); +void BlackScholesSolver::transformPoint(base::DataVector& point) { + base::DataVector tmp_point(point); // apply needed coordinate transformations if (this->useLogTransform) { @@ -1632,17 +1655,16 @@ void BlackScholesSolver::transformPoint(SGPP::base::DataVector& point) { point = tmp_point; } -void BlackScholesSolver::printSparseGridPAT(SGPP::base::DataVector& alpha, - std::string tfilename, bool bSurplus) const { - DataVector temp(alpha); +void BlackScholesSolver::printSparseGridPAT(base::DataVector& alpha, std::string tfilename, + bool bSurplus) const { + base::DataVector temp(alpha); float_t tmp = 0.0; size_t dim = myGrid->getStorage()->dim(); std::ofstream fileout; // Do Dehierarchisation, is specified if (bSurplus == false) { - OperationHierarchisation* myHier = - SGPP::op_factory::createOperationHierarchisation(*myGrid); + base::OperationHierarchisation* myHier = op_factory::createOperationHierarchisation(*myGrid); myHier->doDehierarchisation(temp); delete myHier; } @@ -1651,8 +1673,7 @@ void BlackScholesSolver::printSparseGridPAT(SGPP::base::DataVector& alpha, fileout.open(tfilename.c_str()); for (size_t i = 0; i < myGrid->getStorage()->size(); i++) { - std::string coords = myGrid->getStorage()->get(i)->getCoordsStringBB( - *myGrid->getBoundingBox()); + std::string coords = myGrid->getStorage()->get(i)->getCoordsStringBB(*myGrid->getBoundingBox()); std::stringstream coordsStream(coords); float_t* dblFuncValues = new float_t[dim]; @@ -1666,8 +1687,8 @@ void BlackScholesSolver::printSparseGridPAT(SGPP::base::DataVector& alpha, float_t trans_point = 0.0; for (size_t j = 0; j < dim; j++) { - trans_point += this->eigvec_covar->get(l, - j) * (dblFuncValues[j] - (this->current_time * this->mu_hat->get(j))); + trans_point += this->eigvec_covar->get(l, j) * + (dblFuncValues[j] - (this->current_time * this->mu_hat->get(j))); } fileout << exp(trans_point) << " "; @@ -1681,44 +1702,32 @@ void BlackScholesSolver::printSparseGridPAT(SGPP::base::DataVector& alpha, fileout.close(); } -void BlackScholesSolver::resetSolveTime() { - this->current_time = 0.0; -} +void BlackScholesSolver::resetSolveTime() { this->current_time = 0.0; } -size_t BlackScholesSolver::getNeededIterationsToSolve() { - return this->nNeededIterations; -} +size_t BlackScholesSolver::getNeededIterationsToSolve() { return this->nNeededIterations; } -float_t BlackScholesSolver::getNeededTimeToSolve() { - return this->dNeededTime; -} +float_t BlackScholesSolver::getNeededTimeToSolve() { return this->dNeededTime; } -size_t BlackScholesSolver::getStartInnerGridSize() { - return this->staInnerGridSize; -} +size_t BlackScholesSolver::getStartInnerGridSize() { return this->staInnerGridSize; } -size_t BlackScholesSolver::getFinalInnerGridSize() { - return this->finInnerGridSize; -} +size_t BlackScholesSolver::getFinalInnerGridSize() { return this->finInnerGridSize; } -size_t BlackScholesSolver::getAverageInnerGridSize() { - return this->avgInnerGridSize; -} +size_t BlackScholesSolver::getAverageInnerGridSize() { return this->avgInnerGridSize; } -void BlackScholesSolver::storeInnerRHS(DataVector& alpha, std::string tFilename, +void BlackScholesSolver::storeInnerRHS(base::DataVector& alpha, std::string tFilename, float_t timestepsize) { if (this->bGridConstructed) { - OperationParabolicPDESolverSystemDirichlet* myBSSystem = new - BlackScholesParabolicPDESolverSystemEuroAmer(*this->myGrid, alpha, *this->mus, - *this->sigmas, *this->rhos, this->r, timestepsize, "ImEul", this->dStrike, - this->payoffType, this->useLogTransform, this->useCoarsen, - this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, - this->refineThreshold, this->refineMode, this->refineMaxLevel); - SGppStopwatch* myStopwatch = new SGppStopwatch(); + pde::OperationParabolicPDESolverSystemDirichlet* myBSSystem = + new BlackScholesParabolicPDESolverSystemEuroAmer( + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + "ImEul", this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, + this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); myStopwatch->start(); std::cout << "Exporting inner right-hand-side..." << std::endl; - DataVector* rhs_inner = myBSSystem->generateRHS(); + base::DataVector* rhs_inner = myBSSystem->generateRHS(); size_t nCoefs = rhs_inner->getSize(); std::ofstream outfile(tFilename.c_str()); @@ -1728,36 +1737,39 @@ void BlackScholesSolver::storeInnerRHS(DataVector& alpha, std::string tFilename, } outfile.close(); - std::cout << "Exporting inner right-hand-side... DONE! (" << myStopwatch->stop() - << " s)" << std::endl << std::endl << std::endl; + std::cout << "Exporting inner right-hand-side... DONE! (" << myStopwatch->stop() << " s)" + << std::endl + << std::endl + << std::endl; delete myStopwatch; delete myBSSystem; } else { - throw new application_exception("BlackScholesSolver::storeInnerMatrix : A grid wasn't constructed before!"); + throw new base::application_exception( + "BlackScholesSolver::storeInnerMatrix : A grid wasn't constructed before!"); } } -void BlackScholesSolver::storeInnerSolution(DataVector& alpha, - size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, - float_t epsilonCG, std::string tFilename) { +void BlackScholesSolver::storeInnerSolution(base::DataVector& alpha, size_t numTimesteps, + float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, std::string tFilename) { if (this->bGridConstructed) { - Euler* myEuler = new Euler("ImEul", numTimesteps, timestepsize, false, 0, - myScreen); - BiCGStab* myCG = new BiCGStab(maxCGIterations, epsilonCG); - OperationParabolicPDESolverSystemDirichlet* myBSSystem = new - BlackScholesParabolicPDESolverSystemEuroAmer(*this->myGrid, alpha, *this->mus, - *this->sigmas, *this->rhos, this->r, timestepsize, "ImEul", this->dStrike, - this->payoffType, this->useLogTransform, this->useCoarsen, - this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, - this->refineThreshold, this->refineMode, this->refineMaxLevel); - SGppStopwatch* myStopwatch = new SGppStopwatch(); + solver::Euler* myEuler = + new solver::Euler("ImEul", numTimesteps, timestepsize, false, 0, myScreen); + solver::BiCGStab* myCG = new solver::BiCGStab(maxCGIterations, epsilonCG); + pde::OperationParabolicPDESolverSystemDirichlet* myBSSystem = + new BlackScholesParabolicPDESolverSystemEuroAmer( + *this->myGrid, alpha, *this->mus, *this->sigmas, *this->rhos, this->r, timestepsize, + "ImEul", this->dStrike, this->payoffType, this->useLogTransform, this->useCoarsen, + this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); myStopwatch->start(); std::cout << "Exporting inner solution..." << std::endl; myEuler->solve(*myCG, *myBSSystem, false); - DataVector* alpha_solve = myBSSystem->getGridCoefficientsForCG(); + base::DataVector* alpha_solve = myBSSystem->getGridCoefficientsForCG(); size_t nCoefs = alpha_solve->getSize(); std::ofstream outfile(tFilename.c_str()); @@ -1774,10 +1786,9 @@ void BlackScholesSolver::storeInnerSolution(DataVector& alpha, delete myCG; delete myEuler; } else { - throw new application_exception("BlackScholesSolver::solveImplicitEuler : A grid wasn't constructed before!"); + throw new base::application_exception( + "BlackScholesSolver::solveImplicitEuler : A grid wasn't constructed before!"); } - -} - -} } +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/application/BlackScholesSolver.hpp b/finance/src/sgpp/finance/application/BlackScholesSolver.hpp index 03bf2ec594..4d8ef81ab7 100644 --- a/finance/src/sgpp/finance/application/BlackScholesSolver.hpp +++ b/finance/src/sgpp/finance/application/BlackScholesSolver.hpp @@ -6,7 +6,6 @@ #ifndef BLACKSCHOLESSOLVER_HPP #define BLACKSCHOLESSOLVER_HPP - #include #include @@ -21,21 +20,20 @@ #include #include +#include +#include + #include #include #include #include #include #include - -#include -#include - +#include namespace SGPP { namespace finance { - /** * This class provides a simple-to-use solver of the multi dimensional Black * Scholes Equation that uses Sparse Grids. @@ -72,7 +70,8 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { int numCoarsenPoints; /// identifies if the Black Scholes Equation should be solved on a log-transformed grid bool useLogTransform; - /// identifies if the Black Scholes Equation should be solved by using a principal axis transformation + /// identifies if the Black Scholes Equation should be solved by using a principal axis + /// transformation bool usePAT; /// max. level for refinement during solving SGPP::base::GridIndex::level_type refineMaxLevel; @@ -117,10 +116,11 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * * @param alpha the coefficient vector of the grid's ansatzfunctions * @param strike the option's strike - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available */ - virtual void initCartesianGridWithPayoff(SGPP::base::DataVector& alpha, - float_t strike, std::string payoffType); + virtual void initCartesianGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType); /** * Inits the alpha vector with a payoff function of an European call option or put option @@ -128,21 +128,24 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * * @param alpha the coefficient vector of the grid's ansatzfunctions * @param strike the option's strike - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available */ - virtual void initLogTransformedGridWithPayoff(SGPP::base::DataVector& alpha, - float_t strike, std::string payoffType); + virtual void initLogTransformedGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType); /** * Inits the alpha vector with a payoff function of an European call option or put option - * The grid is initialized based on log-transformed and a principal axis transformation coordinates! + * The grid is initialized based on log-transformed and a principal axis transformation + * coordinates! * * @param alpha the coefficient vector of the grid's ansatzfunctions * @param strike the option's strike - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available */ - virtual void initPATTransformedGridWithPayoff(SGPP::base::DataVector& alpha, - float_t strike, std::string payoffType); + virtual void initPATTransformedGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType); /** * This function calculates for every grid point the value @@ -151,21 +154,25 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * * This method is overwritten in order to support grids with logarithmic coordinates. * - * @param alpha contains dehierarchized sparse grid coefficients containing the values of the multi dimensional normal distribution after call + * @param alpha contains dehierarchized sparse grid coefficients containing the values of the + * multi dimensional normal distribution after call * @param norm_mu the expected values of the normal distribution for every grid dimension * @param norm_sigma the standard deviation of the normal distribution for every grid dimension */ virtual void getGridNormalDistribution(SGPP::base::DataVector& alpha, - std::vector& norm_mu, std::vector& norm_sigma); + std::vector& norm_mu, + std::vector& norm_sigma); public: /** * Std-Constructor of the solver * - * @param useLogTransform speciefies if a log transformed formulation should be used for solving BlackScholes Equation - * @param usePAT speciefies if a principal axis transformation (also enabling a log-transformation) should be used for solving BlackScholes Equation + * @param useLogTransform speciefies if a log transformed formulation should be used for solving + * BlackScholes Equation + * @param usePAT speciefies if a principal axis transformation (also enabling a + * log-transformation) should be used for solving BlackScholes Equation */ - BlackScholesSolver(bool useLogTransform = false, bool usePAT = false); + explicit BlackScholesSolver(bool useLogTransform = false, bool usePAT = false); /** * Std-Destructor of the solver @@ -183,13 +190,15 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * * Only on Cartesian grids! * - * @param alpha reference to a SGPP::base::DataVector object that contains the gird ansatzfunction's coefficients + * @param alpha reference to a SGPP::base::DataVector object that contains the gird + * ansatzfunction's coefficients * @param strike containing the option's strike * @param payoffType the type of payoff Function used ONLY supported: avgM - * @param dStrikeDistance the max. distance from "at the money" a point is allowed to have in order to get refined + * @param dStrikeDistance the max. distance from "at the money" a point is allowed to have in + * order to get refined */ - virtual void refineInitialGridWithPayoff(SGPP::base::DataVector& alpha, - float_t strike, std::string payoffType, float_t dStrikeDistance); + virtual void refineInitialGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType, float_t dStrikeDistance); /** * This function tries to refine the grid such that @@ -201,15 +210,18 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * * Only on Cartesian grids! * - * @param alpha reference to a SGPP::base::DataVector object that contains the gird ansatzfunction's coefficients + * @param alpha reference to a SGPP::base::DataVector object that contains the gird + * ansatzfunction's coefficients * @param strike containing the option's strike * @param payoffType the type of payoff Function used ONLY supported: avgM - * @param dStrikeDistance the max. distance from "at the money" a point is allowed to have in order to get refined + * @param dStrikeDistance the max. distance from "at the money" a point is allowed to have in + * order to get refined * @param maxLevel maximum level of refinement */ - virtual void refineInitialGridWithPayoffToMaxLevel(SGPP::base::DataVector& - alpha, float_t strike, std::string payoffType, float_t dStrikeDistance, - SGPP::base::GridIndex::level_type maxLevel); + virtual void refineInitialGridWithPayoffToMaxLevel(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType, + float_t dStrikeDistance, + SGPP::base::GridIndex::level_type maxLevel); /** * In order to solve the multi dimensional Black Scholes Equation you have to provided @@ -221,52 +233,47 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * @param rhos a SGPP::base::DataMatrix that contains the correlations between the underlyings * @param r the riskfree rate used in the market model */ - virtual void setStochasticData(SGPP::base::DataVector& mus, - SGPP::base::DataVector& sigmas, SGPP::base::DataMatrix& rhos, float_t r); + virtual void setStochasticData(SGPP::base::DataVector& mus, SGPP::base::DataVector& sigmas, + SGPP::base::DataMatrix& rhos, float_t r); - void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false, bool generateAnimation = false, - size_t numEvalsAnimation = 20); + void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, + bool generateAnimation = false, size_t numEvalsAnimation = 20); - void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false, bool generateAnimation = false, - size_t numEvalsAnimation = 20); + void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, + bool generateAnimation = false, size_t numEvalsAnimation = 20); - void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - size_t NumImEul = 0); + void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, size_t NumImEul = 0); - void solveX(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, - float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, - void* myODESolverV = NULL, std::string Solver = "ImEul"); + void solveX(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, + SGPP::base::DataVector& alpha, bool verbose = false, void* myODESolverV = NULL, + std::string Solver = "ImEul"); void solveSC(std::string Solver, size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false); - void solveAdamsBashforth(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false); + void solveAdamsBashforth(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false); - void solveSCAC(size_t numTimesteps, float_t timestepsize, float_t epsilon, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false); + void solveSCAC(size_t numTimesteps, float_t timestepsize, float_t epsilon, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false); - void solveSCH(size_t numTimesteps, float_t timestepsize, float_t epsilon, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false); + void solveSCH(size_t numTimesteps, float_t timestepsize, float_t epsilon, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false); void solveSCBDF(size_t numTimesteps, float_t timestepsize, float_t epsilon, size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false); - void solveSCEJ(size_t numTimesteps, float_t timestepsize, float_t epsilon, - float_t myAlpha, size_t maxCGIterations, float_t epsilonCG, - SGPP::base::DataVector& alpha, bool verbose = false); + void solveSCEJ(size_t numTimesteps, float_t timestepsize, float_t epsilon, float_t myAlpha, + size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, + bool verbose = false); - //void solveSCMC(size_t numTimesteps, float_t timestepsize, float_t epsilon, size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false); + // void solveSCMC(size_t numTimesteps, float_t timestepsize, float_t epsilon, size_t + // maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false); /** * evaluates the analytic solution of the 1D Black Scholes equation @@ -279,8 +286,8 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * * @returns the option price for the given stock value */ - float_t getAnalyticSolution1D(float_t stock, bool isCall, float_t t, - float_t vola, float_t r, float_t strike); + float_t getAnalyticSolution1D(float_t stock, bool isCall, float_t t, float_t vola, float_t r, + float_t strike); /** * Solves the closed form of the Black Scholes equation, the Black Scholes @@ -297,9 +304,8 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * @param t time to maturity * @param isCall set this to true to calculate call, false calculates put */ - void solve1DAnalytic(std::vector< std::pair >& premiums, - float_t minStock, float_t maxStock, float_t StockInc, float_t strike, float_t t, - bool isCall); + void solve1DAnalytic(std::vector >& premiums, float_t minStock, + float_t maxStock, float_t StockInc, float_t strike, float_t t, bool isCall); /** * Writes the premiums into a file that can be easily plot with gnuplot @@ -307,27 +313,31 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * @param premiums the result vector, here the combinations of stock price and premium are stored * @param tfilename absolute path to file into which the grid's evaluation is written */ - void print1DAnalytic(std::vector< std::pair >& premiums, - std::string tfilename); + void print1DAnalytic(std::vector >& premiums, std::string tfilename); /** - * computes the relative error between the solution and the exact analytic solution for the 1-dimensional Black-Schoesl equation + * computes the relative error between the solution and the exact analytic solution for the + * 1-dimensional Black-Schoesl equation * * @param alpha_analytic data vector with the analytic solution * @param strike strike price of the option * @param t maturity time - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available - * @param hierarchized flag whether values should be hierarchized (true=hierarchized, false=dehierarchized) + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available + * @param hierarchized flag whether values should be hierarchized (true=hierarchized, + * false=dehierarchized) */ - virtual void getAnalyticAlpha1D(SGPP::base::DataVector& alpha_analytic, - float_t strike, float_t t, std::string payoffType, bool hierarchized); + virtual void getAnalyticAlpha1D(SGPP::base::DataVector& alpha_analytic, float_t strike, float_t t, + std::string payoffType, bool hierarchized); /** * Evaluates the analytic solution of the 1d Black Scholes equation * on different points specified in EvaluationPoints and stores the result into FunctionValues. * - * @param AnalyticOptionPrices SGPP::base::DataVector into the which the result of function's evaluation is stored - * @param EvaluationPoints SGPP::base::DataMatrix that contains the points at which the sparse grid's function is evaluated + * @param AnalyticOptionPrices SGPP::base::DataVector into the which the result of function's + * evaluation is stored + * @param EvaluationPoints SGPP::base::DataMatrix that contains the points at which the sparse + * grid's function is evaluated * @param strike the strike price of the Option * @param vola volatility * @param r risk-free rate @@ -335,21 +345,20 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * @param isCall set this to true to calculate call, false calculates put */ void evaluate1DAnalyticCuboid(SGPP::base::DataVector& AnalyticOptionPrices, - SGPP::base::DataMatrix& EvaluationPoints, float_t strike, float_t vola, - float_t r, float_t t, bool isCall); + SGPP::base::DataMatrix& EvaluationPoints, float_t strike, + float_t vola, float_t r, float_t t, bool isCall); /** * Inits the alpha vector with a payoff function of an European call option or put option * * @param alpha the coefficient vector of the grid's ansatzfunctions * @param strike the option's strike - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available */ virtual void initGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, std::string payoffType); - - /** * Inits the screen object */ @@ -383,12 +392,14 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * @param numCoarsenPoints number of points coarsened, -1 all coarsenable points are coarsened * @param refineThreshold Threshold needed to determine if a grid point should be refined */ - virtual void setEnableCoarseningData(std::string adaptSolveMode, - std::string refineMode, SGPP::base::GridIndex::level_type refineMaxLevel, - int numCoarsenPoints, float_t coarsenThreshold, float_t refineThreshold); + virtual void setEnableCoarseningData(std::string adaptSolveMode, std::string refineMode, + SGPP::base::GridIndex::level_type refineMaxLevel, + int numCoarsenPoints, float_t coarsenThreshold, + float_t refineThreshold); /** - * prints the 2D interpolation error at money into a file. This file is plotable via gnuplot. A bounding + * prints the 2D interpolation error at money into a file. This file is plotable via gnuplot. A + * bounding * box [0,x] X [0,y] is assumed. * * Only on Cartesian grids! @@ -398,8 +409,8 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * @param numTestpoints Number of equal distribute testpoints at money * @param strike the option's strike */ - virtual void printPayoffInterpolationError2D(SGPP::base::DataVector& alpha, - std::string tFilename, size_t numTestpoints, float_t strike); + virtual void printPayoffInterpolationError2D(SGPP::base::DataVector& alpha, std::string tFilename, + size_t numTestpoints, float_t strike); /** * Evaluates the current option value @@ -410,8 +421,7 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * * @return the option price at the given point */ - virtual float_t evalOption(std::vector& eval_point, - SGPP::base::DataVector& alpha); + virtual float_t evalOption(std::vector& eval_point, SGPP::base::DataVector& alpha); /** * This method transforms a point given @@ -431,7 +441,8 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { virtual void resetSolveTime(); /** - * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis value + * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis + * value * or their hierarchical surplus * * This function is available for all dimensions @@ -453,20 +464,21 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * @param eps epsilon to determine the gridpoints, use if at money is not exactly on grid * @return number of gridpoints at money */ - virtual size_t getGridPointsAtMoney(std::string payoffType, float_t strike, - float_t eps = 0.0); + virtual size_t getGridPointsAtMoney(std::string payoffType, float_t strike, float_t eps = 0.0); /** * gets the number needed iterations to solve Black Scholes Equation * - * @return number of iterations needed to solve Black Scholes Equation, if called before solving 0 is returned + * @return number of iterations needed to solve Black Scholes Equation, if called before solving 0 + * is returned */ virtual size_t getNeededIterationsToSolve(); /** * gets needed time in seconds to solve Black Scholes Equation * - * @return needed time in seconds to solve Black Scholes Equation, if called before solving 0 is returned + * @return needed time in seconds to solve Black Scholes Equation, if called before solving 0 is + * returned */ virtual float_t getNeededTimeToSolve(); @@ -499,8 +511,7 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * @param tFilename file into which the rhs is written * @param timestepsize the size of the timesteps */ - void storeInnerRHS(SGPP::base::DataVector& alpha, std::string tFilename, - float_t timestepsize); + void storeInnerRHS(SGPP::base::DataVector& alpha, std::string tFilename, float_t timestepsize); /** * Routine to export the solution of the inner system which @@ -513,12 +524,10 @@ class BlackScholesSolver : public SGPP::pde::ParabolicPDESolver { * @param epsilonCG the epsilon used in the C * @param tFilename file into which the rhs is written */ - void storeInnerSolution(SGPP::base::DataVector& alpha, size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - std::string tFilename); + void storeInnerSolution(SGPP::base::DataVector& alpha, size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, std::string tFilename); }; - -} -} +} // namespace finance +} // namespace SGPP #endif /* BLACKSCHOLESSOLVER_HPP */ diff --git a/finance/src/sgpp/finance/application/BlackScholesSolverWithStretching.cpp b/finance/src/sgpp/finance/application/BlackScholesSolverWithStretching.cpp index fca4fe0c8b..e770542b39 100644 --- a/finance/src/sgpp/finance/application/BlackScholesSolverWithStretching.cpp +++ b/finance/src/sgpp/finance/application/BlackScholesSolverWithStretching.cpp @@ -17,21 +17,24 @@ #include #include #include + +#include + #include #include #include #include #include - -#include - +#include +#include +#include namespace SGPP { namespace finance { -BlackScholesSolverWithStretching::BlackScholesSolverWithStretching( - bool useLogTransform, std::string OptionType) : BlackScholesSolver( - useLogTransform) { +BlackScholesSolverWithStretching::BlackScholesSolverWithStretching(bool useLogTransform, + std::string OptionType) + : BlackScholesSolver(useLogTransform) { this->bStochasticDataAlloc = false; this->bGridConstructed = false; this->myScreen = NULL; @@ -53,20 +56,19 @@ BlackScholesSolverWithStretching::BlackScholesSolverWithStretching( this->myStretching = NULL; } -BlackScholesSolverWithStretching::~BlackScholesSolverWithStretching() { -} +BlackScholesSolverWithStretching::~BlackScholesSolverWithStretching() {} -void BlackScholesSolverWithStretching::getGridNormalDistribution( - SGPP::base::DataVector& alpha, std::vector& norm_mu, - std::vector& norm_sigma) { +void BlackScholesSolverWithStretching::getGridNormalDistribution(SGPP::base::DataVector& alpha, + std::vector& norm_mu, + std::vector& norm_sigma) { if (this->bGridConstructed) { float_t tmp; float_t value; SGPP::base::StdNormalDistribution myNormDistr; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringStretching(* - (this->myStretching)); + std::string coords = + this->myGridStorage->get(i)->getCoordsStringStretching(*(this->myStretching)); std::stringstream coordsStream(coords); value = 1.0; @@ -84,13 +86,14 @@ void BlackScholesSolverWithStretching::getGridNormalDistribution( alpha[i] = value; } } else { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::getGridNormalDistribution : The grid wasn't initialized before!"); + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::getGridNormalDistribution : The grid wasn't initialized " + "before!"); } } - -void BlackScholesSolverWithStretching::constructGridStretching( - SGPP::base::Stretching& stretching, int level) { +void BlackScholesSolverWithStretching::constructGridStretching(SGPP::base::Stretching& stretching, + int level) { this->dim = stretching.getDimensions(); this->levels = level; @@ -103,21 +106,24 @@ void BlackScholesSolverWithStretching::constructGridStretching( this->myStretching = this->myGrid->getStretching(); this->myGridStorage = this->myGrid->getStorage(); - //std::string serGrid; - //myGrid->serialize(serGrid); - //std::cout << serGrid << std::endl; + // std::string serGrid; + // myGrid->serialize(serGrid); + // std::cout << serGrid << std::endl; this->bGridConstructed = true; } -void BlackScholesSolverWithStretching::constructGrid(SGPP::base::BoundingBox& - myBoundingBox, size_t level) { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::constructGrid : This solver does not support SGPP::base::BoundingBox, use constructGridStretching instead!"); +void BlackScholesSolverWithStretching::constructGrid(SGPP::base::BoundingBox& myBoundingBox, + size_t level) { + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::constructGrid : This solver does not support " + "SGPP::base::BoundingBox, use constructGridStretching instead!"); } -void BlackScholesSolverWithStretching::refineInitialGridWithPayoff( - SGPP::base::DataVector& alpha, float_t strike, std::string payoffType, - float_t dStrikeDistance) { +void BlackScholesSolverWithStretching::refineInitialGridWithPayoff(SGPP::base::DataVector& alpha, + float_t strike, + std::string payoffType, + float_t dStrikeDistance) { size_t nRefinements = 0; this->dStrike = strike; @@ -125,7 +131,6 @@ void BlackScholesSolverWithStretching::refineInitialGridWithPayoff( if (this->useLogTransform == false) { if (this->bGridConstructed) { - SGPP::base::DataVector refineVector(alpha.getSize()); if (payoffType == "std_euro_call" || payoffType == "std_euro_put") { @@ -136,8 +141,8 @@ void BlackScholesSolverWithStretching::refineInitialGridWithPayoff( float_t dDistance = 0.0; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringStretching(* - (this->myStretching)); + std::string coords = + this->myGridStorage->get(i)->getCoordsStringStretching(*(this->myStretching)); std::stringstream coordsStream(coords); for (size_t j = 0; j < this->dim; j++) { @@ -170,8 +175,8 @@ void BlackScholesSolverWithStretching::refineInitialGridWithPayoff( delete[] dblFuncValues; - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(&refineVector, nRefinements, 0.0); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = + new SGPP::base::SurplusRefinementFunctor(&refineVector, nRefinements, 0.0); this->myGrid->createGridGenerator()->refine(myRefineFunc); @@ -182,17 +187,21 @@ void BlackScholesSolverWithStretching::refineInitialGridWithPayoff( // reinit the grid with the payoff function initGridWithPayoff(alpha, strike, payoffType); } else { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::refineInitialGridWithPayoff : An unsupported payoffType was specified!"); + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::refineInitialGridWithPayoff : An unsupported " + "payoffType was specified!"); } } else { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::refineInitialGridWithPayoff : The grid wasn't initialized before!"); + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::refineInitialGridWithPayoff : The grid wasn't " + "initialized before!"); } } } void BlackScholesSolverWithStretching::refineInitialGridWithPayoffToMaxLevel( - SGPP::base::DataVector& alpha, float_t strike, std::string payoffType, - float_t dStrikeDistance, SGPP::base::GridIndex::level_type maxLevel) { + SGPP::base::DataVector& alpha, float_t strike, std::string payoffType, float_t dStrikeDistance, + SGPP::base::GridIndex::level_type maxLevel) { size_t nRefinements = 0; this->dStrike = strike; @@ -200,7 +209,6 @@ void BlackScholesSolverWithStretching::refineInitialGridWithPayoffToMaxLevel( if (this->useLogTransform == false) { if (this->bGridConstructed) { - SGPP::base::DataVector refineVector(alpha.getSize()); if (payoffType == "std_euro_call" || payoffType == "std_euro_put") { @@ -211,8 +219,8 @@ void BlackScholesSolverWithStretching::refineInitialGridWithPayoffToMaxLevel( float_t dDistance = 0.0; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringStretching( - *this->myStretching); + std::string coords = + this->myGridStorage->get(i)->getCoordsStringStretching(*this->myStretching); std::stringstream coordsStream(coords); for (size_t j = 0; j < this->dim; j++) { @@ -245,8 +253,8 @@ void BlackScholesSolverWithStretching::refineInitialGridWithPayoffToMaxLevel( delete[] dblFuncValues; - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(&refineVector, nRefinements, 0.0); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = + new SGPP::base::SurplusRefinementFunctor(&refineVector, nRefinements, 0.0); this->myGrid->createGridGenerator()->refineMaxLevel(myRefineFunc, maxLevel); @@ -257,22 +265,25 @@ void BlackScholesSolverWithStretching::refineInitialGridWithPayoffToMaxLevel( // reinit the grid with the payoff function initGridWithPayoff(alpha, strike, payoffType); } else { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::refineInitialGridWithPayoffToMaxLevel : An unsupported payoffType was specified!"); + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::refineInitialGridWithPayoffToMaxLevel : An " + "unsupported payoffType was specified!"); } } else { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::refineInitialGridWithPayoffToMaxLevel : The grid wasn't initialized before!"); + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::refineInitialGridWithPayoffToMaxLevel : The grid " + "wasn't initialized before!"); } } } - -void BlackScholesSolverWithStretching::initGridWithPayoff( - SGPP::base::DataVector& alpha, float_t strike, std::string payoffType) { +void BlackScholesSolverWithStretching::initGridWithPayoff(SGPP::base::DataVector& alpha, + float_t strike, std::string payoffType) { this->dStrike = strike; this->payoffType = payoffType; - if (payoffType == "std_euro_call" || payoffType == "std_euro_put" - || payoffType == "std_amer_put") { + if (payoffType == "std_euro_call" || payoffType == "std_euro_put" || + payoffType == "std_amer_put") { this->tBoundaryType = "Dirichlet"; } @@ -285,20 +296,19 @@ void BlackScholesSolverWithStretching::initGridWithPayoff( void BlackScholesSolverWithStretching::initScreen() { this->myScreen = new SGPP::base::ScreenOutput(); - this->myScreen->writeTitle("SGpp - Black Scholes Solver with SGPP::base::Stretching, 2.1.0", - "The SG++ Project (C) 2009-2010, by Alexander Heinecke and Sarpkan Selcuk"); - this->myScreen->writeStartSolve("Multidimensional Black Scholes Solver with SGPP::base::Stretching"); + this->myScreen->writeTitle( + "SGpp - Black Scholes Solver with SGPP::base::Stretching, 2.1.0", + "The SG++ Project (C) 2009-2010, by Alexander Heinecke and Sarpkan Selcuk"); + this->myScreen->writeStartSolve( + "Multidimensional Black Scholes Solver with SGPP::base::Stretching"); } - void BlackScholesSolverWithStretching::printPayoffInterpolationError2D( - SGPP::base::DataVector& alpha, std::string tFilename, size_t numTestpoints, - float_t strike) { + SGPP::base::DataVector& alpha, std::string tFilename, size_t numTestpoints, float_t strike) { if (this->useLogTransform == false) { if (this->bGridConstructed) { if (this->myGrid->getStorage()->getStretching()->getDimensions() == 2) { - if (numTestpoints < 2) - numTestpoints = 2; + if (numTestpoints < 2) numTestpoints = 2; float_t dInc = (2.0 * strike) / static_cast(numTestpoints - 1); @@ -308,8 +318,7 @@ void BlackScholesSolverWithStretching::printPayoffInterpolationError2D( std::ofstream file; file.open(tFilename.c_str()); - SGPP::base::OperationEval* myEval = SGPP::op_factory::createOperationEval( - *this->myGrid); + SGPP::base::OperationEval* myEval = SGPP::op_factory::createOperationEval(*this->myGrid); for (size_t i = 0; i < numTestpoints; i++) { std::vector point; @@ -319,8 +328,8 @@ void BlackScholesSolverWithStretching::printPayoffInterpolationError2D( float_t result = myEval->eval(alpha, point); - file << std::scientific << std::setprecision( 16 ) << dX << " " << dY << " " << - result << std::endl; + file << std::scientific << std::setprecision(16) << dX << " " << dY << " " << result + << std::endl; dX += dInc; dY -= dInc; @@ -331,13 +340,15 @@ void BlackScholesSolverWithStretching::printPayoffInterpolationError2D( file.close(); } } else { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::getPayoffInterpolationError : A grid wasn't constructed before!"); + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::getPayoffInterpolationError : A grid wasn't " + "constructed before!"); } } } -size_t BlackScholesSolverWithStretching::getGridPointsAtMoney( - std::string payoffType, float_t strike, float_t eps) { +size_t BlackScholesSolverWithStretching::getGridPointsAtMoney(std::string payoffType, + float_t strike, float_t eps) { size_t nPoints = 0; if (this->useLogTransform == false) { @@ -349,14 +360,15 @@ size_t BlackScholesSolverWithStretching::getGridPointsAtMoney( if (payoffType == "std_euro_call" || payoffType == "std_euro_put") { for (size_t d = 0; d < this->dim; d++) { - if ( ((coords.sum() / static_cast(this->dim)) < (strike - eps)) - || ((coords.sum() / static_cast(this->dim)) > (strike + eps)) ) { + if (((coords.sum() / static_cast(this->dim)) < (strike - eps)) || + ((coords.sum() / static_cast(this->dim)) > (strike + eps))) { isAtMoney = false; } - } } else { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::getGridPointsAtMoney : An unknown payoff-type was specified!"); + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::getGridPointsAtMoney : An unknown payoff-type was " + "specified!"); } if (isAtMoney == true) { @@ -364,21 +376,24 @@ size_t BlackScholesSolverWithStretching::getGridPointsAtMoney( } } } else { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::getGridPointsAtMoney : A grid wasn't constructed before!"); + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::getGridPointsAtMoney : A grid wasn't constructed " + "before!"); } } return nPoints; } -void BlackScholesSolverWithStretching::initCartesianGridWithPayoff( - SGPP::base::DataVector& alpha, float_t strike, std::string payoffType) { +void BlackScholesSolverWithStretching::initCartesianGridWithPayoff(SGPP::base::DataVector& alpha, + float_t strike, + std::string payoffType) { float_t tmp; if (this->bGridConstructed) { for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringStretching( - *this->myStretching); + std::string coords = + this->myGridStorage->get(i)->getCoordsStringStretching(*this->myStretching); std::stringstream coordsStream(coords); float_t* dblFuncValues = new float_t[dim]; @@ -405,29 +420,33 @@ void BlackScholesSolverWithStretching::initCartesianGridWithPayoff( alpha[i] = std::max(strike - ((tmp / static_cast(dim))), 0.0); } else { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::initCartesianGridWithPayoff : An unknown payoff-type was specified!"); + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::initCartesianGridWithPayoff : An unknown " + "payoff-type was specified!"); } delete[] dblFuncValues; } SGPP::base::OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + SGPP::op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::initCartesianGridWithPayoff : A grid wasn't constructed before!"); + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::initCartesianGridWithPayoff : A grid wasn't constructed " + "before!"); } } void BlackScholesSolverWithStretching::initLogTransformedGridWithPayoff( - SGPP::base::DataVector& alpha, float_t strike, std::string payoffType) { + SGPP::base::DataVector& alpha, float_t strike, std::string payoffType) { float_t tmp; if (this->bGridConstructed) { for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringStretching( - *this->myStretching); + std::string coords = + this->myGridStorage->get(i)->getCoordsStringStretching(*this->myStretching); std::stringstream coordsStream(coords); float_t* dblFuncValues = new float_t[dim]; @@ -454,38 +473,45 @@ void BlackScholesSolverWithStretching::initLogTransformedGridWithPayoff( alpha[i] = std::max(strike - ((tmp / static_cast(dim))), 0.0); } else { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::initLogTransformedGridWithPayoff : An unknown payoff-type was specified!"); + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::initLogTransformedGridWithPayoff : An unknown " + "payoff-type was specified!"); } delete[] dblFuncValues; } SGPP::base::OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + SGPP::op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::initLogTransformedGridWithPayoff : A grid wasn't constructed before!"); + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::initLogTransformedGridWithPayoff : A grid wasn't " + "constructed before!"); } } -void BlackScholesSolverWithStretching::getAnalyticAlpha1D( - base::DataVector& alpha_analytic, float_t strike, float_t t, - std::string payoffType, bool hierarchized) { +void BlackScholesSolverWithStretching::getAnalyticAlpha1D(base::DataVector& alpha_analytic, + float_t strike, float_t t, + std::string payoffType, + bool hierarchized) { float_t coord; if (dim != 1) { - throw new base::application_exception("BlackScholesSolver::getAnalyticAlpha1D : A grid wasn't constructed before!"); + throw new base::application_exception( + "BlackScholesSolver::getAnalyticAlpha1D : A grid wasn't constructed before!"); } if (!this->bGridConstructed) { - throw new base::application_exception("BlackScholesSolver::getAnalyticAlpha1D : function only available for dim = 1!"); + throw new base::application_exception( + "BlackScholesSolver::getAnalyticAlpha1D : function only available for dim = 1!"); } // compute values of analytic solution on given grid for (size_t i = 0; i < this->myGridStorage->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringStretching( - *this->myStretching); + std::string coords = + this->myGridStorage->get(i)->getCoordsStringStretching(*this->myStretching); std::stringstream coordsStream(coords); coordsStream >> coord; @@ -494,18 +520,18 @@ void BlackScholesSolverWithStretching::getAnalyticAlpha1D( } if (payoffType == "std_euro_call") { - alpha_analytic[i] = this->getAnalyticSolution1D(coord, true, t, - this->sigmas->get(0), this->r, strike); + alpha_analytic[i] = + this->getAnalyticSolution1D(coord, true, t, this->sigmas->get(0), this->r, strike); } else if (payoffType == "std_euro_put") { - alpha_analytic[i] = this->getAnalyticSolution1D(coord, false, t, - this->sigmas->get(0), this->r, strike); + alpha_analytic[i] = + this->getAnalyticSolution1D(coord, false, t, this->sigmas->get(0), this->r, strike); } } if (hierarchized) { // hierarchize computed values base::OperationHierarchisation* myHier = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + SGPP::op_factory::createOperationHierarchisation(*this->myGrid); myHier->doHierarchisation(alpha_analytic); delete myHier; @@ -513,36 +539,40 @@ void BlackScholesSolverWithStretching::getAnalyticAlpha1D( } void BlackScholesSolverWithStretching::printGrid(SGPP::base::DataVector& alpha, - size_t PointesPerDimension, std::string tfilename) const { + size_t PointesPerDimension, + std::string tfilename) const { SGPP::base::GridPrinterForStretching myPrinter(*this->myGrid); myPrinter.printGrid(alpha, tfilename, PointesPerDimension); } -void BlackScholesSolverWithStretching::printGridDomainStretching( - SGPP::base::DataVector& alpha, size_t PointesPerDimension, - SGPP::base::Stretching& GridArea, std::string tfilename) const { +void BlackScholesSolverWithStretching::printGridDomainStretching(SGPP::base::DataVector& alpha, + size_t PointesPerDimension, + SGPP::base::Stretching& GridArea, + std::string tfilename) const { SGPP::base::GridPrinterForStretching myPrinter(*this->myGrid); - myPrinter.printGridDomainStretching(alpha, tfilename, GridArea, - PointesPerDimension); + myPrinter.printGridDomainStretching(alpha, tfilename, GridArea, PointesPerDimension); } -void BlackScholesSolverWithStretching::printGridDomain(SGPP::base::DataVector& - alpha, size_t PointesPerDimension, SGPP::base::BoundingBox& GridArea, - std::string tfilename)const { - throw new SGPP::base::application_exception("BlackScholesSolverWithStretching::printGridDomain: SGPP::base::BoundingBox not supported, use printGridDomainStretching instead!"); +void BlackScholesSolverWithStretching::printGridDomain(SGPP::base::DataVector& alpha, + size_t PointesPerDimension, + SGPP::base::BoundingBox& GridArea, + std::string tfilename) const { + throw new SGPP::base::application_exception( + "BlackScholesSolverWithStretching::printGridDomain: SGPP::base::BoundingBox not supported, " + "use printGridDomainStretching instead!"); } -void BlackScholesSolverWithStretching::printSparseGrid(SGPP::base::DataVector& - alpha, std::string tfilename, bool bSurplus) const { +void BlackScholesSolverWithStretching::printSparseGrid(SGPP::base::DataVector& alpha, + std::string tfilename, bool bSurplus) const { SGPP::base::GridPrinterForStretching myPrinter(*this->myGrid); myPrinter.printSparseGrid(alpha, tfilename, bSurplus); } -void BlackScholesSolverWithStretching::printSparseGridExpTransform( - SGPP::base::DataVector& alpha, std::string tfilename, bool bSurplus) const { +void BlackScholesSolverWithStretching::printSparseGridExpTransform(SGPP::base::DataVector& alpha, + std::string tfilename, + bool bSurplus) const { SGPP::base::GridPrinterForStretching myPrinter(*this->myGrid); myPrinter.printSparseGridExpTransform(alpha, tfilename, bSurplus); } - -} -} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/application/BlackScholesSolverWithStretching.hpp b/finance/src/sgpp/finance/application/BlackScholesSolverWithStretching.hpp index 4b46ac746f..9424651714 100644 --- a/finance/src/sgpp/finance/application/BlackScholesSolverWithStretching.hpp +++ b/finance/src/sgpp/finance/application/BlackScholesSolverWithStretching.hpp @@ -14,6 +14,8 @@ #include #include +#include +#include namespace SGPP { namespace finance { @@ -37,10 +39,11 @@ class BlackScholesSolverWithStretching : public BlackScholesSolver { * * @param alpha the coefficient vector of the grid's ansatzfunctions * @param strike the option's strike - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available */ - virtual void initCartesianGridWithPayoff(SGPP::base::DataVector& alpha, - float_t strike, std::string payoffType); + virtual void initCartesianGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType); /** * Inits the alpha vector with a payoff function of an European call option or put option @@ -48,10 +51,11 @@ class BlackScholesSolverWithStretching : public BlackScholesSolver { * * @param alpha the coefficient vector of the grid's ansatzfunctions * @param strike the option's strike - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available */ - virtual void initLogTransformedGridWithPayoff(SGPP::base::DataVector& alpha, - float_t strike, std::string payoffType); + virtual void initLogTransformedGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType); /** * This function calculates for every grid point the value @@ -60,22 +64,26 @@ class BlackScholesSolverWithStretching : public BlackScholesSolver { * * This method is overwritten in order to support grids with logarithmic coordinates. * - * @param alpha contains dehierarchized sparse grid coefficients containing the values of the multi dimensional normal distribution after call + * @param alpha contains dehierarchized sparse grid coefficients containing the values of the + * multi dimensional normal distribution after call * @param norm_mu the expected values of the normal distribution for every grid dimension * @param norm_sigma the standard deviation of the normal distribution for every grid dimension */ virtual void getGridNormalDistribution(SGPP::base::DataVector& alpha, - std::vector& norm_mu, std::vector& norm_sigma); + std::vector& norm_mu, + std::vector& norm_sigma); public: /** * Std-Constructor of the solver * - * @param useLogTransform specifies if a log transformed formulation should be used for solving BlackScholes Equation - * @param OptionType possible values "all" and "European", if "European" is choose a solver with fix Dirichlet boundaries is selected + * @param useLogTransform specifies if a log transformed formulation should be used for solving + * BlackScholes Equation + * @param OptionType possible values "all" and "European", if "European" is choose a solver with + * fix Dirichlet boundaries is selected */ - BlackScholesSolverWithStretching(bool useLogTransform = false, - std::string OptionType = "all"); + explicit BlackScholesSolverWithStretching(bool useLogTransform = false, + std::string OptionType = "all"); /** * Std-Destructor of the solver @@ -95,13 +103,15 @@ class BlackScholesSolverWithStretching : public BlackScholesSolver { * * Only on Cartesian grids! * - * @param alpha reference to a SGPP::base::DataVector object that contains the gird ansatzfunction's coefficients + * @param alpha reference to a SGPP::base::DataVector object that contains the gird + * ansatzfunction's coefficients * @param strike containing the option's strike * @param payoffType the type of payoff Function used ONLY supported: avgM - * @param dStrikeDistance the max. distance from "at the money" a point is allowed to have in order to get refined + * @param dStrikeDistance the max. distance from "at the money" a point is allowed to have in + * order to get refined */ - virtual void refineInitialGridWithPayoff(SGPP::base::DataVector& alpha, - float_t strike, std::string payoffType, float_t dStrikeDistance); + virtual void refineInitialGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType, float_t dStrikeDistance); /** * This function tries to refine the grid such that @@ -113,46 +123,53 @@ class BlackScholesSolverWithStretching : public BlackScholesSolver { * * Only on Cartesian grids! * - * @param alpha reference to a SGPP::base::DataVector object that contains the gird ansatzfunction's coefficients + * @param alpha reference to a SGPP::base::DataVector object that contains the gird + * ansatzfunction's coefficients * @param strike containing the option's strike * @param payoffType the type of payoff Function used ONLY supported: avgM - * @param dStrikeDistance the max. distance from "at the money" a point is allowed to have in order to get refined + * @param dStrikeDistance the max. distance from "at the money" a point is allowed to have in + * order to get refined * @param maxLevel maximum level of refinement */ - virtual void refineInitialGridWithPayoffToMaxLevel(SGPP::base::DataVector& - alpha, float_t strike, std::string payoffType, float_t dStrikeDistance, - SGPP::base::GridIndex::level_type maxLevel); + virtual void refineInitialGridWithPayoffToMaxLevel(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType, + float_t dStrikeDistance, + SGPP::base::GridIndex::level_type maxLevel); /** * Inits the alpha vector with a payoff function of an European call option or put option * * @param alpha the coefficient vector of the grid's ansatzfunctions * @param strike the option's strike - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available */ virtual void initGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, std::string payoffType); /** - * computes the relative error between the solution and the exact analytic solution for the 1-dimensional Black-Schoesl equation + * computes the relative error between the solution and the exact analytic solution for the + * 1-dimensional Black-Schoesl equation * * @param alpha_analytic data vector with the analytic solution * @param strike strike price of the option * @param t maturity time - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available - * @param hierarchized flag whether values should be hierarchized (true=hierarchized, false=dehierarchized) + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available + * @param hierarchized flag whether values should be hierarchized (true=hierarchized, + * false=dehierarchized) */ - virtual void getAnalyticAlpha1D(SGPP::base::DataVector& alpha_analytic, - float_t strike, float_t t, std::string payoffType, bool hierarchized); + virtual void getAnalyticAlpha1D(SGPP::base::DataVector& alpha_analytic, float_t strike, float_t t, + std::string payoffType, bool hierarchized); /** * Inits the screen object */ virtual void initScreen(); - /** - * prints the 2D interpolation error at money into a file. This file is plotable via gnuplot. A bounding + * prints the 2D interpolation error at money into a file. This file is plotable via gnuplot. A + * bounding * box [0,x] X [0,y] is assumed. * * Only on Cartesian grids! @@ -162,8 +179,8 @@ class BlackScholesSolverWithStretching : public BlackScholesSolver { * @param numTestpoints Number of equal distribute testpoints at the money * @param strike the option's strike */ - virtual void printPayoffInterpolationError2D(SGPP::base::DataVector& alpha, - std::string tFilename, size_t numTestpoints, float_t strike); + virtual void printPayoffInterpolationError2D(SGPP::base::DataVector& alpha, std::string tFilename, + size_t numTestpoints, float_t strike); /** * gets the number of gridpoints at money @@ -174,9 +191,7 @@ class BlackScholesSolverWithStretching : public BlackScholesSolver { * @param strike the option's strike * @param eps epsilon to determine the gridpoints, use if at money is not exactly on grid */ - virtual size_t getGridPointsAtMoney(std::string payoffType, float_t strike, - float_t eps = 0.0); - + virtual size_t getGridPointsAtMoney(std::string payoffType, float_t strike, float_t eps = 0.0); /** * This is some kind of debug functionality. It writes a file, @@ -188,15 +203,14 @@ class BlackScholesSolverWithStretching : public BlackScholesSolver { * @param PointesPerDimension the distance between evaluation points * @param tfilename absolute path to file into which the grid's evaluation is written */ - virtual void printGrid(SGPP::base::DataVector& alpha, - size_t PointesPerDimension, std::string tfilename) const; + virtual void printGrid(SGPP::base::DataVector& alpha, size_t PointesPerDimension, + std::string tfilename) const; /** * This is not used, throws exception to inform about the function printGridDomainStretching */ - virtual void printGridDomain(SGPP::base::DataVector& alpha, - size_t PointesPerDimension, SGPP::base::BoundingBox& GridArea, - std::string tfilename) const; + virtual void printGridDomain(SGPP::base::DataVector& alpha, size_t PointesPerDimension, + SGPP::base::BoundingBox& GridArea, std::string tfilename) const; /** * This is some kind of debug functionality. It writes a file, @@ -209,12 +223,13 @@ class BlackScholesSolverWithStretching : public BlackScholesSolver { * @param GridArea the area in which the function should be plotted * @param tfilename absolute path to file into which the grid's evaluation is written */ - virtual void printGridDomainStretching(SGPP::base::DataVector& alpha, - size_t PointesPerDimension, SGPP::base::Stretching& GridArea, + virtual void printGridDomainStretching(SGPP::base::DataVector& alpha, size_t PointesPerDimension, + SGPP::base::Stretching& GridArea, std::string tfilename) const; /** - * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis value + * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis + * value * or their hierarchical surplus * * This function is available for all dimensions @@ -223,11 +238,12 @@ class BlackScholesSolverWithStretching : public BlackScholesSolver { * @param tfilename absoulte path to the file the grid is written into * @param bSurplus specifies whether the surplus (true) or the node basis value (false) is written */ - virtual void printSparseGrid(SGPP::base::DataVector& alpha, - std::string tfilename, bool bSurplus) const; + virtual void printSparseGrid(SGPP::base::DataVector& alpha, std::string tfilename, + bool bSurplus) const; /** - * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis value + * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis + * value * or their hierarchical surplus * * This function is available for all dimensions. @@ -239,12 +255,9 @@ class BlackScholesSolverWithStretching : public BlackScholesSolver { * @param tfilename absoulte path to the file the grid is written into * @param bSurplus specifies whether the surplus (true) or the node basis value (false) is written */ - virtual void printSparseGridExpTransform(SGPP::base::DataVector& alpha, - std::string tfilename, bool bSurplus) const; - - + virtual void printSparseGridExpTransform(SGPP::base::DataVector& alpha, std::string tfilename, + bool bSurplus) const; }; - -} -} +} // namespace finance +} // namespace SGPP #endif /* BLACKSCHOLESSOLVERWITHSTRETCHING_HPP */ diff --git a/finance/src/sgpp/finance/application/HestonSolver.cpp b/finance/src/sgpp/finance/application/HestonSolver.cpp index 71b49ad914..0e6c8c77a8 100644 --- a/finance/src/sgpp/finance/application/HestonSolver.cpp +++ b/finance/src/sgpp/finance/application/HestonSolver.cpp @@ -22,6 +22,8 @@ #include #include +#include + #include #include #include @@ -29,24 +31,17 @@ #include #include #include - -#include - - -using namespace SGPP::pde; -using namespace SGPP::solver; -using namespace SGPP::base; -using namespace std; +#include +#include +#include #ifndef M_PI #define M_PI 3.14159265358979323846 #endif - namespace SGPP { namespace finance { - HestonSolver::HestonSolver(bool useLogTransform) : ParabolicPDESolver() { this->bStochasticDataAlloc = false; this->bGridConstructed = false; @@ -89,18 +84,21 @@ HestonSolver::~HestonSolver() { } } -void HestonSolver::constructGrid(BoundingBox& BoundingBox, int level) { +void HestonSolver::constructGrid(base::BoundingBox& BoundingBox, int level) { this->dim = BoundingBox.getDimensions(); if ((dim % 2) != 0) - throw new application_exception("HestonSolver::constructGrid : The number of dimensions in the grid is not an even number! This doesn't correspond to an integer number of assets. The number of dimensions in the grid must be divisible by two."); + throw new base::application_exception( + "HestonSolver::constructGrid : The number of dimensions in the grid is not an even number! " + "This doesn't correspond to an integer number of assets. The number of dimensions in the " + "grid must be divisible by two."); this->numAssets = this->dim / 2; this->levels = level; - this->myGrid = new LinearBoundaryGrid(BoundingBox); + this->myGrid = new base::LinearBoundaryGrid(BoundingBox); - GridGenerator* myGenerator = this->myGrid->createGridGenerator(); + base::GridGenerator* myGenerator = this->myGrid->createGridGenerator(); myGenerator->regular(this->levels); delete myGenerator; @@ -110,8 +108,8 @@ void HestonSolver::constructGrid(BoundingBox& BoundingBox, int level) { this->bGridConstructed = true; } -void HestonSolver::refineInitialGridWithPayoff(DataVector& alpha, - float_t strike, std::string payoffType, float_t dStrikeDistance) { +void HestonSolver::refineInitialGridWithPayoff(base::DataVector& alpha, float_t strike, + std::string payoffType, float_t dStrikeDistance) { size_t nRefinements = 0; this->dStrike = strike; @@ -119,19 +117,18 @@ void HestonSolver::refineInitialGridWithPayoff(DataVector& alpha, if (this->useLogTransform == false) { if (this->bGridConstructed) { + base::DataVector refineVector(alpha.getSize()); - DataVector refineVector(alpha.getSize()); - - if (payoffType == "std_euro_call" || payoffType == "std_euro_put" - || payoffType == "std_amer_put") { + if (payoffType == "std_euro_call" || payoffType == "std_euro_put" || + payoffType == "std_amer_put") { this->tBoundaryType = "Dirichlet"; float_t tmp; float_t* dblFuncValues = new float_t[dim]; float_t dDistance = 0.0; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(* - (this->myBoundingBox)); + std::string coords = + this->myGridStorage->get(i)->getCoordsStringBB(*(this->myBoundingBox)); std::stringstream coordsStream(coords); for (size_t j = 0; j < this->dim; j++) { @@ -164,8 +161,8 @@ void HestonSolver::refineInitialGridWithPayoff(DataVector& alpha, delete[] dblFuncValues; - SurplusRefinementFunctor* myRefineFunc = new SurplusRefinementFunctor( - &refineVector, nRefinements, 0.0); + base::SurplusRefinementFunctor* myRefineFunc = + new base::SurplusRefinementFunctor(&refineVector, nRefinements, 0.0); this->myGrid->createGridGenerator()->refine(myRefineFunc); @@ -176,17 +173,20 @@ void HestonSolver::refineInitialGridWithPayoff(DataVector& alpha, // reinit the grid with the payoff function initGridWithPayoff(alpha, strike, payoffType); } else { - throw new application_exception("HestonSolver::refineInitialGridWithPayoff : An unsupported payoffType was specified!"); + throw new base::application_exception( + "HestonSolver::refineInitialGridWithPayoff : An unsupported payoffType was specified!"); } } else { - throw new application_exception("HestonSolver::refineInitialGridWithPayoff : The grid wasn't initialized before!"); + throw new base::application_exception( + "HestonSolver::refineInitialGridWithPayoff : The grid wasn't initialized before!"); } } } -void HestonSolver::refineInitialGridWithPayoffToMaxLevel(DataVector& alpha, - float_t strike, std::string payoffType, float_t dStrikeDistance, - SGPP::base::GridIndex::level_type maxLevel) { +void HestonSolver::refineInitialGridWithPayoffToMaxLevel(base::DataVector& alpha, float_t strike, + std::string payoffType, + float_t dStrikeDistance, + base::GridIndex::level_type maxLevel) { size_t nRefinements = 0; this->dStrike = strike; @@ -194,11 +194,10 @@ void HestonSolver::refineInitialGridWithPayoffToMaxLevel(DataVector& alpha, if (this->useLogTransform == false) { if (this->bGridConstructed) { + base::DataVector refineVector(alpha.getSize()); - DataVector refineVector(alpha.getSize()); - - if (payoffType == "std_euro_call" || payoffType == "std_euro_put" - || payoffType == "std_amer_put") { + if (payoffType == "std_euro_call" || payoffType == "std_euro_put" || + payoffType == "std_amer_put") { float_t tmp; float_t* dblFuncValues = new float_t[dim]; float_t dDistance = 0.0; @@ -206,8 +205,7 @@ void HestonSolver::refineInitialGridWithPayoffToMaxLevel(DataVector& alpha, this->tBoundaryType = "Dirichlet"; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); for (size_t j = 0; j < this->dim; j++) { @@ -240,8 +238,8 @@ void HestonSolver::refineInitialGridWithPayoffToMaxLevel(DataVector& alpha, delete[] dblFuncValues; - SurplusRefinementFunctor* myRefineFunc = new SurplusRefinementFunctor( - &refineVector, nRefinements, 0.0); + base::SurplusRefinementFunctor* myRefineFunc = + new base::SurplusRefinementFunctor(&refineVector, nRefinements, 0.0); this->myGrid->createGridGenerator()->refineMaxLevel(myRefineFunc, maxLevel); @@ -252,44 +250,48 @@ void HestonSolver::refineInitialGridWithPayoffToMaxLevel(DataVector& alpha, // reinit the grid with the payoff function initGridWithPayoff(alpha, strike, payoffType); } else { - throw new application_exception("HestonSolver::refineInitialGridWithPayoffToMaxLevel : An unsupported payoffType was specified!"); + throw new base::application_exception( + "HestonSolver::refineInitialGridWithPayoffToMaxLevel : An unsupported payoffType was " + "specified!"); } } else { - throw new application_exception("HestonSolver::refineInitialGridWithPayoffToMaxLevel : The grid wasn't initialized before!"); + throw new base::application_exception( + "HestonSolver::refineInitialGridWithPayoffToMaxLevel : The grid wasn't initialized " + "before!"); } } } -void HestonSolver::setStochasticData(DataVector& thetas_arg, - DataVector& kappas_arg, DataVector& volvols_arg, DataMatrix& hMatrix_arg, +void HestonSolver::setStochasticData(base::DataVector& thetas_arg, base::DataVector& kappas_arg, + base::DataVector& volvols_arg, base::DataMatrix& hMatrix_arg, float_t r) { - this->thetas = new SGPP::base::DataVector(thetas_arg); - this->kappas = new SGPP::base::DataVector(kappas_arg); - this->volvols = new SGPP::base::DataVector(volvols_arg); - this->hMatrix = new SGPP::base::DataMatrix(hMatrix_arg); + this->thetas = new base::DataVector(thetas_arg); + this->kappas = new base::DataVector(kappas_arg); + this->volvols = new base::DataVector(volvols_arg); + this->hMatrix = new base::DataMatrix(hMatrix_arg); this->r = r; bStochasticDataAlloc = true; } void HestonSolver::solveCrankNicolson(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, DataVector& alpha, size_t NumImEul) { + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, size_t NumImEul) { if (this->bGridConstructed && this->bStochasticDataAlloc) { - SLESolver* myCG = NULL; - OperationParabolicPDESolverSystem* myHestonSystem = NULL; + solver::SLESolver* myCG = NULL; + solver::OperationParabolicPDESolverSystem* myHestonSystem = NULL; if (this->tBoundaryType == "Dirichlet") { - myCG = new BiCGStab(maxCGIterations, epsilonCG); - myHestonSystem = new HestonParabolicPDESolverSystemEuroAmer(*this->myGrid, - alpha, *this->thetas, *this->volvols, *this->kappas, *this->hMatrix, this->r, - timestepsize, "CrNic", this->dStrike, this->payoffType, this->useLogTransform, - this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, - this->numCoarsenPoints, this->refineThreshold, this->refineMode, - this->refineMaxLevel); + myCG = new solver::BiCGStab(maxCGIterations, epsilonCG); + myHestonSystem = new HestonParabolicPDESolverSystemEuroAmer( + *this->myGrid, alpha, *this->thetas, *this->volvols, *this->kappas, *this->hMatrix, + this->r, timestepsize, "CrNic", this->dStrike, this->payoffType, this->useLogTransform, + this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); } else { } - SGppStopwatch* myStopwatch = new SGppStopwatch(); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); this->staInnerGridSize = getNumberInnerGridPoints(); size_t numCNSteps; @@ -303,37 +305,42 @@ void HestonSolver::solveCrankNicolson(size_t numTimesteps, float_t timestepsize, numIESteps = NumImEul; - Euler* myEuler = new Euler("ImEul", numIESteps, timestepsize, false, 0, - this->myScreen); - CrankNicolson* myCN = new CrankNicolson(numCNSteps, timestepsize, - this->myScreen); + solver::Euler* myEuler = + new solver::Euler("ImEul", numIESteps, timestepsize, false, 0, this->myScreen); + solver::CrankNicolson* myCN = + new solver::CrankNicolson(numCNSteps, timestepsize, this->myScreen); myStopwatch->start(); if (numIESteps > 0) { - std::cout << "Using Implicit Euler to solve " << numIESteps << " timesteps:" << - std::endl; + std::cout << "Using Implicit Euler to solve " << numIESteps << " timesteps:" << std::endl; myHestonSystem->setODESolver("ImEul"); myEuler->solve(*myCG, *myHestonSystem, false, false); } myHestonSystem->setODESolver("CrNic"); - std::cout << "Using Crank Nicolson to solve " << numCNSteps << " timesteps:" << - std::endl << std::endl << std::endl << std::endl; + std::cout << "Using Crank Nicolson to solve " << numCNSteps << " timesteps:" << std::endl + << std::endl + << std::endl + << std::endl; myCN->solve(*myCG, *myHestonSystem, true, false); this->dNeededTime = myStopwatch->stop(); - std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << - std::endl; - std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << - std::endl << std::endl << std::endl; - - std::cout << "Average Grid size: " << static_cast - (myHestonSystem->getSumGridPointsComplete()) / static_cast - (numTimesteps) << std::endl; - std::cout << "Average Grid size (Inner): " << static_cast - (myHestonSystem->getSumGridPointsInner()) / static_cast - (numTimesteps) << std::endl << std::endl << std::endl; + std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << std::endl; + std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << std::endl + << std::endl + << std::endl; + + std::cout << "Average Grid size: " + << static_cast(myHestonSystem->getSumGridPointsComplete()) / + static_cast(numTimesteps) + << std::endl; + std::cout << "Average Grid size (Inner): " + << static_cast(myHestonSystem->getSumGridPointsInner()) / + static_cast(numTimesteps) + << std::endl + << std::endl + << std::endl; if (this->myScreen != NULL) { std::cout << "Time to solve: " << this->dNeededTime << " seconds" << std::endl; @@ -341,11 +348,11 @@ void HestonSolver::solveCrankNicolson(size_t numTimesteps, float_t timestepsize, } this->finInnerGridSize = getNumberInnerGridPoints(); - this->avgInnerGridSize = static_cast((static_cast - (myHestonSystem->getSumGridPointsInner()) / static_cast - (numTimesteps)) + 0.5); - this->nNeededIterations = myEuler->getNumberIterations() + - myCN->getNumberIterations(); + this->avgInnerGridSize = + static_cast((static_cast(myHestonSystem->getSumGridPointsInner()) / + static_cast(numTimesteps)) + + 0.5); + this->nNeededIterations = myEuler->getNumberIterations() + myCN->getNumberIterations(); delete myHestonSystem; delete myCG; @@ -355,18 +362,19 @@ void HestonSolver::solveCrankNicolson(size_t numTimesteps, float_t timestepsize, this->current_time += (static_cast(numTimesteps) * timestepsize); } else { - throw new application_exception("HestonSolver::solveCrankNicolson : A grid wasn't constructed before or stochastic parameters weren't set!"); + throw new base::application_exception( + "HestonSolver::solveCrankNicolson : A grid wasn't constructed before or stochastic " + "parameters weren't set!"); } } - -void HestonSolver::initGridWithPayoff(DataVector& alpha, float_t strike, +void HestonSolver::initGridWithPayoff(base::DataVector& alpha, float_t strike, std::string payoffType) { this->dStrike = strike; this->payoffType = payoffType; - if (payoffType == "std_euro_call" || payoffType == "std_euro_put" - || payoffType == "std_amer_put") { + if (payoffType == "std_euro_call" || payoffType == "std_euro_put" || + payoffType == "std_amer_put") { this->tBoundaryType = "Dirichlet"; } @@ -377,8 +385,7 @@ void HestonSolver::initGridWithPayoff(DataVector& alpha, float_t strike, } } -float_t HestonSolver::get1DEuroCallPayoffValue(float_t assetValue, - float_t strike) { +float_t HestonSolver::get1DEuroCallPayoffValue(float_t assetValue, float_t strike) { if (assetValue <= strike) { return 0.0; } else { @@ -387,15 +394,17 @@ float_t HestonSolver::get1DEuroCallPayoffValue(float_t assetValue, } void HestonSolver::solveImplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose, bool generateAnimation, size_t numEvalsAnimation) { - throw new application_exception("This scheme is not implemented for the Heston solver!"); + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose, bool generateAnimation, + size_t numEvalsAnimation) { + throw new base::application_exception("This scheme is not implemented for the Heston solver!"); } void HestonSolver::solveExplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose, bool generateAnimation, size_t numEvalsAnimation) { - throw new application_exception("This scheme is not implemented for the Heston solver!"); + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose, bool generateAnimation, + size_t numEvalsAnimation) { + throw new base::application_exception("This scheme is not implemented for the Heston solver!"); } std::vector HestonSolver::getAlgorithmicDimensions() { @@ -406,20 +415,23 @@ void HestonSolver::setAlgorithmicDimensions(std::vector newAlgoDims) { if (this->tBoundaryType == "freeBoundaries") { this->myGrid->setAlgorithmicDimensions(newAlgoDims); } else { - throw new application_exception("HestonSolver::setAlgorithmicDimensions : Set algorithmic dimensions is only supported when choosing option type all!"); + throw new base::application_exception( + "HestonSolver::setAlgorithmicDimensions : Set algorithmic dimensions is only supported " + "when choosing option type all!"); } } void HestonSolver::initScreen() { - this->myScreen = new ScreenOutput(); + this->myScreen = new base::ScreenOutput(); this->myScreen->writeTitle("SGpp - Heston Solver, 1.0.0", "The SG++ Project (C) 2009-2010, by Sam Maurus (CSE Master's Thesis)"); this->myScreen->writeStartSolve("Multidimensional Heston Solver"); } -void HestonSolver::setEnableCoarseningData(std::string adaptSolveMode, - std::string refineMode, SGPP::base::GridIndex::level_type refineMaxLevel, - int numCoarsenPoints, float_t coarsenThreshold, float_t refineThreshold) { +void HestonSolver::setEnableCoarseningData(std::string adaptSolveMode, std::string refineMode, + base::GridIndex::level_type refineMaxLevel, + int numCoarsenPoints, float_t coarsenThreshold, + float_t refineThreshold) { this->useCoarsen = true; this->coarsenThreshold = coarsenThreshold; this->refineThreshold = refineThreshold; @@ -429,33 +441,35 @@ void HestonSolver::setEnableCoarseningData(std::string adaptSolveMode, this->numCoarsenPoints = numCoarsenPoints; } -size_t HestonSolver::getGridPointsAtMoney(std::string payoffType, - float_t strike, float_t eps) { +size_t HestonSolver::getGridPointsAtMoney(std::string payoffType, float_t strike, float_t eps) { size_t nPoints = 0; if (this->useLogTransform == false) { if (this->bGridConstructed) { for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { bool isAtMoney = true; - DataVector coords(this->dim); + base::DataVector coords(this->dim); this->myGridStorage->get(i)->getCoordsBB(coords, *this->myBoundingBox); - // The stock prices come from the coordinates of the 0th, 2nd, 4th, 6th... dimensions. The other dimensions are the volatilities...they don't count for adding up stock prices. - // So...in order to determine whether the point is at the money or not, we have to add up only the 0th, 2nd, 4th, 6th...dimension values. - if (payoffType == "std_euro_call" || payoffType == "std_euro_put" - || payoffType == "std_amer_put") { + // The stock prices come from the coordinates of the 0th, 2nd, 4th, 6th... dimensions. The + // other dimensions are the volatilities...they don't count for adding up stock prices. + // So...in order to determine whether the point is at the money or not, we have to add up + // only the 0th, 2nd, 4th, 6th...dimension values. + if (payoffType == "std_euro_call" || payoffType == "std_euro_put" || + payoffType == "std_amer_put") { float_t stockPriceSum = 0.0; for (size_t j = 0; j < this->dim; j = j + 2) { stockPriceSum += coords[j]; } - if ( ((stockPriceSum / static_cast(this->dim)) < (strike - eps)) - || ((stockPriceSum / static_cast(this->dim)) > (strike + eps)) ) { + if (((stockPriceSum / static_cast(this->dim)) < (strike - eps)) || + ((stockPriceSum / static_cast(this->dim)) > (strike + eps))) { isAtMoney = false; } } else { - throw new application_exception("HestonSolver::getGridPointsAtMoney : An unknown payoff-type was specified!"); + throw new base::application_exception( + "HestonSolver::getGridPointsAtMoney : An unknown payoff-type was specified!"); } if (isAtMoney == true) { @@ -463,27 +477,27 @@ size_t HestonSolver::getGridPointsAtMoney(std::string payoffType, } } } else { - throw new application_exception("HestonSolver::getGridPointsAtMoney : A grid wasn't constructed before!"); + throw new base::application_exception( + "HestonSolver::getGridPointsAtMoney : A grid wasn't constructed before!"); } } return nPoints; } -void HestonSolver::initCartesianGridWithPayoff(DataVector& alpha, - float_t strike, std::string payoffType) { +void HestonSolver::initCartesianGridWithPayoff(base::DataVector& alpha, float_t strike, + std::string payoffType) { float_t tmp; - //BlackScholesSolver* bsSolver = new BlackScholesSolver(); + // BlackScholesSolver* bsSolver = new BlackScholesSolver(); if (this->bGridConstructed) { std::ofstream fileout; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); - GridIndex* curPoint = (*myGridStorage)[i]; + base::GridIndex* curPoint = (*myGridStorage)[i]; std::stringstream coordsStream(coords); float_t* dblFuncValues = new float_t[dim]; @@ -499,7 +513,8 @@ void HestonSolver::initCartesianGridWithPayoff(DataVector& alpha, if (payoffType == "std_euro_call") { // So now we have in alpha[i] the standard payoff value for the point S_i, v_i. // What we now want to do is solve the exact BS equation for every point S_i, v_i; - // alpha[i] = bsSolver->getAnalyticSolution1D(dblFuncValues[0], true, 0.05, pow(dblFuncValues[1], 2.0), this->r, this->dStrike); + // alpha[i] = bsSolver->getAnalyticSolution1D(dblFuncValues[0], true, 0.05, + // pow(dblFuncValues[1], 2.0), this->r, this->dStrike); tmp = 0.0; @@ -507,45 +522,51 @@ void HestonSolver::initCartesianGridWithPayoff(DataVector& alpha, tmp += dblFuncValues[2 * j]; } - if (!curPoint->isInnerPoint() - && dblFuncValues[1] == this->myBoundingBox->getBoundary(1).rightBoundary) { + if (!curPoint->isInnerPoint() && + dblFuncValues[1] == this->myBoundingBox->getBoundary(1).rightBoundary) { // Dirichlet condition when v -> inf is that U = S - alpha[i] = - dblFuncValues[0]; //(this->myBoundingBox->getBoundary(0).rightBoundary-strike)/(this->myBoundingBox->getBoundary(0).rightBoundary)*dblFuncValues[0]; - } else if (!curPoint->isInnerPoint() - && dblFuncValues[0] == this->myBoundingBox->getBoundary(0).rightBoundary) { + alpha[i] = dblFuncValues[0]; + // (this->myBoundingBox->getBoundary(0).rightBoundary-strike)/ + // (this->myBoundingBox->getBoundary(0).rightBoundary)*dblFuncValues[0]; + } else if (!curPoint->isInnerPoint() && + dblFuncValues[0] == this->myBoundingBox->getBoundary(0).rightBoundary) { // Set boundary to be the linear function at s_max - float_t normalPayoff = std::max(((tmp / static_cast - (numAssets)) - strike), 0.0); + float_t normalPayoff = + std::max(((tmp / static_cast(numAssets)) - strike), 0.0); float_t vRange = this->myBoundingBox->getBoundary(1).rightBoundary - this->myBoundingBox->getBoundary(1).leftBoundary; float_t sPayoffDiff = dblFuncValues[0] - normalPayoff; - alpha[i] = normalPayoff + ((dblFuncValues[1] - this->myBoundingBox->getBoundary( - 1).leftBoundary) / vRange) * sPayoffDiff; + alpha[i] = + normalPayoff + + ((dblFuncValues[1] - this->myBoundingBox->getBoundary(1).leftBoundary) / vRange) * + sPayoffDiff; } else { // Payoff function - alpha[i] = std::max(((tmp / static_cast(numAssets)) - strike), - 0.0); + alpha[i] = std::max(((tmp / static_cast(numAssets)) - strike), 0.0); } } else if (payoffType == "std_euro_put") { if (!curPoint->isInnerPoint()) { - if (numAssets == 1 - && dblFuncValues[1] == this->myBoundingBox->getBoundary(1).rightBoundary) { + if (numAssets == 1 && + dblFuncValues[1] == this->myBoundingBox->getBoundary(1).rightBoundary) { // Vmax boundary for a single asset. Strike price alpha[i] = strike; - } else if (numAssets == 1 - && dblFuncValues[0] == this->myBoundingBox->getBoundary(0).rightBoundary) { + } else if (numAssets == 1 && + dblFuncValues[0] == this->myBoundingBox->getBoundary(0).rightBoundary) { // Smax boundary for a single asset. exponential function - //float_t constantC = 20.0; - float_t constantB = (strike * pow(exp(this->myBoundingBox->getBoundary( - 1).leftBoundary - this->myBoundingBox->getBoundary(1).rightBoundary), - 20.0)) / (1 - exp(this->myBoundingBox->getBoundary(1).leftBoundary - - this->myBoundingBox->getBoundary(1).rightBoundary)); + // float_t constantC = 20.0; + float_t constantB = + (strike * pow(exp(this->myBoundingBox->getBoundary(1).leftBoundary - + this->myBoundingBox->getBoundary(1).rightBoundary), + 20.0)) / + (1 - exp(this->myBoundingBox->getBoundary(1).leftBoundary - + this->myBoundingBox->getBoundary(1).rightBoundary)); float_t constantA = strike + constantB; - alpha[i] = constantA * pow(exp(dblFuncValues[1] - - this->myBoundingBox->getBoundary(1).rightBoundary), 20.0) - constantB; + alpha[i] = + constantA * + pow(exp(dblFuncValues[1] - this->myBoundingBox->getBoundary(1).rightBoundary), + 20.0) - + constantB; } else { - // Get the payoff function value for this point float_t payoffFuncVal = 0.0; @@ -553,8 +574,8 @@ void HestonSolver::initCartesianGridWithPayoff(DataVector& alpha, payoffFuncVal += dblFuncValues[2 * k]; } - payoffFuncVal = std::max(strike - payoffFuncVal / - (static_cast(numAssets)), 0.0); + payoffFuncVal = + std::max(strike - payoffFuncVal / (static_cast(numAssets)), 0.0); // Get the max-volatility function value for this point float_t maxVolFuncVal = 0.0; @@ -562,7 +583,7 @@ void HestonSolver::initCartesianGridWithPayoff(DataVector& alpha, for (size_t k = 0; k < numAssets; k++) { float_t stockPrice = dblFuncValues[2 * k]; float_t sMaxValue = this->myBoundingBox->getBoundary(2 * k).rightBoundary; - maxVolFuncVal += (strike / (2.0 * sMaxValue)) * stockPrice; + maxVolFuncVal += (strike / (2.0 * sMaxValue)) * stockPrice; } maxVolFuncVal = strike - maxVolFuncVal / (static_cast(numAssets)); @@ -581,8 +602,8 @@ void HestonSolver::initCartesianGridWithPayoff(DataVector& alpha, volFraction = volFraction / (static_cast(numAssets)); // Now set the value of the point as the payoff function + fraction*maxVol function - alpha[i] = std::max(payoffFuncVal + volFraction * - (maxVolFuncVal - payoffFuncVal), 0.0); + alpha[i] = std::max( + payoffFuncVal + volFraction * (maxVolFuncVal - payoffFuncVal), 0.0); } } else { // Non-boundary point. Just set the payoff value. @@ -592,11 +613,11 @@ void HestonSolver::initCartesianGridWithPayoff(DataVector& alpha, tmp += dblFuncValues[2 * j]; } - alpha[i] = std::max(strike - ((tmp / static_cast(numAssets))), - 0.0); + alpha[i] = std::max(strike - ((tmp / static_cast(numAssets))), 0.0); } } else { - throw new application_exception("HestonSolver::initCartesianGridWithPayoff : An unknown payoff-type was specified!"); + throw new base::application_exception( + "HestonSolver::initCartesianGridWithPayoff : An unknown payoff-type was specified!"); } delete[] dblFuncValues; @@ -606,43 +627,42 @@ void HestonSolver::initCartesianGridWithPayoff(DataVector& alpha, // determine the number of grid points for both grids size_t numTotalGridPoints = myGridStorage->size(); - //size_t numInnerGridPoints = myGridStorage->getNumInnerPoints(); + // size_t numInnerGridPoints = myGridStorage->getNumInnerPoints(); size_t numNonZeroInner = 0; for (size_t i = 0; i < numTotalGridPoints; i++) { - SGPP::base::GridIndex* curPoint = (*myGridStorage)[i]; + base::GridIndex* curPoint = (*myGridStorage)[i]; - if (curPoint->isInnerPoint() && alpha.get(i) != 0) - numNonZeroInner++; + if (curPoint->isInnerPoint() && alpha.get(i) != 0) numNonZeroInner++; } int k = 0; k++; - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("HestonSolver::initCartesianGridWithPayoff : A grid wasn't constructed before!"); + throw new base::application_exception( + "HestonSolver::initCartesianGridWithPayoff : A grid wasn't constructed before!"); } } -void HestonSolver::initLogTransformedGridWithPayoff(DataVector& alpha, - float_t strike, std::string payoffType) { +void HestonSolver::initLogTransformedGridWithPayoff(base::DataVector& alpha, float_t strike, + std::string payoffType) { float_t tmp; - //BlackScholesSolver* bsSolver = new BlackScholesSolver(); + // BlackScholesSolver* bsSolver = new BlackScholesSolver(); if (this->bGridConstructed) { for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); float_t* dblFuncValues = new float_t[dim]; - GridIndex* curPoint = (*myGridStorage)[i]; + base::GridIndex* curPoint = (*myGridStorage)[i]; for (size_t j = 0; j < this->dim; j++) { coordsStream >> tmp; @@ -652,11 +672,15 @@ void HestonSolver::initLogTransformedGridWithPayoff(DataVector& alpha, if (payoffType == "std_euro_call") { // Here we have to be a little careful in comparison to the Black-Scholes solver. - // In the Black-Scholes solver, every dimension represents an asset price, so determining the payoff value at this particular point - // is simply a case of adding up all the dimension (asset) values and inserting that into the payoff function. - // In the Heston model, however, only every second dimension represents an asset price. Every other dimension represents a variance, which + // In the Black-Scholes solver, every dimension represents an asset price, so determining + // the payoff value at this particular point + // is simply a case of adding up all the dimension (asset) values and inserting that into + // the payoff function. + // In the Heston model, however, only every second dimension represents an asset price. + // Every other dimension represents a variance, which // we MUST NOT use to determine the payoff value. - // Thus, in oder to determine the payoff value, we have to only iterate over the first, third, fifth... dimensions. + // Thus, in oder to determine the payoff value, we have to only iterate over the first, + // third, fifth... dimensions. if (!curPoint->isInnerPoint()) { float_t sumStockPrices = 0.0; @@ -666,7 +690,8 @@ void HestonSolver::initLogTransformedGridWithPayoff(DataVector& alpha, // Get the sum of all stock prices sumStockPrices += exp(dblFuncValues[2 * k]); - // At the same time, figure out the fraction of the way we are away from the max-v value for this stock + // At the same time, figure out the fraction of the way we are away from the max-v value + // for this stock float_t vValue = dblFuncValues[2 * k + 1]; float_t vRightValue = this->myBoundingBox->getBoundary(2 * k + 1).rightBoundary; float_t vLeftValue = this->myBoundingBox->getBoundary(2 * k + 1).leftBoundary; @@ -674,8 +699,8 @@ void HestonSolver::initLogTransformedGridWithPayoff(DataVector& alpha, kMultiplier += (vRightValue - vValue) / vRange; } - alpha[i] = std::max((sumStockPrices - strike * kMultiplier) / - static_cast(numAssets), 0.0); + alpha[i] = std::max( + (sumStockPrices - strike * kMultiplier) / static_cast(numAssets), 0.0); } else { // Non-boundary point. Just set the payoff value. tmp = 0.0; @@ -684,26 +709,30 @@ void HestonSolver::initLogTransformedGridWithPayoff(DataVector& alpha, tmp += exp(dblFuncValues[2 * j]); } - alpha[i] = std::max(((tmp / static_cast(numAssets)) - strike), - 0.0); + alpha[i] = std::max(((tmp / static_cast(numAssets)) - strike), 0.0); } } else if (payoffType == "std_euro_put") { if (!curPoint->isInnerPoint()) { - if (numAssets == 1 - && dblFuncValues[1] == this->myBoundingBox->getBoundary(1).rightBoundary) { + if (numAssets == 1 && + dblFuncValues[1] == this->myBoundingBox->getBoundary(1).rightBoundary) { // Vmax boundary for a single asset. Strike price alpha[i] = strike; - } else if (numAssets == 1 - && dblFuncValues[0] == this->myBoundingBox->getBoundary(0).rightBoundary) { + } else if (numAssets == 1 && + dblFuncValues[0] == this->myBoundingBox->getBoundary(0).rightBoundary) { // Smax boundary for a single asset. exponential function - //float_t constantC = 20.0; - float_t constantB = (strike * pow(exp(this->myBoundingBox->getBoundary( - 1).leftBoundary - this->myBoundingBox->getBoundary(1).rightBoundary), - 20.0)) / (1 - exp(this->myBoundingBox->getBoundary(1).leftBoundary - - this->myBoundingBox->getBoundary(1).rightBoundary)); + // float_t constantC = 20.0; + float_t constantB = + (strike * pow(exp(this->myBoundingBox->getBoundary(1).leftBoundary - + this->myBoundingBox->getBoundary(1).rightBoundary), + 20.0)) / + (1 - exp(this->myBoundingBox->getBoundary(1).leftBoundary - + this->myBoundingBox->getBoundary(1).rightBoundary)); float_t constantA = strike + constantB; - alpha[i] = constantA * pow(exp(dblFuncValues[1] - - this->myBoundingBox->getBoundary(1).rightBoundary), 20.0) - constantB; + alpha[i] = + constantA * + pow(exp(dblFuncValues[1] - this->myBoundingBox->getBoundary(1).rightBoundary), + 20.0) - + constantB; } else { // Get the payoff function value for this point float_t payoffFuncVal = 0.0; @@ -712,8 +741,8 @@ void HestonSolver::initLogTransformedGridWithPayoff(DataVector& alpha, payoffFuncVal += exp(dblFuncValues[2 * k]); } - payoffFuncVal = std::max(strike - payoffFuncVal / - (static_cast(numAssets)), 0.0); + payoffFuncVal = + std::max(strike - payoffFuncVal / (static_cast(numAssets)), 0.0); // Get the max-volatility function value for this point float_t maxVolFuncVal = 0.0; @@ -722,8 +751,8 @@ void HestonSolver::initLogTransformedGridWithPayoff(DataVector& alpha, float_t stockPrice = exp(dblFuncValues[2 * k]); float_t sMinValue = exp(this->myBoundingBox->getBoundary(2 * k).leftBoundary); float_t sMaxValue = exp(this->myBoundingBox->getBoundary(2 * k).rightBoundary); - maxVolFuncVal += (strike / (2.0 * (sMaxValue - sMinValue))) * - (stockPrice - sMinValue); + maxVolFuncVal += + (strike / (2.0 * (sMaxValue - sMinValue))) * (stockPrice - sMinValue); } maxVolFuncVal = strike - maxVolFuncVal / (static_cast(numAssets)); @@ -742,8 +771,8 @@ void HestonSolver::initLogTransformedGridWithPayoff(DataVector& alpha, volFraction = volFraction / (static_cast(numAssets)); // Now set the value of the point as the payoff function + fraction*maxVol function - alpha[i] = std::max(payoffFuncVal + volFraction * - (maxVolFuncVal - payoffFuncVal), 0.0); + alpha[i] = std::max( + payoffFuncVal + volFraction * (maxVolFuncVal - payoffFuncVal), 0.0); } } else { // Non-boundary point. Just set the payoff value. @@ -753,47 +782,48 @@ void HestonSolver::initLogTransformedGridWithPayoff(DataVector& alpha, tmp += exp(dblFuncValues[2 * j]); } - alpha[i] = std::max(strike - ((tmp / static_cast(numAssets))), - 0.0); + alpha[i] = std::max(strike - ((tmp / static_cast(numAssets))), 0.0); } } else { - throw new application_exception("HestonSolver::initLogTransformedGridWithPayoff : An unknown payoff-type was specified!"); + throw new base::application_exception( + "HestonSolver::initLogTransformedGridWithPayoff : An unknown payoff-type was " + "specified!"); } delete[] dblFuncValues; } - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("HestonSolver::initLogTransformedGridWithPayoff : A grid wasn't constructed before!"); + throw new base::application_exception( + "HestonSolver::initLogTransformedGridWithPayoff : A grid wasn't constructed before!"); } } -float_t HestonSolver::evalOption(std::vector& eval_point, - SGPP::base::DataVector& alpha) { +float_t HestonSolver::evalOption(std::vector& eval_point, base::DataVector& alpha) { std::vector trans_eval = eval_point; // apply needed coordinate transformations if (this->useLogTransform) { for (size_t i = 0; i < eval_point.size(); - i = i + 2) { // Here we know that the variance dimension is not log-transformed, so we shouldn't log its value + i = i + 2) { // Here we know that the variance dimension is not log-transformed, so we + // shouldn't log its value trans_eval[i] = log(trans_eval[i]); } } - SGPP::base::OperationEval* myEval = SGPP::op_factory::createOperationEval( - *this->myGrid); + base::OperationEval* myEval = op_factory::createOperationEval(*this->myGrid); float_t result = myEval->eval(alpha, trans_eval); delete myEval; return result; } -void HestonSolver::transformPoint(SGPP::base::DataVector& point) { - SGPP::base::DataVector tmp_point(point); +void HestonSolver::transformPoint(base::DataVector& point) { + base::DataVector tmp_point(point); // apply needed coordinate transformations if (this->useLogTransform) { @@ -805,33 +835,21 @@ void HestonSolver::transformPoint(SGPP::base::DataVector& point) { point = tmp_point; } -void HestonSolver::resetSolveTime() { - this->current_time = 0.0; -} +void HestonSolver::resetSolveTime() { this->current_time = 0.0; } -size_t HestonSolver::getNeededIterationsToSolve() { - return this->nNeededIterations; -} +size_t HestonSolver::getNeededIterationsToSolve() { return this->nNeededIterations; } -float_t HestonSolver::getNeededTimeToSolve() { - return this->dNeededTime; -} +float_t HestonSolver::getNeededTimeToSolve() { return this->dNeededTime; } -size_t HestonSolver::getStartInnerGridSize() { - return this->staInnerGridSize; -} +size_t HestonSolver::getStartInnerGridSize() { return this->staInnerGridSize; } -size_t HestonSolver::getFinalInnerGridSize() { - return this->finInnerGridSize; -} +size_t HestonSolver::getFinalInnerGridSize() { return this->finInnerGridSize; } -size_t HestonSolver::getAverageInnerGridSize() { - return this->avgInnerGridSize; -} +size_t HestonSolver::getAverageInnerGridSize() { return this->avgInnerGridSize; } -float_t EvaluateHestonClosedFormIntegralFunction(float_t phi, float_t xi, - float_t theta, float_t kappa, float_t rho, float_t r, float_t T, float_t K, - float_t S, float_t v, int type) { +float_t EvaluateHestonClosedFormIntegralFunction(float_t phi, float_t xi, float_t theta, + float_t kappa, float_t rho, float_t r, float_t T, + float_t K, float_t S, float_t v, int type) { float_t a, b, u, x; if (type == 1) { @@ -846,9 +864,9 @@ float_t EvaluateHestonClosedFormIntegralFunction(float_t phi, float_t xi, x = log(S); // Build d - complex dBuilder1; - complex dBuilder2; - complex d; + std::complex dBuilder1; + std::complex dBuilder2; + std::complex d; dBuilder1 = std::complex(0.0, 1.0); dBuilder1 = pow(dBuilder1 * phi * rho * xi - b, 2.0); dBuilder2 = std::complex(0.0, 1.0); @@ -858,52 +876,52 @@ float_t EvaluateHestonClosedFormIntegralFunction(float_t phi, float_t xi, d = sqrt(dBuilder1 - dBuilder2); // Build g - complex g; + std::complex g; g = std::complex(0.0, 1.0); g = (b - rho * xi * phi * g + d) / (b - rho * xi * phi * g - d); - // Build C - complex C; + std::complex C; C = std::complex(0.0, 1.0); - C = (r * phi * C * T) + (a / float_t(pow(xi, - 2.0))) * ((b - rho * xi * phi * C + d) * T - float_t(2.0) * log( (float_t( - 1.0) - g * exp(d * T)) / (float_t(1.0) - g) )); + C = (r * phi * C * T) + + (a / float_t(pow(xi, 2.0))) * + ((b - rho * xi * phi * C + d) * T - + float_t(2.0) * log((float_t(1.0) - g * exp(d * T)) / (float_t(1.0) - g))); // Build D - complex D; + std::complex D; D = std::complex(0.0, 1.0); - D = ((b - rho * xi * phi * D + d) / float_t(pow(xi, - 2.0))) * ((float_t(1.0) - exp(d * T)) / (float_t(1.0) - g * exp(d * T))); + D = ((b - rho * xi * phi * D + d) / float_t(pow(xi, 2.0))) * + ((float_t(1.0) - exp(d * T)) / (float_t(1.0) - g * exp(d * T))); // Build f - complex f; - f = complex(0.0, 1.0); + std::complex f; + f = std::complex(0.0, 1.0); f = exp(C + D * v + f * phi * x); - // Build realArgument - complex realArgument; + std::complex realArgument; realArgument = std::complex(0.0, 1.0); - realArgument = (exp(float_t(0.0) - realArgument * phi * float_t(log( - K))) * f) / (realArgument * phi); + realArgument = + (exp(float_t(0.0) - realArgument * phi * float_t(log(K))) * f) / (realArgument * phi); return real(realArgument); } -void HestonSolver::EvaluateHestonExactSurface(DataVector& alpha, - float_t maturity) { +void HestonSolver::EvaluateHestonExactSurface(base::DataVector& alpha, float_t maturity) { if (!this->bGridConstructed) - throw new application_exception("HestonSolver::EvaluateHestonPriceExact : The grid wasn't initialized before!"); + throw new base::application_exception( + "HestonSolver::EvaluateHestonPriceExact : The grid wasn't initialized before!"); if (this->numAssets != 1 || this->payoffType != "std_euro_call") - throw new application_exception("HestonSolver::EvaluateHestonPriceExact : Can only solve in closed form for a European call option with one asset!"); + throw new base::application_exception( + "HestonSolver::EvaluateHestonPriceExact : Can only solve in closed form for a European " + "call option with one asset!"); float_t tmp; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); float_t* dblFuncValues = new float_t[dim]; @@ -916,31 +934,32 @@ void HestonSolver::EvaluateHestonExactSurface(DataVector& alpha, dblFuncValues[j] = tmp; } - alpha[i] = EvaluateHestonPriceExact(dblFuncValues[0], dblFuncValues[1], - this->volvols->get(0), this->thetas->get(0), this->kappas->get(0), - this->hMatrix->get(0, 1), this->r, maturity, this->dStrike) ; + alpha[i] = EvaluateHestonPriceExact(dblFuncValues[0], dblFuncValues[1], this->volvols->get(0), + this->thetas->get(0), this->kappas->get(0), + this->hMatrix->get(0, 1), this->r, maturity, this->dStrike); delete dblFuncValues; } - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } -void HestonSolver::EvaluateHestonExactSurfacePut(DataVector& alpha, - float_t maturity) { +void HestonSolver::EvaluateHestonExactSurfacePut(base::DataVector& alpha, float_t maturity) { if (!this->bGridConstructed) - throw new application_exception("HestonSolver::EvaluateHestonPriceExact : The grid wasn't initialized before!"); + throw new base::application_exception( + "HestonSolver::EvaluateHestonPriceExact : The grid wasn't initialized before!"); if (this->numAssets != 1 || this->payoffType != "std_euro_put") - throw new application_exception("HestonSolver::EvaluateHestonPriceExact : Can only solve in closed form for a European put option with one asset!"); + throw new base::application_exception( + "HestonSolver::EvaluateHestonPriceExact : Can only solve in closed form for a European put " + "option with one asset!"); float_t tmp; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); float_t* dblFuncValues = new float_t[dim]; @@ -953,52 +972,50 @@ void HestonSolver::EvaluateHestonExactSurfacePut(DataVector& alpha, dblFuncValues[j] = tmp; } - alpha[i] = EvaluateHestonPriceExactPut(dblFuncValues[0], dblFuncValues[1], - this->volvols->get(0), this->thetas->get(0), this->kappas->get(0), - this->hMatrix->get(0, 1), this->r, maturity, this->dStrike) ; + alpha[i] = EvaluateHestonPriceExactPut( + dblFuncValues[0], dblFuncValues[1], this->volvols->get(0), this->thetas->get(0), + this->kappas->get(0), this->hMatrix->get(0, 1), this->r, maturity, this->dStrike); delete dblFuncValues; } - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } void HestonSolver::CompareHestonBs1d(float_t maturity, float_t v) { if (this->numAssets != 1 || this->payoffType != "std_euro_call") - throw new application_exception("HestonSolver::EvaluateHestonPriceExact : Can only solve in closed form for a European call option with one asset!"); + throw new base::application_exception( + "HestonSolver::EvaluateHestonPriceExact : Can only solve in closed form for a European " + "call option with one asset!"); size_t dim1d = 1; int levels1d = this->levels; // Build a new 1d grid for stock price - DimensionBoundary* boundaries1d = new SGPP::base::DimensionBoundary[dim1d]; + base::DimensionBoundary* boundaries1d = new base::DimensionBoundary[dim1d]; boundaries1d[0].leftBoundary = this->myBoundingBox->getBoundary(0).leftBoundary; - boundaries1d[0].rightBoundary = this->myBoundingBox->getBoundary( - 0).rightBoundary; - boundaries1d[0].bDirichletLeft = this->myBoundingBox->getBoundary( - 0).bDirichletLeft; - boundaries1d[0].bDirichletRight = this->myBoundingBox->getBoundary( - 0).bDirichletRight; + boundaries1d[0].rightBoundary = this->myBoundingBox->getBoundary(0).rightBoundary; + boundaries1d[0].bDirichletLeft = this->myBoundingBox->getBoundary(0).bDirichletLeft; + boundaries1d[0].bDirichletRight = this->myBoundingBox->getBoundary(0).bDirichletRight; - BoundingBox* boundingBox1d = new BoundingBox(dim1d, boundaries1d); + base::BoundingBox* boundingBox1d = new base::BoundingBox(dim1d, boundaries1d); - Grid* grid1d = new LinearBoundaryGrid(*boundingBox1d); + base::Grid* grid1d = new base::LinearBoundaryGrid(*boundingBox1d); - GridGenerator* myGenerator = grid1d->createGridGenerator(); + base::GridGenerator* myGenerator = grid1d->createGridGenerator(); myGenerator->regular(levels1d); - SGPP::base::DataVector* alphaHeston = new SGPP::base::DataVector( - grid1d->getSize()); - SGPP::base::DataVector* alphaBS = new SGPP::base::DataVector(grid1d->getSize()); + base::DataVector* alphaHeston = new base::DataVector(grid1d->getSize()); + base::DataVector* alphaBS = new base::DataVector(grid1d->getSize()); EvaluateHestonExact1d(*alphaHeston, grid1d, boundingBox1d, maturity, v); EvaluateBsExact1d(*alphaBS, grid1d, boundingBox1d, maturity, 0.259); // Switch over the grids so we can print the 1d ones - Grid* gridTemp = this->myGrid; + base::Grid* gridTemp = this->myGrid; this->myGrid = grid1d; printGrid(*alphaHeston, 50, "hestonExact1d.gnuplot"); @@ -1017,122 +1034,120 @@ void HestonSolver::CompareHestonBs1d(float_t maturity, float_t v) { delete alphaBS; } -void HestonSolver::EvaluateHestonExact1d(DataVector& alpha, Grid* grid1d, - BoundingBox* boundingBox1d, float_t maturity, float_t v) { +void HestonSolver::EvaluateHestonExact1d(base::DataVector& alpha, base::Grid* grid1d, + base::BoundingBox* boundingBox1d, float_t maturity, + float_t v) { float_t tmp; for (size_t i = 0; i < grid1d->getStorage()->size(); i++) { - std::string coords = grid1d->getStorage()->get(i)->getCoordsStringBB( - *boundingBox1d); + std::string coords = grid1d->getStorage()->get(i)->getCoordsStringBB(*boundingBox1d); std::stringstream coordsStream(coords); float_t* dblFuncValues = new float_t[1]; coordsStream >> tmp; dblFuncValues[0] = tmp; alpha[i] = EvaluateHestonPriceExact(dblFuncValues[0], v, this->volvols->get(0), - this->thetas->get(0), this->kappas->get(0), this->hMatrix->get(0, 1), this->r, - maturity, this->dStrike) ; + this->thetas->get(0), this->kappas->get(0), + this->hMatrix->get(0, 1), this->r, maturity, this->dStrike); delete dblFuncValues; } - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*grid1d); + base::OperationHierarchisation* myHierarchisation = + op_factory::createOperationHierarchisation(*grid1d); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } -void HestonSolver::EvaluateBsExact1d(DataVector& alpha, Grid* grid1d, - BoundingBox* boundingBox1d, float_t maturity, float_t sigma) { +void HestonSolver::EvaluateBsExact1d(base::DataVector& alpha, base::Grid* grid1d, + base::BoundingBox* boundingBox1d, float_t maturity, + float_t sigma) { float_t tmp; - SGPP::finance::BlackScholesSolver* myBSSolver = new - SGPP::finance::BlackScholesSolver(false); + finance::BlackScholesSolver* myBSSolver = new finance::BlackScholesSolver(false); for (size_t i = 0; i < grid1d->getStorage()->size(); i++) { - std::string coords = grid1d->getStorage()->get(i)->getCoordsStringBB( - *boundingBox1d); + std::string coords = grid1d->getStorage()->get(i)->getCoordsStringBB(*boundingBox1d); std::stringstream coordsStream(coords); float_t* dblFuncValues = new float_t[1]; coordsStream >> tmp; dblFuncValues[0] = tmp; - alpha[i] = myBSSolver->getAnalyticSolution1D(dblFuncValues[0], true, maturity, - sigma, this->r, this->dStrike); + alpha[i] = myBSSolver->getAnalyticSolution1D(dblFuncValues[0], true, maturity, sigma, this->r, + this->dStrike); delete dblFuncValues; } - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*grid1d); + base::OperationHierarchisation* myHierarchisation = + op_factory::createOperationHierarchisation(*grid1d); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; delete myBSSolver; } -float_t HestonSolver::EvaluateHestonPriceExact(float_t S, float_t v, float_t xi, - float_t theta, float_t kappa, float_t rho, float_t r, float_t T, float_t K) { - float_t int1 = 0.5 + (1.0 / M_PI) * GaussLobattoInt(0.001, 1000.0, 1e-10, - 100000, xi, theta, kappa, rho, r, T, K, S, v, 1); - float_t int2 = 0.5 + (1.0 / M_PI) * GaussLobattoInt(0.001, 1000.0, 1e-10, - 100000, xi, theta, kappa, rho, r, T, K, S, v, 2); +float_t HestonSolver::EvaluateHestonPriceExact(float_t S, float_t v, float_t xi, float_t theta, + float_t kappa, float_t rho, float_t r, float_t T, + float_t K) { + float_t int1 = 0.5 + + (1.0 / M_PI) * GaussLobattoInt(0.001, 1000.0, 1e-10, 100000, xi, theta, kappa, rho, + r, T, K, S, v, 1); + float_t int2 = 0.5 + + (1.0 / M_PI) * GaussLobattoInt(0.001, 1000.0, 1e-10, 100000, xi, theta, kappa, rho, + r, T, K, S, v, 2); return S * int1 - K * exp((-1.0) * r * T) * int2; } -float_t HestonSolver::EvaluateHestonPriceExact(float_t S, float_t v, - float_t maturity) { - return EvaluateHestonPriceExact(S, v, this->volvols->get(0), - this->thetas->get(0), this->kappas->get(0), this->hMatrix->get(0, 1), this->r, - maturity, this->dStrike); +float_t HestonSolver::EvaluateHestonPriceExact(float_t S, float_t v, float_t maturity) { + return EvaluateHestonPriceExact(S, v, this->volvols->get(0), this->thetas->get(0), + this->kappas->get(0), this->hMatrix->get(0, 1), this->r, maturity, + this->dStrike); } -float_t HestonSolver::EvaluateHestonPriceExactPut(float_t S, float_t v, - float_t xi, float_t theta, float_t kappa, float_t rho, float_t r, float_t T, - float_t K) { - float_t int1 = 0.5 + (1.0 / M_PI) * GaussLobattoInt(0.001, 1000.0, 1e-10, - 100000, xi, theta, kappa, rho, r, T, K, S, v, 1); - float_t int2 = 0.5 + (1.0 / M_PI) * GaussLobattoInt(0.001, 1000.0, 1e-10, - 100000, xi, theta, kappa, rho, r, T, K, S, v, 2); +float_t HestonSolver::EvaluateHestonPriceExactPut(float_t S, float_t v, float_t xi, float_t theta, + float_t kappa, float_t rho, float_t r, float_t T, + float_t K) { + float_t int1 = 0.5 + + (1.0 / M_PI) * GaussLobattoInt(0.001, 1000.0, 1e-10, 100000, xi, theta, kappa, rho, + r, T, K, S, v, 1); + float_t int2 = 0.5 + + (1.0 / M_PI) * GaussLobattoInt(0.001, 1000.0, 1e-10, 100000, xi, theta, kappa, rho, + r, T, K, S, v, 2); return S * int1 - K * exp((-1.0) * r * T) * int2 + K * exp((-1.0) * r * T) - S; } -float_t HestonSolver::EvaluateHestonPriceExactPut(float_t S, float_t v, - float_t maturity) { - return EvaluateHestonPriceExactPut(S, v, this->volvols->get(0), - this->thetas->get(0), this->kappas->get(0), this->hMatrix->get(0, 1), this->r, +float_t HestonSolver::EvaluateHestonPriceExactPut(float_t S, float_t v, float_t maturity) { + return EvaluateHestonPriceExactPut(S, v, this->volvols->get(0), this->thetas->get(0), + this->kappas->get(0), this->hMatrix->get(0, 1), this->r, maturity, this->dStrike); } -void HestonSolver::GetBsExactSolution(SGPP::base::DataVector& alphaBS, - float_t maturity) { - SGPP::finance::BlackScholesSolver* myBSSolver = new - SGPP::finance::BlackScholesSolver(false); +void HestonSolver::GetBsExactSolution(base::DataVector& alphaBS, float_t maturity) { + finance::BlackScholesSolver* myBSSolver = new finance::BlackScholesSolver(false); float_t S, v; for (size_t i = 0; i < this->myGridStorage->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); coordsStream >> S; coordsStream >> v; if (this->useLogTransform) - alphaBS[i] = myBSSolver->getAnalyticSolution1D(exp(S), true, maturity, sqrt(v), - this->r, this->dStrike); + alphaBS[i] = myBSSolver->getAnalyticSolution1D(exp(S), true, maturity, sqrt(v), this->r, + this->dStrike); else - alphaBS[i] = myBSSolver->getAnalyticSolution1D(S, true, maturity, sqrt(v), - this->r, this->dStrike); + alphaBS[i] = + myBSSolver->getAnalyticSolution1D(S, true, maturity, sqrt(v), this->r, this->dStrike); } - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alphaBS); delete myHierarchisation; } -void HestonSolver::CompareHestonBsExact(SGPP::base::DataVector& alpha, - float_t maturity) { - DataVector* alphaHeston = new DataVector(getNumberGridPoints()); - DataVector* alphaBS = new DataVector(getNumberGridPoints()); +void HestonSolver::CompareHestonBsExact(base::DataVector& alpha, float_t maturity) { + base::DataVector* alphaHeston = new base::DataVector(getNumberGridPoints()); + base::DataVector* alphaBS = new base::DataVector(getNumberGridPoints()); EvaluateHestonExactSurface(*alphaHeston, maturity); GetBsExactSolution(*alphaBS, maturity); @@ -1143,9 +1158,9 @@ void HestonSolver::CompareHestonBsExact(SGPP::base::DataVector& alpha, } } -void HestonSolver::CompareHestonNumericToBsExact(SGPP::base::DataVector& - alphaHestonNumeric, SGPP::base::DataVector& alphaBS, - SGPP::base::DataVector& error, float_t maturity) { +void HestonSolver::CompareHestonNumericToBsExact(base::DataVector& alphaHestonNumeric, + base::DataVector& alphaBS, base::DataVector& error, + float_t maturity) { GetBsExactSolution(alphaBS, maturity); // Find the difference (heston - BS) @@ -1154,22 +1169,17 @@ void HestonSolver::CompareHestonNumericToBsExact(SGPP::base::DataVector& } } - -float_t HestonSolver::GaussLobattoIntStep( - float_t a, float_t b, - float_t fa, float_t fb, - size_t& neval, - size_t maxeval, - float_t acc - , float_t xi, float_t theta, float_t kappa, float_t rho, float_t r, float_t T, - float_t K, float_t S, float_t v, int type) { - +float_t HestonSolver::GaussLobattoIntStep(float_t a, float_t b, float_t fa, float_t fb, + size_t& neval, size_t maxeval, float_t acc, float_t xi, + float_t theta, float_t kappa, float_t rho, float_t r, + float_t T, float_t K, float_t S, float_t v, int type) { // Constants used in the algorithm const float_t alpha = std::sqrt(2.0 / 3.0); - const float_t beta = 1.0 / std::sqrt(5.0); + const float_t beta = 1.0 / std::sqrt(5.0); if (neval >= maxeval) { - throw new application_exception("HestonSolver::Gauss-Lobatto : Maximum number of evaluations reached in GaussLobatto."); + throw new base::application_exception( + "HestonSolver::Gauss-Lobatto : Maximum number of evaluations reached in GaussLobatto."); } // Here the abcissa points and function values for both the 4-point @@ -1184,22 +1194,22 @@ float_t HestonSolver::GaussLobattoIntStep( const float_t mr = m + beta * h; const float_t mrr = m + alpha * h; - const float_t fmll = EvaluateHestonClosedFormIntegralFunction(mll, xi, theta, - kappa, rho, r, T, K, S, v, type); - const float_t fml = EvaluateHestonClosedFormIntegralFunction(ml, xi, theta, - kappa, rho, r, T, K, S, v, type); - const float_t fm = EvaluateHestonClosedFormIntegralFunction(m, xi, theta, - kappa, rho, r, T, K, S, v, type); - const float_t fmr = EvaluateHestonClosedFormIntegralFunction(mr, xi, theta, - kappa, rho, r, T, K, S, v, type); - const float_t fmrr = EvaluateHestonClosedFormIntegralFunction(mrr, xi, theta, - kappa, rho, r, T, K, S, v, type); + const float_t fmll = + EvaluateHestonClosedFormIntegralFunction(mll, xi, theta, kappa, rho, r, T, K, S, v, type); + const float_t fml = + EvaluateHestonClosedFormIntegralFunction(ml, xi, theta, kappa, rho, r, T, K, S, v, type); + const float_t fm = + EvaluateHestonClosedFormIntegralFunction(m, xi, theta, kappa, rho, r, T, K, S, v, type); + const float_t fmr = + EvaluateHestonClosedFormIntegralFunction(mr, xi, theta, kappa, rho, r, T, K, S, v, type); + const float_t fmrr = + EvaluateHestonClosedFormIntegralFunction(mrr, xi, theta, kappa, rho, r, T, K, S, v, type); neval += 5; // Both the 4-point and 7-point rule integrals are evaluted const float_t integral2 = (h / 6) * (fa + fb + 5 * (fml + fmr)); - const float_t integral1 = (h / 1470) * (77 * (fa + fb) - + 432 * (fmll + fmrr) + 625 * (fml + fmr) + 672 * fm); + const float_t integral1 = + (h / 1470) * (77 * (fa + fb) + 432 * (fmll + fmrr) + 625 * (fml + fmr) + 672 * fm); // The difference betwen the 4-point and 7-point integrals is the // estimate of the accuracy @@ -1213,53 +1223,48 @@ float_t HestonSolver::GaussLobattoIntStep( if (dist == acc || mll <= a || b <= mrr) { if (!(m > a && b > m)) { - throw new application_exception("HestonSolver::Gauss-Lobatto : Integration reached an interval with no more machine numbers!"); + throw new base::application_exception( + "HestonSolver::Gauss-Lobatto : Integration reached an interval with no more machine " + "numbers!"); } return integral1; } else { - return GaussLobattoIntStep(a, mll, fa, fmll, neval, maxeval, acc, xi, theta, - kappa, rho, r, T, K, S, v, type) - + GaussLobattoIntStep(mll, ml, fmll, fml, neval, maxeval, acc, xi, theta, kappa, - rho, r, T, K, S, v, type) - + GaussLobattoIntStep(ml, m, fml, fm, neval, maxeval, acc, xi, theta, kappa, - rho, r, T, K, S, v, type) - + GaussLobattoIntStep(m, mr, fm, fmr, neval, maxeval, acc, xi, theta, kappa, - rho, r, T, K, S, v, type) - + GaussLobattoIntStep(mr, mrr, fmr, fmrr, neval, maxeval, acc, xi, theta, kappa, - rho, r, T, K, S, v, type) - + GaussLobattoIntStep(mrr, b, fmrr, fb, neval, maxeval, acc, xi, theta, kappa, - rho, r, T, K, S, v, type); - + return GaussLobattoIntStep(a, mll, fa, fmll, neval, maxeval, acc, xi, theta, kappa, rho, r, T, + K, S, v, type) + + GaussLobattoIntStep(mll, ml, fmll, fml, neval, maxeval, acc, xi, theta, kappa, rho, r, T, + K, S, v, type) + + GaussLobattoIntStep(ml, m, fml, fm, neval, maxeval, acc, xi, theta, kappa, rho, r, T, K, + S, v, type) + + GaussLobattoIntStep(m, mr, fm, fmr, neval, maxeval, acc, xi, theta, kappa, rho, r, T, K, + S, v, type) + + GaussLobattoIntStep(mr, mrr, fmr, fmrr, neval, maxeval, acc, xi, theta, kappa, rho, r, T, + K, S, v, type) + + GaussLobattoIntStep(mrr, b, fmrr, fb, neval, maxeval, acc, xi, theta, kappa, rho, r, T, + K, S, v, type); } } -float_t HestonSolver::GaussLobattoInt(float_t a, float_t b, - float_t abstol, - size_t maxeval - , float_t xi, float_t theta, float_t kappa, float_t rho, float_t r, float_t T, - float_t K, float_t S, float_t v, int type) { +float_t HestonSolver::GaussLobattoInt(float_t a, float_t b, float_t abstol, size_t maxeval, + float_t xi, float_t theta, float_t kappa, float_t rho, + float_t r, float_t T, float_t K, float_t S, float_t v, + int type) { const float_t tol_epsunit = abstol / std::numeric_limits::epsilon(); size_t neval = 0; - return GaussLobattoIntStep(a, b, - EvaluateHestonClosedFormIntegralFunction(a, xi, theta, kappa, rho, r, T, K, S, - v, type), EvaluateHestonClosedFormIntegralFunction(b, xi, theta, kappa, rho, r, - T, K, S, v, type), - neval, - maxeval, - tol_epsunit, xi, theta, kappa, rho, r, T, K, S, v, type); + return GaussLobattoIntStep( + a, b, EvaluateHestonClosedFormIntegralFunction(a, xi, theta, kappa, rho, r, T, K, S, v, type), + EvaluateHestonClosedFormIntegralFunction(b, xi, theta, kappa, rho, r, T, K, S, v, type), + neval, maxeval, tol_epsunit, xi, theta, kappa, rho, r, T, K, S, v, type); } -void HestonSolver::CompareHestonSolutionToExact(SGPP::base::DataVector* - solution, SGPP::base::DataVector* exact, std::string filename, - size_t PointsPerDimension) { - DimensionBoundary dimOne; - DimensionBoundary dimTwo; +void HestonSolver::CompareHestonSolutionToExact(base::DataVector* solution, base::DataVector* exact, + std::string filename, size_t PointsPerDimension) { + base::DimensionBoundary dimOne; + base::DimensionBoundary dimTwo; std::ofstream fileout; fileout.open(filename.c_str()); - OperationEval* myEval = SGPP::op_factory::createOperationEval(*myGrid); - + base::OperationEval* myEval = op_factory::createOperationEval(*myGrid); if (myGrid->getStorage()->dim() == 2) { dimOne = myGrid->getBoundingBox()->getBoundary(0); @@ -1267,21 +1272,21 @@ void HestonSolver::CompareHestonSolutionToExact(SGPP::base::DataVector* float_t offset_x = dimOne.leftBoundary; float_t offset_y = dimTwo.leftBoundary; - float_t inc_x = ((dimOne.rightBoundary - dimOne.leftBoundary) / float_t( - PointsPerDimension - 1)); - float_t inc_y = ((dimTwo.rightBoundary - dimTwo.leftBoundary) / float_t( - PointsPerDimension - 1)); + float_t inc_x = + ((dimOne.rightBoundary - dimOne.leftBoundary) / float_t(PointsPerDimension - 1)); + float_t inc_y = + ((dimTwo.rightBoundary - dimTwo.leftBoundary) / float_t(PointsPerDimension - 1)); size_t points = (size_t)PointsPerDimension; for (size_t i = 0; i < points; i++) { for (size_t j = 0; j < points; j++) { std::vector point; - point.push_back(offset_x + (((float_t)(i))*inc_x)); - point.push_back(offset_y + (((float_t)(j))*inc_y)); - fileout << (offset_x + ((float_t)(i))*inc_x) << " " << (offset_y + ((float_t)( - j))*inc_y) << " " << (myEval->eval(*solution, point) - myEval->eval(*exact, - point)) << std::endl; + point.push_back(offset_x + (((float_t)(i)) * inc_x)); + point.push_back(offset_y + (((float_t)(j)) * inc_y)); + fileout << (offset_x + ((float_t)(i)) * inc_x) << " " << (offset_y + ((float_t)(j)) * inc_y) + << " " << (myEval->eval(*solution, point) - myEval->eval(*exact, point)) + << std::endl; } fileout << std::endl; @@ -1293,14 +1298,12 @@ void HestonSolver::CompareHestonSolutionToExact(SGPP::base::DataVector* fileout.close(); } -float_t HestonSolver::EvalSinglePoint1Asset(float_t s, float_t v, - DataVector& alphaVec) { - OperationEval* myEval = SGPP::op_factory::createOperationEval(*myGrid); +float_t HestonSolver::EvalSinglePoint1Asset(float_t s, float_t v, base::DataVector& alphaVec) { + base::OperationEval* myEval = op_factory::createOperationEval(*myGrid); std::vector point; point.push_back(s); point.push_back(v); return myEval->eval(alphaVec, point); } - -} -} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/application/HestonSolver.hpp b/finance/src/sgpp/finance/application/HestonSolver.hpp index 4d8edc4621..0de31a7b92 100644 --- a/finance/src/sgpp/finance/application/HestonSolver.hpp +++ b/finance/src/sgpp/finance/application/HestonSolver.hpp @@ -6,7 +6,6 @@ #ifndef HESTONSOLVER_HPP #define HESTONSOLVER_HPP - #include #include @@ -18,6 +17,9 @@ #include #include +#include +#include + #include #include #include @@ -25,14 +27,9 @@ #include #include -#include -#include - - namespace SGPP { namespace finance { - /** * This class provides abstracts the functionality for solving the multi dimensional Heston * Equation on Sparse Grids. @@ -40,7 +37,6 @@ namespace finance { */ class HestonSolver : public SGPP::pde::ParabolicPDESolver { protected: - /// Vector that contains the thetas SGPP::base::DataVector* thetas; @@ -83,7 +79,8 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { /// Number of points the are coarsened in each coarsening-step int numCoarsenPoints; - /// Identifies if the Heston Equation should be solved using log-transformed stock-price coordinates. The variance coordinates are always linear. + /// Identifies if the Heston Equation should be solved using log-transformed stock-price + /// coordinates. The variance coordinates are always linear. bool useLogTransform; /// Max. level for refinement during solving @@ -132,10 +129,11 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * * @param alpha the coefficient vector of the grid's basis functions * @param strike the option's strike - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available */ - virtual void initCartesianGridWithPayoff(SGPP::base::DataVector& alpha, - float_t strike, std::string payoffType); + virtual void initCartesianGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType); /** * Initialises the alpha vector with a payoff function of an European call option or put option @@ -143,18 +141,20 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * * @param alpha the coefficient vector of the grid's basis functions * @param strike the option's strike - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available */ - virtual void initLogTransformedGridWithPayoff(SGPP::base::DataVector& alpha, - float_t strike, std::string payoffType); + virtual void initLogTransformedGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType); public: /** * Std-Constructor of the solver * - * @param useLogTransform speciefies if a log transformed formulation should be used for solving the Heston Equation + * @param useLogTransform speciefies if a log transformed formulation should be used for solving + * the Heston Equation */ - HestonSolver(bool useLogTransform = true); + explicit HestonSolver(bool useLogTransform = true); /** * Std-Destructor of the solver @@ -178,13 +178,15 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * * Only on Cartesian grids! * - * @param alpha reference to a SGPP::base::DataVector object that contains the gird ansatzfunction's coefficients + * @param alpha reference to a SGPP::base::DataVector object that contains the gird + * ansatzfunction's coefficients * @param strike containing the option's strike * @param payoffType the type of payoff Function used ONLY supported: avgM - * @param dStrikeDistance the max. distance from "at the money" a point is allowed to have in order to get refined + * @param dStrikeDistance the max. distance from "at the money" a point is allowed to have in + * order to get refined */ - virtual void refineInitialGridWithPayoff(SGPP::base::DataVector& alpha, - float_t strike, std::string payoffType, float_t dStrikeDistance); + virtual void refineInitialGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType, float_t dStrikeDistance); /** * This function tries to refine the grid such that @@ -196,60 +198,68 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * * Only on Cartesian grids! * - * @param alpha reference to a SGPP::base::DataVector object that contains the gird ansatzfunction's coefficients + * @param alpha reference to a SGPP::base::DataVector object that contains the gird + * ansatzfunction's coefficients * @param strike containing the option's strike * @param payoffType the type of payoff Function used ONLY supported: avgM - * @param dStrikeDistance the max. distance from "at the money" a point is allowed to have in order to get refined + * @param dStrikeDistance the max. distance from "at the money" a point is allowed to have in + * order to get refined * @param maxLevel maximum level of refinement */ - virtual void refineInitialGridWithPayoffToMaxLevel(SGPP::base::DataVector& - alpha, float_t strike, std::string payoffType, float_t dStrikeDistance, - SGPP::base::GridIndex::level_type maxLevel); + virtual void refineInitialGridWithPayoffToMaxLevel(SGPP::base::DataVector& alpha, float_t strike, + std::string payoffType, + float_t dStrikeDistance, + SGPP::base::GridIndex::level_type maxLevel); /** * In order to solve the multi dimensional Heston Equation you have to provided - * some statistical data about the underlying (long-run variance, vol of vol, mean reversion rate). This function allows you to set this data. + * some statistical data about the underlying (long-run variance, vol of vol, mean reversion + * rate). This function allows you to set this data. * * @param thetas_arg vector of long-run variances, one for each asset. * @param kappas_arg vector of mean reversion rates, one for each asset. * @param volvols_arg vector of volatility of volatilities, one for each asset. - * @param rhos correlation matrix. Size needs to be twice the number of assets to handle the two Wiener processes for each asset. + * @param rhos correlation matrix. Size needs to be twice the number of assets to handle the two + * Wiener processes for each asset. * @param r market risk-free interest rate scalar. */ virtual void setStochasticData(SGPP::base::DataVector& thetas_arg, - SGPP::base::DataVector& kappas_arg, SGPP::base::DataVector& volvols_arg, - SGPP::base::DataMatrix& rhos, float_t r); + SGPP::base::DataVector& kappas_arg, + SGPP::base::DataVector& volvols_arg, SGPP::base::DataMatrix& rhos, + float_t r); - void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false, bool generateAnimation = false, - size_t numEvalsAnimation = 20); + void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, + bool generateAnimation = false, size_t numEvalsAnimation = 20); - void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false, bool generateAnimation = false, - size_t numEvalsAnimation = 20); + void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, + bool generateAnimation = false, size_t numEvalsAnimation = 20); /** - * Concrete implementation of the Crank-Nicholson solver. Optional use of implicit euler as a 'kickstart'. + * Concrete implementation of the Crank-Nicholson solver. Optional use of implicit euler as a + * 'kickstart'. * - * @param numTimesteps the number of timesteps to use. The product of this and the timestepsize parameter must be equal to the maturity T. + * @param numTimesteps the number of timesteps to use. The product of this and the timestepsize + * parameter must be equal to the maturity T. * @param timestepsize size of the timestep to take. Assumed constant. - * @param maxCGIterations the maximum number of iterations to be undertaken by the CG algorithm before aborting. + * @param maxCGIterations the maximum number of iterations to be undertaken by the CG algorithm + * before aborting. * @param epsilonCG residual value below which the CG iterative process stops * @param alpha coefficients of the sparse grid basis functions - * @param NumImEul the number of initial implicit euler steps to take before switching to Crank-Nicholson + * @param NumImEul the number of initial implicit euler steps to take before switching to + * Crank-Nicholson */ - void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - size_t NumImEul = 0); + void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, size_t NumImEul = 0); /** * Inits the alpha vector with a payoff function of an European call option or put option * * @param alpha the coefficient vector of the grid's ansatzfunctions * @param strike the option's strike - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available */ virtual void initGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, std::string payoffType); @@ -287,9 +297,10 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * @param numCoarsenPoints number of points coarsened, -1 all coarsenable points are coarsened * @param refineThreshold Threshold needed to determine if a grid point should be refined */ - virtual void setEnableCoarseningData(std::string adaptSolveMode, - std::string refineMode, SGPP::base::GridIndex::level_type refineMaxLevel, - int numCoarsenPoints, float_t coarsenThreshold, float_t refineThreshold); + virtual void setEnableCoarseningData(std::string adaptSolveMode, std::string refineMode, + SGPP::base::GridIndex::level_type refineMaxLevel, + int numCoarsenPoints, float_t coarsenThreshold, + float_t refineThreshold); /** * Evaluates the current option value @@ -300,8 +311,7 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * * @return the option price at the given point */ - virtual float_t evalOption(std::vector& eval_point, - SGPP::base::DataVector& alpha); + virtual float_t evalOption(std::vector& eval_point, SGPP::base::DataVector& alpha); /** * This method transforms a point given @@ -330,20 +340,21 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * @param eps epsilon to determine the gridpoints, use if at money is not exactly on grid * @return number of gridpoints at money */ - virtual size_t getGridPointsAtMoney(std::string payoffType, float_t strike, - float_t eps = 0.0); + virtual size_t getGridPointsAtMoney(std::string payoffType, float_t strike, float_t eps = 0.0); /** * gets the number needed iterations to solve the Heston Equation * - * @return number of iterations needed to solve the Heston Equation, if called before solving 0 is returned + * @return number of iterations needed to solve the Heston Equation, if called before solving 0 is + * returned */ virtual size_t getNeededIterationsToSolve(); /** * gets needed time in seconds to solve the Heston Equation * - * @return needed time in seconds to solve the Heston Equation, if called before solving 0 is returned + * @return needed time in seconds to solve the Heston Equation, if called before solving 0 is + * returned */ virtual float_t getNeededTimeToSolve(); @@ -374,20 +385,20 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * @param alpha the vector in which to store the closed-form results * @param maturity the option maturity */ - void EvaluateHestonExactSurface(SGPP::base::DataVector& alpha, - float_t maturity); + void EvaluateHestonExactSurface(SGPP::base::DataVector& alpha, float_t maturity); /** - * Uses the put-call parity to evaluate the exact Heston surface for a put option, based on the closed-form Heston surface for a call option. + * Uses the put-call parity to evaluate the exact Heston surface for a put option, based on the + * closed-form Heston surface for a call option. * * @param alpha the vector in which to store the results * @param maturity the option maturity */ - void EvaluateHestonExactSurfacePut(SGPP::base::DataVector& alpha, - float_t maturity); + void EvaluateHestonExactSurfacePut(SGPP::base::DataVector& alpha, float_t maturity); /** - * Evaluates the Heston closed-form curve for a constant variance and varying stock price based on the provided grid. + * Evaluates the Heston closed-form curve for a constant variance and varying stock price based on + * the provided grid. * * @param alpha the vector in which to store the results * @param grid1d the grid that specifies the stock price evaluation points @@ -395,9 +406,8 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * @param maturity the option maturity * @param v the constant variance value for evaluation */ - void EvaluateHestonExact1d(SGPP::base::DataVector& alpha, - SGPP::base::Grid* grid1d, SGPP::base::BoundingBox* boundingBox1d, - float_t maturity, float_t v); + void EvaluateHestonExact1d(SGPP::base::DataVector& alpha, SGPP::base::Grid* grid1d, + SGPP::base::BoundingBox* boundingBox1d, float_t maturity, float_t v); /** * Uses a Black-Scholes solver to evaluate the curve for a constant volatility. @@ -426,11 +436,12 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * * @return option price */ - float_t EvaluateHestonPriceExact(float_t S, float_t v, float_t xi, - float_t theta, float_t kappa, float_t rho, float_t r, float_t T, float_t K); + float_t EvaluateHestonPriceExact(float_t S, float_t v, float_t xi, float_t theta, float_t kappa, + float_t rho, float_t r, float_t T, float_t K); /* - * Calls the larger overload (the one with more parameters) of EvaluateHestonPriceExact with the stochastic data already saved in this instance. + * Calls the larger overload (the one with more parameters) of EvaluateHestonPriceExact with the + * stochastic data already saved in this instance. * * @param S stock price * @param v variance @@ -452,11 +463,12 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * * @return option price */ - float_t EvaluateHestonPriceExactPut(float_t S, float_t v, float_t xi, - float_t theta, float_t kappa, float_t rho, float_t r, float_t T, float_t K); + float_t EvaluateHestonPriceExactPut(float_t S, float_t v, float_t xi, float_t theta, + float_t kappa, float_t rho, float_t r, float_t T, float_t K); /* - * Calls the larger overload (the one with more parameters) of EvaluateHestonPriceExactPut with the stochastic data already saved in this instance. + * Calls the larger overload (the one with more parameters) of EvaluateHestonPriceExactPut with + * the stochastic data already saved in this instance. * * @param S stock price * @param v variance @@ -464,7 +476,8 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { float_t EvaluateHestonPriceExactPut(float_t S, float_t v, float_t maturity); /** - * Evaluates the difference surface between the closed-form Heston surface and the closed-form Black-Scholes surface on the current grid. + * Evaluates the difference surface between the closed-form Heston surface and the closed-form + * Black-Scholes surface on the current grid. * * @param alpha vector in which to store the difference results * @param maturity the option maturity @@ -472,7 +485,8 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { void CompareHestonBsExact(SGPP::base::DataVector& alpha, float_t maturity); /** - * Prints the closed-form BS, Heston and difference curves for a constant variance (and thus constant volatility) to files. + * Prints the closed-form BS, Heston and difference curves for a constant variance (and thus + * constant volatility) to files. * * @param maturity option maturity * @param v variance value (from which volatility is also derived) @@ -480,16 +494,21 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { void CompareHestonBs1d(float_t maturity, float_t v); /** - * Perform a single step of the Gauss-Lobatto integration for the Heston closed-form integral functions. - * Adapted from the implementation found at http://www.bnikolic.co.uk/nqm/1dinteg/gausslobatto.html + * Perform a single step of the Gauss-Lobatto integration for the Heston closed-form integral + * functions. + * Adapted from the implementation found at + * http://www.bnikolic.co.uk/nqm/1dinteg/gausslobatto.html * * @param a lower integration limit * @param b upper integration limit - * @param fa value of the function at the lower limit (used to save an evaluation when refinement is used) - * @param fb value of the function at the upper limit (used to save an evaluation when refinement is used) + * @param fa value of the function at the lower limit (used to save an evaluation when refinement + * is used) + * @param fb value of the function at the upper limit (used to save an evaluation when refinement + * is used) * @param neval number of evaluations made so far * @param maxeval maximum number of evaluations which should not be exceeded - * @param acc required accuracy expressed in units of std::numeric_limits::epsilon(). This allows less-than comparison by using addition and equality. + * @param acc required accuracy expressed in units of std::numeric_limits::epsilon(). + * This allows less-than comparison by using addition and equality. * @param xi Heston parameter * @param theta Heston parameter * @param kappa Heston parameter @@ -503,19 +522,22 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * * @return integral step value */ - float_t GaussLobattoIntStep(float_t a, float_t b, float_t fa, float_t fb, - size_t& neval, size_t maxeval, float_t acc, float_t xi, float_t theta, - float_t kappa, float_t rho, float_t r, float_t T, float_t K, float_t S, - float_t v, int type); + float_t GaussLobattoIntStep(float_t a, float_t b, float_t fa, float_t fb, size_t& neval, + size_t maxeval, float_t acc, float_t xi, float_t theta, float_t kappa, + float_t rho, float_t r, float_t T, float_t K, float_t S, float_t v, + int type); /** * Perform Gauss-Lobatto integration for the Heston closed-form integral functions. - * Adapted from the implementation found at http://www.bnikolic.co.uk/nqm/1dinteg/gausslobatto.html + * Adapted from the implementation found at + * http://www.bnikolic.co.uk/nqm/1dinteg/gausslobatto.html * * @param a the lower integration limit * @param b the upper integration limit - * @param abstol absolute tolerance - integration stops when the error estimate is smaller than this - * @param maxeval maximum of evaluations to make. If this number of evaluations is made without reaching the required accuracy, an exception of type std::runtime_error is thrown. + * @param abstol absolute tolerance - integration stops when the error estimate is smaller than + * this + * @param maxeval maximum of evaluations to make. If this number of evaluations is made without + * reaching the required accuracy, an exception of type std::runtime_error is thrown. * @param xi Heston parameter * @param theta Heston parameter * @param kappa Heston parameter @@ -529,11 +551,10 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * * @return integral value */ - float_t GaussLobattoInt(float_t a, float_t b, float_t abstol, size_t maxeval, - float_t xi, float_t theta, float_t kappa, float_t rho, float_t r, float_t T, + float_t GaussLobattoInt(float_t a, float_t b, float_t abstol, size_t maxeval, float_t xi, + float_t theta, float_t kappa, float_t rho, float_t r, float_t T, float_t K, float_t S, float_t v, int type); - /** * Compares a numerical Heston solution to the exact solution and writes the difference to a file. * @@ -542,11 +563,12 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * @param filename name of the file in which to write the difference * @param PointsPerDimension granularity of the difference measurements */ - void CompareHestonSolutionToExact(SGPP::base::DataVector* solution, - SGPP::base::DataVector* exact, std::string filename, size_t PointsPerDimension); + void CompareHestonSolutionToExact(SGPP::base::DataVector* solution, SGPP::base::DataVector* exact, + std::string filename, size_t PointsPerDimension); /** - * Uses an evaluation operator to get the interpolated option value for a particular s and v based on the given numerical solution. + * Uses an evaluation operator to get the interpolated option value for a particular s and v based + * on the given numerical solution. * * @param s stock-price for the evaluation point * @param v variance for the evaluation point @@ -554,11 +576,11 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { * * @return the evaluated option price */ - float_t EvalSinglePoint1Asset(float_t s, float_t v, - SGPP::base::DataVector& alphaVec); + float_t EvalSinglePoint1Asset(float_t s, float_t v, SGPP::base::DataVector& alphaVec); /** - * Gets the closed-form Black-Scholes surface on the current grid. Uses the equivalent volatility of the variance values. Vanilla option only. + * Gets the closed-form Black-Scholes surface on the current grid. Uses the equivalent volatility + * of the variance values. Vanilla option only. * * @param alphaBS vector in which to store the exact BS solution values * @param maturity the option maturity @@ -566,7 +588,8 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { void GetBsExactSolution(SGPP::base::DataVector& alphaBS, float_t maturity); /** - * Computes the difference between the a provided numerical Heston solution and the equivalent Black-Scholes solution on the current grid. + * Computes the difference between the a provided numerical Heston solution and the equivalent + * Black-Scholes solution on the current grid. * * @param alphaHestonNumeric numeric Heston solution * @param alphaBS vector in which to store the equivalent BS solution @@ -577,8 +600,7 @@ class HestonSolver : public SGPP::pde::ParabolicPDESolver { SGPP::base::DataVector& alphaBS, SGPP::base::DataVector& error, float_t maturity); }; - -} -} +} // namespace finance +} // namespace SGPP #endif /* HESTONSOLVER_HPP */ diff --git a/finance/src/sgpp/finance/application/HullWhiteSolver.cpp b/finance/src/sgpp/finance/application/HullWhiteSolver.cpp index 7ab2025284..b33d861d1d 100644 --- a/finance/src/sgpp/finance/application/HullWhiteSolver.cpp +++ b/finance/src/sgpp/finance/application/HullWhiteSolver.cpp @@ -11,19 +11,18 @@ #include #include #include + +#include +#include + #include #include #include #include #include -#include - -using namespace SGPP::pde; -using namespace SGPP::solver; -using namespace SGPP::base; - -#include - +#include +#include +#include namespace SGPP { namespace finance { @@ -45,7 +44,6 @@ HullWhiteSolver::HullWhiteSolver() : ParabolicPDESolver() { this->theta = 0.0; } - HullWhiteSolver::~HullWhiteSolver() { /*if (this->bStochasticDataAlloc) { @@ -58,28 +56,27 @@ HullWhiteSolver::~HullWhiteSolver() { } } -void HullWhiteSolver::constructGrid(BoundingBox& BoundingBox, int level) { +void HullWhiteSolver::constructGrid(base::BoundingBox& BoundingBox, int level) { this->dim = BoundingBox.getDimensions(); this->levels = level; - this->myGrid = new LinearBoundaryGrid(BoundingBox); + this->myGrid = new base::LinearBoundaryGrid(BoundingBox); - GridGenerator* myGenerator = this->myGrid->createGridGenerator(); + base::GridGenerator* myGenerator = this->myGrid->createGridGenerator(); myGenerator->regular(this->levels); delete myGenerator; this->myBoundingBox = this->myGrid->getBoundingBox(); this->myGridStorage = this->myGrid->getStorage(); - //std::string serGrid; - //myGrid->serialize(serGrid); - //std::cout << serGrid << std::endl; + // std::string serGrid; + // myGrid->serialize(serGrid); + // std::cout << serGrid << std::endl; this->bGridConstructed = true; } -void HullWhiteSolver::setStochasticData(float_t theta, float_t sigma, - float_t a) { +void HullWhiteSolver::setStochasticData(float_t theta, float_t sigma, float_t a) { this->theta = theta; this->sigma = sigma; this->a = a; @@ -87,39 +84,41 @@ void HullWhiteSolver::setStochasticData(float_t theta, float_t sigma, bStochasticDataAlloc = true; } -void HullWhiteSolver::solveExplicitEuler(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose, bool generateAnimation, - size_t numEvalsAnimation) { +void HullWhiteSolver::solveExplicitEuler(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose, + bool generateAnimation, size_t numEvalsAnimation) { if (this->bGridConstructed && this->bStochasticDataAlloc) { - Euler* myEuler = new Euler("ExEul", numTimesteps, timestepsize, - generateAnimation, numEvalsAnimation, myScreen); - BiCGStab* myCG = new BiCGStab(maxCGIterations, epsilonCG); - HullWhiteParabolicPDESolverSystem* myHWSystem = new - HullWhiteParabolicPDESolverSystem(*this->myGrid, alpha, this->sigma, - this->theta, this->a, timestepsize, "ExEul", this->useCoarsen, - this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, - this->refineThreshold, this->refineMode, this->refineMaxLevel); - SGppStopwatch* myStopwatch = new SGppStopwatch(); + solver::Euler* myEuler = new solver::Euler("ExEul", numTimesteps, timestepsize, + generateAnimation, numEvalsAnimation, myScreen); + solver::BiCGStab* myCG = new solver::BiCGStab(maxCGIterations, epsilonCG); + HullWhiteParabolicPDESolverSystem* myHWSystem = new HullWhiteParabolicPDESolverSystem( + *this->myGrid, alpha, this->sigma, this->theta, this->a, timestepsize, "ExEul", + this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); float_t execTime; - std::cout << "Using Explicit Euler to solve " << numTimesteps << " timesteps:" - << std::endl; + std::cout << "Using Explicit Euler to solve " << numTimesteps << " timesteps:" << std::endl; myStopwatch->start(); myEuler->solve(*myCG, *myHWSystem, true, verbose); execTime = myStopwatch->stop(); - std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << - std::endl; - std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << - std::endl << std::endl << std::endl; + std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << std::endl; + std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << std::endl + << std::endl + << std::endl; - std::cout << "Average Grid size: " << static_cast - (myHWSystem->getSumGridPointsComplete()) / static_cast - (numTimesteps) << std::endl; - std::cout << "Average Grid size (Inner): " << static_cast - (myHWSystem->getSumGridPointsInner()) / static_cast - (numTimesteps) << std::endl << std::endl << std::endl; + std::cout << "Average Grid size: " + << static_cast(myHWSystem->getSumGridPointsComplete()) / + static_cast(numTimesteps) + << std::endl; + std::cout << "Average Grid size (Inner): " + << static_cast(myHWSystem->getSumGridPointsInner()) / + static_cast(numTimesteps) + << std::endl + << std::endl + << std::endl; if (this->myScreen != NULL) { std::cout << "Time to solve: " << execTime << " seconds" << std::endl; @@ -131,44 +130,47 @@ void HullWhiteSolver::solveExplicitEuler(size_t numTimesteps, delete myEuler; delete myStopwatch; } else { - throw new application_exception("HullWhiteSolver::solveExplicitEuler : A grid wasn't constructed before or stochastic parameters weren't set!"); + throw new base::application_exception( + "HullWhiteSolver::solveExplicitEuler : A grid wasn't constructed before or stochastic " + "parameters weren't set!"); } } - -void HullWhiteSolver::solveImplicitEuler(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose, bool generateAnimation, - size_t numEvalsAnimation) { +void HullWhiteSolver::solveImplicitEuler(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose, + bool generateAnimation, size_t numEvalsAnimation) { if (this->bGridConstructed && this->bStochasticDataAlloc) { - Euler* myEuler = new Euler("ImEul", numTimesteps, timestepsize, - generateAnimation, numEvalsAnimation, myScreen); - BiCGStab* myCG = new BiCGStab(maxCGIterations, epsilonCG); - HullWhiteParabolicPDESolverSystem* myHWSystem = new - HullWhiteParabolicPDESolverSystem(*this->myGrid, alpha, this->sigma, - this->theta, this->a, timestepsize, "ImEul", this->useCoarsen, - this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, - this->refineThreshold, this->refineMode, this->refineMaxLevel); - SGppStopwatch* myStopwatch = new SGppStopwatch(); + solver::Euler* myEuler = new solver::Euler("ImEul", numTimesteps, timestepsize, + generateAnimation, numEvalsAnimation, myScreen); + solver::BiCGStab* myCG = new solver::BiCGStab(maxCGIterations, epsilonCG); + HullWhiteParabolicPDESolverSystem* myHWSystem = new HullWhiteParabolicPDESolverSystem( + *this->myGrid, alpha, this->sigma, this->theta, this->a, timestepsize, "ImEul", + this->useCoarsen, this->coarsenThreshold, this->adaptSolveMode, this->numCoarsenPoints, + this->refineThreshold, this->refineMode, this->refineMaxLevel); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); float_t execTime; - std::cout << "Using Implicit Euler to solve " << numTimesteps << " timesteps:" - << std::endl; + std::cout << "Using Implicit Euler to solve " << numTimesteps << " timesteps:" << std::endl; myStopwatch->start(); myEuler->solve(*myCG, *myHWSystem, true, verbose); execTime = myStopwatch->stop(); - std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << - std::endl; - std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << - std::endl << std::endl << std::endl; + std::cout << std::endl << "Final Grid size: " << getNumberGridPoints() << std::endl; + std::cout << "Final Grid size (inner): " << getNumberInnerGridPoints() << std::endl + << std::endl + << std::endl; - std::cout << "Average Grid size: " << static_cast - (myHWSystem->getSumGridPointsComplete()) / static_cast - (numTimesteps) << std::endl; - std::cout << "Average Grid size (Inner): " << static_cast - (myHWSystem->getSumGridPointsInner()) / static_cast - (numTimesteps) << std::endl << std::endl << std::endl; + std::cout << "Average Grid size: " + << static_cast(myHWSystem->getSumGridPointsComplete()) / + static_cast(numTimesteps) + << std::endl; + std::cout << "Average Grid size (Inner): " + << static_cast(myHWSystem->getSumGridPointsInner()) / + static_cast(numTimesteps) + << std::endl + << std::endl + << std::endl; if (this->myScreen != NULL) { std::cout << "Time to solve: " << execTime << " seconds" << std::endl; @@ -180,25 +182,28 @@ void HullWhiteSolver::solveImplicitEuler(size_t numTimesteps, delete myEuler; delete myStopwatch; } else { - throw new application_exception("HullWhiteSolver::solveImplicitEuler : A grid wasn't constructed before or stochastic parameters weren't set!"); + throw new base::application_exception( + "HullWhiteSolver::solveImplicitEuler : A grid wasn't constructed before or stochastic " + "parameters weren't set!"); } } -void HullWhiteSolver::solveCrankNicolson(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, size_t NumImEul) { - throw new application_exception("HullWhiteSolver::solveCrankNicolson : Crank-Nicolson is not supported for HullWhiteSolver!!"); +void HullWhiteSolver::solveCrankNicolson(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, size_t NumImEul) { + throw new base::application_exception( + "HullWhiteSolver::solveCrankNicolson : Crank-Nicolson is not supported for " + "HullWhiteSolver!!"); } - -void HullWhiteSolver::initGridWithPayoff(DataVector& alpha, float_t strike, - std::string payoffType, float_t sigma, float_t a, float_t t, float_t T) { +void HullWhiteSolver::initGridWithPayoff(base::DataVector& alpha, float_t strike, + std::string payoffType, float_t sigma, float_t a, + float_t t, float_t T) { float_t tmp; if (this->bGridConstructed) { for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); coordsStream >> tmp; float_t* dblFuncValues = new float_t[1]; @@ -206,10 +211,10 @@ void HullWhiteSolver::initGridWithPayoff(DataVector& alpha, float_t strike, for (size_t j = 0; j < 1; j++) { coordsStream >> tmp; - dblFuncValues[j] = exp((0.04 * (t - T)) + 0.04 * (1 - exp(-a * - (T - t))) / a - 1 / (4 * pow(a, 3)) * pow(sigma, - 2) * pow((exp(-a * T) - exp(-a * t)), - 2) * (exp(2 * a * t) - 1) - tmp / a * (1 - exp(-a * (T - t)))); + dblFuncValues[j] = exp((0.04 * (t - T)) + 0.04 * (1 - exp(-a * (T - t))) / a - + 1 / (4 * pow(a, 3)) * pow(sigma, 2) * + pow((exp(-a * T) - exp(-a * t)), 2) * (exp(2 * a * t) - 1) - + tmp / a * (1 - exp(-a * (T - t)))); } if (payoffType == "std_euro_call") { @@ -219,7 +224,7 @@ void HullWhiteSolver::initGridWithPayoff(DataVector& alpha, float_t strike, tmp += dblFuncValues[j]; } - alpha[i] = std::max(((tmp) - strike), 0.0); + alpha[i] = std::max(((tmp)-strike), 0.0); } else if (payoffType == "std_euro_put") { tmp = 0.0; @@ -229,20 +234,22 @@ void HullWhiteSolver::initGridWithPayoff(DataVector& alpha, float_t strike, alpha[i] = std::max(strike - ((tmp)), 0.0); } else { - throw new application_exception("HullWhiteSolver::initGridWithPayoff : An unknown payoff-type was specified!"); + throw new base::application_exception( + "HullWhiteSolver::initGridWithPayoff : An unknown payoff-type was specified!"); } delete[] dblFuncValues; - //delete dblFuncValues; + // delete dblFuncValues; } - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("HullWhiteSolver::initGridWithPayoff : A grid wasn't constructed before!"); + throw new base::application_exception( + "HullWhiteSolver::initGridWithPayoff : A grid wasn't constructed before!"); } } @@ -250,17 +257,15 @@ std::vector HullWhiteSolver::getAlgorithmicDimensions() { return this->myGrid->getAlgorithmicDimensions(); } - -void HullWhiteSolver::setAlgorithmicDimensions(std::vector - newAlgoDims) { +void HullWhiteSolver::setAlgorithmicDimensions(std::vector newAlgoDims) { this->myGrid->setAlgorithmicDimensions(newAlgoDims); } void HullWhiteSolver::initScreen() { - this->myScreen = new ScreenOutput(); + this->myScreen = new base::ScreenOutput(); this->myScreen->writeTitle("SGpp - Hull White Solver, 1.3.0", "The SG++ Project (C) 2009-2010, by Chao qi"); this->myScreen->writeStartSolve("One dimensional Hull White Solver"); } -} -} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/application/HullWhiteSolver.hpp b/finance/src/sgpp/finance/application/HullWhiteSolver.hpp index fbb0d2fa9a..d6444914bb 100644 --- a/finance/src/sgpp/finance/application/HullWhiteSolver.hpp +++ b/finance/src/sgpp/finance/application/HullWhiteSolver.hpp @@ -6,13 +6,15 @@ #ifndef HULLWHITESOLVER_HPP #define HULLWHITESOLVER_HPP - #include #include #include #include +#include +#include + #include #include #include @@ -20,10 +22,6 @@ #include #include -#include -#include - - namespace SGPP { namespace finance { @@ -36,7 +34,6 @@ namespace finance { * */ - class HullWhiteSolver : public SGPP::pde::ParabolicPDESolver { private: /// the theta value @@ -46,7 +43,7 @@ class HullWhiteSolver : public SGPP::pde::ParabolicPDESolver { /// the a value float_t a; /// the current time - //float_t t; + // float_t t; /// stores if the stochastic asset data was passed to the solver bool bStochasticDataAlloc; /// screen object used in this solver @@ -67,7 +64,6 @@ class HullWhiteSolver : public SGPP::pde::ParabolicPDESolver { SGPP::base::GridIndex::level_type refineMaxLevel; /// variable to store needed solving iterations - public: /** * Std-Constructor of the solver @@ -83,34 +79,31 @@ class HullWhiteSolver : public SGPP::pde::ParabolicPDESolver { void setStochasticData(float_t theta, float_t sigma, float_t a); + void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, + bool generateAnimation = false, size_t numEvalsAnimation = 20); - void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false, bool generateAnimation = false, - size_t numEvalsAnimation = 20); + void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, + bool generateAnimation = false, size_t numEvalsAnimation = 20); - void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false, bool generateAnimation = false, - size_t numEvalsAnimation = 20); - - void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - size_t NumImEul = 0); + void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, size_t NumImEul = 0); /** * Inits the alpha vector with a payoff function of an European call option * * @param alpha the coefficient vector of the grid's ansatzfunctions * @param strike the option's strike - * @param payoffType specifies the type of the combined payoff function; std_euro_call or std_euro_put are available + * @param payoffType specifies the type of the combined payoff function; std_euro_call or + * std_euro_put are available * @param sigma the sigma value in HullWhite model * @param a the value of a in HullWhite model * @param t the current time * @param T the maturity time */ - void initGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, - std::string payoffType, float_t sigma, float_t a, float_t t, float_t T); + void initGridWithPayoff(SGPP::base::DataVector& alpha, float_t strike, std::string payoffType, + float_t sigma, float_t a, float_t t, float_t T); /** * Inits the screen object @@ -132,10 +125,8 @@ class HullWhiteSolver : public SGPP::pde::ParabolicPDESolver { * @param newAlgoDims std::vector containing the algorithmic dimensions */ void setAlgorithmicDimensions(std::vector newAlgoDims); - }; - -} -} +} // namespace finance +} // namespace SGPP #endif /* BLACKSCHOLESSOLVER_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiDownBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiDownBBLinearBoundary.cpp index 1e0db6d684..33d78d2a15 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiDownBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiDownBBLinearBoundary.cpp @@ -7,22 +7,17 @@ #include - namespace SGPP { namespace finance { +DPhiPhiDownBBLinearBoundary::DPhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage) + : DPhiPhiDownBBLinear(storage) {} - -DPhiPhiDownBBLinearBoundary::DPhiPhiDownBBLinearBoundary( - SGPP::base::GridStorage* storage) : DPhiPhiDownBBLinear(storage) { -} - -DPhiPhiDownBBLinearBoundary::~DPhiPhiDownBBLinearBoundary() { -} - +DPhiPhiDownBBLinearBoundary::~DPhiPhiDownBBLinearBoundary() {} void DPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { // get boundary values float_t left_boundary; float_t right_boundary; @@ -44,18 +39,17 @@ void DPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, seq_right = index.seq(); right_boundary = source[seq_right]; - // the following is independent from a bounding box // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = left_boundary * (-0.5); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = right_boundary * (0.5); // down @@ -75,7 +69,5 @@ void DPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiDownBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiDownBBLinearBoundary.hpp index fcc6b2e2c7..7b96285470 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiDownBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiDownBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -31,7 +28,7 @@ class DPhiPhiDownBBLinearBoundary : public DPhiPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - DPhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit DPhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class DPhiPhiDownBBLinearBoundary : public DPhiPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* DPHIPHIDOWNBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* DPHIPHIDOWNBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiUpBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiUpBBLinearBoundary.cpp index a4dc360fd3..f99dccf144 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiUpBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiUpBBLinearBoundary.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +DPhiPhiUpBBLinearBoundary::DPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage) + : DPhiPhiUpBBLinear(storage) {} - -DPhiPhiUpBBLinearBoundary::DPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* - storage) : DPhiPhiUpBBLinear(storage) { -} - -DPhiPhiUpBBLinearBoundary::~DPhiPhiUpBBLinearBoundary() { -} +DPhiPhiUpBBLinearBoundary::~DPhiPhiUpBBLinearBoundary() {} void DPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { // get boundary values float_t fl = 0.0; float_t fr = 0.0; @@ -48,7 +44,7 @@ void DPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { // up ////////////////////////////////////// @@ -58,7 +54,7 @@ void DPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -66,7 +62,5 @@ void DPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, index.resetToLeftLevelZero(dim); } -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiUpBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiUpBBLinearBoundary.hpp index a7f0dbfc1c..83df543c46 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiUpBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/DPhiPhiUpBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -31,7 +28,7 @@ class DPhiPhiUpBBLinearBoundary : public DPhiPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - DPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit DPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class DPhiPhiUpBBLinearBoundary : public DPhiPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* DPHIPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* DPHIPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiDownBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiDownBBLinearBoundary.cpp index 8c272c6cfd..8ab3c499b5 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiDownBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiDownBBLinearBoundary.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +PhidPhiDownBBLinearBoundary::PhidPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage) + : PhidPhiDownBBLinear(storage) {} - -PhidPhiDownBBLinearBoundary::PhidPhiDownBBLinearBoundary( - SGPP::base::GridStorage* storage) : PhidPhiDownBBLinear(storage) { -} - -PhidPhiDownBBLinearBoundary::~PhidPhiDownBBLinearBoundary() { -} +PhidPhiDownBBLinearBoundary::~PhidPhiDownBBLinearBoundary() {} void PhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { // get boundary values float_t left_boundary; float_t right_boundary; @@ -43,18 +39,17 @@ void PhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, seq_right = index.seq(); right_boundary = source[seq_right]; - // the following code is independent from a bounding box // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = left_boundary * (-0.5); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = right_boundary * (0.5); // down @@ -74,7 +69,5 @@ void PhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiDownBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiDownBBLinearBoundary.hpp index 19491fde3f..6f1c228c17 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiDownBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiDownBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -31,7 +28,7 @@ class PhidPhiDownBBLinearBoundary : public PhidPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - PhidPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit PhidPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class PhidPhiDownBBLinearBoundary : public PhidPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* PHIDPHIDOWNBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* PHIDPHIDOWNBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiUpBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiUpBBLinearBoundary.cpp index 93520c7d75..4eefd69486 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiUpBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiUpBBLinearBoundary.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +PhidPhiUpBBLinearBoundary::PhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage) + : PhidPhiUpBBLinear(storage) {} - -PhidPhiUpBBLinearBoundary::PhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* - storage) : PhidPhiUpBBLinear(storage) { -} - -PhidPhiUpBBLinearBoundary::~PhidPhiUpBBLinearBoundary() { -} +PhidPhiUpBBLinearBoundary::~PhidPhiUpBBLinearBoundary() {} void PhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { // get boundary values float_t fl = 0.0; float_t fr = 0.0; @@ -49,7 +45,7 @@ void PhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { // up ////////////////////////////////////// @@ -59,7 +55,7 @@ void PhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -67,7 +63,5 @@ void PhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, index.resetToLeftLevelZero(dim); } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiUpBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiUpBBLinearBoundary.hpp index 468792a44c..1a2fc67717 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiUpBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/PhidPhiUpBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -31,7 +28,7 @@ class PhidPhiUpBBLinearBoundary : public PhidPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - PhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit PhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class PhidPhiUpBBLinearBoundary : public PhidPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* PHIDPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* PHIDPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearBoundary.cpp index b38e255636..feb0bbea8b 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearBoundary.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +SqXdPhidPhiDownBBLinearBoundary::SqXdPhidPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage) + : SqXdPhidPhiDownBBLinear(storage) {} - -SqXdPhidPhiDownBBLinearBoundary::SqXdPhidPhiDownBBLinearBoundary( - SGPP::base::GridStorage* storage) : SqXdPhidPhiDownBBLinear(storage) { -} - -SqXdPhidPhiDownBBLinearBoundary::~SqXdPhidPhiDownBBLinearBoundary() { -} +SqXdPhidPhiDownBBLinearBoundary::~SqXdPhidPhiDownBBLinearBoundary() {} void SqXdPhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -57,13 +53,13 @@ void SqXdPhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = (1.0 / 3.0) * left_boundary * bbFactor; } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = (1.0 / 3.0) * right_boundary * bbFactor; // down @@ -84,13 +80,13 @@ void SqXdPhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } else { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = (1.0 / 3.0) * left_boundary; } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = (1.0 / 3.0) * right_boundary; // down @@ -111,7 +107,5 @@ void SqXdPhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearBoundary.hpp index 5efeffc46c..84b71ca5e1 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x^{2} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ @@ -31,7 +28,7 @@ class SqXdPhidPhiDownBBLinearBoundary : public SqXdPhidPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - SqXdPhidPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit SqXdPhidPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,24 +39,24 @@ class SqXdPhidPhiDownBBLinearBoundary : public SqXdPhidPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * * On level zero the getfixDirechletBoundaries of the storage object evaluated * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* SQXDPHIDPHIDOWNBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* SQXDPHIDPHIDOWNBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearBoundary.cpp index a28281db99..0fcdae8480 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearBoundary.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +SqXdPhidPhiUpBBLinearBoundary::SqXdPhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage) + : SqXdPhidPhiUpBBLinear(storage) {} - -SqXdPhidPhiUpBBLinearBoundary::SqXdPhidPhiUpBBLinearBoundary( - SGPP::base::GridStorage* storage) : SqXdPhidPhiUpBBLinear(storage) { -} - -SqXdPhidPhiUpBBLinearBoundary::~SqXdPhidPhiUpBBLinearBoundary() { -} +SqXdPhidPhiUpBBLinearBoundary::~SqXdPhidPhiUpBBLinearBoundary() {} void SqXdPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -60,7 +56,7 @@ void SqXdPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, ////////////////////////////////////// // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { result[seq_left] = fl; float_t bbFactor = ((q * q) + (3.0 * q * t) + (3.0 * t * t)) / (q); @@ -68,7 +64,7 @@ void SqXdPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -99,7 +95,7 @@ void SqXdPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, ////////////////////////////////////// // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { result[seq_left] = fl; @@ -107,7 +103,7 @@ void SqXdPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -116,7 +112,5 @@ void SqXdPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearBoundary.hpp index ec275530df..d1b7c0bf4c 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x^{2} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ @@ -31,7 +28,7 @@ class SqXdPhidPhiUpBBLinearBoundary : public SqXdPhidPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - SqXdPhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit SqXdPhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class SqXdPhidPhiUpBBLinearBoundary : public SqXdPhidPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* SQXDPHIDPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* SQXDPHIDPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiDownBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiDownBBLinearBoundary.cpp index 558d37f97a..218e98409e 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiDownBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiDownBBLinearBoundary.cpp @@ -8,21 +8,17 @@ #include - namespace SGPP { namespace finance { +SqrtXPhiPhiDownBBLinearBoundary::SqrtXPhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage) + : SqrtXPhiPhiDownBBLinear(storage) {} - -SqrtXPhiPhiDownBBLinearBoundary::SqrtXPhiPhiDownBBLinearBoundary( - SGPP::base::GridStorage* storage) : SqrtXPhiPhiDownBBLinear(storage) { -} - -SqrtXPhiPhiDownBBLinearBoundary::~SqrtXPhiPhiDownBBLinearBoundary() { -} +SqrtXPhiPhiDownBBLinearBoundary::~SqrtXPhiPhiDownBBLinearBoundary() {} void SqrtXPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -56,15 +52,19 @@ void SqrtXPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, if (useBB) { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary + result[seq_left] = 0.0; // left_boundary } else { - throw new base::application_exception("SqrtXPhiPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "SqrtXPhiPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { - throw new base::application_exception("SqrtXPhiPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "SqrtXPhiPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } // move to root @@ -80,15 +80,19 @@ void SqrtXPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } else { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary + result[seq_left] = 0.0; // left_boundary } else { - throw new base::application_exception("SqrtXPhiPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "SqrtXPhiPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { - throw new base::application_exception("SqrtXPhiPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "SqrtXPhiPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } // move to root @@ -104,7 +108,5 @@ void SqrtXPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiDownBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiDownBBLinearBoundary.hpp index c59d26e726..df70799907 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiDownBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiDownBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \sqrt{x} \phi(x) \phi(x) dx\f$ @@ -31,7 +28,7 @@ class SqrtXPhiPhiDownBBLinearBoundary : public SqrtXPhiPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - SqrtXPhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit SqrtXPhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,24 +39,24 @@ class SqrtXPhiPhiDownBBLinearBoundary : public SqrtXPhiPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * * On level zero the getfixDirechletBoundaries of the storage object evaluated * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* SQRTXPHIPHIDOWNBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* SQRTXPHIPHIDOWNBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiUpBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiUpBBLinearBoundary.cpp index b46639460f..1eb206987d 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiUpBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiUpBBLinearBoundary.cpp @@ -8,21 +8,17 @@ #include - namespace SGPP { namespace finance { +SqrtXPhiPhiUpBBLinearBoundary::SqrtXPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage) + : SqrtXPhiPhiUpBBLinear(storage) {} - -SqrtXPhiPhiUpBBLinearBoundary::SqrtXPhiPhiUpBBLinearBoundary( - SGPP::base::GridStorage* storage) : SqrtXPhiPhiUpBBLinear(storage) { -} - -SqrtXPhiPhiUpBBLinearBoundary::~SqrtXPhiPhiUpBBLinearBoundary() { -} +SqrtXPhiPhiUpBBLinearBoundary::~SqrtXPhiPhiUpBBLinearBoundary() {} void SqrtXPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -59,18 +55,22 @@ void SqrtXPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // up ////////////////////////////////////// - //Left + // Left if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { - throw new base::application_exception("SqrtXPhiPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "SqrtXPhiPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } // Right if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { - throw new base::application_exception("SqrtXPhiPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "SqrtXPhiPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } index.resetToLeftLevelZero(dim); @@ -97,25 +97,27 @@ void SqrtXPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // up ////////////////////////////////////// - //Left + // Left if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { - throw new base::application_exception("SqrtXPhiPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "SqrtXPhiPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } // Right if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { - throw new base::application_exception("SqrtXPhiPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "SqrtXPhiPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } index.resetToLeftLevelZero(dim); } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiUpBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiUpBBLinearBoundary.hpp index 798e2b4834..8a52661eb7 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiUpBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/SqrtXPhiPhiUpBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \sqrt{x} \phi(x) \phi(x) dx\f$ @@ -31,7 +28,7 @@ class SqrtXPhiPhiUpBBLinearBoundary : public SqrtXPhiPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - SqrtXPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit SqrtXPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class SqrtXPhiPhiUpBBLinearBoundary : public SqrtXPhiPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* SQRTXPHIPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* SQRTXPHIPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiDownBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiDownBBLinearBoundary.cpp index 01dd6f2ea5..dcb3cde82f 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiDownBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiDownBBLinearBoundary.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +XPhiPhiDownBBLinearBoundary::XPhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage) + : XPhiPhiDownBBLinear(storage) {} - -XPhiPhiDownBBLinearBoundary::XPhiPhiDownBBLinearBoundary( - SGPP::base::GridStorage* storage) : XPhiPhiDownBBLinear(storage) { -} - -XPhiPhiDownBBLinearBoundary::~XPhiPhiDownBBLinearBoundary() { -} +XPhiPhiDownBBLinearBoundary::~XPhiPhiDownBBLinearBoundary() {} void XPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -55,13 +51,13 @@ void XPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, if (useBB) { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary + result[seq_left] = 0.0; // left_boundary } else { result[seq_left] = ((1.0 / 3.0 * t + 1.0 / 12.0 * q * q) * left_boundary); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = ((1.0 / 3.0 * t + 1.0 / 4.0 * q * q) * right_boundary); @@ -83,13 +79,13 @@ void XPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } else { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary + result[seq_left] = 0.0; // left_boundary } else { result[seq_left] = (1.0 / 12.0) * left_boundary; } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = (1.0 / 4.0) * right_boundary; @@ -111,7 +107,5 @@ void XPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiDownBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiDownBBLinearBoundary.hpp index 732858c874..d07fa5ad2d 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiDownBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiDownBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x \phi(x) \phi(x) dx\f$ @@ -31,7 +28,7 @@ class XPhiPhiDownBBLinearBoundary : public XPhiPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XPhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit XPhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,24 +39,24 @@ class XPhiPhiDownBBLinearBoundary : public XPhiPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * * On level zero the getfixDirechletBoundaries of the storage object evaluated * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XPHIPHIDOWNBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* XPHIPHIDOWNBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiUpBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiUpBBLinearBoundary.cpp index cc2ea0c9b2..6b93768278 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiUpBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiUpBBLinearBoundary.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +XPhiPhiUpBBLinearBoundary::XPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage) + : XPhiPhiUpBBLinear(storage) {} - -XPhiPhiUpBBLinearBoundary::XPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* - storage) : XPhiPhiUpBBLinear(storage) { -} - -XPhiPhiUpBBLinearBoundary::~XPhiPhiUpBBLinearBoundary() { -} +XPhiPhiUpBBLinearBoundary::~XPhiPhiUpBBLinearBoundary() {} void XPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -58,9 +54,9 @@ void XPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // up ////////////////////////////////////// - //Left + // Left if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { result[seq_left] = fl; result[seq_left] += ((1.0 / 6.0 * t + 1.0 / 12.0 * q * q) * source[seq_right]); @@ -68,7 +64,7 @@ void XPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // Right if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -97,9 +93,9 @@ void XPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // up ////////////////////////////////////// - //Left + // Left if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { result[seq_left] = fl; result[seq_left] += ((1.0 / 12.0) * source[seq_right]); @@ -107,7 +103,7 @@ void XPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // Right if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -116,7 +112,5 @@ void XPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiUpBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiUpBBLinearBoundary.hpp index 9ffc119a2b..aef097791a 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiUpBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhiPhiUpBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x \phi(x) \phi(x) dx\f$ @@ -31,7 +28,7 @@ class XPhiPhiUpBBLinearBoundary : public XPhiPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit XPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class XPhiPhiUpBBLinearBoundary : public XPhiPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XPHIPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* XPHIPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiDownBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiDownBBLinearBoundary.cpp index 088c023e3e..71bf304935 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiDownBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiDownBBLinearBoundary.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +XPhidPhiDownBBLinearBoundary::XPhidPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage) + : XPhidPhiDownBBLinear(storage) {} - -XPhidPhiDownBBLinearBoundary::XPhidPhiDownBBLinearBoundary( - SGPP::base::GridStorage* storage) : XPhidPhiDownBBLinear(storage) { -} - -XPhidPhiDownBBLinearBoundary::~XPhidPhiDownBBLinearBoundary() { -} +XPhidPhiDownBBLinearBoundary::~XPhidPhiDownBBLinearBoundary() {} void XPhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -55,13 +51,13 @@ void XPhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, if (useBB) { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = left_boundary * (((-1.0 / 6.0) * q) - (0.5 * t)); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = right_boundary * (((1.0 / 3.0) * q) + (0.5 * t)); // down @@ -82,13 +78,13 @@ void XPhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } else { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = left_boundary * (-1.0 / 6.0); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = right_boundary * (1.0 / 3.0); // down @@ -109,7 +105,5 @@ void XPhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiDownBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiDownBBLinearBoundary.hpp index cdf808041b..622cc2ea17 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiDownBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiDownBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -31,7 +28,7 @@ class XPhidPhiDownBBLinearBoundary : public XPhidPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XPhidPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit XPhidPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,24 +39,24 @@ class XPhidPhiDownBBLinearBoundary : public XPhidPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * * On level zero the getfixDirechletBoundaries of the storage object evaluated * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XPHIDPHIDOWNBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* XPHIDPHIDOWNBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiUpBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiUpBBLinearBoundary.cpp index f119b03457..01ac9843f8 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiUpBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiUpBBLinearBoundary.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +XPhidPhiUpBBLinearBoundary::XPhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage) + : XPhidPhiUpBBLinear(storage) {} - -XPhidPhiUpBBLinearBoundary::XPhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* - storage) : XPhidPhiUpBBLinear(storage) { -} - -XPhidPhiUpBBLinearBoundary::~XPhidPhiUpBBLinearBoundary() { -} +XPhidPhiUpBBLinearBoundary::~XPhidPhiUpBBLinearBoundary() {} void XPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -58,7 +54,7 @@ void XPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { // up ////////////////////////////////////// @@ -68,7 +64,7 @@ void XPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -97,7 +93,7 @@ void XPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { // up ////////////////////////////////////// @@ -107,7 +103,7 @@ void XPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -116,7 +112,5 @@ void XPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiUpBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiUpBBLinearBoundary.hpp index e286e62f28..1778831c38 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiUpBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XPhidPhiUpBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -31,7 +28,7 @@ class XPhidPhiUpBBLinearBoundary : public XPhidPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XPhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit XPhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class XPhidPhiUpBBLinearBoundary : public XPhidPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XPHIDPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* XPHIDPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiDownBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiDownBBLinearBoundary.cpp index eafa1f8f1a..f7b16cf857 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiDownBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiDownBBLinearBoundary.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +XdPhiPhiDownBBLinearBoundary::XdPhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage) + : XdPhiPhiDownBBLinear(storage) {} - -XdPhiPhiDownBBLinearBoundary::XdPhiPhiDownBBLinearBoundary( - SGPP::base::GridStorage* storage) : XdPhiPhiDownBBLinear(storage) { -} - -XdPhiPhiDownBBLinearBoundary::~XdPhiPhiDownBBLinearBoundary() { -} +XdPhiPhiDownBBLinearBoundary::~XdPhiPhiDownBBLinearBoundary() {} void XdPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -55,13 +51,13 @@ void XdPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, if (useBB) { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = left_boundary * (((-1.0 / 6.0) * q) - (0.5 * t)); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = right_boundary * (((1.0 / 3.0) * q) + (0.5 * t)); // down @@ -82,13 +78,13 @@ void XdPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } else { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = left_boundary * (-1.0 / 3.0); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = right_boundary * (1.0 / 3.0); // down @@ -109,7 +105,5 @@ void XdPhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiDownBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiDownBBLinearBoundary.hpp index 7457f92645..d03cdcfaf5 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiDownBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiDownBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -31,7 +28,7 @@ class XdPhiPhiDownBBLinearBoundary : public XdPhiPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XdPhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit XdPhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,24 +39,24 @@ class XdPhiPhiDownBBLinearBoundary : public XdPhiPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * * On level zero the getfixDirechletBoundaries of the storage object evaluated * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XDPHIPHIDOWNBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* XDPHIPHIDOWNBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiUpBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiUpBBLinearBoundary.cpp index 3fcbd9935c..8924726615 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiUpBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiUpBBLinearBoundary.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +XdPhiPhiUpBBLinearBoundary::XdPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage) + : XdPhiPhiUpBBLinear(storage) {} - -XdPhiPhiUpBBLinearBoundary::XdPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* - storage) : XdPhiPhiUpBBLinear(storage) { -} - -XdPhiPhiUpBBLinearBoundary::~XdPhiPhiUpBBLinearBoundary() { -} +XdPhiPhiUpBBLinearBoundary::~XdPhiPhiUpBBLinearBoundary() {} void XdPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -58,7 +54,7 @@ void XdPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { // up ////////////////////////////////////// @@ -68,7 +64,7 @@ void XdPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -97,7 +93,7 @@ void XdPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { // up ////////////////////////////////////// @@ -107,7 +103,7 @@ void XdPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -116,7 +112,5 @@ void XdPhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiUpBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiUpBBLinearBoundary.hpp index 7a0489484e..ee36832d44 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiUpBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhiPhiUpBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -31,7 +28,7 @@ class XdPhiPhiUpBBLinearBoundary : public XdPhiPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XdPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit XdPhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class XdPhiPhiUpBBLinearBoundary : public XdPhiPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XDPHIPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* XDPHIPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiDownBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiDownBBLinearBoundary.cpp index 717ddb3fd0..c0706c54b5 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiDownBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiDownBBLinearBoundary.cpp @@ -8,21 +8,17 @@ #include - namespace SGPP { namespace finance { +XdPhidPhiDownBBLinearBoundary::XdPhidPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage) + : XdPhidPhiDownBBLinear(storage) {} - -XdPhidPhiDownBBLinearBoundary::XdPhidPhiDownBBLinearBoundary( - SGPP::base::GridStorage* storage) : XdPhidPhiDownBBLinear(storage) { -} - -XdPhidPhiDownBBLinearBoundary::~XdPhidPhiDownBBLinearBoundary() { -} +XdPhidPhiDownBBLinearBoundary::~XdPhidPhiDownBBLinearBoundary() {} void XdPhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -56,15 +52,19 @@ void XdPhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, if (useBB) { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { - throw new base::application_exception("XdPhidPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "XdPhidPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { - throw new base::application_exception("XdPhidPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "XdPhidPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } // move to root @@ -80,15 +80,19 @@ void XdPhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } else { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { - throw new base::application_exception("XdPhidPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "XdPhidPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { - throw new base::application_exception("XdPhidPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "XdPhidPhiDownBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } // move to root @@ -104,7 +108,5 @@ void XdPhidPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiDownBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiDownBBLinearBoundary.hpp index 0b84e087a1..2d1504474c 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiDownBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiDownBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ @@ -31,7 +28,7 @@ class XdPhidPhiDownBBLinearBoundary : public XdPhidPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XdPhidPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit XdPhidPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,24 +39,24 @@ class XdPhidPhiDownBBLinearBoundary : public XdPhidPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * * On level zero the getfixDirechletBoundaries of the storage object evaluated * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XDPHIDPHIDOWNBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* XDPHIDPHIDOWNBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiUpBBLinearBoundary.cpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiUpBBLinearBoundary.cpp index d240304451..0e36232bcc 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiUpBBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiUpBBLinearBoundary.cpp @@ -8,21 +8,17 @@ #include - namespace SGPP { namespace finance { +XdPhidPhiUpBBLinearBoundary::XdPhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage) + : XdPhidPhiUpBBLinear(storage) {} - -XdPhidPhiUpBBLinearBoundary::XdPhidPhiUpBBLinearBoundary( - SGPP::base::GridStorage* storage) : XdPhidPhiUpBBLinear(storage) { -} - -XdPhidPhiUpBBLinearBoundary::~XdPhidPhiUpBBLinearBoundary() { -} +XdPhidPhiUpBBLinearBoundary::~XdPhidPhiUpBBLinearBoundary() {} void XdPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -59,15 +55,19 @@ void XdPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { - throw new base::application_exception("XdPhidPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "XdPhidPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { - throw new base::application_exception("XdPhidPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "XdPhidPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } index.resetToLeftLevelZero(dim); @@ -94,22 +94,24 @@ void XdPhidPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { - throw new base::application_exception("XdPhidPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "XdPhidPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { - throw new base::application_exception("XdPhidPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet boundaries."); + throw new base::application_exception( + "XdPhidPhiUpBBLinearBoundary::operator : Not yet implemented for non-Dirichlet " + "boundaries."); } index.resetToLeftLevelZero(dim); } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiUpBBLinearBoundary.hpp b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiUpBBLinearBoundary.hpp index a4284f2c4d..ca2f3d5c21 100644 --- a/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiUpBBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linear/boundary/algorithm_sweep/XdPhidPhiUpBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ @@ -31,7 +28,7 @@ class XdPhidPhiUpBBLinearBoundary : public XdPhidPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XdPhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit XdPhidPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class XdPhidPhiUpBBLinearBoundary : public XdPhidPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XDPHIDPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* XDPHIDPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiDownBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiDownBBLinear.cpp index 23b6d69223..90ff5fd7a3 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiDownBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiDownBBLinear.cpp @@ -7,27 +7,21 @@ #include - namespace SGPP { namespace finance { +DPhiPhiDownBBLinear::DPhiPhiDownBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} +DPhiPhiDownBBLinear::~DPhiPhiDownBBLinear() {} -DPhiPhiDownBBLinear::DPhiPhiDownBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -DPhiPhiDownBBLinear::~DPhiPhiDownBBLinear() { -} - -void DPhiPhiDownBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void DPhiPhiDownBBLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { rec(source, result, index, dim, 0.0, 0.0); } -void DPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { +void DPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -38,7 +32,7 @@ void DPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, index.get(dim, l, i); // integration - result[seq] = ( 0.5 * (fr - fl) ); // diagonal entry = 0.0 + result[seq] = (0.5 * (fr - fl)); // diagonal entry = 0.0 // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -60,7 +54,5 @@ void DPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiDownBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiDownBBLinear.hpp index 8f058d78c6..bbd3e8207d 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiDownBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiDownBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -30,14 +27,13 @@ class DPhiPhiDownBBLinear { /// Pointer to the bounding box Obejct SGPP::base::BoundingBox* boundingBox; - public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - DPhiPhiDownBBLinear(SGPP::base::GridStorage* storage); + explicit DPhiPhiDownBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +43,16 @@ class DPhiPhiDownBBLinear { /** * This operations performs the calculation of down in the direction of dimension dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down without and with Bounding Box support * (calculations are independent from bounding box) @@ -68,13 +64,11 @@ class DPhiPhiDownBBLinear { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* PHIDPHIDOWNBBLINEAR_HPP */ \ No newline at end of file +#endif /* PHIDPHIDOWNBBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiUpBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiUpBBLinear.cpp index 666bb3bf76..4a26dffd15 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiUpBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiUpBBLinear.cpp @@ -7,22 +7,16 @@ #include - namespace SGPP { namespace finance { +DPhiPhiUpBBLinear::DPhiPhiUpBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} +DPhiPhiUpBBLinear::~DPhiPhiUpBBLinear() {} -DPhiPhiUpBBLinear::DPhiPhiUpBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - - -DPhiPhiUpBBLinear::~DPhiPhiUpBBLinear() { -} - -void DPhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void DPhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { // get boundary values float_t fl = 0.0; float_t fr = 0.0; @@ -30,10 +24,8 @@ void DPhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, rec(source, result, index, dim, fl, fr); } - -void DPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void DPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -72,7 +64,5 @@ void DPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, fr = (fm / 2.0) + (alpha_value * (-0.5) + fr); } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiUpBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiUpBBLinear.hpp index d27edb945b..47a77447ff 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiUpBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhiPhiUpBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -36,7 +33,7 @@ class DPhiPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - DPhiPhiUpBBLinear(SGPP::base::GridStorage* storage); + explicit DPhiPhiUpBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -46,16 +43,16 @@ class DPhiPhiUpBBLinear { /** * This operations performs the calculation of up in the direction of dimension dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up (with and without bounding box support, * since calculations are independent from bounding box) @@ -68,14 +65,11 @@ class DPhiPhiUpBBLinear { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); }; +} // namespace finance +} // namespace SGPP -// namespace detail - -} // namespace SGPP -} - -#endif /* DPHIPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* DPHIPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiDownBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiDownBBLinear.cpp index de8701719a..b879eb978f 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiDownBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiDownBBLinear.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +DPhidPhiDownBBLinear::DPhidPhiDownBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} - -DPhidPhiDownBBLinear::DPhidPhiDownBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -DPhidPhiDownBBLinear::~DPhidPhiDownBBLinear() { -} +DPhidPhiDownBBLinear::~DPhidPhiDownBBLinear() {} void DPhidPhiDownBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -38,9 +34,8 @@ void DPhidPhiDownBBLinear::operator()(SGPP::base::DataVector& source, } } -void DPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { +void DPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -55,7 +50,6 @@ void DPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, float_t h = (1.0 / (static_cast(1 << (l_int)))); - float_t diagonal = 2.0 / h; // integration @@ -81,9 +75,9 @@ void DPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, } } -void DPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr, float_t q, float_t t) { +void DPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr, + float_t q, float_t t) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -123,7 +117,5 @@ void DPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiDownBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiDownBBLinear.hpp index 01e13f8739..0d7c86d889 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiDownBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiDownBBLinear.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ @@ -38,7 +35,7 @@ class DPhidPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - DPhidPhiDownBBLinear(SGPP::base::GridStorage* storage); + explicit DPhidPhiDownBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -49,16 +46,16 @@ class DPhidPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down without Bounding Box support * @@ -69,8 +66,8 @@ class DPhidPhiDownBBLinear { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); /** * recursive function for the calculation of Down with Bounding Box support @@ -84,13 +81,11 @@ class DPhidPhiDownBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr, float_t q, float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* DPHIDPHIDOWNBBLINEAR_HPP */ \ No newline at end of file +#endif /* DPHIDPHIDOWNBBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiUpBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiUpBBLinear.cpp index 8d6815177d..bc70f9d7d9 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiUpBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiUpBBLinear.cpp @@ -7,23 +7,16 @@ #include - namespace SGPP { namespace finance { +DPhidPhiUpBBLinear::DPhidPhiUpBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} +DPhidPhiUpBBLinear::~DPhidPhiUpBBLinear() {} -DPhidPhiUpBBLinear::DPhidPhiUpBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - - -DPhidPhiUpBBLinear::~DPhidPhiUpBBLinear() { -} - - -void DPhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void DPhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -44,9 +37,8 @@ void DPhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, } } -void DPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void DPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -85,9 +77,9 @@ void DPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, fr = (fm / 2.0) + fr; } -void DPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr, float_t q, float_t t) { +void DPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr, + float_t q, float_t t) { size_t seq = index.seq(); fl = fr = 0.0; @@ -126,7 +118,5 @@ void DPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, fr = (fm / 2.0) + fr; } -// namespace detail -} -// namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiUpBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiUpBBLinear.hpp index b6522b2529..c3093db64b 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiUpBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/DPhidPhiUpBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ @@ -36,28 +33,27 @@ class DPhidPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - DPhidPhiUpBBLinear(SGPP::base::GridStorage* storage); + explicit DPhidPhiUpBBLinear(SGPP::base::GridStorage* storage); /** * Destructor */ virtual ~DPhidPhiUpBBLinear(); - /** * This operations performs the calculation of up in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up without Bounding Box support * @@ -68,8 +64,8 @@ class DPhidPhiUpBBLinear { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); /** * recursive function for the calculation of Up with Bounding Box support @@ -83,14 +79,11 @@ class DPhidPhiUpBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr, float_t q, - float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* DPHIDPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* DPHIDPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiDownBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiDownBBLinear.cpp index c828513ab1..49c6742d90 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiDownBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiDownBBLinear.cpp @@ -7,27 +7,21 @@ #include - namespace SGPP { namespace finance { +PhidPhiDownBBLinear::PhidPhiDownBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} +PhidPhiDownBBLinear::~PhidPhiDownBBLinear() {} -PhidPhiDownBBLinear::PhidPhiDownBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -PhidPhiDownBBLinear::~PhidPhiDownBBLinear() { -} - -void PhidPhiDownBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void PhidPhiDownBBLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { rec(source, result, index, dim, 0.0, 0.0); } -void PhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { +void PhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -38,7 +32,7 @@ void PhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, index.get(dim, l, i); // integration - result[seq] = ( 0.5 * (fl - fr) ); // diagonal entry = 0.0 + result[seq] = (0.5 * (fl - fr)); // diagonal entry = 0.0 // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -60,7 +54,5 @@ void PhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiDownBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiDownBBLinear.hpp index 3e956c202d..e7c1f413f3 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiDownBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiDownBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -36,7 +33,7 @@ class PhidPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - PhidPhiDownBBLinear(SGPP::base::GridStorage* storage); + explicit PhidPhiDownBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -46,16 +43,16 @@ class PhidPhiDownBBLinear { /** * This operations performs the calculation of down in the direction of dimension dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down with and without Bounding Box support * (since the calculations are independent from a bounding box) @@ -67,13 +64,11 @@ class PhidPhiDownBBLinear { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* PHIDPHIDOWNBBLINEAR_HPP */ \ No newline at end of file +#endif /* PHIDPHIDOWNBBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiUpBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiUpBBLinear.cpp index 1842dca258..138f9cc249 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiUpBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiUpBBLinear.cpp @@ -7,21 +7,16 @@ #include - namespace SGPP { namespace finance { +PhidPhiUpBBLinear::PhidPhiUpBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} +PhidPhiUpBBLinear::~PhidPhiUpBBLinear() {} -PhidPhiUpBBLinear::PhidPhiUpBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -PhidPhiUpBBLinear::~PhidPhiUpBBLinear() { -} - -void PhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void PhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { // get boundary values float_t fl = 0.0; float_t fr = 0.0; @@ -29,9 +24,8 @@ void PhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, rec(source, result, index, dim, fl, fr); } -void PhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void PhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -72,7 +66,5 @@ void PhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, fr = (fm / 2.0) + ((alpha_value * helper) + fr); } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiUpBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiUpBBLinear.hpp index 143463844a..4f334f17fb 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiUpBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/PhidPhiUpBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -36,7 +33,7 @@ class PhidPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - PhidPhiUpBBLinear(SGPP::base::GridStorage* storage); + explicit PhidPhiUpBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class PhidPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * on a grid with Dirichlet 0 boundary conditions. * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up (with and without bounding box support, * since the calculations are independent from a bounding box) @@ -68,13 +65,11 @@ class PhidPhiUpBBLinear { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* PHIDPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* PHIDPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinear.cpp index f508b2103d..b8480098bf 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinear.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +SqXdPhidPhiDownBBLinear::SqXdPhidPhiDownBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} - -SqXdPhidPhiDownBBLinear::SqXdPhidPhiDownBBLinear(SGPP::base::GridStorage* - storage) : storage(storage), boundingBox(storage->getBoundingBox()) { -} - -SqXdPhidPhiDownBBLinear::~SqXdPhidPhiDownBBLinear() { -} +SqXdPhidPhiDownBBLinear::~SqXdPhidPhiDownBBLinear() {} void SqXdPhidPhiDownBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -38,9 +34,8 @@ void SqXdPhidPhiDownBBLinear::operator()(SGPP::base::DataVector& source, } } -void SqXdPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { +void SqXdPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -56,8 +51,8 @@ void SqXdPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, float_t diagonal = ((1.0 / 3.0) + (i_dbl * i_dbl)) * pow(2.0, 1 - l_int); // integration - result[seq] = ( (((1.0 / static_cast(1 << l_int)) * i_dbl) * - (fl - fr)) + (diagonal * alpha_value) ); + result[seq] = + ((((1.0 / static_cast(1 << l_int)) * i_dbl) * (fl - fr)) + (diagonal * alpha_value)); // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -79,9 +74,9 @@ void SqXdPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, } } -void SqXdPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr, float_t q, float_t t) { +void SqXdPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr, + float_t q, float_t t) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -94,14 +89,15 @@ void SqXdPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, float_t i_dbl = static_cast(i); int l_int = static_cast(l); - float_t diagonal = (1.0 / 3.0) * ((((pow(2.0, - (1 - l_int))) * q * q) * (3.0 * (i_dbl * i_dbl) + 1)) + - (12.0 * t * q * i_dbl) + (3.0 * (static_cast(1 << - (1 + l_int))) * t * t)) / (q); + float_t diagonal = + (1.0 / 3.0) * + ((((pow(2.0, (1 - l_int))) * q * q) * (3.0 * (i_dbl * i_dbl) + 1)) + (12.0 * t * q * i_dbl) + + (3.0 * (static_cast(1 << (1 + l_int))) * t * t)) / + (q); // integration - result[seq] = ( (((1.0 / static_cast(1 << l_int)) * i_dbl * q + t) * - (fl - fr)) + (diagonal * alpha_value) ); + result[seq] = ((((1.0 / static_cast(1 << l_int)) * i_dbl * q + t) * (fl - fr)) + + (diagonal * alpha_value)); // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -123,7 +119,5 @@ void SqXdPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinear.hpp index 0511aba8ad..92518fed35 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x^{2} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ @@ -36,7 +33,7 @@ class SqXdPhidPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - SqXdPhidPhiDownBBLinear(SGPP::base::GridStorage* storage); + explicit SqXdPhidPhiDownBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class SqXdPhidPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down without Bounding Box support * @@ -67,8 +64,8 @@ class SqXdPhidPhiDownBBLinear { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); /** * recursive function for the calculation of Down with Bounding Box support @@ -82,13 +79,11 @@ class SqXdPhidPhiDownBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr, float_t q, float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* SQXDPHIDPHIDOWNBBLINEAR_HPP */ \ No newline at end of file +#endif /* SQXDPHIDPHIDOWNBBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinear.cpp index 1799e988be..2aa9ee58c0 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinear.cpp @@ -7,23 +7,17 @@ #include - namespace SGPP { namespace finance { +SqXdPhidPhiUpBBLinear::SqXdPhidPhiUpBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} - -SqXdPhidPhiUpBBLinear::SqXdPhidPhiUpBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - - -SqXdPhidPhiUpBBLinear::~SqXdPhidPhiUpBBLinear() { -} - +SqXdPhidPhiUpBBLinear::~SqXdPhidPhiUpBBLinear() {} void SqXdPhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -44,9 +38,8 @@ void SqXdPhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, } } -void SqXdPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void SqXdPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -78,8 +71,8 @@ void SqXdPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, float_t alpha_value = source[seq]; - float_t c = ((1.0 / static_cast(1 << current_level)) * - static_cast(current_index)); + float_t c = + ((1.0 / static_cast(1 << current_level)) * static_cast(current_index)); // transposed operations: result[seq] = fm; @@ -88,9 +81,9 @@ void SqXdPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, fr = (fm / 2.0) - (alpha_value * c) + fr; } -void SqXdPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr, float_t q, float_t t) { +void SqXdPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr, + float_t q, float_t t) { size_t seq = index.seq(); fl = fr = 0.0; @@ -122,8 +115,9 @@ void SqXdPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, float_t alpha_value = source[seq]; - float_t c = ((1.0 / static_cast(1 << current_level)) * - static_cast(current_index) * q) + t; + float_t c = + ((1.0 / static_cast(1 << current_level)) * static_cast(current_index) * q) + + t; // transposed operations: result[seq] = fm; @@ -132,7 +126,5 @@ void SqXdPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, fr = (fm / 2.0) - (alpha_value * c) + fr; } -// namespace detail -} -// namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinear.hpp index f6c67ce884..a4988b24d4 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x^{2} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ @@ -36,28 +33,27 @@ class SqXdPhidPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - SqXdPhidPhiUpBBLinear(SGPP::base::GridStorage* storage); + explicit SqXdPhidPhiUpBBLinear(SGPP::base::GridStorage* storage); /** * Destructor */ virtual ~SqXdPhidPhiUpBBLinear(); - /** * This operations performs the calculation of up in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up without Bounding Box support * @@ -68,8 +64,8 @@ class SqXdPhidPhiUpBBLinear { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); /** * recursive function for the calculation of Up with Bounding Box support @@ -83,14 +79,11 @@ class SqXdPhidPhiUpBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr, float_t q, - float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* SQXDPHIDPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* SQXDPHIDPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiDownBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiDownBBLinear.cpp index ed45ea40ba..cd88ba44c8 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiDownBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiDownBBLinear.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +SqrtXPhiPhiDownBBLinear::SqrtXPhiPhiDownBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} - -SqrtXPhiPhiDownBBLinear::SqrtXPhiPhiDownBBLinear(SGPP::base::GridStorage* - storage) : storage(storage), boundingBox(storage->getBoundingBox()) { -} - -SqrtXPhiPhiDownBBLinear::~SqrtXPhiPhiDownBBLinear() { -} +SqrtXPhiPhiDownBBLinear::~SqrtXPhiPhiDownBBLinear() {} void SqrtXPhiPhiDownBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -38,9 +34,8 @@ void SqrtXPhiPhiDownBBLinear::operator()(SGPP::base::DataVector& source, } } -void SqrtXPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { +void SqrtXPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -67,26 +62,21 @@ void SqrtXPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, float_t iSq = pow(i, 2); float_t iCu = pow(i, 3); - float_t diagResultTemp = e * iCu * hCu - 3 * e * iSq * hCu + 3 * e * i * hCu + - 7 * d * iSq * hCu - c * iCu * hCu - - 3 * c * iSq * hCu - 3 * c * i * hCu - e * hCu - c * hCu; + float_t diagResultTemp = e * iCu * hCu - 3 * e * iSq * hCu + 3 * e * i * hCu + 7 * d * iSq * hCu - + c * iCu * hCu - 3 * c * iSq * hCu - 3 * c * i * hCu - e * hCu - c * hCu; diagResultTemp = (-16.0 / 105.0) * (1.0 / (hSq)) * diagResultTemp; - float_t downResultTemp = 2 * c * hCu * a + 5 * c * hCu * b + 4 * d * iCu * hCu * - b - 7 * d * iSq * hCu * b - - 4 * d * iCu * hCu * a - 8 * e * hCu * a * i - 6 * e * hCu * b * i - 2 * e * - iCu * hCu * b + - 6 * e * iSq * hCu * b + 2 * e * iCu * hCu * a + e * iSq * hCu * a + 5 * e * - hCu * a + 2 * e * hCu * b + - 6 * c * hCu * a * i - 2 * c * iCu * hCu * b + c * iSq * hCu * b + - 6 * c * iSq * hCu * a + 2 * c * iCu * hCu * a + 8 * c * i * hCu * b - 7 * d * - iSq * hCu * a; + float_t downResultTemp = + 2 * c * hCu * a + 5 * c * hCu * b + 4 * d * iCu * hCu * b - 7 * d * iSq * hCu * b - + 4 * d * iCu * hCu * a - 8 * e * hCu * a * i - 6 * e * hCu * b * i - 2 * e * iCu * hCu * b + + 6 * e * iSq * hCu * b + 2 * e * iCu * hCu * a + e * iSq * hCu * a + 5 * e * hCu * a + + 2 * e * hCu * b + 6 * c * hCu * a * i - 2 * c * iCu * hCu * b + c * iSq * hCu * b + + 6 * c * iSq * hCu * a + 2 * c * iCu * hCu * a + 8 * c * i * hCu * b - 7 * d * iSq * hCu * a; downResultTemp = (4.0 / 105.0) * (1.0 / (hSq)) * downResultTemp; - // integration - result[seq] = downResultTemp + ((diagResultTemp) * alpha_value); + result[seq] = downResultTemp + ((diagResultTemp)*alpha_value); // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -108,9 +98,9 @@ void SqrtXPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, } } -void SqrtXPhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr, float_t q, float_t t) { +void SqrtXPhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr, + float_t q, float_t t) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -141,55 +131,42 @@ void SqrtXPhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, float_t a = fl; float_t b = fr; - float_t diagResultTemp = e * iCu * hCu * qCu - 3 * e * iSq * hCu * qCu + 3 * e * - i * hCu * qCu - - 3 * e * tSq * q * h + 3 * e * t * qSq * hSq + 7 * d * tSq * q * h + 7 * d * - iSq * hCu * qCu - - c * iCu * hCu * qCu - 3 * c * iSq * hCu * qCu - 3 * c * i * hCu * qCu - - 3 * c * tSq * q * h - 3 * c * t * qSq * hSq + 3 * e * iSq * hSq * qSq * t - + 3 * e * i * h * q * tSq - 6 * e * i * hSq * qSq * t + 14 * d * t * qSq * hSq * - i - - 3 * c * iSq * hSq * qSq * t - 3 * c * i * h * q * tSq - 6 * c * i * hSq * - qSq * t - + e * tCu - c * tCu - e * qCu * hCu - c * qCu * hCu; + float_t diagResultTemp = + e * iCu * hCu * qCu - 3 * e * iSq * hCu * qCu + 3 * e * i * hCu * qCu - 3 * e * tSq * q * h + + 3 * e * t * qSq * hSq + 7 * d * tSq * q * h + 7 * d * iSq * hCu * qCu - c * iCu * hCu * qCu - + 3 * c * iSq * hCu * qCu - 3 * c * i * hCu * qCu - 3 * c * tSq * q * h - + 3 * c * t * qSq * hSq + 3 * e * iSq * hSq * qSq * t + 3 * e * i * h * q * tSq - + 6 * e * i * hSq * qSq * t + 14 * d * t * qSq * hSq * i - 3 * c * iSq * hSq * qSq * t - + 3 * c * i * h * q * tSq - 6 * c * i * hSq * qSq * t + e * tCu - c * tCu - e * qCu * hCu - + c * qCu * hCu; diagResultTemp = (-16.0 / 105.0) * (1.0 / (qSq * hSq)) * diagResultTemp; - float_t downResultTemp = 2 * c * qCu * hCu * a + 5 * c * qCu * hCu * b - 14 * - d * i * hSq * qSq * a * t - + 6 * c * a * tSq * i * h * q - 6 * c * b * tSq * i * h * q + 6 * c * iSq * - hSq * qSq * a * t - + 12 * c * i * hSq * qSq * a * t - 6 * c * iSq * hSq * qSq * b * t + 2 * c * i * - hSq * qSq * b * t - + 2 * e * a * tCu - 2 * e * b * tCu + 4 * d * b * tCu - 4 * d * a * tCu - + 4 * d * iCu * hCu * qCu * b - 7 * d * iSq * hCu * qCu * b - 4 * d * iCu * - hCu * qCu * a - 7 * d * tSq * b * q * h - - 8 * e * qCu * hCu * a * i - 8 * e * qSq * hSq * a * t - 6 * e * qCu * hCu * - b * i - - 6 * e * qSq * hSq * b * t + 6 * e * b * tSq * q * h + e * a * tSq * q * h - - 2 * e * iCu * hCu * qCu * b + 6 * e * iSq * hCu * qCu * b + 2 * e * iCu * - hCu * qCu * a - + e * iSq * hCu * qCu * a + 5 * e * qCu * hCu * a + 2 * e * qCu * hCu * b - - 14 * d * i * hSq * qSq * b * t + 6 * e * iSq * hSq * qSq * a * t + 6 * e * i * - h * q * a * tSq - + 2 * e * i * hSq * qSq * a * t - 6 * e * iSq * hSq * qSq * b * t - 6 * e * i * - h * q * b * tSq - + 12 * e * i * hSq * qSq * b * t + 12 * d * iSq * hSq * qSq * b * t + 12 * d * - i * h * q * b * tSq - - 12 * d * iSq * hSq * qSq * a * t - 12 * d * i * h * q * a * tSq + 2 * c * a * - tCu - 2 * c * b * tCu - + 6 * c * a * tSq * q * h + c * b * tSq * q * h + 6 * c * qCu * hCu * a * i - + 6 * c * qSq * hSq * a * t - 2 * c * iCu * hCu * qCu * b + c * iSq * hCu * - qCu * b - + 6 * c * iSq * hCu * qCu * a + 2 * c * iCu * hCu * qCu * a + 8 * c * t * b * - qSq * hSq - + 8 * c * i * hCu * qCu * b - 7 * d * iSq * hCu * qCu * a - 7 * d * tSq * a * - q * h; + float_t downResultTemp = + 2 * c * qCu * hCu * a + 5 * c * qCu * hCu * b - 14 * d * i * hSq * qSq * a * t + + 6 * c * a * tSq * i * h * q - 6 * c * b * tSq * i * h * q + 6 * c * iSq * hSq * qSq * a * t + + 12 * c * i * hSq * qSq * a * t - 6 * c * iSq * hSq * qSq * b * t + + 2 * c * i * hSq * qSq * b * t + 2 * e * a * tCu - 2 * e * b * tCu + 4 * d * b * tCu - + 4 * d * a * tCu + 4 * d * iCu * hCu * qCu * b - 7 * d * iSq * hCu * qCu * b - + 4 * d * iCu * hCu * qCu * a - 7 * d * tSq * b * q * h - 8 * e * qCu * hCu * a * i - + 8 * e * qSq * hSq * a * t - 6 * e * qCu * hCu * b * i - 6 * e * qSq * hSq * b * t + + 6 * e * b * tSq * q * h + e * a * tSq * q * h - 2 * e * iCu * hCu * qCu * b + + 6 * e * iSq * hCu * qCu * b + 2 * e * iCu * hCu * qCu * a + e * iSq * hCu * qCu * a + + 5 * e * qCu * hCu * a + 2 * e * qCu * hCu * b - 14 * d * i * hSq * qSq * b * t + + 6 * e * iSq * hSq * qSq * a * t + 6 * e * i * h * q * a * tSq + + 2 * e * i * hSq * qSq * a * t - 6 * e * iSq * hSq * qSq * b * t - + 6 * e * i * h * q * b * tSq + 12 * e * i * hSq * qSq * b * t + + 12 * d * iSq * hSq * qSq * b * t + 12 * d * i * h * q * b * tSq - + 12 * d * iSq * hSq * qSq * a * t - 12 * d * i * h * q * a * tSq + 2 * c * a * tCu - + 2 * c * b * tCu + 6 * c * a * tSq * q * h + c * b * tSq * q * h + 6 * c * qCu * hCu * a * i + + 6 * c * qSq * hSq * a * t - 2 * c * iCu * hCu * qCu * b + c * iSq * hCu * qCu * b + + 6 * c * iSq * hCu * qCu * a + 2 * c * iCu * hCu * qCu * a + 8 * c * t * b * qSq * hSq + + 8 * c * i * hCu * qCu * b - 7 * d * iSq * hCu * qCu * a - 7 * d * tSq * a * q * h; downResultTemp = (4.0 / 105.0) * (1.0 / (qSq * hSq)) * downResultTemp; // integration - result[seq] = downResultTemp + ((diagResultTemp) * alpha_value); + result[seq] = downResultTemp + ((diagResultTemp)*alpha_value); // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -211,7 +188,5 @@ void SqrtXPhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiDownBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiDownBBLinear.hpp index ecaf421a71..b8ddbe7027 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiDownBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiDownBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \sqrt{x} \phi(x) \phi(x) dx\f$ @@ -36,7 +33,7 @@ class SqrtXPhiPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - SqrtXPhiPhiDownBBLinear(SGPP::base::GridStorage* storage); + explicit SqrtXPhiPhiDownBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class SqrtXPhiPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * on a grid with Dirichlet 0 boundary conditions. * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down without Bounding Box * @@ -67,8 +64,8 @@ class SqrtXPhiPhiDownBBLinear { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); /** * recursive function for the calculation of Down with Bouding Box @@ -82,13 +79,11 @@ class SqrtXPhiPhiDownBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr, float_t q, float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* SQRTXPHIPHIDOWNBBLINEAR_HPP */ \ No newline at end of file +#endif /* SQRTXPHIPHIDOWNBBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiUpBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiUpBBLinear.cpp index 47b40920f5..5efbe41c4b 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiUpBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiUpBBLinear.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +SqrtXPhiPhiUpBBLinear::SqrtXPhiPhiUpBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} - -SqrtXPhiPhiUpBBLinear::SqrtXPhiPhiUpBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -SqrtXPhiPhiUpBBLinear::~SqrtXPhiPhiUpBBLinear() { -} +SqrtXPhiPhiUpBBLinear::~SqrtXPhiPhiUpBBLinear() {} void SqrtXPhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -42,9 +38,8 @@ void SqrtXPhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, } } -void SqrtXPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void SqrtXPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -88,24 +83,15 @@ void SqrtXPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, float_t iSq = pow(i, 2); float_t iCu = pow(i, 3); - float_t flTemp = 2 * c * hCu - - 4 * d * iCu * hCu - - 8 * e * hCu * i - + 2 * e * iCu * hCu - + e * iSq * hCu + 5 * e * hCu - + 6 * c * hCu * i - + 6 * c * iSq * hCu + 2 * c * iCu * hCu - - 7 * d * iSq * hCu; + float_t flTemp = 2 * c * hCu - 4 * d * iCu * hCu - 8 * e * hCu * i + 2 * e * iCu * hCu + + e * iSq * hCu + 5 * e * hCu + 6 * c * hCu * i + 6 * c * iSq * hCu + + 2 * c * iCu * hCu - 7 * d * iSq * hCu; flTemp = (4.0 / 105.0) * (1 / (hSq)) * flTemp; - float_t frTemp = 5 * c * hCu - + 4 * d * iCu * hCu - 7 * d * iSq * hCu - - 6 * e * hCu * i - - 2 * e * iCu * hCu + 6 * e * iSq * hCu - + 2 * e * hCu - - 2 * c * iCu * hCu + c * iSq * hCu - + 8 * c * i * hCu; + float_t frTemp = 5 * c * hCu + 4 * d * iCu * hCu - 7 * d * iSq * hCu - 6 * e * hCu * i - + 2 * e * iCu * hCu + 6 * e * iSq * hCu + 2 * e * hCu - 2 * c * iCu * hCu + + c * iSq * hCu + 8 * c * i * hCu; frTemp = (4.0 / 105.0) * (1 / (hSq)) * frTemp; @@ -116,9 +102,9 @@ void SqrtXPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, result[seq] = fm; } -void SqrtXPhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr, float_t q, float_t t) { +void SqrtXPhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr, + float_t q, float_t t) { size_t seq = index.seq(); fl = fr = 0.0; @@ -138,7 +124,7 @@ void SqrtXPhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, index.stepRight(dim); if (!storage->end(index.seq())) { - recBB(source, result, index, dim, fmr, fr, q , t); + recBB(source, result, index, dim, fmr, fr, q, t); } index.up(dim); @@ -169,53 +155,33 @@ void SqrtXPhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, float_t iSq = pow(i, 2); float_t iCu = pow(i, 3); - float_t flTemp = 2 * c * qCu * hCu - 14 * d * i * hSq * qSq * t - + 6 * c * tSq * i * h * q + 6 * c * iSq * hSq * qSq * t - + 12 * c * i * hSq * qSq * t - + 2 * e * tCu - 4 * d * tCu - - 4 * d * iCu * hCu * qCu - - 8 * e * qCu * hCu * i - 8 * e * qSq * hSq * t - + e * tSq * q * h - + 2 * e * iCu * hCu * qCu - + e * iSq * hCu * qCu + 5 * e * qCu * hCu - + 6 * e * iSq * hSq * qSq * t + 6 * e * i * h * q * tSq - + 2 * e * i * hSq * qSq * t - - 12 * d * iSq * hSq * qSq * t - 12 * d * i * h * q * tSq + 2 * c * tCu - + 6 * c * tSq * q * h + 6 * c * qCu * hCu * i - + 6 * c * qSq * hSq * t - + 6 * c * iSq * hCu * qCu + 2 * c * iCu * hCu * qCu - - 7 * d * iSq * hCu * qCu - 7 * d * tSq * q * h; + float_t flTemp = + 2 * c * qCu * hCu - 14 * d * i * hSq * qSq * t + 6 * c * tSq * i * h * q + + 6 * c * iSq * hSq * qSq * t + 12 * c * i * hSq * qSq * t + 2 * e * tCu - 4 * d * tCu - + 4 * d * iCu * hCu * qCu - 8 * e * qCu * hCu * i - 8 * e * qSq * hSq * t + e * tSq * q * h + + 2 * e * iCu * hCu * qCu + e * iSq * hCu * qCu + 5 * e * qCu * hCu + + 6 * e * iSq * hSq * qSq * t + 6 * e * i * h * q * tSq + 2 * e * i * hSq * qSq * t - + 12 * d * iSq * hSq * qSq * t - 12 * d * i * h * q * tSq + 2 * c * tCu + 6 * c * tSq * q * h + + 6 * c * qCu * hCu * i + 6 * c * qSq * hSq * t + 6 * c * iSq * hCu * qCu + + 2 * c * iCu * hCu * qCu - 7 * d * iSq * hCu * qCu - 7 * d * tSq * q * h; flTemp = (4.0 / 105.0) * (1 / (qSq * hSq)) * flTemp; - float_t frTemp = 5 * c * qCu * hCu - - 6 * c * tSq * i * h * q - - 6 * c * iSq * hSq * qSq * t + 2 * c * i * hSq * qSq * t - - 2 * e * tCu + 4 * d * tCu - + 4 * d * iCu * hCu * qCu - 7 * d * iSq * hCu * qCu - 7 * d * tSq * q * h - - 6 * e * qCu * hCu * i - - 6 * e * qSq * hSq * t + 6 * e * tSq * q * h - - 2 * e * iCu * hCu * qCu + 6 * e * iSq * hCu * qCu - + 2 * e * qCu * hCu - - 14 * d * i * hSq * qSq * t - - 6 * e * iSq * hSq * qSq * t - 6 * e * i * h * q * tSq - + 12 * e * i * hSq * qSq * t + 12 * d * iSq * hSq * qSq * t + 12 * d * i * h * - q * tSq - - 2 * c * tCu - + c * tSq * q * h - - 2 * c * iCu * hCu * qCu + c * iSq * hCu * qCu - + 8 * c * t * qSq * hSq - + 8 * c * i * hCu * qCu; + float_t frTemp = + 5 * c * qCu * hCu - 6 * c * tSq * i * h * q - 6 * c * iSq * hSq * qSq * t + + 2 * c * i * hSq * qSq * t - 2 * e * tCu + 4 * d * tCu + 4 * d * iCu * hCu * qCu - + 7 * d * iSq * hCu * qCu - 7 * d * tSq * q * h - 6 * e * qCu * hCu * i - + 6 * e * qSq * hSq * t + 6 * e * tSq * q * h - 2 * e * iCu * hCu * qCu + + 6 * e * iSq * hCu * qCu + 2 * e * qCu * hCu - 14 * d * i * hSq * qSq * t - + 6 * e * iSq * hSq * qSq * t - 6 * e * i * h * q * tSq + 12 * e * i * hSq * qSq * t + + 12 * d * iSq * hSq * qSq * t + 12 * d * i * h * q * tSq - 2 * c * tCu + c * tSq * q * h - + 2 * c * iCu * hCu * qCu + c * iSq * hCu * qCu + 8 * c * t * qSq * hSq + 8 * c * i * hCu * qCu; frTemp = (4.0 / 105.0) * (1 / (qSq * hSq)) * frTemp; - - fl = ((fm / 2.0) + (alpha_value * (flTemp))) + fl; fr = ((fm / 2.0) + (alpha_value * (frTemp))) + fr; } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiUpBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiUpBBLinear.hpp index efdda4b9e7..c221459108 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiUpBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/SqrtXPhiPhiUpBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \sqrt{x} \phi(x) \phi(x) dx\f$ @@ -36,7 +33,7 @@ class SqrtXPhiPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - SqrtXPhiPhiUpBBLinear(SGPP::base::GridStorage* storage); + explicit SqrtXPhiPhiUpBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class SqrtXPhiPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up without bounding Box support * @@ -67,8 +64,8 @@ class SqrtXPhiPhiUpBBLinear { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); /** * recursive function for the calculation of Up with Bounding Box Support @@ -82,14 +79,11 @@ class SqrtXPhiPhiUpBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr, float_t q, - float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* SQRTXPHIPHIUPBBLINEAR_HPP */ \ No newline at end of file +#endif /* SQRTXPHIPHIUPBBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiDownBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiDownBBLinear.cpp index abfbde56c1..94d6754fa6 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiDownBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiDownBBLinear.cpp @@ -7,21 +7,16 @@ #include - namespace SGPP { namespace finance { +XPhiPhiDownBBLinear::XPhiPhiDownBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} +XPhiPhiDownBBLinear::~XPhiPhiDownBBLinear() {} -XPhiPhiDownBBLinear::XPhiPhiDownBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -XPhiPhiDownBBLinear::~XPhiPhiDownBBLinear() { -} - -void XPhiPhiDownBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void XPhiPhiDownBBLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -38,9 +33,8 @@ void XPhiPhiDownBBLinear::operator()(SGPP::base::DataVector& source, } } -void XPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { +void XPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -56,8 +50,8 @@ void XPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, float_t hsquare = (1.0 / static_cast(1 << (2 * l_int))); // integration - result[seq] = (hsquare * ((fl + fr) / 2.0)) * i_dbl + hsquare * - (fr - fl) / 12.0 + (((2.0 / 3.0) * hsquare * i_dbl) * alpha_value); + result[seq] = (hsquare * ((fl + fr) / 2.0)) * i_dbl + hsquare * (fr - fl) / 12.0 + + (((2.0 / 3.0) * hsquare * i_dbl) * alpha_value); // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -79,9 +73,9 @@ void XPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, } } -void XPhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr, float_t q, float_t t) { +void XPhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr, float_t q, + float_t t) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -97,9 +91,10 @@ void XPhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, float_t h = (1.0 / (static_cast(1 << (l_int)))); // integration - result[seq] = (h * h * i_dbl * q * q + h * q * t) * ((fl + fr) / 2.0) + h * h * - q * q * (fr - fl) / 12.0 + (((2.0 / 3.0) * h * q * t + (2.0 / 3.0) * i_dbl * h * - h * q * q ) * alpha_value); // diagonal entry + result[seq] = (h * h * i_dbl * q * q + h * q * t) * ((fl + fr) / 2.0) + + h * h * q * q * (fr - fl) / 12.0 + + (((2.0 / 3.0) * h * q * t + (2.0 / 3.0) * i_dbl * h * h * q * q) * + alpha_value); // diagonal entry // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -121,7 +116,5 @@ void XPhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiDownBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiDownBBLinear.hpp index 416da51b94..ac6b0656df 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiDownBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiDownBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x \phi(x) \phi(x) dx\f$ @@ -36,7 +33,7 @@ class XPhiPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XPhiPhiDownBBLinear(SGPP::base::GridStorage* storage); + explicit XPhiPhiDownBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class XPhiPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * on a grid with Dirichlet 0 boundary conditions. * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down without Bounding Box * @@ -67,8 +64,8 @@ class XPhiPhiDownBBLinear { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); /** * recursive function for the calculation of Down with Bouding Box @@ -82,13 +79,11 @@ class XPhiPhiDownBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr, float_t q, float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XPHIPHIDOWNBBLINEAR_HPP */ \ No newline at end of file +#endif /* XPHIPHIDOWNBBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiUpBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiUpBBLinear.cpp index 474158651f..aca20ae4dc 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiUpBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiUpBBLinear.cpp @@ -7,21 +7,16 @@ #include - namespace SGPP { namespace finance { +XPhiPhiUpBBLinear::XPhiPhiUpBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} +XPhiPhiUpBBLinear::~XPhiPhiUpBBLinear() {} -XPhiPhiUpBBLinear::XPhiPhiUpBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -XPhiPhiUpBBLinear::~XPhiPhiUpBBLinear() { -} - -void XPhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void XPhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -42,9 +37,8 @@ void XPhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, } } -void XPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void XPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -76,21 +70,22 @@ void XPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, float_t alpha_value = source[seq]; - float_t hsquare = (1.0 / static_cast(1 << (2 * static_cast - (current_level)))); + float_t hsquare = (1.0 / static_cast(1 << (2 * static_cast(current_level)))); // transposed operations: result[seq] = fm; - fl = ((fm / 2.0) + (alpha_value * (hsquare / 2.0 * static_cast - (current_index) - hsquare / 12.0))) + fl; - fr = ((fm / 2.0) + (alpha_value * (hsquare / 2.0 * static_cast - (current_index) + hsquare / 12.0))) + fr; + fl = ((fm / 2.0) + + (alpha_value * (hsquare / 2.0 * static_cast(current_index) - hsquare / 12.0))) + + fl; + fr = ((fm / 2.0) + + (alpha_value * (hsquare / 2.0 * static_cast(current_index) + hsquare / 12.0))) + + fr; } -void XPhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr, float_t q, float_t t) { +void XPhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr, float_t q, + float_t t) { size_t seq = index.seq(); fl = fr = 0.0; @@ -110,7 +105,7 @@ void XPhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, index.stepRight(dim); if (!storage->end(index.seq())) { - recBB(source, result, index, dim, fmr, fr, q , t); + recBB(source, result, index, dim, fmr, fr, q, t); } index.up(dim); @@ -126,13 +121,13 @@ void XPhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, // transposed operations: result[seq] = fm; - fl = ((fm / 2.0) + (alpha_value * (h * h / 2.0 * static_cast - (current_index) * q * q + h * t * q / 4.0 - h * h / 12.0 * q * q))) + fl; - fr = ((fm / 2.0) + (alpha_value * (h * h / 2.0 * static_cast - (current_index) * q * q + h * t * q / 4.0 + h * h / 12.0 * q * q))) + fr; + fl = ((fm / 2.0) + (alpha_value * (h * h / 2.0 * static_cast(current_index) * q * q + + h * t * q / 4.0 - h * h / 12.0 * q * q))) + + fl; + fr = ((fm / 2.0) + (alpha_value * (h * h / 2.0 * static_cast(current_index) * q * q + + h * t * q / 4.0 + h * h / 12.0 * q * q))) + + fr; } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiUpBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiUpBBLinear.hpp index 631506912a..64d2e4da4e 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiUpBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhiPhiUpBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x \phi(x) \phi(x) dx\f$ @@ -36,7 +33,7 @@ class XPhiPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XPhiPhiUpBBLinear(SGPP::base::GridStorage* storage); + explicit XPhiPhiUpBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class XPhiPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up without bounding Box support * @@ -67,8 +64,8 @@ class XPhiPhiUpBBLinear { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); /** * recursive function for the calculation of Up with Bounding Box Support @@ -82,14 +79,11 @@ class XPhiPhiUpBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr, float_t q, - float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XPHIPHIUPBBLINEAR_HPP */ \ No newline at end of file +#endif /* XPHIPHIUPBBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiDownBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiDownBBLinear.cpp index 8cf585c746..5822201bad 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiDownBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiDownBBLinear.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +XPhidPhiDownBBLinear::XPhidPhiDownBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} - -XPhidPhiDownBBLinear::XPhidPhiDownBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -XPhidPhiDownBBLinear::~XPhidPhiDownBBLinear() { -} +XPhidPhiDownBBLinear::~XPhidPhiDownBBLinear() {} void XPhidPhiDownBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -38,9 +34,8 @@ void XPhidPhiDownBBLinear::operator()(SGPP::base::DataVector& source, } } -void XPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { +void XPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -54,9 +49,9 @@ void XPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, float_t i_dbl = static_cast(i); // integration - result[seq] = ( ( (fl * ((hhalf * i_dbl) - hhalf)) + (fr * (((-1.0) * - (hhalf * i_dbl)) - hhalf)) ) - ((1.0 / 3.0) * (((1.0 / static_cast - (1 << l))) * alpha_value)) ); // diagonal entry + result[seq] = + (((fl * ((hhalf * i_dbl) - hhalf)) + (fr * (((-1.0) * (hhalf * i_dbl)) - hhalf))) - + ((1.0 / 3.0) * (((1.0 / static_cast(1 << l))) * alpha_value))); // diagonal entry // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -78,9 +73,9 @@ void XPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, } } -void XPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr, float_t q, float_t t) { +void XPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr, + float_t q, float_t t) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -94,10 +89,10 @@ void XPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, float_t i_dbl = static_cast(i); // integration - result[seq] = ( ( (fl * ((q * ((hhalf * i_dbl) - hhalf)) + (0.5 * t))) + - (fr * ((q * (((-1.0) * (hhalf * i_dbl)) - hhalf)) - (0.5 * t))) ) - - ((1.0 / 3.0) * (((1.0 / static_cast(1 << l)) * q) * - alpha_value)) ); // diagonal entry + result[seq] = (((fl * ((q * ((hhalf * i_dbl) - hhalf)) + (0.5 * t))) + + (fr * ((q * (((-1.0) * (hhalf * i_dbl)) - hhalf)) - (0.5 * t)))) - + ((1.0 / 3.0) * + (((1.0 / static_cast(1 << l)) * q) * alpha_value))); // diagonal entry // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -119,7 +114,5 @@ void XPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiDownBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiDownBBLinear.hpp index 68f247ed55..d5da4aa611 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiDownBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiDownBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -36,7 +33,7 @@ class XPhidPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XPhidPhiDownBBLinear(SGPP::base::GridStorage* storage); + explicit XPhidPhiDownBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class XPhidPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary condition * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down without Bounding Box support * @@ -67,8 +64,8 @@ class XPhidPhiDownBBLinear { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); /** * recursive function for the calculation of Down wit Bounding Box support @@ -82,13 +79,11 @@ class XPhidPhiDownBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr, float_t q, float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XPHIDPHIDOWNBBLINEAR_HPP */ \ No newline at end of file +#endif /* XPHIDPHIDOWNBBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiUpBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiUpBBLinear.cpp index b30af14f3b..0202788f8d 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiUpBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiUpBBLinear.cpp @@ -7,21 +7,16 @@ #include - namespace SGPP { namespace finance { +XPhidPhiUpBBLinear::XPhidPhiUpBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} +XPhidPhiUpBBLinear::~XPhidPhiUpBBLinear() {} -XPhidPhiUpBBLinear::XPhidPhiUpBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -XPhidPhiUpBBLinear::~XPhidPhiUpBBLinear() { -} - -void XPhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void XPhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -42,9 +37,8 @@ void XPhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, } } -void XPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void XPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -86,9 +80,9 @@ void XPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, fr = (fm / 2.0) + ((alpha_value * helper) + fr); } -void XPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr, float_t q, float_t t) { +void XPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr, + float_t q, float_t t) { size_t seq = index.seq(); fl = fr = 0.0; @@ -121,7 +115,8 @@ void XPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, float_t alpha_value = source[seq]; float_t helper = (1.0 / static_cast(1 << (current_level + 1))) * - (q * static_cast(current_index)) + (0.5 * t); + (q * static_cast(current_index)) + + (0.5 * t); // transposed operations: result[seq] = fm; @@ -130,7 +125,5 @@ void XPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, fr = (fm / 2.0) + ((alpha_value * helper) + fr); } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiUpBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiUpBBLinear.hpp index a3529d8bbb..999765289b 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiUpBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XPhidPhiUpBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -36,7 +33,7 @@ class XPhidPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XPhidPhiUpBBLinear(SGPP::base::GridStorage* storage); + explicit XPhidPhiUpBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,7 +44,8 @@ class XPhidPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * on a a grid with fix Dirichlet 0 boundary condition * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -56,7 +54,6 @@ class XPhidPhiUpBBLinear { grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up * @@ -67,8 +64,8 @@ class XPhidPhiUpBBLinear { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); /** * recursive function for the calculation of Up with Bounding Box support @@ -82,14 +79,11 @@ class XPhidPhiUpBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr, float_t q, - float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XPHIDPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* XPHIDPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiDownBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiDownBBLinear.cpp index 3cf222de44..8ac8f3e3f9 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiDownBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiDownBBLinear.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +XdPhiPhiDownBBLinear::XdPhiPhiDownBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} - -XdPhiPhiDownBBLinear::XdPhiPhiDownBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -XdPhiPhiDownBBLinear::~XdPhiPhiDownBBLinear() { -} +XdPhiPhiDownBBLinear::~XdPhiPhiDownBBLinear() {} void XdPhiPhiDownBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -38,9 +34,8 @@ void XdPhiPhiDownBBLinear::operator()(SGPP::base::DataVector& source, } } -void XdPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { +void XdPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -50,12 +45,12 @@ void XdPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, index.get(dim, l, i); - float_t helper = (1.0 / static_cast(1 << (l + 1))) * - (static_cast(i)); + float_t helper = (1.0 / static_cast(1 << (l + 1))) * (static_cast(i)); // integration - result[seq] = ( ( (fr - fl) * (helper) ) - ((1.0 / 3.0) * ((( - 1.0 / static_cast(1 << l))) * alpha_value)) ); // diagonal entry + result[seq] = + (((fr - fl) * (helper)) - + ((1.0 / 3.0) * (((1.0 / static_cast(1 << l))) * alpha_value))); // diagonal entry // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -77,9 +72,9 @@ void XdPhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, } } -void XdPhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr, float_t q, float_t t) { +void XdPhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr, + float_t q, float_t t) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -89,13 +84,12 @@ void XdPhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, index.get(dim, l, i); - float_t helper = (1.0 / static_cast(1 << (l + 1))) * - (q * static_cast(i)); + float_t helper = (1.0 / static_cast(1 << (l + 1))) * (q * static_cast(i)); // integration - result[seq] = ( ( (fr - fl) * (helper + (0.5 * t)) ) - - ((1.0 / 3.0) * (((1.0 / static_cast(1 << l)) * q) * - alpha_value)) ); // diagonal entry + result[seq] = (((fr - fl) * (helper + (0.5 * t))) - + ((1.0 / 3.0) * + (((1.0 / static_cast(1 << l)) * q) * alpha_value))); // diagonal entry // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -117,7 +111,5 @@ void XdPhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiDownBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiDownBBLinear.hpp index a32c1e1438..0af6a106f3 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiDownBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiDownBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -30,14 +27,13 @@ class XdPhiPhiDownBBLinear { /// Pointer to the bounding box Obejct SGPP::base::BoundingBox* boundingBox; - public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - XdPhiPhiDownBBLinear(SGPP::base::GridStorage* storage); + explicit XdPhiPhiDownBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -48,7 +44,8 @@ class XdPhiPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -57,7 +54,6 @@ class XdPhiPhiDownBBLinear { grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down without Bounding Box support * @@ -68,8 +64,8 @@ class XdPhiPhiDownBBLinear { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); /** * recursive function for the calculation of Down wit Bounding Box support @@ -83,13 +79,11 @@ class XdPhiPhiDownBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr, float_t q, float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XDPHIPHIDOWNBBLINEAR_HPP */ \ No newline at end of file +#endif /* XDPHIPHIDOWNBBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiUpBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiUpBBLinear.cpp index 10b85d68da..b62df66ea0 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiUpBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiUpBBLinear.cpp @@ -7,21 +7,16 @@ #include - namespace SGPP { namespace finance { +XdPhiPhiUpBBLinear::XdPhiPhiUpBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} +XdPhiPhiUpBBLinear::~XdPhiPhiUpBBLinear() {} -XdPhiPhiUpBBLinear::XdPhiPhiUpBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -XdPhiPhiUpBBLinear::~XdPhiPhiUpBBLinear() { -} - -void XdPhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void XdPhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -42,9 +37,8 @@ void XdPhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, } } -void XdPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void XdPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -86,9 +80,9 @@ void XdPhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, fr = (fm / 2.0) + ((alpha_value * (((-1.0) * (hhalf * i_dbl)) - hhalf)) + fr); } -void XdPhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr, float_t q, float_t t) { +void XdPhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr, + float_t q, float_t t) { size_t seq = index.seq(); fl = fr = 0.0; @@ -126,13 +120,9 @@ void XdPhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, // transposed operations: result[seq] = fm; - fl = (fm / 2.0) + ((alpha_value * ((q * ((hhalf * i_dbl) - hhalf)) + - (0.5 * t))) + fl); - fr = (fm / 2.0) + ((alpha_value * ((q * (((-1.0) * (hhalf * i_dbl)) - hhalf)) - - (0.5 * t))) + fr); + fl = (fm / 2.0) + ((alpha_value * ((q * ((hhalf * i_dbl) - hhalf)) + (0.5 * t))) + fl); + fr = (fm / 2.0) + ((alpha_value * ((q * (((-1.0) * (hhalf * i_dbl)) - hhalf)) - (0.5 * t))) + fr); } -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiUpBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiUpBBLinear.hpp index 9229ca6288..aa5aef849c 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiUpBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhiPhiUpBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -36,7 +33,7 @@ class XdPhiPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XdPhiPhiUpBBLinear(SGPP::base::GridStorage* storage); + explicit XdPhiPhiUpBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,7 +44,8 @@ class XdPhiPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -56,7 +54,6 @@ class XdPhiPhiUpBBLinear { grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up * @@ -67,8 +64,8 @@ class XdPhiPhiUpBBLinear { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); /** * recursive function for the calculation of Up with Bounding Box support @@ -82,14 +79,11 @@ class XdPhiPhiUpBBLinear { * @param q strechting parameter * @param t translation parameter */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr, float_t q, - float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XDPHIPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* XDPHIPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiDownBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiDownBBLinear.cpp index ed6df93ed7..a1c3a86f94 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiDownBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiDownBBLinear.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +XdPhidPhiDownBBLinear::XdPhidPhiDownBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} - -XdPhidPhiDownBBLinear::XdPhidPhiDownBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -XdPhidPhiDownBBLinear::~XdPhidPhiDownBBLinear() { -} +XdPhidPhiDownBBLinear::~XdPhidPhiDownBBLinear() {} void XdPhidPhiDownBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -38,9 +34,8 @@ void XdPhidPhiDownBBLinear::operator()(SGPP::base::DataVector& source, } } -void XdPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { +void XdPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -51,14 +46,14 @@ void XdPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, index.get(dim, l, i); float_t i_dbl = static_cast(i); - //int l_int = static_cast(l); + // int l_int = static_cast(l); - //float_t h = (1.0/(static_cast(1<<(l_int)))); + // float_t h = (1.0/(static_cast(1<<(l_int)))); float_t diagonal = 2 * i_dbl; // integration - result[seq] = ( (0.5 * (fl - fr)) + (diagonal * alpha_value) ); + result[seq] = ((0.5 * (fl - fr)) + (diagonal * alpha_value)); // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -80,9 +75,9 @@ void XdPhidPhiDownBBLinear::rec(SGPP::base::DataVector& source, } } -void XdPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr, float_t q, float_t t) { +void XdPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr, + float_t q, float_t t) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -92,7 +87,7 @@ void XdPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, index.get(dim, l, i); - //float_t i_dbl = static_cast(i); + // float_t i_dbl = static_cast(i); int l_int = static_cast(l); float_t h = (1.0 / (static_cast(1 << (l_int)))); @@ -100,7 +95,7 @@ void XdPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, float_t diagonal = (2 * (static_cast(i) * h * q + t)) / (q * h); // integration - result[seq] = ( (0.5 * q * (fl - fr)) + (diagonal * alpha_value) ); + result[seq] = ((0.5 * q * (fl - fr)) + (diagonal * alpha_value)); // dehierarchisation float_t fm = ((fl + fr) / 2.0) + alpha_value; @@ -122,7 +117,5 @@ void XdPhidPhiDownBBLinear::recBB(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiDownBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiDownBBLinear.hpp index 2a4486a9fc..5b370cc22c 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiDownBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiDownBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ @@ -36,7 +33,7 @@ class XdPhidPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XdPhidPhiDownBBLinear(SGPP::base::GridStorage* storage); + explicit XdPhidPhiDownBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class XdPhidPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down without Bounding Box support * @@ -67,8 +64,8 @@ class XdPhidPhiDownBBLinear { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); /** * recursive function for the calculation of Down with Bounding Box support @@ -82,13 +79,11 @@ class XdPhidPhiDownBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr, float_t q, float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XDPHIDPHIDOWNBBLINEAR_HPP */ \ No newline at end of file +#endif /* XDPHIDPHIDOWNBBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiUpBBLinear.cpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiUpBBLinear.cpp index d234d60f70..da6e49b35f 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiUpBBLinear.cpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiUpBBLinear.cpp @@ -7,23 +7,16 @@ #include - namespace SGPP { namespace finance { +XdPhidPhiUpBBLinear::XdPhidPhiUpBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} +XdPhidPhiUpBBLinear::~XdPhidPhiUpBBLinear() {} -XdPhidPhiUpBBLinear::XdPhidPhiUpBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - - -XdPhidPhiUpBBLinear::~XdPhidPhiUpBBLinear() { -} - - -void XdPhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void XdPhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -44,9 +37,8 @@ void XdPhidPhiUpBBLinear::operator()(SGPP::base::DataVector& source, } } -void XdPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void XdPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -85,9 +77,9 @@ void XdPhidPhiUpBBLinear::rec(SGPP::base::DataVector& source, fr = (fm / 2.0) + (alpha_value * ((-0.5))) + fr; } -void XdPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr, float_t q, float_t t) { +void XdPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr, + float_t q, float_t t) { size_t seq = index.seq(); fl = fr = 0.0; @@ -126,7 +118,5 @@ void XdPhidPhiUpBBLinear::recBB(SGPP::base::DataVector& source, fr = (fm / 2.0) + (alpha_value * ((-0.5) * q)) + fr; } -// namespace detail -} -// namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiUpBBLinear.hpp b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiUpBBLinear.hpp index 35e9ba571b..d80fe4f6c3 100644 --- a/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiUpBBLinear.hpp +++ b/finance/src/sgpp/finance/basis/linear/noboundary/algorithm_sweep/XdPhidPhiUpBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ @@ -36,28 +33,27 @@ class XdPhidPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - XdPhidPhiUpBBLinear(SGPP::base::GridStorage* storage); + explicit XdPhidPhiUpBBLinear(SGPP::base::GridStorage* storage); /** * Destructor */ virtual ~XdPhidPhiUpBBLinear(); - /** * This operations performs the calculation of up in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up without Bounding Box support * @@ -68,8 +64,8 @@ class XdPhidPhiUpBBLinear { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); /** * recursive function for the calculation of Up with Bounding Box support @@ -83,14 +79,11 @@ class XdPhidPhiUpBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr, float_t q, - float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XDPHIDPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* XDPHIDPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiDownBBLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiDownBBLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index 62ba1761d7..6524678d72 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiDownBBLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiDownBBLinearStretchedBoundary.cpp @@ -7,22 +7,18 @@ #include - namespace SGPP { namespace finance { - - DPhiPhiDownBBLinearStretchedBoundary::DPhiPhiDownBBLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : DPhiPhiDownBBLinearStretched(storage) { -} - -DPhiPhiDownBBLinearStretchedBoundary::~DPhiPhiDownBBLinearStretchedBoundary() { -} + SGPP::base::GridStorage* storage) + : DPhiPhiDownBBLinearStretched(storage) {} +DPhiPhiDownBBLinearStretchedBoundary::~DPhiPhiDownBBLinearStretchedBoundary() {} -void DPhiPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& - source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void DPhiPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { // get boundary values float_t left_boundary; float_t right_boundary; @@ -44,18 +40,17 @@ void DPhiPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& seq_right = index.seq(); right_boundary = source[seq_right]; - // the following is independent from a bounding box // check boundary conditions if (this->stretching->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = left_boundary * (-0.5); } if (this->stretching->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = right_boundary * (0.5); // down @@ -75,7 +70,5 @@ void DPhiPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiDownBBLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiDownBBLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 5d28e45979..697cfb6471 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiDownBBLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiDownBBLinearStretchedBoundary.hpp @@ -13,26 +13,22 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of SGPP::base::sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{x} \phi(x) dx\f$ * on linear boundary grids */ -class DPhiPhiDownBBLinearStretchedBoundary : public - DPhiPhiDownBBLinearStretched { +class DPhiPhiDownBBLinearStretchedBoundary : public DPhiPhiDownBBLinearStretched { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - DPhiPhiDownBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit DPhiPhiDownBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -43,22 +39,22 @@ class DPhiPhiDownBBLinearStretchedBoundary : public * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* DPHIPHIDOWNBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* DPHIPHIDOWNBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiUpBBLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiUpBBLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index 0c0c35f9fa..f330f3f58d --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiUpBBLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiUpBBLinearStretchedBoundary.cpp @@ -7,21 +7,18 @@ #include - namespace SGPP { namespace finance { - - DPhiPhiUpBBLinearStretchedBoundary::DPhiPhiUpBBLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : DPhiPhiUpBBLinearStretched(storage) { -} + SGPP::base::GridStorage* storage) + : DPhiPhiUpBBLinearStretched(storage) {} -DPhiPhiUpBBLinearStretchedBoundary::~DPhiPhiUpBBLinearStretchedBoundary() { -} +DPhiPhiUpBBLinearStretchedBoundary::~DPhiPhiUpBBLinearStretchedBoundary() {} -void DPhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& - source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void DPhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { // get boundary values float_t fl = 0.0; float_t fr = 0.0; @@ -48,7 +45,7 @@ void DPhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& // check boundary conditions if (this->stretching->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { // up ////////////////////////////////////// @@ -58,7 +55,7 @@ void DPhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& } if (this->stretching->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -66,7 +63,5 @@ void DPhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& index.resetToLeftLevelZero(dim); } -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiUpBBLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiUpBBLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 1d45c57565..f1c3b0b38e --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiUpBBLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/DPhiPhiUpBBLinearStretchedBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of SGPP::base::sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -31,7 +28,7 @@ class DPhiPhiUpBBLinearStretchedBoundary : public DPhiPhiUpBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - DPhiPhiUpBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit DPhiPhiUpBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class DPhiPhiUpBBLinearStretchedBoundary : public DPhiPhiUpBBLinearStretched { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* DPHIPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* DPHIPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiDownBBLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiDownBBLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index f88f06e71a..8a5fab7568 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiDownBBLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiDownBBLinearStretchedBoundary.cpp @@ -7,21 +7,18 @@ #include - namespace SGPP { namespace finance { - - PhidPhiDownBBLinearStretchedBoundary::PhidPhiDownBBLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : PhidPhiDownBBLinearStretched(storage) { -} + SGPP::base::GridStorage* storage) + : PhidPhiDownBBLinearStretched(storage) {} -PhidPhiDownBBLinearStretchedBoundary::~PhidPhiDownBBLinearStretchedBoundary() { -} +PhidPhiDownBBLinearStretchedBoundary::~PhidPhiDownBBLinearStretchedBoundary() {} -void PhidPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& - source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void PhidPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { // get boundary values float_t left_boundary; float_t right_boundary; @@ -43,18 +40,17 @@ void PhidPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& seq_right = index.seq(); right_boundary = source[seq_right]; - // the following code is independent from a bounding box // check boundary conditions if (this->stretching->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = left_boundary * (-0.5); } if (this->stretching->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = right_boundary * (0.5); // down @@ -74,7 +70,5 @@ void PhidPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiDownBBLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiDownBBLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index af7f3a01be..e87f9ebe89 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiDownBBLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiDownBBLinearStretchedBoundary.hpp @@ -13,26 +13,22 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of SGPP::base::sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \phi(x) \frac{\partial \phi(x)}{x} dx\f$ * on linear boundary grids */ -class PhidPhiDownBBLinearStretchedBoundary : public - PhidPhiDownBBLinearStretched { +class PhidPhiDownBBLinearStretchedBoundary : public PhidPhiDownBBLinearStretched { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - PhidPhiDownBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit PhidPhiDownBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -43,22 +39,22 @@ class PhidPhiDownBBLinearStretchedBoundary : public * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* PHIDPHIDOWNBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* PHIDPHIDOWNBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiUpBBLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiUpBBLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index a055dabe88..36a484ecf3 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiUpBBLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiUpBBLinearStretchedBoundary.cpp @@ -7,21 +7,18 @@ #include - namespace SGPP { namespace finance { - - PhidPhiUpBBLinearStretchedBoundary::PhidPhiUpBBLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : PhidPhiUpBBLinearStretched(storage) { -} + SGPP::base::GridStorage* storage) + : PhidPhiUpBBLinearStretched(storage) {} -PhidPhiUpBBLinearStretchedBoundary::~PhidPhiUpBBLinearStretchedBoundary() { -} +PhidPhiUpBBLinearStretchedBoundary::~PhidPhiUpBBLinearStretchedBoundary() {} -void PhidPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& - source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void PhidPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { // get boundary values float_t fl = 0.0; float_t fr = 0.0; @@ -49,7 +46,7 @@ void PhidPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& // check boundary conditions if (this->stretching->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { // up ////////////////////////////////////// @@ -59,7 +56,7 @@ void PhidPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& } if (this->stretching->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -67,7 +64,5 @@ void PhidPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& index.resetToLeftLevelZero(dim); } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiUpBBLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiUpBBLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 948052c49d..21bd7b9242 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiUpBBLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/PhidPhiUpBBLinearStretchedBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of SGPP::base::sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -31,7 +28,7 @@ class PhidPhiUpBBLinearStretchedBoundary : public PhidPhiUpBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - PhidPhiUpBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit PhidPhiUpBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class PhidPhiUpBBLinearStretchedBoundary : public PhidPhiUpBBLinearStretched { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* PHIDPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* PHIDPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index 98572f3fa6..9c9ce179e5 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretchedBoundary.cpp @@ -7,27 +7,21 @@ #include - namespace SGPP { namespace finance { - - SqXdPhidPhiDownBBLinearStretchedBoundary::SqXdPhidPhiDownBBLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : SqXdPhidPhiDownBBLinearStretched(storage) { -} + SGPP::base::GridStorage* storage) + : SqXdPhidPhiDownBBLinearStretched(storage) {} -SqXdPhidPhiDownBBLinearStretchedBoundary::~SqXdPhidPhiDownBBLinearStretchedBoundary() { -} +SqXdPhidPhiDownBBLinearStretchedBoundary::~SqXdPhidPhiDownBBLinearStretchedBoundary() {} -void SqXdPhidPhiDownBBLinearStretchedBoundary::operator()( - SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim) { +void SqXdPhidPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = this->stretching->getIntervalWidth(dim); float_t t = this->stretching->getIntervalOffset(dim); - - // get boundary values float_t left_boundary; float_t right_boundary; @@ -49,18 +43,17 @@ void SqXdPhidPhiDownBBLinearStretchedBoundary::operator()( seq_right = index.seq(); right_boundary = source[seq_right]; - float_t bbFactor = ((q * q) + (3.0 * q * t) + (3.0 * t * t)) / (q); // check boundary conditions if (this->stretching->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = (1.0 / 3.0) * left_boundary * bbFactor; } if (this->stretching->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = (1.0 / 3.0) * right_boundary * bbFactor; // down @@ -78,11 +71,7 @@ void SqXdPhidPhiDownBBLinearStretchedBoundary::operator()( index.resetToLeftLevelZero(dim); } - - } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 2479218cbc..69112cb831 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretchedBoundary.hpp @@ -13,26 +13,22 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of SGPP::base::sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x^{2} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ * on linear boundary grids */ -class SqXdPhidPhiDownBBLinearStretchedBoundary : public - SqXdPhidPhiDownBBLinearStretched { +class SqXdPhidPhiDownBBLinearStretchedBoundary : public SqXdPhidPhiDownBBLinearStretched { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - SqXdPhidPhiDownBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit SqXdPhidPhiDownBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -43,24 +39,24 @@ class SqXdPhidPhiDownBBLinearStretchedBoundary : public * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * * On level zero the getfixDirechletBoundaries of the storage object evaluated * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* SQXDPHIDPHIDOWNBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* SQXDPHIDPHIDOWNBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index dca2a348ac..242c87e87e --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretchedBoundary.cpp @@ -7,22 +7,18 @@ #include - namespace SGPP { namespace finance { - - SqXdPhidPhiUpBBLinearStretchedBoundary::SqXdPhidPhiUpBBLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : SqXdPhidPhiUpBBLinearStretched(storage) { -} + SGPP::base::GridStorage* storage) + : SqXdPhidPhiUpBBLinearStretched(storage) {} -SqXdPhidPhiUpBBLinearStretchedBoundary::~SqXdPhidPhiUpBBLinearStretchedBoundary() { -} +SqXdPhidPhiUpBBLinearStretchedBoundary::~SqXdPhidPhiUpBBLinearStretchedBoundary() {} -void SqXdPhidPhiUpBBLinearStretchedBoundary::operator()( - SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim) { +void SqXdPhidPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = this->stretching->getIntervalWidth(dim); float_t t = this->stretching->getIntervalOffset(dim); @@ -30,7 +26,6 @@ void SqXdPhidPhiUpBBLinearStretchedBoundary::operator()( float_t fl = 0.0; float_t fr = 0.0; - if (!index.hint()) { index.resetToLevelOne(dim); @@ -55,7 +50,7 @@ void SqXdPhidPhiUpBBLinearStretchedBoundary::operator()( ////////////////////////////////////// // check boundary conditions if (this->stretching->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { result[seq_left] = fl; float_t bbFactor = ((q * q) + (3.0 * q * t) + (3.0 * t * t)) / (q); @@ -63,17 +58,13 @@ void SqXdPhidPhiUpBBLinearStretchedBoundary::operator()( } if (this->stretching->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } index.resetToLeftLevelZero(dim); - - } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 80cdaef3f9..cd73a43ddc --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretchedBoundary.hpp @@ -13,26 +13,22 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of SGPP::base::sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x^{2} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ * on linear boundary grids */ -class SqXdPhidPhiUpBBLinearStretchedBoundary : public - SqXdPhidPhiUpBBLinearStretched { +class SqXdPhidPhiUpBBLinearStretchedBoundary : public SqXdPhidPhiUpBBLinearStretched { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - SqXdPhidPhiUpBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit SqXdPhidPhiUpBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -43,22 +39,22 @@ class SqXdPhidPhiUpBBLinearStretchedBoundary : public * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* SQXDPHIDPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* SQXDPHIDPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiDownBBLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiDownBBLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index 4f4cfb5a09..cf777c2cb1 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiDownBBLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiDownBBLinearStretchedBoundary.cpp @@ -7,26 +7,21 @@ #include - namespace SGPP { namespace finance { - - XPhidPhiDownBBLinearStretchedBoundary::XPhidPhiDownBBLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : XPhidPhiDownBBLinearStretched(storage) { -} + SGPP::base::GridStorage* storage) + : XPhidPhiDownBBLinearStretched(storage) {} -XPhidPhiDownBBLinearStretchedBoundary::~XPhidPhiDownBBLinearStretchedBoundary() { -} +XPhidPhiDownBBLinearStretchedBoundary::~XPhidPhiDownBBLinearStretchedBoundary() {} -void XPhidPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& - source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void XPhidPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = this->stretching->getIntervalWidth(dim); float_t t = this->stretching->getIntervalOffset(dim); - - // get boundary values float_t left_boundary; float_t right_boundary; @@ -48,16 +43,15 @@ void XPhidPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& seq_right = index.seq(); right_boundary = source[seq_right]; - // check boundary conditions if (this->stretching->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = left_boundary * (((-1.0 / 6.0) * q) - (0.5 * t)); } if (this->stretching->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = right_boundary * (((1.0 / 3.0) * q) + (0.5 * t)); // down @@ -75,13 +69,7 @@ void XPhidPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& index.resetToLeftLevelZero(dim); } - - - - } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiDownBBLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiDownBBLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index d43c162625..8ca3fc6cd1 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiDownBBLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiDownBBLinearStretchedBoundary.hpp @@ -13,26 +13,22 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of SGPP::base::sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x \phi(x) \frac{\partial \phi(x)}{x} dx\f$ * on linear boundary grids */ -class XPhidPhiDownBBLinearStretchedBoundary : public - XPhidPhiDownBBLinearStretched { +class XPhidPhiDownBBLinearStretchedBoundary : public XPhidPhiDownBBLinearStretched { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - XPhidPhiDownBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit XPhidPhiDownBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -43,24 +39,24 @@ class XPhidPhiDownBBLinearStretchedBoundary : public * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * * On level zero the getfixDirechletBoundaries of the storage object evaluated * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XPHIDPHIDOWNBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* XPHIDPHIDOWNBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiUpBBLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiUpBBLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index 53fd8bc7b5..c55aef7ecf --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiUpBBLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiUpBBLinearStretchedBoundary.cpp @@ -7,20 +7,17 @@ #include - namespace SGPP { namespace finance { - - XPhidPhiUpBBLinearStretchedBoundary::XPhidPhiUpBBLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : XPhidPhiUpBBLinearStretched(storage) { -} + SGPP::base::GridStorage* storage) + : XPhidPhiUpBBLinearStretched(storage) {} -XPhidPhiUpBBLinearStretchedBoundary::~XPhidPhiUpBBLinearStretchedBoundary() { -} +XPhidPhiUpBBLinearStretchedBoundary::~XPhidPhiUpBBLinearStretchedBoundary() {} -/*void XPhidPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim) +/*void XPhidPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, +SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { float_t q = this->stretching->getIntervalWidth(dim); float_t t = this->stretching->getIntervalOffset(dim); @@ -83,19 +80,16 @@ XPhidPhiUpBBLinearStretchedBoundary::~XPhidPhiUpBBLinearStretchedBoundary() { }*/ - -void XPhidPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& - source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void XPhidPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = this->stretching->getIntervalWidth(dim); float_t t = this->stretching->getIntervalOffset(dim); - - // get boundary values float_t fl = 0.0; float_t fr = 0.0; - if (!index.hint()) { index.resetToLevelOne(dim); @@ -118,7 +112,7 @@ void XPhidPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& // check boundary conditions if (this->stretching->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { // up ////////////////////////////////////// @@ -128,16 +122,12 @@ void XPhidPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& } if (this->stretching->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } index.resetToLeftLevelZero(dim); - - } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiUpBBLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiUpBBLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 7b09a5caa0..0e83c96722 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiUpBBLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XPhidPhiUpBBLinearStretchedBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of SGPP::base::sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -31,7 +28,7 @@ class XPhidPhiUpBBLinearStretchedBoundary : public XPhidPhiUpBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - XPhidPhiUpBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit XPhidPhiUpBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class XPhidPhiUpBBLinearStretchedBoundary : public XPhidPhiUpBBLinearStretched { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XPHIDPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* XPHIDPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiDownBBLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiDownBBLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index 52fa005401..a88d10e05f --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiDownBBLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiDownBBLinearStretchedBoundary.cpp @@ -7,26 +7,21 @@ #include - namespace SGPP { namespace finance { - - XdPhiPhiDownBBLinearStretchedBoundary::XdPhiPhiDownBBLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : XdPhiPhiDownBBLinearStretched(storage) { -} + SGPP::base::GridStorage* storage) + : XdPhiPhiDownBBLinearStretched(storage) {} -XdPhiPhiDownBBLinearStretchedBoundary::~XdPhiPhiDownBBLinearStretchedBoundary() { -} +XdPhiPhiDownBBLinearStretchedBoundary::~XdPhiPhiDownBBLinearStretchedBoundary() {} -void XdPhiPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& - source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void XdPhiPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = this->stretching->getIntervalWidth(dim); float_t t = this->stretching->getIntervalOffset(dim); - - // get boundary values float_t left_boundary; float_t right_boundary; @@ -48,16 +43,15 @@ void XdPhiPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& seq_right = index.seq(); right_boundary = source[seq_right]; - // check boundary conditions if (this->stretching->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary; + result[seq_left] = 0.0; // left_boundary; } else { result[seq_left] = left_boundary * (((-1.0 / 6.0) * q) - (0.5 * t)); } if (this->stretching->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = right_boundary * (((1.0 / 3.0) * q) + (0.5 * t)); // down @@ -76,11 +70,7 @@ void XdPhiPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& index.resetToLeftLevelZero(dim); } - - } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiDownBBLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiDownBBLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 83899afd1f..979fd0b871 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiDownBBLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiDownBBLinearStretchedBoundary.hpp @@ -13,26 +13,22 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of SGPP::base::sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x \frac{\partial \phi(x)}{x} \phi(x) dx\f$ * on linear boundary grids */ -class XdPhiPhiDownBBLinearStretchedBoundary : public - XdPhiPhiDownBBLinearStretched { +class XdPhiPhiDownBBLinearStretchedBoundary : public XdPhiPhiDownBBLinearStretched { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - XdPhiPhiDownBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit XdPhiPhiDownBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -43,24 +39,24 @@ class XdPhiPhiDownBBLinearStretchedBoundary : public * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * * On level zero the getfixDirechletBoundaries of the storage object evaluated * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XDPHIPHIDOWNBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* XDPHIPHIDOWNBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiUpBBLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiUpBBLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index cc1b4112f6..407393e483 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiUpBBLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiUpBBLinearStretchedBoundary.cpp @@ -7,31 +7,25 @@ #include - namespace SGPP { namespace finance { - - XdPhiPhiUpBBLinearStretchedBoundary::XdPhiPhiUpBBLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : XdPhiPhiUpBBLinearStretched(storage) { -} + SGPP::base::GridStorage* storage) + : XdPhiPhiUpBBLinearStretched(storage) {} -XdPhiPhiUpBBLinearStretchedBoundary::~XdPhiPhiUpBBLinearStretchedBoundary() { -} +XdPhiPhiUpBBLinearStretchedBoundary::~XdPhiPhiUpBBLinearStretchedBoundary() {} -void XdPhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& - source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void XdPhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = this->stretching->getIntervalWidth(dim); float_t t = this->stretching->getIntervalOffset(dim); - - // get boundary values float_t fl = 0.0; float_t fr = 0.0; - if (!index.hint()) { index.resetToLevelOne(dim); @@ -54,7 +48,7 @@ void XdPhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& // check boundary conditions if (this->stretching->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { // up ////////////////////////////////////// @@ -64,17 +58,12 @@ void XdPhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& } if (this->stretching->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } index.resetToLeftLevelZero(dim); - - - } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiUpBBLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiUpBBLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 24a90aaee5..51ed5c1557 --- a/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiUpBBLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/boundary/algorithm_sweep/XdPhiPhiUpBBLinearStretchedBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of SGPP::base::sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -31,7 +28,7 @@ class XdPhiPhiUpBBLinearStretchedBoundary : public XdPhiPhiUpBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - XdPhiPhiUpBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit XdPhiPhiUpBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class XdPhiPhiUpBBLinearStretchedBoundary : public XdPhiPhiUpBBLinearStretched { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XDPHIPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* XDPHIPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiDownBBLinearStretched.cpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiDownBBLinearStretched.cpp old mode 100755 new mode 100644 index 3ffdf168ff..15b706e9c0 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiDownBBLinearStretched.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiDownBBLinearStretched.cpp @@ -7,28 +7,23 @@ #include - namespace SGPP { namespace finance { +DPhiPhiDownBBLinearStretched::DPhiPhiDownBBLinearStretched(SGPP::base::GridStorage* storage) + : storage(storage), stretching(storage->getStretching()) {} - -DPhiPhiDownBBLinearStretched::DPhiPhiDownBBLinearStretched( - SGPP::base::GridStorage* storage) : storage(storage), - stretching(storage->getStretching()) { -} - -DPhiPhiDownBBLinearStretched::~DPhiPhiDownBBLinearStretched() { -} +DPhiPhiDownBBLinearStretched::~DPhiPhiDownBBLinearStretched() {} void DPhiPhiDownBBLinearStretched::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { rec(source, result, index, dim, 0.0, 0.0); } void DPhiPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -40,15 +35,15 @@ void DPhiPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, float_t posl = 0, posr = 0, posc = 0; - this->stretching->getAdjacentPositions(static_cast(l), static_cast(i), - dim, posc, posl, posr ); + this->stretching->getAdjacentPositions(static_cast(l), static_cast(i), dim, posc, posl, + posr); // integration - result[seq] = ( 0.5 * (fr - fl) ); // diagonal entry = 0.0 + result[seq] = (0.5 * (fr - fl)); // diagonal entry = 0.0 // dehierarchisation - float_t fm = (fr - fl) * (posc - posl) / (posr - posl) + fl + alpha_value; + float_t fm = (fr - fl) * (posc - posl) / (posr - posl) + fl + alpha_value; if (!index.hint()) { index.leftChild(dim); @@ -67,7 +62,5 @@ void DPhiPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiDownBBLinearStretched.hpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiDownBBLinearStretched.hpp old mode 100755 new mode 100644 index d3587e4880..9aaa480769 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiDownBBLinearStretched.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiDownBBLinearStretched.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -30,14 +27,13 @@ class DPhiPhiDownBBLinearStretched { /// Pointer to the SGPP::base::Stretching bounding box Object SGPP::base::Stretching* stretching; - public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - DPhiPhiDownBBLinearStretched(SGPP::base::GridStorage* storage); + explicit DPhiPhiDownBBLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,18 +43,19 @@ class DPhiPhiDownBBLinearStretched { /** * This operations performs the calculation of down in the direction of dimension dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** - * recursive function for the calculation of Down without and with SGPP::base::Stretching Bounding Box support + * recursive function for the calculation of Down without and with SGPP::base::Stretching Bounding + * Box support * (calculations are independent from bounding box) * * @param source SGPP::base::DataVector that contains the coefficients of the ansatzfunction @@ -68,13 +65,11 @@ class DPhiPhiDownBBLinearStretched { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* PHIDPHIDOWNBBLINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* PHIDPHIDOWNBBLINEARSTRETCHED_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiUpBBLinearStretched.cpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiUpBBLinearStretched.cpp old mode 100755 new mode 100644 index f24c03ea28..bbfb204ace --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiUpBBLinearStretched.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiUpBBLinearStretched.cpp @@ -7,22 +7,17 @@ #include - namespace SGPP { namespace finance { +DPhiPhiUpBBLinearStretched::DPhiPhiUpBBLinearStretched(SGPP::base::GridStorage* storage) + : storage(storage), stretching(storage->getStretching()) {} - -DPhiPhiUpBBLinearStretched::DPhiPhiUpBBLinearStretched(SGPP::base::GridStorage* - storage) : storage(storage), stretching(storage->getStretching()) { -} - - -DPhiPhiUpBBLinearStretched::~DPhiPhiUpBBLinearStretched() { -} +DPhiPhiUpBBLinearStretched::~DPhiPhiUpBBLinearStretched() {} void DPhiPhiUpBBLinearStretched::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { // get boundary values float_t fl = 0.0; float_t fr = 0.0; @@ -30,10 +25,8 @@ void DPhiPhiUpBBLinearStretched::operator()(SGPP::base::DataVector& source, rec(source, result, index, dim, fl, fr); } - -void DPhiPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void DPhiPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -62,7 +55,7 @@ void DPhiPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, index.get(dim, current_level, current_index); float_t posl = 0, posr = 0, posc = 0; this->stretching->getAdjacentPositions(static_cast(current_level), - static_cast(current_index), dim, posc, posl, posr ); + static_cast(current_index), dim, posc, posl, posr); float_t fm = fml + fmr; float_t alpha_value = source[seq]; @@ -77,7 +70,5 @@ void DPhiPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, fr = (-0.5) * alpha_value + fr + fm * (leftLength / baseLength); } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiUpBBLinearStretched.hpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiUpBBLinearStretched.hpp old mode 100755 new mode 100644 index 71ef20b614..07c75b6825 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiUpBBLinearStretched.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/DPhiPhiUpBBLinearStretched.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -36,7 +33,7 @@ class DPhiPhiUpBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - DPhiPhiUpBBLinearStretched(SGPP::base::GridStorage* storage); + explicit DPhiPhiUpBBLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -46,16 +43,16 @@ class DPhiPhiUpBBLinearStretched { /** * This operations performs the calculation of up in the direction of dimension dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up (with and without bounding box support, * since calculations are independent from bounding box) @@ -68,14 +65,11 @@ class DPhiPhiUpBBLinearStretched { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); }; +} // namespace finance +} // namespace SGPP -// namespace detail - -} // namespace SGPP -} - -#endif /* DPHIPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* DPHIPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiDownBBLinearStretched.cpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiDownBBLinearStretched.cpp old mode 100755 new mode 100644 index 798ccfaa32..76bbe54374 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiDownBBLinearStretched.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiDownBBLinearStretched.cpp @@ -7,29 +7,24 @@ #include - namespace SGPP { namespace finance { +PhidPhiDownBBLinearStretched::PhidPhiDownBBLinearStretched(SGPP::base::GridStorage* storage) + : storage(storage), stretching(storage->getStretching()) {} - -PhidPhiDownBBLinearStretched::PhidPhiDownBBLinearStretched( - SGPP::base::GridStorage* storage) : storage(storage), - stretching(storage->getStretching()) { -} - -PhidPhiDownBBLinearStretched::~PhidPhiDownBBLinearStretched() { -} +PhidPhiDownBBLinearStretched::~PhidPhiDownBBLinearStretched() {} void PhidPhiDownBBLinearStretched::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { rec(source, result, index, dim, 0.0, 0.0); } void PhidPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { - //Fix the eqn (Selcuk) + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr) { + // Fix the eqn (Selcuk) size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -40,14 +35,14 @@ void PhidPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, index.get(dim, l, i); float_t posl = 0, posr = 0, posc = 0; - this->stretching->getAdjacentPositions(static_cast(l), static_cast(i), - dim, posc, posl, posr ); + this->stretching->getAdjacentPositions(static_cast(l), static_cast(i), dim, posc, posl, + posr); // integration - result[seq] = ( 0.5 * (fl - fr) ); // diagonal entry = 0.0 + result[seq] = (0.5 * (fl - fr)); // diagonal entry = 0.0 // dehierarchisation - float_t fm = (fr - fl) * (posc - posl) / (posr - posl) + fl + alpha_value; + float_t fm = (fr - fl) * (posc - posl) / (posr - posl) + fl + alpha_value; if (!index.hint()) { index.leftChild(dim); @@ -66,7 +61,5 @@ void PhidPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiDownBBLinearStretched.hpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiDownBBLinearStretched.hpp old mode 100755 new mode 100644 index d36d0836f5..5e4848a2c5 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiDownBBLinearStretched.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiDownBBLinearStretched.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -36,7 +33,7 @@ class PhidPhiDownBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - PhidPhiDownBBLinearStretched(SGPP::base::GridStorage* storage); + explicit PhidPhiDownBBLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -46,16 +43,16 @@ class PhidPhiDownBBLinearStretched { /** * This operations performs the calculation of down in the direction of dimension dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down with and without Bounding Box support * (since the calculations are independent from a bounding box) @@ -67,13 +64,11 @@ class PhidPhiDownBBLinearStretched { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* PHIDPHIDOWNBBLINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* PHIDPHIDOWNBBLINEARSTRETCHED_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiUpBBLinearStretched.cpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiUpBBLinearStretched.cpp old mode 100755 new mode 100644 index 659841a35e..0038b26c8b --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiUpBBLinearStretched.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiUpBBLinearStretched.cpp @@ -7,21 +7,17 @@ #include - namespace SGPP { namespace finance { +PhidPhiUpBBLinearStretched::PhidPhiUpBBLinearStretched(SGPP::base::GridStorage* storage) + : storage(storage), stretching(storage->getStretching()) {} - -PhidPhiUpBBLinearStretched::PhidPhiUpBBLinearStretched(SGPP::base::GridStorage* - storage) : storage(storage), stretching(storage->getStretching()) { -} - -PhidPhiUpBBLinearStretched::~PhidPhiUpBBLinearStretched() { -} +PhidPhiUpBBLinearStretched::~PhidPhiUpBBLinearStretched() {} void PhidPhiUpBBLinearStretched::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { // get boundary values float_t fl = 0.0; float_t fr = 0.0; @@ -29,9 +25,8 @@ void PhidPhiUpBBLinearStretched::operator()(SGPP::base::DataVector& source, rec(source, result, index, dim, fl, fr); } -void PhidPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void PhidPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -60,13 +55,12 @@ void PhidPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, index.get(dim, current_level, current_index); float_t posl = 0, posr = 0, posc = 0; this->stretching->getAdjacentPositions(static_cast(current_level), - static_cast(current_index), dim, posc, posl, posr ); + static_cast(current_index), dim, posc, posl, posr); float_t fm = fml + fmr; float_t alpha_value = source[seq]; - // transposed operations: result[seq] = fm; @@ -77,7 +71,5 @@ void PhidPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, fr = (0.5) * alpha_value + fr + fm * (leftLength / baseLength); } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiUpBBLinearStretched.hpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiUpBBLinearStretched.hpp old mode 100755 new mode 100644 index a2ae4e426a..d32665eebb --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiUpBBLinearStretched.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/PhidPhiUpBBLinearStretched.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -36,7 +33,7 @@ class PhidPhiUpBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - PhidPhiUpBBLinearStretched(SGPP::base::GridStorage* storage); + explicit PhidPhiUpBBLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class PhidPhiUpBBLinearStretched { * This operations performs the calculation of up in the direction of dimension dim * on a grid with Dirichlet 0 boundary conditions. * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up (with and without bounding box support, * since the calculations are independent from a bounding box) @@ -68,13 +65,11 @@ class PhidPhiUpBBLinearStretched { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* PHIDPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* PHIDPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretched.cpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretched.cpp old mode 100755 new mode 100644 index 36425598c2..f188263439 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretched.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretched.cpp @@ -7,29 +7,23 @@ #include - namespace SGPP { namespace finance { +SqXdPhidPhiDownBBLinearStretched::SqXdPhidPhiDownBBLinearStretched(SGPP::base::GridStorage* storage) + : storage(storage), stretching(storage->getStretching()) {} +SqXdPhidPhiDownBBLinearStretched::~SqXdPhidPhiDownBBLinearStretched() {} -SqXdPhidPhiDownBBLinearStretched::SqXdPhidPhiDownBBLinearStretched( - SGPP::base::GridStorage* storage) : storage(storage), - stretching(storage->getStretching()) { -} - -SqXdPhidPhiDownBBLinearStretched::~SqXdPhidPhiDownBBLinearStretched() { -} - -void SqXdPhidPhiDownBBLinearStretched::operator()(SGPP::base::DataVector& - source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void SqXdPhidPhiDownBBLinearStretched::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { rec(source, result, index, dim, 0.0, 0.0); - } void SqXdPhidPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -40,21 +34,20 @@ void SqXdPhidPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, index.get(dim, l, i); float_t posl = 0, posr = 0, posc = 0; - this->stretching->getAdjacentPositions(static_cast(l), static_cast(i), - dim, posc, posl, posr ); + this->stretching->getAdjacentPositions(static_cast(l), static_cast(i), dim, posc, posl, + posr); float_t baseLength = posr - posl; float_t leftLength = posc - posl; float_t rightLength = posr - posc; float_t c = 1.0 / 3.0 * (posc + posr + posl); - result[seq] = 1.0 / 3.0 * alpha_value * baseLength * (posc * - (2 * posc + posr + posl) - posr * posl) / (leftLength * rightLength) + c * - (fl - fr); - + result[seq] = 1.0 / 3.0 * alpha_value * baseLength * + (posc * (2 * posc + posr + posl) - posr * posl) / (leftLength * rightLength) + + c * (fl - fr); // dehierarchisation - float_t fm = (fr - fl) * (leftLength) / (baseLength) + fl + alpha_value; + float_t fm = (fr - fl) * (leftLength) / (baseLength) + fl + alpha_value; if (!index.hint()) { index.leftChild(dim); @@ -73,8 +66,5 @@ void SqXdPhidPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, } } - -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretched.hpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretched.hpp old mode 100755 new mode 100644 index 31aefcdef1..930ab52bfa --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretched.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiDownBBLinearStretched.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x^{2} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ @@ -36,7 +33,7 @@ class SqXdPhidPhiDownBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - SqXdPhidPhiDownBBLinearStretched(SGPP::base::GridStorage* storage); + explicit SqXdPhidPhiDownBBLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class SqXdPhidPhiDownBBLinearStretched { * This operations performs the calculation of down in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down without Bounding Box support * @@ -67,13 +64,11 @@ class SqXdPhidPhiDownBBLinearStretched { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* SQXDPHIDPHIDOWNBBLINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* SQXDPHIDPHIDOWNBBLINEARSTRETCHED_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretched.cpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretched.cpp old mode 100755 new mode 100644 index 0e829187d3..2d44f5eef1 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretched.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretched.cpp @@ -7,36 +7,27 @@ #include - namespace SGPP { namespace finance { +SqXdPhidPhiUpBBLinearStretched::SqXdPhidPhiUpBBLinearStretched(SGPP::base::GridStorage* storage) + : storage(storage), stretching(storage->getStretching()) {} - -SqXdPhidPhiUpBBLinearStretched::SqXdPhidPhiUpBBLinearStretched( - SGPP::base::GridStorage* storage) : storage(storage), - stretching(storage->getStretching()) { -} - - -SqXdPhidPhiUpBBLinearStretched::~SqXdPhidPhiUpBBLinearStretched() { -} - +SqXdPhidPhiUpBBLinearStretched::~SqXdPhidPhiUpBBLinearStretched() {} void SqXdPhidPhiUpBBLinearStretched::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { - + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { // get boundary values float_t fl = 0.0; float_t fr = 0.0; rec(source, result, index, dim, fl, fr); - } void SqXdPhidPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -74,18 +65,13 @@ void SqXdPhidPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, float_t alpha_value = source[seq]; - float_t c = 1.0 / 3.0 * (posc + posr + posl); // transposed operations: result[seq] = fm; fl = c * alpha_value + fl + fm * (rightLength / baseLength); fr = -c * alpha_value + fr + fm * (leftLength / baseLength); - } - -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretched.hpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretched.hpp old mode 100755 new mode 100644 index 2a9362ba7d..912cf40519 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretched.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/SqXdPhidPhiUpBBLinearStretched.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x^{2} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ @@ -36,28 +33,27 @@ class SqXdPhidPhiUpBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - SqXdPhidPhiUpBBLinearStretched(SGPP::base::GridStorage* storage); + explicit SqXdPhidPhiUpBBLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor */ virtual ~SqXdPhidPhiUpBBLinearStretched(); - /** * This operations performs the calculation of up in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up without Bounding Box support * @@ -68,13 +64,11 @@ class SqXdPhidPhiUpBBLinearStretched { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* SQXDPHIDPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* SQXDPHIDPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiDownBBLinearStretched.cpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiDownBBLinearStretched.cpp old mode 100755 new mode 100644 index 9608c45ebc..5588d3ac54 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiDownBBLinearStretched.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiDownBBLinearStretched.cpp @@ -7,29 +7,23 @@ #include - namespace SGPP { namespace finance { +XPhidPhiDownBBLinearStretched::XPhidPhiDownBBLinearStretched(SGPP::base::GridStorage* storage) + : storage(storage), stretching(storage->getStretching()) {} - -XPhidPhiDownBBLinearStretched::XPhidPhiDownBBLinearStretched( - SGPP::base::GridStorage* storage) : storage(storage), - stretching(storage->getStretching()) { -} - -XPhidPhiDownBBLinearStretched::~XPhidPhiDownBBLinearStretched() { -} +XPhidPhiDownBBLinearStretched::~XPhidPhiDownBBLinearStretched() {} void XPhidPhiDownBBLinearStretched::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { rec(source, result, index, dim, 0.0, 0.0); - } void XPhidPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -38,41 +32,36 @@ void XPhidPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, SGPP::base::GridStorage::index_type::index_type i; index.get(dim, l, i); - //get the positions of the current index as well as its left and right neighbors + // get the positions of the current index as well as its left and right neighbors float_t posl = 0, posr = 0, posc = 0; - this->stretching->getAdjacentPositions(static_cast(l), static_cast(i), - dim, posc, posl, posr ); + this->stretching->getAdjacentPositions(static_cast(l), static_cast(i), dim, posc, posl, + posr); float_t baseLength = posr - posl; float_t leftLength = posc - posl; - result[seq] = fl * (1.0 / 6.0) * (2 * posc + 2 * posl - posr) - fr * - (1.0 / 6.0) * (2 * posc - posl + 2 * posr) - - 1.0 / 6.0 * (baseLength) * alpha_value; // diagonal entry - + result[seq] = fl * (1.0 / 6.0) * (2 * posc + 2 * posl - posr) - + fr * (1.0 / 6.0) * (2 * posc - posl + 2 * posr) - + 1.0 / 6.0 * (baseLength)*alpha_value; // diagonal entry // dehierarchisation - float_t fm = (fr - fl) * (leftLength) / (baseLength) + fl + alpha_value; + float_t fm = (fr - fl) * (leftLength) / (baseLength) + fl + alpha_value; if (!index.hint()) { index.leftChild(dim); if (!storage->end(index.seq())) { rec(source, result, index, dim, fl, fm); - } index.stepRight(dim); if (!storage->end(index.seq())) { rec(source, result, index, dim, fm, fr); - } index.up(dim); } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiDownBBLinearStretched.hpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiDownBBLinearStretched.hpp old mode 100755 new mode 100644 index 903f889b7c..d9a2022094 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiDownBBLinearStretched.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiDownBBLinearStretched.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -36,7 +33,7 @@ class XPhidPhiDownBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - XPhidPhiDownBBLinearStretched(SGPP::base::GridStorage* storage); + explicit XPhidPhiDownBBLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class XPhidPhiDownBBLinearStretched { * This operations performs the calculation of down in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary condition * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down without Bounding Box support * @@ -67,14 +64,11 @@ class XPhidPhiDownBBLinearStretched { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); - + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XPHIDPHIDOWNBBLINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* XPHIDPHIDOWNBBLINEARSTRETCHED_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiUpBBLinearStretched.cpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiUpBBLinearStretched.cpp old mode 100755 new mode 100644 index 23ae263b77..c0dfea40fd --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiUpBBLinearStretched.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiUpBBLinearStretched.cpp @@ -7,33 +7,27 @@ #include - namespace SGPP { namespace finance { +XPhidPhiUpBBLinearStretched::XPhidPhiUpBBLinearStretched(SGPP::base::GridStorage* storage) + : storage(storage), stretching(storage->getStretching()) {} - -XPhidPhiUpBBLinearStretched::XPhidPhiUpBBLinearStretched( - SGPP::base::GridStorage* storage) : storage(storage), - stretching(storage->getStretching()) { -} - -XPhidPhiUpBBLinearStretched::~XPhidPhiUpBBLinearStretched() { -} +XPhidPhiUpBBLinearStretched::~XPhidPhiUpBBLinearStretched() {} void XPhidPhiUpBBLinearStretched::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { // get boundary values float_t fl = 0.0; float_t fr = 0.0; rec(source, result, index, dim, fl, fr); - } void XPhidPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -62,10 +56,10 @@ void XPhidPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, } index.get(dim, current_level, current_index); - //get the positions of the current index as well as its left and right neighbors + // get the positions of the current index as well as its left and right neighbors float_t posl = 0, posr = 0, posc = 0; this->stretching->getAdjacentPositions(static_cast(current_level), - static_cast(current_index), dim, posc, posl, posr ); + static_cast(current_index), dim, posc, posl, posr); float_t baseLength = posr - posl; float_t leftLength = posc - posl; float_t rightLength = posr - posc; @@ -74,7 +68,6 @@ void XPhidPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, float_t alpha_value = source[seq]; - // transposed operations: result[seq] = fm; @@ -83,7 +76,5 @@ void XPhidPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, fr = (-c * alpha_value) + fr + fm * (leftLength / baseLength); } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiUpBBLinearStretched.hpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiUpBBLinearStretched.hpp old mode 100755 new mode 100644 index f7a6ea1248..744921444f --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiUpBBLinearStretched.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XPhidPhiUpBBLinearStretched.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x \phi(x) \frac{\partial \phi(x)}{x} dx\f$ @@ -36,7 +33,7 @@ class XPhidPhiUpBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - XPhidPhiUpBBLinearStretched(SGPP::base::GridStorage* storage); + explicit XPhidPhiUpBBLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,7 +44,8 @@ class XPhidPhiUpBBLinearStretched { * This operations performs the calculation of up in the direction of dimension dim * on a a grid with fix Dirichlet 0 boundary condition * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -56,7 +54,6 @@ class XPhidPhiUpBBLinearStretched { grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up * @@ -67,14 +64,11 @@ class XPhidPhiUpBBLinearStretched { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); - + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XPHIDPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* XPHIDPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiDownBBLinearStretched.cpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiDownBBLinearStretched.cpp old mode 100755 new mode 100644 index 038007a4f4..76102a08f1 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiDownBBLinearStretched.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiDownBBLinearStretched.cpp @@ -7,31 +7,23 @@ #include - namespace SGPP { namespace finance { +XdPhiPhiDownBBLinearStretched::XdPhiPhiDownBBLinearStretched(SGPP::base::GridStorage* storage) + : storage(storage), stretching(storage->getStretching()) {} - -XdPhiPhiDownBBLinearStretched::XdPhiPhiDownBBLinearStretched( - SGPP::base::GridStorage* storage) : storage(storage), - stretching(storage->getStretching()) { -} - -XdPhiPhiDownBBLinearStretched::~XdPhiPhiDownBBLinearStretched() { -} +XdPhiPhiDownBBLinearStretched::~XdPhiPhiDownBBLinearStretched() {} void XdPhiPhiDownBBLinearStretched::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { - + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { rec(source, result, index, dim, 0.0, 0.0); - } - void XdPhiPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -40,24 +32,20 @@ void XdPhiPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, SGPP::base::GridStorage::index_type::index_type i; index.get(dim, l, i); - //get the positions of the current index as well as its left and right neighbors + // get the positions of the current index as well as its left and right neighbors float_t posl = 0, posr = 0, posc = 0; - this->stretching->getAdjacentPositions(static_cast(l), static_cast(i), - dim, posc, posl, posr ); + this->stretching->getAdjacentPositions(static_cast(l), static_cast(i), dim, posc, posl, + posr); float_t baseLength = posr - posl; float_t leftLength = posc - posl; - result[seq] = fl * (-1.0 / 6.0) * (posc + posl + posr) - fr * (-1.0 / 6.0) * - (posc + posl + posr) - - (1.0 / 6.0) * baseLength * alpha_value; // diagonal entry - - - + result[seq] = fl * (-1.0 / 6.0) * (posc + posl + posr) - + fr * (-1.0 / 6.0) * (posc + posl + posr) - + (1.0 / 6.0) * baseLength * alpha_value; // diagonal entry // dehierarchisation - float_t fm = (fr - fl) * (leftLength) / (baseLength) + fl + alpha_value; - + float_t fm = (fr - fl) * (leftLength) / (baseLength) + fl + alpha_value; if (!index.hint()) { index.leftChild(dim); @@ -76,7 +64,5 @@ void XdPhiPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiDownBBLinearStretched.hpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiDownBBLinearStretched.hpp old mode 100755 new mode 100644 index 13dd4b9cbe..60ff7098e9 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiDownBBLinearStretched.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiDownBBLinearStretched.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} x \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -30,14 +27,13 @@ class XdPhiPhiDownBBLinearStretched { /// Pointer to the stretching Obejct SGPP::base::Stretching* stretching; - public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - XdPhiPhiDownBBLinearStretched(SGPP::base::GridStorage* storage); + explicit XdPhiPhiDownBBLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -48,7 +44,8 @@ class XdPhiPhiDownBBLinearStretched { * This operations performs the calculation of down in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -57,7 +54,6 @@ class XdPhiPhiDownBBLinearStretched { grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down without Bounding Box support * @@ -68,13 +64,11 @@ class XdPhiPhiDownBBLinearStretched { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XDPHIPHIDOWNBBLINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* XDPHIPHIDOWNBBLINEARSTRETCHED_HPP */ diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiUpBBLinearStretched.cpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiUpBBLinearStretched.cpp old mode 100755 new mode 100644 index a9339f079f..924d4910e3 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiUpBBLinearStretched.cpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiUpBBLinearStretched.cpp @@ -7,33 +7,27 @@ #include - namespace SGPP { namespace finance { +XdPhiPhiUpBBLinearStretched::XdPhiPhiUpBBLinearStretched(SGPP::base::GridStorage* storage) + : storage(storage), stretching(storage->getStretching()) {} - -XdPhiPhiUpBBLinearStretched::XdPhiPhiUpBBLinearStretched( - SGPP::base::GridStorage* storage) : storage(storage), - stretching(storage->getStretching()) { -} - -XdPhiPhiUpBBLinearStretched::~XdPhiPhiUpBBLinearStretched() { -} +XdPhiPhiUpBBLinearStretched::~XdPhiPhiUpBBLinearStretched() {} void XdPhiPhiUpBBLinearStretched::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { // get boundary values float_t fl = 0.0; float_t fr = 0.0; rec(source, result, index, dim, fl, fr); - } void XdPhiPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -60,10 +54,10 @@ void XdPhiPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, } index.get(dim, current_level, current_index); - //get the positions of the current index as well as its left and right neighbors + // get the positions of the current index as well as its left and right neighbors float_t posl = 0, posr = 0, posc = 0; this->stretching->getAdjacentPositions(static_cast(current_level), - static_cast(current_index), dim, posc, posl, posr ); + static_cast(current_index), dim, posc, posl, posr); float_t baseLength = posr - posl; float_t leftLength = posc - posl; float_t rightLength = posr - posc; @@ -72,18 +66,14 @@ void XdPhiPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, float_t alpha_value = source[seq]; - // transposed operations: result[seq] = fm; - fl = (1.0 / 6.0) * (2 * posc + 2 * posl - posr) * alpha_value + fl + fm * - (rightLength / baseLength); - fr = (-1.0 / 6.0) * (2 * posc - posl + 2 * posr) * alpha_value + fr + fm * - (leftLength / baseLength); - + fl = (1.0 / 6.0) * (2 * posc + 2 * posl - posr) * alpha_value + fl + + fm * (rightLength / baseLength); + fr = (-1.0 / 6.0) * (2 * posc - posl + 2 * posr) * alpha_value + fr + + fm * (leftLength / baseLength); } -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiUpBBLinearStretched.hpp b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiUpBBLinearStretched.hpp old mode 100755 new mode 100644 index 6252f91dd1..1bc9c256c6 --- a/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiUpBBLinearStretched.hpp +++ b/finance/src/sgpp/finance/basis/linearstretched/noboundary/algorithm_sweep/XdPhiPhiUpBBLinearStretched.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace finance { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} x \frac{\partial \phi(x)}{x} \phi(x) dx\f$ @@ -36,7 +33,7 @@ class XdPhiPhiUpBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - XdPhiPhiUpBBLinearStretched(SGPP::base::GridStorage* storage); + explicit XdPhiPhiUpBBLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,7 +44,8 @@ class XdPhiPhiUpBBLinearStretched { * This operations performs the calculation of up in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -56,7 +54,6 @@ class XdPhiPhiUpBBLinearStretched { grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up * @@ -67,14 +64,11 @@ class XdPhiPhiUpBBLinearStretched { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); - + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace finance +} // namespace SGPP -#endif /* XDPHIPHIUPBBLINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* XDPHIPHIUPBBLINEARSTRETCHED_HPP */ diff --git a/finance/src/sgpp/finance/operation/FinanceOpFactory.cpp b/finance/src/sgpp/finance/operation/FinanceOpFactory.cpp index f14cf66b18..6a2af8c773 100644 --- a/finance/src/sgpp/finance/operation/FinanceOpFactory.cpp +++ b/finance/src/sgpp/finance/operation/FinanceOpFactory.cpp @@ -5,8 +5,6 @@ #include -#include - #include #include @@ -67,280 +65,248 @@ #include #include - #include +#include namespace SGPP { namespace op_factory { -base::OperationMatrix* createOperationGamma(base::Grid& grid, - base::DataMatrix& coef) { - +base::OperationMatrix* createOperationGamma(base::Grid& grid, base::DataMatrix& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationGammaLinear(grid.getStorage(), coef); } else if (grid.getType() == base::GridType::LinearStretched) { return new finance::OperationGammaLinearStretched(grid.getStorage(), coef); } else if (grid.getType() == base::GridType::LinearStretchedBoundary) { - return new finance::OperationGammaLinearStretchedBoundary(grid.getStorage(), - coef); - } - - else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + return new finance::OperationGammaLinearStretchedBoundary(grid.getStorage(), coef); + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationGammaLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationGamma is not implemented for this grid type."); - + } } -base::OperationMatrix* createOperationGammaLog(base::Grid& grid, - base::DataMatrix& coef) { - +base::OperationMatrix* createOperationGammaLog(base::Grid& grid, base::DataMatrix& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationGammaLogLinear(grid.getStorage(), coef); } else if (grid.getType() == base::GridType::LinearStretched) { return new finance::OperationGammaLogLinearStretched(grid.getStorage(), coef); } else if (grid.getType() == base::GridType::LinearStretchedBoundary) { - return new finance::OperationGammaLogLinearStretchedBoundary(grid.getStorage(), - coef); - } - - else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + return new finance::OperationGammaLogLinearStretchedBoundary(grid.getStorage(), coef); + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationGammaLogLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationGammaLog is not implemented for this grid type."); - + } } - base::OperationMatrix* createOperationLB(base::Grid& grid) { - if (grid.getType() == base::GridType::Linear) { return new finance::OperationLBLinear(grid.getStorage()); - } - - - else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationLBLinearBoundary(grid.getStorage()); - } else + } else { throw base::factory_exception("OperationLB is not implemented for this grid type."); + } } base::OperationMatrix* createOperationLE(base::Grid& grid) { - if (grid.getType() == base::GridType::Linear) { return new finance::OperationLELinear(grid.getStorage()); - } - - - else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationLELinearBoundary(grid.getStorage()); - } else + } else { throw base::factory_exception("OperationLE is not implemented for this grid type."); + } } base::OperationMatrix* createOperationLD(base::Grid& grid) { - if (grid.getType() == base::GridType::Linear) { return new finance::OperationLDLinear(grid.getStorage()); - } - - - else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationLDLinearBoundary(grid.getStorage()); - } else + } else { throw base::factory_exception("OperationLD is not implemented for this grid type."); + } } base::OperationMatrix* createOperationLF(base::Grid& grid) { - if (grid.getType() == base::GridType::Linear) { return new finance::OperationLFLinear(grid.getStorage()); - } - - - else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationLFLinearBoundary(grid.getStorage()); - } else + } else { throw base::factory_exception("OperationLF is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationDelta(base::Grid& grid, - base::DataVector& coef) { - +base::OperationMatrix* createOperationDelta(base::Grid& grid, base::DataVector& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationDeltaLinear(grid.getStorage(), coef); } else if (grid.getType() == base::GridType::LinearStretched) { return new finance::OperationDeltaLinearStretched(grid.getStorage(), coef); } else if (grid.getType() == base::GridType::LinearStretchedBoundary) { - return new finance::OperationDeltaLinearStretchedBoundary(grid.getStorage(), - coef); - } - - else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + return new finance::OperationDeltaLinearStretchedBoundary(grid.getStorage(), coef); + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationDeltaLinearBoundary(grid.getStorage(), coef); - } - - else + } else { throw base::factory_exception("OperationDelta is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationDeltaLog(base::Grid& grid, - base::DataVector& coef) { - +base::OperationMatrix* createOperationDeltaLog(base::Grid& grid, base::DataVector& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationDeltaLogLinear(grid.getStorage(), coef); } else if (grid.getType() == base::GridType::LinearStretched) { return new finance::OperationDeltaLogLinearStretched(grid.getStorage(), coef); } else if (grid.getType() == base::GridType::LinearStretchedBoundary) { - return new finance::OperationDeltaLogLinearStretchedBoundary(grid.getStorage(), - coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary ) { + return new finance::OperationDeltaLogLinearStretchedBoundary(grid.getStorage(), coef); + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationDeltaLogLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationDeltaLog is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationHestonBLog(base::Grid& grid, - base::DataMatrix& coef) { +base::OperationMatrix* createOperationHestonBLog(base::Grid& grid, base::DataMatrix& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationHestonBLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationHestonBLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationHestonB is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationHestonCLog(base::Grid& grid, - base::DataMatrix& coef) { +base::OperationMatrix* createOperationHestonCLog(base::Grid& grid, base::DataMatrix& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationHestonCLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationHestonCLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationHestonC is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationHestonDLog(base::Grid& grid, - base::DataVector& coef) { +base::OperationMatrix* createOperationHestonDLog(base::Grid& grid, base::DataVector& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationHestonDLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationHestonDLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationHestonD is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationHestonELog(base::Grid& grid, - base::DataVector& coef) { +base::OperationMatrix* createOperationHestonELog(base::Grid& grid, base::DataVector& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationHestonELinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationHestonELinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationHestonE is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationHestonFLog(base::Grid& grid, - base::DataVector& coef) { +base::OperationMatrix* createOperationHestonFLog(base::Grid& grid, base::DataVector& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationHestonFLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationHestonFLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationHestonF is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationHestonGLog(base::Grid& grid, - base::DataVector& coef) { +base::OperationMatrix* createOperationHestonGLog(base::Grid& grid, base::DataVector& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationHestonGLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationHestonGLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationHestonG is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationHestonHLog(base::Grid& grid, - base::DataMatrix& coef) { +base::OperationMatrix* createOperationHestonHLog(base::Grid& grid, base::DataMatrix& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationHestonHLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationHestonHLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationHestonH is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationHestonKLog(base::Grid& grid, - float_t**** * coef) { +base::OperationMatrix* createOperationHestonKLog(base::Grid& grid, float_t***** coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationHestonKLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationHestonKLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationHestonK is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationHestonX(base::Grid& grid, - base::DataMatrix& coef) { +base::OperationMatrix* createOperationHestonX(base::Grid& grid, base::DataMatrix& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationHestonXLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationHestonXLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationHestonX is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationHestonY(base::Grid& grid, - base::DataMatrix& coef) { +base::OperationMatrix* createOperationHestonY(base::Grid& grid, base::DataMatrix& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationHestonYLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationHestonYLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationHestonY is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationHestonW(base::Grid& grid, - base::DataMatrix& coef) { +base::OperationMatrix* createOperationHestonW(base::Grid& grid, base::DataMatrix& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationHestonWLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationHestonWLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationHestonW is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationHestonZ(base::Grid& grid, - base::DataVector& coef) { +base::OperationMatrix* createOperationHestonZ(base::Grid& grid, base::DataVector& coef) { if (grid.getType() == base::GridType::Linear) { return new finance::OperationHestonZLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new finance::OperationHestonZLinearBoundary(grid.getStorage(), coef); - } else + } else { throw base::factory_exception("OperationHestonZ is not implemented for this grid type."); + } } - -} -} +} // namespace op_factory +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/FinanceOpFactory.hpp b/finance/src/sgpp/finance/operation/FinanceOpFactory.hpp index 0d77fa72fe..1b4e51e1c1 100644 --- a/finance/src/sgpp/finance/operation/FinanceOpFactory.hpp +++ b/finance/src/sgpp/finance/operation/FinanceOpFactory.hpp @@ -18,7 +18,6 @@ #include - namespace SGPP { namespace op_factory { @@ -28,28 +27,30 @@ namespace op_factory { * * This operation calculates the following bilinear form which is * needed to solve the Black Scholes equation: - * \f$ \int_{\Omega} S_i S_j \frac{\partial u(\vec{s}}{\partial S_i} \frac{\partial v(\vec{s}}{\partial S_j} d \vec{s}\f$ + * \f$ \int_{\Omega} S_i S_j \frac{\partial u(\vec{s}}{\partial S_i} \frac{\partial + * v(\vec{s}}{\partial S_j} d \vec{s}\f$ * * @param grid Grid which is to be used - * @param coef Reference to a DataMatrix object that contains the constant coeffecients of this bilinear form + * @param coef Reference to a DataMatrix object that contains the constant coeffecients of this + * bilinear form * @return Pointer to the new OperationMatrix object for the Grid grid */ -base::OperationMatrix* createOperationGamma(base::Grid& grid, - base::DataMatrix& coef); +base::OperationMatrix* createOperationGamma(base::Grid& grid, base::DataMatrix& coef); /** * Factory method, returning an OperationGammaLog (OperationMatrix) for the grid at hand. * Note: object has to be freed after use. * * This operation calculates the following bilinear form which is * needed to solve the Black Scholes equation: - * \f$ \int_{\Omega} \frac{\partial u(\vec{s}}{\partial S_i} \frac{\partial v(\vec{s}}{\partial S_j} d \vec{s}\f$ + * \f$ \int_{\Omega} \frac{\partial u(\vec{s}}{\partial S_i} \frac{\partial v(\vec{s}}{\partial S_j} + * d \vec{s}\f$ * * @param grid Grid which is to be used - * @param coef Reference to a DataMatrix object that contains the constant coeffecients of this bilinear form + * @param coef Reference to a DataMatrix object that contains the constant coeffecients of this + * bilinear form * @return Pointer to the new OperationMatrix object for the Grid grid */ -base::OperationMatrix* createOperationGammaLog(base::Grid& grid, - base::DataMatrix& coef); +base::OperationMatrix* createOperationGammaLog(base::Grid& grid, base::DataMatrix& coef); /** * Factory method, returning an OperationLB (OperationMatrix) for the grid at hand. * Note: object has to be freed after use. @@ -91,11 +92,11 @@ base::OperationMatrix* createOperationLF(base::Grid& grid); * \f$ \int_{\Omega} S_i v(\vec{s}) \frac{\partial u(\vec{s}}{\partial S_i} d \vec{s}\f$ * * @param grid Grid which is to be used - * @param coef Reference to a DataMatrix object that contains the constant coeffecients of this bilinear form + * @param coef Reference to a DataMatrix object that contains the constant coeffecients of this + * bilinear form * @return Pointer to the new OperationMatrix object for the Grid grid */ -base::OperationMatrix* createOperationDelta(base::Grid& grid, - base::DataVector& coef); +base::OperationMatrix* createOperationDelta(base::Grid& grid, base::DataVector& coef); /** * Factory method, returning an OperationDeltaLog (OperationMatrix) for the grid at hand. * Note: object has to be freed after use. @@ -105,39 +106,25 @@ base::OperationMatrix* createOperationDelta(base::Grid& grid, * \f$ \int_{\Omega} \frac{\partial u(\vec{s}}{\partial S_i} v(\vec{s}) d \vec{s}\f$ * * @param grid Grid which is to be used - * @param coef Reference to a DataMatrix object that contains the constant coeffecients of this bilinear form + * @param coef Reference to a DataMatrix object that contains the constant coeffecients of this + * bilinear form * @return Pointer to the new OperationMatrix object for the Grid grid */ -base::OperationMatrix* createOperationDeltaLog(base::Grid& grid, - base::DataVector& coef); - -base::OperationMatrix* createOperationHestonBLog(base::Grid& grid, - base::DataMatrix& coef); -base::OperationMatrix* createOperationHestonCLog(base::Grid& grid, - base::DataMatrix& coef); -base::OperationMatrix* createOperationHestonDLog(base::Grid& grid, - base::DataVector& coef); -base::OperationMatrix* createOperationHestonELog(base::Grid& grid, - base::DataVector& coef); -base::OperationMatrix* createOperationHestonFLog(base::Grid& grid, - base::DataVector& coef); -base::OperationMatrix* createOperationHestonGLog(base::Grid& grid, - base::DataVector& coef); -base::OperationMatrix* createOperationHestonHLog(base::Grid& grid, - base::DataMatrix& coef); -base::OperationMatrix* createOperationHestonKLog(base::Grid& grid, - float_t**** * coef); -base::OperationMatrix* createOperationHestonX(base::Grid& grid, - base::DataMatrix& coef); -base::OperationMatrix* createOperationHestonY(base::Grid& grid, - base::DataMatrix& coef); -base::OperationMatrix* createOperationHestonW(base::Grid& grid, - base::DataMatrix& coef); -base::OperationMatrix* createOperationHestonZ(base::Grid& grid, - base::DataVector& coef); - -} +base::OperationMatrix* createOperationDeltaLog(base::Grid& grid, base::DataVector& coef); -} +base::OperationMatrix* createOperationHestonBLog(base::Grid& grid, base::DataMatrix& coef); +base::OperationMatrix* createOperationHestonCLog(base::Grid& grid, base::DataMatrix& coef); +base::OperationMatrix* createOperationHestonDLog(base::Grid& grid, base::DataVector& coef); +base::OperationMatrix* createOperationHestonELog(base::Grid& grid, base::DataVector& coef); +base::OperationMatrix* createOperationHestonFLog(base::Grid& grid, base::DataVector& coef); +base::OperationMatrix* createOperationHestonGLog(base::Grid& grid, base::DataVector& coef); +base::OperationMatrix* createOperationHestonHLog(base::Grid& grid, base::DataMatrix& coef); +base::OperationMatrix* createOperationHestonKLog(base::Grid& grid, float_t***** coef); +base::OperationMatrix* createOperationHestonX(base::Grid& grid, base::DataMatrix& coef); +base::OperationMatrix* createOperationHestonY(base::Grid& grid, base::DataMatrix& coef); +base::OperationMatrix* createOperationHestonW(base::Grid& grid, base::DataMatrix& coef); +base::OperationMatrix* createOperationHestonZ(base::Grid& grid, base::DataVector& coef); +} // namespace op_factory +} // namespace SGPP -#endif /*FINANCE_OP_FACTORY_HPP*/ \ No newline at end of file +#endif /*FINANCE_OP_FACTORY_HPP*/ diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinear.cpp index 25e150d479..5f5b073dc4 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinear.cpp @@ -15,19 +15,17 @@ #include - namespace SGPP { namespace finance { OperationDeltaLinear::OperationDeltaLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationDeltaLinear::~OperationDeltaLinear() { -} +OperationDeltaLinear::~OperationDeltaLinear() {} -void OperationDeltaLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -35,8 +33,8 @@ void OperationDeltaLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationDeltaLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -44,8 +42,8 @@ void OperationDeltaLinear::down(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationDeltaLinear::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLinear::upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -53,14 +51,13 @@ void OperationDeltaLinear::upOpDim(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationDeltaLinear::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLinear::downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // x * dphi * phi XdPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinear.hpp index 4b753b7507..0dc95c6533 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -26,10 +25,10 @@ class OperationDeltaLinear : public SGPP::pde::UpDownOneOpDim { * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationDeltaLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationDeltaLinear(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -46,8 +45,7 @@ class OperationDeltaLinear : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -58,8 +56,7 @@ class OperationDeltaLinear : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -69,8 +66,7 @@ class OperationDeltaLinear : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -80,11 +76,9 @@ class OperationDeltaLinear : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONDELTALINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONDELTALINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearBoundary.cpp index 6990e4bdcd..183ef6b7f5 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearBoundary.cpp @@ -15,20 +15,17 @@ #include - namespace SGPP { namespace finance { -OperationDeltaLinearBoundary::OperationDeltaLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} +OperationDeltaLinearBoundary::OperationDeltaLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationDeltaLinearBoundary::~OperationDeltaLinearBoundary() { -} +OperationDeltaLinearBoundary::~OperationDeltaLinearBoundary() {} -void OperationDeltaLinearBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -46,7 +43,7 @@ void OperationDeltaLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationDeltaLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -55,13 +52,12 @@ void OperationDeltaLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, } void OperationDeltaLinearBoundary::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearBoundary.hpp index 04ecdc8f11..e00acfd561 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -20,16 +19,16 @@ namespace finance { * equation * */ -class OperationDeltaLinearBoundary: public SGPP::pde::UpDownOneOpDim { +class OperationDeltaLinearBoundary : public SGPP::pde::UpDownOneOpDim { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationDeltaLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationDeltaLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -46,8 +45,7 @@ class OperationDeltaLinearBoundary: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -58,8 +56,7 @@ class OperationDeltaLinearBoundary: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -69,8 +66,7 @@ class OperationDeltaLinearBoundary: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -80,11 +76,9 @@ class OperationDeltaLinearBoundary: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONDELTALINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONDELTALINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretched.cpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretched.cpp old mode 100755 new mode 100644 index 99dfb82cdf..6927f6e281 --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretched.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretched.cpp @@ -15,17 +15,14 @@ #include - namespace SGPP { namespace finance { -OperationDeltaLinearStretched::OperationDeltaLinearStretched( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} +OperationDeltaLinearStretched::OperationDeltaLinearStretched(SGPP::base::GridStorage* storage, + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationDeltaLinearStretched::~OperationDeltaLinearStretched() { -} +OperationDeltaLinearStretched::~OperationDeltaLinearStretched() {} void OperationDeltaLinearStretched::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { @@ -37,17 +34,16 @@ void OperationDeltaLinearStretched::up(SGPP::base::DataVector& alpha, } void OperationDeltaLinearStretched::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearStretched func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } void OperationDeltaLinearStretched::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -56,13 +52,12 @@ void OperationDeltaLinearStretched::upOpDim(SGPP::base::DataVector& alpha, } void OperationDeltaLinearStretched::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiDownBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretched.hpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretched.hpp old mode 100755 new mode 100644 index b83ecd83f5..a40b78d8ff --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretched.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretched.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -26,10 +25,10 @@ class OperationDeltaLinearStretched : public SGPP::pde::UpDownOneOpDim { * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationDeltaLinearStretched(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationDeltaLinearStretched(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -46,8 +45,7 @@ class OperationDeltaLinearStretched : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -58,8 +56,7 @@ class OperationDeltaLinearStretched : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -69,8 +66,7 @@ class OperationDeltaLinearStretched : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -80,11 +76,9 @@ class OperationDeltaLinearStretched : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONDELTALINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* OPERATIONDELTALINEARSTRETCHED_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index f195927b39..523c27a6be --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretchedBoundary.cpp @@ -15,40 +15,35 @@ #include - namespace SGPP { namespace finance { OperationDeltaLinearStretchedBoundary::OperationDeltaLinearStretchedBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} + SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationDeltaLinearStretchedBoundary::~OperationDeltaLinearStretchedBoundary() { -} +OperationDeltaLinearStretchedBoundary::~OperationDeltaLinearStretchedBoundary() {} void OperationDeltaLinearStretchedBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinearStretchedBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } void OperationDeltaLinearStretchedBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearStretchedBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } -void OperationDeltaLinearStretchedBoundary::upOpDim(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLinearStretchedBoundary::upOpDim(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -56,14 +51,13 @@ void OperationDeltaLinearStretchedBoundary::upOpDim(SGPP::base::DataVector& s.sweep1D_Boundary(alpha, result, dim); } -void OperationDeltaLinearStretchedBoundary::downOpDim(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLinearStretchedBoundary::downOpDim(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiDownBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 8363bd035d..3f5235685e --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLinearStretchedBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -20,13 +19,14 @@ namespace finance { * equation * */ -class OperationDeltaLinearStretchedBoundary: public SGPP::pde::UpDownOneOpDim { +class OperationDeltaLinearStretchedBoundary : public SGPP::pde::UpDownOneOpDim { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ OperationDeltaLinearStretchedBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); @@ -46,8 +46,7 @@ class OperationDeltaLinearStretchedBoundary: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -58,8 +57,7 @@ class OperationDeltaLinearStretchedBoundary: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -69,8 +67,7 @@ class OperationDeltaLinearStretchedBoundary: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -80,11 +77,9 @@ class OperationDeltaLinearStretchedBoundary: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONDELTALINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONDELTALINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinear.cpp old mode 100755 new mode 100644 index 831174f556..51ad6492e8 --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinear.cpp @@ -15,20 +15,17 @@ #include - namespace SGPP { namespace finance { -OperationDeltaLogLinear::OperationDeltaLogLinear(SGPP::base::GridStorage* - storage, SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, - coef) { -} +OperationDeltaLogLinear::OperationDeltaLogLinear(SGPP::base::GridStorage* storage, + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationDeltaLogLinear::~OperationDeltaLogLinear() { -} +OperationDeltaLogLinear::~OperationDeltaLogLinear() {} -void OperationDeltaLogLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLogLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -36,8 +33,8 @@ void OperationDeltaLogLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationDeltaLogLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLogLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -45,8 +42,8 @@ void OperationDeltaLogLinear::down(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationDeltaLogLinear::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLogLinear::upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // dphi * phi DPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -62,6 +59,5 @@ void OperationDeltaLogLinear::downOpDim(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinear.hpp old mode 100755 new mode 100644 index 6a80d41182..b2e9972bb4 --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -25,16 +24,16 @@ namespace finance { * on grid's with 0-Dririchlet Boundaries. * */ -class OperationDeltaLogLinear: public SGPP::pde::UpDownOneOpDim { +class OperationDeltaLogLinear : public SGPP::pde::UpDownOneOpDim { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationDeltaLogLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationDeltaLogLinear(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -51,8 +50,7 @@ class OperationDeltaLogLinear: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -63,8 +61,7 @@ class OperationDeltaLogLinear: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -74,8 +71,7 @@ class OperationDeltaLogLinear: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -85,11 +81,9 @@ class OperationDeltaLogLinear: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONDELTALOGLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONDELTALOGLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearBoundary.cpp index 94d3e6cf16..4129e202a3 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearBoundary.cpp @@ -15,20 +15,17 @@ #include - namespace SGPP { namespace finance { -OperationDeltaLogLinearBoundary::OperationDeltaLogLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} +OperationDeltaLogLinearBoundary::OperationDeltaLogLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationDeltaLogLinearBoundary::~OperationDeltaLogLinearBoundary() { -} +OperationDeltaLogLinearBoundary::~OperationDeltaLogLinearBoundary() {} void OperationDeltaLogLinearBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -37,7 +34,7 @@ void OperationDeltaLogLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationDeltaLogLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -46,7 +43,7 @@ void OperationDeltaLogLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationDeltaLogLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -55,13 +52,12 @@ void OperationDeltaLogLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, } void OperationDeltaLogLinearBoundary::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearBoundary.hpp index 820e8acc97..1429424f89 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -21,16 +20,16 @@ namespace finance { * equation * */ -class OperationDeltaLogLinearBoundary: public SGPP::pde::UpDownOneOpDim { +class OperationDeltaLogLinearBoundary : public SGPP::pde::UpDownOneOpDim { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationDeltaLogLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationDeltaLogLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -47,8 +46,7 @@ class OperationDeltaLogLinearBoundary: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +57,7 @@ class OperationDeltaLogLinearBoundary: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -70,8 +67,7 @@ class OperationDeltaLogLinearBoundary: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -81,11 +77,9 @@ class OperationDeltaLogLinearBoundary: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONDELTALOGLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONDELTALOGLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretched.cpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretched.cpp old mode 100755 new mode 100644 index 95ae92d7b8..c8210702ae --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretched.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretched.cpp @@ -15,20 +15,17 @@ #include - namespace SGPP { namespace finance { -OperationDeltaLogLinearStretched::OperationDeltaLogLinearStretched( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} +OperationDeltaLogLinearStretched::OperationDeltaLogLinearStretched(SGPP::base::GridStorage* storage, + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationDeltaLogLinearStretched::~OperationDeltaLogLinearStretched() { -} +OperationDeltaLogLinearStretched::~OperationDeltaLogLinearStretched() {} void OperationDeltaLogLinearStretched::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -37,17 +34,16 @@ void OperationDeltaLogLinearStretched::up(SGPP::base::DataVector& alpha, } void OperationDeltaLogLinearStretched::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearStretched func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } void OperationDeltaLogLinearStretched::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiUpBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -56,13 +52,12 @@ void OperationDeltaLogLinearStretched::upOpDim(SGPP::base::DataVector& alpha, } void OperationDeltaLogLinearStretched::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiDownBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretched.hpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretched.hpp old mode 100755 new mode 100644 index 7626e30af0..2a5a113ee4 --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretched.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretched.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -25,16 +24,16 @@ namespace finance { * on grid's with 0-Dririchlet Boundaries. * */ -class OperationDeltaLogLinearStretched: public SGPP::pde::UpDownOneOpDim { +class OperationDeltaLogLinearStretched : public SGPP::pde::UpDownOneOpDim { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationDeltaLogLinearStretched(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationDeltaLogLinearStretched(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -51,8 +50,7 @@ class OperationDeltaLogLinearStretched: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -63,8 +61,7 @@ class OperationDeltaLogLinearStretched: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -74,8 +71,7 @@ class OperationDeltaLogLinearStretched: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -85,11 +81,9 @@ class OperationDeltaLogLinearStretched: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONDELTALOGLINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* OPERATIONDELTALOGLINEARSTRETCHED_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index 9bccc92ff2..09adda52d5 --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretchedBoundary.cpp @@ -15,40 +15,35 @@ #include - namespace SGPP { namespace finance { OperationDeltaLogLinearStretchedBoundary::OperationDeltaLogLinearStretchedBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} + SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationDeltaLogLinearStretchedBoundary::~OperationDeltaLogLinearStretchedBoundary() { -} +OperationDeltaLogLinearStretchedBoundary::~OperationDeltaLogLinearStretchedBoundary() {} void OperationDeltaLogLinearStretchedBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinearStretchedBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } -void OperationDeltaLogLinearStretchedBoundary::down(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLogLinearStretchedBoundary::down(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearStretchedBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } -void OperationDeltaLogLinearStretchedBoundary::upOpDim(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLogLinearStretchedBoundary::upOpDim(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiUpBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -56,14 +51,14 @@ void OperationDeltaLogLinearStretchedBoundary::upOpDim(SGPP::base::DataVector& s.sweep1D_Boundary(alpha, result, dim); } -void OperationDeltaLogLinearStretchedBoundary::downOpDim( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationDeltaLogLinearStretchedBoundary::downOpDim(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // dphi * phi DPhiPhiDownBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index bbcb0ba433..0d21779275 --- a/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationDeltaLogLinearStretchedBoundary.hpp @@ -8,10 +8,8 @@ #include - #include - namespace SGPP { namespace finance { @@ -22,17 +20,17 @@ namespace finance { * equation * */ -class OperationDeltaLogLinearStretchedBoundary: public - SGPP::pde::UpDownOneOpDim { +class OperationDeltaLogLinearStretchedBoundary : public SGPP::pde::UpDownOneOpDim { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ OperationDeltaLogLinearStretchedBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + SGPP::base::DataVector& coef); /** * Destructor @@ -49,8 +47,7 @@ class OperationDeltaLogLinearStretchedBoundary: public * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +58,7 @@ class OperationDeltaLogLinearStretchedBoundary: public * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -72,8 +68,7 @@ class OperationDeltaLogLinearStretchedBoundary: public * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -83,11 +78,9 @@ class OperationDeltaLogLinearStretchedBoundary: public * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONDELTALOGLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONDELTALOGLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLinear.cpp index 03f3d204ee..21f3a085f1 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLinear.cpp @@ -19,23 +19,21 @@ #include -#include - #include +#include namespace SGPP { namespace finance { OperationGammaLinear::OperationGammaLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationGammaLinear::~OperationGammaLinear() { -} +OperationGammaLinear::~OperationGammaLinear() {} -void OperationGammaLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -43,8 +41,8 @@ void OperationGammaLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationGammaLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -52,8 +50,8 @@ void OperationGammaLinear::down(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationGammaLinear::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinear::upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // x * phi * dphi XPhidPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -70,8 +68,8 @@ void OperationGammaLinear::downOpDimOne(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationGammaLinear::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinear::upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -89,7 +87,7 @@ void OperationGammaLinear::downOpDimTwo(SGPP::base::DataVector& alpha, } void OperationGammaLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x^2 * dphi * dphi SqXdPhidPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -97,14 +95,13 @@ void OperationGammaLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationGammaLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // x^2 * dphi * dphi SqXdPhidPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLinear.hpp index 9fc09d6bd2..2bc2c7663c 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationGammaLinear : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationGammaLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationGammaLinear(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -46,8 +44,7 @@ class OperationGammaLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -58,8 +55,7 @@ class OperationGammaLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x phi dphi operation @@ -69,8 +65,8 @@ class OperationGammaLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi dphi operation @@ -80,8 +76,8 @@ class OperationGammaLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -91,8 +87,8 @@ class OperationGammaLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -102,33 +98,34 @@ class OperationGammaLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi + * dphi operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi + * operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONGAMMALINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONGAMMALINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLinearBoundary.cpp index 1bcbdf840e..b4d2434388 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLinearBoundary.cpp @@ -19,24 +19,21 @@ #include -#include - #include +#include namespace SGPP { namespace finance { -OperationGammaLinearBoundary::OperationGammaLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} +OperationGammaLinearBoundary::OperationGammaLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationGammaLinearBoundary::~OperationGammaLinearBoundary() { -} +OperationGammaLinearBoundary::~OperationGammaLinearBoundary() {} -void OperationGammaLinearBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -54,7 +51,7 @@ void OperationGammaLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationGammaLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * dphi XPhidPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -63,7 +60,7 @@ void OperationGammaLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationGammaLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * dphi XPhidPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -72,7 +69,7 @@ void OperationGammaLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, } void OperationGammaLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -81,7 +78,7 @@ void OperationGammaLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationGammaLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -89,8 +86,9 @@ void OperationGammaLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLinearBoundary::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinearBoundary::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // x^2 * dphi * dphi SqXdPhidPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -98,14 +96,14 @@ void OperationGammaLinearBoundary::upOpDimOneAndOpDimTwo( s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLinearBoundary::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinearBoundary::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // x^2 * dphi * dphi SqXdPhidPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLinearBoundary.hpp index 9fa73d4973..f43563f767 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -20,7 +19,7 @@ namespace finance { * equation * */ -class OperationGammaLinearBoundary: public SGPP::pde::UpDownTwoOpDims { +class OperationGammaLinearBoundary : public SGPP::pde::UpDownTwoOpDims { public: /** * Constructor @@ -28,8 +27,7 @@ class OperationGammaLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationGammaLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationGammaLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -46,8 +44,7 @@ class OperationGammaLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -58,8 +55,7 @@ class OperationGammaLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x phi dphi operation @@ -69,8 +65,8 @@ class OperationGammaLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi dphi operation @@ -80,8 +76,8 @@ class OperationGammaLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -91,8 +87,8 @@ class OperationGammaLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -102,33 +98,34 @@ class OperationGammaLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi + * dphi operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi + * operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONGAMMALINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONGAMMALINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretched.cpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretched.cpp old mode 100755 new mode 100644 index 94928d17f7..7be6b69aee --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretched.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretched.cpp @@ -19,21 +19,18 @@ #include -#include - #include +#include namespace SGPP { namespace finance { -OperationGammaLinearStretched::OperationGammaLinearStretched( - SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} +OperationGammaLinearStretched::OperationGammaLinearStretched(SGPP::base::GridStorage* storage, + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationGammaLinearStretched::~OperationGammaLinearStretched() { -} +OperationGammaLinearStretched::~OperationGammaLinearStretched() {} void OperationGammaLinearStretched::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { @@ -45,17 +42,16 @@ void OperationGammaLinearStretched::up(SGPP::base::DataVector& alpha, } void OperationGammaLinearStretched::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearStretched func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } void OperationGammaLinearStretched::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * dphi XPhidPhiUpBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -64,7 +60,7 @@ void OperationGammaLinearStretched::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationGammaLinearStretched::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * dphi XPhidPhiDownBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -73,7 +69,7 @@ void OperationGammaLinearStretched::downOpDimOne(SGPP::base::DataVector& alpha, } void OperationGammaLinearStretched::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -82,7 +78,7 @@ void OperationGammaLinearStretched::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationGammaLinearStretched::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiDownBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -90,8 +86,9 @@ void OperationGammaLinearStretched::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationGammaLinearStretched::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinearStretched::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // x^2 * dphi * dphi SqXdPhidPhiUpBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -99,14 +96,14 @@ void OperationGammaLinearStretched::upOpDimOneAndOpDimTwo( s.sweep1D(alpha, result, dim); } -void OperationGammaLinearStretched::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinearStretched::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // x^2 * dphi * dphi SqXdPhidPhiDownBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretched.hpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretched.hpp old mode 100755 new mode 100644 index 228084d24e..d01e363e2c --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretched.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretched.hpp @@ -8,10 +8,8 @@ #include - #include - namespace SGPP { namespace finance { @@ -29,8 +27,7 @@ class OperationGammaLinearStretched : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationGammaLinearStretched(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationGammaLinearStretched(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -47,8 +44,7 @@ class OperationGammaLinearStretched : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +55,7 @@ class OperationGammaLinearStretched : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x phi dphi operation @@ -70,8 +65,8 @@ class OperationGammaLinearStretched : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi dphi operation @@ -81,8 +76,8 @@ class OperationGammaLinearStretched : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -92,8 +87,8 @@ class OperationGammaLinearStretched : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -103,33 +98,34 @@ class OperationGammaLinearStretched : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi + * dphi operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi + * operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONGAMMALINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* OPERATIONGAMMALINEARSTRETCHED_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index fd65a2a991..3169393c66 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretchedBoundary.cpp @@ -19,44 +19,39 @@ #include -#include - #include +#include namespace SGPP { namespace finance { OperationGammaLinearStretchedBoundary::OperationGammaLinearStretchedBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} + SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationGammaLinearStretchedBoundary::~OperationGammaLinearStretchedBoundary() { -} +OperationGammaLinearStretchedBoundary::~OperationGammaLinearStretchedBoundary() {} void OperationGammaLinearStretchedBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinearStretchedBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } void OperationGammaLinearStretchedBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearStretchedBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLinearStretchedBoundary::upOpDimOne(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinearStretchedBoundary::upOpDimOne(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // x * phi * dphi XPhidPhiUpBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -64,8 +59,9 @@ void OperationGammaLinearStretchedBoundary::upOpDimOne(SGPP::base::DataVector& s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLinearStretchedBoundary::downOpDimOne( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinearStretchedBoundary::downOpDimOne(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // x * phi * dphi XPhidPhiDownBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -73,8 +69,8 @@ void OperationGammaLinearStretchedBoundary::downOpDimOne( s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLinearStretchedBoundary::upOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinearStretchedBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -82,8 +78,9 @@ void OperationGammaLinearStretchedBoundary::upOpDimTwo(SGPP::base::DataVector& s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLinearStretchedBoundary::downOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinearStretchedBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // x * dphi * phi XdPhiPhiDownBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -91,25 +88,24 @@ void OperationGammaLinearStretchedBoundary::downOpDimTwo( s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLinearStretchedBoundary::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinearStretchedBoundary::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // x^2 * dphi * dphi SqXdPhidPhiUpBBLinearStretchedBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLinearStretchedBoundary::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLinearStretchedBoundary::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // x^2 * dphi * dphi SqXdPhidPhiDownBBLinearStretchedBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 1b45e212a9..1d59d06e88 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLinearStretchedBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -20,7 +19,7 @@ namespace finance { * equation * */ -class OperationGammaLinearStretchedBoundary: public SGPP::pde::UpDownTwoOpDims { +class OperationGammaLinearStretchedBoundary : public SGPP::pde::UpDownTwoOpDims { public: /** * Constructor @@ -46,8 +45,7 @@ class OperationGammaLinearStretchedBoundary: public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -58,8 +56,7 @@ class OperationGammaLinearStretchedBoundary: public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x phi dphi operation @@ -69,8 +66,8 @@ class OperationGammaLinearStretchedBoundary: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi dphi operation @@ -80,8 +77,8 @@ class OperationGammaLinearStretchedBoundary: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -91,8 +88,8 @@ class OperationGammaLinearStretchedBoundary: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -102,33 +99,34 @@ class OperationGammaLinearStretchedBoundary: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi + * dphi operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi + * operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONGAMMALINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONGAMMALINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinear.cpp index e5f986a9e7..5508b959d7 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinear.cpp @@ -18,24 +18,21 @@ #include -#include - #include +#include namespace SGPP { namespace finance { -OperationGammaLogLinear::OperationGammaLogLinear(SGPP::base::GridStorage* - storage, SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, - coef) { -} +OperationGammaLogLinear::OperationGammaLogLinear(SGPP::base::GridStorage* storage, + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationGammaLogLinear::~OperationGammaLogLinear() { -} +OperationGammaLogLinear::~OperationGammaLogLinear() {} -void OperationGammaLogLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -43,8 +40,8 @@ void OperationGammaLogLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationGammaLogLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -53,7 +50,7 @@ void OperationGammaLogLinear::down(SGPP::base::DataVector& alpha, } void OperationGammaLogLinear::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * dphi PhidPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -62,7 +59,7 @@ void OperationGammaLogLinear::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationGammaLogLinear::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * dphi PhidPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -71,7 +68,7 @@ void OperationGammaLogLinear::downOpDimOne(SGPP::base::DataVector& alpha, } void OperationGammaLogLinear::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -80,7 +77,7 @@ void OperationGammaLogLinear::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationGammaLogLinear::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -88,16 +85,15 @@ void OperationGammaLogLinear::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationGammaLogLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { result.setAll(0.0); } -void OperationGammaLogLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { SGPP::pde::DowndPhidPhiBBIterativeLinear myDown(this->storage); myDown(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinear.hpp index 369c24bb73..bf0fe93269 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -25,7 +24,7 @@ namespace finance { * on grid's with 0-Dririchlet Boundaries. * */ -class OperationGammaLogLinear: public SGPP::pde::UpDownTwoOpDims { +class OperationGammaLogLinear : public SGPP::pde::UpDownTwoOpDims { public: /** * Constructor @@ -33,8 +32,7 @@ class OperationGammaLogLinear: public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationGammaLogLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationGammaLogLinear(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -51,8 +49,7 @@ class OperationGammaLogLinear: public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -63,8 +60,7 @@ class OperationGammaLogLinear: public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x phi dphi operation @@ -74,8 +70,8 @@ class OperationGammaLogLinear: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi dphi operation @@ -85,8 +81,8 @@ class OperationGammaLogLinear: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -96,8 +92,8 @@ class OperationGammaLogLinear: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -107,33 +103,34 @@ class OperationGammaLogLinear: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi + * dphi operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi + * operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONGAMMALOGLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONGAMMALOGLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearBoundary.cpp index ca00bb8aee..695825e50e 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearBoundary.cpp @@ -19,24 +19,21 @@ #include -#include - #include +#include namespace SGPP { namespace finance { -OperationGammaLogLinearBoundary::OperationGammaLogLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} +OperationGammaLogLinearBoundary::OperationGammaLogLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationGammaLogLinearBoundary::~OperationGammaLogLinearBoundary() { -} +OperationGammaLogLinearBoundary::~OperationGammaLogLinearBoundary() {} void OperationGammaLogLinearBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -45,7 +42,7 @@ void OperationGammaLogLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationGammaLogLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -54,7 +51,7 @@ void OperationGammaLogLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationGammaLogLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * dphi PhidPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -62,8 +59,8 @@ void OperationGammaLogLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLogLinearBoundary::downOpDimOne(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // phi * dphi PhidPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -72,7 +69,7 @@ void OperationGammaLogLinearBoundary::downOpDimOne(SGPP::base::DataVector& } void OperationGammaLogLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -80,8 +77,8 @@ void OperationGammaLogLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLogLinearBoundary::downOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -89,17 +86,18 @@ void OperationGammaLogLinearBoundary::downOpDimTwo(SGPP::base::DataVector& s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLogLinearBoundary::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearBoundary::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { SGPP::pde::UpdPhidPhiBBIterativeLinearBoundary myUp(this->storage); myUp(alpha, result, dim); } -void OperationGammaLogLinearBoundary::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearBoundary::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { SGPP::pde::DowndPhidPhiBBIterativeLinearBoundary myDown(this->storage); myDown(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearBoundary.hpp index d8bb0ba18d..bf65d55e66 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -21,7 +20,7 @@ namespace finance { * equation * */ -class OperationGammaLogLinearBoundary: public SGPP::pde::UpDownTwoOpDims { +class OperationGammaLogLinearBoundary : public SGPP::pde::UpDownTwoOpDims { public: /** * Constructor @@ -29,8 +28,7 @@ class OperationGammaLogLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationGammaLogLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationGammaLogLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -47,8 +45,7 @@ class OperationGammaLogLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +56,7 @@ class OperationGammaLogLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x phi dphi operation @@ -70,8 +66,8 @@ class OperationGammaLogLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi dphi operation @@ -81,8 +77,8 @@ class OperationGammaLogLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -92,8 +88,8 @@ class OperationGammaLogLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -103,33 +99,34 @@ class OperationGammaLogLinearBoundary: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi + * dphi operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi + * operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONGAMMALOGLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONGAMMALOGLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretched.cpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretched.cpp old mode 100755 new mode 100644 index 12765edcef..bebbf3cd9d --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretched.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretched.cpp @@ -18,24 +18,21 @@ #include -#include - #include +#include namespace SGPP { namespace finance { -OperationGammaLogLinearStretched::OperationGammaLogLinearStretched( - SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} +OperationGammaLogLinearStretched::OperationGammaLogLinearStretched(SGPP::base::GridStorage* storage, + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationGammaLogLinearStretched::~OperationGammaLogLinearStretched() { -} +OperationGammaLogLinearStretched::~OperationGammaLogLinearStretched() {} void OperationGammaLogLinearStretched::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -44,17 +41,16 @@ void OperationGammaLogLinearStretched::up(SGPP::base::DataVector& alpha, } void OperationGammaLogLinearStretched::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearStretched func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } void OperationGammaLogLinearStretched::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * dphi PhidPhiUpBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -62,8 +58,8 @@ void OperationGammaLogLinearStretched::upOpDimOne(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationGammaLogLinearStretched::downOpDimOne(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearStretched::downOpDimOne(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // phi * dphi PhidPhiDownBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -72,7 +68,7 @@ void OperationGammaLogLinearStretched::downOpDimOne(SGPP::base::DataVector& } void OperationGammaLogLinearStretched::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiUpBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -80,8 +76,8 @@ void OperationGammaLogLinearStretched::upOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationGammaLogLinearStretched::downOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearStretched::downOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiDownBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -89,16 +85,17 @@ void OperationGammaLogLinearStretched::downOpDimTwo(SGPP::base::DataVector& s.sweep1D(alpha, result, dim); } -void OperationGammaLogLinearStretched::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearStretched::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { result.setAll(0.0); } -void OperationGammaLogLinearStretched::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearStretched::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { SGPP::pde::DowndPhidPhiBBIterativeLinearStretched myDown(this->storage); myDown(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretched.hpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretched.hpp old mode 100755 new mode 100644 index 79bb26aa61..a386941646 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretched.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretched.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -25,7 +24,7 @@ namespace finance { * on grid's with 0-Dririchlet Boundaries. * */ -class OperationGammaLogLinearStretched: public SGPP::pde::UpDownTwoOpDims { +class OperationGammaLogLinearStretched : public SGPP::pde::UpDownTwoOpDims { public: /** * Constructor @@ -33,8 +32,7 @@ class OperationGammaLogLinearStretched: public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationGammaLogLinearStretched(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationGammaLogLinearStretched(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -51,8 +49,7 @@ class OperationGammaLogLinearStretched: public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -63,8 +60,7 @@ class OperationGammaLogLinearStretched: public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x phi dphi operation @@ -74,8 +70,8 @@ class OperationGammaLogLinearStretched: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi dphi operation @@ -85,8 +81,8 @@ class OperationGammaLogLinearStretched: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -96,8 +92,8 @@ class OperationGammaLogLinearStretched: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -107,33 +103,34 @@ class OperationGammaLogLinearStretched: public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi + * dphi operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi + * operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONGAMMALOGLINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* OPERATIONGAMMALOGLINEARSTRETCHED_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretchedBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index ce05a40641..a883c584d2 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretchedBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretchedBoundary.cpp @@ -19,44 +19,40 @@ #include -#include - #include +#include namespace SGPP { namespace finance { OperationGammaLogLinearStretchedBoundary::OperationGammaLogLinearStretchedBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} + SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationGammaLogLinearStretchedBoundary::~OperationGammaLogLinearStretchedBoundary() { -} +OperationGammaLogLinearStretchedBoundary::~OperationGammaLogLinearStretchedBoundary() {} void OperationGammaLogLinearStretchedBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinearStretchedBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLogLinearStretchedBoundary::down(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearStretchedBoundary::down(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearStretchedBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLogLinearStretchedBoundary::upOpDimOne( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearStretchedBoundary::upOpDimOne(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // phi * dphi PhidPhiUpBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -64,8 +60,9 @@ void OperationGammaLogLinearStretchedBoundary::upOpDimOne( s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLogLinearStretchedBoundary::downOpDimOne( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearStretchedBoundary::downOpDimOne(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // phi * dphi PhidPhiDownBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -73,8 +70,9 @@ void OperationGammaLogLinearStretchedBoundary::downOpDimOne( s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLogLinearStretchedBoundary::upOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearStretchedBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // dphi * phi DPhiPhiUpBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -82,8 +80,9 @@ void OperationGammaLogLinearStretchedBoundary::upOpDimTwo( s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLogLinearStretchedBoundary::downOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearStretchedBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // dphi * phi DPhiPhiDownBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -91,17 +90,17 @@ void OperationGammaLogLinearStretchedBoundary::downOpDimTwo( s.sweep1D_Boundary(alpha, result, dim); } -void OperationGammaLogLinearStretchedBoundary::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationGammaLogLinearStretchedBoundary::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { SGPP::pde::UpdPhidPhiBBIterativeLinearStretchedBoundary myUp(this->storage); myUp(alpha, result, dim); } void OperationGammaLogLinearStretchedBoundary::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { SGPP::pde::DowndPhidPhiBBIterativeLinearStretchedBoundary myDown(this->storage); myDown(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretchedBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 092e6832e2..6605f79796 --- a/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretchedBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationGammaLogLinearStretchedBoundary.hpp @@ -8,10 +8,8 @@ #include - #include - namespace SGPP { namespace finance { @@ -22,8 +20,7 @@ namespace finance { * equation * */ -class OperationGammaLogLinearStretchedBoundary: public - SGPP::pde::UpDownTwoOpDims { +class OperationGammaLogLinearStretchedBoundary : public SGPP::pde::UpDownTwoOpDims { public: /** * Constructor @@ -32,7 +29,7 @@ class OperationGammaLogLinearStretchedBoundary: public * @param coef vector that contains the constant coefficients of this operation */ OperationGammaLogLinearStretchedBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + SGPP::base::DataMatrix& coef); /** * Destructor @@ -49,8 +46,7 @@ class OperationGammaLogLinearStretchedBoundary: public * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationGammaLogLinearStretchedBoundary: public * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x phi dphi operation @@ -72,8 +67,8 @@ class OperationGammaLogLinearStretchedBoundary: public * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi dphi operation @@ -83,8 +78,8 @@ class OperationGammaLogLinearStretchedBoundary: public * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -94,8 +89,8 @@ class OperationGammaLogLinearStretchedBoundary: public * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -105,33 +100,34 @@ class OperationGammaLogLinearStretchedBoundary: public * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * down-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi + * dphi operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi operation + * up-Gradient multiplied with a squared x step in dimension dim applies the x^2 dphi dphi + * operation * in one dimension * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONGAMMALOGLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONGAMMALOGLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonBLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonBLinear.cpp index 7f95328e35..3d6f8012b1 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonBLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonBLinear.cpp @@ -18,33 +18,30 @@ #include -#include - #include +#include namespace SGPP { namespace finance { OperationHestonBLinear::OperationHestonBLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationHestonBLinear::~OperationHestonBLinear() { -} +OperationHestonBLinear::~OperationHestonBLinear() {} -void OperationHestonBLinear::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +void OperationHestonBLinear::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { - // no symmetry in the operator - #pragma omp task firstprivate(i, j) shared(alpha, result) +// no symmetry in the operator +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -52,30 +49,26 @@ void OperationHestonBLinear::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } -void OperationHestonBLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonBLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -83,8 +76,8 @@ void OperationHestonBLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonBLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonBLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -98,7 +91,7 @@ void OperationHestonBLinear::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonBLinear::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // Dphi * dphi SGPP::pde::DowndPhidPhiBBIterativeLinear myDown(this->storage); myDown(alpha, result, dim); @@ -114,7 +107,7 @@ void OperationHestonBLinear::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonBLinear::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * phi XPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -122,13 +115,10 @@ void OperationHestonBLinear::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonBLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { -} +void OperationHestonBLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonBLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationHestonBLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonBLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonBLinear.hpp index a3a24121c1..93c194b013 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonBLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonBLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonBLinear : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonBLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationHestonBLinear(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonBLinear : public SGPP::pde::UpDownTwoOpDims { virtual ~OperationHestonBLinear(); protected: - void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** @@ -49,8 +46,7 @@ class OperationHestonBLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationHestonBLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the dphi dphi operation @@ -72,8 +67,8 @@ class OperationHestonBLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the dphi dphi operation @@ -83,8 +78,8 @@ class OperationHestonBLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x phi phi operation @@ -94,8 +89,8 @@ class OperationHestonBLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi phi operation @@ -105,31 +100,32 @@ class OperationHestonBLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * Does nothing (this situation doesn't occur in the Heston PDEs). Implemented only so that this can be a concrete class. + * Does nothing (this situation doesn't occur in the Heston PDEs). Implemented only so that this + * can be a concrete class. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * Does nothing (this situation doesn't occur in the Heston PDEs). Implemented only so that this can be a concrete class. + * Does nothing (this situation doesn't occur in the Heston PDEs). Implemented only so that this + * can be a concrete class. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONBLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonBLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonBLinearBoundary.cpp index 470aecad86..82363029bd 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonBLinearBoundary.cpp @@ -19,34 +19,31 @@ #include -#include - #include +#include namespace SGPP { namespace finance { -OperationHestonBLinearBoundary::OperationHestonBLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} +OperationHestonBLinearBoundary::OperationHestonBLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationHestonBLinearBoundary::~OperationHestonBLinearBoundary() { -} +OperationHestonBLinearBoundary::~OperationHestonBLinearBoundary() {} void OperationHestonBLinearBoundary::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { + SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { - // no symmetry in the operator - #pragma omp task firstprivate(i, j) shared(alpha, result) +// no symmetry in the operator +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -54,24 +51,20 @@ void OperationHestonBLinearBoundary::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } @@ -86,7 +79,7 @@ void OperationHestonBLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationHestonBLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -95,20 +88,20 @@ void OperationHestonBLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationHestonBLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { SGPP::pde::UpdPhidPhiBBIterativeLinearBoundary myUp(this->storage); myUp(alpha, result, dim); } void OperationHestonBLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // Dphi * dphi SGPP::pde::DowndPhidPhiBBIterativeLinearBoundary myDown(this->storage); myDown(alpha, result, dim); } void OperationHestonBLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * phi XPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -117,7 +110,7 @@ void OperationHestonBLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonBLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * phi XPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -125,13 +118,12 @@ void OperationHestonBLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationHestonBLinearBoundary::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { -} +void OperationHestonBLinearBoundary::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} -void OperationHestonBLinearBoundary::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationHestonBLinearBoundary::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonBLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonBLinearBoundary.hpp index 1af5a3c70c..71eb4ec3f0 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonBLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonBLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonBLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationHestonBLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonBLinearBoundary : public SGPP::pde::UpDownTwoOpDims { virtual ~OperationHestonBLinearBoundary(); protected: - void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** @@ -49,8 +46,7 @@ class OperationHestonBLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationHestonBLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the dphi dphi operation @@ -72,8 +67,8 @@ class OperationHestonBLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the dphi dphi operation @@ -83,8 +78,8 @@ class OperationHestonBLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x phi phi operation @@ -94,8 +89,8 @@ class OperationHestonBLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi phi operation @@ -105,31 +100,32 @@ class OperationHestonBLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * Does nothing (this situation doesn't occur in the Heston PDEs). Implemented only so that this can be a concrete class. + * Does nothing (this situation doesn't occur in the Heston PDEs). Implemented only so that this + * can be a concrete class. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * Does nothing (this situation doesn't occur in the Heston PDEs). Implemented only so that this can be a concrete class. + * Does nothing (this situation doesn't occur in the Heston PDEs). Implemented only so that this + * can be a concrete class. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonCLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonCLinear.cpp index e7f04faf46..47fbc4e419 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonCLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonCLinear.cpp @@ -19,33 +19,30 @@ #include -#include - #include +#include namespace SGPP { namespace finance { OperationHestonCLinear::OperationHestonCLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationHestonCLinear::~OperationHestonCLinear() { -} +OperationHestonCLinear::~OperationHestonCLinear() {} -void OperationHestonCLinear::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +void OperationHestonCLinear::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { - // no symmetry in the operator - #pragma omp task firstprivate(i, j) shared(alpha, result) +// no symmetry in the operator +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -53,30 +50,26 @@ void OperationHestonCLinear::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } -void OperationHestonCLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonCLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -84,8 +77,8 @@ void OperationHestonCLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonCLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonCLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -103,7 +96,7 @@ void OperationHestonCLinear::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonCLinear::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * dphi PhidPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -121,7 +114,7 @@ void OperationHestonCLinear::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonCLinear::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -129,13 +122,10 @@ void OperationHestonCLinear::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonCLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { -} +void OperationHestonCLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonCLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationHestonCLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonCLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonCLinear.hpp index 259d20343a..3c635c612d 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonCLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonCLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonCLinear : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonCLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationHestonCLinear(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonCLinear : public SGPP::pde::UpDownTwoOpDims { virtual ~OperationHestonCLinear(); protected: - void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** @@ -49,8 +46,7 @@ class OperationHestonCLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationHestonCLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the phi dphi operation @@ -72,8 +67,8 @@ class OperationHestonCLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the phi dphi operation @@ -83,8 +78,8 @@ class OperationHestonCLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -94,8 +89,8 @@ class OperationHestonCLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -105,31 +100,32 @@ class OperationHestonCLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Only required to make the class complete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Only required to + * make the class complete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Only required to make the class complete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Only required to + * make the class complete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONCLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONCLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonCLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonCLinearBoundary.cpp index e8efcf6876..63f0802a93 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonCLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonCLinearBoundary.cpp @@ -19,34 +19,31 @@ #include -#include - #include +#include namespace SGPP { namespace finance { -OperationHestonCLinearBoundary::OperationHestonCLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} +OperationHestonCLinearBoundary::OperationHestonCLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationHestonCLinearBoundary::~OperationHestonCLinearBoundary() { -} +OperationHestonCLinearBoundary::~OperationHestonCLinearBoundary() {} void OperationHestonCLinearBoundary::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { + SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { - // no symmetry in the operator - #pragma omp task firstprivate(i, j) shared(alpha, result) +// no symmetry in the operator +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -54,24 +51,20 @@ void OperationHestonCLinearBoundary::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } @@ -86,7 +79,7 @@ void OperationHestonCLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationHestonCLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -95,7 +88,7 @@ void OperationHestonCLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationHestonCLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * dphi PhidPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -104,7 +97,7 @@ void OperationHestonCLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonCLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * dphi PhidPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -113,7 +106,7 @@ void OperationHestonCLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonCLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -122,7 +115,7 @@ void OperationHestonCLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonCLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -130,13 +123,12 @@ void OperationHestonCLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationHestonCLinearBoundary::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { -} +void OperationHestonCLinearBoundary::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} -void OperationHestonCLinearBoundary::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationHestonCLinearBoundary::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonCLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonCLinearBoundary.hpp index 4717c2eba4..bdc84a4a2e 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonCLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonCLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonCLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonCLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationHestonCLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonCLinearBoundary : public SGPP::pde::UpDownTwoOpDims { virtual ~OperationHestonCLinearBoundary(); protected: - void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** @@ -49,8 +46,7 @@ class OperationHestonCLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationHestonCLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the phi dphi operation @@ -72,8 +67,8 @@ class OperationHestonCLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the phi dphi operation @@ -83,8 +78,8 @@ class OperationHestonCLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -94,8 +89,8 @@ class OperationHestonCLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -105,31 +100,32 @@ class OperationHestonCLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Only required to make the class complete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Only required to + * make the class complete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Only required to make the class complete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Only required to + * make the class complete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONCLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONCLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonDLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonDLinear.cpp index 532595658f..05a24feeeb 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonDLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonDLinear.cpp @@ -15,19 +15,17 @@ #include - namespace SGPP { namespace finance { OperationHestonDLinear::OperationHestonDLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationHestonDLinear::~OperationHestonDLinear() { -} +OperationHestonDLinear::~OperationHestonDLinear() {} -void OperationHestonDLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonDLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -35,8 +33,8 @@ void OperationHestonDLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonDLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonDLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -44,8 +42,8 @@ void OperationHestonDLinear::down(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonDLinear::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonDLinear::upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // x * dphi * dphi XdPhidPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -61,6 +59,5 @@ void OperationHestonDLinear::downOpDim(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonDLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonDLinear.hpp index 109dbf00d0..99c7c25272 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonDLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonDLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -26,10 +25,10 @@ class OperationHestonDLinear : public SGPP::pde::UpDownOneOpDim { * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationHestonDLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationHestonDLinear(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -37,7 +36,6 @@ class OperationHestonDLinear : public SGPP::pde::UpDownOneOpDim { virtual ~OperationHestonDLinear(); protected: - /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. * Applies the up-part of the one-dimensional mass matrix in one dimension. @@ -47,8 +45,7 @@ class OperationHestonDLinear : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +56,7 @@ class OperationHestonDLinear : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi dphi operation @@ -70,8 +66,7 @@ class OperationHestonDLinear : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the x dphi dphi operation @@ -81,11 +76,9 @@ class OperationHestonDLinear : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONDLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONDLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonDLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonDLinearBoundary.cpp index 096043a427..16f0939d35 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonDLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonDLinearBoundary.cpp @@ -15,17 +15,14 @@ #include - namespace SGPP { namespace finance { -OperationHestonDLinearBoundary::OperationHestonDLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} +OperationHestonDLinearBoundary::OperationHestonDLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationHestonDLinearBoundary::~OperationHestonDLinearBoundary() { -} +OperationHestonDLinearBoundary::~OperationHestonDLinearBoundary() {} void OperationHestonDLinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { @@ -37,7 +34,7 @@ void OperationHestonDLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationHestonDLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -46,7 +43,7 @@ void OperationHestonDLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationHestonDLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * dphi XdPhidPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -55,13 +52,12 @@ void OperationHestonDLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, } void OperationHestonDLinearBoundary::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * dphi XdPhidPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonDLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonDLinearBoundary.hpp index 14bc4d1d42..3b29f540e5 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonDLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonDLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -26,10 +25,10 @@ class OperationHestonDLinearBoundary : public SGPP::pde::UpDownOneOpDim { * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationHestonDLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationHestonDLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -37,7 +36,6 @@ class OperationHestonDLinearBoundary : public SGPP::pde::UpDownOneOpDim { virtual ~OperationHestonDLinearBoundary(); protected: - /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. * Applies the up-part of the one-dimensional mass matrix in one dimension. @@ -47,8 +45,7 @@ class OperationHestonDLinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +56,7 @@ class OperationHestonDLinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi dphi operation @@ -70,8 +66,7 @@ class OperationHestonDLinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the x dphi dphi operation @@ -81,11 +76,9 @@ class OperationHestonDLinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONDLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONDLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonELinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonELinear.cpp index e0ee4097fd..ec682d4ef9 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonELinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonELinear.cpp @@ -15,39 +15,35 @@ #include - namespace SGPP { namespace finance { OperationHestonELinear::OperationHestonELinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationHestonELinear::~OperationHestonELinear() { -} +OperationHestonELinear::~OperationHestonELinear() {} -void OperationHestonELinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonELinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); - } -void OperationHestonELinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonELinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); - } -void OperationHestonELinear::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonELinear::upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // dphi * phi DPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -63,6 +59,5 @@ void OperationHestonELinear::downOpDim(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonELinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonELinear.hpp index a1dbb2e00f..ab0f46f172 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonELinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonELinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -26,10 +25,10 @@ class OperationHestonELinear : public SGPP::pde::UpDownOneOpDim { * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationHestonELinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationHestonELinear(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -37,7 +36,6 @@ class OperationHestonELinear : public SGPP::pde::UpDownOneOpDim { virtual ~OperationHestonELinear(); protected: - /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. * Applies the up-part of the one-dimensional mass matrix in one dimension. @@ -47,8 +45,7 @@ class OperationHestonELinear : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +56,7 @@ class OperationHestonELinear : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the dphi phi operation @@ -70,8 +66,7 @@ class OperationHestonELinear : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the dphi phi operation @@ -81,11 +76,9 @@ class OperationHestonELinear : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONELINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONELINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonELinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonELinearBoundary.cpp index 0fb802bf63..3bb1ef7178 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonELinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonELinearBoundary.cpp @@ -15,17 +15,14 @@ #include - namespace SGPP { namespace finance { -OperationHestonELinearBoundary::OperationHestonELinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} +OperationHestonELinearBoundary::OperationHestonELinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationHestonELinearBoundary::~OperationHestonELinearBoundary() { -} +OperationHestonELinearBoundary::~OperationHestonELinearBoundary() {} void OperationHestonELinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { @@ -34,21 +31,19 @@ void OperationHestonELinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); - } void OperationHestonELinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); - } void OperationHestonELinearBoundary::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -57,13 +52,12 @@ void OperationHestonELinearBoundary::upOpDim(SGPP::base::DataVector& alpha, } void OperationHestonELinearBoundary::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonELinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonELinearBoundary.hpp index 071f2a7e3b..03861ed98e 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonELinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonELinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -26,10 +25,10 @@ class OperationHestonELinearBoundary : public SGPP::pde::UpDownOneOpDim { * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationHestonELinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationHestonELinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -37,7 +36,6 @@ class OperationHestonELinearBoundary : public SGPP::pde::UpDownOneOpDim { virtual ~OperationHestonELinearBoundary(); protected: - /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. * Applies the up-part of the one-dimensional mass matrix in one dimension. @@ -47,8 +45,7 @@ class OperationHestonELinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +56,7 @@ class OperationHestonELinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the dphi phi operation @@ -70,8 +66,7 @@ class OperationHestonELinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the dphi phi operation @@ -81,11 +76,9 @@ class OperationHestonELinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONELINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONELINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonFLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonFLinear.cpp old mode 100755 new mode 100644 index b1472eb4ec..f07dc5bb8e --- a/finance/src/sgpp/finance/operation/hash/OperationHestonFLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonFLinear.cpp @@ -15,19 +15,17 @@ #include - namespace SGPP { namespace finance { OperationHestonFLinear::OperationHestonFLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationHestonFLinear::~OperationHestonFLinear() { -} +OperationHestonFLinear::~OperationHestonFLinear() {} -void OperationHestonFLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonFLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -35,8 +33,8 @@ void OperationHestonFLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonFLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonFLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -44,8 +42,8 @@ void OperationHestonFLinear::down(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonFLinear::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonFLinear::upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // dphi * phi DPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -61,6 +59,5 @@ void OperationHestonFLinear::downOpDim(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonFLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonFLinear.hpp old mode 100755 new mode 100644 index 8470d2af3f..833c390e8f --- a/finance/src/sgpp/finance/operation/hash/OperationHestonFLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonFLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -20,16 +19,16 @@ namespace finance { * equation, on grids with fix Dirichlet-0-Boundaries. * */ -class OperationHestonFLinear: public SGPP::pde::UpDownOneOpDim { +class OperationHestonFLinear : public SGPP::pde::UpDownOneOpDim { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationHestonFLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationHestonFLinear(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -37,7 +36,6 @@ class OperationHestonFLinear: public SGPP::pde::UpDownOneOpDim { virtual ~OperationHestonFLinear(); protected: - /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. * Applies the up-part of the one-dimensional mass matrix in one dimension. @@ -47,8 +45,7 @@ class OperationHestonFLinear: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +56,7 @@ class OperationHestonFLinear: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the dphi phi operation @@ -70,8 +66,7 @@ class OperationHestonFLinear: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the dphi phi operation @@ -81,11 +76,9 @@ class OperationHestonFLinear: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONFLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONFLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonFLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonFLinearBoundary.cpp index d25a6965f5..7f1c29d5a0 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonFLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonFLinearBoundary.cpp @@ -15,17 +15,14 @@ #include - namespace SGPP { namespace finance { -OperationHestonFLinearBoundary::OperationHestonFLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} +OperationHestonFLinearBoundary::OperationHestonFLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationHestonFLinearBoundary::~OperationHestonFLinearBoundary() { -} +OperationHestonFLinearBoundary::~OperationHestonFLinearBoundary() {} void OperationHestonFLinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { @@ -37,7 +34,7 @@ void OperationHestonFLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationHestonFLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -46,7 +43,7 @@ void OperationHestonFLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationHestonFLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -55,13 +52,12 @@ void OperationHestonFLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, } void OperationHestonFLinearBoundary::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonFLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonFLinearBoundary.hpp index a24cff98ae..563ba8be49 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonFLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonFLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -20,16 +19,16 @@ namespace finance { * equation. * */ -class OperationHestonFLinearBoundary: public SGPP::pde::UpDownOneOpDim { +class OperationHestonFLinearBoundary : public SGPP::pde::UpDownOneOpDim { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationHestonFLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationHestonFLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -37,7 +36,6 @@ class OperationHestonFLinearBoundary: public SGPP::pde::UpDownOneOpDim { virtual ~OperationHestonFLinearBoundary(); protected: - /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. * Applies the up-part of the one-dimensional mass matrix in one dimension. @@ -47,8 +45,7 @@ class OperationHestonFLinearBoundary: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +56,7 @@ class OperationHestonFLinearBoundary: public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the dphi phi operation @@ -70,8 +66,7 @@ class OperationHestonFLinearBoundary: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the dphi phi operation @@ -81,11 +76,9 @@ class OperationHestonFLinearBoundary: public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONFLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONFLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonGLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonGLinear.cpp index eece185189..d14e133b14 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonGLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonGLinear.cpp @@ -15,19 +15,17 @@ #include - namespace SGPP { namespace finance { OperationHestonGLinear::OperationHestonGLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationHestonGLinear::~OperationHestonGLinear() { -} +OperationHestonGLinear::~OperationHestonGLinear() {} -void OperationHestonGLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonGLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -35,8 +33,8 @@ void OperationHestonGLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonGLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonGLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -44,8 +42,8 @@ void OperationHestonGLinear::down(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonGLinear::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonGLinear::upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -61,6 +59,5 @@ void OperationHestonGLinear::downOpDim(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonGLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonGLinear.hpp index d62e0a7171..b5c4f1d3f6 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonGLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonGLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -26,10 +25,10 @@ class OperationHestonGLinear : public SGPP::pde::UpDownOneOpDim { * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationHestonGLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationHestonGLinear(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -37,7 +36,6 @@ class OperationHestonGLinear : public SGPP::pde::UpDownOneOpDim { virtual ~OperationHestonGLinear(); protected: - /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. * Applies the up-part of the one-dimensional mass matrix in one dimension. @@ -47,8 +45,7 @@ class OperationHestonGLinear : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +56,7 @@ class OperationHestonGLinear : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -70,8 +66,7 @@ class OperationHestonGLinear : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -81,11 +76,9 @@ class OperationHestonGLinear : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONGLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONGLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonGLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonGLinearBoundary.cpp index 8b7cc14a3e..2369c59b86 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonGLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonGLinearBoundary.cpp @@ -15,17 +15,14 @@ #include - namespace SGPP { namespace finance { -OperationHestonGLinearBoundary::OperationHestonGLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} +OperationHestonGLinearBoundary::OperationHestonGLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationHestonGLinearBoundary::~OperationHestonGLinearBoundary() { -} +OperationHestonGLinearBoundary::~OperationHestonGLinearBoundary() {} void OperationHestonGLinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { @@ -37,7 +34,7 @@ void OperationHestonGLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationHestonGLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -46,7 +43,7 @@ void OperationHestonGLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationHestonGLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -55,13 +52,12 @@ void OperationHestonGLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, } void OperationHestonGLinearBoundary::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonGLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonGLinearBoundary.hpp index 3c9ba07c04..e8fd2af919 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonGLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonGLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -26,10 +25,10 @@ class OperationHestonGLinearBoundary : public SGPP::pde::UpDownOneOpDim { * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationHestonGLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationHestonGLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -37,7 +36,6 @@ class OperationHestonGLinearBoundary : public SGPP::pde::UpDownOneOpDim { virtual ~OperationHestonGLinearBoundary(); protected: - /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. * Applies the up-part of the one-dimensional mass matrix in one dimension. @@ -47,8 +45,7 @@ class OperationHestonGLinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +56,7 @@ class OperationHestonGLinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -70,8 +66,7 @@ class OperationHestonGLinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -81,11 +76,9 @@ class OperationHestonGLinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONGLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONGLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonHLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonHLinear.cpp index 3d9a52af43..971aff3a6f 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonHLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonHLinear.cpp @@ -19,33 +19,30 @@ #include -#include - #include +#include namespace SGPP { namespace finance { OperationHestonHLinear::OperationHestonHLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationHestonHLinear::~OperationHestonHLinear() { -} +OperationHestonHLinear::~OperationHestonHLinear() {} -void OperationHestonHLinear::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +void OperationHestonHLinear::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { - // no symmetry in the operator - #pragma omp task firstprivate(i, j) shared(alpha, result) +// no symmetry in the operator +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -53,30 +50,26 @@ void OperationHestonHLinear::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } -void OperationHestonHLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonHLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -84,8 +77,8 @@ void OperationHestonHLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonHLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonHLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -103,7 +96,7 @@ void OperationHestonHLinear::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonHLinear::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -121,7 +114,7 @@ void OperationHestonHLinear::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonHLinear::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * phi XPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -129,13 +122,10 @@ void OperationHestonHLinear::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonHLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { -} +void OperationHestonHLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonHLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationHestonHLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonHLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonHLinear.hpp index 5de5625a9f..ad3cf831c8 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonHLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonHLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonHLinear : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonHLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationHestonHLinear(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonHLinear : public SGPP::pde::UpDownTwoOpDims { virtual ~OperationHestonHLinear(); protected: - void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** @@ -49,8 +46,7 @@ class OperationHestonHLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationHestonHLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the dphi phi operation @@ -72,8 +67,8 @@ class OperationHestonHLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the dphi phi operation @@ -83,8 +78,8 @@ class OperationHestonHLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x phi phi operation @@ -94,8 +89,8 @@ class OperationHestonHLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi phi operation @@ -105,31 +100,32 @@ class OperationHestonHLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONHLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONHLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonHLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonHLinearBoundary.cpp index e9495494df..7175d95172 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonHLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonHLinearBoundary.cpp @@ -19,34 +19,31 @@ #include -#include - #include +#include namespace SGPP { namespace finance { -OperationHestonHLinearBoundary::OperationHestonHLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} +OperationHestonHLinearBoundary::OperationHestonHLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationHestonHLinearBoundary::~OperationHestonHLinearBoundary() { -} +OperationHestonHLinearBoundary::~OperationHestonHLinearBoundary() {} void OperationHestonHLinearBoundary::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { + SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { - // no symmetry in the operator - #pragma omp task firstprivate(i, j) shared(alpha, result) +// no symmetry in the operator +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -54,24 +51,20 @@ void OperationHestonHLinearBoundary::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } @@ -86,7 +79,7 @@ void OperationHestonHLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationHestonHLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -95,7 +88,7 @@ void OperationHestonHLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationHestonHLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -104,7 +97,7 @@ void OperationHestonHLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonHLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -113,7 +106,7 @@ void OperationHestonHLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonHLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * phi XPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -122,7 +115,7 @@ void OperationHestonHLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonHLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * phi XPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -130,13 +123,12 @@ void OperationHestonHLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationHestonHLinearBoundary::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { -} +void OperationHestonHLinearBoundary::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} -void OperationHestonHLinearBoundary::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationHestonHLinearBoundary::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonHLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonHLinearBoundary.hpp index aa905d2d49..690235a98d 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonHLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonHLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonHLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonHLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationHestonHLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonHLinearBoundary : public SGPP::pde::UpDownTwoOpDims { virtual ~OperationHestonHLinearBoundary(); protected: - void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** @@ -49,8 +46,7 @@ class OperationHestonHLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationHestonHLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the dphi phi operation @@ -72,8 +67,8 @@ class OperationHestonHLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the dphi phi operation @@ -83,8 +78,8 @@ class OperationHestonHLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x phi phi operation @@ -94,8 +89,8 @@ class OperationHestonHLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi phi operation @@ -105,31 +100,32 @@ class OperationHestonHLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONHLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONHLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonKLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonKLinear.cpp index 91700352ca..db5466d47d 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonKLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonKLinear.cpp @@ -19,32 +19,29 @@ #include -#include - #include +#include namespace SGPP { namespace finance { -OperationHestonKLinear::OperationHestonKLinear(SGPP::base::GridStorage* storage, - float_t**** * coef) : SGPP::pde::UpDownFourOpDims(storage, coef) { -} +OperationHestonKLinear::OperationHestonKLinear(SGPP::base::GridStorage* storage, float_t***** coef) + : SGPP::pde::UpDownFourOpDims(storage, coef) {} -OperationHestonKLinear::~OperationHestonKLinear() { -} +OperationHestonKLinear::~OperationHestonKLinear() {} // Unidirectional -void OperationHestonKLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonKLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } -void OperationHestonKLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonKLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -54,7 +51,7 @@ void OperationHestonKLinear::down(SGPP::base::DataVector& alpha, // Singles void OperationHestonKLinear::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * dphi PhidPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -72,7 +69,7 @@ void OperationHestonKLinear::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonKLinear::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // sqrtX phi phi SqrtXPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -90,17 +87,16 @@ void OperationHestonKLinear::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonKLinear::downOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); - } void OperationHestonKLinear::upOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -109,7 +105,7 @@ void OperationHestonKLinear::upOpDimThree(SGPP::base::DataVector& alpha, } void OperationHestonKLinear::downOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // sqrtX phi phi SqrtXPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -118,7 +114,7 @@ void OperationHestonKLinear::downOpDimFour(SGPP::base::DataVector& alpha, } void OperationHestonKLinear::upOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // sqrtX phi phi SqrtXPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -127,55 +123,64 @@ void OperationHestonKLinear::upOpDimFour(SGPP::base::DataVector& alpha, } // Doubles -void OperationHestonKLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::downOpDimOneAndOpDimThree(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::upOpDimOneAndOpDimThree(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::downOpDimOneAndOpDimFour(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::upOpDimOneAndOpDimFour(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::downOpDimTwoAndOpDimThree(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::upOpDimTwoAndOpDimThree(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::downOpDimTwoAndOpDimFour(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::upOpDimTwoAndOpDimFour(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::downOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::upOpDimThreeAndOpDimFour(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) {} +void OperationHestonKLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +void OperationHestonKLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +void OperationHestonKLinear::downOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { +} +void OperationHestonKLinear::upOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +void OperationHestonKLinear::downOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +void OperationHestonKLinear::upOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +void OperationHestonKLinear::downOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { +} +void OperationHestonKLinear::upOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +void OperationHestonKLinear::downOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +void OperationHestonKLinear::upOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +void OperationHestonKLinear::downOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinear::upOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} // Triples -void OperationHestonKLinear::downOpDimOneAndOpDimTwoAndOpDimThree( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::upOpDimOneAndOpDimTwoAndOpDimThree( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::downOpDimOneAndOpDimTwoAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::upOpDimOneAndOpDimTwoAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::downOpDimOneAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::upOpDimOneAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::downOpDimTwoAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinear::upOpDimTwoAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} +void OperationHestonKLinear::downOpDimOneAndOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinear::upOpDimOneAndOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinear::downOpDimOneAndOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinear::upOpDimOneAndOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinear::downOpDimOneAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinear::upOpDimOneAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinear::downOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinear::upOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} // Quadruples void OperationHestonKLinear::downOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} void OperationHestonKLinear::upOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} - - -} -} \ No newline at end of file + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonKLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonKLinear.hpp index cf28f73894..c097487bab 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonKLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonKLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,7 +27,7 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonKLinear(SGPP::base::GridStorage* storage, float_t**** * coef); + OperationHestonKLinear(SGPP::base::GridStorage* storage, float_t***** coef); /** * Destructor @@ -36,7 +35,6 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { virtual ~OperationHestonKLinear(); protected: - /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. * Applies the up-part of the one-dimensional mass matrix in one dimension. @@ -46,8 +44,7 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -58,8 +55,7 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the phi dphi operation @@ -69,8 +65,7 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the phi dphi operation @@ -80,8 +75,7 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the sqrt phi phi operation @@ -91,8 +85,7 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the sqrt phi phi operation @@ -102,8 +95,7 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the phi dphi operation @@ -113,8 +105,7 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the phi dphi operation @@ -124,8 +115,7 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void upOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the sqrt phi phi operation @@ -135,8 +125,7 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the sqrt phi phi operation @@ -146,141 +135,154 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void upOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ void downOpDimOneAndOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation @@ -290,17 +292,19 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ void downOpDimOneAndOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation @@ -310,68 +314,72 @@ class OperationHestonKLinear : public SGPP::pde::UpDownFourOpDims { SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ void downOpDimOneAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ void upOpDimOneAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ void downOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ void upOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim); - + void upOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONKLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONKLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonKLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonKLinearBoundary.cpp index 6f625aac18..99e55b64ff 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonKLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonKLinearBoundary.cpp @@ -19,21 +19,18 @@ #include -#include - #include +#include namespace SGPP { namespace finance { -OperationHestonKLinearBoundary::OperationHestonKLinearBoundary( - SGPP::base::GridStorage* storage, - float_t**** * coef) : SGPP::pde::UpDownFourOpDims(storage, coef) { -} +OperationHestonKLinearBoundary::OperationHestonKLinearBoundary(SGPP::base::GridStorage* storage, + float_t***** coef) + : SGPP::pde::UpDownFourOpDims(storage, coef) {} -OperationHestonKLinearBoundary::~OperationHestonKLinearBoundary() { -} +OperationHestonKLinearBoundary::~OperationHestonKLinearBoundary() {} // Unidirectional void OperationHestonKLinearBoundary::up(SGPP::base::DataVector& alpha, @@ -45,7 +42,7 @@ void OperationHestonKLinearBoundary::up(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } void OperationHestonKLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -55,7 +52,7 @@ void OperationHestonKLinearBoundary::down(SGPP::base::DataVector& alpha, // Singles void OperationHestonKLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * dphi PhidPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -64,7 +61,7 @@ void OperationHestonKLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonKLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * dphi PhidPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -73,7 +70,7 @@ void OperationHestonKLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonKLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // sqrtX phi phi SqrtXPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -82,7 +79,7 @@ void OperationHestonKLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonKLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // sqrtX phi phi SqrtXPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -90,18 +87,17 @@ void OperationHestonKLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationHestonKLinearBoundary::downOpDimThree(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationHestonKLinearBoundary::downOpDimThree(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); - } void OperationHestonKLinearBoundary::upOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // dphi * phi DPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -109,8 +105,8 @@ void OperationHestonKLinearBoundary::upOpDimThree(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationHestonKLinearBoundary::downOpDimFour(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationHestonKLinearBoundary::downOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // sqrtX phi phi SqrtXPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -119,7 +115,7 @@ void OperationHestonKLinearBoundary::downOpDimFour(SGPP::base::DataVector& } void OperationHestonKLinearBoundary::upOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // sqrtX phi phi SqrtXPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -128,55 +124,65 @@ void OperationHestonKLinearBoundary::upOpDimFour(SGPP::base::DataVector& alpha, } // Doubles -void OperationHestonKLinearBoundary::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinearBoundary::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinearBoundary::downOpDimOneAndOpDimThree( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinearBoundary::upOpDimOneAndOpDimThree( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinearBoundary::downOpDimOneAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinearBoundary::upOpDimOneAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinearBoundary::downOpDimTwoAndOpDimThree( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinearBoundary::upOpDimTwoAndOpDimThree( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinearBoundary::downOpDimTwoAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinearBoundary::upOpDimTwoAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinearBoundary::downOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonKLinearBoundary::upOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} +void OperationHestonKLinearBoundary::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinearBoundary::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinearBoundary::downOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinearBoundary::upOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinearBoundary::downOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinearBoundary::upOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinearBoundary::downOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinearBoundary::upOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinearBoundary::downOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinearBoundary::upOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinearBoundary::downOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +void OperationHestonKLinearBoundary::upOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} // Triples void OperationHestonKLinearBoundary::downOpDimOneAndOpDimTwoAndOpDimThree( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} void OperationHestonKLinearBoundary::upOpDimOneAndOpDimTwoAndOpDimThree( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} void OperationHestonKLinearBoundary::downOpDimOneAndOpDimTwoAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} void OperationHestonKLinearBoundary::upOpDimOneAndOpDimTwoAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} void OperationHestonKLinearBoundary::downOpDimOneAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} void OperationHestonKLinearBoundary::upOpDimOneAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} void OperationHestonKLinearBoundary::downOpDimTwoAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} void OperationHestonKLinearBoundary::upOpDimTwoAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} // Quadruples void OperationHestonKLinearBoundary::downOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} void OperationHestonKLinearBoundary::upOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} - - -} -} \ No newline at end of file + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonKLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonKLinearBoundary.hpp index c841884796..a5a408b790 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonKLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonKLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonKLinearBoundary(SGPP::base::GridStorage* storage, - float_t**** * coef); + OperationHestonKLinearBoundary(SGPP::base::GridStorage* storage, float_t***** coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { virtual ~OperationHestonKLinearBoundary(); protected: - /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. * Applies the up-part of the one-dimensional mass matrix in one dimension. @@ -47,8 +44,7 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +55,7 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the phi dphi operation @@ -70,8 +65,7 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the phi dphi operation @@ -81,8 +75,7 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the sqrt phi phi operation @@ -92,8 +85,7 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the sqrt phi phi operation @@ -103,8 +95,7 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the phi dphi operation @@ -114,8 +105,7 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the phi dphi operation @@ -125,8 +115,7 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void upOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the sqrt phi phi operation @@ -136,8 +125,7 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the sqrt phi phi operation @@ -147,141 +135,154 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void upOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ void downOpDimOneAndOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation @@ -291,17 +292,19 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ void downOpDimOneAndOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation @@ -311,68 +314,72 @@ class OperationHestonKLinearBoundary : public SGPP::pde::UpDownFourOpDims { SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ void downOpDimOneAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ void upOpDimOneAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ void downOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ void upOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void upOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim); - + void upOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONKLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONKLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonWLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonWLinear.cpp index 36e6302ecc..a8bc239115 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonWLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonWLinear.cpp @@ -16,33 +16,30 @@ #include -#include - #include +#include namespace SGPP { namespace finance { OperationHestonWLinear::OperationHestonWLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationHestonWLinear::~OperationHestonWLinear() { -} +OperationHestonWLinear::~OperationHestonWLinear() {} -void OperationHestonWLinear::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +void OperationHestonWLinear::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { - // no symmetry in the operator - #pragma omp task firstprivate(i, j) shared(alpha, result) +// no symmetry in the operator +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -50,30 +47,26 @@ void OperationHestonWLinear::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } -void OperationHestonWLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonWLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -81,8 +74,8 @@ void OperationHestonWLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonWLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonWLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -100,7 +93,7 @@ void OperationHestonWLinear::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonWLinear::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // X * phi * dphi XPhidPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -118,7 +111,7 @@ void OperationHestonWLinear::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonWLinear::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // X * dphi * phi XdPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -126,13 +119,10 @@ void OperationHestonWLinear::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonWLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { -} +void OperationHestonWLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonWLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationHestonWLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonWLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonWLinear.hpp index 60abbf2786..51f748ffcf 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonWLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonWLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonWLinear : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonWLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationHestonWLinear(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonWLinear : public SGPP::pde::UpDownTwoOpDims { virtual ~OperationHestonWLinear(); protected: - void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** @@ -49,8 +46,7 @@ class OperationHestonWLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationHestonWLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x phi dphi operation @@ -72,8 +67,8 @@ class OperationHestonWLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi dphi operation @@ -83,8 +78,8 @@ class OperationHestonWLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -94,8 +89,8 @@ class OperationHestonWLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -105,31 +100,32 @@ class OperationHestonWLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONWLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONWLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonWLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonWLinearBoundary.cpp index 75447841c7..454376e669 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonWLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonWLinearBoundary.cpp @@ -16,34 +16,31 @@ #include -#include - #include +#include namespace SGPP { namespace finance { -OperationHestonWLinearBoundary::OperationHestonWLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} +OperationHestonWLinearBoundary::OperationHestonWLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationHestonWLinearBoundary::~OperationHestonWLinearBoundary() { -} +OperationHestonWLinearBoundary::~OperationHestonWLinearBoundary() {} void OperationHestonWLinearBoundary::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { + SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { - // no symmetry in the operator - #pragma omp task firstprivate(i, j) shared(alpha, result) +// no symmetry in the operator +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -51,24 +48,20 @@ void OperationHestonWLinearBoundary::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } @@ -83,7 +76,7 @@ void OperationHestonWLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationHestonWLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -92,7 +85,7 @@ void OperationHestonWLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationHestonWLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // X * phi * dphi XPhidPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -101,7 +94,7 @@ void OperationHestonWLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonWLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // X * phi * dphi XPhidPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -110,7 +103,7 @@ void OperationHestonWLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonWLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // X * dphi * phi XdPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -119,7 +112,7 @@ void OperationHestonWLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonWLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // X * dphi * phi XdPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -127,13 +120,12 @@ void OperationHestonWLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationHestonWLinearBoundary::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { -} +void OperationHestonWLinearBoundary::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} -void OperationHestonWLinearBoundary::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationHestonWLinearBoundary::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonWLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonWLinearBoundary.hpp index e842f9f969..6384362010 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonWLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonWLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonWLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonWLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationHestonWLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonWLinearBoundary : public SGPP::pde::UpDownTwoOpDims { virtual ~OperationHestonWLinearBoundary(); protected: - void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** @@ -49,8 +46,7 @@ class OperationHestonWLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationHestonWLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x phi dphi operation @@ -72,8 +67,8 @@ class OperationHestonWLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi dphi operation @@ -83,8 +78,8 @@ class OperationHestonWLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -94,8 +89,8 @@ class OperationHestonWLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -105,31 +100,32 @@ class OperationHestonWLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONWLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONWLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonXLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonXLinear.cpp index c238fd3cd9..950c00f68c 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonXLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonXLinear.cpp @@ -16,33 +16,30 @@ #include -#include - #include +#include namespace SGPP { namespace finance { OperationHestonXLinear::OperationHestonXLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationHestonXLinear::~OperationHestonXLinear() { -} +OperationHestonXLinear::~OperationHestonXLinear() {} -void OperationHestonXLinear::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +void OperationHestonXLinear::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { - // no symmetry in the operator - #pragma omp task firstprivate(i, j) shared(alpha, result) +// no symmetry in the operator +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -50,30 +47,26 @@ void OperationHestonXLinear::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } -void OperationHestonXLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonXLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -81,8 +74,8 @@ void OperationHestonXLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonXLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonXLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -100,7 +93,7 @@ void OperationHestonXLinear::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonXLinear::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi SGPP::finance::XdPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -118,7 +111,7 @@ void OperationHestonXLinear::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonXLinear::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * phi XPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -126,13 +119,10 @@ void OperationHestonXLinear::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonXLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { -} +void OperationHestonXLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonXLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationHestonXLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonXLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonXLinear.hpp index e64702c93c..0bb1eac5fa 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonXLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonXLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonXLinear : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonXLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationHestonXLinear(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonXLinear : public SGPP::pde::UpDownTwoOpDims { virtual ~OperationHestonXLinear(); protected: - void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** @@ -49,8 +46,7 @@ class OperationHestonXLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationHestonXLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -72,8 +67,8 @@ class OperationHestonXLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -83,8 +78,8 @@ class OperationHestonXLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x phi phi operation @@ -94,8 +89,8 @@ class OperationHestonXLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi phi operation @@ -105,31 +100,32 @@ class OperationHestonXLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONXLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONXLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonXLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonXLinearBoundary.cpp index bc5ebf3982..a8274947df 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonXLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonXLinearBoundary.cpp @@ -16,34 +16,31 @@ #include -#include - #include +#include namespace SGPP { namespace finance { -OperationHestonXLinearBoundary::OperationHestonXLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} +OperationHestonXLinearBoundary::OperationHestonXLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationHestonXLinearBoundary::~OperationHestonXLinearBoundary() { -} +OperationHestonXLinearBoundary::~OperationHestonXLinearBoundary() {} void OperationHestonXLinearBoundary::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { + SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { - // no symmetry in the operator - #pragma omp task firstprivate(i, j) shared(alpha, result) +// no symmetry in the operator +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -51,24 +48,20 @@ void OperationHestonXLinearBoundary::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } @@ -83,7 +76,7 @@ void OperationHestonXLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationHestonXLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -92,7 +85,7 @@ void OperationHestonXLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationHestonXLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -101,17 +94,16 @@ void OperationHestonXLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonXLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi SGPP::finance::XdPhiPhiDownBBLinearBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } void OperationHestonXLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * phi XPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -120,7 +112,7 @@ void OperationHestonXLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonXLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * phi XPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -128,13 +120,12 @@ void OperationHestonXLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationHestonXLinearBoundary::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { -} +void OperationHestonXLinearBoundary::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} -void OperationHestonXLinearBoundary::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationHestonXLinearBoundary::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonXLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonXLinearBoundary.hpp index 91efc5455b..8d4c4afa9b 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonXLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonXLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonXLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonXLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationHestonXLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonXLinearBoundary : public SGPP::pde::UpDownTwoOpDims { virtual ~OperationHestonXLinearBoundary(); protected: - void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** @@ -49,8 +46,7 @@ class OperationHestonXLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationHestonXLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the x dphi phi operation @@ -72,8 +67,8 @@ class OperationHestonXLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x dphi phi operation @@ -83,8 +78,8 @@ class OperationHestonXLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x phi phi operation @@ -94,8 +89,8 @@ class OperationHestonXLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi phi operation @@ -105,31 +100,32 @@ class OperationHestonXLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONXLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONXLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonYLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonYLinear.cpp index 47d24b92f7..1f5fbf31ad 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonYLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonYLinear.cpp @@ -14,36 +14,32 @@ #include #include - #include -#include - #include +#include namespace SGPP { namespace finance { OperationHestonYLinear::OperationHestonYLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationHestonYLinear::~OperationHestonYLinear() { -} +OperationHestonYLinear::~OperationHestonYLinear() {} -void OperationHestonYLinear::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +void OperationHestonYLinear::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { - // no symmetry in the operator - #pragma omp task firstprivate(i, j) shared(alpha, result) +// no symmetry in the operator +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -51,30 +47,26 @@ void OperationHestonYLinear::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } -void OperationHestonYLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonYLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -82,8 +74,8 @@ void OperationHestonYLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonYLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonYLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -101,11 +93,10 @@ void OperationHestonYLinear::upOpDimOne(SGPP::base::DataVector& alpha, } void OperationHestonYLinear::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x^2 * dphi * dphi SGPP::finance::SqXdPhidPhiDownBBLinear func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } @@ -120,7 +111,7 @@ void OperationHestonYLinear::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonYLinear::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * phi XPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -128,13 +119,10 @@ void OperationHestonYLinear::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonYLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { -} +void OperationHestonYLinear::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} -void OperationHestonYLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationHestonYLinear::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonYLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonYLinear.hpp index d7b3916344..344045f171 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonYLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonYLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonYLinear : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonYLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationHestonYLinear(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonYLinear : public SGPP::pde::UpDownTwoOpDims { virtual ~OperationHestonYLinear(); protected: - void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** @@ -49,8 +46,7 @@ class OperationHestonYLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationHestonYLinear : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the sqX dphi dphi operation @@ -72,8 +67,8 @@ class OperationHestonYLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the sqX dphi dphi operation @@ -83,8 +78,8 @@ class OperationHestonYLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x phi phi operation @@ -94,8 +89,8 @@ class OperationHestonYLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi phi operation @@ -105,31 +100,32 @@ class OperationHestonYLinear : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONYLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONYLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonYLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonYLinearBoundary.cpp index 1cbf9dc4af..7d6acd01eb 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonYLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonYLinearBoundary.cpp @@ -14,37 +14,33 @@ #include #include - #include -#include - #include +#include namespace SGPP { namespace finance { -OperationHestonYLinearBoundary::OperationHestonYLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : SGPP::pde::UpDownTwoOpDims(storage, coef) { -} +OperationHestonYLinearBoundary::OperationHestonYLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataMatrix& coef) + : SGPP::pde::UpDownTwoOpDims(storage, coef) {} -OperationHestonYLinearBoundary::~OperationHestonYLinearBoundary() { -} +OperationHestonYLinearBoundary::~OperationHestonYLinearBoundary() {} void OperationHestonYLinearBoundary::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { + SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { - // no symmetry in the operator - #pragma omp task firstprivate(i, j) shared(alpha, result) +// no symmetry in the operator +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -52,24 +48,20 @@ void OperationHestonYLinearBoundary::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } @@ -84,7 +76,7 @@ void OperationHestonYLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationHestonYLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -93,27 +85,25 @@ void OperationHestonYLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationHestonYLinearBoundary::upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x^2 * dphi * dphi SGPP::finance::SqXdPhidPhiUpBBLinearBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } void OperationHestonYLinearBoundary::downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x^2 * dphi * dphi SGPP::finance::SqXdPhidPhiDownBBLinearBoundary func(this->storage); - SGPP::base::sweep s(func, - this->storage); + SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } void OperationHestonYLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * phi XPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -122,7 +112,7 @@ void OperationHestonYLinearBoundary::upOpDimTwo(SGPP::base::DataVector& alpha, } void OperationHestonYLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * phi * phi XPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -130,13 +120,12 @@ void OperationHestonYLinearBoundary::downOpDimTwo(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationHestonYLinearBoundary::upOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { -} +void OperationHestonYLinearBoundary::upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} -void OperationHestonYLinearBoundary::downOpDimOneAndOpDimTwo( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationHestonYLinearBoundary::downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) {} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonYLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonYLinearBoundary.hpp index 9a82f62f31..e5f277793d 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonYLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonYLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -28,8 +27,7 @@ class OperationHestonYLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param storage the grid's SGPP::base::GridStorage object * @param coef vector that contains the constant coefficients of this operation */ - OperationHestonYLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef); + OperationHestonYLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef); /** * Destructor @@ -37,7 +35,6 @@ class OperationHestonYLinearBoundary : public SGPP::pde::UpDownTwoOpDims { virtual ~OperationHestonYLinearBoundary(); protected: - void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** @@ -49,8 +46,7 @@ class OperationHestonYLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -61,8 +57,7 @@ class OperationHestonYLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the sqX dphi dphi operation @@ -72,8 +67,8 @@ class OperationHestonYLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the sqX dphi dphi operation @@ -83,8 +78,8 @@ class OperationHestonYLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * down-Gradient step in dimension dim applies the x phi phi operation @@ -94,8 +89,8 @@ class OperationHestonYLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** * up-Gradient step in dimension dim applies the x phi phi operation @@ -105,31 +100,32 @@ class OperationHestonYLinearBoundary : public SGPP::pde::UpDownTwoOpDims { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); /** - * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make the class concrete. + * This method does nothing (this situation doesn't come up in Heston's PDEs). Needed only to make + * the class concrete. * * @param alpha the coefficients of the gridpoints * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONYLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONYLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonZLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonZLinear.cpp index 9ba30a751e..b0b1818f6b 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonZLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonZLinear.cpp @@ -11,26 +11,21 @@ #include #include -#include -#include - #include #include - namespace SGPP { namespace finance { OperationHestonZLinear::OperationHestonZLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationHestonZLinear::~OperationHestonZLinear() { -} +OperationHestonZLinear::~OperationHestonZLinear() {} -void OperationHestonZLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonZLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -38,8 +33,8 @@ void OperationHestonZLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonZLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonZLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -47,8 +42,8 @@ void OperationHestonZLinear::down(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationHestonZLinear::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationHestonZLinear::upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -64,6 +59,5 @@ void OperationHestonZLinear::downOpDim(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } - -} -} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonZLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonZLinear.hpp index bce4ada92b..b2c8aa5853 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonZLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonZLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -26,10 +25,10 @@ class OperationHestonZLinear : public SGPP::pde::UpDownOneOpDim { * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationHestonZLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationHestonZLinear(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -37,7 +36,6 @@ class OperationHestonZLinear : public SGPP::pde::UpDownOneOpDim { virtual ~OperationHestonZLinear(); protected: - /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. * Applies the up-part of the one-dimensional mass matrix in one dimension. @@ -47,8 +45,7 @@ class OperationHestonZLinear : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +56,7 @@ class OperationHestonZLinear : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the X dphi phi operation @@ -70,8 +66,7 @@ class OperationHestonZLinear : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the X dphi phi operation @@ -81,11 +76,9 @@ class OperationHestonZLinear : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONZLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONZLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonZLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationHestonZLinearBoundary.cpp index 16fd7fac07..2cd7a0f312 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonZLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonZLinearBoundary.cpp @@ -11,24 +11,18 @@ #include #include -#include -#include - #include #include - namespace SGPP { namespace finance { -OperationHestonZLinearBoundary::OperationHestonZLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : SGPP::pde::UpDownOneOpDim(storage, coef) { -} +OperationHestonZLinearBoundary::OperationHestonZLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataVector& coef) + : SGPP::pde::UpDownOneOpDim(storage, coef) {} -OperationHestonZLinearBoundary::~OperationHestonZLinearBoundary() { -} +OperationHestonZLinearBoundary::~OperationHestonZLinearBoundary() {} void OperationHestonZLinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { @@ -40,7 +34,7 @@ void OperationHestonZLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationHestonZLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi SGPP::pde::PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -49,7 +43,7 @@ void OperationHestonZLinearBoundary::down(SGPP::base::DataVector& alpha, } void OperationHestonZLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -58,13 +52,12 @@ void OperationHestonZLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, } void OperationHestonZLinearBoundary::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // x * dphi * phi XdPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationHestonZLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationHestonZLinearBoundary.hpp index 4eba2caa45..bfc146b590 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationHestonZLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationHestonZLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -26,10 +25,10 @@ class OperationHestonZLinearBoundary : public SGPP::pde::UpDownOneOpDim { * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients */ - OperationHestonZLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationHestonZLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -37,7 +36,6 @@ class OperationHestonZLinearBoundary : public SGPP::pde::UpDownOneOpDim { virtual ~OperationHestonZLinearBoundary(); protected: - /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. * Applies the up-part of the one-dimensional mass matrix in one dimension. @@ -47,8 +45,7 @@ class OperationHestonZLinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -59,8 +56,7 @@ class OperationHestonZLinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * down-Gradient step in dimension dim applies the X dphi phi operation @@ -70,8 +66,7 @@ class OperationHestonZLinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * up-Gradient step in dimension dim applies the X dphi phi operation @@ -81,11 +76,9 @@ class OperationHestonZLinearBoundary : public SGPP::pde::UpDownOneOpDim { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONHESTONZLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONHESTONZLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationLBLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationLBLinear.cpp index f554d69e05..156b8d4bbe 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLBLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLBLinear.cpp @@ -12,19 +12,16 @@ #include - namespace SGPP { namespace finance { -OperationLBLinear::OperationLBLinear(SGPP::base::GridStorage* storage) : - SGPP::pde::StdUpDown(storage) { -} +OperationLBLinear::OperationLBLinear(SGPP::base::GridStorage* storage) + : SGPP::pde::StdUpDown(storage) {} -OperationLBLinear::~OperationLBLinear() { -} +OperationLBLinear::~OperationLBLinear() {} -void OperationLBLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLBLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // Dphi * phi DPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -32,14 +29,13 @@ void OperationLBLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationLBLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLBLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // Dphi * phi DPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationLBLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationLBLinear.hpp index dedde91190..8f89e6bf86 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLBLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLBLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -18,14 +17,14 @@ namespace finance { * Implements the standard \f$(\phi_i(x),d\phi_j(x))\f$ operator on linear grids (no boundaries) * */ -class OperationLBLinear: public SGPP::pde::StdUpDown { +class OperationLBLinear : public SGPP::pde::StdUpDown { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLBLinear(SGPP::base::GridStorage* storage); + explicit OperationLBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,8 +41,7 @@ class OperationLBLinear: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),d\phi_j(x))\f$. @@ -54,11 +52,9 @@ class OperationLBLinear: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONLBLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONLBLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationLBLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationLBLinearBoundary.cpp index 9e6365bd14..ca6ab270b5 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLBLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLBLinearBoundary.cpp @@ -12,19 +12,16 @@ #include - namespace SGPP { namespace finance { -OperationLBLinearBoundary::OperationLBLinearBoundary(SGPP::base::GridStorage* - storage) : SGPP::pde::StdUpDown(storage) { -} +OperationLBLinearBoundary::OperationLBLinearBoundary(SGPP::base::GridStorage* storage) + : SGPP::pde::StdUpDown(storage) {} -OperationLBLinearBoundary::~OperationLBLinearBoundary() { -} +OperationLBLinearBoundary::~OperationLBLinearBoundary() {} -void OperationLBLinearBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLBLinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // Dphi * phi DPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -32,14 +29,13 @@ void OperationLBLinearBoundary::up(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationLBLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLBLinearBoundary::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // Dphi * phi DPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationLBLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationLBLinearBoundary.hpp index 310ba43b8f..a6b77baf60 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLBLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLBLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -18,14 +17,14 @@ namespace finance { * Implements the standard \f$(\phi_i(x),d\phi_j(x))\f$ operator on linear boundary grids * */ -class OperationLBLinearBoundary: public SGPP::pde::StdUpDown { +class OperationLBLinearBoundary : public SGPP::pde::StdUpDown { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLBLinearBoundary(SGPP::base::GridStorage* storage); + explicit OperationLBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,8 +41,7 @@ class OperationLBLinearBoundary: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),d\phi_j(x))\f$. @@ -54,11 +52,9 @@ class OperationLBLinearBoundary: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONLBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONLBLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationLDLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationLDLinear.cpp index 1f391c3552..5051e39b29 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLDLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLDLinear.cpp @@ -12,19 +12,16 @@ #include - namespace SGPP { namespace finance { -OperationLDLinear::OperationLDLinear(SGPP::base::GridStorage* storage) : - SGPP::pde::StdUpDown(storage) { -} +OperationLDLinear::OperationLDLinear(SGPP::base::GridStorage* storage) + : SGPP::pde::StdUpDown(storage) {} -OperationLDLinear::~OperationLDLinear() { -} +OperationLDLinear::~OperationLDLinear() {} -void OperationLDLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLDLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // X * phi * phi XPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -32,14 +29,13 @@ void OperationLDLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationLDLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLDLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // X * phi * phi XPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationLDLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationLDLinear.hpp index 6712f11757..251bff8e2c 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLDLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLDLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -18,14 +17,14 @@ namespace finance { *Implements the \f$(x \phi_i(x),\phi_j(x))\f$ operator on linear grids (no boundaries) * */ -class OperationLDLinear: public SGPP::pde::StdUpDown { +class OperationLDLinear : public SGPP::pde::StdUpDown { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLDLinear(SGPP::base::GridStorage* storage); + explicit OperationLDLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,8 +41,7 @@ class OperationLDLinear: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(x \phi_i(x),\phi_j(x))\f$. @@ -54,11 +52,9 @@ class OperationLDLinear: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONLDLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONLDLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationLDLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationLDLinearBoundary.cpp index 5d3cd2cafa..a89cfe2149 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLDLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLDLinearBoundary.cpp @@ -12,19 +12,16 @@ #include - namespace SGPP { namespace finance { -OperationLDLinearBoundary::OperationLDLinearBoundary(SGPP::base::GridStorage* - storage) : SGPP::pde::StdUpDown(storage) { -} +OperationLDLinearBoundary::OperationLDLinearBoundary(SGPP::base::GridStorage* storage) + : SGPP::pde::StdUpDown(storage) {} -OperationLDLinearBoundary::~OperationLDLinearBoundary() { -} +OperationLDLinearBoundary::~OperationLDLinearBoundary() {} -void OperationLDLinearBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLDLinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // X * phi * phi XPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -32,14 +29,13 @@ void OperationLDLinearBoundary::up(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationLDLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLDLinearBoundary::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // X * phi * phi XPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationLDLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationLDLinearBoundary.hpp index 127d6050fa..63c46a078d 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLDLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLDLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -18,14 +17,14 @@ namespace finance { * Implements the \f$(x \phi_i(x),\phi_j(x))\f$ operator on linear boundary grids * */ -class OperationLDLinearBoundary: public SGPP::pde::StdUpDown { +class OperationLDLinearBoundary : public SGPP::pde::StdUpDown { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLDLinearBoundary(SGPP::base::GridStorage* storage); + explicit OperationLDLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,8 +41,7 @@ class OperationLDLinearBoundary: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(x \phi_i(x),\phi_j(x))\f$. @@ -54,11 +52,9 @@ class OperationLDLinearBoundary: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONLDLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONLDLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationLELinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationLELinear.cpp index 01868af386..01ed4f6a34 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLELinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLELinear.cpp @@ -5,35 +5,29 @@ #include -//#include -//#include +// #include +// #include #include #include #include - namespace SGPP { namespace finance { -OperationLELinear::OperationLELinear(SGPP::base::GridStorage* storage) : - SGPP::pde::StdUpDown(storage) { -} +OperationLELinear::OperationLELinear(SGPP::base::GridStorage* storage) + : SGPP::pde::StdUpDown(storage) {} -OperationLELinear::~OperationLELinear() { -} +OperationLELinear::~OperationLELinear() {} -void OperationLELinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLELinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) {} -} - -void OperationLELinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLELinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // Dphi * dphi SGPP::pde::DowndPhidPhiBBIterativeLinear myDown(this->storage); myDown(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationLELinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationLELinear.hpp index 7649e523db..2fa92ed93d 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLELinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLELinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -18,14 +17,14 @@ namespace finance { * Implements the \f$(d\phi_i(x),d\phi_j(x))\f$ operator on linear grids (no boundaries) * */ -class OperationLELinear: public SGPP::pde::StdUpDown { +class OperationLELinear : public SGPP::pde::StdUpDown { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLELinear(SGPP::base::GridStorage* storage); + explicit OperationLELinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,8 +41,7 @@ class OperationLELinear: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(d\phi_i(x),d\phi_j(x))\f$. @@ -54,11 +52,9 @@ class OperationLELinear: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONLELINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONLELINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationLELinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationLELinearBoundary.cpp index 73baf3c9eb..3f2a9f9973 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLELinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLELinearBoundary.cpp @@ -5,37 +5,31 @@ #include - #include #include - #include - namespace SGPP { namespace finance { -OperationLELinearBoundary::OperationLELinearBoundary(SGPP::base::GridStorage* - storage) : SGPP::pde::StdUpDown(storage) { -} +OperationLELinearBoundary::OperationLELinearBoundary(SGPP::base::GridStorage* storage) + : SGPP::pde::StdUpDown(storage) {} -OperationLELinearBoundary::~OperationLELinearBoundary() { -} +OperationLELinearBoundary::~OperationLELinearBoundary() {} -void OperationLELinearBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLELinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // Dphi * dphi SGPP::pde::UpdPhidPhiBBIterativeLinearBoundary myUp(this->storage); myUp(alpha, result, dim); } -void OperationLELinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLELinearBoundary::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // Dphi * dphi SGPP::pde::DowndPhidPhiBBIterativeLinearBoundary myDown(this->storage); myDown(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationLELinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationLELinearBoundary.hpp index b63a7e9303..a093af5ded 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLELinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLELinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -18,14 +17,14 @@ namespace finance { * Implements the \f$(d\phi_i(x),d\phi_j(x))\f$ operator on linear boundary grids * */ -class OperationLELinearBoundary: public SGPP::pde::StdUpDown { +class OperationLELinearBoundary : public SGPP::pde::StdUpDown { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLELinearBoundary(SGPP::base::GridStorage* storage); + explicit OperationLELinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,8 +41,7 @@ class OperationLELinearBoundary: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(d\phi_i(x),d\phi_j(x))\f$. @@ -54,11 +52,9 @@ class OperationLELinearBoundary: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONLELINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONLELINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationLFLinear.cpp b/finance/src/sgpp/finance/operation/hash/OperationLFLinear.cpp index c99a8b7ece..de4fe0967a 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLFLinear.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLFLinear.cpp @@ -12,19 +12,16 @@ #include - namespace SGPP { namespace finance { -OperationLFLinear::OperationLFLinear(SGPP::base::GridStorage* storage) : - SGPP::pde::StdUpDown(storage) { -} +OperationLFLinear::OperationLFLinear(SGPP::base::GridStorage* storage) + : SGPP::pde::StdUpDown(storage) {} -OperationLFLinear::~OperationLFLinear() { -} +OperationLFLinear::~OperationLFLinear() {} -void OperationLFLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLFLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // X * dphi * phi XdPhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -32,14 +29,13 @@ void OperationLFLinear::up(SGPP::base::DataVector& alpha, s.sweep1D(alpha, result, dim); } -void OperationLFLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLFLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // X * dphi * phi XdPhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationLFLinear.hpp b/finance/src/sgpp/finance/operation/hash/OperationLFLinear.hpp index 9b355f27d8..4031853242 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLFLinear.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLFLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -18,14 +17,14 @@ namespace finance { * Implements the \f$(x\phi_i(x),d\phi_j(x))\f$ operator on linear grids (no boundaries) * */ -class OperationLFLinear: public SGPP::pde::StdUpDown { +class OperationLFLinear : public SGPP::pde::StdUpDown { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLFLinear(SGPP::base::GridStorage* storage); + explicit OperationLFLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,8 +41,7 @@ class OperationLFLinear: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(x\phi_i(x),d\phi_j(x))\f$. @@ -54,11 +52,9 @@ class OperationLFLinear: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONLFLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONLFLINEAR_HPP */ diff --git a/finance/src/sgpp/finance/operation/hash/OperationLFLinearBoundary.cpp b/finance/src/sgpp/finance/operation/hash/OperationLFLinearBoundary.cpp index bd29c416b9..d89795c569 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLFLinearBoundary.cpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLFLinearBoundary.cpp @@ -12,19 +12,16 @@ #include - namespace SGPP { namespace finance { -OperationLFLinearBoundary::OperationLFLinearBoundary(SGPP::base::GridStorage* - storage) : SGPP::pde::StdUpDown(storage) { -} +OperationLFLinearBoundary::OperationLFLinearBoundary(SGPP::base::GridStorage* storage) + : SGPP::pde::StdUpDown(storage) {} -OperationLFLinearBoundary::~OperationLFLinearBoundary() { -} +OperationLFLinearBoundary::~OperationLFLinearBoundary() {} -void OperationLFLinearBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLFLinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // X * dphi * phi XdPhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -32,14 +29,13 @@ void OperationLFLinearBoundary::up(SGPP::base::DataVector& alpha, s.sweep1D_Boundary(alpha, result, dim); } -void OperationLFLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLFLinearBoundary::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { // X * dphi * phi XdPhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/operation/hash/OperationLFLinearBoundary.hpp b/finance/src/sgpp/finance/operation/hash/OperationLFLinearBoundary.hpp index 7cad965c1d..029c2b4f74 100644 --- a/finance/src/sgpp/finance/operation/hash/OperationLFLinearBoundary.hpp +++ b/finance/src/sgpp/finance/operation/hash/OperationLFLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace finance { @@ -18,14 +17,14 @@ namespace finance { * Implements the \f$(x\phi_i(x),d\phi_j(x))\f$ operator on linear boundary grids * */ -class OperationLFLinearBoundary: public SGPP::pde::StdUpDown { +class OperationLFLinearBoundary : public SGPP::pde::StdUpDown { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLFLinearBoundary(SGPP::base::GridStorage* storage); + explicit OperationLFLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,8 +41,7 @@ class OperationLFLinearBoundary: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(x\phi_i(x),d\phi_j(x))\f$. @@ -54,11 +52,9 @@ class OperationLFLinearBoundary: public SGPP::pde::StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* OPERATIONLFLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONLFLINEARBOUNDARY_HPP */ diff --git a/finance/src/sgpp/finance/tools/Hedging.cpp b/finance/src/sgpp/finance/tools/Hedging.cpp index 20f16906c9..d085820866 100644 --- a/finance/src/sgpp/finance/tools/Hedging.cpp +++ b/finance/src/sgpp/finance/tools/Hedging.cpp @@ -10,39 +10,38 @@ #include #include -#include -#include - #include +#include +#include +#include namespace SGPP { namespace finance { -Hedging::Hedging(SGPP::base::BoundingBox& hedge_area, size_t resolution, - float_t eps, bool is_log_transformed) : - m_res(resolution), m_eps(eps), m_hedge_points(new SGPP::base::DataMatrix(1, - hedge_area.getDimensions())), m_is_log_transformed(is_log_transformed) { +Hedging::Hedging(SGPP::base::BoundingBox& hedge_area, size_t resolution, float_t eps, + bool is_log_transformed) + : m_res(resolution), + m_eps(eps), + m_hedge_points(new SGPP::base::DataMatrix(1, hedge_area.getDimensions())), + m_is_log_transformed(is_log_transformed) { SGPP::base::EvalCuboidGenerator* myEval = new SGPP::base::EvalCuboidGenerator(); myEval->getEvaluationCuboid(*m_hedge_points, hedge_area, resolution); delete myEval; } -Hedging::~Hedging() { - delete m_hedge_points; -} +Hedging::~Hedging() { delete m_hedge_points; } -void Hedging::calc_hedging(SGPP::base::Grid& sparse_grid, - SGPP::base::DataVector alpha, std::string file_extension) { +void Hedging::calc_hedging(SGPP::base::Grid& sparse_grid, SGPP::base::DataVector alpha, + std::string file_extension) { std::stringstream sfilename; sfilename << "hedging_" << file_extension << ".out"; std::ofstream fileout; fileout.open(sfilename.str().c_str()); - SGPP::base::OperationEval* myEval = SGPP::op_factory::createOperationEval( - sparse_grid); + SGPP::base::OperationEval* myEval = SGPP::op_factory::createOperationEval(sparse_grid); // loop overall evaluation points for (size_t i = 0; i < m_hedge_points->getNrows(); i++) { @@ -52,7 +51,6 @@ void Hedging::calc_hedging(SGPP::base::Grid& sparse_grid, m_hedge_points->getRow(i, curPoint); - // print coordinates into file for (size_t j = 0; j < m_hedge_points->getNcols(); j++) { fileout << curPoint.get(j) << " "; @@ -84,10 +82,11 @@ void Hedging::calc_hedging(SGPP::base::Grid& sparse_grid, right.set(j, (right.get(j) + m_eps)); } - float_t tmp_delta = ((myEval->eval(alpha, right) - myEval->eval(alpha, - left)) / (2.0 * m_eps)); - float_t tmp_gamma = ((myEval->eval(alpha, - right) - (2.0 * value) + myEval->eval(alpha, left)) / (m_eps * m_eps)); + float_t tmp_delta = + ((myEval->eval(alpha, right) - myEval->eval(alpha, left)) / (2.0 * m_eps)); + float_t tmp_gamma = + ((myEval->eval(alpha, right) - (2.0 * value) + myEval->eval(alpha, left)) / + (m_eps * m_eps)); fileout << tmp_delta << " " << tmp_gamma << " "; @@ -105,7 +104,5 @@ void Hedging::calc_hedging(SGPP::base::Grid& sparse_grid, delete myEval; fileout.close(); } - -} - -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/tools/Hedging.hpp b/finance/src/sgpp/finance/tools/Hedging.hpp index 406d63715f..64dc83bd4a 100644 --- a/finance/src/sgpp/finance/tools/Hedging.hpp +++ b/finance/src/sgpp/finance/tools/Hedging.hpp @@ -10,10 +10,9 @@ #include #include -#include - #include +#include namespace SGPP { @@ -42,7 +41,8 @@ class Hedging { /** * Constructor * - * @param hedge_area BoundingBox that describes the full-grid area for which the delta and gamma should be calculated. They must be in Cartesian coordinates! + * @param hedge_area BoundingBox that describes the full-grid area for which the delta and gamma + * should be calculated. They must be in Cartesian coordinates! * @param resolution number of grid points in every dimension * @param eps epsilon used for calculating finite differences * @param is_log_transformed set to true if hedging is used with log-transformed grids @@ -61,14 +61,13 @@ class Hedging { * * @param sparse_grid the sparse grid * @param alpha the sparse grid's coefficients - * @param file_extension some file extension (e.g. numbering) in order to distinguish different outputs that are written + * @param file_extension some file extension (e.g. numbering) in order to distinguish different + * outputs that are written */ void calc_hedging(SGPP::base::Grid& sparse_grid, SGPP::base::DataVector alpha, std::string file_extension); }; +} // namespace finance +} // namespace SGPP -} - -} - -#endif /* HEDGING_HPP */ \ No newline at end of file +#endif /* HEDGING_HPP */ diff --git a/finance/src/sgpp/finance/tools/VariableDiscountFactor.cpp b/finance/src/sgpp/finance/tools/VariableDiscountFactor.cpp index 6d35db6928..becb495b0f 100644 --- a/finance/src/sgpp/finance/tools/VariableDiscountFactor.cpp +++ b/finance/src/sgpp/finance/tools/VariableDiscountFactor.cpp @@ -7,20 +7,17 @@ #include +#include namespace SGPP { namespace finance { -VariableDiscountFactor::VariableDiscountFactor(SGPP::base::GridStorage* storage, - int dim_r): myBoundingBox(storage->getBoundingBox()), storage(storage), - dim_r(dim_r) { -} +VariableDiscountFactor::VariableDiscountFactor(SGPP::base::GridStorage* storage, int dim_r) + : myBoundingBox(storage->getBoundingBox()), storage(storage), dim_r(dim_r) {} -VariableDiscountFactor::~VariableDiscountFactor() { -} +VariableDiscountFactor::~VariableDiscountFactor() {} -void VariableDiscountFactor::getDiscountFactor(SGPP::base::DataVector& factor, - float_t T) { +void VariableDiscountFactor::getDiscountFactor(SGPP::base::DataVector& factor, float_t T) { float_t tmp; for (size_t i = 0; i < storage->size(); i++) { @@ -33,11 +30,10 @@ void VariableDiscountFactor::getDiscountFactor(SGPP::base::DataVector& factor, dblFuncValues[j] = tmp; } - //std::cout<dim_r]*T)); + // std::cout<dim_r] * T)); } } - -} -} \ No newline at end of file +} // namespace finance +} // namespace SGPP diff --git a/finance/src/sgpp/finance/tools/VariableDiscountFactor.hpp b/finance/src/sgpp/finance/tools/VariableDiscountFactor.hpp index f2dcb88b58..2e225e1ec5 100644 --- a/finance/src/sgpp/finance/tools/VariableDiscountFactor.hpp +++ b/finance/src/sgpp/finance/tools/VariableDiscountFactor.hpp @@ -12,15 +12,14 @@ #include - namespace SGPP { namespace finance { /** - * This class provides a method for discounting when the risk-free rate corresponds to an axis of the grid + * This class provides a method for discounting when the risk-free rate corresponds to an axis of + * the grid */ class VariableDiscountFactor { - private: /// bounding box of the grid SGPP::base::BoundingBox* myBoundingBox; @@ -33,7 +32,8 @@ class VariableDiscountFactor { /** * Std-Constructor * - * @param storage the grid's storage object; needed to determine the bounding box and to iterate of the entries in the coefficient vector + * @param storage the grid's storage object; needed to determine the bounding box and to iterate + * of the entries in the coefficient vector * @param dim_r dimension of the risk-free rate (HW axis) */ VariableDiscountFactor(SGPP::base::GridStorage* storage, int dim_r); @@ -48,10 +48,8 @@ class VariableDiscountFactor { *@param T timestepsize */ void getDiscountFactor(SGPP::base::DataVector& factor, float_t T); - }; +} // namespace finance +} // namespace SGPP -} -} - -#endif /* VARIABLEDISCOUNTFACTOR_HPP */ \ No newline at end of file +#endif /* VARIABLEDISCOUNTFACTOR_HPP */ diff --git a/finance/src/sgpp_finance.hpp b/finance/src/sgpp_finance.hpp index cbfd27d918..aa58924bdc 100644 --- a/finance/src/sgpp_finance.hpp +++ b/finance/src/sgpp_finance.hpp @@ -6,7 +6,6 @@ #ifndef FINANCE_HPP #define FINANCE_HPP - #include #include #include diff --git a/misc/SConscript b/misc/SConscript index bde27a98be..3f87e376ba 100755 --- a/misc/SConscript +++ b/misc/SConscript @@ -15,6 +15,7 @@ Import('installTargetList') Import('exampleTargetList') Import('headerSourceList') Import('headerDestList') +Import('lintAction') moduleDependencies = ['sgppfinance', 'sgppdatadriven', 'sgpppde', 'sgppsolver', 'sgppbase'] Export('moduleDependencies') @@ -26,18 +27,21 @@ if env['USE_STATICLIB']: moduleDependencies[i] = "%sstatic" % moduleDependencies[i] Export('libname') -srcs = [] +cpps = [] +hpps = [] +objs = [] + for currentFolder, subdirNames, fileNames in os.walk("src"): for fileName in fnmatch.filter(fileNames, '*.cpp'): - srcs.append(os.path.join(currentFolder, fileName)) + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) if currentFolder != 'src': for fileName in fnmatch.filter(fileNames, '*.hpp'): - headerSourceList.append(os.path.join(moduleName, currentFolder, fileName)) - headerDestList.append(os.path.join(currentFolder, fileName).split(os.sep,1)[1]) - -objs = [] -for sourceFile in srcs: - objs.append(env.SharedObject(sourceFile)) + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + headerSourceList.append(os.path.join(moduleName, hpp)) + headerDestList.append(hpp.split(os.sep, 1)[1]) if env['USE_STATICLIB']: # building static libraries is the same for unix and windows platforms @@ -62,6 +66,11 @@ for lib_str in moduleDependencies: libInstall = env.Install(BUILD_DIR, lib) +if env['RUN_CPPLINT']: + for path in cpps + hpps: + lintCommand = env.Command(path + ".lint", path, lintAction) + env.Depends(lib, lintCommand) + for fileName in os.listdir("examples"): if fnmatch.fnmatch(fileName, "*.cpp"): example = env.Program(source=os.path.join("examples", fileName), diff --git a/misc/src/sgpp/misc/operation/MiscOpFactory.cpp b/misc/src/sgpp/misc/operation/MiscOpFactory.cpp index bb7e2fcedd..ae2d5cf8bc 100644 --- a/misc/src/sgpp/misc/operation/MiscOpFactory.cpp +++ b/misc/src/sgpp/misc/operation/MiscOpFactory.cpp @@ -3,17 +3,12 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include #include - #include - #include +#include namespace SGPP { - -namespace op_factory { - -} -} +namespace op_factory {} // namespace op_factory +} // namespace SGPP diff --git a/misc/src/sgpp/misc/operation/MiscOpFactory.hpp b/misc/src/sgpp/misc/operation/MiscOpFactory.hpp index ef31dc70c1..443fe3022f 100644 --- a/misc/src/sgpp/misc/operation/MiscOpFactory.hpp +++ b/misc/src/sgpp/misc/operation/MiscOpFactory.hpp @@ -14,13 +14,9 @@ */ #include - namespace SGPP { -namespace op_factory { - -} - +namespace op_factory {} } -#endif /* EXPERIMENTAL_OP_FACTORY_HPP */ \ No newline at end of file +#endif /* EXPERIMENTAL_OP_FACTORY_HPP */ diff --git a/misc/src/sgpp/misc/pde/algorithm/UpDownOneOpDimEnhanced.cpp b/misc/src/sgpp/misc/pde/algorithm/UpDownOneOpDimEnhanced.cpp index feb36dd773..1f7c253c91 100644 --- a/misc/src/sgpp/misc/pde/algorithm/UpDownOneOpDimEnhanced.cpp +++ b/misc/src/sgpp/misc/pde/algorithm/UpDownOneOpDimEnhanced.cpp @@ -7,38 +7,35 @@ #include - namespace SGPP { namespace pde { UpDownOneOpDimEnhanced::UpDownOneOpDimEnhanced(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : storage(storage), coefs(&coef), - algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()) { -} + SGPP::base::DataVector& coef) + : storage(storage), + coefs(&coef), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()) {} UpDownOneOpDimEnhanced::UpDownOneOpDimEnhanced(SGPP::base::GridStorage* storage) - : storage(storage), coefs(NULL), algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()) { -} + : storage(storage), + coefs(NULL), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()) {} -UpDownOneOpDimEnhanced::~UpDownOneOpDimEnhanced() { -} +UpDownOneOpDimEnhanced::~UpDownOneOpDimEnhanced() {} -void UpDownOneOpDimEnhanced::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +void UpDownOneOpDimEnhanced::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataMatrix beta(result.getSize(), this->numAlgoDims_); SGPP::base::DataMatrix maAlpha(alpha.getSize(), this->numAlgoDims_); result.setAll(0.0); maAlpha.expand(alpha); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait - { - this->updown(maAlpha, beta, this->numAlgoDims_ - 1); - } +#pragma omp single nowait + { this->updown(maAlpha, beta, this->numAlgoDims_ - 1); } } if (coefs == NULL) { @@ -48,8 +45,8 @@ void UpDownOneOpDimEnhanced::mult(SGPP::base::DataVector& alpha, } } -void UpDownOneOpDimEnhanced::multParallelBuildingBlock(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result) { +void UpDownOneOpDimEnhanced::multParallelBuildingBlock(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { SGPP::base::DataMatrix beta(result.getSize(), this->numAlgoDims_); SGPP::base::DataMatrix maAlpha(alpha.getSize(), this->numAlgoDims_); @@ -65,48 +62,49 @@ void UpDownOneOpDimEnhanced::multParallelBuildingBlock(SGPP::base::DataVector& } } -void UpDownOneOpDimEnhanced::updown(SGPP::base::DataMatrix& alpha, - SGPP::base::DataMatrix& result, size_t dim) { +void UpDownOneOpDimEnhanced::updown(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, + size_t dim) { size_t curNumAlgoDims = this->numAlgoDims_; size_t curMaxParallelDims = this->maxParallelDims_; - //Unidirectional scheme + // Unidirectional scheme if (dim > 0) { // Reordering ups and downs SGPP::base::DataMatrix temp(alpha.getNrows(), this->numAlgoDims_); SGPP::base::DataMatrix result_temp(alpha.getNrows(), this->numAlgoDims_); SGPP::base::DataMatrix temp_two(alpha.getNrows(), this->numAlgoDims_); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) { up(alpha, temp, dim); updown(temp, result, dim - 1); } - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, result_temp) - { +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, \ + result_temp) + { // NOLINT(whitespace/braces) updown(alpha, temp_two, dim - 1); down(temp_two, result_temp, dim); } - #pragma omp taskwait +#pragma omp taskwait result.add(result_temp); } else { // Terminates dimension recursion SGPP::base::DataMatrix temp(alpha.getNrows(), this->numAlgoDims_); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) up(alpha, result, dim); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) down(alpha, temp, dim); - #pragma omp taskwait +#pragma omp taskwait result.add(temp); } } -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/misc/src/sgpp/misc/pde/algorithm/UpDownOneOpDimEnhanced.hpp b/misc/src/sgpp/misc/pde/algorithm/UpDownOneOpDimEnhanced.hpp index c07b09cf26..75487fcef5 100644 --- a/misc/src/sgpp/misc/pde/algorithm/UpDownOneOpDimEnhanced.hpp +++ b/misc/src/sgpp/misc/pde/algorithm/UpDownOneOpDimEnhanced.hpp @@ -6,8 +6,6 @@ #ifndef UPDOWNONEOPDIMENHANCED_HPP #define UPDOWNONEOPDIMENHANCED_HPP -#include - #include #include #include @@ -19,6 +17,7 @@ #include +#include namespace SGPP { namespace pde { @@ -29,32 +28,30 @@ namespace pde { * afterwards. * */ -class UpDownOneOpDimEnhanced: public SGPP::base::OperationMatrix { +class UpDownOneOpDimEnhanced : public SGPP::base::OperationMatrix { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients; one per dimension + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients; one per dimension */ - UpDownOneOpDimEnhanced(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + UpDownOneOpDimEnhanced(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - UpDownOneOpDimEnhanced(SGPP::base::GridStorage* storage); + explicit UpDownOneOpDimEnhanced(SGPP::base::GridStorage* storage); /** * Destructor */ virtual ~UpDownOneOpDimEnhanced(); - - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** * this functions provides the same functionality as the normal mult routine. @@ -70,9 +67,7 @@ class UpDownOneOpDimEnhanced: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - void multParallelBuildingBlock(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); - + void multParallelBuildingBlock(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); protected: typedef SGPP::base::GridStorage::grid_iterator grid_iterator; @@ -95,8 +90,7 @@ class UpDownOneOpDimEnhanced: public SGPP::base::OperationMatrix { * @param alpha matrix of coefficients * @param result matrix to store the results of all dimensions */ - void updown(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, - size_t dim); + void updown(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, size_t dim); /** * 1D up Operation @@ -105,8 +99,7 @@ class UpDownOneOpDimEnhanced: public SGPP::base::OperationMatrix { * @param alpha matrix of coefficients * @param result matrix to store the results of all dimensions */ - virtual void up(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, - size_t dim) = 0; + virtual void up(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, size_t dim) = 0; /** * 1D down Operation @@ -115,11 +108,10 @@ class UpDownOneOpDimEnhanced: public SGPP::base::OperationMatrix { * @param alpha matrix of coefficients * @param result matrix to store the results of all dimensions */ - virtual void down(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, - size_t dim) = 0; + virtual void down(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, size_t dim) = 0; }; -} -} +} // namespace pde +} // namespace SGPP -#endif /* STDUPDOWN_HPP */ \ No newline at end of file +#endif /* STDUPDOWN_HPP */ diff --git a/optimization/SConscript b/optimization/SConscript index 97acc10b9f..8cc6292aa2 100755 --- a/optimization/SConscript +++ b/optimization/SConscript @@ -17,7 +17,7 @@ Import("exampleTargetList") Import("config") Import('headerSourceList') Import('headerDestList') - +Import('lintAction') moduleDependencies = ["sgppbase"] Export('moduleDependencies') @@ -78,18 +78,21 @@ else: dependencies = ["base"] -srcs = [] +cpps = [] +hpps = [] +objs = [] + for currentFolder, subdirNames, fileNames in os.walk("src"): for fileName in fnmatch.filter(fileNames, "*.cpp"): - srcs.append(os.path.join(currentFolder, fileName)) + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) if currentFolder != 'src': for fileName in fnmatch.filter(fileNames, '*.hpp'): - headerSourceList.append(os.path.join(moduleName, currentFolder, fileName)) - headerDestList.append(os.path.join(currentFolder, fileName).split(os.sep,1)[1]) - -objs = [] -for sourceFile in srcs: - objs.append(env.SharedObject(sourceFile)) + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + headerSourceList.append(os.path.join(moduleName, hpp)) + headerDestList.append(hpp.split(os.sep, 1)[1]) if env['USE_STATICLIB']: libsuffix = env['LIBSUFFIX'] @@ -115,6 +118,11 @@ for lib_str in moduleDependencies: libInstall = env.Install(BUILD_DIR, lib) +if env['RUN_CPPLINT']: + for path in cpps + hpps: + lintCommand = env.Command(path + ".lint", path, lintAction) + env.Depends(lib, lintCommand) + for fileName in os.listdir("examples"): if fnmatch.fnmatch(fileName, "*.cpp"): example = env.Program(source=os.path.join("examples", fileName), diff --git a/optimization/src/sgpp/optimization/function/scalar/ComponentScalarFunction.hpp b/optimization/src/sgpp/optimization/function/scalar/ComponentScalarFunction.hpp index 9e642903f3..4f72d6eb59 100644 --- a/optimization/src/sgpp/optimization/function/scalar/ComponentScalarFunction.hpp +++ b/optimization/src/sgpp/optimization/function/scalar/ComponentScalarFunction.hpp @@ -54,23 +54,20 @@ class ComponentScalarFunction : public ScalarFunction { * while the finite entries denote the constant * values for the corresponding parameter. */ - ComponentScalarFunction( - ScalarFunction& f, - std::vector defaultValues = std::vector()) : - - ScalarFunction((defaultValues.size() > 0) ? - std::count(defaultValues.begin(), - defaultValues.end(), NAN) : - f.getNumberOfParameters()), - fScalar(&f), - fVector(nullptr), - dF(f.getNumberOfParameters()), - k(0), - defaultValues((defaultValues.size() > 0) ? - defaultValues : std::vector(dF, NAN)), - tmpVec1(dF), - tmpVec2(0) { - + ComponentScalarFunction(ScalarFunction& f, + std::vector defaultValues = std::vector()) + : + + ScalarFunction((defaultValues.size() > 0) + ? std::count(defaultValues.begin(), defaultValues.end(), NAN) + : f.getNumberOfParameters()), + fScalar(&f), + fVector(nullptr), + dF(f.getNumberOfParameters()), + k(0), + defaultValues((defaultValues.size() > 0) ? defaultValues : std::vector(dF, NAN)), + tmpVec1(dF), + tmpVec2(0) { initialize(); } @@ -89,32 +86,27 @@ class ComponentScalarFunction : public ScalarFunction { * (between 0 and m - 1) * @param defaultValues see other constructor */ - ComponentScalarFunction( - VectorFunction& f, - size_t k, - std::vector defaultValues = std::vector()) : - - ScalarFunction((defaultValues.size() > 0) ? - std::count(defaultValues.begin(), - defaultValues.end(), NAN) : - f.getNumberOfParameters()), - fScalar(nullptr), - fVector(&f), - dF(f.getNumberOfParameters()), - k(k), - defaultValues((defaultValues.size() > 0) ? - defaultValues : std::vector(dF, NAN)), - tmpVec1(dF), - tmpVec2(f.getNumberOfComponents()) { - + ComponentScalarFunction(VectorFunction& f, size_t k, + std::vector defaultValues = std::vector()) + : + + ScalarFunction((defaultValues.size() > 0) + ? std::count(defaultValues.begin(), defaultValues.end(), NAN) + : f.getNumberOfParameters()), + fScalar(nullptr), + fVector(&f), + dF(f.getNumberOfParameters()), + k(k), + defaultValues((defaultValues.size() > 0) ? defaultValues : std::vector(dF, NAN)), + tmpVec1(dF), + tmpVec2(f.getNumberOfComponents()) { initialize(); } /** * Destructor. */ - virtual ~ComponentScalarFunction() override { - } + ~ComponentScalarFunction() override {} /** * @param x evaluation point \f$\vec{x} \in [0, 1]^n\f$ @@ -122,7 +114,7 @@ class ComponentScalarFunction : public ScalarFunction { * where \f$(x_1, \dotsc, x_n) = * (y_{i_1}, \dotsc, y_{i_n})\f$ */ - inline virtual float_t eval(const base::DataVector& x) override { + inline float_t eval(const base::DataVector& x) override { size_t t2 = 0; // select entries of x which correspond to NAN entries in @@ -147,9 +139,8 @@ class ComponentScalarFunction : public ScalarFunction { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const override { - clone = std::unique_ptr( - new ComponentScalarFunction(*this)); + void clone(std::unique_ptr& clone) const override { + clone = std::unique_ptr(new ComponentScalarFunction(*this)); } protected: @@ -171,8 +162,7 @@ class ComponentScalarFunction : public ScalarFunction { void initialize() { // make sure defaultValues has the correct size if (defaultValues.size() != dF) { - throw std::runtime_error( - "ComponentScalarFunction::initialize(): Invalid defaultValues."); + throw std::runtime_error("ComponentScalarFunction::initialize(): Invalid defaultValues."); } // initialize constant non-NAN entries @@ -183,8 +173,7 @@ class ComponentScalarFunction : public ScalarFunction { } } }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_SCALAR_COMPONENTSCALARFUNCTION_HPP */ diff --git a/optimization/src/sgpp/optimization/function/scalar/ComponentScalarFunctionGradient.hpp b/optimization/src/sgpp/optimization/function/scalar/ComponentScalarFunctionGradient.hpp index a78cf6f84e..6812ec944b 100644 --- a/optimization/src/sgpp/optimization/function/scalar/ComponentScalarFunctionGradient.hpp +++ b/optimization/src/sgpp/optimization/function/scalar/ComponentScalarFunctionGradient.hpp @@ -47,24 +47,21 @@ class ComponentScalarFunctionGradient : public ScalarFunctionGradient { * while the finite entries denote the constant * values for the corresponding parameter. */ - ComponentScalarFunctionGradient( - ScalarFunctionGradient& fGradient, - std::vector defaultValues = std::vector()) : - - ScalarFunctionGradient((defaultValues.size() > 0) ? - std::count(defaultValues.begin(), - defaultValues.end(), NAN) : - fGradient.getNumberOfParameters()), - fGradientScalar(&fGradient), - fGradientVector(nullptr), - dF(fGradient.getNumberOfParameters()), - k(0), - defaultValues((defaultValues.size() > 0) ? - defaultValues : std::vector(dF, NAN)), - tmpVec1(dF), - tmpVec2(dF), - tmpMat(0, 0) { - + ComponentScalarFunctionGradient(ScalarFunctionGradient& fGradient, + std::vector defaultValues = std::vector()) + : + + ScalarFunctionGradient((defaultValues.size() > 0) + ? std::count(defaultValues.begin(), defaultValues.end(), NAN) + : fGradient.getNumberOfParameters()), + fGradientScalar(&fGradient), + fGradientVector(nullptr), + dF(fGradient.getNumberOfParameters()), + k(0), + defaultValues((defaultValues.size() > 0) ? defaultValues : std::vector(dF, NAN)), + tmpVec1(dF), + tmpVec2(dF), + tmpMat(0, 0) { initialize(); } @@ -83,33 +80,28 @@ class ComponentScalarFunctionGradient : public ScalarFunctionGradient { * (between 0 and m - 1) * @param defaultValues see other constructor */ - ComponentScalarFunctionGradient( - VectorFunctionGradient& fGradient, - size_t k, - std::vector defaultValues = std::vector()) : - - ScalarFunctionGradient((defaultValues.size() > 0) ? - std::count(defaultValues.begin(), - defaultValues.end(), NAN) : - fGradient.getNumberOfParameters()), - fGradientScalar(nullptr), - fGradientVector(&fGradient), - dF(fGradient.getNumberOfParameters()), - k(k), - defaultValues((defaultValues.size() > 0) ? - defaultValues : std::vector(dF, NAN)), - tmpVec1(dF), - tmpVec2(fGradient.getNumberOfComponents()), - tmpMat(fGradient.getNumberOfComponents(), dF) { - + ComponentScalarFunctionGradient(VectorFunctionGradient& fGradient, size_t k, + std::vector defaultValues = std::vector()) + : + + ScalarFunctionGradient((defaultValues.size() > 0) + ? std::count(defaultValues.begin(), defaultValues.end(), NAN) + : fGradient.getNumberOfParameters()), + fGradientScalar(nullptr), + fGradientVector(&fGradient), + dF(fGradient.getNumberOfParameters()), + k(k), + defaultValues((defaultValues.size() > 0) ? defaultValues : std::vector(dF, NAN)), + tmpVec1(dF), + tmpVec2(fGradient.getNumberOfComponents()), + tmpMat(fGradient.getNumberOfComponents(), dF) { initialize(); } /** * Destructor. */ - virtual ~ComponentScalarFunctionGradient() override { - } + ~ComponentScalarFunctionGradient() override {} /** * @param[in] x evaluation point \f$\vec{x} \in [0, 1]^n\f$ @@ -118,8 +110,7 @@ class ComponentScalarFunctionGradient : public ScalarFunctionGradient { * where \f$(x_1, \dotsc, x_n) = * (y_{i_1}, \dotsc, y_{i_n})\f$ */ - inline virtual float_t eval(const base::DataVector& x, - base::DataVector& gradient) override { + inline float_t eval(const base::DataVector& x, base::DataVector& gradient) override { size_t t2 = 0; // select entries of x which correspond to NAN entries in @@ -163,10 +154,8 @@ class ComponentScalarFunctionGradient : public ScalarFunctionGradient { /** * @param[out] clone pointer to cloned object */ - virtual void clone( - std::unique_ptr& clone) const override { - clone = std::unique_ptr( - new ComponentScalarFunctionGradient(*this)); + void clone(std::unique_ptr& clone) const override { + clone = std::unique_ptr(new ComponentScalarFunctionGradient(*this)); } protected: @@ -191,7 +180,7 @@ class ComponentScalarFunctionGradient : public ScalarFunctionGradient { // make sure defaultValues has the correct size if (defaultValues.size() != dF) { throw std::runtime_error( - "ComponentScalarFunctionGradient::initialize(): Invalid defaultValues."); + "ComponentScalarFunctionGradient::initialize(): Invalid defaultValues."); } // initialize constant non-NAN entries @@ -202,8 +191,7 @@ class ComponentScalarFunctionGradient : public ScalarFunctionGradient { } } }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_SCALAR_COMPONENTSCALARFUNCTIONGRADIENT_HPP */ diff --git a/optimization/src/sgpp/optimization/function/scalar/ComponentScalarFunctionHessian.hpp b/optimization/src/sgpp/optimization/function/scalar/ComponentScalarFunctionHessian.hpp index e6d299f263..35744b9357 100644 --- a/optimization/src/sgpp/optimization/function/scalar/ComponentScalarFunctionHessian.hpp +++ b/optimization/src/sgpp/optimization/function/scalar/ComponentScalarFunctionHessian.hpp @@ -47,25 +47,22 @@ class ComponentScalarFunctionHessian : public ScalarFunctionHessian { * while the finite entries denote the constant * values for the corresponding parameter. */ - ComponentScalarFunctionHessian( - ScalarFunctionHessian& fHessian, - std::vector defaultValues = std::vector()) : - - ScalarFunctionHessian((defaultValues.size() > 0) ? - std::count(defaultValues.begin(), - defaultValues.end(), NAN) : - fHessian.getNumberOfParameters()), - fHessianScalar(&fHessian), - fHessianVector(nullptr), - dF(fHessian.getNumberOfParameters()), - k(0), - defaultValues((defaultValues.size() > 0) ? - defaultValues : std::vector(dF, NAN)), - tmpVec1(dF), - tmpVec2(dF), - tmpMat(dF, dF), - tmpVecMat() { - + ComponentScalarFunctionHessian(ScalarFunctionHessian& fHessian, + std::vector defaultValues = std::vector()) + : + + ScalarFunctionHessian((defaultValues.size() > 0) + ? std::count(defaultValues.begin(), defaultValues.end(), NAN) + : fHessian.getNumberOfParameters()), + fHessianScalar(&fHessian), + fHessianVector(nullptr), + dF(fHessian.getNumberOfParameters()), + k(0), + defaultValues((defaultValues.size() > 0) ? defaultValues : std::vector(dF, NAN)), + tmpVec1(dF), + tmpVec2(dF), + tmpMat(dF, dF), + tmpVecMat() { initialize(); } @@ -84,35 +81,30 @@ class ComponentScalarFunctionHessian : public ScalarFunctionHessian { * (between 0 and m - 1) * @param defaultValues see other constructor */ - ComponentScalarFunctionHessian( - VectorFunctionHessian& fHessian, - size_t k, - std::vector defaultValues = std::vector()) : - - ScalarFunctionHessian((defaultValues.size() > 0) ? - std::count(defaultValues.begin(), - defaultValues.end(), NAN) : - fHessian.getNumberOfParameters()), - fHessianScalar(nullptr), - fHessianVector(&fHessian), - dF(fHessian.getNumberOfParameters()), - k(k), - defaultValues((defaultValues.size() > 0) ? - defaultValues : std::vector(dF, NAN)), - tmpVec1(dF), - tmpVec2(fHessian.getNumberOfComponents()), - tmpMat(fHessian.getNumberOfComponents(), dF), - tmpVecMat(std::vector( - fHessian.getNumberOfComponents(), base::DataMatrix(dF, dF))) { - + ComponentScalarFunctionHessian(VectorFunctionHessian& fHessian, size_t k, + std::vector defaultValues = std::vector()) + : + + ScalarFunctionHessian((defaultValues.size() > 0) + ? std::count(defaultValues.begin(), defaultValues.end(), NAN) + : fHessian.getNumberOfParameters()), + fHessianScalar(nullptr), + fHessianVector(&fHessian), + dF(fHessian.getNumberOfParameters()), + k(k), + defaultValues((defaultValues.size() > 0) ? defaultValues : std::vector(dF, NAN)), + tmpVec1(dF), + tmpVec2(fHessian.getNumberOfComponents()), + tmpMat(fHessian.getNumberOfComponents(), dF), + tmpVecMat(std::vector(fHessian.getNumberOfComponents(), + base::DataMatrix(dF, dF))) { initialize(); } /** * Destructor. */ - virtual ~ComponentScalarFunctionHessian() override { - } + ~ComponentScalarFunctionHessian() override {} /** * @param[in] x evaluation point \f$\vec{x} \in [0, 1]^n\f$ @@ -122,9 +114,8 @@ class ComponentScalarFunctionHessian : public ScalarFunctionHessian { * where \f$(x_1, \dotsc, x_n) = * (y_{i_1}, \dotsc, y_{i_n})\f$ */ - inline virtual float_t eval(const base::DataVector& x, - base::DataVector& gradient, - base::DataMatrix& hessian) override { + inline float_t eval(const base::DataVector& x, base::DataVector& gradient, + base::DataMatrix& hessian) override { size_t t2 = 0, t4; // select entries of x which correspond to NAN entries in @@ -186,10 +177,8 @@ class ComponentScalarFunctionHessian : public ScalarFunctionHessian { /** * @param[out] clone pointer to cloned object */ - virtual void clone( - std::unique_ptr& clone) const override { - clone = std::unique_ptr( - new ComponentScalarFunctionHessian(*this)); + void clone(std::unique_ptr& clone) const override { + clone = std::unique_ptr(new ComponentScalarFunctionHessian(*this)); } protected: @@ -216,7 +205,7 @@ class ComponentScalarFunctionHessian : public ScalarFunctionHessian { // make sure defaultValues has the correct size if (defaultValues.size() != dF) { throw std::runtime_error( - "ComponentScalarFunctionHessian::initialize(): Invalid defaultValues."); + "ComponentScalarFunctionHessian::initialize(): Invalid defaultValues."); } // initialize constant non-NAN entries @@ -227,8 +216,7 @@ class ComponentScalarFunctionHessian : public ScalarFunctionHessian { } } }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_SCALAR_COMPONENTSCALARFUNCTIONHESSIAN_HPP */ diff --git a/optimization/src/sgpp/optimization/function/scalar/InterpolantScalarFunction.hpp b/optimization/src/sgpp/optimization/function/scalar/InterpolantScalarFunction.hpp index efaa1423a2..103e69f117 100644 --- a/optimization/src/sgpp/optimization/function/scalar/InterpolantScalarFunction.hpp +++ b/optimization/src/sgpp/optimization/function/scalar/InterpolantScalarFunction.hpp @@ -43,19 +43,16 @@ class InterpolantScalarFunction : public ScalarFunction { * @param grid sparse grid * @param alpha coefficient vector */ - InterpolantScalarFunction(base::Grid& grid, - const base::DataVector& alpha) : - ScalarFunction(grid.getStorage()->dim()), - grid(grid), - opEval(op_factory::createOperationNaiveEval(grid)), - alpha(alpha) { - } + InterpolantScalarFunction(base::Grid& grid, const base::DataVector& alpha) + : ScalarFunction(grid.getStorage()->dim()), + grid(grid), + opEval(op_factory::createOperationNaiveEval(grid)), + alpha(alpha) {} /** * Destructor. */ - virtual ~InterpolantScalarFunction() override { - } + ~InterpolantScalarFunction() override {} /** * Evaluation of the function. @@ -63,7 +60,7 @@ class InterpolantScalarFunction : public ScalarFunction { * @param x evaluation point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - inline virtual float_t eval(const base::DataVector& x) override { + inline float_t eval(const base::DataVector& x) override { for (size_t t = 0; t < d; t++) { if ((x[t] < 0.0) || (x[t] > 1.0)) { return INFINITY; @@ -76,24 +73,19 @@ class InterpolantScalarFunction : public ScalarFunction { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const override { - clone = std::unique_ptr( - new InterpolantScalarFunction(grid, alpha)); + void clone(std::unique_ptr& clone) const override { + clone = std::unique_ptr(new InterpolantScalarFunction(grid, alpha)); } /** * @return coefficient vector */ - const base::DataVector& getAlpha() const { - return alpha; - } + const base::DataVector& getAlpha() const { return alpha; } /** * @param alpha coefficient vector */ - void setAlpha(const base::DataVector& alpha) { - this->alpha = alpha; - } + void setAlpha(const base::DataVector& alpha) { this->alpha = alpha; } protected: /// sparse grid @@ -103,8 +95,7 @@ class InterpolantScalarFunction : public ScalarFunction { /// coefficient vector base::DataVector alpha; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_SCALAR_INTERPOLANTSCALARFUNCTION_HPP */ diff --git a/optimization/src/sgpp/optimization/function/scalar/InterpolantScalarFunctionGradient.hpp b/optimization/src/sgpp/optimization/function/scalar/InterpolantScalarFunctionGradient.hpp index 10e6422580..2cf2bd9e11 100644 --- a/optimization/src/sgpp/optimization/function/scalar/InterpolantScalarFunctionGradient.hpp +++ b/optimization/src/sgpp/optimization/function/scalar/InterpolantScalarFunctionGradient.hpp @@ -32,19 +32,16 @@ class InterpolantScalarFunctionGradient : public ScalarFunctionGradient { * @param grid sparse grid * @param alpha coefficient vector */ - InterpolantScalarFunctionGradient(base::Grid& grid, - const base::DataVector& alpha) : - ScalarFunctionGradient(grid.getStorage()->dim()), - grid(grid), - opEvalGradient(op_factory::createOperationNaiveEvalGradient(grid)), - alpha(alpha) { - } + InterpolantScalarFunctionGradient(base::Grid& grid, const base::DataVector& alpha) + : ScalarFunctionGradient(grid.getStorage()->dim()), + grid(grid), + opEvalGradient(op_factory::createOperationNaiveEvalGradient(grid)), + alpha(alpha) {} /** * Destructor. */ - virtual ~InterpolantScalarFunctionGradient() override { - } + ~InterpolantScalarFunctionGradient() override {} /** * Evaluation of the function and its gradient. @@ -54,8 +51,7 @@ class InterpolantScalarFunctionGradient : public ScalarFunctionGradient { * \f$\nabla f(\vec{x}) \in \mathbb{R}^d\f$ * @return \f$f(\vec{x})\f$ */ - inline virtual float_t eval(const base::DataVector& x, - base::DataVector& gradient) override { + inline float_t eval(const base::DataVector& x, base::DataVector& gradient) override { for (size_t t = 0; t < d; t++) { if ((x[t] < 0.0) || (x[t] > 1.0)) { return INFINITY; @@ -68,25 +64,20 @@ class InterpolantScalarFunctionGradient : public ScalarFunctionGradient { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override { - clone = std::unique_ptr( - new InterpolantScalarFunctionGradient(grid, alpha)); + void clone(std::unique_ptr& clone) const override { + clone = + std::unique_ptr(new InterpolantScalarFunctionGradient(grid, alpha)); } /** * @return coefficient vector */ - const base::DataVector& getAlpha() const { - return alpha; - } + const base::DataVector& getAlpha() const { return alpha; } /** * @param alpha coefficient vector */ - void setAlpha(const base::DataVector& alpha) { - this->alpha = alpha; - } + void setAlpha(const base::DataVector& alpha) { this->alpha = alpha; } protected: /// sparse grid @@ -96,8 +87,7 @@ class InterpolantScalarFunctionGradient : public ScalarFunctionGradient { /// coefficient vector base::DataVector alpha; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_SCALAR_INTERPOLANTSCALARFUNCTIONGRADIENT_HPP */ diff --git a/optimization/src/sgpp/optimization/function/scalar/InterpolantScalarFunctionHessian.hpp b/optimization/src/sgpp/optimization/function/scalar/InterpolantScalarFunctionHessian.hpp index e63e674fdc..37dec032f2 100644 --- a/optimization/src/sgpp/optimization/function/scalar/InterpolantScalarFunctionHessian.hpp +++ b/optimization/src/sgpp/optimization/function/scalar/InterpolantScalarFunctionHessian.hpp @@ -18,7 +18,6 @@ namespace SGPP { namespace optimization { - /** * Sparse grid interpolant Hessian of a scalar-valued function. * @@ -34,19 +33,16 @@ class InterpolantScalarFunctionHessian : public ScalarFunctionHessian { * @param grid sparse grid * @param alpha coefficient vector */ - InterpolantScalarFunctionHessian(base::Grid& grid, - const base::DataVector& alpha) : - ScalarFunctionHessian(grid.getStorage()->dim()), - grid(grid), - opEvalHessian(op_factory::createOperationNaiveEvalHessian(grid)), - alpha(alpha) { - } + InterpolantScalarFunctionHessian(base::Grid& grid, const base::DataVector& alpha) + : ScalarFunctionHessian(grid.getStorage()->dim()), + grid(grid), + opEvalHessian(op_factory::createOperationNaiveEvalHessian(grid)), + alpha(alpha) {} /** * Destructor. */ - virtual ~InterpolantScalarFunctionHessian() override { - } + ~InterpolantScalarFunctionHessian() override {} /** * Evaluation of the function, its gradient and its Hessian. @@ -58,9 +54,8 @@ class InterpolantScalarFunctionHessian : public ScalarFunctionHessian { * \f$H_f(\vec{x}) \in \mathbb{R}^{d \times d}\f$ * @return \f$f(\vec{x})\f$ */ - inline virtual float_t eval(const base::DataVector& x, - base::DataVector& gradient, - base::DataMatrix& hessian) override { + inline float_t eval(const base::DataVector& x, base::DataVector& gradient, + base::DataMatrix& hessian) override { for (size_t t = 0; t < d; t++) { if ((x[t] < 0.0) || (x[t] > 1.0)) { return INFINITY; @@ -73,25 +68,20 @@ class InterpolantScalarFunctionHessian : public ScalarFunctionHessian { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override { - clone = std::unique_ptr( - new InterpolantScalarFunctionHessian(grid, alpha)); + void clone(std::unique_ptr& clone) const override { + clone = + std::unique_ptr(new InterpolantScalarFunctionHessian(grid, alpha)); } /** * @return coefficient vector */ - const base::DataVector& getAlpha() const { - return alpha; - } + const base::DataVector& getAlpha() const { return alpha; } /** * @param alpha coefficient vector */ - void setAlpha(const base::DataVector& alpha) { - this->alpha = alpha; - } + void setAlpha(const base::DataVector& alpha) { this->alpha = alpha; } protected: /// sparse grid @@ -101,8 +91,7 @@ class InterpolantScalarFunctionHessian : public ScalarFunctionHessian { /// coefficient vector base::DataVector alpha; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_SCALAR_INTERPOLANTSCALARFUNCTIONHESSIAN_HPP */ diff --git a/optimization/src/sgpp/optimization/function/scalar/ScalarFunction.hpp b/optimization/src/sgpp/optimization/function/scalar/ScalarFunction.hpp index 0415107fdd..18e66e8d7e 100644 --- a/optimization/src/sgpp/optimization/function/scalar/ScalarFunction.hpp +++ b/optimization/src/sgpp/optimization/function/scalar/ScalarFunction.hpp @@ -27,14 +27,12 @@ class ScalarFunction { * * @param d dimension of the domain */ - ScalarFunction(size_t d) : d(d) { - } + explicit ScalarFunction(size_t d) : d(d) {} /** * Destructor. */ - virtual ~ScalarFunction() { - } + virtual ~ScalarFunction() {} /** * Pure virtual method for calculating \f$f(\vec{x})\f$. @@ -47,9 +45,7 @@ class ScalarFunction { /** * @return dimension \f$d\f$ of the domain */ - size_t getNumberOfParameters() const { - return d; - } + size_t getNumberOfParameters() const { return d; } /** * Pure virtual method for cloning the function. @@ -59,15 +55,13 @@ class ScalarFunction { * * @param[out] clone pointer to cloned object */ - virtual void clone( - std::unique_ptr& clone) const = 0; + virtual void clone(std::unique_ptr& clone) const = 0; protected: /// dimension of the domain size_t d; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_SCALAR_SCALARFUNCTION_HPP */ diff --git a/optimization/src/sgpp/optimization/function/scalar/ScalarFunctionGradient.hpp b/optimization/src/sgpp/optimization/function/scalar/ScalarFunctionGradient.hpp index 04c8df52c0..70e0cf0df1 100644 --- a/optimization/src/sgpp/optimization/function/scalar/ScalarFunctionGradient.hpp +++ b/optimization/src/sgpp/optimization/function/scalar/ScalarFunctionGradient.hpp @@ -7,12 +7,11 @@ #define SGPP_OPTIMIZATION_FUNCTION_SCALAR_SCALARFUNCTIONGRADIENT_HPP #include +#include #include #include -#include - namespace SGPP { namespace optimization { @@ -30,14 +29,12 @@ class ScalarFunctionGradient { * * @param d dimension of the domain */ - ScalarFunctionGradient(size_t d) : d(d) { - } + explicit ScalarFunctionGradient(size_t d) : d(d) {} /** * Destructor. */ - virtual ~ScalarFunctionGradient() { - } + virtual ~ScalarFunctionGradient() {} /** * Pure virtual method for calculating @@ -48,15 +45,12 @@ class ScalarFunctionGradient { * \f$\nabla f(\vec{x}) \in \mathbb{R}^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t eval(const base::DataVector& x, - base::DataVector& gradient) = 0; + virtual float_t eval(const base::DataVector& x, base::DataVector& gradient) = 0; /** * @return dimension \f$d\f$ of the domain */ - size_t getNumberOfParameters() const { - return d; - } + size_t getNumberOfParameters() const { return d; } /** * Pure virtual method for cloning the gradient. @@ -66,15 +60,13 @@ class ScalarFunctionGradient { * * @param[out] clone pointer to cloned object */ - virtual void clone( - std::unique_ptr& clone) const = 0; + virtual void clone(std::unique_ptr& clone) const = 0; protected: /// dimension of the domain size_t d; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_SCALAR_SCALARFUNCTIONGRADIENT_HPP */ diff --git a/optimization/src/sgpp/optimization/function/scalar/ScalarFunctionHessian.hpp b/optimization/src/sgpp/optimization/function/scalar/ScalarFunctionHessian.hpp index f0118f131b..31801c645c 100644 --- a/optimization/src/sgpp/optimization/function/scalar/ScalarFunctionHessian.hpp +++ b/optimization/src/sgpp/optimization/function/scalar/ScalarFunctionHessian.hpp @@ -7,14 +7,13 @@ #define SGPP_OPTIMIZATION_FUNCTION_SCALAR_SCALARFUNCTIONHESSIAN_HPP #include +#include +#include #include #include #include -#include -#include - namespace SGPP { namespace optimization { @@ -34,14 +33,12 @@ class ScalarFunctionHessian { * * @param d dimension of the domain */ - ScalarFunctionHessian(size_t d) : d(d) { - } + explicit ScalarFunctionHessian(size_t d) : d(d) {} /** * Destructor. */ - virtual ~ScalarFunctionHessian() { - } + virtual ~ScalarFunctionHessian() {} /** * Pure virtual method for calculating \f$f(\vec{x})\f$ together with @@ -55,16 +52,13 @@ class ScalarFunctionHessian { * \f$H_f(\vec{x}) \in \mathbb{R}^{d \times d}\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t eval(const base::DataVector& x, - base::DataVector& gradient, + virtual float_t eval(const base::DataVector& x, base::DataVector& gradient, base::DataMatrix& hessian) = 0; /** * @return dimension \f$d\f$ of the domain */ - size_t getNumberOfParameters() const { - return d; - } + size_t getNumberOfParameters() const { return d; } /** * Pure virtual method for cloning the Hessian. @@ -74,15 +68,13 @@ class ScalarFunctionHessian { * * @param[out] clone pointer to cloned object */ - virtual void clone( - std::unique_ptr& clone) const = 0; + virtual void clone(std::unique_ptr& clone) const = 0; protected: /// dimension of the domain size_t d; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_SCALAR_SCALARFUNCTIONHESSIAN_HPP */ diff --git a/optimization/src/sgpp/optimization/function/scalar/WrapperScalarFunction.hpp b/optimization/src/sgpp/optimization/function/scalar/WrapperScalarFunction.hpp index 85c0b1ce38..b39e7f3bf2 100644 --- a/optimization/src/sgpp/optimization/function/scalar/WrapperScalarFunction.hpp +++ b/optimization/src/sgpp/optimization/function/scalar/WrapperScalarFunction.hpp @@ -21,8 +21,7 @@ namespace optimization { */ class WrapperScalarFunction : public ScalarFunction { public: - typedef std::function - FunctionEvalType; + typedef std::function FunctionEvalType; /** * Constructor. @@ -30,38 +29,31 @@ class WrapperScalarFunction : public ScalarFunction { * @param d dimension of the domain * @param f function to be wrapped */ - WrapperScalarFunction(size_t d, FunctionEvalType f) : - ScalarFunction(d), f(f) { - } + WrapperScalarFunction(size_t d, FunctionEvalType f) : ScalarFunction(d), f(f) {} /** * Destructor. */ - virtual ~WrapperScalarFunction() override { - } + ~WrapperScalarFunction() override {} /** * @param x evaluation point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - inline virtual float_t eval(const base::DataVector& x) override { - return f(x); - } + inline float_t eval(const base::DataVector& x) override { return f(x); } /** * @param[out] clone pointer to cloned object */ void clone(std::unique_ptr& clone) const override { - clone = std::unique_ptr( - new WrapperScalarFunction(d, f)); + clone = std::unique_ptr(new WrapperScalarFunction(d, f)); } protected: /// function to be wrapped FunctionEvalType f; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_SCALAR_WRAPPERSCALARFUNCTION_HPP */ diff --git a/optimization/src/sgpp/optimization/function/scalar/WrapperScalarFunctionGradient.hpp b/optimization/src/sgpp/optimization/function/scalar/WrapperScalarFunctionGradient.hpp index cbbb243f22..0a2a73db61 100644 --- a/optimization/src/sgpp/optimization/function/scalar/WrapperScalarFunctionGradient.hpp +++ b/optimization/src/sgpp/optimization/function/scalar/WrapperScalarFunctionGradient.hpp @@ -22,9 +22,8 @@ namespace optimization { */ class WrapperScalarFunctionGradient : public ScalarFunctionGradient { public: - typedef std::function - FunctionGradientEvalType; + typedef std::function + FunctionGradientEvalType; /** * Constructor. @@ -32,16 +31,13 @@ class WrapperScalarFunctionGradient : public ScalarFunctionGradient { * @param d dimension of the domain * @param fGradient function gradient to be wrapped */ - WrapperScalarFunctionGradient(size_t d, - FunctionGradientEvalType fGradient) : - ScalarFunctionGradient(d), fGradient(fGradient) { - } + WrapperScalarFunctionGradient(size_t d, FunctionGradientEvalType fGradient) + : ScalarFunctionGradient(d), fGradient(fGradient) {} /** * Destructor. */ - virtual ~WrapperScalarFunctionGradient() override { - } + ~WrapperScalarFunctionGradient() override {} /** * @param x evaluation point \f$\vec{x} \in [0, 1]^d\f$ @@ -49,8 +45,7 @@ class WrapperScalarFunctionGradient : public ScalarFunctionGradient { * \f$\nabla f(\vec{x}) \in \mathbb{R}^d\f$ * @return \f$f(\vec{x})\f$ */ - inline virtual float_t eval(const base::DataVector& x, - base::DataVector& gradient) override { + inline float_t eval(const base::DataVector& x, base::DataVector& gradient) override { return fGradient(x, gradient); } @@ -58,16 +53,15 @@ class WrapperScalarFunctionGradient : public ScalarFunctionGradient { * @param[out] clone pointer to cloned object */ void clone(std::unique_ptr& clone) const override { - clone = std::unique_ptr( - new WrapperScalarFunctionGradient(d, fGradient)); + clone = + std::unique_ptr(new WrapperScalarFunctionGradient(d, fGradient)); } protected: /// function gradient to be wrapped FunctionGradientEvalType fGradient; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_SCALAR_WRAPPERSCALARFUNCTIONGRADIENT_HPP */ diff --git a/optimization/src/sgpp/optimization/function/scalar/WrapperScalarFunctionHessian.hpp b/optimization/src/sgpp/optimization/function/scalar/WrapperScalarFunctionHessian.hpp index 8e8efd2496..bb5a0072d0 100644 --- a/optimization/src/sgpp/optimization/function/scalar/WrapperScalarFunctionHessian.hpp +++ b/optimization/src/sgpp/optimization/function/scalar/WrapperScalarFunctionHessian.hpp @@ -22,10 +22,8 @@ namespace optimization { */ class WrapperScalarFunctionHessian : public ScalarFunctionHessian { public: - typedef std::function - FunctionHessianEvalType; + typedef std::function + FunctionHessianEvalType; /** * Constructor. @@ -33,16 +31,13 @@ class WrapperScalarFunctionHessian : public ScalarFunctionHessian { * @param d dimension of the domain * @param fHessian function gradient to be wrapped */ - WrapperScalarFunctionHessian(size_t d, - FunctionHessianEvalType fHessian) : - ScalarFunctionHessian(d), fHessian(fHessian) { - } + WrapperScalarFunctionHessian(size_t d, FunctionHessianEvalType fHessian) + : ScalarFunctionHessian(d), fHessian(fHessian) {} /** * Destructor. */ - virtual ~WrapperScalarFunctionHessian() override { - } + ~WrapperScalarFunctionHessian() override {} /** * @param x evaluation point \f$\vec{x} \in [0, 1]^d\f$ @@ -52,9 +47,8 @@ class WrapperScalarFunctionHessian : public ScalarFunctionHessian { * \f$H_f(\vec{x}) \in \mathbb{R}^{d \times d}\f$ * @return \f$f(\vec{x})\f$ */ - inline virtual float_t eval(const base::DataVector& x, - base::DataVector& gradient, - base::DataMatrix& hessian) override { + inline float_t eval(const base::DataVector& x, base::DataVector& gradient, + base::DataMatrix& hessian) override { return fHessian(x, gradient, hessian); } @@ -62,16 +56,14 @@ class WrapperScalarFunctionHessian : public ScalarFunctionHessian { * @param[out] clone pointer to cloned object */ void clone(std::unique_ptr& clone) const override { - clone = std::unique_ptr( - new WrapperScalarFunctionHessian(d, fHessian)); + clone = std::unique_ptr(new WrapperScalarFunctionHessian(d, fHessian)); } protected: /// function Hessian to be wrapped FunctionHessianEvalType fHessian; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_SCALAR_WRAPPERSCALARFUNCTIONHESSIAN_HPP */ diff --git a/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunction.cpp b/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunction.cpp new file mode 100644 index 0000000000..b9dab0bf9f --- /dev/null +++ b/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunction.cpp @@ -0,0 +1,18 @@ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + +#include +#include + +namespace SGPP { +namespace optimization { + +WrapperVectorFunction& EmptyVectorFunction::getInstance() { + static WrapperVectorFunction wrapperVectorFunction( + 0, 0, [](const base::DataVector& x, base::DataVector& value) {}); + return wrapperVectorFunction; +} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunction.hpp b/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunction.hpp index 26f7cec25d..5ee689beef 100644 --- a/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunction.hpp +++ b/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunction.hpp @@ -6,6 +6,7 @@ #ifndef SGPP_OPTIMIZATION_FUNCTION_VECTOR_EMPTYVECTORFUNCTION_HPP #define SGPP_OPTIMIZATION_FUNCTION_VECTOR_EMPTYVECTORFUNCTION_HPP +#include #include namespace SGPP { @@ -18,20 +19,14 @@ namespace optimization { */ class EmptyVectorFunction { public: - inline static WrapperVectorFunction& getInstance() { - static WrapperVectorFunction wrapperVectorFunction( - 0, 0, [](const base::DataVector & x, - base::DataVector & value) {}); - return wrapperVectorFunction; - } + static WrapperVectorFunction& getInstance(); private: EmptyVectorFunction() {} EmptyVectorFunction(const EmptyVectorFunction&) = delete; void operator=(const EmptyVectorFunction&) = delete; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_VECTOR_EMPTYVECTORFUNCTION_HPP */ diff --git a/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunctionGradient.cpp b/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunctionGradient.cpp new file mode 100644 index 0000000000..1ff8f76381 --- /dev/null +++ b/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunctionGradient.cpp @@ -0,0 +1,18 @@ +// Copyright (C) 2008-today The SG++ project +// This file is part of the SG++ project. For conditions of distribution and +// use, please see the copyright notice provided with SG++ or at +// sgpp.sparsegrids.org + +#include +#include + +namespace SGPP { +namespace optimization { + +WrapperVectorFunctionGradient& EmptyVectorFunctionGradient::getInstance() { + static WrapperVectorFunctionGradient wrapperVectorFunctionGradient( + 0, 0, [](const base::DataVector& x, base::DataVector& value, base::DataMatrix& gradient) {}); + return wrapperVectorFunctionGradient; +} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunctionGradient.hpp b/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunctionGradient.hpp index df01bdd892..c092fb0e58 100644 --- a/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunctionGradient.hpp +++ b/optimization/src/sgpp/optimization/function/vector/EmptyVectorFunctionGradient.hpp @@ -6,6 +6,7 @@ #ifndef SGPP_OPTIMIZATION_FUNCTION_VECTOR_EMPTYVECTORFUNCTIONGRADIENT_HPP #define SGPP_OPTIMIZATION_FUNCTION_VECTOR_EMPTYVECTORFUNCTIONGRADIENT_HPP +#include #include namespace SGPP { @@ -18,21 +19,14 @@ namespace optimization { */ class EmptyVectorFunctionGradient { public: - inline static WrapperVectorFunctionGradient& getInstance() { - static WrapperVectorFunctionGradient wrapperVectorFunctionGradient( - 0, 0, [](const base::DataVector & x, - base::DataVector & value, - base::DataMatrix & gradient) {}); - return wrapperVectorFunctionGradient; - } + static WrapperVectorFunctionGradient& getInstance(); private: EmptyVectorFunctionGradient() {} EmptyVectorFunctionGradient(const EmptyVectorFunctionGradient&) = delete; void operator=(const EmptyVectorFunctionGradient&) = delete; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_VECTOR_EMPTYVECTORGRADIENT_HPP */ diff --git a/optimization/src/sgpp/optimization/function/vector/InterpolantVectorFunction.hpp b/optimization/src/sgpp/optimization/function/vector/InterpolantVectorFunction.hpp index e396e5c124..3245a340ce 100644 --- a/optimization/src/sgpp/optimization/function/vector/InterpolantVectorFunction.hpp +++ b/optimization/src/sgpp/optimization/function/vector/InterpolantVectorFunction.hpp @@ -45,19 +45,16 @@ class InterpolantVectorFunction : public VectorFunction { * (j-th column contains hierarchical surplusses * \f$\alpha_{\cdot,j}\f$ of \f$g_j\f$) */ - InterpolantVectorFunction(base::Grid& grid, - const base::DataMatrix& alpha) : - VectorFunction(grid.getStorage()->dim(), alpha.getNcols()), - grid(grid), - opEval(op_factory::createOperationNaiveEval(grid)), - alpha(alpha) { - } + InterpolantVectorFunction(base::Grid& grid, const base::DataMatrix& alpha) + : VectorFunction(grid.getStorage()->dim(), alpha.getNcols()), + grid(grid), + opEval(op_factory::createOperationNaiveEval(grid)), + alpha(alpha) {} /** * Destructor. */ - virtual ~InterpolantVectorFunction() override { - } + ~InterpolantVectorFunction() override {} /** * Evaluation of the function. @@ -65,8 +62,7 @@ class InterpolantVectorFunction : public VectorFunction { * @param[in] x evaluation point \f$\vec{x} \in [0, 1]^d\f$ * @param[out] value \f$g(\vec{x})\f$ */ - inline virtual void eval(const base::DataVector& x, - base::DataVector& value) override { + inline void eval(const base::DataVector& x, base::DataVector& value) override { for (size_t t = 0; t < d; t++) { if ((x[t] < 0.0) || (x[t] > 1.0)) { for (size_t j = 0; j < m; j++) { @@ -88,24 +84,19 @@ class InterpolantVectorFunction : public VectorFunction { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const override { - clone = std::unique_ptr( - new InterpolantVectorFunction(grid, alpha)); + void clone(std::unique_ptr& clone) const override { + clone = std::unique_ptr(new InterpolantVectorFunction(grid, alpha)); } /** * @return coefficient matrix */ - const base::DataMatrix& getAlpha() const { - return alpha; - } + const base::DataMatrix& getAlpha() const { return alpha; } /** * @param alpha coefficient matrix */ - void setAlpha(const base::DataMatrix& alpha) { - this->alpha = alpha; - } + void setAlpha(const base::DataMatrix& alpha) { this->alpha = alpha; } protected: /// sparse grid @@ -115,8 +106,7 @@ class InterpolantVectorFunction : public VectorFunction { /// coefficient matrix base::DataMatrix alpha; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_VECTOR_INTERPOLANTVECTORFUNCTION_HPP */ diff --git a/optimization/src/sgpp/optimization/function/vector/InterpolantVectorFunctionGradient.hpp b/optimization/src/sgpp/optimization/function/vector/InterpolantVectorFunctionGradient.hpp index 544cad0b3f..421fc096e1 100644 --- a/optimization/src/sgpp/optimization/function/vector/InterpolantVectorFunctionGradient.hpp +++ b/optimization/src/sgpp/optimization/function/vector/InterpolantVectorFunctionGradient.hpp @@ -37,19 +37,16 @@ class InterpolantVectorFunctionGradient : public VectorFunctionGradient { * (j-th column contains hierarchical surplusses * \f$\alpha_{\cdot,j}\f$ of \f$g_j\f$) */ - InterpolantVectorFunctionGradient(base::Grid& grid, - const base::DataMatrix& alpha) : - VectorFunctionGradient(grid.getStorage()->dim(), alpha.getNcols()), - grid(grid), - opEvalGradient(op_factory::createOperationNaiveEvalGradient(grid)), - alpha(alpha) { - } + InterpolantVectorFunctionGradient(base::Grid& grid, const base::DataMatrix& alpha) + : VectorFunctionGradient(grid.getStorage()->dim(), alpha.getNcols()), + grid(grid), + opEvalGradient(op_factory::createOperationNaiveEvalGradient(grid)), + alpha(alpha) {} /** * Destructor. */ - virtual ~InterpolantVectorFunctionGradient() override { - } + ~InterpolantVectorFunctionGradient() override {} /** * Evaluation of the function and its gradient. @@ -59,9 +56,8 @@ class InterpolantVectorFunctionGradient : public VectorFunctionGradient { * @param[out] gradient Jacobian \f$\nabla g(\vec{x}) \in * \mathbb{R}^{m \times d}\f$ */ - inline virtual void eval(const base::DataVector& x, - base::DataVector& value, - base::DataMatrix& gradient) override { + inline void eval(const base::DataVector& x, base::DataVector& value, + base::DataMatrix& gradient) override { for (size_t t = 0; t < d; t++) { if ((x[t] < 0.0) || (x[t] > 1.0)) { for (size_t j = 0; j < m; j++) { @@ -85,25 +81,20 @@ class InterpolantVectorFunctionGradient : public VectorFunctionGradient { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override { - clone = std::unique_ptr( - new InterpolantVectorFunctionGradient(grid, alpha)); + void clone(std::unique_ptr& clone) const override { + clone = + std::unique_ptr(new InterpolantVectorFunctionGradient(grid, alpha)); } /** * @return coefficient matrix */ - const base::DataMatrix& getAlpha() const { - return alpha; - } + const base::DataMatrix& getAlpha() const { return alpha; } /** * @param alpha coefficient matrix */ - void setAlpha(const base::DataMatrix& alpha) { - this->alpha = alpha; - } + void setAlpha(const base::DataMatrix& alpha) { this->alpha = alpha; } protected: /// sparse grid @@ -113,8 +104,7 @@ class InterpolantVectorFunctionGradient : public VectorFunctionGradient { /// coefficient matrix base::DataMatrix alpha; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_VECTOR_INTERPOLANTVECTORFUNCTIONGRADIENT_HPP */ diff --git a/optimization/src/sgpp/optimization/function/vector/InterpolantVectorFunctionHessian.hpp b/optimization/src/sgpp/optimization/function/vector/InterpolantVectorFunctionHessian.hpp index a21de958eb..1dda869750 100644 --- a/optimization/src/sgpp/optimization/function/vector/InterpolantVectorFunctionHessian.hpp +++ b/optimization/src/sgpp/optimization/function/vector/InterpolantVectorFunctionHessian.hpp @@ -16,6 +16,7 @@ #include #include +#include namespace SGPP { namespace optimization { @@ -37,19 +38,16 @@ class InterpolantVectorFunctionHessian : public VectorFunctionHessian { * (j-th column contains hierarchical surplusses * \f$\alpha_{\cdot,j}\f$ of \f$g_j\f$) */ - InterpolantVectorFunctionHessian(base::Grid& grid, - const base::DataMatrix& alpha) : - VectorFunctionHessian(grid.getStorage()->dim(), alpha.getNcols()), - grid(grid), - opEvalHessian(op_factory::createOperationNaiveEvalHessian(grid)), - alpha(alpha) { - } + InterpolantVectorFunctionHessian(base::Grid& grid, const base::DataMatrix& alpha) + : VectorFunctionHessian(grid.getStorage()->dim(), alpha.getNcols()), + grid(grid), + opEvalHessian(op_factory::createOperationNaiveEvalHessian(grid)), + alpha(alpha) {} /** * Destructor. */ - virtual ~InterpolantVectorFunctionHessian() override { - } + ~InterpolantVectorFunctionHessian() override {} /** * Evaluation of the function and its gradient. @@ -62,10 +60,9 @@ class InterpolantVectorFunctionHessian : public VectorFunctionHessian { * \f$\nabla^2 g_i(\vec{x}) \in * \mathbb{R}^{d \times d}\f$ */ - inline virtual void eval(const base::DataVector& x, - base::DataVector& value, - base::DataMatrix& gradient, - std::vector& hessian) override { + inline void eval(const base::DataVector& x, base::DataVector& value, + base::DataMatrix& gradient, + std::vector& hessian) override { for (size_t t = 0; t < d; t++) { if ((x[t] < 0.0) || (x[t] > 1.0)) { for (size_t j = 0; j < m; j++) { @@ -82,8 +79,7 @@ class InterpolantVectorFunctionHessian : public VectorFunctionHessian { for (size_t j = 0; j < m; j++) { alpha.getColumn(j, curAlpha); - value[j] = opEvalHessian->evalHessian( - curAlpha, x, curGradient, hessian[j]); + value[j] = opEvalHessian->evalHessian(curAlpha, x, curGradient, hessian[j]); gradient.setRow(j, curGradient); } } @@ -91,25 +87,20 @@ class InterpolantVectorFunctionHessian : public VectorFunctionHessian { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override { - clone = std::unique_ptr( - new InterpolantVectorFunctionHessian(grid, alpha)); + void clone(std::unique_ptr& clone) const override { + clone = + std::unique_ptr(new InterpolantVectorFunctionHessian(grid, alpha)); } /** * @return coefficient matrix */ - const base::DataMatrix& getAlpha() const { - return alpha; - } + const base::DataMatrix& getAlpha() const { return alpha; } /** * @param alpha coefficient matrix */ - void setAlpha(const base::DataMatrix& alpha) { - this->alpha = alpha; - } + void setAlpha(const base::DataMatrix& alpha) { this->alpha = alpha; } protected: /// sparse grid @@ -119,8 +110,7 @@ class InterpolantVectorFunctionHessian : public VectorFunctionHessian { /// coefficient matrix base::DataMatrix alpha; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_VECTOR_INTERPOLANTVECTORFUNCTIONHESSIAN_HPP */ diff --git a/optimization/src/sgpp/optimization/function/vector/VectorFunction.hpp b/optimization/src/sgpp/optimization/function/vector/VectorFunction.hpp index 91c2703c79..35684ab37c 100644 --- a/optimization/src/sgpp/optimization/function/vector/VectorFunction.hpp +++ b/optimization/src/sgpp/optimization/function/vector/VectorFunction.hpp @@ -30,14 +30,12 @@ class VectorFunction { * @param d dimension of the domain * @param m number of components */ - VectorFunction(size_t d, size_t m) : d(d), m(m) { - } + VectorFunction(size_t d, size_t m) : d(d), m(m) {} /** * Destructor. */ - virtual ~VectorFunction() { - } + virtual ~VectorFunction() {} /** * Pure virtual method for calculating \f$g(\vec{x})\f$. @@ -45,22 +43,17 @@ class VectorFunction { * @param[in] x evaluation point \f$\vec{x} \in [0, 1]^d\f$ * @param[out] value \f$g(\vec{x})\f$ */ - virtual void eval(const base::DataVector& x, - base::DataVector& value) = 0; + virtual void eval(const base::DataVector& x, base::DataVector& value) = 0; /** * @return dimension \f$d\f$ of the domain */ - size_t getNumberOfParameters() const { - return d; - } + size_t getNumberOfParameters() const { return d; } /** * @return number \f$m\f$ of components */ - size_t getNumberOfComponents() const { - return m; - } + size_t getNumberOfComponents() const { return m; } /** * Pure virtual method for cloning the function. @@ -70,8 +63,7 @@ class VectorFunction { * * @param[out] clone pointer to cloned object */ - virtual void clone( - std::unique_ptr& clone) const = 0; + virtual void clone(std::unique_ptr& clone) const = 0; protected: /// dimension of the domain @@ -79,8 +71,7 @@ class VectorFunction { /// number of components size_t m; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_VECTOR_VECTORFUNCTION_HPP */ diff --git a/optimization/src/sgpp/optimization/function/vector/VectorFunctionGradient.hpp b/optimization/src/sgpp/optimization/function/vector/VectorFunctionGradient.hpp index 1b15b88253..8443355086 100644 --- a/optimization/src/sgpp/optimization/function/vector/VectorFunctionGradient.hpp +++ b/optimization/src/sgpp/optimization/function/vector/VectorFunctionGradient.hpp @@ -35,14 +35,12 @@ class VectorFunctionGradient { * @param d dimension of the domain * @param m number of components */ - VectorFunctionGradient(size_t d, size_t m) : d(d), m(m) { - } + VectorFunctionGradient(size_t d, size_t m) : d(d), m(m) {} /** * Destructor. */ - virtual ~VectorFunctionGradient() { - } + virtual ~VectorFunctionGradient() {} /** * Pure virtual method for calculating \f$g(\vec{x})\f$ @@ -53,23 +51,18 @@ class VectorFunctionGradient { * @param[out] gradient gradient \f$\nabla g(\vec{x}) \in * \mathbb{R}^{m \times d}\f$ */ - virtual void eval(const base::DataVector& x, - base::DataVector& value, + virtual void eval(const base::DataVector& x, base::DataVector& value, base::DataMatrix& gradient) = 0; /** * @return dimension \f$d\f$ of the domain */ - size_t getNumberOfParameters() const { - return d; - } + size_t getNumberOfParameters() const { return d; } /** * @return number \f$m\f$ of components */ - size_t getNumberOfComponents() const { - return m; - } + size_t getNumberOfComponents() const { return m; } /** * Pure virtual method for cloning the gradient. @@ -79,8 +72,7 @@ class VectorFunctionGradient { * * @param[out] clone pointer to cloned object */ - virtual void clone( - std::unique_ptr& clone) const = 0; + virtual void clone(std::unique_ptr& clone) const = 0; protected: /// dimension of the domain @@ -88,8 +80,7 @@ class VectorFunctionGradient { /// number of components size_t m; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_VECTOR_VECTORFUNCTIONGRADIENT_HPP */ diff --git a/optimization/src/sgpp/optimization/function/vector/VectorFunctionHessian.hpp b/optimization/src/sgpp/optimization/function/vector/VectorFunctionHessian.hpp index a8f89cfc09..f630dc0ebe 100644 --- a/optimization/src/sgpp/optimization/function/vector/VectorFunctionHessian.hpp +++ b/optimization/src/sgpp/optimization/function/vector/VectorFunctionHessian.hpp @@ -40,14 +40,12 @@ class VectorFunctionHessian { * @param d dimension of the domain * @param m number of components */ - VectorFunctionHessian(size_t d, size_t m) : d(d), m(m) { - } + VectorFunctionHessian(size_t d, size_t m) : d(d), m(m) {} /** * Destructor. */ - virtual ~VectorFunctionHessian() { - } + virtual ~VectorFunctionHessian() {} /** * Pure virtual method for calculating \f$g(\vec{x})\f$ @@ -61,24 +59,18 @@ class VectorFunctionHessian { * \f$\nabla^2 g_i(\vec{x}) \in * \mathbb{R}^{d \times d}\f$ */ - virtual void eval(const base::DataVector& x, - base::DataVector& value, - base::DataMatrix& gradient, + virtual void eval(const base::DataVector& x, base::DataVector& value, base::DataMatrix& gradient, std::vector& hessian) = 0; /** * @return dimension \f$d\f$ of the domain */ - size_t getNumberOfParameters() const { - return d; - } + size_t getNumberOfParameters() const { return d; } /** * @return number \f$m\f$ of components */ - size_t getNumberOfComponents() const { - return m; - } + size_t getNumberOfComponents() const { return m; } /** * Pure virtual method for cloning the Hessian. @@ -88,8 +80,7 @@ class VectorFunctionHessian { * * @param[out] clone pointer to cloned object */ - virtual void clone( - std::unique_ptr& clone) const = 0; + virtual void clone(std::unique_ptr& clone) const = 0; protected: /// dimension of the domain @@ -97,8 +88,7 @@ class VectorFunctionHessian { /// number of components size_t m; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_VECTOR_VECTORFUNCTIONHESSIAN_HPP */ diff --git a/optimization/src/sgpp/optimization/function/vector/WrapperVectorFunction.hpp b/optimization/src/sgpp/optimization/function/vector/WrapperVectorFunction.hpp index c274e9897e..6e2a1232fa 100644 --- a/optimization/src/sgpp/optimization/function/vector/WrapperVectorFunction.hpp +++ b/optimization/src/sgpp/optimization/function/vector/WrapperVectorFunction.hpp @@ -21,9 +21,7 @@ namespace optimization { */ class WrapperVectorFunction : public VectorFunction { public: - typedef std::function - FunctionEvalType; + typedef std::function FunctionEvalType; /** * Constructor. @@ -32,22 +30,18 @@ class WrapperVectorFunction : public VectorFunction { * @param m number of components * @param f function to be wrapped */ - WrapperVectorFunction(size_t d, size_t m, FunctionEvalType f) : - VectorFunction(d, m), f(f) { - } + WrapperVectorFunction(size_t d, size_t m, FunctionEvalType f) : VectorFunction(d, m), f(f) {} /** * Destructor. */ - virtual ~WrapperVectorFunction() override { - } + ~WrapperVectorFunction() override {} /** * @param[in] x evaluation point \f$\vec{x} \in [0, 1]^d\f$ * @param[out] value \f$g(\vec{x})\f$ */ - inline virtual void eval(const base::DataVector& x, - base::DataVector& value) override { + inline void eval(const base::DataVector& x, base::DataVector& value) override { f(x, value); } @@ -55,16 +49,14 @@ class WrapperVectorFunction : public VectorFunction { * @param[out] clone pointer to cloned object */ void clone(std::unique_ptr& clone) const override { - clone = std::unique_ptr( - new WrapperVectorFunction(d, m, f)); + clone = std::unique_ptr(new WrapperVectorFunction(d, m, f)); } protected: /// function to be wrapped FunctionEvalType f; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_VECTOR_WRAPPERVECTORFUNCTION_HPP */ diff --git a/optimization/src/sgpp/optimization/function/vector/WrapperVectorFunctionGradient.hpp b/optimization/src/sgpp/optimization/function/vector/WrapperVectorFunctionGradient.hpp index 60c79eb0d1..8f3fc7ff1e 100644 --- a/optimization/src/sgpp/optimization/function/vector/WrapperVectorFunctionGradient.hpp +++ b/optimization/src/sgpp/optimization/function/vector/WrapperVectorFunctionGradient.hpp @@ -22,10 +22,8 @@ namespace optimization { */ class WrapperVectorFunctionGradient : public VectorFunctionGradient { public: - typedef std::function - FunctionGradientEvalType; + typedef std::function + FunctionGradientEvalType; /** * Constructor. @@ -34,17 +32,13 @@ class WrapperVectorFunctionGradient : public VectorFunctionGradient { * @param m number of components * @param fGradient function gradient to be wrapped */ - WrapperVectorFunctionGradient(size_t d, - size_t m, - FunctionGradientEvalType fGradient) : - VectorFunctionGradient(d, m), fGradient(fGradient) { - } + WrapperVectorFunctionGradient(size_t d, size_t m, FunctionGradientEvalType fGradient) + : VectorFunctionGradient(d, m), fGradient(fGradient) {} /** * Destructor. */ - virtual ~WrapperVectorFunctionGradient() override { - } + ~WrapperVectorFunctionGradient() override {} /** * @param[in] x evaluation point \f$\vec{x} \in [0, 1]^d\f$ @@ -52,9 +46,8 @@ class WrapperVectorFunctionGradient : public VectorFunctionGradient { * @param[out] gradient Jacobian \f$\nabla g(\vec{x}) \in * \mathbb{R}^{m \times d}\f$ */ - inline virtual void eval(const base::DataVector& x, - base::DataVector& value, - base::DataMatrix& gradient) override { + inline void eval(const base::DataVector& x, base::DataVector& value, + base::DataMatrix& gradient) override { fGradient(x, value, gradient); } @@ -62,16 +55,15 @@ class WrapperVectorFunctionGradient : public VectorFunctionGradient { * @param[out] clone pointer to cloned object */ void clone(std::unique_ptr& clone) const override { - clone = std::unique_ptr( - new WrapperVectorFunctionGradient(d, m, fGradient)); + clone = + std::unique_ptr(new WrapperVectorFunctionGradient(d, m, fGradient)); } protected: /// function gradient to be wrapped FunctionGradientEvalType fGradient; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_VECTOR_WRAPPERVECTORFUNCTIONGRADIENT_HPP */ diff --git a/optimization/src/sgpp/optimization/function/vector/WrapperVectorFunctionHessian.hpp b/optimization/src/sgpp/optimization/function/vector/WrapperVectorFunctionHessian.hpp index 98b335b4df..7954b2d14a 100644 --- a/optimization/src/sgpp/optimization/function/vector/WrapperVectorFunctionHessian.hpp +++ b/optimization/src/sgpp/optimization/function/vector/WrapperVectorFunctionHessian.hpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace SGPP { namespace optimization { @@ -22,11 +23,8 @@ namespace optimization { */ class WrapperVectorFunctionHessian : public VectorFunctionHessian { public: - typedef std::function&)> - FunctionHessianEvalType; + typedef std::function&)> FunctionHessianEvalType; /** * Constructor. @@ -35,17 +33,13 @@ class WrapperVectorFunctionHessian : public VectorFunctionHessian { * @param m number of components * @param fHessian function gradient to be wrapped */ - WrapperVectorFunctionHessian(size_t d, - size_t m, - FunctionHessianEvalType fHessian) : - VectorFunctionHessian(d, m), fHessian(fHessian) { - } + WrapperVectorFunctionHessian(size_t d, size_t m, FunctionHessianEvalType fHessian) + : VectorFunctionHessian(d, m), fHessian(fHessian) {} /** * Destructor. */ - virtual ~WrapperVectorFunctionHessian() override { - } + ~WrapperVectorFunctionHessian() override {} /** * @param[in] x evaluation point \f$\vec{x} \in [0, 1]^d\f$ @@ -56,10 +50,9 @@ class WrapperVectorFunctionHessian : public VectorFunctionHessian { * \f$\nabla^2 g_i(\vec{x}) \in * \mathbb{R}^{d \times d}\f$ */ - inline virtual void eval(const base::DataVector& x, - base::DataVector& value, - base::DataMatrix& gradient, - std::vector& hessian) override { + inline void eval(const base::DataVector& x, base::DataVector& value, + base::DataMatrix& gradient, + std::vector& hessian) override { fHessian(x, value, gradient, hessian); } @@ -67,16 +60,15 @@ class WrapperVectorFunctionHessian : public VectorFunctionHessian { * @param[out] clone pointer to cloned object */ void clone(std::unique_ptr& clone) const override { - clone = std::unique_ptr( - new WrapperVectorFunctionHessian(d, m, fHessian)); + clone = + std::unique_ptr(new WrapperVectorFunctionHessian(d, m, fHessian)); } protected: /// function Hessian to be wrapped FunctionHessianEvalType fHessian; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_FUNCTION_VECTOR_WRAPPERVECTORFUNCTIONHESSIAN_HPP */ diff --git a/optimization/src/sgpp/optimization/gridgen/HashRefinementMultiple.hpp b/optimization/src/sgpp/optimization/gridgen/HashRefinementMultiple.hpp old mode 100755 new mode 100644 index 6bbb73e0d3..a80a4d8cea --- a/optimization/src/sgpp/optimization/gridgen/HashRefinementMultiple.hpp +++ b/optimization/src/sgpp/optimization/gridgen/HashRefinementMultiple.hpp @@ -52,9 +52,7 @@ class HashRefinementMultiple : public base::HashRefinement { * @param storage grid storage * @return number of refinable points */ - size_t getNumberOfRefinablePoints(base::GridStorage* storage) { - return storage->size(); - } + size_t getNumberOfRefinablePoints(base::GridStorage* storage) { return storage->size(); } /** * Refines a grid point in one dimension. @@ -64,8 +62,7 @@ class HashRefinementMultiple : public base::HashRefinement { * @param index index of the grid point * @param t dimension in which the refinement should take place */ - void refineGridpoint1D(base::GridStorage* storage, index_type& index, - size_t t) { + void refineGridpoint1D(base::GridStorage* storage, index_type& index, size_t t) { index_t sourceIndex, childIndex; level_t sourceLevel, childLevel; @@ -126,12 +123,9 @@ class HashRefinementMultiple : public base::HashRefinement { * @param maxValues the array where the corresponding indicator * values should be stored */ - void collectRefinablePoints( - base::GridStorage* storage, - base::RefinementFunctor* functor, - size_t refinementsNum, - size_t* maxIndices, - base::RefinementFunctor::value_type* maxValues) { + void collectRefinablePoints(base::GridStorage* storage, base::RefinementFunctor* functor, + size_t refinementsNum, size_t* maxIndices, + base::RefinementFunctor::value_type* maxValues) { size_t min_idx = 0; // max value equals min value @@ -141,10 +135,8 @@ class HashRefinementMultiple : public base::HashRefinement { base::GridStorage::grid_map_iterator end_iter = storage->end(); // start iterating over whole grid - for (base::GridStorage::grid_map_iterator iter = storage->begin(); - iter != end_iter; iter++) { - base::RefinementFunctor::value_type current_value = - (*functor)(storage, iter->second); + for (base::GridStorage::grid_map_iterator iter = storage->begin(); iter != end_iter; iter++) { + base::RefinementFunctor::value_type current_value = (*functor)(storage, iter->second); if (current_value > max_value) { // replace the minimal point in result array, @@ -157,8 +149,7 @@ class HashRefinementMultiple : public base::HashRefinement { } } }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_GRIDGEN_HASHREFINEMENTMULTIPLE_HPP */ diff --git a/optimization/src/sgpp/optimization/gridgen/IterativeGridGenerator.cpp b/optimization/src/sgpp/optimization/gridgen/IterativeGridGenerator.cpp index 3147b77861..f2475ef4b6 100644 --- a/optimization/src/sgpp/optimization/gridgen/IterativeGridGenerator.cpp +++ b/optimization/src/sgpp/optimization/gridgen/IterativeGridGenerator.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #ifdef _OPENMP #include #endif @@ -12,27 +10,20 @@ #include #include +#include +#include + namespace SGPP { namespace optimization { -IterativeGridGenerator::IterativeGridGenerator( - ScalarFunction& f, base::Grid& grid, size_t N) : - f(f), - grid(grid), - N(N), - functionValues(0) { -} +IterativeGridGenerator::IterativeGridGenerator(ScalarFunction& f, base::Grid& grid, size_t N) + : f(f), grid(grid), N(N), functionValues(0) {} -IterativeGridGenerator::~IterativeGridGenerator() { -} +IterativeGridGenerator::~IterativeGridGenerator() {} -base::Grid& IterativeGridGenerator::getGrid() const { - return grid; -} +base::Grid& IterativeGridGenerator::getGrid() const { return grid; } -const base::DataVector& IterativeGridGenerator::getFunctionValues() const { - return functionValues; -} +const base::DataVector& IterativeGridGenerator::getFunctionValues() const { return functionValues; } void IterativeGridGenerator::undoRefinement(size_t oldGridSize) { base::GridStorage& gridStorage = *grid.getStorage(); @@ -47,8 +38,7 @@ void IterativeGridGenerator::evalFunction(size_t oldGridSize) { const size_t curGridSize = gridStorage.size(); base::DataVector& fX = functionValues; - #pragma omp parallel shared(fX, oldGridSize, gridStorage) \ - default(none) +#pragma omp parallel shared(fX, oldGridSize, gridStorage) default(none) { base::GridIndex* gp; base::DataVector x(d); @@ -63,7 +53,7 @@ void IterativeGridGenerator::evalFunction(size_t oldGridSize) { #endif /* _OPENMP */ - #pragma omp for +#pragma omp for for (size_t i = oldGridSize; i < curGridSize; i++) { // convert grid point to coordinate vector @@ -78,6 +68,5 @@ void IterativeGridGenerator::evalFunction(size_t oldGridSize) { } } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/gridgen/IterativeGridGenerator.hpp b/optimization/src/sgpp/optimization/gridgen/IterativeGridGenerator.hpp index be291a24b2..335d1994af 100644 --- a/optimization/src/sgpp/optimization/gridgen/IterativeGridGenerator.hpp +++ b/optimization/src/sgpp/optimization/gridgen/IterativeGridGenerator.hpp @@ -6,14 +6,14 @@ #ifndef SGPP_OPTIMIZATION_GRIDGEN_ITERATIVEGRIDGENERATOR_HPP #define SGPP_OPTIMIZATION_GRIDGEN_ITERATIVEGRIDGENERATOR_HPP -#include - #include #include #include #include +#include + namespace SGPP { namespace optimization { @@ -30,8 +30,7 @@ class IterativeGridGenerator { * @param grid grid (should be empty) * @param N maximal number of grid points */ - IterativeGridGenerator( - ScalarFunction& f, base::Grid& grid, size_t N); + IterativeGridGenerator(ScalarFunction& f, base::Grid& grid, size_t N); /** * Destructor. @@ -83,8 +82,7 @@ class IterativeGridGenerator { */ void evalFunction(size_t oldGridSize = 0); }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_GRIDGEN_ITERATIVEGRIDGENERATOR_HPP */ diff --git a/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorLinearSurplus.cpp b/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorLinearSurplus.cpp index abf1256f29..d0c0b46c85 100644 --- a/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorLinearSurplus.cpp +++ b/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorLinearSurplus.cpp @@ -3,9 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include -#include - #include #include @@ -23,94 +20,84 @@ #include #include +#include +#include +#include +#include + namespace SGPP { namespace optimization { -IterativeGridGeneratorLinearSurplus::IterativeGridGeneratorLinearSurplus( - ScalarFunction& f, - base::Grid& grid, - size_t N, - float_t adaptivity, - base::level_t initialLevel) : - IterativeGridGenerator(f, grid, N), - gamma(adaptivity), - initialLevel(initialLevel) { - if ((grid.getType() == base::GridType::Bspline) - || (grid.getType() == base::GridType::Wavelet) - || (grid.getType() == base::GridType::Linear) - || (grid.getType() == base::GridType::FundamentalSpline)) { - linearGrid = std::unique_ptr( - new base::LinearGrid(f.getNumberOfParameters())); - } else if ((grid.getType() == base::GridType::BsplineBoundary) - || (grid.getType() == base::GridType::WaveletBoundary) - || (grid.getType() == base::GridType::LinearBoundary)) { - linearGrid = std::unique_ptr( - new base::LinearBoundaryGrid(f.getNumberOfParameters())); - } else if ((grid.getType() == base::GridType::BsplineClenshawCurtis) - || (grid.getType() == base::GridType::LinearClenshawCurtis)) { - linearGrid = std::unique_ptr( - new base::LinearClenshawCurtisGrid(f.getNumberOfParameters())); - } else if ((grid.getType() == base::GridType::ModBspline) - || (grid.getType() == base::GridType::ModWavelet) - || (grid.getType() == base::GridType::ModLinear) - || (grid.getType() == base::GridType::ModFundamentalSpline)) { - linearGrid = std::unique_ptr( - new base::ModLinearGrid(f.getNumberOfParameters())); +IterativeGridGeneratorLinearSurplus::IterativeGridGeneratorLinearSurplus(ScalarFunction& f, + base::Grid& grid, size_t N, + float_t adaptivity, + base::level_t initialLevel) + : IterativeGridGenerator(f, grid, N), gamma(adaptivity), initialLevel(initialLevel) { + if ((grid.getType() == base::GridType::Bspline) || (grid.getType() == base::GridType::Wavelet) || + (grid.getType() == base::GridType::Linear) || + (grid.getType() == base::GridType::FundamentalSpline)) { + linearGrid = std::unique_ptr(new base::LinearGrid(f.getNumberOfParameters())); + } else if ((grid.getType() == base::GridType::BsplineBoundary) || + (grid.getType() == base::GridType::WaveletBoundary) || + (grid.getType() == base::GridType::LinearBoundary)) { + linearGrid = + std::unique_ptr(new base::LinearBoundaryGrid(f.getNumberOfParameters())); + } else if ((grid.getType() == base::GridType::BsplineClenshawCurtis) || + (grid.getType() == base::GridType::LinearClenshawCurtis)) { + linearGrid = + std::unique_ptr(new base::LinearClenshawCurtisGrid(f.getNumberOfParameters())); + } else if ((grid.getType() == base::GridType::ModBspline) || + (grid.getType() == base::GridType::ModWavelet) || + (grid.getType() == base::GridType::ModLinear) || + (grid.getType() == base::GridType::ModFundamentalSpline)) { + linearGrid = std::unique_ptr(new base::ModLinearGrid(f.getNumberOfParameters())); } else if (grid.getType() == base::GridType::ModBsplineClenshawCurtis) { linearGrid = std::unique_ptr( - new base::ModBsplineClenshawCurtisGrid(f.getNumberOfParameters(), 1)); + new base::ModBsplineClenshawCurtisGrid(f.getNumberOfParameters(), 1)); } else { throw std::invalid_argument("Grid type not supported."); } } -IterativeGridGeneratorLinearSurplus::~IterativeGridGeneratorLinearSurplus() { -} +IterativeGridGeneratorLinearSurplus::~IterativeGridGeneratorLinearSurplus() {} -float_t IterativeGridGeneratorLinearSurplus::getAdaptivity() const { - return gamma; -} +float_t IterativeGridGeneratorLinearSurplus::getAdaptivity() const { return gamma; } void IterativeGridGeneratorLinearSurplus::setAdaptivity(float_t adaptivity) { this->gamma = adaptivity; } -base::level_t IterativeGridGeneratorLinearSurplus::getInitialLevel() const { - return initialLevel; -} +base::level_t IterativeGridGeneratorLinearSurplus::getInitialLevel() const { return initialLevel; } -void IterativeGridGeneratorLinearSurplus::setInitialLevel( - base::level_t initialLevel) { +void IterativeGridGeneratorLinearSurplus::setInitialLevel(base::level_t initialLevel) { this->initialLevel = initialLevel; } bool IterativeGridGeneratorLinearSurplus::generate() { Printer::getInstance().printStatusBegin("Adaptive grid generation (linear surplus)..."); - base::GridIndex::PointDistribution distr = - base::GridIndex::PointDistribution::Normal; + base::GridIndex::PointDistribution distr = base::GridIndex::PointDistribution::Normal; - if ((grid.getType() == base::GridType::BsplineClenshawCurtis) - || (grid.getType() == base::GridType::ModBsplineClenshawCurtis) - || (grid.getType() == base::GridType::LinearClenshawCurtis)) { + if ((grid.getType() == base::GridType::BsplineClenshawCurtis) || + (grid.getType() == base::GridType::ModBsplineClenshawCurtis) || + (grid.getType() == base::GridType::LinearClenshawCurtis)) { // Clenshaw-Curtis grid distr = base::GridIndex::PointDistribution::ClenshawCurtis; } std::unique_ptr abstractRefinement; - if ((grid.getType() == base::GridType::BsplineBoundary) - || (grid.getType() == base::GridType::WaveletBoundary) - || (grid.getType() == base::GridType::LinearBoundary) - || (grid.getType() == base::GridType::BsplineClenshawCurtis) - || (grid.getType() == base::GridType::LinearClenshawCurtis)) { + if ((grid.getType() == base::GridType::BsplineBoundary) || + (grid.getType() == base::GridType::WaveletBoundary) || + (grid.getType() == base::GridType::LinearBoundary) || + (grid.getType() == base::GridType::BsplineClenshawCurtis) || + (grid.getType() == base::GridType::LinearClenshawCurtis)) { // grid with boundaries - abstractRefinement = std::unique_ptr( - new base::HashRefinementBoundaries()); + abstractRefinement = + std::unique_ptr(new base::HashRefinementBoundaries()); } else { // grid without boundaries - abstractRefinement = std::unique_ptr( - new base::HashRefinement()); + abstractRefinement = std::unique_ptr(new base::HashRefinement()); } base::GridStorage& gridStorage = *grid.getStorage(); @@ -184,17 +171,16 @@ bool IterativeGridGeneratorLinearSurplus::generate() { // status printing { char str[10]; - snprintf(str, 10, "%.1f%%", + snprintf(str, sizeof(str), "%.1f%%", static_cast(currentN) / static_cast(N) * 100.0); - Printer::getInstance().printStatusUpdate( - std::string(str) + " (N = " + std::to_string(currentN) + ")"); + Printer::getInstance().printStatusUpdate(std::string(str) + " (N = " + + std::to_string(currentN) + ")"); } // calculate number of points to be refined - refinablePtsCount = abstractRefinement->getNumberOfRefinablePoints( - &gridStorage); - ptsToBeRefinedCount = static_cast(1.0 - + refineFactor * gamma * static_cast(refinablePtsCount)); + refinablePtsCount = abstractRefinement->getNumberOfRefinablePoints(&gridStorage); + ptsToBeRefinedCount = + static_cast(1.0 + refineFactor * gamma * static_cast(refinablePtsCount)); // refine base::SurplusRefinementFunctor refineFunc(&coeffs, ptsToBeRefinedCount); @@ -206,7 +192,7 @@ bool IterativeGridGeneratorLinearSurplus::generate() { if (newN == currentN) { // size unchanged ==> nothing refined (should not happen) Printer::getInstance().printStatusEnd( - "error: size unchanged in IterativeGridGeneratorLinearSurplus"); + "error: size unchanged in IterativeGridGeneratorLinearSurplus"); result = false; break; } @@ -255,14 +241,12 @@ bool IterativeGridGeneratorLinearSurplus::generate() { fX.resize(currentN); if (result) { - Printer::getInstance().printStatusUpdate("100.0% (N = " + std::to_string( - currentN) + ")"); + Printer::getInstance().printStatusUpdate("100.0% (N = " + std::to_string(currentN) + ")"); Printer::getInstance().printStatusEnd(); return true; } else { return false; } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorLinearSurplus.hpp b/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorLinearSurplus.hpp index ec72443338..50fc4ed2c9 100644 --- a/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorLinearSurplus.hpp +++ b/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorLinearSurplus.hpp @@ -6,12 +6,11 @@ #ifndef SGPP_OPTIMIZATION_GRIDGEN_ITERATIVEGRIDGENERATORLINEARSURPLUS_HPP #define SGPP_OPTIMIZATION_GRIDGEN_ITERATIVEGRIDGENERATORLINEARSURPLUS_HPP -#include - #include - #include +#include + namespace SGPP { namespace optimization { @@ -39,12 +38,9 @@ class IterativeGridGeneratorLinearSurplus : public IterativeGridGenerator { * @param adaptivity adaptivity between 0 and 1 * @param initialLevel level of initial regular sparse grid */ - IterativeGridGeneratorLinearSurplus( - ScalarFunction& f, - base::Grid& grid, - size_t N, - float_t adaptivity = DEFAULT_ADAPTIVITY, - base::level_t initialLevel = DEFAULT_INITIAL_LEVEL); + IterativeGridGeneratorLinearSurplus(ScalarFunction& f, base::Grid& grid, size_t N, + float_t adaptivity = DEFAULT_ADAPTIVITY, + base::level_t initialLevel = DEFAULT_INITIAL_LEVEL); /** * Destructor. @@ -86,8 +82,7 @@ class IterativeGridGeneratorLinearSurplus : public IterativeGridGenerator { /// level of initial regular sparse grid base::level_t initialLevel; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_GRIDGEN_ITERATIVEGRIDGENERATORLINEARSURPLUS_HPP */ diff --git a/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorRitterNovak.cpp b/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorRitterNovak.cpp index dad0bacc09..ed11ba2442 100644 --- a/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorRitterNovak.cpp +++ b/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorRitterNovak.cpp @@ -3,9 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include -#include - #include #include @@ -13,6 +10,12 @@ #include #include +#include +#include +#include +#include +#include + namespace SGPP { namespace optimization { @@ -30,63 +33,48 @@ inline double fastPow(double a, double b) { int x[2]; } u = {a}; - u.x[1] = static_cast( - b * static_cast(u.x[1] - 1072632447) + 1072632447); + u.x[1] = static_cast(b * static_cast(u.x[1] - 1072632447) + 1072632447); u.x[0] = 0; return u.d; } IterativeGridGeneratorRitterNovak::IterativeGridGeneratorRitterNovak( - ScalarFunction& f, - base::Grid& grid, - size_t N, - float_t adaptivity, - base::level_t initialLevel, - base::level_t maxLevel, - PowMethod powMethod) : - IterativeGridGenerator(f, grid, N), - gamma(adaptivity), - initialLevel(initialLevel), - maxLevel(maxLevel), - powMethod(powMethod) { -} + ScalarFunction& f, base::Grid& grid, size_t N, float_t adaptivity, base::level_t initialLevel, + base::level_t maxLevel, PowMethod powMethod) + : IterativeGridGenerator(f, grid, N), + gamma(adaptivity), + initialLevel(initialLevel), + maxLevel(maxLevel), + powMethod(powMethod) {} -IterativeGridGeneratorRitterNovak::~IterativeGridGeneratorRitterNovak() { -} +IterativeGridGeneratorRitterNovak::~IterativeGridGeneratorRitterNovak() {} -float_t IterativeGridGeneratorRitterNovak::getAdaptivity() const { - return gamma; -} +float_t IterativeGridGeneratorRitterNovak::getAdaptivity() const { return gamma; } void IterativeGridGeneratorRitterNovak::setAdaptivity(float_t adaptivity) { this->gamma = adaptivity; } -base::level_t IterativeGridGeneratorRitterNovak::getInitialLevel() const { - return initialLevel; -} +base::level_t IterativeGridGeneratorRitterNovak::getInitialLevel() const { return initialLevel; } -void IterativeGridGeneratorRitterNovak::setInitialLevel( - base::level_t initialLevel) { +void IterativeGridGeneratorRitterNovak::setInitialLevel(base::level_t initialLevel) { this->initialLevel = initialLevel; } -base::level_t IterativeGridGeneratorRitterNovak::getMaxLevel() const { - return maxLevel; -} +base::level_t IterativeGridGeneratorRitterNovak::getMaxLevel() const { return maxLevel; } void IterativeGridGeneratorRitterNovak::setMaxLevel(base::level_t maxLevel) { this->maxLevel = maxLevel; } -IterativeGridGeneratorRitterNovak::PowMethod -IterativeGridGeneratorRitterNovak::getPowMethod() const { +IterativeGridGeneratorRitterNovak::PowMethod IterativeGridGeneratorRitterNovak::getPowMethod() + const { return powMethod; } void IterativeGridGeneratorRitterNovak::setPowMethod( - IterativeGridGeneratorRitterNovak::PowMethod powMethod) { + IterativeGridGeneratorRitterNovak::PowMethod powMethod) { this->powMethod = powMethod; } @@ -94,8 +82,7 @@ bool IterativeGridGeneratorRitterNovak::generate() { Printer::getInstance().printStatusBegin("Adaptive grid generation (Ritter-Novak)..."); bool result = true; - base::GridIndex::PointDistribution distr = - base::GridIndex::PointDistribution::Normal; + base::GridIndex::PointDistribution distr = base::GridIndex::PointDistribution::Normal; base::GridStorage& gridStorage = *grid.getStorage(); const size_t d = f.getNumberOfParameters(); @@ -110,8 +97,7 @@ bool IterativeGridGeneratorRitterNovak::generate() { // generate initial grid { - std::unique_ptr gridGen( - grid.createGridGenerator()); + std::unique_ptr gridGen(grid.createGridGenerator()); gridGen->regular(initialLevel); } @@ -162,13 +148,9 @@ bool IterativeGridGeneratorRitterNovak::generate() { // determine fXOrder and rank (prepared above) std::sort(fXOrder.begin(), fXOrder.begin() + currentN, - [&](size_t a, size_t b) { - return (fX[a] < fX[b]); - }); + [&fX](size_t a, size_t b) { return (fX[a] < fX[b]); }); std::sort(rank.begin(), rank.begin() + currentN, - [&](size_t a, size_t b) { - return (fXOrder[a - 1] < fXOrder[b - 1]); - }); + [&fXOrder](size_t a, size_t b) { return (fXOrder[a - 1] < fXOrder[b - 1]); }); // determine fXSorted for (size_t i = 0; i < currentN; i++) { @@ -182,12 +164,11 @@ bool IterativeGridGeneratorRitterNovak::generate() { // status printing { char str[10]; - snprintf(str, 10, "%.1f%%", - static_cast(currentN) / - static_cast(N) * 100.0); - Printer::getInstance().printStatusUpdate(std::string(str) + - " (N = " + std::to_string(currentN) + - ", k = " + std::to_string(k) + ")"); + snprintf(str, sizeof(str), + "%.1f%%", static_cast(currentN) / static_cast(N) * 100.0); + Printer::getInstance().printStatusUpdate(std::string(str) + " (N = " + + std::to_string(currentN) + ", k = " + + std::to_string(k) + ")"); } // determine the best i (i.e. i_best = argmin_i g_i) @@ -203,12 +184,10 @@ bool IterativeGridGeneratorRitterNovak::generate() { float_t g; if (powMethod == STD_POW) { - g = std::pow(static_cast(levelSum[i] + degree[i]) + 1.0, - gamma) * + g = std::pow(static_cast(levelSum[i] + degree[i]) + 1.0, gamma) * std::pow(static_cast(rank[i]) + 1.0, 1.0 - gamma); } else { - g = fastPow(static_cast(levelSum[i] + degree[i]) + 1.0, - gamma) * + g = fastPow(static_cast(levelSum[i] + degree[i]) + 1.0, gamma) * fastPow(static_cast(rank[i]) + 1.0, 1.0 - gamma); } @@ -290,7 +269,7 @@ bool IterativeGridGeneratorRitterNovak::generate() { if (newN == currentN) { // size unchanged ==> point not refined (should not happen) Printer::getInstance().printStatusEnd( - "error: size unchanged in IterativeGridGeneratorRitterNovak"); + "error: size unchanged in IterativeGridGeneratorRitterNovak"); result = false; break; } @@ -326,7 +305,7 @@ bool IterativeGridGeneratorRitterNovak::generate() { // update rank and fXOrder by insertion sort // ==> go through fX from greatest entry to lowest - for (size_t j = i; j-- > 0; ) { + for (size_t j = i; j-- > 0;) { if (fXSorted[j] < fXi) { // new function value is greater than current one ==> insert here fXOrder.insert(fXOrder.begin() + (j + 1), i); @@ -358,15 +337,13 @@ bool IterativeGridGeneratorRitterNovak::generate() { fX.resize(currentN); if (result) { - Printer::getInstance().printStatusUpdate("100.0% (N = " + std::to_string( - currentN) + - ", k = " + std::to_string(k) + ")"); + Printer::getInstance().printStatusUpdate("100.0% (N = " + std::to_string(currentN) + ", k = " + + std::to_string(k) + ")"); Printer::getInstance().printStatusEnd(); return true; } else { return false; } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorRitterNovak.hpp b/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorRitterNovak.hpp index 927922a9d8..5cd8a7316d 100644 --- a/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorRitterNovak.hpp +++ b/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorRitterNovak.hpp @@ -6,13 +6,12 @@ #ifndef SGPP_OPTIMIZATION_GRIDGEN_ITERATIVEGRIDGENERATORRITTERNOVAK_HPP #define SGPP_OPTIMIZATION_GRIDGEN_ITERATIVEGRIDGENERATORRITTERNOVAK_HPP -#include - #include - #include #include +#include + namespace SGPP { namespace optimization { @@ -40,9 +39,7 @@ class IterativeGridGeneratorRitterNovak : public IterativeGridGenerator { static const base::level_t DEFAULT_MAX_LEVEL = 20; /// exponentiation methods - enum PowMethod { - STD_POW, FAST_POW - }; + enum PowMethod { STD_POW, FAST_POW }; /** * Constructor. @@ -58,14 +55,11 @@ class IterativeGridGeneratorRitterNovak : public IterativeGridGenerator { * (fastPow is faster than std::pow, * but only approximative) */ - IterativeGridGeneratorRitterNovak( - ScalarFunction& f, - base::Grid& grid, - size_t N, - float_t adaptivity = DEFAULT_ADAPTIVITY, - base::level_t initialLevel = DEFAULT_INITIAL_LEVEL, - base::level_t maxLevel = DEFAULT_MAX_LEVEL, - PowMethod powMethod = STD_POW); + IterativeGridGeneratorRitterNovak(ScalarFunction& f, base::Grid& grid, size_t N, + float_t adaptivity = DEFAULT_ADAPTIVITY, + base::level_t initialLevel = DEFAULT_INITIAL_LEVEL, + base::level_t maxLevel = DEFAULT_MAX_LEVEL, + PowMethod powMethod = STD_POW); /** * Destructor. @@ -129,8 +123,7 @@ class IterativeGridGeneratorRitterNovak : public IterativeGridGenerator { /// exponentiation method PowMethod powMethod; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_GRIDGEN_ITERATIVEGRIDGENERATORRITTERNOVAK_HPP */ diff --git a/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorSOO.cpp b/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorSOO.cpp index de7031674b..0504385473 100644 --- a/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorSOO.cpp +++ b/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorSOO.cpp @@ -3,9 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include -#include - #include #include @@ -13,32 +10,33 @@ #include #include +#include +#include +#include +#include +#include + namespace SGPP { namespace optimization { -IterativeGridGeneratorSOO::IterativeGridGeneratorSOO( - ScalarFunction& f, base::Grid& grid, size_t N, - float_t adaptivity) : - IterativeGridGenerator(f, grid, N) { +IterativeGridGeneratorSOO::IterativeGridGeneratorSOO(ScalarFunction& f, base::Grid& grid, size_t N, + float_t adaptivity) + : IterativeGridGenerator(f, grid, N) { setAdaptivity(adaptivity); } -IterativeGridGeneratorSOO::~IterativeGridGeneratorSOO() { -} +IterativeGridGeneratorSOO::~IterativeGridGeneratorSOO() {} -IterativeGridGeneratorSOO::AdaptivityFunction -IterativeGridGeneratorSOO::getAdaptivity() const { +IterativeGridGeneratorSOO::AdaptivityFunction IterativeGridGeneratorSOO::getAdaptivity() const { return hMax; } void IterativeGridGeneratorSOO::setAdaptivity(float_t adaptivity) { - hMax = [adaptivity](size_t n) { - return static_cast(std::pow(n, adaptivity)); - }; + hMax = [adaptivity](size_t n) { return static_cast(std::pow(n, adaptivity)); }; } void IterativeGridGeneratorSOO::setAdaptivity( - IterativeGridGeneratorSOO::AdaptivityFunction adaptivity) { + IterativeGridGeneratorSOO::AdaptivityFunction adaptivity) { hMax = adaptivity; } @@ -46,8 +44,7 @@ bool IterativeGridGeneratorSOO::generate() { Printer::getInstance().printStatusBegin("Adaptive grid generation (SOO)..."); bool result = true; - base::GridIndex::PointDistribution distr = - base::GridIndex::PointDistribution::Normal; + base::GridIndex::PointDistribution distr = base::GridIndex::PointDistribution::Normal; base::GridStorage& gridStorage = *grid.getStorage(); const size_t d = f.getNumberOfParameters(); @@ -107,17 +104,15 @@ bool IterativeGridGeneratorSOO::generate() { // status printing { char str[10]; - snprintf(str, 10, "%.1f%%", - static_cast(currentN) / - static_cast(N) * 100.0); - Printer::getInstance().printStatusUpdate(std::string(str) + - " (N = " + std::to_string(currentN) + - ", k = " + std::to_string(k) + ")"); + snprintf(str, sizeof(str), "%.1f%%", + static_cast(currentN) / static_cast(N) * 100.0); + Printer::getInstance().printStatusUpdate(std::string(str) + " (N = " + + std::to_string(currentN) + ", k = " + + std::to_string(k) + ")"); } const size_t curDepthBound = - std::min(depthMap.size() - 1, - static_cast(hMax(n)) + depthBoundOffset); + std::min(depthMap.size() - 1, static_cast(hMax(n)) + depthBoundOffset); float_t nuMin = INFINITY; for (size_t depth = 0; depth <= curDepthBound; depth++) { @@ -142,7 +137,7 @@ bool IterativeGridGeneratorSOO::generate() { if (newN == currentN) { // size unchanged ==> point not refined (should not happen) Printer::getInstance().printStatusEnd( - "error: size unchanged in IterativeGridGeneratorSOO"); + "error: size unchanged in IterativeGridGeneratorSOO"); result = false; breakLoop = true; break; @@ -204,15 +199,13 @@ bool IterativeGridGeneratorSOO::generate() { fX.resize(currentN); if (result) { - Printer::getInstance().printStatusUpdate("100.0% (N = " + std::to_string( - currentN) + - ", k = " + std::to_string(k) + ")"); + Printer::getInstance().printStatusUpdate("100.0% (N = " + std::to_string(currentN) + ", k = " + + std::to_string(k) + ")"); Printer::getInstance().printStatusEnd(); return true; } else { return false; } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorSOO.hpp b/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorSOO.hpp index e77d2e5b99..0840a0364e 100644 --- a/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorSOO.hpp +++ b/optimization/src/sgpp/optimization/gridgen/IterativeGridGeneratorSOO.hpp @@ -6,12 +6,12 @@ #ifndef SGPP_OPTIMIZATION_GRIDGEN_ITERATIVEGRIDGENERATORSOO_HPP #define SGPP_OPTIMIZATION_GRIDGEN_ITERATIVEGRIDGENERATORSOO_HPP -#include -#include - #include #include +#include +#include + namespace SGPP { namespace optimization { @@ -35,9 +35,7 @@ class IterativeGridGeneratorSOO : public IterativeGridGenerator { * @param N maximal number of grid points * @param adaptivity adaptivity (positive number) */ - IterativeGridGeneratorSOO(ScalarFunction& f, - base::Grid& grid, - size_t N, + IterativeGridGeneratorSOO(ScalarFunction& f, base::Grid& grid, size_t N, float_t adaptivity = DEFAULT_ADAPTIVITY); /** @@ -73,8 +71,7 @@ class IterativeGridGeneratorSOO : public IterativeGridGenerator { /// adaptivity AdaptivityFunction hMax; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_GRIDGEN_ITERATIVEGRIDGENERATORSOO_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/OptimizationOpFactory.cpp b/optimization/src/sgpp/optimization/operation/OptimizationOpFactory.cpp old mode 100755 new mode 100644 index 053e4d268a..f33a6e3f6b --- a/optimization/src/sgpp/optimization/operation/OptimizationOpFactory.cpp +++ b/optimization/src/sgpp/optimization/operation/OptimizationOpFactory.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -40,59 +38,59 @@ #include #include +#include + namespace SGPP { namespace op_factory { -optimization::OperationMultipleHierarchisation* -createOperationMultipleHierarchisation(base::Grid& grid) { +optimization::OperationMultipleHierarchisation* createOperationMultipleHierarchisation( + base::Grid& grid) { if (grid.getType() == base::GridType::Linear) { return new optimization::OperationMultipleHierarchisationLinear( - dynamic_cast(grid)); + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::LinearBoundary) { return new optimization::OperationMultipleHierarchisationLinearBoundary( - dynamic_cast(grid)); + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::LinearClenshawCurtis) { return new optimization::OperationMultipleHierarchisationLinearClenshawCurtis( - dynamic_cast(grid)); + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::ModLinear) { return new optimization::OperationMultipleHierarchisationModLinear( - dynamic_cast(grid)); + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::Bspline) { return new optimization::OperationMultipleHierarchisationBspline( - dynamic_cast(grid)); + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::BsplineBoundary) { return new optimization::OperationMultipleHierarchisationBsplineBoundary( - dynamic_cast(grid)); + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::BsplineClenshawCurtis) { return new optimization::OperationMultipleHierarchisationBsplineClenshawCurtis( - dynamic_cast(grid)); + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::ModBspline) { return new optimization::OperationMultipleHierarchisationModBspline( - dynamic_cast(grid)); + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::ModBsplineClenshawCurtis) { - return new - optimization::OperationMultipleHierarchisationModBsplineClenshawCurtis( - dynamic_cast(grid)); + return new optimization::OperationMultipleHierarchisationModBsplineClenshawCurtis( + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::Wavelet) { return new optimization::OperationMultipleHierarchisationWavelet( - dynamic_cast(grid)); + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::WaveletBoundary) { return new optimization::OperationMultipleHierarchisationWaveletBoundary( - dynamic_cast(grid)); + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::ModWavelet) { return new optimization::OperationMultipleHierarchisationModWavelet( - dynamic_cast(grid)); + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::FundamentalSpline) { return new optimization::OperationMultipleHierarchisationFundamentalSpline( - dynamic_cast(grid)); + dynamic_cast(grid)); } else if (grid.getType() == base::GridType::ModFundamentalSpline) { return new optimization::OperationMultipleHierarchisationModFundamentalSpline( - dynamic_cast(grid)); + dynamic_cast(grid)); } else { throw base::factory_exception( - "OperationMultipleHierarchisation is not implemented for this grid type."); + "OperationMultipleHierarchisation is not implemented for this grid type."); } } - -} -} +} // namespace op_factory +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/OptimizationOpFactory.hpp b/optimization/src/sgpp/optimization/operation/OptimizationOpFactory.hpp old mode 100755 new mode 100644 index a791246266..93fd8d1dcb --- a/optimization/src/sgpp/optimization/operation/OptimizationOpFactory.hpp +++ b/optimization/src/sgpp/optimization/operation/OptimizationOpFactory.hpp @@ -23,10 +23,9 @@ namespace op_factory { * @return pointer to a OperationMultipleHierarchisation object * for the grid */ -optimization::OperationMultipleHierarchisation* -createOperationMultipleHierarchisation(base::Grid& grid); - -} -} +optimization::OperationMultipleHierarchisation* createOperationMultipleHierarchisation( + base::Grid& grid); +} // namespace op_factory +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPERATION_OPERATIONOPFACTORY_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisation.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisation.hpp old mode 100755 new mode 100644 index 3243ce2842..26330732a4 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisation.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisation.hpp @@ -3,10 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATION_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATION_HPP - -#include +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIER_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIER_HPP #include @@ -14,6 +12,8 @@ #include #include +#include + namespace SGPP { namespace optimization { @@ -26,14 +26,12 @@ class OperationMultipleHierarchisation { /** * Constructor. */ - OperationMultipleHierarchisation() { - } + OperationMultipleHierarchisation() {} /** * Destructor. */ - virtual ~OperationMultipleHierarchisation() { - } + virtual ~OperationMultipleHierarchisation() {} /** * Virtual method for hierarchizing for one set of function values. @@ -75,8 +73,7 @@ class OperationMultipleHierarchisation { */ virtual void doDehierarchisation(base::DataMatrix& alpha) = 0; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATION_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIER_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBspline.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBspline.cpp old mode 100755 new mode 100644 index ad96c826c7..cf2f12c29a --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBspline.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBspline.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -16,23 +14,19 @@ namespace SGPP { namespace optimization { OperationMultipleHierarchisationBspline::OperationMultipleHierarchisationBspline( - base::BsplineGrid& grid) : - grid(grid) { -} + base::BsplineGrid& grid) + : grid(grid) {} -OperationMultipleHierarchisationBspline::~OperationMultipleHierarchisationBspline() { -} +OperationMultipleHierarchisationBspline::~OperationMultipleHierarchisationBspline() {} -bool OperationMultipleHierarchisationBspline::doHierarchisation( - base::DataVector& nodeValues) { +bool OperationMultipleHierarchisationBspline::doHierarchisation(base::DataVector& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataVector b(nodeValues); return solver.solve(system, b, nodeValues); } -void OperationMultipleHierarchisationBspline::doDehierarchisation( - base::DataVector& alpha) { +void OperationMultipleHierarchisationBspline::doDehierarchisation(base::DataVector& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalBspline opNaiveEval(&storage, grid.getDegree()); @@ -53,16 +47,14 @@ void OperationMultipleHierarchisationBspline::doDehierarchisation( alpha = nodeValues; } -bool OperationMultipleHierarchisationBspline::doHierarchisation( - base::DataMatrix& nodeValues) { +bool OperationMultipleHierarchisationBspline::doHierarchisation(base::DataMatrix& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataMatrix B(nodeValues); return solver.solve(system, B, nodeValues); } -void OperationMultipleHierarchisationBspline::doDehierarchisation( - base::DataMatrix& alpha) { +void OperationMultipleHierarchisationBspline::doDehierarchisation(base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalBspline opNaiveEval(&storage, grid.getDegree()); @@ -86,6 +78,5 @@ void OperationMultipleHierarchisationBspline::doDehierarchisation( alpha.setColumn(i, nodeValues); } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBspline.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBspline.hpp old mode 100755 new mode 100644 index a90a6114ae..9b6f98ba73 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBspline.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBspline.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONBSPLINE_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONBSPLINE_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERBSPLINE_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERBSPLINE_HPP #include @@ -19,15 +19,14 @@ namespace optimization { * Hierarchisation operation for B-spline basis functions on * Noboundary grids. */ -class OperationMultipleHierarchisationBspline : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationBspline : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationBspline(base::BsplineGrid& grid); + explicit OperationMultipleHierarchisationBspline(base::BsplineGrid& grid); /** * Destructor. @@ -68,8 +67,7 @@ class OperationMultipleHierarchisationBspline : /// storage of the sparse grid base::BsplineGrid& grid; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONBSPLINE_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERBSPLINE_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineBoundary.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineBoundary.cpp old mode 100755 new mode 100644 index 410ebb0e54..5c845c06f8 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineBoundary.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineBoundary.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -16,23 +14,21 @@ namespace SGPP { namespace optimization { OperationMultipleHierarchisationBsplineBoundary::OperationMultipleHierarchisationBsplineBoundary( - base::BsplineBoundaryGrid& grid) : - grid(grid) { -} + base::BsplineBoundaryGrid& grid) + : grid(grid) {} -OperationMultipleHierarchisationBsplineBoundary::~OperationMultipleHierarchisationBsplineBoundary() { -} +OperationMultipleHierarchisationBsplineBoundary:: + ~OperationMultipleHierarchisationBsplineBoundary() {} bool OperationMultipleHierarchisationBsplineBoundary::doHierarchisation( - base::DataVector& nodeValues) { + base::DataVector& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataVector b(nodeValues); return solver.solve(system, b, nodeValues); } -void OperationMultipleHierarchisationBsplineBoundary::doDehierarchisation( - base::DataVector& alpha) { +void OperationMultipleHierarchisationBsplineBoundary::doDehierarchisation(base::DataVector& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalBsplineBoundary opNaiveEval(&storage, grid.getDegree()); @@ -54,15 +50,14 @@ void OperationMultipleHierarchisationBsplineBoundary::doDehierarchisation( } bool OperationMultipleHierarchisationBsplineBoundary::doHierarchisation( - base::DataMatrix& nodeValues) { + base::DataMatrix& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataMatrix B(nodeValues); return solver.solve(system, B, nodeValues); } -void OperationMultipleHierarchisationBsplineBoundary::doDehierarchisation( - base::DataMatrix& alpha) { +void OperationMultipleHierarchisationBsplineBoundary::doDehierarchisation(base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalBsplineBoundary opNaiveEval(&storage, grid.getDegree()); @@ -86,6 +81,5 @@ void OperationMultipleHierarchisationBsplineBoundary::doDehierarchisation( alpha.setColumn(i, nodeValues); } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineBoundary.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineBoundary.hpp old mode 100755 new mode 100644 index c0cb09ee1b..1991ac2aa9 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineBoundary.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineBoundary.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONBSPLINEBOUNDARY_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONBSPLINEBOUNDARY_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERBSPLINEBOUNDARY_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERBSPLINEBOUNDARY_HPP #include @@ -19,16 +19,14 @@ namespace optimization { * Hierarchisation operation for B-spline basis functions on * Boundary grids. */ -class OperationMultipleHierarchisationBsplineBoundary : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationBsplineBoundary : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationBsplineBoundary( - base::BsplineBoundaryGrid& grid); + explicit OperationMultipleHierarchisationBsplineBoundary(base::BsplineBoundaryGrid& grid); /** * Destructor. @@ -69,8 +67,7 @@ class OperationMultipleHierarchisationBsplineBoundary : /// storage of the sparse grid base::BsplineBoundaryGrid& grid; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONBSPLINEBOUNDARY_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERBSPLINEBOUNDARY_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineClenshawCurtis.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineClenshawCurtis.cpp old mode 100755 new mode 100644 index b8a1082a93..077550dc9e --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineClenshawCurtis.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineClenshawCurtis.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -15,16 +13,15 @@ namespace SGPP { namespace optimization { -OperationMultipleHierarchisationBsplineClenshawCurtis::OperationMultipleHierarchisationBsplineClenshawCurtis( - base::BsplineClenshawCurtisGrid& grid) : - grid(grid) { -} +OperationMultipleHierarchisationBsplineClenshawCurtis:: + OperationMultipleHierarchisationBsplineClenshawCurtis(base::BsplineClenshawCurtisGrid& grid) + : grid(grid) {} -OperationMultipleHierarchisationBsplineClenshawCurtis::~OperationMultipleHierarchisationBsplineClenshawCurtis() { -} +OperationMultipleHierarchisationBsplineClenshawCurtis:: + ~OperationMultipleHierarchisationBsplineClenshawCurtis() {} bool OperationMultipleHierarchisationBsplineClenshawCurtis::doHierarchisation( - base::DataVector& nodeValues) { + base::DataVector& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataVector b(nodeValues); @@ -32,11 +29,10 @@ bool OperationMultipleHierarchisationBsplineClenshawCurtis::doHierarchisation( } void OperationMultipleHierarchisationBsplineClenshawCurtis::doDehierarchisation( - base::DataVector& alpha) { + base::DataVector& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); - base::OperationNaiveEvalBsplineClenshawCurtis opNaiveEval(&storage, - grid.getDegree()); + base::OperationNaiveEvalBsplineClenshawCurtis opNaiveEval(&storage, grid.getDegree()); base::DataVector nodeValues(storage.size()); base::DataVector x(d, 0.0); @@ -55,7 +51,7 @@ void OperationMultipleHierarchisationBsplineClenshawCurtis::doDehierarchisation( } bool OperationMultipleHierarchisationBsplineClenshawCurtis::doHierarchisation( - base::DataMatrix& nodeValues) { + base::DataMatrix& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataMatrix B(nodeValues); @@ -63,11 +59,10 @@ bool OperationMultipleHierarchisationBsplineClenshawCurtis::doHierarchisation( } void OperationMultipleHierarchisationBsplineClenshawCurtis::doDehierarchisation( - base::DataMatrix& alpha) { + base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); - base::OperationNaiveEvalBsplineClenshawCurtis opNaiveEval(&storage, - grid.getDegree()); + base::OperationNaiveEvalBsplineClenshawCurtis opNaiveEval(&storage, grid.getDegree()); base::DataVector nodeValues(storage.size(), 0.0); base::DataVector x(d, 0.0); base::DataVector alpha1(storage.size(), 0.0); @@ -88,6 +83,5 @@ void OperationMultipleHierarchisationBsplineClenshawCurtis::doDehierarchisation( alpha.setColumn(i, nodeValues); } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineClenshawCurtis.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineClenshawCurtis.hpp old mode 100755 new mode 100644 index ff2ccb384f..790cd90bc5 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineClenshawCurtis.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationBsplineClenshawCurtis.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONBSPLINECLENSHAWCURTIS_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONBSPLINECLENSHAWCURTIS_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERBSPLINECLENSHAWCURTIS_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERBSPLINECLENSHAWCURTIS_HPP #include @@ -19,16 +19,16 @@ namespace optimization { * Hierarchisation operation for B-spline basis functions on * Clenshaw-Curtis grids. */ -class OperationMultipleHierarchisationBsplineClenshawCurtis : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationBsplineClenshawCurtis + : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationBsplineClenshawCurtis( - base::BsplineClenshawCurtisGrid& grid); + explicit OperationMultipleHierarchisationBsplineClenshawCurtis( + base::BsplineClenshawCurtisGrid& grid); /** * Destructor. @@ -69,8 +69,7 @@ class OperationMultipleHierarchisationBsplineClenshawCurtis : /// storage of the sparse grid base::BsplineClenshawCurtisGrid& grid; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONBSPLINECLENSHAWCURTIS_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERBSPLINECLENSHAWCURTIS_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationFundamentalSpline.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationFundamentalSpline.cpp old mode 100755 new mode 100644 index b8f3df64e4..9f61acb0ce --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationFundamentalSpline.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationFundamentalSpline.cpp @@ -11,16 +11,15 @@ namespace SGPP { namespace optimization { -OperationMultipleHierarchisationFundamentalSpline::OperationMultipleHierarchisationFundamentalSpline( - base::FundamentalSplineGrid& grid) : - grid(grid), op(&grid) { -} +OperationMultipleHierarchisationFundamentalSpline:: + OperationMultipleHierarchisationFundamentalSpline(base::FundamentalSplineGrid& grid) + : grid(grid), op(&grid) {} -OperationMultipleHierarchisationFundamentalSpline::~OperationMultipleHierarchisationFundamentalSpline() { -} +OperationMultipleHierarchisationFundamentalSpline:: + ~OperationMultipleHierarchisationFundamentalSpline() {} bool OperationMultipleHierarchisationFundamentalSpline::doHierarchisation( - base::DataVector& nodeValues) { + base::DataVector& nodeValues) { Printer::getInstance().printStatusBegin("Hierarchization (BFS)..."); op.doHierarchisation(nodeValues); Printer::getInstance().printStatusEnd(); @@ -28,14 +27,14 @@ bool OperationMultipleHierarchisationFundamentalSpline::doHierarchisation( } void OperationMultipleHierarchisationFundamentalSpline::doDehierarchisation( - base::DataVector& alpha) { + base::DataVector& alpha) { Printer::getInstance().printStatusBegin("Dehierarchization (BFS)..."); op.doDehierarchisation(alpha); Printer::getInstance().printStatusEnd(); } bool OperationMultipleHierarchisationFundamentalSpline::doHierarchisation( - base::DataMatrix& nodeValues) { + base::DataMatrix& nodeValues) { Printer::getInstance().printStatusBegin("Hierarchization (BFS)..."); op.doHierarchisation(nodeValues); Printer::getInstance().printStatusEnd(); @@ -43,11 +42,10 @@ bool OperationMultipleHierarchisationFundamentalSpline::doHierarchisation( } void OperationMultipleHierarchisationFundamentalSpline::doDehierarchisation( - base::DataMatrix& alpha) { + base::DataMatrix& alpha) { Printer::getInstance().printStatusBegin("Dehierarchization (BFS)..."); op.doDehierarchisation(alpha); Printer::getInstance().printStatusEnd(); } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationFundamentalSpline.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationFundamentalSpline.hpp old mode 100755 new mode 100644 index 8110d49bf1..8e5ed4bca7 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationFundamentalSpline.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationFundamentalSpline.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONFUNDAMENTALSPLINE_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONFUNDAMENTALSPLINE_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERFUNDAMENTALSPLINE_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERFUNDAMENTALSPLINE_HPP #include @@ -20,16 +20,14 @@ namespace optimization { * Hierarchisation operation for B-spline basis functions on * Noboundary grids. */ -class OperationMultipleHierarchisationFundamentalSpline : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationFundamentalSpline : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationFundamentalSpline( - base::FundamentalSplineGrid& grid); + explicit OperationMultipleHierarchisationFundamentalSpline(base::FundamentalSplineGrid& grid); /** * Destructor. @@ -72,8 +70,7 @@ class OperationMultipleHierarchisationFundamentalSpline : /// hierarchization operation base::OperationHierarchisationFundamentalSpline op; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONFUNDAMENTALSPLINE_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERFUNDAMENTALSPLINE_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinear.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinear.cpp old mode 100755 new mode 100644 index b1c1baa6de..3c378fad7d --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinear.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinear.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -16,23 +14,19 @@ namespace SGPP { namespace optimization { OperationMultipleHierarchisationLinear::OperationMultipleHierarchisationLinear( - base::LinearGrid& grid) : - grid(grid) { -} + base::LinearGrid& grid) + : grid(grid) {} -OperationMultipleHierarchisationLinear::~OperationMultipleHierarchisationLinear() { -} +OperationMultipleHierarchisationLinear::~OperationMultipleHierarchisationLinear() {} -bool OperationMultipleHierarchisationLinear::doHierarchisation( - base::DataVector& nodeValues) { +bool OperationMultipleHierarchisationLinear::doHierarchisation(base::DataVector& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataVector b(nodeValues); return solver.solve(system, b, nodeValues); } -void OperationMultipleHierarchisationLinear::doDehierarchisation( - base::DataVector& alpha) { +void OperationMultipleHierarchisationLinear::doDehierarchisation(base::DataVector& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalLinear opNaiveEval(&storage); @@ -53,16 +47,14 @@ void OperationMultipleHierarchisationLinear::doDehierarchisation( alpha = nodeValues; } -bool OperationMultipleHierarchisationLinear::doHierarchisation( - base::DataMatrix& nodeValues) { +bool OperationMultipleHierarchisationLinear::doHierarchisation(base::DataMatrix& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataMatrix B(nodeValues); return solver.solve(system, B, nodeValues); } -void OperationMultipleHierarchisationLinear::doDehierarchisation( - base::DataMatrix& alpha) { +void OperationMultipleHierarchisationLinear::doDehierarchisation(base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalLinear opNaiveEval(&storage); @@ -86,6 +78,5 @@ void OperationMultipleHierarchisationLinear::doDehierarchisation( alpha.setColumn(i, nodeValues); } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinear.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinear.hpp old mode 100755 new mode 100644 index ea4842dd8b..2cc6cc2a6b --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinear.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinear.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONLINEAR_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONLINEAR_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERLINEAR_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERLINEAR_HPP #include @@ -19,15 +19,14 @@ namespace optimization { * Hierarchisation operation for linear basis functions on * Noboundary grids. */ -class OperationMultipleHierarchisationLinear : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationLinear : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationLinear(base::LinearGrid& grid); + explicit OperationMultipleHierarchisationLinear(base::LinearGrid& grid); /** * Destructor. @@ -68,8 +67,7 @@ class OperationMultipleHierarchisationLinear : /// storage of the sparse grid base::LinearGrid& grid; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONLINEAR_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERLINEAR_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearBoundary.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearBoundary.cpp old mode 100755 new mode 100644 index 834403f5fd..c1d67a9332 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearBoundary.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearBoundary.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -16,23 +14,20 @@ namespace SGPP { namespace optimization { OperationMultipleHierarchisationLinearBoundary::OperationMultipleHierarchisationLinearBoundary( - base::LinearBoundaryGrid& grid) : - grid(grid) { -} + base::LinearBoundaryGrid& grid) + : grid(grid) {} -OperationMultipleHierarchisationLinearBoundary::~OperationMultipleHierarchisationLinearBoundary() { -} +OperationMultipleHierarchisationLinearBoundary::~OperationMultipleHierarchisationLinearBoundary() {} bool OperationMultipleHierarchisationLinearBoundary::doHierarchisation( - base::DataVector& nodeValues) { + base::DataVector& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataVector b(nodeValues); return solver.solve(system, b, nodeValues); } -void OperationMultipleHierarchisationLinearBoundary::doDehierarchisation( - base::DataVector& alpha) { +void OperationMultipleHierarchisationLinearBoundary::doDehierarchisation(base::DataVector& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalLinearBoundary opNaiveEval(&storage); @@ -54,15 +49,14 @@ void OperationMultipleHierarchisationLinearBoundary::doDehierarchisation( } bool OperationMultipleHierarchisationLinearBoundary::doHierarchisation( - base::DataMatrix& nodeValues) { + base::DataMatrix& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataMatrix B(nodeValues); return solver.solve(system, B, nodeValues); } -void OperationMultipleHierarchisationLinearBoundary::doDehierarchisation( - base::DataMatrix& alpha) { +void OperationMultipleHierarchisationLinearBoundary::doDehierarchisation(base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalLinearBoundary opNaiveEval(&storage); @@ -86,6 +80,5 @@ void OperationMultipleHierarchisationLinearBoundary::doDehierarchisation( alpha.setColumn(i, nodeValues); } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearBoundary.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearBoundary.hpp old mode 100755 new mode 100644 index 306c9e1aed..f6f729319d --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearBoundary.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearBoundary.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONLINEARBOUNDARY_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONLINEARBOUNDARY_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERLINEARBOUNDARY_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERLINEARBOUNDARY_HPP #include @@ -19,16 +19,14 @@ namespace optimization { * Hierarchisation operation for linear basis functions on * Boundary grids. */ -class OperationMultipleHierarchisationLinearBoundary : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationLinearBoundary : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationLinearBoundary( - base::LinearBoundaryGrid& grid); + explicit OperationMultipleHierarchisationLinearBoundary(base::LinearBoundaryGrid& grid); /** * Destructor. @@ -69,8 +67,7 @@ class OperationMultipleHierarchisationLinearBoundary : /// storage of the sparse grid base::LinearBoundaryGrid& grid; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONLINEARBOUNDARY_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERLINEARBOUNDARY_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearClenshawCurtis.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearClenshawCurtis.cpp old mode 100755 new mode 100644 index ae1cfdc598..ffaac3b9fc --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearClenshawCurtis.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearClenshawCurtis.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -15,16 +13,15 @@ namespace SGPP { namespace optimization { -OperationMultipleHierarchisationLinearClenshawCurtis::OperationMultipleHierarchisationLinearClenshawCurtis( - base::LinearClenshawCurtisGrid& grid) : - grid(grid) { -} +OperationMultipleHierarchisationLinearClenshawCurtis:: + OperationMultipleHierarchisationLinearClenshawCurtis(base::LinearClenshawCurtisGrid& grid) + : grid(grid) {} -OperationMultipleHierarchisationLinearClenshawCurtis::~OperationMultipleHierarchisationLinearClenshawCurtis() { -} +OperationMultipleHierarchisationLinearClenshawCurtis:: + ~OperationMultipleHierarchisationLinearClenshawCurtis() {} bool OperationMultipleHierarchisationLinearClenshawCurtis::doHierarchisation( - base::DataVector& nodeValues) { + base::DataVector& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataVector b(nodeValues); @@ -32,7 +29,7 @@ bool OperationMultipleHierarchisationLinearClenshawCurtis::doHierarchisation( } void OperationMultipleHierarchisationLinearClenshawCurtis::doDehierarchisation( - base::DataVector& alpha) { + base::DataVector& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalLinearClenshawCurtis opNaiveEval(&storage); @@ -54,7 +51,7 @@ void OperationMultipleHierarchisationLinearClenshawCurtis::doDehierarchisation( } bool OperationMultipleHierarchisationLinearClenshawCurtis::doHierarchisation( - base::DataMatrix& nodeValues) { + base::DataMatrix& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataMatrix B(nodeValues); @@ -62,7 +59,7 @@ bool OperationMultipleHierarchisationLinearClenshawCurtis::doHierarchisation( } void OperationMultipleHierarchisationLinearClenshawCurtis::doDehierarchisation( - base::DataMatrix& alpha) { + base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalLinearClenshawCurtis opNaiveEval(&storage); @@ -86,6 +83,5 @@ void OperationMultipleHierarchisationLinearClenshawCurtis::doDehierarchisation( alpha.setColumn(i, nodeValues); } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearClenshawCurtis.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearClenshawCurtis.hpp old mode 100755 new mode 100644 index f1c2c1633c..9473bc8343 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearClenshawCurtis.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationLinearClenshawCurtis.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONLINEARCLENSHAWCURTIS_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONLINEARCLENSHAWCURTIS_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERLINEARCLENSHAWCURTIS_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERLINEARCLENSHAWCURTIS_HPP #include @@ -19,16 +19,16 @@ namespace optimization { * Hierarchisation operation for linear basis functions on * Clenshaw-Curtis grids. */ -class OperationMultipleHierarchisationLinearClenshawCurtis : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationLinearClenshawCurtis + : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationLinearClenshawCurtis( - base::LinearClenshawCurtisGrid& grid); + explicit OperationMultipleHierarchisationLinearClenshawCurtis( + base::LinearClenshawCurtisGrid& grid); /** * Destructor. @@ -69,8 +69,7 @@ class OperationMultipleHierarchisationLinearClenshawCurtis : /// storage of the sparse grid base::LinearClenshawCurtisGrid& grid; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONLINEARCLENSHAWCURTIS_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERLINEARCLENSHAWCURTIS_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBspline.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBspline.cpp old mode 100755 new mode 100644 index 36479b878a..2e21604325 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBspline.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBspline.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -16,23 +14,19 @@ namespace SGPP { namespace optimization { OperationMultipleHierarchisationModBspline::OperationMultipleHierarchisationModBspline( - base::ModBsplineGrid& grid) : - grid(grid) { -} + base::ModBsplineGrid& grid) + : grid(grid) {} -OperationMultipleHierarchisationModBspline::~OperationMultipleHierarchisationModBspline() { -} +OperationMultipleHierarchisationModBspline::~OperationMultipleHierarchisationModBspline() {} -bool OperationMultipleHierarchisationModBspline::doHierarchisation( - base::DataVector& nodeValues) { +bool OperationMultipleHierarchisationModBspline::doHierarchisation(base::DataVector& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataVector b(nodeValues); return solver.solve(system, b, nodeValues); } -void OperationMultipleHierarchisationModBspline::doDehierarchisation( - base::DataVector& alpha) { +void OperationMultipleHierarchisationModBspline::doDehierarchisation(base::DataVector& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalModBspline opNaiveEval(&storage, grid.getDegree()); @@ -53,16 +47,14 @@ void OperationMultipleHierarchisationModBspline::doDehierarchisation( alpha = nodeValues; } -bool OperationMultipleHierarchisationModBspline::doHierarchisation( - base::DataMatrix& nodeValues) { +bool OperationMultipleHierarchisationModBspline::doHierarchisation(base::DataMatrix& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataMatrix B(nodeValues); return solver.solve(system, B, nodeValues); } -void OperationMultipleHierarchisationModBspline::doDehierarchisation( - base::DataMatrix& alpha) { +void OperationMultipleHierarchisationModBspline::doDehierarchisation(base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalModBspline opNaiveEval(&storage, grid.getDegree()); @@ -86,6 +78,5 @@ void OperationMultipleHierarchisationModBspline::doDehierarchisation( alpha.setColumn(i, nodeValues); } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBspline.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBspline.hpp old mode 100755 new mode 100644 index 98d94c1f42..07644a7d56 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBspline.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBspline.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODBSPLINE_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODBSPLINE_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODBSPLINE_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODBSPLINE_HPP #include @@ -19,15 +19,14 @@ namespace optimization { * Hierarchisation operation for modified B-spline basis functions on * Noboundary grids. */ -class OperationMultipleHierarchisationModBspline : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationModBspline : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationModBspline(base::ModBsplineGrid& grid); + explicit OperationMultipleHierarchisationModBspline(base::ModBsplineGrid& grid); /** * Destructor. @@ -68,8 +67,7 @@ class OperationMultipleHierarchisationModBspline : /// storage of the sparse grid base::ModBsplineGrid& grid; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODBSPLINE_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODBSPLINE_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBsplineClenshawCurtis.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBsplineClenshawCurtis.cpp old mode 100755 new mode 100644 index 12aa932b5c..985a2590fc --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBsplineClenshawCurtis.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBsplineClenshawCurtis.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -15,16 +13,16 @@ namespace SGPP { namespace optimization { -OperationMultipleHierarchisationModBsplineClenshawCurtis::OperationMultipleHierarchisationModBsplineClenshawCurtis( - base::ModBsplineClenshawCurtisGrid& grid) : - grid(grid) { -} +OperationMultipleHierarchisationModBsplineClenshawCurtis:: + OperationMultipleHierarchisationModBsplineClenshawCurtis( + base::ModBsplineClenshawCurtisGrid& grid) + : grid(grid) {} -OperationMultipleHierarchisationModBsplineClenshawCurtis::~OperationMultipleHierarchisationModBsplineClenshawCurtis() { -} +OperationMultipleHierarchisationModBsplineClenshawCurtis:: + ~OperationMultipleHierarchisationModBsplineClenshawCurtis() {} bool OperationMultipleHierarchisationModBsplineClenshawCurtis::doHierarchisation( - base::DataVector& nodeValues) { + base::DataVector& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataVector b(nodeValues); @@ -32,11 +30,10 @@ bool OperationMultipleHierarchisationModBsplineClenshawCurtis::doHierarchisation } void OperationMultipleHierarchisationModBsplineClenshawCurtis::doDehierarchisation( - base::DataVector& alpha) { + base::DataVector& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); - base::OperationNaiveEvalModBsplineClenshawCurtis opNaiveEval(&storage, - grid.getDegree()); + base::OperationNaiveEvalModBsplineClenshawCurtis opNaiveEval(&storage, grid.getDegree()); base::DataVector nodeValues(storage.size()); base::DataVector x(d, 0.0); @@ -55,7 +52,7 @@ void OperationMultipleHierarchisationModBsplineClenshawCurtis::doDehierarchisati } bool OperationMultipleHierarchisationModBsplineClenshawCurtis::doHierarchisation( - base::DataMatrix& nodeValues) { + base::DataMatrix& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataMatrix B(nodeValues); @@ -63,11 +60,10 @@ bool OperationMultipleHierarchisationModBsplineClenshawCurtis::doHierarchisation } void OperationMultipleHierarchisationModBsplineClenshawCurtis::doDehierarchisation( - base::DataMatrix& alpha) { + base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); - base::OperationNaiveEvalModBsplineClenshawCurtis opNaiveEval(&storage, - grid.getDegree()); + base::OperationNaiveEvalModBsplineClenshawCurtis opNaiveEval(&storage, grid.getDegree()); base::DataVector nodeValues(storage.size(), 0.0); base::DataVector x(d, 0.0); base::DataVector alpha1(storage.size(), 0.0); @@ -88,6 +84,5 @@ void OperationMultipleHierarchisationModBsplineClenshawCurtis::doDehierarchisati alpha.setColumn(i, nodeValues); } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBsplineClenshawCurtis.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBsplineClenshawCurtis.hpp old mode 100755 new mode 100644 index 8cd3ef3618..bd9a4d2e9d --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBsplineClenshawCurtis.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModBsplineClenshawCurtis.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODBSPLINECLENSHAWCURTIS_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODBSPLINECLENSHAWCURTIS_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODBSPLINECLENSHAWCURTIS_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODBSPLINECLENSHAWCURTIS_HPP #include @@ -19,16 +19,16 @@ namespace optimization { * Hierarchisation operation for modified B-spline basis functions on * Noboundary grids. */ -class OperationMultipleHierarchisationModBsplineClenshawCurtis : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationModBsplineClenshawCurtis + : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationModBsplineClenshawCurtis( - base::ModBsplineClenshawCurtisGrid& grid); + explicit OperationMultipleHierarchisationModBsplineClenshawCurtis( + base::ModBsplineClenshawCurtisGrid& grid); /** * Destructor. @@ -69,8 +69,7 @@ class OperationMultipleHierarchisationModBsplineClenshawCurtis : /// storage of the sparse grid base::ModBsplineClenshawCurtisGrid& grid; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODBSPLINECLENSHAWCURTIS_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODBSPLINECLENSHAWCURTIS_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModFundamentalSpline.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModFundamentalSpline.cpp old mode 100755 new mode 100644 index e8d8819898..832afaf58f --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModFundamentalSpline.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModFundamentalSpline.cpp @@ -11,16 +11,15 @@ namespace SGPP { namespace optimization { -OperationMultipleHierarchisationModFundamentalSpline::OperationMultipleHierarchisationModFundamentalSpline( - base::ModFundamentalSplineGrid& grid) : - grid(grid), op(&grid) { -} +OperationMultipleHierarchisationModFundamentalSpline:: + OperationMultipleHierarchisationModFundamentalSpline(base::ModFundamentalSplineGrid& grid) + : grid(grid), op(&grid) {} -OperationMultipleHierarchisationModFundamentalSpline::~OperationMultipleHierarchisationModFundamentalSpline() { -} +OperationMultipleHierarchisationModFundamentalSpline:: + ~OperationMultipleHierarchisationModFundamentalSpline() {} bool OperationMultipleHierarchisationModFundamentalSpline::doHierarchisation( - base::DataVector& nodeValues) { + base::DataVector& nodeValues) { Printer::getInstance().printStatusBegin("Hierarchization (BFS)..."); op.doHierarchisation(nodeValues); Printer::getInstance().printStatusEnd(); @@ -28,14 +27,14 @@ bool OperationMultipleHierarchisationModFundamentalSpline::doHierarchisation( } void OperationMultipleHierarchisationModFundamentalSpline::doDehierarchisation( - base::DataVector& alpha) { + base::DataVector& alpha) { Printer::getInstance().printStatusBegin("Dehierarchization (BFS)..."); op.doDehierarchisation(alpha); Printer::getInstance().printStatusEnd(); } bool OperationMultipleHierarchisationModFundamentalSpline::doHierarchisation( - base::DataMatrix& nodeValues) { + base::DataMatrix& nodeValues) { Printer::getInstance().printStatusBegin("Hierarchization (BFS)..."); op.doHierarchisation(nodeValues); Printer::getInstance().printStatusEnd(); @@ -43,11 +42,10 @@ bool OperationMultipleHierarchisationModFundamentalSpline::doHierarchisation( } void OperationMultipleHierarchisationModFundamentalSpline::doDehierarchisation( - base::DataMatrix& alpha) { + base::DataMatrix& alpha) { Printer::getInstance().printStatusBegin("Dehierarchization (BFS)..."); op.doDehierarchisation(alpha); Printer::getInstance().printStatusEnd(); } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModFundamentalSpline.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModFundamentalSpline.hpp old mode 100755 new mode 100644 index 204b621f3f..7dd4231c11 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModFundamentalSpline.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModFundamentalSpline.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODFUNDAMENTALSPLINE_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODFUNDAMENTALSPLINE_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODFUNDAMENTALSPLINE_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODFUNDAMENTALSPLINE_HPP #include @@ -20,16 +20,16 @@ namespace optimization { * Hierarchisation operation for modified B-spline basis functions on * Noboundary grids. */ -class OperationMultipleHierarchisationModFundamentalSpline : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationModFundamentalSpline + : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationModFundamentalSpline( - base::ModFundamentalSplineGrid& grid); + explicit OperationMultipleHierarchisationModFundamentalSpline( + base::ModFundamentalSplineGrid& grid); /** * Destructor. @@ -72,8 +72,7 @@ class OperationMultipleHierarchisationModFundamentalSpline : /// hierarchization operation base::OperationHierarchisationModFundamentalSpline op; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODFUNDAMENTALSPLINE_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODFUNDAMENTALSPLINE_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModLinear.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModLinear.cpp old mode 100755 new mode 100644 index 7102113903..49f7b2e260 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModLinear.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModLinear.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -16,23 +14,19 @@ namespace SGPP { namespace optimization { OperationMultipleHierarchisationModLinear::OperationMultipleHierarchisationModLinear( - base::ModLinearGrid& grid) : - grid(grid) { -} + base::ModLinearGrid& grid) + : grid(grid) {} -OperationMultipleHierarchisationModLinear::~OperationMultipleHierarchisationModLinear() { -} +OperationMultipleHierarchisationModLinear::~OperationMultipleHierarchisationModLinear() {} -bool OperationMultipleHierarchisationModLinear::doHierarchisation( - base::DataVector& nodeValues) { +bool OperationMultipleHierarchisationModLinear::doHierarchisation(base::DataVector& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataVector b(nodeValues); return solver.solve(system, b, nodeValues); } -void OperationMultipleHierarchisationModLinear::doDehierarchisation( - base::DataVector& alpha) { +void OperationMultipleHierarchisationModLinear::doDehierarchisation(base::DataVector& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalModLinear opNaiveEval(&storage); @@ -53,16 +47,14 @@ void OperationMultipleHierarchisationModLinear::doDehierarchisation( alpha = nodeValues; } -bool OperationMultipleHierarchisationModLinear::doHierarchisation( - base::DataMatrix& nodeValues) { +bool OperationMultipleHierarchisationModLinear::doHierarchisation(base::DataMatrix& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataMatrix B(nodeValues); return solver.solve(system, B, nodeValues); } -void OperationMultipleHierarchisationModLinear::doDehierarchisation( - base::DataMatrix& alpha) { +void OperationMultipleHierarchisationModLinear::doDehierarchisation(base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalModLinear opNaiveEval(&storage); @@ -86,6 +78,5 @@ void OperationMultipleHierarchisationModLinear::doDehierarchisation( alpha.setColumn(i, nodeValues); } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModLinear.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModLinear.hpp old mode 100755 new mode 100644 index 8035b151ca..18da6cabc3 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModLinear.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModLinear.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODLINEAR_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODLINEAR_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODLINEAR_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODLINEAR_HPP #include @@ -19,15 +19,14 @@ namespace optimization { * Hierarchisation operation for modified linear basis functions on * Noboundary grids. */ -class OperationMultipleHierarchisationModLinear : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationModLinear : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationModLinear(base::ModLinearGrid& grid); + explicit OperationMultipleHierarchisationModLinear(base::ModLinearGrid& grid); /** * Destructor. @@ -68,8 +67,7 @@ class OperationMultipleHierarchisationModLinear : /// storage of the sparse grid base::ModLinearGrid& grid; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODLINEAR_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODLINEAR_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModWavelet.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModWavelet.cpp old mode 100755 new mode 100644 index 035e954b20..6dbfa3dd75 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModWavelet.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModWavelet.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -16,23 +14,19 @@ namespace SGPP { namespace optimization { OperationMultipleHierarchisationModWavelet::OperationMultipleHierarchisationModWavelet( - base::ModWaveletGrid& grid) : - grid(grid) { -} + base::ModWaveletGrid& grid) + : grid(grid) {} -OperationMultipleHierarchisationModWavelet::~OperationMultipleHierarchisationModWavelet() { -} +OperationMultipleHierarchisationModWavelet::~OperationMultipleHierarchisationModWavelet() {} -bool OperationMultipleHierarchisationModWavelet::doHierarchisation( - base::DataVector& nodeValues) { +bool OperationMultipleHierarchisationModWavelet::doHierarchisation(base::DataVector& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataVector b(nodeValues); return solver.solve(system, b, nodeValues); } -void OperationMultipleHierarchisationModWavelet::doDehierarchisation( - base::DataVector& alpha) { +void OperationMultipleHierarchisationModWavelet::doDehierarchisation(base::DataVector& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalModWavelet opNaiveEval(&storage); @@ -53,16 +47,14 @@ void OperationMultipleHierarchisationModWavelet::doDehierarchisation( alpha = nodeValues; } -bool OperationMultipleHierarchisationModWavelet::doHierarchisation( - base::DataMatrix& nodeValues) { +bool OperationMultipleHierarchisationModWavelet::doHierarchisation(base::DataMatrix& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataMatrix B(nodeValues); return solver.solve(system, B, nodeValues); } -void OperationMultipleHierarchisationModWavelet::doDehierarchisation( - base::DataMatrix& alpha) { +void OperationMultipleHierarchisationModWavelet::doDehierarchisation(base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalModWavelet opNaiveEval(&storage); @@ -86,6 +78,5 @@ void OperationMultipleHierarchisationModWavelet::doDehierarchisation( alpha.setColumn(i, nodeValues); } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModWavelet.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModWavelet.hpp old mode 100755 new mode 100644 index bd3c272910..4240edc802 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModWavelet.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationModWavelet.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODWAVELET_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODWAVELET_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODWAVELET_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODWAVELET_HPP #include @@ -19,15 +19,14 @@ namespace optimization { * Hierarchisation operation for modified wavelet basis functions on * Noboundary grids. */ -class OperationMultipleHierarchisationModWavelet : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationModWavelet : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationModWavelet(base::ModWaveletGrid& grid); + explicit OperationMultipleHierarchisationModWavelet(base::ModWaveletGrid& grid); /** * Destructor. @@ -68,8 +67,7 @@ class OperationMultipleHierarchisationModWavelet : /// storage of the sparse grid base::ModWaveletGrid& grid; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONMODWAVELET_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERMODWAVELET_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWavelet.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWavelet.cpp old mode 100755 new mode 100644 index ec5cd2a7f6..7fc55b6500 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWavelet.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWavelet.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -16,23 +14,19 @@ namespace SGPP { namespace optimization { OperationMultipleHierarchisationWavelet::OperationMultipleHierarchisationWavelet( - base::WaveletGrid& grid) : - grid(grid) { -} + base::WaveletGrid& grid) + : grid(grid) {} -OperationMultipleHierarchisationWavelet::~OperationMultipleHierarchisationWavelet() { -} +OperationMultipleHierarchisationWavelet::~OperationMultipleHierarchisationWavelet() {} -bool OperationMultipleHierarchisationWavelet::doHierarchisation( - base::DataVector& nodeValues) { +bool OperationMultipleHierarchisationWavelet::doHierarchisation(base::DataVector& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataVector b(nodeValues); return solver.solve(system, b, nodeValues); } -void OperationMultipleHierarchisationWavelet::doDehierarchisation( - base::DataVector& alpha) { +void OperationMultipleHierarchisationWavelet::doDehierarchisation(base::DataVector& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalWavelet opNaiveEval(&storage); @@ -53,16 +47,14 @@ void OperationMultipleHierarchisationWavelet::doDehierarchisation( alpha = nodeValues; } -bool OperationMultipleHierarchisationWavelet::doHierarchisation( - base::DataMatrix& nodeValues) { +bool OperationMultipleHierarchisationWavelet::doHierarchisation(base::DataMatrix& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataMatrix B(nodeValues); return solver.solve(system, B, nodeValues); } -void OperationMultipleHierarchisationWavelet::doDehierarchisation( - base::DataMatrix& alpha) { +void OperationMultipleHierarchisationWavelet::doDehierarchisation(base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalWavelet opNaiveEval(&storage); @@ -86,6 +78,5 @@ void OperationMultipleHierarchisationWavelet::doDehierarchisation( alpha.setColumn(i, nodeValues); } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWavelet.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWavelet.hpp old mode 100755 new mode 100644 index 4c86fd14e4..2fdf771534 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWavelet.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWavelet.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONWAVELET_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONWAVELET_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERWAVELET_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERWAVELET_HPP #include @@ -19,15 +19,14 @@ namespace optimization { * Hierarchisation operation for wavelet basis functions on * Noboundary grids. */ -class OperationMultipleHierarchisationWavelet : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationWavelet : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationWavelet(base::WaveletGrid& grid); + explicit OperationMultipleHierarchisationWavelet(base::WaveletGrid& grid); /** * Destructor. @@ -68,8 +67,7 @@ class OperationMultipleHierarchisationWavelet : /// storage of the sparse grid base::WaveletGrid& grid; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONWAVELET_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERWAVELET_HPP */ diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWaveletBoundary.cpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWaveletBoundary.cpp old mode 100755 new mode 100644 index 17cdfb71b5..b2a0101931 --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWaveletBoundary.cpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWaveletBoundary.cpp @@ -3,8 +3,6 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include @@ -16,23 +14,21 @@ namespace SGPP { namespace optimization { OperationMultipleHierarchisationWaveletBoundary::OperationMultipleHierarchisationWaveletBoundary( - base::WaveletBoundaryGrid& grid) : - grid(grid) { -} + base::WaveletBoundaryGrid& grid) + : grid(grid) {} -OperationMultipleHierarchisationWaveletBoundary::~OperationMultipleHierarchisationWaveletBoundary() { -} +OperationMultipleHierarchisationWaveletBoundary:: + ~OperationMultipleHierarchisationWaveletBoundary() {} bool OperationMultipleHierarchisationWaveletBoundary::doHierarchisation( - base::DataVector& nodeValues) { + base::DataVector& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataVector b(nodeValues); return solver.solve(system, b, nodeValues); } -void OperationMultipleHierarchisationWaveletBoundary::doDehierarchisation( - base::DataVector& alpha) { +void OperationMultipleHierarchisationWaveletBoundary::doDehierarchisation(base::DataVector& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalWaveletBoundary opNaiveEval(&storage); @@ -54,15 +50,14 @@ void OperationMultipleHierarchisationWaveletBoundary::doDehierarchisation( } bool OperationMultipleHierarchisationWaveletBoundary::doHierarchisation( - base::DataMatrix& nodeValues) { + base::DataMatrix& nodeValues) { HierarchisationSLE system(grid); sle_solver::Auto solver; base::DataMatrix B(nodeValues); return solver.solve(system, B, nodeValues); } -void OperationMultipleHierarchisationWaveletBoundary::doDehierarchisation( - base::DataMatrix& alpha) { +void OperationMultipleHierarchisationWaveletBoundary::doDehierarchisation(base::DataMatrix& alpha) { base::GridStorage& storage = *grid.getStorage(); const size_t d = storage.dim(); base::OperationNaiveEvalWaveletBoundary opNaiveEval(&storage); @@ -86,6 +81,5 @@ void OperationMultipleHierarchisationWaveletBoundary::doDehierarchisation( alpha.setColumn(i, nodeValues); } } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWaveletBoundary.hpp b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWaveletBoundary.hpp old mode 100755 new mode 100644 index 0aacfda125..0fdb6d673d --- a/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWaveletBoundary.hpp +++ b/optimization/src/sgpp/optimization/operation/hash/OperationMultipleHierarchisationWaveletBoundary.hpp @@ -3,8 +3,8 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONWAVELETBOUNDARY_HPP -#define SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONWAVELETBOUNDARY_HPP +#ifndef SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERWAVELETBOUNDARY_HPP +#define SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERWAVELETBOUNDARY_HPP #include @@ -19,16 +19,14 @@ namespace optimization { * Hierarchisation operation for wavelet basis functions on * Boundary grids. */ -class OperationMultipleHierarchisationWaveletBoundary : - public OperationMultipleHierarchisation { +class OperationMultipleHierarchisationWaveletBoundary : public OperationMultipleHierarchisation { public: /** * Constructor. * * @param grid grid */ - OperationMultipleHierarchisationWaveletBoundary( - base::WaveletBoundaryGrid& grid); + explicit OperationMultipleHierarchisationWaveletBoundary(base::WaveletBoundaryGrid& grid); /** * Destructor. @@ -69,8 +67,7 @@ class OperationMultipleHierarchisationWaveletBoundary : /// storage of the sparse grid base::WaveletBoundaryGrid& grid; }; +} // namespace optimization +} // namespace SGPP -} -} - -#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPERATIONMULTIPLEHIERARCHISATIONWAVELETBOUNDARY_HPP */ +#endif /* SGPP_OPTIMIZATION_OPERATION_HASH_OPMULTHIERWAVELETBOUNDARY_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/constrained/AugmentedLagrangian.cpp b/optimization/src/sgpp/optimization/optimizer/constrained/AugmentedLagrangian.cpp index cb210b5d65..89f30e41f0 100644 --- a/optimization/src/sgpp/optimization/optimizer/constrained/AugmentedLagrangian.cpp +++ b/optimization/src/sgpp/optimization/optimizer/constrained/AugmentedLagrangian.cpp @@ -11,6 +11,9 @@ #include #include +#include +#include + namespace SGPP { namespace optimization { namespace optimizer { @@ -18,20 +21,16 @@ namespace optimizer { namespace { class PenalizedObjectiveFunction : public ScalarFunction { public: - PenalizedObjectiveFunction(ScalarFunction& f, - VectorFunction& g, - VectorFunction& h, - float_t mu, - base::DataVector& lambda) : - ScalarFunction(f.getNumberOfParameters()), - f(f), - g(g), - h(h), - mu(mu), - lambda(lambda), - mG(g.getNumberOfComponents()), - mH(h.getNumberOfComponents()) { - } + PenalizedObjectiveFunction(ScalarFunction& f, VectorFunction& g, VectorFunction& h, float_t mu, + base::DataVector& lambda) + : ScalarFunction(f.getNumberOfParameters()), + f(f), + g(g), + h(h), + mu(mu), + lambda(lambda), + mG(g.getNumberOfComponents()), + mH(h.getNumberOfComponents()) {} float_t eval(const base::DataVector& x) { for (size_t t = 0; t < d; t++) { @@ -66,13 +65,10 @@ class PenalizedObjectiveFunction : public ScalarFunction { } void clone(std::unique_ptr& clone) const { - clone = std::unique_ptr( - new PenalizedObjectiveFunction(*this)); + clone = std::unique_ptr(new PenalizedObjectiveFunction(*this)); } - void setMu(float_t mu) { - this->mu = mu; - } + void setMu(float_t mu) { this->mu = mu; } protected: ScalarFunction& f; @@ -86,23 +82,19 @@ class PenalizedObjectiveFunction : public ScalarFunction { class PenalizedObjectiveGradient : public ScalarFunctionGradient { public: - PenalizedObjectiveGradient(ScalarFunctionGradient& fGradient, - VectorFunctionGradient& gGradient, - VectorFunctionGradient& hGradient, - float_t mu, - base::DataVector& lambda) : - ScalarFunctionGradient(fGradient.getNumberOfParameters()), - fGradient(fGradient), - gGradient(gGradient), - hGradient(hGradient), - mu(mu), - lambda(lambda), - mG(gGradient.getNumberOfComponents()), - mH(hGradient.getNumberOfComponents()) { - } - - float_t eval(const base::DataVector& x, - base::DataVector& gradient) { + PenalizedObjectiveGradient(ScalarFunctionGradient& fGradient, VectorFunctionGradient& gGradient, + VectorFunctionGradient& hGradient, float_t mu, + base::DataVector& lambda) + : ScalarFunctionGradient(fGradient.getNumberOfParameters()), + fGradient(fGradient), + gGradient(gGradient), + hGradient(hGradient), + mu(mu), + lambda(lambda), + mG(gGradient.getNumberOfComponents()), + mH(hGradient.getNumberOfComponents()) {} + + float_t eval(const base::DataVector& x, base::DataVector& gradient) { for (size_t t = 0; t < d; t++) { if ((x[t] < 0.0) || (x[t] > 1.0)) { gradient.setAll(NAN); @@ -159,13 +151,10 @@ class PenalizedObjectiveGradient : public ScalarFunctionGradient { } void clone(std::unique_ptr& clone) const { - clone = std::unique_ptr( - new PenalizedObjectiveGradient(*this)); + clone = std::unique_ptr(new PenalizedObjectiveGradient(*this)); } - void setMu(float_t mu) { - this->mu = mu; - } + void setMu(float_t mu) { this->mu = mu; } protected: ScalarFunctionGradient& fGradient; @@ -179,11 +168,8 @@ class PenalizedObjectiveGradient : public ScalarFunctionGradient { class AuxiliaryObjectiveFunction : public ScalarFunction { public: - AuxiliaryObjectiveFunction(size_t d, float_t sMin, float_t sMax) : - ScalarFunction(d + 1), - sMin(sMin), - sMax(sMax) { - } + AuxiliaryObjectiveFunction(size_t d, float_t sMin, float_t sMax) + : ScalarFunction(d + 1), sMin(sMin), sMax(sMax) {} float_t eval(const base::DataVector& x) { const size_t d = this->d - 1; @@ -198,8 +184,7 @@ class AuxiliaryObjectiveFunction : public ScalarFunction { } void clone(std::unique_ptr& clone) const { - clone = std::unique_ptr( - new AuxiliaryObjectiveFunction(*this)); + clone = std::unique_ptr(new AuxiliaryObjectiveFunction(*this)); } protected: @@ -209,14 +194,10 @@ class AuxiliaryObjectiveFunction : public ScalarFunction { class AuxiliaryObjectiveGradient : public ScalarFunctionGradient { public: - AuxiliaryObjectiveGradient(size_t d, float_t sMin, float_t sMax) : - ScalarFunctionGradient(d + 1), - sMin(sMin), - sMax(sMax) { - } + AuxiliaryObjectiveGradient(size_t d, float_t sMin, float_t sMax) + : ScalarFunctionGradient(d + 1), sMin(sMin), sMax(sMax) {} - float_t eval(const base::DataVector& x, - base::DataVector& gradient) { + float_t eval(const base::DataVector& x, base::DataVector& gradient) { const size_t d = this->d - 1; for (size_t t = 0; t < d + 1; t++) { @@ -232,8 +213,7 @@ class AuxiliaryObjectiveGradient : public ScalarFunctionGradient { } void clone(std::unique_ptr& clone) const { - clone = std::unique_ptr( - new AuxiliaryObjectiveGradient(*this)); + clone = std::unique_ptr(new AuxiliaryObjectiveGradient(*this)); } protected: @@ -243,24 +223,17 @@ class AuxiliaryObjectiveGradient : public ScalarFunctionGradient { class AuxiliaryConstraintFunction : public VectorFunction { public: - AuxiliaryConstraintFunction(size_t d, - VectorFunction& g, - VectorFunction& h, - float_t sMin, - float_t sMax) : - VectorFunction(d + 1, - g.getNumberOfComponents() + - 2 * h.getNumberOfComponents() + 1), - g(g), - h(h), - mG(g.getNumberOfComponents()), - mH(h.getNumberOfComponents()), - sMin(sMin), - sMax(sMax) { - } - - void eval(const base::DataVector& x, - base::DataVector& value) { + AuxiliaryConstraintFunction(size_t d, VectorFunction& g, VectorFunction& h, float_t sMin, + float_t sMax) + : VectorFunction(d + 1, g.getNumberOfComponents() + 2 * h.getNumberOfComponents() + 1), + g(g), + h(h), + mG(g.getNumberOfComponents()), + mH(h.getNumberOfComponents()), + sMin(sMin), + sMax(sMax) {} + + void eval(const base::DataVector& x, base::DataVector& value) { const size_t d = this->d - 1; base::DataVector xPart(d); @@ -294,8 +267,7 @@ class AuxiliaryConstraintFunction : public VectorFunction { } void clone(std::unique_ptr& clone) const { - clone = std::unique_ptr( - new AuxiliaryConstraintFunction(*this)); + clone = std::unique_ptr(new AuxiliaryConstraintFunction(*this)); } protected: @@ -309,25 +281,18 @@ class AuxiliaryConstraintFunction : public VectorFunction { class AuxiliaryConstraintGradient : public VectorFunctionGradient { public: - AuxiliaryConstraintGradient(size_t d, - VectorFunctionGradient& gGradient, - VectorFunctionGradient& hGradient, - float_t sMin, - float_t sMax) : - VectorFunctionGradient(d + 1, - gGradient.getNumberOfComponents() + - 2 * hGradient.getNumberOfComponents() + 1), - gGradient(gGradient), - hGradient(hGradient), - mG(gGradient.getNumberOfComponents()), - mH(hGradient.getNumberOfComponents()), - sMin(sMin), - sMax(sMax) { - } - - void eval(const base::DataVector& x, - base::DataVector& value, - base::DataMatrix& gradient) { + AuxiliaryConstraintGradient(size_t d, VectorFunctionGradient& gGradient, + VectorFunctionGradient& hGradient, float_t sMin, float_t sMax) + : VectorFunctionGradient( + d + 1, gGradient.getNumberOfComponents() + 2 * hGradient.getNumberOfComponents() + 1), + gGradient(gGradient), + hGradient(hGradient), + mG(gGradient.getNumberOfComponents()), + mH(hGradient.getNumberOfComponents()), + sMin(sMin), + sMax(sMax) {} + + void eval(const base::DataVector& x, base::DataVector& value, base::DataMatrix& gradient) { const size_t d = this->d - 1; base::DataVector xPart(d); @@ -384,8 +349,7 @@ class AuxiliaryConstraintGradient : public VectorFunctionGradient { } void clone(std::unique_ptr& clone) const { - clone = std::unique_ptr( - new AuxiliaryConstraintGradient(*this)); + clone = std::unique_ptr(new AuxiliaryConstraintGradient(*this)); } protected: @@ -396,33 +360,25 @@ class AuxiliaryConstraintGradient : public VectorFunctionGradient { float_t sMin; float_t sMax; }; -} - -AugmentedLagrangian::AugmentedLagrangian( - ScalarFunction& f, - ScalarFunctionGradient& fGradient, - VectorFunction& g, - VectorFunctionGradient& gGradient, - VectorFunction& h, - VectorFunctionGradient& hGradient, - size_t maxItCount, - float_t xTolerance, - float_t constraintTolerance, - float_t penaltyStartValue, - float_t penaltyIncreaseFactor) : - ConstrainedOptimizer(f, g, h, maxItCount), - fGradient(fGradient), - gGradient(gGradient), - hGradient(hGradient), - theta(xTolerance), - epsilon(constraintTolerance), - mu0(penaltyStartValue), - rhoMuPlus(penaltyIncreaseFactor), - kHist() { -} - -AugmentedLagrangian::~AugmentedLagrangian() { -} +} // namespace + +AugmentedLagrangian::AugmentedLagrangian(ScalarFunction& f, ScalarFunctionGradient& fGradient, + VectorFunction& g, VectorFunctionGradient& gGradient, + VectorFunction& h, VectorFunctionGradient& hGradient, + size_t maxItCount, float_t xTolerance, + float_t constraintTolerance, float_t penaltyStartValue, + float_t penaltyIncreaseFactor) + : ConstrainedOptimizer(f, g, h, maxItCount), + fGradient(fGradient), + gGradient(gGradient), + hGradient(hGradient), + theta(xTolerance), + epsilon(constraintTolerance), + mu0(penaltyStartValue), + rhoMuPlus(penaltyIncreaseFactor), + kHist() {} + +AugmentedLagrangian::~AugmentedLagrangian() {} void AugmentedLagrangian::optimize() { Printer::getInstance().printStatusBegin("Optimizing (Augmented Lagrangian)..."); @@ -459,21 +415,20 @@ void AugmentedLagrangian::optimize() { const size_t unconstrainedN = N / 20; PenalizedObjectiveFunction fPenalized(f, g, h, mu, lambda); - PenalizedObjectiveGradient fPenalizedGradient( - fGradient, gGradient, hGradient, mu, lambda); + PenalizedObjectiveGradient fPenalizedGradient(fGradient, gGradient, hGradient, mu, lambda); while (k < N) { fPenalized.setMu(mu); fPenalizedGradient.setMu(mu); - AdaptiveGradientDescent unconstrainedOptimizer( - fPenalized, fPenalizedGradient, unconstrainedN, 10.0 * theta); + AdaptiveGradientDescent unconstrainedOptimizer(fPenalized, fPenalizedGradient, unconstrainedN, + 10.0 * theta); unconstrainedOptimizer.setStartingPoint(x); unconstrainedOptimizer.optimize(); xNew = unconstrainedOptimizer.getOptimalPoint(); const size_t numberInnerEvaluations = - unconstrainedOptimizer.getHistoryOfOptimalPoints().getNrows(); + unconstrainedOptimizer.getHistoryOfOptimalPoints().getNrows(); k += numberInnerEvaluations; x = xNew; @@ -488,10 +443,8 @@ void AugmentedLagrangian::optimize() { // status printing Printer::getInstance().printStatusUpdate( - std::to_string(k) + " evaluations, x = " + x.toString() + - ", f(x) = " + std::to_string(fx) + - ", g(x) = " + gx.toString() + - ", h(x) = " + hx.toString()); + std::to_string(k) + " evaluations, x = " + x.toString() + ", f(x) = " + std::to_string(fx) + + ", g(x) = " + gx.toString() + ", h(x) = " + hx.toString()); for (size_t i = 0; i < mG; i++) { lambda[i] = std::max(lambda[i] + 2.0 * mu * gx[i], 0.0); @@ -505,9 +458,7 @@ void AugmentedLagrangian::optimize() { xNew.sub(x); - if ((xNew.l2Norm() < theta) && - (gx.max() < epsilon) && - (hx.maxNorm() < epsilon)) { + if ((xNew.l2Norm() < theta) && (gx.max() < epsilon) && (hx.maxNorm() < epsilon)) { breakIterationCounter++; if (breakIterationCounter >= BREAK_ITERATION_COUNTER_MAX) { @@ -546,8 +497,7 @@ base::DataVector AugmentedLagrangian::findFeasiblePoint() const { AuxiliaryObjectiveFunction auxObjFun(d, sMin, sMax); AuxiliaryObjectiveGradient auxObjGrad(d, sMin, sMax); AuxiliaryConstraintFunction auxConstrFun(d, g, h, sMin, sMax); - AuxiliaryConstraintGradient auxConstrGrad( - d, gGradient, hGradient, sMin, sMax); + AuxiliaryConstraintGradient auxConstrGrad(d, gGradient, hGradient, sMin, sMax); base::DataVector auxX(d + 1); @@ -557,10 +507,9 @@ base::DataVector AugmentedLagrangian::findFeasiblePoint() const { auxX[d] = (s0 - sMin) / (sMax - sMin); - AugmentedLagrangian optimizer( - auxObjFun, auxObjGrad, auxConstrFun, auxConstrGrad, - EmptyVectorFunction::getInstance(), - EmptyVectorFunctionGradient::getInstance()); + AugmentedLagrangian optimizer(auxObjFun, auxObjGrad, auxConstrFun, auxConstrGrad, + EmptyVectorFunction::getInstance(), + EmptyVectorFunctionGradient::getInstance()); optimizer.setStartingPoint(auxX); optimizer.optimize(); auxX = optimizer.getOptimalPoint(); @@ -572,65 +521,45 @@ base::DataVector AugmentedLagrangian::findFeasiblePoint() const { return x; } -ScalarFunctionGradient& AugmentedLagrangian::getObjectiveGradient() const { - return fGradient; -} +ScalarFunctionGradient& AugmentedLagrangian::getObjectiveGradient() const { return fGradient; } -VectorFunctionGradient& -AugmentedLagrangian::getInequalityConstraintGradient() const { +VectorFunctionGradient& AugmentedLagrangian::getInequalityConstraintGradient() const { return gGradient; } -VectorFunctionGradient& -AugmentedLagrangian::getEqualityConstraintGradient() const { +VectorFunctionGradient& AugmentedLagrangian::getEqualityConstraintGradient() const { return hGradient; } -float_t AugmentedLagrangian::getXTolerance() const { - return theta; -} +float_t AugmentedLagrangian::getXTolerance() const { return theta; } -void AugmentedLagrangian::setXTolerance(float_t xTolerance) { - theta = xTolerance; -} +void AugmentedLagrangian::setXTolerance(float_t xTolerance) { theta = xTolerance; } -float_t AugmentedLagrangian::getConstraintTolerance() const { - return epsilon; -} +float_t AugmentedLagrangian::getConstraintTolerance() const { return epsilon; } -void AugmentedLagrangian::setConstraintTolerance( - float_t constraintTolerance) { +void AugmentedLagrangian::setConstraintTolerance(float_t constraintTolerance) { epsilon = constraintTolerance; } -float_t AugmentedLagrangian::getPenaltyStartValue() const { - return mu0; -} +float_t AugmentedLagrangian::getPenaltyStartValue() const { return mu0; } -void AugmentedLagrangian::setPenaltyStartValue( - float_t penaltyStartValue) { +void AugmentedLagrangian::setPenaltyStartValue(float_t penaltyStartValue) { mu0 = penaltyStartValue; } -float_t AugmentedLagrangian::getPenaltyIncreaseFactor() const { - return rhoMuPlus; -} +float_t AugmentedLagrangian::getPenaltyIncreaseFactor() const { return rhoMuPlus; } -void AugmentedLagrangian::setPenaltyIncreaseFactor( - float_t penaltyIncreaseFactor) { +void AugmentedLagrangian::setPenaltyIncreaseFactor(float_t penaltyIncreaseFactor) { rhoMuPlus = penaltyIncreaseFactor; } -const std::vector& -AugmentedLagrangian::getHistoryOfInnerIterations() const { +const std::vector& AugmentedLagrangian::getHistoryOfInnerIterations() const { return kHist; } -void AugmentedLagrangian::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new AugmentedLagrangian(*this)); -} -} -} +void AugmentedLagrangian::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new AugmentedLagrangian(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/constrained/AugmentedLagrangian.hpp b/optimization/src/sgpp/optimization/optimizer/constrained/AugmentedLagrangian.hpp index de68408d24..846ba2d026 100644 --- a/optimization/src/sgpp/optimization/optimizer/constrained/AugmentedLagrangian.hpp +++ b/optimization/src/sgpp/optimization/optimizer/constrained/AugmentedLagrangian.hpp @@ -12,6 +12,8 @@ #include #include +#include + namespace SGPP { namespace optimization { namespace optimizer { @@ -46,20 +48,13 @@ class AugmentedLagrangian : public ConstrainedOptimizer { * @param penaltyStartValue penalty start value * @param penaltyIncreaseFactor penalty increase factor */ - AugmentedLagrangian(ScalarFunction& f, - ScalarFunctionGradient& fGradient, - VectorFunction& g, - VectorFunctionGradient& gGradient, - VectorFunction& h, - VectorFunctionGradient& hGradient, - size_t maxItCount = DEFAULT_N, + AugmentedLagrangian(ScalarFunction& f, ScalarFunctionGradient& fGradient, VectorFunction& g, + VectorFunctionGradient& gGradient, VectorFunction& h, + VectorFunctionGradient& hGradient, size_t maxItCount = DEFAULT_N, float_t xTolerance = DEFAULT_X_TOLERANCE, - float_t constraintTolerance = - DEFAULT_CONSTRAINT_TOLERANCE, - float_t penaltyStartValue = - DEFAULT_PENALTY_START_VALUE, - float_t penaltyIncreaseFactor = - DEFAULT_PENALTY_INCREASE_FACTOR); + float_t constraintTolerance = DEFAULT_CONSTRAINT_TOLERANCE, + float_t penaltyStartValue = DEFAULT_PENALTY_START_VALUE, + float_t penaltyIncreaseFactor = DEFAULT_PENALTY_INCREASE_FACTOR); /** * Destructor. @@ -144,8 +139,7 @@ class AugmentedLagrangian : public ConstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// objective function gradient @@ -165,9 +159,8 @@ class AugmentedLagrangian : public ConstrainedOptimizer { /// search history (inner iterations) std::vector kHist; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_CONSTRAINED_AUGMENTEDLAGRANGIAN_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/constrained/ConstrainedOptimizer.hpp b/optimization/src/sgpp/optimization/optimizer/constrained/ConstrainedOptimizer.hpp index fdd81fd56a..cc29d9ec26 100644 --- a/optimization/src/sgpp/optimization/optimizer/constrained/ConstrainedOptimizer.hpp +++ b/optimization/src/sgpp/optimization/optimizer/constrained/ConstrainedOptimizer.hpp @@ -42,35 +42,24 @@ class ConstrainedOptimizer : public UnconstrainedOptimizer { * objective function evaluations * (depending on the implementation) */ - ConstrainedOptimizer( - ScalarFunction& f, - VectorFunction& g, - VectorFunction& h, - size_t N = DEFAULT_N) : - UnconstrainedOptimizer(f, N), - g(g), - h(h) { - } + ConstrainedOptimizer(ScalarFunction& f, VectorFunction& g, VectorFunction& h, + size_t N = DEFAULT_N) + : UnconstrainedOptimizer(f, N), g(g), h(h) {} /** * Destructor. */ - virtual ~ConstrainedOptimizer() override { - } + ~ConstrainedOptimizer() override {} /** * @return inequality constraint function */ - VectorFunction& getInequalityConstraintFunction() const { - return g; - } + VectorFunction& getInequalityConstraintFunction() const { return g; } /** * @return equality constraint function */ - VectorFunction& getEqualityConstraintFunction() const { - return h; - } + VectorFunction& getEqualityConstraintFunction() const { return h; } protected: /// inequality constraint function @@ -78,9 +67,8 @@ class ConstrainedOptimizer : public UnconstrainedOptimizer { /// equality constraint function VectorFunction& h; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_CONSTRAINED_CONSTRAINEDOPTIMIZER_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/constrained/LogBarrier.cpp b/optimization/src/sgpp/optimization/optimizer/constrained/LogBarrier.cpp index 9463c5f40f..f1c572947c 100644 --- a/optimization/src/sgpp/optimization/optimizer/constrained/LogBarrier.cpp +++ b/optimization/src/sgpp/optimization/optimizer/constrained/LogBarrier.cpp @@ -10,6 +10,8 @@ #include #include +#include + namespace SGPP { namespace optimization { namespace optimizer { @@ -17,15 +19,12 @@ namespace optimizer { namespace { class PenalizedObjectiveFunction : public ScalarFunction { public: - PenalizedObjectiveFunction(ScalarFunction& f, - VectorFunction& g, - float_t mu) : - ScalarFunction(f.getNumberOfParameters()), - f(f), - g(g), - mu(mu), - m(g.getNumberOfComponents()) { - } + PenalizedObjectiveFunction(ScalarFunction& f, VectorFunction& g, float_t mu) + : ScalarFunction(f.getNumberOfParameters()), + f(f), + g(g), + mu(mu), + m(g.getNumberOfComponents()) {} float_t eval(const base::DataVector& x) { for (size_t t = 0; t < d; t++) { @@ -52,13 +51,10 @@ class PenalizedObjectiveFunction : public ScalarFunction { } void clone(std::unique_ptr& clone) const { - clone = std::unique_ptr( - new PenalizedObjectiveFunction(*this)); + clone = std::unique_ptr(new PenalizedObjectiveFunction(*this)); } - void setMu(float_t mu) { - this->mu = mu; - } + void setMu(float_t mu) { this->mu = mu; } protected: ScalarFunction& f; @@ -69,18 +65,15 @@ class PenalizedObjectiveFunction : public ScalarFunction { class PenalizedObjectiveGradient : public ScalarFunctionGradient { public: - PenalizedObjectiveGradient(ScalarFunctionGradient& fGradient, - VectorFunctionGradient& gGradient, - float_t mu) : - ScalarFunctionGradient(fGradient.getNumberOfParameters()), - fGradient(fGradient), - gGradient(gGradient), - mu(mu), - m(gGradient.getNumberOfComponents()) { - } - - float_t eval(const base::DataVector& x, - base::DataVector& gradient) { + PenalizedObjectiveGradient(ScalarFunctionGradient& fGradient, VectorFunctionGradient& gGradient, + float_t mu) + : ScalarFunctionGradient(fGradient.getNumberOfParameters()), + fGradient(fGradient), + gGradient(gGradient), + mu(mu), + m(gGradient.getNumberOfComponents()) {} + + float_t eval(const base::DataVector& x, base::DataVector& gradient) { for (size_t t = 0; t < d; t++) { if ((x[t] < 0.0) || (x[t] > 1.0)) { gradient.setAll(NAN); @@ -116,13 +109,10 @@ class PenalizedObjectiveGradient : public ScalarFunctionGradient { } void clone(std::unique_ptr& clone) const { - clone = std::unique_ptr( - new PenalizedObjectiveGradient(*this)); + clone = std::unique_ptr(new PenalizedObjectiveGradient(*this)); } - void setMu(float_t mu) { - this->mu = mu; - } + void setMu(float_t mu) { this->mu = mu; } protected: ScalarFunctionGradient& fGradient; @@ -130,29 +120,20 @@ class PenalizedObjectiveGradient : public ScalarFunctionGradient { float_t mu; size_t m; }; -} +} // namespace -LogBarrier::LogBarrier( - ScalarFunction& f, - ScalarFunctionGradient& fGradient, - VectorFunction& g, - VectorFunctionGradient& gGradient, - size_t maxItCount, - float_t tolerance, - float_t barrierStartValue, - float_t barrierDecreaseFactor) : - ConstrainedOptimizer(f, g, EmptyVectorFunction::getInstance(), - maxItCount), - fGradient(fGradient), - gGradient(gGradient), - theta(tolerance), - mu0(barrierStartValue), - rhoMuMinus(barrierDecreaseFactor), - kHist() { -} +LogBarrier::LogBarrier(ScalarFunction& f, ScalarFunctionGradient& fGradient, VectorFunction& g, + VectorFunctionGradient& gGradient, size_t maxItCount, float_t tolerance, + float_t barrierStartValue, float_t barrierDecreaseFactor) + : ConstrainedOptimizer(f, g, EmptyVectorFunction::getInstance(), maxItCount), + fGradient(fGradient), + gGradient(gGradient), + theta(tolerance), + mu0(barrierStartValue), + rhoMuMinus(barrierDecreaseFactor), + kHist() {} -LogBarrier::~LogBarrier() { -} +LogBarrier::~LogBarrier() {} void LogBarrier::optimize() { Printer::getInstance().printStatusBegin("Optimizing (Log Barrier)..."); @@ -184,21 +165,20 @@ void LogBarrier::optimize() { const size_t unconstrainedN = N / 20; PenalizedObjectiveFunction fPenalized(f, g, mu); - PenalizedObjectiveGradient fPenalizedGradient( - fGradient, gGradient, mu); + PenalizedObjectiveGradient fPenalizedGradient(fGradient, gGradient, mu); while (k < N) { fPenalized.setMu(mu); fPenalizedGradient.setMu(mu); - AdaptiveGradientDescent unconstrainedOptimizer( - fPenalized, fPenalizedGradient, unconstrainedN, 10.0 * theta); + AdaptiveGradientDescent unconstrainedOptimizer(fPenalized, fPenalizedGradient, unconstrainedN, + 10.0 * theta); unconstrainedOptimizer.setStartingPoint(x); unconstrainedOptimizer.optimize(); xNew = unconstrainedOptimizer.getOptimalPoint(); const size_t numberInnerEvaluations = - unconstrainedOptimizer.getHistoryOfOptimalPoints().getNrows(); + unconstrainedOptimizer.getHistoryOfOptimalPoints().getNrows(); k += numberInnerEvaluations; x = xNew; @@ -211,10 +191,9 @@ void LogBarrier::optimize() { kHist.push_back(numberInnerEvaluations); // status printing - Printer::getInstance().printStatusUpdate( - std::to_string(k) + " evaluations, x = " + x.toString() + - ", f(x) = " + std::to_string(fx) + - ", g(x) = " + gx.toString()); + Printer::getInstance().printStatusUpdate(std::to_string(k) + " evaluations, x = " + + x.toString() + ", f(x) = " + std::to_string(fx) + + ", g(x) = " + gx.toString()); mu *= rhoMuMinus; @@ -237,49 +216,29 @@ void LogBarrier::optimize() { Printer::getInstance().printStatusEnd(); } -ScalarFunctionGradient& LogBarrier::getObjectiveGradient() const { - return fGradient; -} +ScalarFunctionGradient& LogBarrier::getObjectiveGradient() const { return fGradient; } -VectorFunctionGradient& LogBarrier::getInequalityConstraintGradient() const { - return gGradient; -} +VectorFunctionGradient& LogBarrier::getInequalityConstraintGradient() const { return gGradient; } -float_t LogBarrier::getTolerance() const { - return theta; -} +float_t LogBarrier::getTolerance() const { return theta; } -void LogBarrier::setTolerance(float_t tolerance) { - theta = tolerance; -} +void LogBarrier::setTolerance(float_t tolerance) { theta = tolerance; } -float_t LogBarrier::getBarrierStartValue() const { - return mu0; -} +float_t LogBarrier::getBarrierStartValue() const { return mu0; } -void LogBarrier::setBarrierStartValue(float_t barrierStartValue) { - mu0 = barrierStartValue; -} +void LogBarrier::setBarrierStartValue(float_t barrierStartValue) { mu0 = barrierStartValue; } -float_t LogBarrier::getBarrierDecreaseFactor() const { - return rhoMuMinus; -} +float_t LogBarrier::getBarrierDecreaseFactor() const { return rhoMuMinus; } -void LogBarrier::setBarrierDecreaseFactor( - float_t barrierDecreaseFactor) { +void LogBarrier::setBarrierDecreaseFactor(float_t barrierDecreaseFactor) { rhoMuMinus = barrierDecreaseFactor; } -const std::vector& -LogBarrier::getHistoryOfInnerIterations() const { - return kHist; -} +const std::vector& LogBarrier::getHistoryOfInnerIterations() const { return kHist; } -void LogBarrier::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new LogBarrier(*this)); -} -} -} +void LogBarrier::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new LogBarrier(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/constrained/LogBarrier.hpp b/optimization/src/sgpp/optimization/optimizer/constrained/LogBarrier.hpp index b2ea4d4d94..f0f517105f 100644 --- a/optimization/src/sgpp/optimization/optimizer/constrained/LogBarrier.hpp +++ b/optimization/src/sgpp/optimization/optimizer/constrained/LogBarrier.hpp @@ -12,6 +12,8 @@ #include #include +#include + namespace SGPP { namespace optimization { namespace optimizer { @@ -41,15 +43,11 @@ class LogBarrier : public ConstrainedOptimizer { * @param barrierStartValue barrier start value * @param barrierDecreaseFactor barrier decrease factor */ - LogBarrier(ScalarFunction& f, - ScalarFunctionGradient& fGradient, - VectorFunction& g, - VectorFunctionGradient& gGradient, - size_t maxItCount = DEFAULT_N, + LogBarrier(ScalarFunction& f, ScalarFunctionGradient& fGradient, VectorFunction& g, + VectorFunctionGradient& gGradient, size_t maxItCount = DEFAULT_N, float_t tolerance = DEFAULT_TOLERANCE, float_t barrierStartValue = DEFAULT_BARRIER_START_VALUE, - float_t barrierDecreaseFactor = - DEFAULT_BARRIER_DECREASE_FACTOR); + float_t barrierDecreaseFactor = DEFAULT_BARRIER_DECREASE_FACTOR); /** * Destructor. @@ -108,8 +106,7 @@ class LogBarrier : public ConstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// objective function gradient @@ -125,9 +122,8 @@ class LogBarrier : public ConstrainedOptimizer { /// search history (inner iterations) std::vector kHist; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_CONSTRAINED_LOGBARRIER_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/constrained/SquaredPenalty.cpp b/optimization/src/sgpp/optimization/optimizer/constrained/SquaredPenalty.cpp index 1d2ff8a52f..39fdbe8f80 100644 --- a/optimization/src/sgpp/optimization/optimizer/constrained/SquaredPenalty.cpp +++ b/optimization/src/sgpp/optimization/optimizer/constrained/SquaredPenalty.cpp @@ -9,6 +9,8 @@ #include #include +#include + namespace SGPP { namespace optimization { namespace optimizer { @@ -16,18 +18,14 @@ namespace optimizer { namespace { class PenalizedObjectiveFunction : public ScalarFunction { public: - PenalizedObjectiveFunction(ScalarFunction& f, - VectorFunction& g, - VectorFunction& h, - float_t mu) : - ScalarFunction(f.getNumberOfParameters()), - f(f), - g(g), - h(h), - mu(mu), - mG(g.getNumberOfComponents()), - mH(h.getNumberOfComponents()) { - } + PenalizedObjectiveFunction(ScalarFunction& f, VectorFunction& g, VectorFunction& h, float_t mu) + : ScalarFunction(f.getNumberOfParameters()), + f(f), + g(g), + h(h), + mu(mu), + mG(g.getNumberOfComponents()), + mH(h.getNumberOfComponents()) {} float_t eval(const base::DataVector& x) { for (size_t t = 0; t < d; t++) { @@ -60,13 +58,10 @@ class PenalizedObjectiveFunction : public ScalarFunction { } void clone(std::unique_ptr& clone) const { - clone = std::unique_ptr( - new PenalizedObjectiveFunction(*this)); + clone = std::unique_ptr(new PenalizedObjectiveFunction(*this)); } - void setMu(float_t mu) { - this->mu = mu; - } + void setMu(float_t mu) { this->mu = mu; } protected: ScalarFunction& f; @@ -79,21 +74,17 @@ class PenalizedObjectiveFunction : public ScalarFunction { class PenalizedObjectiveGradient : public ScalarFunctionGradient { public: - PenalizedObjectiveGradient(ScalarFunctionGradient& fGradient, - VectorFunctionGradient& gGradient, - VectorFunctionGradient& hGradient, - float_t mu) : - ScalarFunctionGradient(fGradient.getNumberOfParameters()), - fGradient(fGradient), - gGradient(gGradient), - hGradient(hGradient), - mu(mu), - mG(gGradient.getNumberOfComponents()), - mH(hGradient.getNumberOfComponents()) { - } - - float_t eval(const base::DataVector& x, - base::DataVector& gradient) { + PenalizedObjectiveGradient(ScalarFunctionGradient& fGradient, VectorFunctionGradient& gGradient, + VectorFunctionGradient& hGradient, float_t mu) + : ScalarFunctionGradient(fGradient.getNumberOfParameters()), + fGradient(fGradient), + gGradient(gGradient), + hGradient(hGradient), + mu(mu), + mG(gGradient.getNumberOfComponents()), + mH(hGradient.getNumberOfComponents()) {} + + float_t eval(const base::DataVector& x, base::DataVector& gradient) { for (size_t t = 0; t < d; t++) { if ((x[t] < 0.0) || (x[t] > 1.0)) { gradient.setAll(NAN); @@ -141,13 +132,10 @@ class PenalizedObjectiveGradient : public ScalarFunctionGradient { } void clone(std::unique_ptr& clone) const { - clone = std::unique_ptr( - new PenalizedObjectiveGradient(*this)); + clone = std::unique_ptr(new PenalizedObjectiveGradient(*this)); } - void setMu(float_t mu) { - this->mu = mu; - } + void setMu(float_t mu) { this->mu = mu; } protected: ScalarFunctionGradient& fGradient; @@ -157,33 +145,24 @@ class PenalizedObjectiveGradient : public ScalarFunctionGradient { size_t mG; size_t mH; }; -} - -SquaredPenalty::SquaredPenalty( - ScalarFunction& f, - ScalarFunctionGradient& fGradient, - VectorFunction& g, - VectorFunctionGradient& gGradient, - VectorFunction& h, - VectorFunctionGradient& hGradient, - size_t maxItCount, - float_t xTolerance, - float_t constraintTolerance, - float_t penaltyStartValue, - float_t penaltyIncreaseFactor) : - ConstrainedOptimizer(f, g, h, maxItCount), - fGradient(fGradient), - gGradient(gGradient), - hGradient(hGradient), - theta(xTolerance), - epsilon(constraintTolerance), - mu0(penaltyStartValue), - rhoMuPlus(penaltyIncreaseFactor), - kHist() { -} - -SquaredPenalty::~SquaredPenalty() { -} +} // namespace + +SquaredPenalty::SquaredPenalty(ScalarFunction& f, ScalarFunctionGradient& fGradient, + VectorFunction& g, VectorFunctionGradient& gGradient, + VectorFunction& h, VectorFunctionGradient& hGradient, + size_t maxItCount, float_t xTolerance, float_t constraintTolerance, + float_t penaltyStartValue, float_t penaltyIncreaseFactor) + : ConstrainedOptimizer(f, g, h, maxItCount), + fGradient(fGradient), + gGradient(gGradient), + hGradient(hGradient), + theta(xTolerance), + epsilon(constraintTolerance), + mu0(penaltyStartValue), + rhoMuPlus(penaltyIncreaseFactor), + kHist() {} + +SquaredPenalty::~SquaredPenalty() {} void SquaredPenalty::optimize() { Printer::getInstance().printStatusBegin("Optimizing (Squared Penalty)..."); @@ -219,21 +198,20 @@ void SquaredPenalty::optimize() { const size_t unconstrainedN = N / 20; PenalizedObjectiveFunction fPenalized(f, g, h, mu); - PenalizedObjectiveGradient fPenalizedGradient( - fGradient, gGradient, hGradient, mu); + PenalizedObjectiveGradient fPenalizedGradient(fGradient, gGradient, hGradient, mu); while (k < N) { fPenalized.setMu(mu); fPenalizedGradient.setMu(mu); - AdaptiveGradientDescent unconstrainedOptimizer( - fPenalized, fPenalizedGradient, unconstrainedN, 10.0 * theta); + AdaptiveGradientDescent unconstrainedOptimizer(fPenalized, fPenalizedGradient, unconstrainedN, + 10.0 * theta); unconstrainedOptimizer.setStartingPoint(x); unconstrainedOptimizer.optimize(); xNew = unconstrainedOptimizer.getOptimalPoint(); const size_t numberInnerEvaluations = - unconstrainedOptimizer.getHistoryOfOptimalPoints().getNrows(); + unconstrainedOptimizer.getHistoryOfOptimalPoints().getNrows(); k += numberInnerEvaluations; x = xNew; @@ -248,18 +226,14 @@ void SquaredPenalty::optimize() { // status printing Printer::getInstance().printStatusUpdate( - std::to_string(k) + " evaluations, x = " + x.toString() + - ", f(x) = " + std::to_string(fx) + - ", g(x) = " + gx.toString() + - ", h(x) = " + hx.toString()); + std::to_string(k) + " evaluations, x = " + x.toString() + ", f(x) = " + std::to_string(fx) + + ", g(x) = " + gx.toString() + ", h(x) = " + hx.toString()); mu *= rhoMuPlus; xNew.sub(x); - if ((xNew.l2Norm() < theta) && - (gx.max() < epsilon) && - (hx.maxNorm() < epsilon)) { + if ((xNew.l2Norm() < theta) && (gx.max() < epsilon) && (hx.maxNorm() < epsilon)) { breakIterationCounter++; if (breakIterationCounter >= BREAK_ITERATION_COUNTER_MAX) { @@ -276,62 +250,39 @@ void SquaredPenalty::optimize() { Printer::getInstance().printStatusEnd(); } -ScalarFunctionGradient& SquaredPenalty::getObjectiveGradient() const { - return fGradient; -} +ScalarFunctionGradient& SquaredPenalty::getObjectiveGradient() const { return fGradient; } -VectorFunctionGradient& -SquaredPenalty::getInequalityConstraintGradient() const { +VectorFunctionGradient& SquaredPenalty::getInequalityConstraintGradient() const { return gGradient; } -VectorFunctionGradient& SquaredPenalty::getEqualityConstraintGradient() const { - return hGradient; -} +VectorFunctionGradient& SquaredPenalty::getEqualityConstraintGradient() const { return hGradient; } -float_t SquaredPenalty::getXTolerance() const { - return theta; -} +float_t SquaredPenalty::getXTolerance() const { return theta; } -void SquaredPenalty::setXTolerance(float_t xTolerance) { - theta = xTolerance; -} +void SquaredPenalty::setXTolerance(float_t xTolerance) { theta = xTolerance; } -float_t SquaredPenalty::getConstraintTolerance() const { - return epsilon; -} +float_t SquaredPenalty::getConstraintTolerance() const { return epsilon; } void SquaredPenalty::setConstraintTolerance(float_t constraintTolerance) { epsilon = constraintTolerance; } -float_t SquaredPenalty::getPenaltyStartValue() const { - return mu0; -} +float_t SquaredPenalty::getPenaltyStartValue() const { return mu0; } -void SquaredPenalty::setPenaltyStartValue(float_t penaltyStartValue) { - mu0 = penaltyStartValue; -} +void SquaredPenalty::setPenaltyStartValue(float_t penaltyStartValue) { mu0 = penaltyStartValue; } -float_t SquaredPenalty::getPenaltyIncreaseFactor() const { - return rhoMuPlus; -} +float_t SquaredPenalty::getPenaltyIncreaseFactor() const { return rhoMuPlus; } -void SquaredPenalty::setPenaltyIncreaseFactor( - float_t penaltyIncreaseFactor) { +void SquaredPenalty::setPenaltyIncreaseFactor(float_t penaltyIncreaseFactor) { rhoMuPlus = penaltyIncreaseFactor; } -const std::vector& -SquaredPenalty::getHistoryOfInnerIterations() const { - return kHist; -} +const std::vector& SquaredPenalty::getHistoryOfInnerIterations() const { return kHist; } -void SquaredPenalty::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new SquaredPenalty(*this)); -} -} -} +void SquaredPenalty::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new SquaredPenalty(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/constrained/SquaredPenalty.hpp b/optimization/src/sgpp/optimization/optimizer/constrained/SquaredPenalty.hpp index 14feca0352..2c9a92c4ad 100644 --- a/optimization/src/sgpp/optimization/optimizer/constrained/SquaredPenalty.hpp +++ b/optimization/src/sgpp/optimization/optimizer/constrained/SquaredPenalty.hpp @@ -12,6 +12,8 @@ #include #include +#include + namespace SGPP { namespace optimization { namespace optimizer { @@ -46,20 +48,13 @@ class SquaredPenalty : public ConstrainedOptimizer { * @param penaltyStartValue penalty start value * @param penaltyIncreaseFactor penalty increase factor */ - SquaredPenalty(ScalarFunction& f, - ScalarFunctionGradient& fGradient, - VectorFunction& g, - VectorFunctionGradient& gGradient, - VectorFunction& h, - VectorFunctionGradient& hGradient, - size_t maxItCount = DEFAULT_N, + SquaredPenalty(ScalarFunction& f, ScalarFunctionGradient& fGradient, VectorFunction& g, + VectorFunctionGradient& gGradient, VectorFunction& h, + VectorFunctionGradient& hGradient, size_t maxItCount = DEFAULT_N, float_t xTolerance = DEFAULT_X_TOLERANCE, - float_t constraintTolerance = - DEFAULT_CONSTRAINT_TOLERANCE, - float_t penaltyStartValue = - DEFAULT_PENALTY_START_VALUE, - float_t penaltyIncreaseFactor = - DEFAULT_PENALTY_INCREASE_FACTOR); + float_t constraintTolerance = DEFAULT_CONSTRAINT_TOLERANCE, + float_t penaltyStartValue = DEFAULT_PENALTY_START_VALUE, + float_t penaltyIncreaseFactor = DEFAULT_PENALTY_INCREASE_FACTOR); /** * Destructor. @@ -133,8 +128,7 @@ class SquaredPenalty : public ConstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// objective function gradient @@ -154,9 +148,8 @@ class SquaredPenalty : public ConstrainedOptimizer { /// search history (inner iterations) std::vector kHist; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_CONSTRAINED_SQUAREDPENALTY_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/least_squares/LeastSquaresOptimizer.hpp b/optimization/src/sgpp/optimization/optimizer/least_squares/LeastSquaresOptimizer.hpp index 5ac20ee257..e8af1014a4 100644 --- a/optimization/src/sgpp/optimization/optimizer/least_squares/LeastSquaresOptimizer.hpp +++ b/optimization/src/sgpp/optimization/optimizer/least_squares/LeastSquaresOptimizer.hpp @@ -36,21 +36,19 @@ class LeastSquaresOptimizer { * @param N maximal number of iterations or function evaluations * (depending on the implementation) */ - LeastSquaresOptimizer(VectorFunction& phi, size_t N = DEFAULT_N) : - phi(phi), - N(N), - x0(phi.getNumberOfParameters(), 0.5), - xOpt(0), - fOpt(NAN), - xHist(0, 0), - fHist(0) { - } + explicit LeastSquaresOptimizer(VectorFunction& phi, size_t N = DEFAULT_N) + : phi(phi), + N(N), + x0(phi.getNumberOfParameters(), 0.5), + xOpt(0), + fOpt(NAN), + xHist(0, 0), + fHist(0) {} /** * Destructor. */ - virtual ~LeastSquaresOptimizer() { - } + virtual ~LeastSquaresOptimizer() {} /** * Pure virtual method for optimization of the objective function. @@ -62,71 +60,53 @@ class LeastSquaresOptimizer { /** * @return phi */ - VectorFunction& getPhiFunction() const { - return phi; - } + VectorFunction& getPhiFunction() const { return phi; } /** * @return maximal number of iterations or function evaluations */ - size_t getN() const { - return N; - } + size_t getN() const { return N; } /** * @param N maximal number of iterations or function evaluations */ - void setN(size_t N) { - this->N = N; - } + void setN(size_t N) { this->N = N; } /** * @return starting point */ - const base::DataVector& getStartingPoint() const { - return x0; - } + const base::DataVector& getStartingPoint() const { return x0; } /** * @param startingPoint starting point */ - void setStartingPoint(const base::DataVector& startingPoint) { - this->x0 = startingPoint; - } + void setStartingPoint(const base::DataVector& startingPoint) { this->x0 = startingPoint; } /** * @return result of optimization (location of optimum), * empty vector on error */ - const base::DataVector& getOptimalPoint() const { - return xOpt; - } + const base::DataVector& getOptimalPoint() const { return xOpt; } /** * @return result of optimization (optimal function value), * NAN on error */ - float_t getOptimalValue() const { - return fOpt; - } + float_t getOptimalValue() const { return fOpt; } /** * @return tall matrix (d columns) in which the k-th row indicates * the best point after k iterations of the optimization, * empty matrix on error or if not supported */ - const base::DataMatrix& getHistoryOfOptimalPoints() const { - return xHist; - } + const base::DataMatrix& getHistoryOfOptimalPoints() const { return xHist; } /** * @return vector in which the k-th entry indicates the best * function value after k iterations of the optimization, * empty vector on error or if not supported */ - const base::DataVector& getHistoryOfOptimalValues() const { - return fHist; - } + const base::DataVector& getHistoryOfOptimalValues() const { return fHist; } /** * Pure virtual method for cloning the optimizer. @@ -135,8 +115,7 @@ class LeastSquaresOptimizer { * * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& - clone) const = 0; + virtual void clone(std::unique_ptr& clone) const = 0; protected: /// phi function @@ -154,9 +133,8 @@ class LeastSquaresOptimizer { /// search history vector (optimal values) base::DataVector fHist; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_LEAST_SQUARES_LEASTSQUARESOPTIMIZER_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/least_squares/LevenbergMarquardt.cpp b/optimization/src/sgpp/optimization/optimizer/least_squares/LevenbergMarquardt.cpp index 65ad14ea49..7de1d08ef8 100644 --- a/optimization/src/sgpp/optimization/optimizer/least_squares/LevenbergMarquardt.cpp +++ b/optimization/src/sgpp/optimization/optimizer/least_squares/LevenbergMarquardt.cpp @@ -13,45 +13,32 @@ namespace SGPP { namespace optimization { namespace optimizer { -LevenbergMarquardt::LevenbergMarquardt( - VectorFunction& phi, - VectorFunctionGradient& phiGradient, - size_t maxItCount, - float_t tolerance, - float_t initialDamping, - float_t acceptanceThreshold, - float_t effectivenessThreshold) : - LeastSquaresOptimizer(phi, maxItCount), - phiGradient(phiGradient), - tol(tolerance), - mu0(initialDamping), - beta0(acceptanceThreshold), - beta1(effectivenessThreshold), - defaultSleSolver(sle_solver::GaussianElimination()), - sleSolver(defaultSleSolver) { -} - -LevenbergMarquardt::LevenbergMarquardt( - VectorFunction& phi, - VectorFunctionGradient& phiGradient, - size_t maxItCount, - float_t tolerance, - float_t damping, - float_t acceptanceThreshold, - float_t effectivenessThreshold, - const sle_solver::SLESolver& sleSolver) : - LeastSquaresOptimizer(phi, maxItCount), - phiGradient(phiGradient), - tol(tolerance), - mu0(damping), - beta0(acceptanceThreshold), - beta1(effectivenessThreshold), - defaultSleSolver(sle_solver::GaussianElimination()), - sleSolver(sleSolver) { -} - -LevenbergMarquardt::~LevenbergMarquardt() { -} +LevenbergMarquardt::LevenbergMarquardt(VectorFunction& phi, VectorFunctionGradient& phiGradient, + size_t maxItCount, float_t tolerance, float_t initialDamping, + float_t acceptanceThreshold, float_t effectivenessThreshold) + : LeastSquaresOptimizer(phi, maxItCount), + phiGradient(phiGradient), + tol(tolerance), + mu0(initialDamping), + beta0(acceptanceThreshold), + beta1(effectivenessThreshold), + defaultSleSolver(sle_solver::GaussianElimination()), + sleSolver(defaultSleSolver) {} + +LevenbergMarquardt::LevenbergMarquardt(VectorFunction& phi, VectorFunctionGradient& phiGradient, + size_t maxItCount, float_t tolerance, float_t damping, + float_t acceptanceThreshold, float_t effectivenessThreshold, + const sle_solver::SLESolver& sleSolver) + : LeastSquaresOptimizer(phi, maxItCount), + phiGradient(phiGradient), + tol(tolerance), + mu0(damping), + beta0(acceptanceThreshold), + beta1(effectivenessThreshold), + defaultSleSolver(sle_solver::GaussianElimination()), + sleSolver(sleSolver) {} + +LevenbergMarquardt::~LevenbergMarquardt() {} void LevenbergMarquardt::optimize() { Printer::getInstance().printStatusBegin("Optimizing (Levenberg-Marquardt)..."); @@ -82,8 +69,7 @@ void LevenbergMarquardt::optimize() { base::DataMatrix gradPhixSquared(m, m); size_t k = 0; - const bool statusPrintingEnabled = - Printer::getInstance().isStatusPrintingEnabled(); + const bool statusPrintingEnabled = Printer::getInstance().isStatusPrintingEnabled(); while (k < N) { // calculate gradient of phi @@ -192,9 +178,8 @@ void LevenbergMarquardt::optimize() { } // status printing - Printer::getInstance().printStatusUpdate( - std::to_string(k) + " evaluations, x = " + x.toString() + - ", f(x) = " + std::to_string(fx)); + Printer::getInstance().printStatusUpdate(std::to_string(k) + " evaluations, x = " + + x.toString() + ", f(x) = " + std::to_string(fx)); x = y; xHist.appendRow(x); @@ -212,49 +197,31 @@ void LevenbergMarquardt::optimize() { Printer::getInstance().printStatusEnd(); } -VectorFunctionGradient& LevenbergMarquardt::getPhiGradient() const { - return phiGradient; -} +VectorFunctionGradient& LevenbergMarquardt::getPhiGradient() const { return phiGradient; } -float_t LevenbergMarquardt::getTolerance() const { - return tol; -} +float_t LevenbergMarquardt::getTolerance() const { return tol; } -void LevenbergMarquardt::setTolerance(float_t tolerance) { - tol = tolerance; -} +void LevenbergMarquardt::setTolerance(float_t tolerance) { tol = tolerance; } -float_t LevenbergMarquardt::getInitialDamping() const { - return mu0; -} +float_t LevenbergMarquardt::getInitialDamping() const { return mu0; } -void LevenbergMarquardt::setInitialDamping(float_t initialDamping) { - mu0 = initialDamping; -} +void LevenbergMarquardt::setInitialDamping(float_t initialDamping) { mu0 = initialDamping; } -float_t LevenbergMarquardt::getAcceptanceThreshold() const { - return beta0; -} +float_t LevenbergMarquardt::getAcceptanceThreshold() const { return beta0; } -void LevenbergMarquardt::setAcceptanceThreshold( - float_t acceptanceThreshold) { +void LevenbergMarquardt::setAcceptanceThreshold(float_t acceptanceThreshold) { beta0 = acceptanceThreshold; } -float_t LevenbergMarquardt::getEffectivenessThreshold() const { - return beta1; -} +float_t LevenbergMarquardt::getEffectivenessThreshold() const { return beta1; } -void LevenbergMarquardt::setEffectivenessThreshold( - float_t effectivenessThreshold) { +void LevenbergMarquardt::setEffectivenessThreshold(float_t effectivenessThreshold) { beta1 = effectivenessThreshold; } -void LevenbergMarquardt::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new LevenbergMarquardt(*this)); -} -} -} +void LevenbergMarquardt::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new LevenbergMarquardt(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/least_squares/LevenbergMarquardt.hpp b/optimization/src/sgpp/optimization/optimizer/least_squares/LevenbergMarquardt.hpp index 7f79d8e144..b2f3f92689 100644 --- a/optimization/src/sgpp/optimization/optimizer/least_squares/LevenbergMarquardt.hpp +++ b/optimization/src/sgpp/optimization/optimizer/least_squares/LevenbergMarquardt.hpp @@ -44,15 +44,11 @@ class LevenbergMarquardt : public LeastSquaresOptimizer { * @param acceptanceThreshold acceptance threshold * @param effectivenessThreshold effectiveness threshold */ - LevenbergMarquardt(VectorFunction& phi, - VectorFunctionGradient& phiGradient, - size_t maxItCount = DEFAULT_N, - float_t tolerance = DEFAULT_TOLERANCE, + LevenbergMarquardt(VectorFunction& phi, VectorFunctionGradient& phiGradient, + size_t maxItCount = DEFAULT_N, float_t tolerance = DEFAULT_TOLERANCE, float_t initialDamping = DEFAULT_INITIAL_DAMPING, - float_t acceptanceThreshold = - DEFAULT_ACCEPTANCE_THRESHOLD, - float_t effectivenessThreshold = - DEFAULT_EFFECTIVENESS_THRESHOLD); + float_t acceptanceThreshold = DEFAULT_ACCEPTANCE_THRESHOLD, + float_t effectivenessThreshold = DEFAULT_EFFECTIVENESS_THRESHOLD); /** * Constructor. @@ -69,14 +65,9 @@ class LevenbergMarquardt : public LeastSquaresOptimizer { * @param sleSolver reference to linear solver * for solving the linear systems */ - LevenbergMarquardt(VectorFunction& phi, - VectorFunctionGradient& phiGradient, - size_t maxItCount, - float_t tolerance, - float_t initialDamping, - float_t acceptanceThreshold, - float_t effectivenessThreshold, - const sle_solver::SLESolver& sleSolver); + LevenbergMarquardt(VectorFunction& phi, VectorFunctionGradient& phiGradient, size_t maxItCount, + float_t tolerance, float_t initialDamping, float_t acceptanceThreshold, + float_t effectivenessThreshold, const sle_solver::SLESolver& sleSolver); /** * Destructor. @@ -133,8 +124,7 @@ class LevenbergMarquardt : public LeastSquaresOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// phi gradient @@ -152,9 +142,8 @@ class LevenbergMarquardt : public LeastSquaresOptimizer { /// linear solver const sle_solver::SLESolver& sleSolver; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_LEAST_SQUARES_LEVENBERGMARQUARDT_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveGradientDescent.cpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveGradientDescent.cpp index b19d1790a2..685efc47fe 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveGradientDescent.cpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveGradientDescent.cpp @@ -13,23 +13,16 @@ namespace optimization { namespace optimizer { AdaptiveGradientDescent::AdaptiveGradientDescent( - ScalarFunction& f, - ScalarFunctionGradient& fGradient, - size_t maxItCount, - float_t tolerance, - float_t stepSizeIncreaseFactor, - float_t stepSizeDecreaseFactor, - float_t lineSearchAccuracy) : - UnconstrainedOptimizer(f, maxItCount), - fGradient(fGradient), - theta(tolerance), - rhoAlphaPlus(stepSizeIncreaseFactor), - rhoAlphaMinus(stepSizeDecreaseFactor), - rhoLs(lineSearchAccuracy) { -} + ScalarFunction& f, ScalarFunctionGradient& fGradient, size_t maxItCount, float_t tolerance, + float_t stepSizeIncreaseFactor, float_t stepSizeDecreaseFactor, float_t lineSearchAccuracy) + : UnconstrainedOptimizer(f, maxItCount), + fGradient(fGradient), + theta(tolerance), + rhoAlphaPlus(stepSizeIncreaseFactor), + rhoAlphaMinus(stepSizeDecreaseFactor), + rhoLs(lineSearchAccuracy) {} -AdaptiveGradientDescent::~AdaptiveGradientDescent() { -} +AdaptiveGradientDescent::~AdaptiveGradientDescent() {} void AdaptiveGradientDescent::optimize() { Printer::getInstance().printStatusBegin("Optimizing (adaptive gradient descent)..."); @@ -91,8 +84,7 @@ void AdaptiveGradientDescent::optimize() { const float_t gradFxTimesDir = -gradFxNorm; // line search - while ((fxNew > fx + rhoLs * alpha * gradFxTimesDir) && - (alpha > 0.0)) { + while ((fxNew > fx + rhoLs * alpha * gradFxTimesDir) && (alpha > 0.0)) { alpha *= rhoAlphaMinus; inDomain = true; @@ -126,9 +118,8 @@ void AdaptiveGradientDescent::optimize() { alpha *= rhoAlphaPlus; // status printing - Printer::getInstance().printStatusUpdate( - std::to_string(k) + " evaluations, x = " + x.toString() + - ", f(x) = " + std::to_string(fx)); + Printer::getInstance().printStatusUpdate(std::to_string(k) + " evaluations, x = " + + x.toString() + ", f(x) = " + std::to_string(fx)); // stopping criterion: // stop if alpha is smaller than tolerance theta @@ -150,50 +141,33 @@ void AdaptiveGradientDescent::optimize() { Printer::getInstance().printStatusEnd(); } -ScalarFunctionGradient& AdaptiveGradientDescent::getObjectiveGradient() const { - return fGradient; -} +ScalarFunctionGradient& AdaptiveGradientDescent::getObjectiveGradient() const { return fGradient; } -float_t AdaptiveGradientDescent::getTolerance() const { - return theta; -} +float_t AdaptiveGradientDescent::getTolerance() const { return theta; } -void AdaptiveGradientDescent::setTolerance(float_t tolerance) { - theta = tolerance; -} +void AdaptiveGradientDescent::setTolerance(float_t tolerance) { theta = tolerance; } -float_t AdaptiveGradientDescent::getStepSizeIncreaseFactor() const { - return rhoAlphaPlus; -} +float_t AdaptiveGradientDescent::getStepSizeIncreaseFactor() const { return rhoAlphaPlus; } -void AdaptiveGradientDescent::setStepSizeIncreaseFactor( - float_t stepSizeIncreaseFactor) { +void AdaptiveGradientDescent::setStepSizeIncreaseFactor(float_t stepSizeIncreaseFactor) { rhoAlphaPlus = stepSizeIncreaseFactor; } -float_t AdaptiveGradientDescent::getStepSizeDecreaseFactor() const { - return rhoAlphaMinus; -} +float_t AdaptiveGradientDescent::getStepSizeDecreaseFactor() const { return rhoAlphaMinus; } -void AdaptiveGradientDescent::setStepSizeDecreaseFactor( - float_t stepSizeDecreaseFactor) { +void AdaptiveGradientDescent::setStepSizeDecreaseFactor(float_t stepSizeDecreaseFactor) { rhoAlphaMinus = stepSizeDecreaseFactor; } -float_t AdaptiveGradientDescent::getLineSearchAccuracy() const { - return rhoLs; -} +float_t AdaptiveGradientDescent::getLineSearchAccuracy() const { return rhoLs; } -void AdaptiveGradientDescent::setLineSearchAccuracy( - float_t lineSearchAccuracy) { +void AdaptiveGradientDescent::setLineSearchAccuracy(float_t lineSearchAccuracy) { rhoLs = lineSearchAccuracy; } -void AdaptiveGradientDescent::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new AdaptiveGradientDescent(*this)); -} -} -} +void AdaptiveGradientDescent::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new AdaptiveGradientDescent(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveGradientDescent.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveGradientDescent.hpp index e2a7883ed1..a8711d3793 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveGradientDescent.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveGradientDescent.hpp @@ -41,14 +41,10 @@ class AdaptiveGradientDescent : public UnconstrainedOptimizer { * @param stepSizeDecreaseFactor step size decrease factor * @param lineSearchAccuracy line search accuracy */ - AdaptiveGradientDescent(ScalarFunction& f, - ScalarFunctionGradient& fGradient, - size_t maxItCount = DEFAULT_N, - float_t tolerance = DEFAULT_TOLERANCE, - float_t stepSizeIncreaseFactor = - DEFAULT_STEP_SIZE_INCREASE_FACTOR, - float_t stepSizeDecreaseFactor = - DEFAULT_STEP_SIZE_DECREASE_FACTOR, + AdaptiveGradientDescent(ScalarFunction& f, ScalarFunctionGradient& fGradient, + size_t maxItCount = DEFAULT_N, float_t tolerance = DEFAULT_TOLERANCE, + float_t stepSizeIncreaseFactor = DEFAULT_STEP_SIZE_INCREASE_FACTOR, + float_t stepSizeDecreaseFactor = DEFAULT_STEP_SIZE_DECREASE_FACTOR, float_t lineSearchAccuracy = DEFAULT_LINE_SEARCH_ACCURACY); /** @@ -106,8 +102,7 @@ class AdaptiveGradientDescent : public UnconstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// objective function gradient @@ -121,9 +116,8 @@ class AdaptiveGradientDescent : public UnconstrainedOptimizer { /// line search accuracy float_t rhoLs; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_ADAPTIVEGRADIENTDESCENT_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveNewton.cpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveNewton.cpp index f7fe7c41ef..6f1fd3fe40 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveNewton.cpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveNewton.cpp @@ -9,57 +9,44 @@ #include #include +#include + namespace SGPP { namespace optimization { namespace optimizer { -AdaptiveNewton::AdaptiveNewton( - ScalarFunction& f, - ScalarFunctionHessian& fHessian, - size_t maxItCount, - float_t tolerance, - float_t stepSizeIncreaseFactor, - float_t stepSizeDecreaseFactor, - float_t dampingIncreaseFactor, - float_t dampingDecreaseFactor, - float_t lineSearchAccuracy) : - UnconstrainedOptimizer(f, maxItCount), - fHessian(fHessian), - theta(tolerance), - rhoAlphaPlus(stepSizeIncreaseFactor), - rhoAlphaMinus(stepSizeDecreaseFactor), - rhoLambdaPlus(dampingIncreaseFactor), - rhoLambdaMinus(dampingDecreaseFactor), - rhoLs(lineSearchAccuracy), - defaultSleSolver(sle_solver::GaussianElimination()), - sleSolver(defaultSleSolver) { -} - -AdaptiveNewton::AdaptiveNewton( - ScalarFunction& f, - ScalarFunctionHessian& fHessian, - size_t maxItCount, - float_t tolerance, - float_t stepSizeIncreaseFactor, - float_t stepSizeDecreaseFactor, - float_t dampingIncreaseFactor, - float_t dampingDecreaseFactor, - float_t lineSearchAccuracy, - const sle_solver::SLESolver& sleSolver) : - UnconstrainedOptimizer(f, N), - fHessian(fHessian), - theta(tolerance), - rhoAlphaPlus(stepSizeIncreaseFactor), - rhoAlphaMinus(stepSizeDecreaseFactor), - rhoLambdaPlus(dampingIncreaseFactor), - rhoLambdaMinus(dampingDecreaseFactor), - rhoLs(lineSearchAccuracy), - defaultSleSolver(sle_solver::GaussianElimination()), - sleSolver(sleSolver) { -} - -AdaptiveNewton::~AdaptiveNewton() { -} +AdaptiveNewton::AdaptiveNewton(ScalarFunction& f, ScalarFunctionHessian& fHessian, + size_t maxItCount, float_t tolerance, float_t stepSizeIncreaseFactor, + float_t stepSizeDecreaseFactor, float_t dampingIncreaseFactor, + float_t dampingDecreaseFactor, float_t lineSearchAccuracy) + : UnconstrainedOptimizer(f, maxItCount), + fHessian(fHessian), + theta(tolerance), + rhoAlphaPlus(stepSizeIncreaseFactor), + rhoAlphaMinus(stepSizeDecreaseFactor), + rhoLambdaPlus(dampingIncreaseFactor), + rhoLambdaMinus(dampingDecreaseFactor), + rhoLs(lineSearchAccuracy), + defaultSleSolver(sle_solver::GaussianElimination()), + sleSolver(defaultSleSolver) {} + +AdaptiveNewton::AdaptiveNewton(ScalarFunction& f, ScalarFunctionHessian& fHessian, + size_t maxItCount, float_t tolerance, float_t stepSizeIncreaseFactor, + float_t stepSizeDecreaseFactor, float_t dampingIncreaseFactor, + float_t dampingDecreaseFactor, float_t lineSearchAccuracy, + const sle_solver::SLESolver& sleSolver) + : UnconstrainedOptimizer(f, N), + fHessian(fHessian), + theta(tolerance), + rhoAlphaPlus(stepSizeIncreaseFactor), + rhoAlphaMinus(stepSizeDecreaseFactor), + rhoLambdaPlus(dampingIncreaseFactor), + rhoLambdaMinus(dampingDecreaseFactor), + rhoLs(lineSearchAccuracy), + defaultSleSolver(sle_solver::GaussianElimination()), + sleSolver(sleSolver) {} + +AdaptiveNewton::~AdaptiveNewton() {} void AdaptiveNewton::optimize() { Printer::getInstance().printStatusBegin("Optimizing (adaptive Newton)..."); @@ -95,8 +82,7 @@ void AdaptiveNewton::optimize() { const float_t ALPHA1 = 1e-6; const float_t ALPHA2 = 1e-6; const float_t P = 0.1; - const bool statusPrintingEnabled = - Printer::getInstance().isStatusPrintingEnabled(); + const bool statusPrintingEnabled = Printer::getInstance().isStatusPrintingEnabled(); while (k < N) { // calculate gradient and Hessian @@ -136,8 +122,7 @@ void AdaptiveNewton::optimize() { // acceptance criterion if (lsSolved && (b.dotProduct(dir) >= - std::min(ALPHA1, ALPHA2 * std::pow(dirNorm, P)) * - dirNorm * dirNorm)) { + std::min(ALPHA1, ALPHA2 * std::pow(dirNorm, P)) * dirNorm * dirNorm)) { // normalize search direction for (size_t t = 0; t < d; t++) { dir[t] /= dirNorm; @@ -170,8 +155,7 @@ void AdaptiveNewton::optimize() { float_t gradFxTimesDir = gradFx.dotProduct(dir); // line search - while ((fxNew > fx + rhoLs * alpha * gradFxTimesDir) && - (alpha > 0.0)) { + while ((fxNew > fx + rhoLs * alpha * gradFxTimesDir) && (alpha > 0.0)) { alpha *= rhoAlphaMinus; // increase damping @@ -222,15 +206,14 @@ void AdaptiveNewton::optimize() { fHist.append(fx); // increase step size - alpha = std::min(rhoAlphaPlus * alpha, float_t(1.0) ); + alpha = std::min(rhoAlphaPlus * alpha, float_t(1.0)); // decrease damping lambda *= rhoLambdaMinus; // status printing - Printer::getInstance().printStatusUpdate( - std::to_string(k) + " evaluations, x = " + x.toString() + - ", f(x) = " + std::to_string(fx)); + Printer::getInstance().printStatusUpdate(std::to_string(k) + " evaluations, x = " + + x.toString() + ", f(x) = " + std::to_string(fx)); // stopping criterion: // stop if alpha * dir is smaller than tolerance theta @@ -252,68 +235,45 @@ void AdaptiveNewton::optimize() { Printer::getInstance().printStatusEnd(); } -ScalarFunctionHessian& AdaptiveNewton::getObjectiveHessian() const { - return fHessian; -} +ScalarFunctionHessian& AdaptiveNewton::getObjectiveHessian() const { return fHessian; } -float_t AdaptiveNewton::getTolerance() const { - return theta; -} +float_t AdaptiveNewton::getTolerance() const { return theta; } -void AdaptiveNewton::setTolerance(float_t tolerance) { - theta = tolerance; -} +void AdaptiveNewton::setTolerance(float_t tolerance) { theta = tolerance; } -float_t AdaptiveNewton::getStepSizeIncreaseFactor() const { - return rhoAlphaPlus; -} +float_t AdaptiveNewton::getStepSizeIncreaseFactor() const { return rhoAlphaPlus; } -void AdaptiveNewton::setStepSizeIncreaseFactor( - float_t stepSizeIncreaseFactor) { +void AdaptiveNewton::setStepSizeIncreaseFactor(float_t stepSizeIncreaseFactor) { rhoAlphaPlus = stepSizeIncreaseFactor; } -float_t AdaptiveNewton::getStepSizeDecreaseFactor() const { - return rhoAlphaMinus; -} +float_t AdaptiveNewton::getStepSizeDecreaseFactor() const { return rhoAlphaMinus; } -void AdaptiveNewton::setStepSizeDecreaseFactor( - float_t stepSizeDecreaseFactor) { +void AdaptiveNewton::setStepSizeDecreaseFactor(float_t stepSizeDecreaseFactor) { rhoAlphaMinus = stepSizeDecreaseFactor; } -float_t AdaptiveNewton::getDampingIncreaseFactor() const { - return rhoLambdaPlus; -} +float_t AdaptiveNewton::getDampingIncreaseFactor() const { return rhoLambdaPlus; } -void AdaptiveNewton::setDampingIncreaseFactor( - float_t dampingIncreaseFactor) { +void AdaptiveNewton::setDampingIncreaseFactor(float_t dampingIncreaseFactor) { rhoLambdaPlus = dampingIncreaseFactor; } -float_t AdaptiveNewton::getDampingDecreaseFactor() const { - return rhoLambdaMinus; -} +float_t AdaptiveNewton::getDampingDecreaseFactor() const { return rhoLambdaMinus; } -void AdaptiveNewton::setDampingDecreaseFactor( - float_t dampingDecreaseFactor) { +void AdaptiveNewton::setDampingDecreaseFactor(float_t dampingDecreaseFactor) { rhoLambdaMinus = dampingDecreaseFactor; } -float_t AdaptiveNewton::getLineSearchAccuracy() const { - return rhoLs; -} +float_t AdaptiveNewton::getLineSearchAccuracy() const { return rhoLs; } -void AdaptiveNewton::setLineSearchAccuracy( - float_t lineSearchAccuracy) { +void AdaptiveNewton::setLineSearchAccuracy(float_t lineSearchAccuracy) { rhoLs = lineSearchAccuracy; } -void AdaptiveNewton::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new AdaptiveNewton(*this)); -} -} -} +void AdaptiveNewton::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new AdaptiveNewton(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveNewton.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveNewton.hpp index 7d490b1a5b..9563ee9718 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveNewton.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/AdaptiveNewton.hpp @@ -54,9 +54,7 @@ class AdaptiveNewton : public UnconstrainedOptimizer { * @param dampingDecreaseFactor damping decrease factor * @param lineSearchAccuracy line search accuracy */ - AdaptiveNewton(ScalarFunction& f, - ScalarFunctionHessian& fHessian, - size_t maxItCount = DEFAULT_N, + AdaptiveNewton(ScalarFunction& f, ScalarFunctionHessian& fHessian, size_t maxItCount = DEFAULT_N, float_t tolerance = DEFAULT_TOLERANCE, float_t stepSizeIncreaseFactor = DEFAULT_STEP_SIZE_INCREASE_FACTOR, float_t stepSizeDecreaseFactor = DEFAULT_STEP_SIZE_DECREASE_FACTOR, @@ -82,16 +80,10 @@ class AdaptiveNewton : public UnconstrainedOptimizer { * solving the linear systems * (Hessian as coefficient matrix) */ - AdaptiveNewton(ScalarFunction& f, - ScalarFunctionHessian& fHessian, - size_t maxItCount, - float_t tolerance, - float_t stepSizeIncreaseFactor, - float_t stepSizeDecreaseFactor, - float_t dampingIncreaseFactor, - float_t dampingDecreaseFactor, - float_t lineSearchAccuracy, - const sle_solver::SLESolver& sleSolver); + AdaptiveNewton(ScalarFunction& f, ScalarFunctionHessian& fHessian, size_t maxItCount, + float_t tolerance, float_t stepSizeIncreaseFactor, float_t stepSizeDecreaseFactor, + float_t dampingIncreaseFactor, float_t dampingDecreaseFactor, + float_t lineSearchAccuracy, const sle_solver::SLESolver& sleSolver); /** * Destructor. @@ -168,8 +160,7 @@ class AdaptiveNewton : public UnconstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// objective function Hessian @@ -191,9 +182,8 @@ class AdaptiveNewton : public UnconstrainedOptimizer { /// linear solver const sle_solver::SLESolver& sleSolver; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_ADAPTIVENEWTON_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/BFGS.cpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/BFGS.cpp index 8855185f38..aecb1b1cc0 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/BFGS.cpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/BFGS.cpp @@ -12,24 +12,17 @@ namespace SGPP { namespace optimization { namespace optimizer { -BFGS::BFGS( - ScalarFunction& f, - ScalarFunctionGradient& fGradient, - size_t maxItCount, - float_t tolerance, - float_t stepSizeIncreaseFactor, - float_t stepSizeDecreaseFactor, - float_t lineSearchAccuracy) : - UnconstrainedOptimizer(f, maxItCount), - fGradient(fGradient), - theta(tolerance), - rhoAlphaPlus(stepSizeIncreaseFactor), - rhoAlphaMinus(stepSizeDecreaseFactor), - rhoLs(lineSearchAccuracy) { -} - -BFGS::~BFGS() { -} +BFGS::BFGS(ScalarFunction& f, ScalarFunctionGradient& fGradient, size_t maxItCount, + float_t tolerance, float_t stepSizeIncreaseFactor, float_t stepSizeDecreaseFactor, + float_t lineSearchAccuracy) + : UnconstrainedOptimizer(f, maxItCount), + fGradient(fGradient), + theta(tolerance), + rhoAlphaPlus(stepSizeIncreaseFactor), + rhoAlphaMinus(stepSizeDecreaseFactor), + rhoLs(lineSearchAccuracy) {} + +BFGS::~BFGS() {} void BFGS::optimize() { Printer::getInstance().printStatusBegin("Optimizing (BFGS)..."); @@ -180,9 +173,8 @@ void BFGS::optimize() { } // status printing - Printer::getInstance().printStatusUpdate( - std::to_string(k) + " evaluations, x = " + x.toString() + - ", f(x) = " + std::to_string(fx)); + Printer::getInstance().printStatusUpdate(std::to_string(k) + " evaluations, x = " + + x.toString() + ", f(x) = " + std::to_string(fx)); // stopping criterion: // stop if delta is smaller than tolerance theta @@ -204,50 +196,31 @@ void BFGS::optimize() { Printer::getInstance().printStatusEnd(); } -ScalarFunctionGradient& BFGS::getObjectiveGradient() const { - return fGradient; -} +ScalarFunctionGradient& BFGS::getObjectiveGradient() const { return fGradient; } -float_t BFGS::getTolerance() const { - return theta; -} +float_t BFGS::getTolerance() const { return theta; } -void BFGS::setTolerance(float_t tolerance) { - theta = tolerance; -} +void BFGS::setTolerance(float_t tolerance) { theta = tolerance; } -float_t BFGS::getStepSizeIncreaseFactor() const { - return rhoAlphaPlus; -} +float_t BFGS::getStepSizeIncreaseFactor() const { return rhoAlphaPlus; } -void BFGS::setStepSizeIncreaseFactor( - float_t stepSizeIncreaseFactor) { +void BFGS::setStepSizeIncreaseFactor(float_t stepSizeIncreaseFactor) { rhoAlphaPlus = stepSizeIncreaseFactor; } -float_t BFGS::getStepSizeDecreaseFactor() const { - return rhoAlphaMinus; -} +float_t BFGS::getStepSizeDecreaseFactor() const { return rhoAlphaMinus; } -void BFGS::setStepSizeDecreaseFactor( - float_t stepSizeDecreaseFactor) { +void BFGS::setStepSizeDecreaseFactor(float_t stepSizeDecreaseFactor) { rhoAlphaMinus = stepSizeDecreaseFactor; } -float_t BFGS::getLineSearchAccuracy() const { - return rhoLs; -} +float_t BFGS::getLineSearchAccuracy() const { return rhoLs; } -void BFGS::setLineSearchAccuracy( - float_t lineSearchAccuracy) { - rhoLs = lineSearchAccuracy; -} +void BFGS::setLineSearchAccuracy(float_t lineSearchAccuracy) { rhoLs = lineSearchAccuracy; } -void BFGS::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new BFGS(*this)); -} -} -} +void BFGS::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new BFGS(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/BFGS.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/BFGS.hpp index 383ad12b65..70ea01b6fe 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/BFGS.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/BFGS.hpp @@ -41,14 +41,10 @@ class BFGS : public UnconstrainedOptimizer { * @param stepSizeDecreaseFactor step size decrease factor * @param lineSearchAccuracy line search accuracy */ - BFGS(ScalarFunction& f, - ScalarFunctionGradient& fGradient, - size_t maxItCount = DEFAULT_N, + BFGS(ScalarFunction& f, ScalarFunctionGradient& fGradient, size_t maxItCount = DEFAULT_N, float_t tolerance = DEFAULT_TOLERANCE, - float_t stepSizeIncreaseFactor = - DEFAULT_STEP_SIZE_INCREASE_FACTOR, - float_t stepSizeDecreaseFactor = - DEFAULT_STEP_SIZE_DECREASE_FACTOR, + float_t stepSizeIncreaseFactor = DEFAULT_STEP_SIZE_INCREASE_FACTOR, + float_t stepSizeDecreaseFactor = DEFAULT_STEP_SIZE_DECREASE_FACTOR, float_t lineSearchAccuracy = DEFAULT_LINE_SEARCH_ACCURACY); /** @@ -106,8 +102,7 @@ class BFGS : public UnconstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// objective function gradient @@ -121,9 +116,8 @@ class BFGS : public UnconstrainedOptimizer { /// line search accuracy float_t rhoLs; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_BFGS_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/CMAES.cpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/CMAES.cpp index 115eb25141..11770f034c 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/CMAES.cpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/CMAES.cpp @@ -12,17 +12,16 @@ #include #include +#include namespace SGPP { namespace optimization { namespace optimizer { -CMAES::CMAES(ScalarFunction& f, size_t maxFcnEvalCount) : - UnconstrainedOptimizer(f, maxFcnEvalCount) { -} +CMAES::CMAES(ScalarFunction& f, size_t maxFcnEvalCount) + : UnconstrainedOptimizer(f, maxFcnEvalCount) {} -CMAES::~CMAES() { -} +CMAES::~CMAES() {} void CMAES::optimize() { Printer::getInstance().printStatusBegin("Optimizing (CMA-ES)..."); @@ -36,9 +35,7 @@ void CMAES::optimize() { const float_t dDbl = static_cast(d); - const float_t E = - std::sqrt(dDbl) * (1.0 - 1.0 / (4.0 * dDbl) + - 1.0 / (21.0 * dDbl * dDbl)); + const float_t E = std::sqrt(dDbl) * (1.0 - 1.0 / (4.0 * dDbl) + 1.0 / (21.0 * dDbl * dDbl)); const size_t lambda = 4 + static_cast(3.0 * std::log(dDbl)); const float_t muPrime = static_cast(lambda) / 2.0; @@ -47,8 +44,7 @@ void CMAES::optimize() { base::DataVector wPrime(mu); for (size_t i = 0; i < mu; i++) { - wPrime[i] = std::log(muPrime + 0.5) - - std::log(static_cast(i) + 1.0); + wPrime[i] = std::log(muPrime + 0.5) - std::log(static_cast(i) + 1.0); } base::DataVector w(wPrime); @@ -57,17 +53,13 @@ void CMAES::optimize() { const float_t muEff = 1.0 / std::pow(w.l2Norm(), 2.0); const float_t cSigma = (muEff + 2.0) / (dDbl + muEff + 5.0); const float_t dSigma = - 1.0 + 2.0 * std::max(0.0, std::sqrt((muEff - 1.0) / - (dDbl + 1.0)) - 1.0) + cSigma; + 1.0 + 2.0 * std::max(0.0, std::sqrt((muEff - 1.0) / (dDbl + 1.0)) - 1.0) + cSigma; - const float_t cC = (4.0 + muEff / dDbl) / - (dDbl + 4.0 + 2.0 * muEff / dDbl); - const float_t c1 = - 2.0 / (std::pow(static_cast(dDbl + 1.3), 2.0) + muEff); + const float_t cC = (4.0 + muEff / dDbl) / (dDbl + 4.0 + 2.0 * muEff / dDbl); + const float_t c1 = 2.0 / (std::pow(static_cast(dDbl + 1.3), 2.0) + muEff); const float_t alphaMu = 2.0; - const float_t cMu = - std::min(1.0 - c1, alphaMu * (muEff - 2.0 + 1.0 / muEff) / - (std::pow(dDbl + 2.0, 2.0) + alphaMu * muEff / 2.0)); + const float_t cMu = std::min(1.0 - c1, alphaMu * (muEff - 2.0 + 1.0 / muEff) / + (std::pow(dDbl + 2.0, 2.0) + alphaMu * muEff / 2.0)); base::DataVector pSigma(d, 0.0); base::DataVector pC(d, 0.0); @@ -142,9 +134,7 @@ void CMAES::optimize() { numberOfFcnEvals += lambda; std::sort(fXOrder.begin(), fXOrder.end(), - [&](size_t a, size_t b) { - return (fX[a] < fX[b]); - }); + [&fX](size_t a, size_t b) { return (fX[a] < fX[b]); }); for (size_t t = 0; t < d; t++) { yW[t] = 0.0; @@ -164,10 +154,11 @@ void CMAES::optimize() { sigma *= std::exp(cSigma / dSigma * (pSigma.l2Norm() / E - 1.0)); const float_t hSigma = - ((pSigma.l2Norm() / - std::sqrt(1.0 - std::pow(1.0 - cSigma, - 2.0 * (static_cast(k) + 1.0))) - < (1.4 + 2.0 / (dDbl + 1.0)) * E) ? 1.0 : 0.0); + ((pSigma.l2Norm() / + std::sqrt(1.0 - std::pow(1.0 - cSigma, 2.0 * (static_cast(k) + 1.0))) < + (1.4 + 2.0 / (dDbl + 1.0)) * E) + ? 1.0 + : 0.0); const float_t delta = (1.0 - hSigma) * cC * (2.0 - cC); tmp = yW; @@ -177,12 +168,10 @@ void CMAES::optimize() { for (size_t t1 = 0; t1 < d; t1++) { for (size_t t2 = 0; t2 < d; t2++) { - CNew(t1, t2) = (1.0 - c1 - cMu) * C(t1, t2) + - c1 * (pC[t1] * pC[t2] + delta * C(t1, t2)); + CNew(t1, t2) = (1.0 - c1 - cMu) * C(t1, t2) + c1 * (pC[t1] * pC[t2] + delta * C(t1, t2)); for (size_t i = 0; i < mu; i++) { - CNew(t1, t2) += cMu * w[i] * Y(t1, fXOrder[i]) * - Y(t2, fXOrder[i]); + CNew(t1, t2) += cMu * w[i] * Y(t1, fXOrder[i]) * Y(t2, fXOrder[i]); } } } @@ -191,7 +180,7 @@ void CMAES::optimize() { k++; Printer::getInstance().printStatusUpdate(std::to_string(k) + " steps, f(x) = " + - std::to_string(fX[fXOrder[0]])); + std::to_string(fX[fXOrder[0]])); X.getColumn(fXOrder[0], x); xHist.appendRow(x); @@ -203,15 +192,13 @@ void CMAES::optimize() { fOpt = fX[fXOrder[0]]; Printer::getInstance().printStatusUpdate(std::to_string(k) + " steps, f(x) = " + - std::to_string(fX[fXOrder[0]])); + std::to_string(fX[fXOrder[0]])); Printer::getInstance().printStatusEnd(); } -void CMAES::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new CMAES(*this)); -} -} -} +void CMAES::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new CMAES(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/CMAES.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/CMAES.hpp index e3715a72d8..f473cdc97c 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/CMAES.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/CMAES.hpp @@ -31,8 +31,7 @@ class CMAES : public UnconstrainedOptimizer { * @param maxFcnEvalCount maximal number of * function evaluations */ - CMAES(ScalarFunction& f, - size_t maxFcnEvalCount = DEFAULT_MAX_FCN_EVAL_COUNT); + explicit CMAES(ScalarFunction& f, size_t maxFcnEvalCount = DEFAULT_MAX_FCN_EVAL_COUNT); /** * Destructor. @@ -44,12 +43,10 @@ class CMAES : public UnconstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_CMAES_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/DifferentialEvolution.cpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/DifferentialEvolution.cpp index 51fdb35023..d48647461a 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/DifferentialEvolution.cpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/DifferentialEvolution.cpp @@ -13,28 +13,26 @@ #include #include #include +#include namespace SGPP { namespace optimization { namespace optimizer { -DifferentialEvolution::DifferentialEvolution(ScalarFunction& f, - size_t maxFcnEvalCount, size_t populationSize, - float_t crossoverProbability, float_t scalingFactor, - size_t idleGenerationsCount, float_t avgImprovementThreshold, - float_t maxDistanceThreshold) : - UnconstrainedOptimizer(f, maxFcnEvalCount), - populationSize((populationSize > 0) ? populationSize : - 10 * f.getNumberOfParameters()), - crossoverProbability(crossoverProbability), - scalingFactor(scalingFactor), - idleGenerationsCount(idleGenerationsCount), - avgImprovementThreshold(avgImprovementThreshold), - maxDistanceThreshold(maxDistanceThreshold) { -} - -DifferentialEvolution::~DifferentialEvolution() { -} +DifferentialEvolution::DifferentialEvolution(ScalarFunction& f, size_t maxFcnEvalCount, + size_t populationSize, float_t crossoverProbability, + float_t scalingFactor, size_t idleGenerationsCount, + float_t avgImprovementThreshold, + float_t maxDistanceThreshold) + : UnconstrainedOptimizer(f, maxFcnEvalCount), + populationSize((populationSize > 0) ? populationSize : 10 * f.getNumberOfParameters()), + crossoverProbability(crossoverProbability), + scalingFactor(scalingFactor), + idleGenerationsCount(idleGenerationsCount), + avgImprovementThreshold(avgImprovementThreshold), + maxDistanceThreshold(maxDistanceThreshold) {} + +DifferentialEvolution::~DifferentialEvolution() {} void DifferentialEvolution::optimize() { Printer::getInstance().printStatusBegin("Optimizing (differential evolution)..."); @@ -47,8 +45,7 @@ void DifferentialEvolution::optimize() { fHist.resize(0); // vector of individuals - std::vector x1(populationSize, - base::DataVector(d, 0.0)); + std::vector x1(populationSize, base::DataVector(d, 0.0)); // another vector for the new population std::vector x2(x1); @@ -82,12 +79,10 @@ void DifferentialEvolution::optimize() { // number of iterations size_t maxK = std::max(static_cast(2), N / populationSize) - 1; - std::vector> a(maxK, std::vector( - populationSize, 0)), - b = a, c = a, j = a; - std::vector> prob(maxK, - std::vector(populationSize, - base::DataVector(d, 0))); + std::vector> a(maxK, std::vector(populationSize, 0)), b = a, c = a, + j = a; + std::vector> prob( + maxK, std::vector(populationSize, base::DataVector(d, 0))); // pregenerate all pseudorandom numbers because the // real algorithm is parallelized @@ -96,20 +91,16 @@ void DifferentialEvolution::optimize() { for (size_t k = 0; k < maxK; k++) { for (size_t i = 0; i < populationSize; i++) { do { - a[k][i] = RandomNumberGenerator::getInstance(). - getUniformIndexRN(populationSize); + a[k][i] = RandomNumberGenerator::getInstance().getUniformIndexRN(populationSize); } while (a[k][i] == i); do { - b[k][i] = RandomNumberGenerator::getInstance(). - getUniformIndexRN(populationSize); + b[k][i] = RandomNumberGenerator::getInstance().getUniformIndexRN(populationSize); } while ((b[k][i] == i) || (b[k][i] == a[k][i])); do { - c[k][i] = RandomNumberGenerator::getInstance(). - getUniformIndexRN(populationSize); - } while ((c[k][i] == i) || (c[k][i] == a[k][i]) || - (c[k][i] == b[k][i])); + c[k][i] = RandomNumberGenerator::getInstance().getUniformIndexRN(populationSize); + } while ((c[k][i] == i) || (c[k][i] == a[k][i]) || (c[k][i] == b[k][i])); j[k][i] = RandomNumberGenerator::getInstance().getUniformIndexRN(d); @@ -124,13 +115,13 @@ void DifferentialEvolution::optimize() { // "real" algorithm loop for (size_t k = 0; k < maxK; k++) { // abbreviations - const std::vector& a_k = a[k], &b_k = b[k], &c_k = c[k]; + const std::vector &a_k = a[k], &b_k = b[k], &c_k = c[k]; const std::vector& j_k = j[k]; const std::vector& prob_k = prob[k]; - #pragma omp parallel shared(k, a_k, b_k, c_k, j_k, prob_k, \ - xOld, fx, fCurrentOpt, xOptIndex, xNew) default(none) - { +#pragma omp parallel shared(k, a_k, b_k, c_k, j_k, prob_k, xOld, fx, fCurrentOpt, xOptIndex, \ + xNew) default(none) + { // NOLINT(whitespace/braces) base::DataVector y(d); ScalarFunction* curFPtr = &f; #ifdef _OPENMP @@ -143,11 +134,11 @@ void DifferentialEvolution::optimize() { #endif /* _OPENMP */ - // for each point in the population - #pragma omp for schedule(dynamic) +// for each point in the population +#pragma omp for schedule(dynamic) for (size_t i = 0; i < populationSize; i++) { - const size_t& cur_a = a_k[i], &cur_b = b_k[i], &cur_c = c_k[i]; + const size_t &cur_a = a_k[i], &cur_b = b_k[i], &cur_c = c_k[i]; const size_t& cur_j = j_k[i]; const base::DataVector& prob_ki = prob_k[i]; bool inDomain = true; @@ -158,9 +149,7 @@ void DifferentialEvolution::optimize() { if ((t == cur_j) || (curProb < crossoverProbability)) { // mutate point in this dimension - y[t] = (*xOld)[cur_a][t] + - scalingFactor * ((*xOld)[cur_b][t] - - (*xOld)[cur_c][t]); + y[t] = (*xOld)[cur_a][t] + scalingFactor * ((*xOld)[cur_b][t] - (*xOld)[cur_c][t]); } else { // don't mutate point in this dimension y[t] = (*xOld)[i][t]; @@ -177,8 +166,8 @@ void DifferentialEvolution::optimize() { const float_t fy = (inDomain ? curFPtr->eval(y) : INFINITY); if (fy < fx[i]) { - // function_value is better ==> replace point with mutated one - #pragma omp critical +// function_value is better ==> replace point with mutated one +#pragma omp critical { fx[i] = fy; @@ -206,21 +195,21 @@ void DifferentialEvolution::optimize() { // calculate average function value for (size_t i = 0; i < populationSize; i++) { - avg += fx[i]; + avg += fx[i]; } avg /= static_cast(populationSize); if (lastAvg - avg >= avgImprovementThreshold) { - // significant improvement - lastNonidleK = k; - } else if (k - lastNonidleK >= idleGenerationsCount) { - // last significant improvement too long ago - // ==> calculate maximum squared distance of all points - // to the best one - float_t maxDistance2 = 0.0; + // significant improvement + lastNonidleK = k; + } else if (k - lastNonidleK >= idleGenerationsCount) { + // last significant improvement too long ago + // ==> calculate maximum squared distance of all points + // to the best one + float_t maxDistance2 = 0.0; - for (size_t i = 0; i < populationSize; i++) { + for (size_t i = 0; i < populationSize; i++) { if (i == xOptIndex) { continue; } @@ -228,8 +217,8 @@ void DifferentialEvolution::optimize() { float_t distance2 = 0.0; for (size_t t = 0; t < d; t++) { - distance2 += ((*xOld)[i][t] - (*xOld)[xOptIndex][t]) * - ((*xOld)[i][t] - (*xOld)[xOptIndex][t]); + distance2 += + ((*xOld)[i][t] - (*xOld)[xOptIndex][t]) * ((*xOld)[i][t] - (*xOld)[xOptIndex][t]); } if (distance2 > maxDistance2) { @@ -248,8 +237,8 @@ void DifferentialEvolution::optimize() { // status message if (k % 10 == 0) { - Printer::getInstance().printStatusUpdate(std::to_string(k) + " steps, f(x) = " + - std::to_string(fCurrentOpt)); + Printer::getInstance().printStatusUpdate(std::to_string(k) + " steps, f(x) = " + + std::to_string(fCurrentOpt)); } xHist.appendRow((*xOld)[xOptIndex]); @@ -261,25 +250,20 @@ void DifferentialEvolution::optimize() { xOpt = (*xOld)[xOptIndex]; fOpt = fCurrentOpt; - Printer::getInstance().printStatusUpdate(std::to_string( - maxK) + " steps, f(x) = " + - std::to_string(fCurrentOpt)); + Printer::getInstance().printStatusUpdate(std::to_string(maxK) + " steps, f(x) = " + + std::to_string(fCurrentOpt)); Printer::getInstance().printStatusEnd(); } -size_t DifferentialEvolution::getPopulationSize() const { - return populationSize; -} +size_t DifferentialEvolution::getPopulationSize() const { return populationSize; } void DifferentialEvolution::setPopulationSize(size_t populationSize) { this->populationSize = populationSize; } -void DifferentialEvolution::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new DifferentialEvolution(*this)); -} -} -} +void DifferentialEvolution::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new DifferentialEvolution(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/DifferentialEvolution.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/DifferentialEvolution.hpp index 7e92ea0a95..32e4de7d9a 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/DifferentialEvolution.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/DifferentialEvolution.hpp @@ -44,21 +44,13 @@ class DifferentialEvolution : public UnconstrainedOptimizer { * @param avgImprovementThreshold stopping criterion parameter 2 * @param maxDistanceThreshold stopping criterion parameter 3 */ - DifferentialEvolution(ScalarFunction& f, - size_t maxFcnEvalCount = - DEFAULT_N, - size_t populationSize = - 0, - float_t crossoverProbability = - DEFAULT_CROSSOVER_PROBABILITY, - float_t scalingFactor = - DEFAULT_SCALING_FACTOR, - size_t idleGenerationsCount = - DEFAULT_IDLE_GENERATIONS_COUNT, - float_t avgImprovementThreshold = - DEFAULT_AVG_IMPROVEMENT_THRESHOLD, - float_t maxDistanceThreshold = - DEFAULT_MAX_DISTANCE_THRESHOLD); + DifferentialEvolution(ScalarFunction& f, size_t maxFcnEvalCount = DEFAULT_N, + size_t populationSize = 0, + float_t crossoverProbability = DEFAULT_CROSSOVER_PROBABILITY, + float_t scalingFactor = DEFAULT_SCALING_FACTOR, + size_t idleGenerationsCount = DEFAULT_IDLE_GENERATIONS_COUNT, + float_t avgImprovementThreshold = DEFAULT_AVG_IMPROVEMENT_THRESHOLD, + float_t maxDistanceThreshold = DEFAULT_MAX_DISTANCE_THRESHOLD); /** * Destructor. @@ -80,8 +72,7 @@ class DifferentialEvolution : public UnconstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// number of individuals @@ -97,9 +88,8 @@ class DifferentialEvolution : public UnconstrainedOptimizer { /// stopping criterion parameter 3 float_t maxDistanceThreshold; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_DIFFERENTIALEVOLUTION_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/GradientDescent.cpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/GradientDescent.cpp index 8303432398..3945f65566 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/GradientDescent.cpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/GradientDescent.cpp @@ -14,24 +14,17 @@ namespace SGPP { namespace optimization { namespace optimizer { -GradientDescent::GradientDescent( - ScalarFunction& f, - ScalarFunctionGradient& fGradient, - size_t maxItCount, - float_t beta, - float_t gamma, - float_t tolerance, - float_t epsilon) : - UnconstrainedOptimizer(f, maxItCount), - fGradient(fGradient), - beta(beta), - gamma(gamma), - tol(tolerance), - eps(epsilon) { -} - -GradientDescent::~GradientDescent() { -} +GradientDescent::GradientDescent(ScalarFunction& f, ScalarFunctionGradient& fGradient, + size_t maxItCount, float_t beta, float_t gamma, float_t tolerance, + float_t epsilon) + : UnconstrainedOptimizer(f, maxItCount), + fGradient(fGradient), + beta(beta), + gamma(gamma), + tol(tolerance), + eps(epsilon) {} + +GradientDescent::~GradientDescent() {} void GradientDescent::optimize() { Printer::getInstance().printStatusBegin("Optimizing (gradient descent)..."); @@ -73,13 +66,11 @@ void GradientDescent::optimize() { } // status printing - Printer::getInstance().printStatusUpdate( - std::to_string(k) + " evaluations, x = " + x.toString() + - ", f(x) = " + std::to_string(fx)); + Printer::getInstance().printStatusUpdate(std::to_string(k) + " evaluations, x = " + + x.toString() + ", f(x) = " + std::to_string(fx)); // line search - if (!lineSearchArmijo(f, beta, gamma, tol, eps, x, fx, - gradFx, s, y, k)) { + if (!lineSearchArmijo(f, beta, gamma, tol, eps, x, fx, gradFx, s, y, k)) { // line search failed ==> exit // (either a "real" error occured or the improvement // achieved is too small) @@ -97,47 +88,27 @@ void GradientDescent::optimize() { Printer::getInstance().printStatusEnd(); } -ScalarFunctionGradient& GradientDescent::getObjectiveGradient() const { - return fGradient; -} +ScalarFunctionGradient& GradientDescent::getObjectiveGradient() const { return fGradient; } -float_t GradientDescent::getBeta() const { - return beta; -} +float_t GradientDescent::getBeta() const { return beta; } -void GradientDescent::setBeta(float_t beta) { - this->beta = beta; -} +void GradientDescent::setBeta(float_t beta) { this->beta = beta; } -float_t GradientDescent::getGamma() const { - return gamma; -} +float_t GradientDescent::getGamma() const { return gamma; } -void GradientDescent::setGamma(float_t gamma) { - this->gamma = gamma; -} +void GradientDescent::setGamma(float_t gamma) { this->gamma = gamma; } -float_t GradientDescent::getTolerance() const { - return tol; -} +float_t GradientDescent::getTolerance() const { return tol; } -void GradientDescent::setTolerance(float_t tolerance) { - tol = tolerance; -} +void GradientDescent::setTolerance(float_t tolerance) { tol = tolerance; } -float_t GradientDescent::getEpsilon() const { - return eps; -} +float_t GradientDescent::getEpsilon() const { return eps; } -void GradientDescent::setEpsilon(float_t epsilon) { - eps = epsilon; -} +void GradientDescent::setEpsilon(float_t epsilon) { eps = epsilon; } -void GradientDescent::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new GradientDescent(*this)); -} -} -} +void GradientDescent::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new GradientDescent(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/GradientDescent.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/GradientDescent.hpp index 2da76f0866..f062037609 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/GradientDescent.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/GradientDescent.hpp @@ -8,11 +8,11 @@ #include -#include - #include #include +#include + namespace SGPP { namespace optimization { namespace optimizer { @@ -44,12 +44,9 @@ class GradientDescent : public UnconstrainedOptimizer { * @param tolerance tolerance (parameter for Armijo's rule) * @param epsilon epsilon (parameter for Armijo's rule) */ - GradientDescent(ScalarFunction& f, - ScalarFunctionGradient& fGradient, - size_t maxItCount = DEFAULT_MAX_IT_COUNT, - float_t beta = DEFAULT_BETA, - float_t gamma = DEFAULT_GAMMA, - float_t tolerance = DEFAULT_TOLERANCE, + GradientDescent(ScalarFunction& f, ScalarFunctionGradient& fGradient, + size_t maxItCount = DEFAULT_MAX_IT_COUNT, float_t beta = DEFAULT_BETA, + float_t gamma = DEFAULT_GAMMA, float_t tolerance = DEFAULT_TOLERANCE, float_t epsilon = DEFAULT_EPSILON); /** @@ -107,8 +104,7 @@ class GradientDescent : public UnconstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// objective function gradient @@ -122,9 +118,8 @@ class GradientDescent : public UnconstrainedOptimizer { /// epsilon (parameter for Armijo's rule) float_t eps; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_GRADIENTDESCENT_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/LineSearchArmijo.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/LineSearchArmijo.hpp index 1f81d25126..10c50befc3 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/LineSearchArmijo.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/LineSearchArmijo.hpp @@ -51,14 +51,10 @@ namespace optimizer { * @return whether the new point reaches an acceptable * improvement */ -inline bool lineSearchArmijo(ScalarFunction& f, float_t beta, - float_t gamma, - float_t tol, float_t eps, - const base::DataVector& x, float_t fx, - base::DataVector& gradFx, - const base::DataVector& s, - base::DataVector& y, - size_t& evalCounter) { +inline bool lineSearchArmijo(ScalarFunction& f, float_t beta, float_t gamma, float_t tol, + float_t eps, const base::DataVector& x, float_t fx, + base::DataVector& gradFx, const base::DataVector& s, + base::DataVector& y, size_t& evalCounter) { const size_t d = x.getSize(); float_t sigma = 1.0; const float_t ip = gradFx.dotProduct(s); @@ -87,8 +83,7 @@ inline bool lineSearchArmijo(ScalarFunction& f, float_t beta, // check if the absolute improvement is big enough if (improvement >= rhs) { - return (std::abs(fx - fy) >= - tol * (std::abs(fx) + std::abs(fy) + eps)); + return (std::abs(fx - fy) >= tol * (std::abs(fx) + std::abs(fy) + eps)); } } @@ -98,9 +93,8 @@ inline bool lineSearchArmijo(ScalarFunction& f, float_t beta, return false; } - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_LINESEARCHARMIJO_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/MultiStart.cpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/MultiStart.cpp index bc39547f7a..ad0b8fb404 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/MultiStart.cpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/MultiStart.cpp @@ -12,36 +12,34 @@ #include #include #include +#include +#include namespace SGPP { namespace optimization { namespace optimizer { -MultiStart::MultiStart(ScalarFunction& f, - size_t maxFcnEvalCount, - size_t populationSize) : - UnconstrainedOptimizer(f, maxFcnEvalCount), - defaultOptimizer(NelderMead(f)), - optimizer(defaultOptimizer) { +MultiStart::MultiStart(ScalarFunction& f, size_t maxFcnEvalCount, size_t populationSize) + : UnconstrainedOptimizer(f, maxFcnEvalCount), + defaultOptimizer(NelderMead(f)), + optimizer(defaultOptimizer) { initialize(populationSize); } -MultiStart::MultiStart(UnconstrainedOptimizer& optimizer, - size_t maxFcnEvalCount, - size_t populationSize) : - UnconstrainedOptimizer(optimizer.getObjectiveFunction(), maxFcnEvalCount), - defaultOptimizer(NelderMead(f)), - optimizer(optimizer) { +MultiStart::MultiStart(UnconstrainedOptimizer& optimizer, size_t maxFcnEvalCount, + size_t populationSize) + : UnconstrainedOptimizer(optimizer.getObjectiveFunction(), maxFcnEvalCount), + defaultOptimizer(NelderMead(f)), + optimizer(optimizer) { initialize(populationSize); } -MultiStart::~MultiStart() { -} +MultiStart::~MultiStart() {} void MultiStart::initialize(size_t populationSize) { - this->populationSize = (populationSize > 0) ? populationSize : - std::min(10 * f.getNumberOfParameters(), - static_cast(100)); + this->populationSize = (populationSize > 0) + ? populationSize + : std::min(10 * f.getNumberOfParameters(), static_cast(100)); } void MultiStart::optimize() { @@ -63,8 +61,7 @@ void MultiStart::optimize() { // generate pseudorandom starting points for (size_t k = 0; k < populationSize; k++) { roundN[k] = static_cast( - std::ceil(static_cast(remainingN) / - static_cast(populationSize - k))); + std::ceil(static_cast(remainingN) / static_cast(populationSize - k))); remainingN -= roundN[k]; for (size_t t = 0; t < d; t++) { @@ -135,15 +132,13 @@ void MultiStart::optimize() { // temporarily save x0 and N (will be overwritten by the loop) const base::DataVector tmpX0(optimizer.getStartingPoint()); const size_t tmpN = optimizer.getN(); - const bool statusPrintingEnabled = - Printer::getInstance().isStatusPrintingEnabled(); + const bool statusPrintingEnabled = Printer::getInstance().isStatusPrintingEnabled(); if (statusPrintingEnabled) { Printer::getInstance().disableStatusPrinting(); } - #pragma omp parallel shared(x0, roundN, xCurrentOpt, fCurrentOpt) \ - default(none) +#pragma omp parallel shared(x0, roundN, xCurrentOpt, fCurrentOpt) default(none) { UnconstrainedOptimizer* curOptimizerPtr = &optimizer; #ifdef _OPENMP @@ -159,7 +154,7 @@ void MultiStart::optimize() { base::DataVector xLocalOpt(d); float_t fLocalOpt; - #pragma omp for ordered schedule(dynamic) +#pragma omp for ordered schedule(dynamic) for (size_t k = 0; k < populationSize; k++) { // optimize with k-th starting point @@ -170,7 +165,7 @@ void MultiStart::optimize() { xLocalOpt = curOptimizerPtr->getOptimalPoint(); fLocalOpt = curOptimizerPtr->getOptimalValue(); - #pragma omp critical +#pragma omp critical { if (fLocalOpt < fCurrentOpt) { // this point is the best so far @@ -179,17 +174,16 @@ void MultiStart::optimize() { } } - // status printing - #pragma omp ordered +// status printing +#pragma omp ordered { char str[10]; - snprintf(str, 10, "%.1f%%", - static_cast(k) / - static_cast(populationSize) * 100.0); + snprintf(str, sizeof(str), "%.1f%%", + static_cast(k) / static_cast(populationSize) * 100.0); Printer::getInstance().getMutex().lock(); Printer::getInstance().enableStatusPrinting(); - Printer::getInstance().printStatusUpdate(std::string(str) + - ", f(x) = " + std::to_string(fCurrentOpt)); + Printer::getInstance().printStatusUpdate(std::string(str) + ", f(x) = " + + std::to_string(fCurrentOpt)); Printer::getInstance().disableStatusPrinting(); Printer::getInstance().getMutex().unlock(); } @@ -212,29 +206,19 @@ void MultiStart::optimize() { Printer::getInstance().enableStatusPrinting(); } - Printer::getInstance().printStatusUpdate("100.0%, f(x) = " + std::to_string( - fOpt)); + Printer::getInstance().printStatusUpdate("100.0%, f(x) = " + std::to_string(fOpt)); Printer::getInstance().printStatusEnd(); } -size_t MultiStart::getPopulationSize() const { - return populationSize; -} +size_t MultiStart::getPopulationSize() const { return populationSize; } -void MultiStart::setPopulationSize(size_t populationSize) { - this->populationSize = populationSize; -} +void MultiStart::setPopulationSize(size_t populationSize) { this->populationSize = populationSize; } -const std::vector& -MultiStart::getHistoryOfInnerIterations() const { - return kHist; -} +const std::vector& MultiStart::getHistoryOfInnerIterations() const { return kHist; } -void MultiStart::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new MultiStart(*this)); -} -} -} +void MultiStart::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new MultiStart(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/MultiStart.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/MultiStart.hpp index 40b774df6d..99a0d9ccb1 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/MultiStart.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/MultiStart.hpp @@ -11,6 +11,8 @@ #include #include +#include + namespace SGPP { namespace optimization { namespace optimizer { @@ -36,8 +38,7 @@ class MultiStart : public UnconstrainedOptimizer { * @param populationSize number of individual points * (default: \f$\min(10d, 100)\f$) */ - MultiStart(ScalarFunction& f, - size_t maxFcnEvalCount = DEFAULT_MAX_FCN_EVAL_COUNT, + MultiStart(ScalarFunction& f, size_t maxFcnEvalCount = DEFAULT_MAX_FCN_EVAL_COUNT, size_t populationSize = 0); /** @@ -51,8 +52,7 @@ class MultiStart : public UnconstrainedOptimizer { * @param populationSize number of individual points * (default: \f$\min(10d, 100)\f$) */ - MultiStart(UnconstrainedOptimizer& optimizer, - size_t maxFcnEvalCount = DEFAULT_MAX_FCN_EVAL_COUNT, + MultiStart(UnconstrainedOptimizer& optimizer, size_t maxFcnEvalCount = DEFAULT_MAX_FCN_EVAL_COUNT, size_t populationSize = 0); /** @@ -82,8 +82,7 @@ class MultiStart : public UnconstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// default optimization algorithm @@ -103,9 +102,8 @@ class MultiStart : public UnconstrainedOptimizer { */ void initialize(size_t populationSize); }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_MULTISTART_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/NLCG.cpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/NLCG.cpp index 06acf49e73..59a50d4b8b 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/NLCG.cpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/NLCG.cpp @@ -15,22 +15,17 @@ namespace SGPP { namespace optimization { namespace optimizer { -NLCG::NLCG(ScalarFunction& f, - ScalarFunctionGradient& fGradient, - size_t maxItCount, float_t beta, float_t gamma, - float_t tolerance, float_t epsilon, - float_t restartThreshold) : - UnconstrainedOptimizer(f, maxItCount), - fGradient(fGradient), - beta(beta), - gamma(gamma), - tol(tolerance), - eps(epsilon), - alpha(restartThreshold) { -} - -NLCG::~NLCG() { -} +NLCG::NLCG(ScalarFunction& f, ScalarFunctionGradient& fGradient, size_t maxItCount, float_t beta, + float_t gamma, float_t tolerance, float_t epsilon, float_t restartThreshold) + : UnconstrainedOptimizer(f, maxItCount), + fGradient(fGradient), + beta(beta), + gamma(gamma), + tol(tolerance), + eps(epsilon), + alpha(restartThreshold) {} + +NLCG::~NLCG() {} void NLCG::optimize() { Printer::getInstance().printStatusBegin("Optimizing (NLCG)..."); @@ -79,8 +74,7 @@ void NLCG::optimize() { } // line search - if (!lineSearchArmijo(f, beta, gamma, tol, eps, x, fx, - gradFx, sNormalized, y, k)) { + if (!lineSearchArmijo(f, beta, gamma, tol, eps, x, fx, gradFx, sNormalized, y, k)) { // line search failed ==> exit // (either a "real" error occured or the improvement achieved is // too small) @@ -97,8 +91,7 @@ void NLCG::optimize() { // the method is restarted (beta = 0), if the following criterion // is *not* met - if (std::abs(gradFy.dotProduct(gradFx)) / - (gradFyNorm * gradFyNorm) < alpha) { + if (std::abs(gradFy.dotProduct(gradFx)) / (gradFyNorm * gradFyNorm) < alpha) { // Polak-Ribiere coefficient for (size_t t = 0; t < d; t++) { beta += gradFy[t] * (gradFy[t] - gradFx[t]); @@ -120,9 +113,8 @@ void NLCG::optimize() { fHist.append(fx); // status printing - Printer::getInstance().printStatusUpdate( - std::to_string(k) + " evaluations, x = " + x.toString() + - ", f(x) = " + std::to_string(fx)); + Printer::getInstance().printStatusUpdate(std::to_string(k) + " evaluations, x = " + + x.toString() + ", f(x) = " + std::to_string(fx)); } xOpt.resize(d); @@ -131,55 +123,31 @@ void NLCG::optimize() { Printer::getInstance().printStatusEnd(); } -ScalarFunctionGradient& NLCG::getObjectiveGradient() const { - return fGradient; -} +ScalarFunctionGradient& NLCG::getObjectiveGradient() const { return fGradient; } -float_t NLCG::getBeta() const { - return beta; -} +float_t NLCG::getBeta() const { return beta; } -void NLCG::setBeta(float_t beta) { - this->beta = beta; -} +void NLCG::setBeta(float_t beta) { this->beta = beta; } -float_t NLCG::getGamma() const { - return gamma; -} +float_t NLCG::getGamma() const { return gamma; } -void NLCG::setGamma(float_t gamma) { - this->gamma = gamma; -} +void NLCG::setGamma(float_t gamma) { this->gamma = gamma; } -float_t NLCG::getTolerance() const { - return tol; -} +float_t NLCG::getTolerance() const { return tol; } -void NLCG::setTolerance(float_t tolerance) { - tol = tolerance; -} +void NLCG::setTolerance(float_t tolerance) { tol = tolerance; } -float_t NLCG::getEpsilon() const { - return eps; -} +float_t NLCG::getEpsilon() const { return eps; } -void NLCG::setEpsilon(float_t epsilon) { - eps = epsilon; -} +void NLCG::setEpsilon(float_t epsilon) { eps = epsilon; } -float_t NLCG::getRestartThreshold() const { - return alpha; -} +float_t NLCG::getRestartThreshold() const { return alpha; } -void NLCG::setRestartThreshold(float_t restartThreshold) { - alpha = restartThreshold; -} +void NLCG::setRestartThreshold(float_t restartThreshold) { alpha = restartThreshold; } -void NLCG::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new NLCG(*this)); -} -} -} +void NLCG::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new NLCG(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/NLCG.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/NLCG.hpp index 4cc690b146..a29dfb1e4c 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/NLCG.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/NLCG.hpp @@ -48,13 +48,9 @@ class NLCG : public UnconstrainedOptimizer { * @param epsilon epsilon (parameter for Armijo's rule) * @param restartThreshold restart threshold */ - NLCG(ScalarFunction& f, - ScalarFunctionGradient& fGradient, - size_t maxItCount = DEFAULT_N, - float_t beta = DEFAULT_BETA, - float_t gamma = DEFAULT_GAMMA, - float_t tolerance = DEFAULT_TOLERANCE, - float_t epsilon = DEFAULT_EPSILON, + NLCG(ScalarFunction& f, ScalarFunctionGradient& fGradient, size_t maxItCount = DEFAULT_N, + float_t beta = DEFAULT_BETA, float_t gamma = DEFAULT_GAMMA, + float_t tolerance = DEFAULT_TOLERANCE, float_t epsilon = DEFAULT_EPSILON, float_t restartThreshold = DEFAULT_RESTART_THRESHOLD); /** @@ -122,8 +118,7 @@ class NLCG : public UnconstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// objective function gradient @@ -139,9 +134,8 @@ class NLCG : public UnconstrainedOptimizer { /// restart threshold float_t alpha; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_NLCG_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/NelderMead.cpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/NelderMead.cpp index 6f62df67bc..b53e0673c0 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/NelderMead.cpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/NelderMead.cpp @@ -10,23 +10,21 @@ #include #include +#include namespace SGPP { namespace optimization { namespace optimizer { -NelderMead::NelderMead(ScalarFunction& f, - size_t maxFcnEvalCount, float_t alpha, - float_t beta, float_t gamma, float_t delta) : - UnconstrainedOptimizer(f, maxFcnEvalCount), - alpha(alpha), - beta(beta), - gamma(gamma), - delta(delta) { -} +NelderMead::NelderMead(ScalarFunction& f, size_t maxFcnEvalCount, float_t alpha, float_t beta, + float_t gamma, float_t delta) + : UnconstrainedOptimizer(f, maxFcnEvalCount), + alpha(alpha), + beta(beta), + gamma(gamma), + delta(delta) {} -NelderMead::~NelderMead() { -} +NelderMead::~NelderMead() {} void NelderMead::optimize() { Printer::getInstance().printStatusBegin("Optimizing (Nelder-Mead)..."); @@ -45,9 +43,7 @@ void NelderMead::optimize() { // construct starting simplex for (size_t t = 0; t < d; t++) { - points[t + 1][t] = std::min(points[t + 1][t] + - STARTING_SIMPLEX_EDGE_LENGTH, - float_t(1.0)); + points[t + 1][t] = std::min(points[t + 1][t] + STARTING_SIMPLEX_EDGE_LENGTH, float_t(1.0)); fPoints[t + 1] = f.eval(points[t + 1]); } @@ -69,9 +65,7 @@ void NelderMead::optimize() { } std::sort(index.begin(), index.end(), - [&](size_t a, size_t b) { - return (fPoints[a] < fPoints[b]); - }); + [&fPoints](size_t a, size_t b) { return (fPoints[a] < fPoints[b]); }); // that could be solved more efficiently, but it suffices for now for (size_t i = 0; i < d + 1; i++) { @@ -180,8 +174,7 @@ void NelderMead::optimize() { bool in_domain = true; for (size_t t = 0; t < d; t++) { - points[i][t] = points[0][t] + - delta * (points[i][t] - points[0][t]); + points[i][t] = points[0][t] + delta * (points[i][t] - points[0][t]); if ((points[i][t] < 0.0) || (points[i][t] > 1.0)) { in_domain = false; @@ -197,7 +190,7 @@ void NelderMead::optimize() { // status printing if (k % 10 == 0) { Printer::getInstance().printStatusUpdate(std::to_string(k) + " steps, f(x) = " + - std::to_string(fPoints[0])); + std::to_string(fPoints[0])); } if (numberOfFcnEvals + (d + 2) > N) { @@ -214,47 +207,29 @@ void NelderMead::optimize() { fOpt = fPoints[0]; Printer::getInstance().printStatusUpdate(std::to_string(k) + " steps, f(x) = " + - std::to_string(fPoints[0])); + std::to_string(fPoints[0])); Printer::getInstance().printStatusEnd(); } -float_t NelderMead::getAlpha() const { - return alpha; -} +float_t NelderMead::getAlpha() const { return alpha; } -void NelderMead::setAlpha(float_t alpha) { - this->alpha = alpha; -} +void NelderMead::setAlpha(float_t alpha) { this->alpha = alpha; } -float_t NelderMead::getBeta() const { - return beta; -} +float_t NelderMead::getBeta() const { return beta; } -void NelderMead::setBeta(float_t beta) { - this->beta = beta; -} +void NelderMead::setBeta(float_t beta) { this->beta = beta; } -float_t NelderMead::getGamma() const { - return gamma; -} +float_t NelderMead::getGamma() const { return gamma; } -void NelderMead::setGamma(float_t gamma) { - this->gamma = gamma; -} +void NelderMead::setGamma(float_t gamma) { this->gamma = gamma; } -float_t NelderMead::getDelta() const { - return delta; -} +float_t NelderMead::getDelta() const { return delta; } -void NelderMead::setDelta(float_t delta) { - this->delta = delta; -} +void NelderMead::setDelta(float_t delta) { this->delta = delta; } -void NelderMead::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new NelderMead(*this)); -} -} -} +void NelderMead::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new NelderMead(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/NelderMead.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/NelderMead.hpp index 621d9f83e2..f275914747 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/NelderMead.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/NelderMead.hpp @@ -45,12 +45,9 @@ class NelderMead : public UnconstrainedOptimizer { * @param gamma contraction coefficient * @param delta shrinking coefficient */ - NelderMead(ScalarFunction& f, - size_t maxFcnEvalCount = DEFAULT_MAX_FCN_EVAL_COUNT, - float_t alpha = DEFAULT_ALPHA, - float_t beta = DEFAULT_BETA, - float_t gamma = DEFAULT_GAMMA, - float_t delta = DEFAULT_DELTA); + NelderMead(ScalarFunction& f, size_t maxFcnEvalCount = DEFAULT_MAX_FCN_EVAL_COUNT, + float_t alpha = DEFAULT_ALPHA, float_t beta = DEFAULT_BETA, + float_t gamma = DEFAULT_GAMMA, float_t delta = DEFAULT_DELTA); /** * Destructor. @@ -102,8 +99,7 @@ class NelderMead : public UnconstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// reflection coefficient @@ -115,9 +111,8 @@ class NelderMead : public UnconstrainedOptimizer { /// shrinking coefficient float_t delta; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_NELDERMEAD_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/Newton.cpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/Newton.cpp index c63bf89a26..5c527f7368 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/Newton.cpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/Newton.cpp @@ -19,47 +19,37 @@ namespace SGPP { namespace optimization { namespace optimizer { -Newton::Newton( - ScalarFunction& f, - ScalarFunctionHessian& fHessian, - size_t max_it_count, float_t beta, float_t gamma, - float_t tolerance, float_t epsilon, float_t alpha1, - float_t alpha2, float_t p) : - UnconstrainedOptimizer(f, max_it_count), - fHessian(fHessian), - beta(beta), - gamma(gamma), - tol(tolerance), - eps(epsilon), - alpha1(alpha1), - alpha2(alpha2), - p(p), - defaultSleSolver(sle_solver::GaussianElimination()), - sleSolver(defaultSleSolver) { -} - -Newton::Newton( - ScalarFunction& f, - ScalarFunctionHessian& fHessian, - size_t max_it_count, float_t beta, float_t gamma, - float_t tolerance, float_t epsilon, float_t alpha1, - float_t alpha2, float_t p, - const sle_solver::SLESolver& sleSolver) : - UnconstrainedOptimizer(f, max_it_count), - fHessian(fHessian), - beta(beta), - gamma(gamma), - tol(tolerance), - eps(epsilon), - alpha1(alpha1), - alpha2(alpha2), - p(p), - defaultSleSolver(sle_solver::GaussianElimination()), - sleSolver(sleSolver) { -} - -Newton::~Newton() { -} +Newton::Newton(ScalarFunction& f, ScalarFunctionHessian& fHessian, size_t max_it_count, + float_t beta, float_t gamma, float_t tolerance, float_t epsilon, float_t alpha1, + float_t alpha2, float_t p) + : UnconstrainedOptimizer(f, max_it_count), + fHessian(fHessian), + beta(beta), + gamma(gamma), + tol(tolerance), + eps(epsilon), + alpha1(alpha1), + alpha2(alpha2), + p(p), + defaultSleSolver(sle_solver::GaussianElimination()), + sleSolver(defaultSleSolver) {} + +Newton::Newton(ScalarFunction& f, ScalarFunctionHessian& fHessian, size_t max_it_count, + float_t beta, float_t gamma, float_t tolerance, float_t epsilon, float_t alpha1, + float_t alpha2, float_t p, const sle_solver::SLESolver& sleSolver) + : UnconstrainedOptimizer(f, max_it_count), + fHessian(fHessian), + beta(beta), + gamma(gamma), + tol(tolerance), + eps(epsilon), + alpha1(alpha1), + alpha2(alpha2), + p(p), + defaultSleSolver(sle_solver::GaussianElimination()), + sleSolver(sleSolver) {} + +Newton::~Newton() {} void Newton::optimize() { Printer::getInstance().printStatusBegin("Optimizing (Newton)..."); @@ -82,8 +72,7 @@ void Newton::optimize() { FullSLE system(hessianFx); size_t k = 0; - const bool statusPrintingEnabled = - Printer::getInstance().isStatusPrintingEnabled(); + const bool statusPrintingEnabled = Printer::getInstance().isStatusPrintingEnabled(); while (k < N) { // calculate gradient, Hessian and gradient norm @@ -122,9 +111,8 @@ void Newton::optimize() { const float_t dkNorm = dk.l2Norm(); // acceptance criterion - if (lsSolved && (s.dotProduct(dk) >= - std::min(alpha1, alpha2 * std::pow(dkNorm, p)) * - dkNorm * dkNorm)) { + if (lsSolved && + (s.dotProduct(dk) >= std::min(alpha1, alpha2 * std::pow(dkNorm, p)) * dkNorm * dkNorm)) { // normalized solution as new search direction for (size_t t = 0; t < d; t++) { s[t] = dk[t] / dkNorm; @@ -138,13 +126,11 @@ void Newton::optimize() { } // status printing - Printer::getInstance().printStatusUpdate( - std::to_string(k) + " evaluations, x = " + x.toString() + - ", f(x) = " + std::to_string(fx)); + Printer::getInstance().printStatusUpdate(std::to_string(k) + " evaluations, x = " + + x.toString() + ", f(x) = " + std::to_string(fx)); // line search - if (!lineSearchArmijo(f, beta, gamma, tol, eps, x, fx, - gradFx, s, y, k)) { + if (!lineSearchArmijo(f, beta, gamma, tol, eps, x, fx, gradFx, s, y, k)) { // line search failed ==> exit // (either a "real" error occured or the improvement // achieved is too small) @@ -162,71 +148,39 @@ void Newton::optimize() { Printer::getInstance().printStatusEnd(); } -ScalarFunctionHessian& Newton::getObjectiveHessian() const { - return fHessian; -} +ScalarFunctionHessian& Newton::getObjectiveHessian() const { return fHessian; } -float_t Newton::getBeta() const { - return beta; -} +float_t Newton::getBeta() const { return beta; } -void Newton::setBeta(float_t beta) { - this->beta = beta; -} +void Newton::setBeta(float_t beta) { this->beta = beta; } -float_t Newton::getGamma() const { - return gamma; -} +float_t Newton::getGamma() const { return gamma; } -void Newton::setGamma(float_t gamma) { - this->gamma = gamma; -} +void Newton::setGamma(float_t gamma) { this->gamma = gamma; } -float_t Newton::getTolerance() const { - return tol; -} +float_t Newton::getTolerance() const { return tol; } -void Newton::setTolerance(float_t tolerance) { - tol = tolerance; -} +void Newton::setTolerance(float_t tolerance) { tol = tolerance; } -float_t Newton::getEpsilon() const { - return eps; -} +float_t Newton::getEpsilon() const { return eps; } -void Newton::setEpsilon(float_t epsilon) { - eps = epsilon; -} +void Newton::setEpsilon(float_t epsilon) { eps = epsilon; } -float_t Newton::getAlpha1() const { - return alpha1; -} +float_t Newton::getAlpha1() const { return alpha1; } -void Newton::setAlpha1(float_t alpha1) { - this->alpha1 = alpha1; -} +void Newton::setAlpha1(float_t alpha1) { this->alpha1 = alpha1; } -float_t Newton::getAlpha2() const { - return alpha2; -} +float_t Newton::getAlpha2() const { return alpha2; } -void Newton::setAlpha2(float_t alpha2) { - this->alpha2 = alpha2; -} +void Newton::setAlpha2(float_t alpha2) { this->alpha2 = alpha2; } -float_t Newton::getP() const { - return p; -} +float_t Newton::getP() const { return p; } -void Newton::setP(float_t p) { - this->p = p; -} +void Newton::setP(float_t p) { this->p = p; } -void Newton::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new Newton(*this)); -} -} -} +void Newton::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new Newton(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/Newton.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/Newton.hpp index e8010a38c8..07e071b0f7 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/Newton.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/Newton.hpp @@ -16,7 +16,6 @@ #include #include - namespace SGPP { namespace optimization { namespace optimizer { @@ -61,16 +60,10 @@ class Newton : public UnconstrainedOptimizer { * @param alpha2 steepest descent restart parameter 2 * @param p steepest descent restart exponent */ - Newton(ScalarFunction& f, - ScalarFunctionHessian& fHessian, - size_t maxItCount = DEFAULT_N, - float_t beta = DEFAULT_BETA, - float_t gamma = DEFAULT_GAMMA, - float_t tolerance = DEFAULT_TOLERANCE, - float_t epsilon = DEFAULT_EPSILON, - float_t alpha1 = DEFAULT_ALPHA1, - float_t alpha2 = DEFAULT_ALPHA2, - float_t p = DEFAULT_P); + Newton(ScalarFunction& f, ScalarFunctionHessian& fHessian, size_t maxItCount = DEFAULT_N, + float_t beta = DEFAULT_BETA, float_t gamma = DEFAULT_GAMMA, + float_t tolerance = DEFAULT_TOLERANCE, float_t epsilon = DEFAULT_EPSILON, + float_t alpha1 = DEFAULT_ALPHA1, float_t alpha2 = DEFAULT_ALPHA2, float_t p = DEFAULT_P); /** * Constructor. @@ -90,17 +83,9 @@ class Newton : public UnconstrainedOptimizer { * the linear systems * (Hessian as coefficient matrix) */ - Newton(ScalarFunction& f, - ScalarFunctionHessian& fHessian, - size_t maxItCount, - float_t beta, - float_t gamma, - float_t tolerance, - float_t epsilon, - float_t alpha1, - float_t alpha2, - float_t p, - const sle_solver::SLESolver& sleSolver); + Newton(ScalarFunction& f, ScalarFunctionHessian& fHessian, size_t maxItCount, float_t beta, + float_t gamma, float_t tolerance, float_t epsilon, float_t alpha1, float_t alpha2, + float_t p, const sle_solver::SLESolver& sleSolver); /** * Destructor. @@ -187,8 +172,7 @@ class Newton : public UnconstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// objective function Hessian @@ -212,9 +196,8 @@ class Newton : public UnconstrainedOptimizer { /// linear solver const sle_solver::SLESolver& sleSolver; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_NEWTON_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/Rprop.cpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/Rprop.cpp index 7482b90928..edb83bcfaa 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/Rprop.cpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/Rprop.cpp @@ -12,24 +12,17 @@ namespace SGPP { namespace optimization { namespace optimizer { -Rprop::Rprop( - ScalarFunction& f, - ScalarFunctionGradient& fGradient, - size_t maxItCount, - float_t tolerance, - float_t initialStepSize, - float_t stepSizeIncreaseFactor, - float_t stepSizeDecreaseFactor) : - UnconstrainedOptimizer(f, maxItCount), - fGradient(fGradient), - theta(tolerance), - initialAlpha(initialStepSize), - rhoAlphaPlus(stepSizeIncreaseFactor), - rhoAlphaMinus(stepSizeDecreaseFactor) { -} - -Rprop::~Rprop() { -} +Rprop::Rprop(ScalarFunction& f, ScalarFunctionGradient& fGradient, size_t maxItCount, + float_t tolerance, float_t initialStepSize, float_t stepSizeIncreaseFactor, + float_t stepSizeDecreaseFactor) + : UnconstrainedOptimizer(f, maxItCount), + fGradient(fGradient), + theta(tolerance), + initialAlpha(initialStepSize), + rhoAlphaPlus(stepSizeIncreaseFactor), + rhoAlphaMinus(stepSizeDecreaseFactor) {} + +Rprop::~Rprop() {} void Rprop::optimize() { Printer::getInstance().printStatusBegin("Optimizing (Rprop)..."); @@ -103,9 +96,8 @@ void Rprop::optimize() { } // status printing - Printer::getInstance().printStatusUpdate( - std::to_string(k) + " evaluations, x = " + x.toString() + - ", f(x) = " + std::to_string(fx)); + Printer::getInstance().printStatusUpdate(std::to_string(k) + " evaluations, x = " + + x.toString() + ", f(x) = " + std::to_string(fx)); xHist.appendRow(x); fHist.append(fx); @@ -133,49 +125,31 @@ void Rprop::optimize() { Printer::getInstance().printStatusEnd(); } -ScalarFunctionGradient& Rprop::getObjectiveGradient() const { - return fGradient; -} +ScalarFunctionGradient& Rprop::getObjectiveGradient() const { return fGradient; } -float_t Rprop::getTolerance() const { - return theta; -} +float_t Rprop::getTolerance() const { return theta; } -void Rprop::setTolerance(float_t tolerance) { - theta = tolerance; -} +void Rprop::setTolerance(float_t tolerance) { theta = tolerance; } -float_t Rprop::getInitialStepSize() const { - return initialAlpha; -} +float_t Rprop::getInitialStepSize() const { return initialAlpha; } -void Rprop::setInitialStepSize(float_t initialStepSize) { - initialAlpha = initialStepSize; -} +void Rprop::setInitialStepSize(float_t initialStepSize) { initialAlpha = initialStepSize; } -float_t Rprop::getStepSizeIncreaseFactor() const { - return rhoAlphaPlus; -} +float_t Rprop::getStepSizeIncreaseFactor() const { return rhoAlphaPlus; } -void Rprop::setStepSizeIncreaseFactor( - float_t stepSizeIncreaseFactor) { +void Rprop::setStepSizeIncreaseFactor(float_t stepSizeIncreaseFactor) { rhoAlphaPlus = stepSizeIncreaseFactor; } -float_t Rprop::getStepSizeDecreaseFactor() const { - return rhoAlphaMinus; -} +float_t Rprop::getStepSizeDecreaseFactor() const { return rhoAlphaMinus; } -void Rprop::setStepSizeDecreaseFactor( - float_t stepSizeDecreaseFactor) { +void Rprop::setStepSizeDecreaseFactor(float_t stepSizeDecreaseFactor) { rhoAlphaMinus = stepSizeDecreaseFactor; } -void Rprop::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new Rprop(*this)); -} -} -} +void Rprop::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new Rprop(*this)); } +} // namespace optimizer +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/Rprop.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/Rprop.hpp index 11ceab0fb7..360e6d0e22 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/Rprop.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/Rprop.hpp @@ -41,15 +41,10 @@ class Rprop : public UnconstrainedOptimizer { * @param stepSizeIncreaseFactor step size increase factor * @param stepSizeDecreaseFactor step size decrease factor */ - Rprop(ScalarFunction& f, - ScalarFunctionGradient& fGradient, - size_t maxItCount = DEFAULT_N, - float_t tolerance = DEFAULT_TOLERANCE, - float_t initialStepSize = DEFAULT_INITIAL_STEP_SIZE, - float_t stepSizeIncreaseFactor = - DEFAULT_STEP_SIZE_INCREASE_FACTOR, - float_t stepSizeDecreaseFactor = - DEFAULT_STEP_SIZE_DECREASE_FACTOR); + Rprop(ScalarFunction& f, ScalarFunctionGradient& fGradient, size_t maxItCount = DEFAULT_N, + float_t tolerance = DEFAULT_TOLERANCE, float_t initialStepSize = DEFAULT_INITIAL_STEP_SIZE, + float_t stepSizeIncreaseFactor = DEFAULT_STEP_SIZE_INCREASE_FACTOR, + float_t stepSizeDecreaseFactor = DEFAULT_STEP_SIZE_DECREASE_FACTOR); /** * Destructor. @@ -106,8 +101,7 @@ class Rprop : public UnconstrainedOptimizer { /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const - override; + void clone(std::unique_ptr& clone) const override; protected: /// objective function gradient @@ -121,9 +115,8 @@ class Rprop : public UnconstrainedOptimizer { /// step size decrease factor float_t rhoAlphaMinus; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_RPROP_HPP */ diff --git a/optimization/src/sgpp/optimization/optimizer/unconstrained/UnconstrainedOptimizer.hpp b/optimization/src/sgpp/optimization/optimizer/unconstrained/UnconstrainedOptimizer.hpp index c3571d5b4d..a83483fefb 100644 --- a/optimization/src/sgpp/optimization/optimizer/unconstrained/UnconstrainedOptimizer.hpp +++ b/optimization/src/sgpp/optimization/optimizer/unconstrained/UnconstrainedOptimizer.hpp @@ -36,21 +36,13 @@ class UnconstrainedOptimizer { * @param N maximal number of iterations or function evaluations * (depending on the implementation) */ - UnconstrainedOptimizer(ScalarFunction& f, size_t N = DEFAULT_N) : - f(f), - N(N), - x0(f.getNumberOfParameters(), 0.5), - xOpt(0), - fOpt(NAN), - xHist(0, 0), - fHist(0) { - } + explicit UnconstrainedOptimizer(ScalarFunction& f, size_t N = DEFAULT_N) + : f(f), N(N), x0(f.getNumberOfParameters(), 0.5), xOpt(0), fOpt(NAN), xHist(0, 0), fHist(0) {} /** * Destructor. */ - virtual ~UnconstrainedOptimizer() { - } + virtual ~UnconstrainedOptimizer() {} /** * Pure virtual method for optimization of the objective function. @@ -62,71 +54,53 @@ class UnconstrainedOptimizer { /** * @return objective function */ - ScalarFunction& getObjectiveFunction() const { - return f; - } + ScalarFunction& getObjectiveFunction() const { return f; } /** * @return maximal number of iterations or function evaluations */ - size_t getN() const { - return N; - } + size_t getN() const { return N; } /** * @param N maximal number of iterations or function evaluations */ - void setN(size_t N) { - this->N = N; - } + void setN(size_t N) { this->N = N; } /** * @return starting point */ - const base::DataVector& getStartingPoint() const { - return x0; - } + const base::DataVector& getStartingPoint() const { return x0; } /** * @param startingPoint starting point */ - void setStartingPoint(const base::DataVector& startingPoint) { - this->x0 = startingPoint; - } + void setStartingPoint(const base::DataVector& startingPoint) { this->x0 = startingPoint; } /** * @return result of optimization (location of optimum), * empty vector on error */ - const base::DataVector& getOptimalPoint() const { - return xOpt; - } + const base::DataVector& getOptimalPoint() const { return xOpt; } /** * @return result of optimization (optimal function value), * NAN on error */ - float_t getOptimalValue() const { - return fOpt; - } + float_t getOptimalValue() const { return fOpt; } /** * @return tall matrix (d columns) in which the k-th row indicates * the best point after k iterations of the optimization, * empty matrix on error or if not supported */ - const base::DataMatrix& getHistoryOfOptimalPoints() const { - return xHist; - } + const base::DataMatrix& getHistoryOfOptimalPoints() const { return xHist; } /** * @return vector in which the k-th entry indicates the best * function value after k iterations of the optimization, * empty vector on error or if not supported */ - const base::DataVector& getHistoryOfOptimalValues() const { - return fHist; - } + const base::DataVector& getHistoryOfOptimalValues() const { return fHist; } /** * Pure virtual method for cloning the optimizer. @@ -135,8 +109,7 @@ class UnconstrainedOptimizer { * * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& - clone) const = 0; + virtual void clone(std::unique_ptr& clone) const = 0; protected: /// objective function @@ -154,9 +127,8 @@ class UnconstrainedOptimizer { /// search history vector (optimal values) base::DataVector fHist; }; - -} -} -} +} // namespace optimizer +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_OPTIMIZER_UNCONSTRAINED_UNCONSTRAINEDOPTIMIZER_HPP */ diff --git a/optimization/src/sgpp/optimization/sle/solver/Armadillo.cpp b/optimization/src/sgpp/optimization/sle/solver/Armadillo.cpp index bac3cf57e9..88e0e05043 100644 --- a/optimization/src/sgpp/optimization/sle/solver/Armadillo.cpp +++ b/optimization/src/sgpp/optimization/sle/solver/Armadillo.cpp @@ -24,16 +24,15 @@ typedef arma::fmat ArmadilloMatrix; #include #include +#include namespace SGPP { namespace optimization { namespace sle_solver { -Armadillo::~Armadillo() { -} +Armadillo::~Armadillo() {} -bool Armadillo::solve(SLE& system, base::DataVector& b, - base::DataVector& x) const { +bool Armadillo::solve(SLE& system, base::DataVector& b, base::DataVector& x) const { base::DataMatrix B(b.getPointer(), b.getSize(), 1); base::DataMatrix X(B.getNrows(), B.getNcols()); @@ -47,9 +46,7 @@ bool Armadillo::solve(SLE& system, base::DataVector& b, } } -bool Armadillo::solve(SLE& system, - base::DataMatrix& B, - base::DataMatrix& X) const { +bool Armadillo::solve(SLE& system, base::DataMatrix& B, base::DataMatrix& X) const { #ifdef USE_ARMADILLO Printer::getInstance().printStatusBegin("Solving linear system (Armadillo)..."); @@ -59,9 +56,8 @@ bool Armadillo::solve(SLE& system, A.zeros(); - // parallelize only if the system is cloneable - #pragma omp parallel if (system.isCloneable()) \ - shared(system, A, nnz) default(none) +// parallelize only if the system is cloneable +#pragma omp parallel if (system.isCloneable()) shared(system, A, nnz) default(none) { SLE* system2 = &system; #ifdef _OPENMP @@ -74,8 +70,8 @@ bool Armadillo::solve(SLE& system, #endif /* _OPENMP */ - // copy system matrix to Armadillo matrix object - #pragma omp for ordered schedule(dynamic) +// copy system matrix to Armadillo matrix object +#pragma omp for ordered schedule(dynamic) for (arma::uword i = 0; i < n; i++) { for (arma::uword j = 0; j < n; j++) { @@ -84,20 +80,20 @@ bool Armadillo::solve(SLE& system, // count nonzero entries // (not necessary, you can also remove that if you like) if (A(i, j) != 0) { - #pragma omp atomic +#pragma omp atomic nnz++; } } // status message if (i % 100 == 0) { - #pragma omp ordered +#pragma omp ordered { char str[10]; - snprintf(str, 10, "%.1f%%", - static_cast(i) / static_cast(n) * 100.0); - Printer::getInstance().printStatusUpdate("constructing matrix (" + - std::string(str) + ")"); + snprintf(str, sizeof(str), "%.1f%%", + static_cast(i) / static_cast(n) * 100.0); + Printer::getInstance().printStatusUpdate("constructing matrix (" + std::string(str) + + ")"); } } } @@ -109,10 +105,9 @@ bool Armadillo::solve(SLE& system, // print ratio of nonzero entries { char str[10]; - float_t nnzRatio = static_cast(nnz) / - (static_cast(n) * - static_cast(n)); - snprintf(str, 10, "%.1f%%", nnzRatio * 100.0); + float_t nnzRatio = + static_cast(nnz) / (static_cast(n) * static_cast(n)); + snprintf(str, sizeof(str), "%.1f%%", nnzRatio * 100.0); Printer::getInstance().printStatusUpdate("nnz ratio: " + std::string(str)); Printer::getInstance().printStatusNewLine(); } @@ -172,7 +167,6 @@ bool Armadillo::solve(SLE& system, return false; #endif /* USE_ARMADILLO */ } - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/sle/solver/Armadillo.hpp b/optimization/src/sgpp/optimization/sle/solver/Armadillo.hpp index d8da67333b..d83ecab07b 100644 --- a/optimization/src/sgpp/optimization/sle/solver/Armadillo.hpp +++ b/optimization/src/sgpp/optimization/sle/solver/Armadillo.hpp @@ -32,9 +32,7 @@ class Armadillo : public SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, - base::DataVector& b, - base::DataVector& x) const override; + bool solve(SLE& system, base::DataVector& b, base::DataVector& x) const override; /** * @param system system to be solved @@ -43,13 +41,10 @@ class Armadillo : public SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, - base::DataMatrix& B, - base::DataMatrix& X) const override; + bool solve(SLE& system, base::DataMatrix& B, base::DataMatrix& X) const override; }; - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_SLE_SOLVER_ARMADILLO_HPP */ diff --git a/optimization/src/sgpp/optimization/sle/solver/Auto.cpp b/optimization/src/sgpp/optimization/sle/solver/Auto.cpp index ed0cfdbdc1..2f28e286e7 100644 --- a/optimization/src/sgpp/optimization/sle/solver/Auto.cpp +++ b/optimization/src/sgpp/optimization/sle/solver/Auto.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include namespace SGPP { namespace optimization { @@ -35,17 +37,14 @@ void addSLESolver(SLESolver* solver, std::vector& solvers, const std::map& supports) { // add solver if it's supported and not already in the vector if ((supports.at(solver)) && - (std::find(solvers.begin(), solvers.end(), solver) == - solvers.end())) { + (std::find(solvers.begin(), solvers.end(), solver) == solvers.end())) { solvers.push_back(solver); } } -Auto::~Auto() { -} +Auto::~Auto() {} -bool Auto::solve(SLE& system, base::DataVector& b, - base::DataVector& x) const { +bool Auto::solve(SLE& system, base::DataVector& b, base::DataVector& x) const { base::DataMatrix B(b.getPointer(), b.getSize(), 1); base::DataMatrix X(B.getNrows(), B.getNcols()); @@ -59,10 +58,8 @@ bool Auto::solve(SLE& system, base::DataVector& b, } } -bool Auto::solve(SLE& system, base::DataMatrix& B, - base::DataMatrix& X) const { - Printer::getInstance().printStatusBegin( - "Solving linear system (automatic method)..."); +bool Auto::solve(SLE& system, base::DataMatrix& B, base::DataMatrix& X) const { + Printer::getInstance().printStatusBegin("Solving linear system (automatic method)..."); Armadillo solverArmadillo; Eigen solverEigen; @@ -108,9 +105,7 @@ bool Auto::solve(SLE& system, base::DataMatrix& B, // every inc-th row size_t nrows = 0; size_t nnz = 0; - size_t inc = static_cast( - ESTIMATE_NNZ_ROWS_SAMPLE_SIZE * - static_cast(n)) + 1; + size_t inc = static_cast(ESTIMATE_NNZ_ROWS_SAMPLE_SIZE * static_cast(n)) + 1; Printer::getInstance().printStatusUpdate("estimating sparsity pattern"); @@ -125,16 +120,14 @@ bool Auto::solve(SLE& system, base::DataMatrix& B, } // calculate estimate ratio nonzero entries - float_t nnzRatio = static_cast(nnz) / - (static_cast(nrows) * - static_cast(n)); + float_t nnzRatio = + static_cast(nnz) / (static_cast(nrows) * static_cast(n)); // print ratio { char str[10]; - snprintf(str, 10, "%.1f%%", nnzRatio * 100.0); - Printer::getInstance().printStatusUpdate("estimated nnz ratio: " + - std::string(str)); + snprintf(str, sizeof(str), "%.1f%%", nnzRatio * 100.0); + Printer::getInstance().printStatusUpdate("estimated nnz ratio: " + std::string(str)); Printer::getInstance().printStatusNewLine(); } @@ -160,13 +153,12 @@ bool Auto::solve(SLE& system, base::DataMatrix& B, if (result) { Printer::getInstance().printStatusEnd(); return true; - } else if ((solvers[i] == &solverGmmpp) && - (n > MAX_DIM_FOR_FULL)) { + } else if ((solvers[i] == &solverGmmpp) && (n > MAX_DIM_FOR_FULL)) { // don't use full solvers and return approximative solution Printer::getInstance().printStatusEnd( - "warning: using non-converged solution of iterative " - "solver, residual can be large " - "(matrix too large to try other solvers)"); + "warning: using non-converged solution of iterative " + "solver, residual can be large " + "(matrix too large to try other solvers)"); return true; } } @@ -174,7 +166,6 @@ bool Auto::solve(SLE& system, base::DataMatrix& B, Printer::getInstance().printStatusEnd("error: Could not solve linear system!"); return false; } - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/sle/solver/Auto.hpp b/optimization/src/sgpp/optimization/sle/solver/Auto.hpp index 9b9504424b..e27a00bb50 100644 --- a/optimization/src/sgpp/optimization/sle/solver/Auto.hpp +++ b/optimization/src/sgpp/optimization/sle/solver/Auto.hpp @@ -39,9 +39,7 @@ class Auto : public SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, - base::DataVector& b, - base::DataVector& x) const override; + bool solve(SLE& system, base::DataVector& b, base::DataVector& x) const override; /** * @param system system to be solved @@ -50,13 +48,10 @@ class Auto : public SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, - base::DataMatrix& B, - base::DataMatrix& X) const override; + bool solve(SLE& system, base::DataMatrix& B, base::DataMatrix& X) const override; }; - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_SLE_SOLVER_AUTO_HPP */ diff --git a/optimization/src/sgpp/optimization/sle/solver/BiCGStab.cpp b/optimization/src/sgpp/optimization/sle/solver/BiCGStab.cpp index c7f4497a7e..e6f132e59e 100644 --- a/optimization/src/sgpp/optimization/sle/solver/BiCGStab.cpp +++ b/optimization/src/sgpp/optimization/sle/solver/BiCGStab.cpp @@ -15,24 +15,14 @@ namespace SGPP { namespace optimization { namespace sle_solver { -BiCGStab::BiCGStab() : - BiCGStab(DEFAULT_MAX_IT_COUNT, DEFAULT_TOLERANCE, - base::DataVector(0)) { -} +BiCGStab::BiCGStab() : BiCGStab(DEFAULT_MAX_IT_COUNT, DEFAULT_TOLERANCE, base::DataVector(0)) {} -BiCGStab::BiCGStab(size_t maxItCount, float_t tolerance, - const base::DataVector& x0) : - SLESolver(), - N(maxItCount), - tol(tolerance), - x0(x0) { -} +BiCGStab::BiCGStab(size_t maxItCount, float_t tolerance, const base::DataVector& x0) + : SLESolver(), N(maxItCount), tol(tolerance), x0(x0) {} -BiCGStab::~BiCGStab() { -} +BiCGStab::~BiCGStab() {} -bool BiCGStab::solve(SLE& system, base::DataVector& b, - base::DataVector& x) const { +bool BiCGStab::solve(SLE& system, base::DataVector& b, base::DataVector& x) const { Printer::getInstance().printStatusBegin("Solving linear system (BiCGStab)..."); const size_t n = b.getSize(); @@ -96,9 +86,10 @@ bool BiCGStab::solve(SLE& system, base::DataVector& b, omega = t.dotProduct(s) / t.dotProduct(t); rNormSquared = s.dotProduct(s); - if (rNormSquared < tol*tol*0.1){//if || s || sufficiently small, then set xi = xi−1 + αpi and quit - omega = 0.; - } + if (rNormSquared < + tol * tol * 0.1) { // if || s || sufficiently small, then set xi = xi−1 + αpi and quit + omega = 0.; + } if (std::isnan(omega)) { Printer::getInstance().printStatusEnd("error: Could not solve linear system!"); return false; @@ -111,47 +102,34 @@ bool BiCGStab::solve(SLE& system, base::DataVector& b, rNormSquared = r.dotProduct(r); - Printer::getInstance().printStatusUpdate("k = " + std::to_string(k) + - ", residual norm = " + - std::to_string(sqrt(rNormSquared))); + Printer::getInstance().printStatusUpdate("k = " + std::to_string(k) + ", residual norm = " + + std::to_string(sqrt(rNormSquared))); if (rNormSquared < tol * tol) { break; } } - Printer::getInstance().printStatusUpdate("k = " + std::to_string(k) + - ", residual norm = " + - std::to_string(sqrt(rNormSquared))); + Printer::getInstance().printStatusUpdate("k = " + std::to_string(k) + ", residual norm = " + + std::to_string(sqrt(rNormSquared))); Printer::getInstance().printStatusEnd(); return true; } -size_t BiCGStab::getMaxItCount() const { - return N; -} +size_t BiCGStab::getMaxItCount() const { return N; } -void BiCGStab::setMaxItCount(size_t maxItCount) { - N = maxItCount; -} +void BiCGStab::setMaxItCount(size_t maxItCount) { N = maxItCount; } -float_t BiCGStab::getTolerance() const { - return tol; -} +float_t BiCGStab::getTolerance() const { return tol; } -void BiCGStab::setTolerance(float_t tolerance) { - tol = tolerance; -} +void BiCGStab::setTolerance(float_t tolerance) { tol = tolerance; } -const base::DataVector& BiCGStab::getStartingPoint() const { - return x0; -} +const base::DataVector& BiCGStab::getStartingPoint() const { return x0; } void BiCGStab::setStartingPoint(const base::DataVector& startingPoint) { x0.resize(startingPoint.getSize()); x0 = startingPoint; } - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/sle/solver/BiCGStab.hpp b/optimization/src/sgpp/optimization/sle/solver/BiCGStab.hpp index 2d8bee13ef..9644637d7c 100644 --- a/optimization/src/sgpp/optimization/sle/solver/BiCGStab.hpp +++ b/optimization/src/sgpp/optimization/sle/solver/BiCGStab.hpp @@ -37,8 +37,7 @@ class BiCGStab : public SLESolver { * @param tolerance tolerance * @param startingPoint starting vector */ - BiCGStab(size_t maxItCount, float_t tolerance, - const base::DataVector& startingPoint); + BiCGStab(size_t maxItCount, float_t tolerance, const base::DataVector& startingPoint); /** * Destructor. @@ -52,9 +51,7 @@ class BiCGStab : public SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, - base::DataVector& b, - base::DataVector& x) const override; + bool solve(SLE& system, base::DataVector& b, base::DataVector& x) const override; /** * @return maximal number of iterations @@ -94,9 +91,8 @@ class BiCGStab : public SLESolver { /// starting vector base::DataVector x0; }; - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_SLE_SOLVER_BICGSTAB_HPP */ diff --git a/optimization/src/sgpp/optimization/sle/solver/Eigen.cpp b/optimization/src/sgpp/optimization/sle/solver/Eigen.cpp index e106c50099..b6c3988a69 100644 --- a/optimization/src/sgpp/optimization/sle/solver/Eigen.cpp +++ b/optimization/src/sgpp/optimization/sle/solver/Eigen.cpp @@ -15,6 +15,7 @@ #include #include +#include namespace SGPP { namespace optimization { @@ -37,16 +38,13 @@ typedef ::Eigen::MatrixXf EigenMatrix; * @param[out] x solution of the linear system * @return whether all went well (false if errors occurred) */ -bool solveInternal( - const EigenMatrix& A, - const ::Eigen::HouseholderQR& A_QR, - base::DataVector& b, - base::DataVector& x) { +bool solveInternal(const EigenMatrix& A, const ::Eigen::HouseholderQR& A_QR, + base::DataVector& b, base::DataVector& x) { const SGPP::float_t tolerance = #if USE_DOUBLE_PRECISION - 1e-12; + 1e-12; #else - 1e-4; + 1e-4; #endif // solve system @@ -63,11 +61,9 @@ bool solveInternal( } #endif /* USE_EIGEN */ -Eigen::~Eigen() { -} +Eigen::~Eigen() {} -bool Eigen::solve(SLE& system, base::DataVector& b, - base::DataVector& x) const { +bool Eigen::solve(SLE& system, base::DataVector& b, base::DataVector& x) const { base::DataMatrix B(b.getPointer(), b.getSize(), 1); base::DataMatrix X(B.getNrows(), B.getNcols()); @@ -81,9 +77,7 @@ bool Eigen::solve(SLE& system, base::DataVector& b, } } -bool Eigen::solve(SLE& system, - base::DataMatrix& B, - base::DataMatrix& X) const { +bool Eigen::solve(SLE& system, base::DataMatrix& B, base::DataMatrix& X) const { #ifdef USE_EIGEN Printer::getInstance().printStatusBegin("Solving linear system (Eigen)..."); @@ -91,9 +85,8 @@ bool Eigen::solve(SLE& system, EigenMatrix A = EigenMatrix::Zero(n, n); size_t nnz = 0; - // parallelize only if the system is cloneable - #pragma omp parallel if (system.isCloneable()) \ - shared(system, A, nnz) default(none) +// parallelize only if the system is cloneable +#pragma omp parallel if (system.isCloneable()) shared(system, A, nnz) default(none) { SLE* system2 = &system; #ifdef _OPENMP @@ -106,8 +99,8 @@ bool Eigen::solve(SLE& system, #endif /* _OPENMP */ - // copy system matrix to Eigen matrix object - #pragma omp for ordered schedule(dynamic) +// copy system matrix to Eigen matrix object +#pragma omp for ordered schedule(dynamic) for (size_t i = 0; i < n; i++) { for (size_t j = 0; j < n; j++) { @@ -116,20 +109,20 @@ bool Eigen::solve(SLE& system, // count nonzero entries // (not necessary, you can also remove that if you like) if (A(i, j) != 0) { - #pragma omp atomic +#pragma omp atomic nnz++; } } // status message if (i % 100 == 0) { - #pragma omp ordered +#pragma omp ordered { char str[10]; - snprintf(str, 10, "%.1f%%", - static_cast(i) / static_cast(n) * 100.0); - Printer::getInstance().printStatusUpdate("constructing matrix (" + - std::string(str) + ")"); + snprintf(str, sizeof(str), "%.1f%%", + static_cast(i) / static_cast(n) * 100.0); + Printer::getInstance().printStatusUpdate("constructing matrix (" + std::string(str) + + ")"); } } } @@ -141,10 +134,9 @@ bool Eigen::solve(SLE& system, // print ratio of nonzero entries { char str[10]; - float_t nnz_ratio = static_cast(nnz) / - (static_cast(n) * - static_cast(n)); - snprintf(str, 10, "%.1f%%", nnz_ratio * 100.0); + float_t nnz_ratio = + static_cast(nnz) / (static_cast(n) * static_cast(n)); + snprintf(str, sizeof(str), "%.1f%%", nnz_ratio * 100.0); Printer::getInstance().printStatusUpdate("nnz ratio: " + std::string(str)); Printer::getInstance().printStatusNewLine(); } @@ -165,10 +157,8 @@ bool Eigen::solve(SLE& system, if (B.getNcols() == 1) { Printer::getInstance().printStatusUpdate("step 2: solving"); } else { - Printer::getInstance().printStatusUpdate("step 2: solving (RHS " + - std::to_string(i + 1) + - " of " + std::to_string(B.getNcols()) + - ")"); + Printer::getInstance().printStatusUpdate("step 2: solving (RHS " + std::to_string(i + 1) + + " of " + std::to_string(B.getNcols()) + ")"); } if (solveInternal(A, A_QR, b, x)) { @@ -187,7 +177,6 @@ bool Eigen::solve(SLE& system, return false; #endif /* USE_EIGEN */ } - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/sle/solver/Eigen.hpp b/optimization/src/sgpp/optimization/sle/solver/Eigen.hpp index d350ff1c4a..9c4690bc48 100644 --- a/optimization/src/sgpp/optimization/sle/solver/Eigen.hpp +++ b/optimization/src/sgpp/optimization/sle/solver/Eigen.hpp @@ -32,9 +32,7 @@ class Eigen : public SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, - base::DataVector& b, - base::DataVector& x) const override; + bool solve(SLE& system, base::DataVector& b, base::DataVector& x) const override; /** * @param system system to be solved @@ -43,13 +41,10 @@ class Eigen : public SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, - base::DataMatrix& B, - base::DataMatrix& X) const override; + bool solve(SLE& system, base::DataMatrix& B, base::DataMatrix& X) const override; }; - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_SLE_SOLVER_EIGEN_HPP */ diff --git a/optimization/src/sgpp/optimization/sle/solver/GaussianElimination.cpp b/optimization/src/sgpp/optimization/sle/solver/GaussianElimination.cpp index 84caa9af13..63ba18b092 100644 --- a/optimization/src/sgpp/optimization/sle/solver/GaussianElimination.cpp +++ b/optimization/src/sgpp/optimization/sle/solver/GaussianElimination.cpp @@ -16,14 +16,10 @@ namespace SGPP { namespace optimization { namespace sle_solver { -GaussianElimination::~GaussianElimination() { -} +GaussianElimination::~GaussianElimination() {} -bool GaussianElimination::solve(SLE& system, - base::DataVector& b, - base::DataVector& x) const { - Printer::getInstance().printStatusBegin( - "Solving linear system (Gaussian elimination)..."); +bool GaussianElimination::solve(SLE& system, base::DataVector& b, base::DataVector& x) const { + Printer::getInstance().printStatusBegin("Solving linear system (Gaussian elimination)..."); // size of the system const size_t n = b.getSize(); @@ -71,8 +67,7 @@ bool GaussianElimination::solve(SLE& system, // all entries are zero ==> matrices W and A are rank deficient if (maxEntry == 0) { - Printer::getInstance().printStatusEnd( - "error: Could not solve linear system!"); + Printer::getInstance().printStatusEnd("error: Could not solve linear system!"); return false; } @@ -112,7 +107,6 @@ bool GaussianElimination::solve(SLE& system, Printer::getInstance().printStatusEnd(); return true; } - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/sle/solver/GaussianElimination.hpp b/optimization/src/sgpp/optimization/sle/solver/GaussianElimination.hpp index ba92766d8e..3857ecc819 100644 --- a/optimization/src/sgpp/optimization/sle/solver/GaussianElimination.hpp +++ b/optimization/src/sgpp/optimization/sle/solver/GaussianElimination.hpp @@ -32,13 +32,10 @@ class GaussianElimination : public SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, - base::DataVector& b, - base::DataVector& x) const override; + bool solve(SLE& system, base::DataVector& b, base::DataVector& x) const override; }; - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_SLE_SOLVER_GAUSSIANELIMINATION_HPP */ diff --git a/optimization/src/sgpp/optimization/sle/solver/Gmmpp.cpp b/optimization/src/sgpp/optimization/sle/solver/Gmmpp.cpp index d31792ce95..b204c488b3 100644 --- a/optimization/src/sgpp/optimization/sle/solver/Gmmpp.cpp +++ b/optimization/src/sgpp/optimization/sle/solver/Gmmpp.cpp @@ -15,6 +15,9 @@ #include #include +#include +#include +#include namespace SGPP { namespace optimization { @@ -28,9 +31,8 @@ namespace sle_solver { */ void callback(const gmm::iteration& iter) { Printer::getInstance().printStatusUpdate( - "solving with Gmm++ (k = " + - std::to_string(iter.get_iteration()) + - ", residual norm = " + std::to_string(iter.get_res()) + ")"); + "solving with Gmm++ (k = " + std::to_string(iter.get_iteration()) + ", residual norm = " + + std::to_string(iter.get_res()) + ")"); } /** @@ -39,9 +41,7 @@ void callback(const gmm::iteration& iter) { * @param[out] x solution of the linear system * @return whether all went well (false if errors occurred) */ -bool solveInternal(const gmm::csr_matrix& A, - base::DataVector& b, - base::DataVector& x) { +bool solveInternal(const gmm::csr_matrix& A, base::DataVector& b, base::DataVector& x) { // allow warnings gmm::warning_level::level(1); const size_t n = b.getSize(); @@ -67,10 +67,9 @@ bool solveInternal(const gmm::csr_matrix& A, if (iter.converged() && (res < 1e3)) { // GMRES converged x = base::DataVector(xVec); - Printer::getInstance().printStatusUpdate( - "solving with Gmm++ (k = " + - std::to_string(iter.get_iteration()) + - ", residual norm = " + std::to_string(res) + ")"); + Printer::getInstance().printStatusUpdate("solving with Gmm++ (k = " + + std::to_string(iter.get_iteration()) + + ", residual norm = " + std::to_string(res) + ")"); Printer::getInstance().printStatusEnd(); return true; } else { @@ -79,7 +78,7 @@ bool solveInternal(const gmm::csr_matrix& A, Printer::getInstance().printStatusNewLine(); Printer::getInstance().printStatusUpdate( - "solving with preconditioner failed, trying again without one"); + "solving with preconditioner failed, trying again without one"); Printer::getInstance().printStatusNewLine(); // call GMRES again @@ -88,33 +87,29 @@ bool solveInternal(const gmm::csr_matrix& A, if (iter.converged() && (res < 1e3)) { x = base::DataVector(xVec); - Printer::getInstance().printStatusUpdate( - "solving with Gmm++ (k = " + - std::to_string(iter.get_iteration()) + - ", residual norm = " + std::to_string(res) + ")"); + Printer::getInstance().printStatusUpdate("solving with Gmm++ (k = " + + std::to_string(iter.get_iteration()) + + ", residual norm = " + std::to_string(res) + ")"); Printer::getInstance().printStatusEnd(); return true; } else { Printer::getInstance().printStatusEnd( - "error: Could not solve linear system, " - "method didn't converge"); + "error: Could not solve linear system, " + "method didn't converge"); return false; } } } catch (std::exception& e) { - Printer::getInstance().printStatusEnd( - "error: Could not solve linear system, what(): " + - std::string(e.what())); + Printer::getInstance().printStatusEnd("error: Could not solve linear system, what(): " + + std::string(e.what())); return false; } } #endif /* USE_GMMPP */ -Gmmpp::~Gmmpp() { -} +Gmmpp::~Gmmpp() {} -bool Gmmpp::solve(SLE& system, base::DataVector& b, - base::DataVector& x) const { +bool Gmmpp::solve(SLE& system, base::DataVector& b, base::DataVector& x) const { #ifdef USE_GMMPP Printer::getInstance().printStatusBegin("Solving linear system (Gmm++)..."); @@ -125,9 +120,8 @@ bool Gmmpp::solve(SLE& system, base::DataVector& b, { gmm::row_matrix> A(n, n); - // parallelize only if the system is cloneable - #pragma omp parallel if (system.isCloneable()) \ - shared(system, A, nnz) default(none) +// parallelize only if the system is cloneable +#pragma omp parallel if (system.isCloneable()) shared(system, A, nnz) default(none) { SLE* system2 = &system; #ifdef _OPENMP @@ -140,15 +134,15 @@ bool Gmmpp::solve(SLE& system, base::DataVector& b, #endif /* _OPENMP */ - // copy system matrix to Gmm++ matrix object - #pragma omp for ordered schedule(dynamic) +// copy system matrix to Gmm++ matrix object +#pragma omp for ordered schedule(dynamic) for (size_t i = 0; i < n; i++) { for (size_t j = 0; j < n; j++) { float_t entry = system2->getMatrixEntry(i, j); if (entry != 0) { - #pragma omp critical +#pragma omp critical { A(i, j) = entry; nnz++; @@ -158,13 +152,13 @@ bool Gmmpp::solve(SLE& system, base::DataVector& b, // status message if (i % 100 == 0) { - #pragma omp ordered +#pragma omp ordered { char str[10]; - snprintf(str, 10, "%.1f%%", - static_cast(i) / static_cast(n) * 100.0); + snprintf(str, sizeof(str), "%.1f%%", + static_cast(i) / static_cast(n) * 100.0); Printer::getInstance().printStatusUpdate("constructing sparse matrix (" + - std::string(str) + ")"); + std::string(str) + ")"); } } } @@ -181,10 +175,9 @@ bool Gmmpp::solve(SLE& system, base::DataVector& b, // print ratio of nonzero entries { char str[10]; - float_t nnz_ratio = static_cast(nnz) / - (static_cast(n) * - static_cast(n)); - snprintf(str, 10, "%.1f%%", nnz_ratio * 100.0); + float_t nnz_ratio = + static_cast(nnz) / (static_cast(n) * static_cast(n)); + snprintf(str, sizeof(str), "%.1f%%", nnz_ratio * 100.0); Printer::getInstance().printStatusUpdate("nnz ratio: " + std::string(str)); Printer::getInstance().printStatusNewLine(); } @@ -198,7 +191,6 @@ bool Gmmpp::solve(SLE& system, base::DataVector& b, return false; #endif /* USE_GMMPP */ } - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/sle/solver/Gmmpp.hpp b/optimization/src/sgpp/optimization/sle/solver/Gmmpp.hpp index 7bc4ac7bdf..88a6ba42c6 100644 --- a/optimization/src/sgpp/optimization/sle/solver/Gmmpp.hpp +++ b/optimization/src/sgpp/optimization/sle/solver/Gmmpp.hpp @@ -32,13 +32,10 @@ class Gmmpp : public SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, - base::DataVector& b, - base::DataVector& x) const override; + bool solve(SLE& system, base::DataVector& b, base::DataVector& x) const override; }; - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_SLE_SOLVER_GMMPP_HPP */ diff --git a/optimization/src/sgpp/optimization/sle/solver/SLESolver.hpp b/optimization/src/sgpp/optimization/sle/solver/SLESolver.hpp index 5be45cd772..5a2eaa8190 100644 --- a/optimization/src/sgpp/optimization/sle/solver/SLESolver.hpp +++ b/optimization/src/sgpp/optimization/sle/solver/SLESolver.hpp @@ -26,14 +26,12 @@ class SLESolver { /** * Constructor. */ - SLESolver() { - } + SLESolver() {} /** * Destructor. */ - virtual ~SLESolver() { - } + virtual ~SLESolver() {} /** * Pure virtual method for a solving linear system. @@ -44,8 +42,7 @@ class SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, base::DataVector& b, - base::DataVector& x) const = 0; + virtual bool solve(SLE& system, base::DataVector& b, base::DataVector& x) const = 0; /** * Virtual method for solving multiple linear systems with @@ -59,9 +56,7 @@ class SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, - base::DataMatrix& B, - base::DataMatrix& X) const { + virtual bool solve(SLE& system, base::DataMatrix& B, base::DataMatrix& X) const { const size_t n = system.getDimension(); const size_t m = B.getNcols(); base::DataVector b(n); @@ -81,9 +76,8 @@ class SLESolver { return true; } }; - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_SLE_SOLVER_SLESOLVER_HPP */ diff --git a/optimization/src/sgpp/optimization/sle/solver/UMFPACK.cpp b/optimization/src/sgpp/optimization/sle/solver/UMFPACK.cpp index 00c12f99fe..fed8ad9d6b 100644 --- a/optimization/src/sgpp/optimization/sle/solver/UMFPACK.cpp +++ b/optimization/src/sgpp/optimization/sle/solver/UMFPACK.cpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include namespace SGPP { namespace optimization { @@ -33,28 +35,23 @@ typedef UF_long sslong; * @param[out] x solution to the system * @return whether all went well (false if errors occurred) */ -bool solveInternal(void* numeric, const std::vector& Ap, - const std::vector& Ai, - const std::vector& Ax, - base::DataVector& b, - base::DataVector& x) { +bool solveInternal(void* numeric, const std::vector& Ap, const std::vector& Ai, + const std::vector& Ax, base::DataVector& b, base::DataVector& x) { const size_t n = b.getSize(); #if USE_DOUBLE_PRECISION x.resize(n); x.setAll(0.0); - sslong result = umfpack_dl_solve(UMFPACK_A, &Ap[0], &Ai[0], - &Ax[0], x.getPointer(), b.getPointer(), - numeric, NULL, NULL); + sslong result = umfpack_dl_solve(UMFPACK_A, &Ap[0], &Ai[0], &Ax[0], x.getPointer(), + b.getPointer(), numeric, NULL, NULL); return (result == UMFPACK_OK); #else std::vector bDbl(b.getPointer(), b.getPointer() + b.getSize()); std::vector xDbl(n); - sslong result = umfpack_dl_solve(UMFPACK_A, &Ap[0], &Ai[0], - &Ax[0], &xDbl[0], &bDbl[0], - numeric, NULL, NULL); + sslong result = + umfpack_dl_solve(UMFPACK_A, &Ap[0], &Ai[0], &Ax[0], &xDbl[0], &bDbl[0], numeric, NULL, NULL); if (result == UMFPACK_OK) { for (size_t i = 0; i < xDbl.size(); i++) { @@ -70,11 +67,9 @@ bool solveInternal(void* numeric, const std::vector& Ap, } #endif /* USE_UMFPACK */ -UMFPACK::~UMFPACK() { -} +UMFPACK::~UMFPACK() {} -bool UMFPACK::solve(SLE& system, base::DataVector& b, - base::DataVector& x) const { +bool UMFPACK::solve(SLE& system, base::DataVector& b, base::DataVector& x) const { base::DataMatrix B(b.getPointer(), b.getSize(), 1); base::DataMatrix X(B.getNrows(), B.getNcols()); @@ -88,9 +83,7 @@ bool UMFPACK::solve(SLE& system, base::DataVector& b, } } -bool UMFPACK::solve(SLE& system, - base::DataMatrix& B, - base::DataMatrix& X) const { +bool UMFPACK::solve(SLE& system, base::DataMatrix& B, base::DataMatrix& X) const { #ifdef USE_UMFPACK Printer::getInstance().printStatusBegin("Solving linear system (UMFPACK)..."); @@ -101,9 +94,8 @@ bool UMFPACK::solve(SLE& system, std::vector Tj; std::vector Tx; - // parallelize only if the system is cloneable - #pragma omp parallel if (system.isCloneable()) \ - shared(system, Ti, Tj, Tx, nnz) default(none) +// parallelize only if the system is cloneable +#pragma omp parallel if (system.isCloneable()) shared(system, Ti, Tj, Tx, nnz) default(none) { SLE* system2 = &system; #ifdef _OPENMP @@ -116,15 +108,15 @@ bool UMFPACK::solve(SLE& system, #endif /* _OPENMP */ - // get indices and values of nonzero entries - #pragma omp for ordered schedule(dynamic) +// get indices and values of nonzero entries +#pragma omp for ordered schedule(dynamic) for (uint32_t i = 0; i < n; i++) { for (uint32_t j = 0; j < n; j++) { float_t entry = system2->getMatrixEntry(i, j); if (entry != 0) { - #pragma omp critical +#pragma omp critical { Ti.push_back(i); Tj.push_back(j); @@ -136,13 +128,13 @@ bool UMFPACK::solve(SLE& system, // status message if (i % 100 == 0) { - #pragma omp ordered +#pragma omp ordered { char str[10]; - snprintf(str, 10, "%.1f%%", - static_cast(i) / static_cast(n) * 100.0); + snprintf(str, sizeof(str), "%.1f%%", + static_cast(i) / static_cast(n) * 100.0); Printer::getInstance().printStatusUpdate("constructing sparse matrix (" + - std::string(str) + ")"); + std::string(str) + ")"); } } } @@ -154,10 +146,9 @@ bool UMFPACK::solve(SLE& system, // print ratio of nonzero entries { char str[10]; - float_t nnz_ratio = static_cast(nnz) / - (static_cast(n) * - static_cast(n)); - snprintf(str, 10, "%.1f%%", nnz_ratio * 100.0); + float_t nnz_ratio = + static_cast(nnz) / (static_cast(n) * static_cast(n)); + snprintf(str, sizeof(str), "%.1f%%", nnz_ratio * 100.0); Printer::getInstance().printStatusUpdate("nnz ratio: " + std::string(str)); Printer::getInstance().printStatusNewLine(); } @@ -180,35 +171,33 @@ bool UMFPACK::solve(SLE& system, Printer::getInstance().printStatusUpdate("step 1: umfpack_dl_triplet_to_col"); - result = umfpack_dl_triplet_to_col( - static_cast(n), static_cast(n), - static_cast(nnz), - &TiArray[0], &TjArray[0], &Tx[0], - &Ap[0], &Ai[0], &Ax[0], NULL); + result = umfpack_dl_triplet_to_col(static_cast(n), static_cast(n), + static_cast(nnz), &TiArray[0], &TjArray[0], &Tx[0], + &Ap[0], &Ai[0], &Ax[0], NULL); if (result != UMFPACK_OK) { Printer::getInstance().printStatusEnd( - "error: Could not convert to CCS via " - "umfpack_dl_triplet_to_col, error code " + - std::to_string(result)); + "error: Could not convert to CCS via " + "umfpack_dl_triplet_to_col, error code " + + std::to_string(result)); return false; } } - void* symbolic, *numeric; + void *symbolic, *numeric; Printer::getInstance().printStatusNewLine(); Printer::getInstance().printStatusUpdate("step 2: umfpack_dl_symbolic"); // call umfpack_dl_symbolic - result = umfpack_dl_symbolic(static_cast(n), - static_cast(n), - &Ap[0], &Ai[0], &Ax[0], - &symbolic, NULL, NULL); + result = umfpack_dl_symbolic(static_cast(n), static_cast(n), &Ap[0], &Ai[0], + &Ax[0], &symbolic, NULL, NULL); if (result != UMFPACK_OK) { - Printer::getInstance().printStatusEnd("error: Could solve via umfpack_dl_symbolic, " - "error code " + std::to_string(result)); + Printer::getInstance().printStatusEnd( + "error: Could solve via umfpack_dl_symbolic, " + "error code " + + std::to_string(result)); return false; } @@ -216,12 +205,13 @@ bool UMFPACK::solve(SLE& system, Printer::getInstance().printStatusUpdate("step 3: umfpack_dl_numeric"); // call umfpack_dl_numeric - result = umfpack_dl_numeric(&Ap[0], &Ai[0], &Ax[0], - symbolic, &numeric, NULL, NULL); + result = umfpack_dl_numeric(&Ap[0], &Ai[0], &Ax[0], symbolic, &numeric, NULL, NULL); if (result != UMFPACK_OK) { - Printer::getInstance().printStatusEnd("error: Could solve via umfpack_dl_numeric, " - "error code " + std::to_string(result)); + Printer::getInstance().printStatusEnd( + "error: Could solve via umfpack_dl_numeric, " + "error code " + + std::to_string(result)); umfpack_dl_free_symbolic(&symbolic); return false; } @@ -241,16 +231,17 @@ bool UMFPACK::solve(SLE& system, Printer::getInstance().printStatusUpdate("step 4: umfpack_dl_solve"); } else { Printer::getInstance().printStatusUpdate("step 4: umfpack_dl_solve (RHS " + - std::to_string(i + 1) + - " of " + std::to_string(B.getNcols()) + - ")"); + std::to_string(i + 1) + " of " + + std::to_string(B.getNcols()) + ")"); } if (solveInternal(numeric, Ap, Ai, Ax, b, x)) { X.setColumn(i, x); } else { - Printer::getInstance().printStatusEnd("error: Could solve via umfpack_dl_solve, " - "error code " + std::to_string(result)); + Printer::getInstance().printStatusEnd( + "error: Could solve via umfpack_dl_solve, " + "error code " + + std::to_string(result)); umfpack_dl_free_numeric(&numeric); return false; } @@ -266,7 +257,6 @@ bool UMFPACK::solve(SLE& system, return false; #endif /* USE_UMFPACK */ } - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/sle/solver/UMFPACK.hpp b/optimization/src/sgpp/optimization/sle/solver/UMFPACK.hpp index 4be5581b7d..544a8467cc 100644 --- a/optimization/src/sgpp/optimization/sle/solver/UMFPACK.hpp +++ b/optimization/src/sgpp/optimization/sle/solver/UMFPACK.hpp @@ -9,9 +9,10 @@ #include #include +#include + #include #include -#include namespace SGPP { namespace optimization { @@ -34,9 +35,7 @@ class UMFPACK : public SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, - base::DataVector& b, - base::DataVector& x) const override; + bool solve(SLE& system, base::DataVector& b, base::DataVector& x) const override; /** * @param system system to be solved @@ -45,13 +44,10 @@ class UMFPACK : public SLESolver { * @return whether all went well * (false if errors occurred) */ - virtual bool solve(SLE& system, - base::DataMatrix& B, - base::DataMatrix& X) const override; + bool solve(SLE& system, base::DataMatrix& B, base::DataMatrix& X) const override; }; - -} -} -} +} // namespace sle_solver +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_SLE_SOLVER_UMFPACK_HPP */ diff --git a/optimization/src/sgpp/optimization/sle/system/CloneableSLE.hpp b/optimization/src/sgpp/optimization/sle/system/CloneableSLE.hpp index edd68b928d..710fcc9aad 100644 --- a/optimization/src/sgpp/optimization/sle/system/CloneableSLE.hpp +++ b/optimization/src/sgpp/optimization/sle/system/CloneableSLE.hpp @@ -6,12 +6,11 @@ #ifndef SGPP_OPTIMIZATION_SLE_SYSTEM_CLONEABLESLE_HPP #define SGPP_OPTIMIZATION_SLE_SYSTEM_CLONEABLESLE_HPP -#include - #include - #include +#include + namespace SGPP { namespace optimization { @@ -26,14 +25,12 @@ class CloneableSLE : public SLE { /** * Constructor. */ - CloneableSLE() : SLE() { - } + CloneableSLE() : SLE() {} /** * Destructor. */ - virtual ~CloneableSLE() override { - } + ~CloneableSLE() override {} /** * Pure virtual method for cloning the linear system. @@ -48,12 +45,9 @@ class CloneableSLE : public SLE { /** * @return whether this system derives from CloneableSLE or not (true) */ - virtual bool isCloneable() const override { - return true; - } + bool isCloneable() const override { return true; } }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_SLE_SYSTEM_CLONEABLESLE_HPP */ diff --git a/optimization/src/sgpp/optimization/sle/system/FullSLE.hpp b/optimization/src/sgpp/optimization/sle/system/FullSLE.hpp index bdae52c084..4b8dcbdc27 100644 --- a/optimization/src/sgpp/optimization/sle/system/FullSLE.hpp +++ b/optimization/src/sgpp/optimization/sle/system/FullSLE.hpp @@ -27,43 +27,33 @@ class FullSLE : public CloneableSLE { * * @param A coefficient matrix */ - FullSLE(base::DataMatrix& A) : CloneableSLE(), A(A) { - } + explicit FullSLE(base::DataMatrix& A) : CloneableSLE(), A(A) {} /** * Destructor. */ - virtual ~FullSLE() override { - } + ~FullSLE() override {} /** * @param i row index * @param j column index * @return whether the (i,j)-th entry of the matrix is non-zero */ - inline virtual bool isMatrixEntryNonZero(size_t i, size_t j) override { - return (A(i, j) != 0.0); - } + inline bool isMatrixEntryNonZero(size_t i, size_t j) override { return (A(i, j) != 0.0); } /** * @param i row index * @param j column index * @return (i,j)-th entry of the matrix */ - inline virtual float_t getMatrixEntry(size_t i, size_t j) override { - return A(i, j); - } + inline float_t getMatrixEntry(size_t i, size_t j) override { return A(i, j); } /** * @return coefficient matrix */ - base::DataMatrix& getA() { - return A; - } + base::DataMatrix& getA() { return A; } - virtual size_t getDimension() const override { - return A.getNrows(); - } + size_t getDimension() const override { return A.getNrows(); } /** * Clones the linear system. @@ -71,7 +61,7 @@ class FullSLE : public CloneableSLE { * * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const override { + void clone(std::unique_ptr& clone) const override { clone = std::unique_ptr(new FullSLE(A)); } @@ -79,8 +69,7 @@ class FullSLE : public CloneableSLE { /// coefficient matrix base::DataMatrix& A; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_SLE_SYSTEM_FULLSLE_HPP */ diff --git a/optimization/src/sgpp/optimization/sle/system/HierarchisationSLE.hpp b/optimization/src/sgpp/optimization/sle/system/HierarchisationSLE.hpp index b4a000e401..61605026ce 100644 --- a/optimization/src/sgpp/optimization/sle/system/HierarchisationSLE.hpp +++ b/optimization/src/sgpp/optimization/sle/system/HierarchisationSLE.hpp @@ -55,9 +55,7 @@ class HierarchisationSLE : public CloneableSLE { * * @param grid sparse grid */ - HierarchisationSLE(base::Grid& grid) - : HierarchisationSLE(grid, *grid.getStorage()) { - } + explicit HierarchisationSLE(base::Grid& grid) : HierarchisationSLE(grid, *grid.getStorage()) {} /** * Constructor. @@ -69,85 +67,65 @@ class HierarchisationSLE : public CloneableSLE { * grid points according to gridStorage) */ HierarchisationSLE(base::Grid& grid, base::GridStorage& gridStorage) - : CloneableSLE(), - grid(grid), - gridStorage(gridStorage), - basisType(INVALID) { + : CloneableSLE(), grid(grid), gridStorage(gridStorage), basisType(INVALID) { // initialize the correct basis (according to the grid) if (grid.getType() == base::GridType::Bspline) { bsplineBasis = std::unique_ptr( - new base::SBsplineBase( - dynamic_cast(grid). - getDegree())); + new base::SBsplineBase(dynamic_cast(grid).getDegree())); basisType = BSPLINE; } else if (grid.getType() == base::GridType::BsplineBoundary) { bsplineBoundaryBasis = - std::unique_ptr( - new base::SBsplineBoundaryBase( - dynamic_cast(grid) - .getDegree())); + std::unique_ptr(new base::SBsplineBoundaryBase( + dynamic_cast(grid).getDegree())); basisType = BSPLINE_BOUNDARY; } else if (grid.getType() == base::GridType::BsplineClenshawCurtis) { bsplineClenshawCurtisBasis = - std::unique_ptr( - new base::SBsplineClenshawCurtisBase( - dynamic_cast(grid). - getDegree())); + std::unique_ptr(new base::SBsplineClenshawCurtisBase( + dynamic_cast(grid).getDegree())); basisType = BSPLINE_CLENSHAW_CURTIS; } else if (grid.getType() == base::GridType::ModBspline) { modBsplineBasis = std::unique_ptr( - new base::SBsplineModifiedBase( - dynamic_cast(grid). - getDegree())); + new base::SBsplineModifiedBase(dynamic_cast(grid).getDegree())); basisType = BSPLINE_MODIFIED; } else if (grid.getType() == base::GridType::ModBsplineClenshawCurtis) { - modBsplineClenshawCurtisBasis = - std::unique_ptr( + modBsplineClenshawCurtisBasis = std::unique_ptr( new base::SBsplineModifiedClenshawCurtisBase( - dynamic_cast(grid). - getDegree())); + dynamic_cast(grid).getDegree())); basisType = BSPLINE_MODIFIED_CLENSHAW_CURTIS; } else if (grid.getType() == base::GridType::FundamentalSpline) { - fundamentalSplineBasis = std::unique_ptr( - new base::SFundamentalSplineBase( - dynamic_cast(grid). - getDegree())); + fundamentalSplineBasis = + std::unique_ptr(new base::SFundamentalSplineBase( + dynamic_cast(grid).getDegree())); basisType = FUNDAMENTAL_SPLINE; } else if (grid.getType() == base::GridType::ModFundamentalSpline) { - modFundamentalSplineBasis = - std::unique_ptr( + modFundamentalSplineBasis = std::unique_ptr( new base::SFundamentalSplineModifiedBase( - dynamic_cast(grid). - getDegree())); + dynamic_cast(grid).getDegree())); basisType = FUNDAMENTAL_SPLINE_MODIFIED; } else if (grid.getType() == base::GridType::Linear) { - linearBasis = std::unique_ptr( - new base::SLinearBase()); + linearBasis = std::unique_ptr(new base::SLinearBase()); basisType = LINEAR; } else if (grid.getType() == base::GridType::LinearBoundary) { - linearL0BoundaryBasis = std::unique_ptr( - new base::SLinearBoundaryBase()); + linearL0BoundaryBasis = + std::unique_ptr(new base::SLinearBoundaryBase()); basisType = LINEAR_BOUNDARY; } else if (grid.getType() == base::GridType::LinearClenshawCurtis) { linearClenshawCurtisBasis = - std::unique_ptr( - new base::SLinearClenshawCurtisBase()); + std::unique_ptr(new base::SLinearClenshawCurtisBase()); basisType = LINEAR_CLENSHAW_CURTIS; } else if (grid.getType() == base::GridType::ModLinear) { - modLinearBasis = std::unique_ptr( - new base::SLinearModifiedBase()); + modLinearBasis = std::unique_ptr(new base::SLinearModifiedBase()); basisType = LINEAR_MODIFIED; } else if (grid.getType() == base::GridType::Wavelet) { - waveletBasis = std::unique_ptr( - new base::SWaveletBase()); + waveletBasis = std::unique_ptr(new base::SWaveletBase()); basisType = WAVELET; } else if (grid.getType() == base::GridType::WaveletBoundary) { - waveletBoundaryBasis = std::unique_ptr( - new base::SWaveletBoundaryBase()); + waveletBoundaryBasis = + std::unique_ptr(new base::SWaveletBoundaryBase()); basisType = WAVELET_BOUNDARY; } else if (grid.getType() == base::GridType::ModWavelet) { - modWaveletBasis = std::unique_ptr( - new base::SWaveletModifiedBase()); + modWaveletBasis = + std::unique_ptr(new base::SWaveletModifiedBase()); basisType = WAVELET_MODIFIED; } else { throw std::invalid_argument("Grid type not supported."); @@ -160,7 +138,7 @@ class HierarchisationSLE : public CloneableSLE { * @return whether the i-th grid point lies in the support of * the j-th basis function */ - inline virtual bool isMatrixEntryNonZero(size_t i, size_t j) override { + inline bool isMatrixEntryNonZero(size_t i, size_t j) override { return (evalBasisFunctionAtGridPoint(j, i) != 0.0); } @@ -169,41 +147,32 @@ class HierarchisationSLE : public CloneableSLE { * @param j column index * @return value of the j-th basis function at the i-th grid point */ - inline virtual float_t getMatrixEntry(size_t i, size_t j) override { + inline float_t getMatrixEntry(size_t i, size_t j) override { return evalBasisFunctionAtGridPoint(j, i); } /** * @return sparse grid */ - base::Grid& getGrid() { - return grid; - } + base::Grid& getGrid() { return grid; } /** * @param grid sparse grid */ - void setGrid(base::Grid& grid) { - this->grid = grid; - } + void setGrid(base::Grid& grid) { this->grid = grid; } /** * @return grid storage */ - base::GridStorage& getGridStorage() { - return gridStorage; - } + base::GridStorage& getGridStorage() { return gridStorage; } - virtual size_t getDimension() const override { - return gridStorage.size(); - } + size_t getDimension() const override { return gridStorage.size(); } /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) const override { - clone = std::unique_ptr( - new HierarchisationSLE(grid, gridStorage)); + void clone(std::unique_ptr& clone) const override { + clone = std::unique_ptr(new HierarchisationSLE(grid, gridStorage)); } protected: @@ -217,25 +186,21 @@ class HierarchisationSLE : public CloneableSLE { /// B-spline boundary basis std::unique_ptr bsplineBoundaryBasis; /// B-spline Clenshaw-Curtis basis - std::unique_ptr - bsplineClenshawCurtisBasis; + std::unique_ptr bsplineClenshawCurtisBasis; /// modified B-spline basis std::unique_ptr modBsplineBasis; /// modified B-spline Clenshaw-Curtis basis - std::unique_ptr - modBsplineClenshawCurtisBasis; + std::unique_ptr modBsplineClenshawCurtisBasis; /// fundamental spline basis std::unique_ptr fundamentalSplineBasis; /// modified fundamental spline basis - std::unique_ptr - modFundamentalSplineBasis; + std::unique_ptr modFundamentalSplineBasis; /// linear basis std::unique_ptr linearBasis; /// linear boundary basis std::unique_ptr linearL0BoundaryBasis; /// linear Clenshaw-Curtis basis - std::unique_ptr - linearClenshawCurtisBasis; + std::unique_ptr linearClenshawCurtisBasis; /// modified linear basis std::unique_ptr modLinearBasis; /// wavelet basis @@ -270,25 +235,21 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th basis function at the * pointJ-th grid point */ - inline float_t evalBasisFunctionAtGridPoint(size_t basisI, - size_t pointJ) { + inline float_t evalBasisFunctionAtGridPoint(size_t basisI, size_t pointJ) { if (basisType == BSPLINE) { return evalBsplineFunctionAtGridPoint(basisI, pointJ); } else if (basisType == BSPLINE_BOUNDARY) { return evalBsplineBoundaryFunctionAtGridPoint(basisI, pointJ); } else if (basisType == BSPLINE_CLENSHAW_CURTIS) { - return evalBsplineClenshawCurtisFunctionAtGridPoint(basisI, - pointJ); + return evalBsplineClenshawCurtisFunctionAtGridPoint(basisI, pointJ); } else if (basisType == BSPLINE_MODIFIED) { return evalBsplineModifiedFunctionAtGridPoint(basisI, pointJ); } else if (basisType == BSPLINE_MODIFIED_CLENSHAW_CURTIS) { - return evalBsplineModifiedClenshawCurtisFunctionAtGridPoint( - basisI, pointJ); + return evalBsplineModifiedClenshawCurtisFunctionAtGridPoint(basisI, pointJ); } else if (basisType == FUNDAMENTAL_SPLINE) { return evalFundamentalSplineFunctionAtGridPoint(basisI, pointJ); } else if (basisType == FUNDAMENTAL_SPLINE_MODIFIED) { - return evalFundamentalSplineModifiedFunctionAtGridPoint(basisI, - pointJ); + return evalFundamentalSplineModifiedFunctionAtGridPoint(basisI, pointJ); } else if (basisType == LINEAR) { return evalLinearFunctionAtGridPoint(basisI, pointJ); } else if (basisType == LINEAR_BOUNDARY) { @@ -314,17 +275,14 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th B-spline basis function * at the pointJ-th grid point */ - inline float_t evalBsplineFunctionAtGridPoint(size_t basisI, - size_t pointJ) { + inline float_t evalBsplineFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; for (size_t t = 0; t < gridStorage.dim(); t++) { - const float_t result1d = bsplineBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + const float_t result1d = + bsplineBasis->eval(gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -342,17 +300,14 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th B-spline boundary * basis function at the pointJ-th grid point */ - inline float_t evalBsplineBoundaryFunctionAtGridPoint(size_t basisI, - size_t pointJ) { + inline float_t evalBsplineBoundaryFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; for (size_t t = 0; t < gridStorage.dim(); t++) { - const float_t result1d = bsplineBoundaryBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + const float_t result1d = + bsplineBoundaryBasis->eval(gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -370,17 +325,14 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th B-spline Clenshaw-Curtis * basis function at the pointJ-th grid point */ - inline float_t evalBsplineClenshawCurtisFunctionAtGridPoint( - size_t basisI, size_t pointJ) { + inline float_t evalBsplineClenshawCurtisFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; for (size_t t = 0; t < gridStorage.dim(); t++) { const float_t result1d = bsplineClenshawCurtisBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -398,17 +350,14 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th modified B-spline * basis function at the pointJ-th grid point */ - inline float_t evalBsplineModifiedFunctionAtGridPoint(size_t basisI, - size_t pointJ) { + inline float_t evalBsplineModifiedFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; for (size_t t = 0; t < gridStorage.dim(); t++) { - const float_t result1d = modBsplineBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + const float_t result1d = + modBsplineBasis->eval(gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -426,17 +375,15 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th modified Clenshaw-Curtis * B-spline basis function at the pointJ-th grid point */ - inline float_t evalBsplineModifiedClenshawCurtisFunctionAtGridPoint( - size_t basisI, size_t pointJ) { + inline float_t evalBsplineModifiedClenshawCurtisFunctionAtGridPoint(size_t basisI, + size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; for (size_t t = 0; t < gridStorage.dim(); t++) { const float_t result1d = modBsplineClenshawCurtisBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -454,8 +401,7 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th fundamental spline basis * function at the pointJ-th grid point */ - inline float_t evalFundamentalSplineFunctionAtGridPoint(size_t basisI, - size_t pointJ) { + inline float_t evalFundamentalSplineFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; @@ -469,9 +415,7 @@ class HierarchisationSLE : public CloneableSLE { } } else { const float_t result1d = fundamentalSplineBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -490,8 +434,7 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th modified fundamental spline * basis function at the pointJ-th grid point */ - inline float_t evalFundamentalSplineModifiedFunctionAtGridPoint( - size_t basisI, size_t pointJ) { + inline float_t evalFundamentalSplineModifiedFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; @@ -505,9 +448,7 @@ class HierarchisationSLE : public CloneableSLE { } } else { const float_t result1d = modFundamentalSplineBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -526,17 +467,14 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th linear * basis function at the pointJ-th grid point */ - inline float_t evalLinearFunctionAtGridPoint(size_t basisI, - size_t pointJ) { + inline float_t evalLinearFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; for (size_t t = 0; t < gridStorage.dim(); t++) { - const float_t result1d = linearBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + const float_t result1d = + linearBasis->eval(gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -554,17 +492,14 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th linear boundary * basis function at the pointJ-th grid point */ - inline float_t evalLinearBoundaryFunctionAtGridPoint(size_t basisI, - size_t pointJ) { + inline float_t evalLinearBoundaryFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; for (size_t t = 0; t < gridStorage.dim(); t++) { - const float_t result1d = linearL0BoundaryBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + const float_t result1d = linearL0BoundaryBasis->eval(gpBasis.getLevel(t), gpBasis.getIndex(t), + gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -582,17 +517,14 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th linear Clenshaw-Curtis * basis function at the pointJ-th grid point */ - inline float_t evalLinearClenshawCurtisFunctionAtGridPoint( - size_t basisI, size_t pointJ) { + inline float_t evalLinearClenshawCurtisFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; for (size_t t = 0; t < gridStorage.dim(); t++) { const float_t result1d = linearClenshawCurtisBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -610,17 +542,14 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th modified linear * basis function at the pointJ-th grid point */ - inline float_t evalLinearModifiedFunctionAtGridPoint(size_t basisI, - size_t pointJ) { + inline float_t evalLinearModifiedFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; for (size_t t = 0; t < gridStorage.dim(); t++) { - const float_t result1d = modLinearBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + const float_t result1d = + modLinearBasis->eval(gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -638,17 +567,14 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th wavelet * basis function at the pointJ-th grid point */ - inline float_t evalWaveletFunctionAtGridPoint(size_t basisI, - size_t pointJ) { + inline float_t evalWaveletFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; for (size_t t = 0; t < gridStorage.dim(); t++) { - const float_t result1d = waveletBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + const float_t result1d = + waveletBasis->eval(gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -666,17 +592,14 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th wavelet boundary * basis function at the pointJ-th grid point */ - inline float_t evalWaveletBoundaryFunctionAtGridPoint(size_t basisI, - size_t pointJ) { + inline float_t evalWaveletBoundaryFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; for (size_t t = 0; t < gridStorage.dim(); t++) { - const float_t result1d = waveletBoundaryBasis->eval( - gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + const float_t result1d = + waveletBoundaryBasis->eval(gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -694,16 +617,14 @@ class HierarchisationSLE : public CloneableSLE { * @return value of the basisI-th modified wavelet * basis function at the pointJ-th grid point */ - inline float_t evalWaveletModifiedFunctionAtGridPoint(size_t basisI, - size_t pointJ) { + inline float_t evalWaveletModifiedFunctionAtGridPoint(size_t basisI, size_t pointJ) { const base::GridIndex& gpBasis = *gridStorage[basisI]; const base::GridIndex& gpPoint = *gridStorage[pointJ]; float_t result = 1.0; for (size_t t = 0; t < gridStorage.dim(); t++) { - const float_t result1d = modWaveletBasis->eval(gpBasis.getLevel(t), - gpBasis.getIndex(t), - gpPoint.getCoord(t)); + const float_t result1d = + modWaveletBasis->eval(gpBasis.getLevel(t), gpBasis.getIndex(t), gpPoint.getCoord(t)); if (result1d == 0.0) { return 0.0; @@ -715,8 +636,7 @@ class HierarchisationSLE : public CloneableSLE { return result; } }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_SLE_SYSTEM_HIERARCHISATIONSLE_HPP */ diff --git a/optimization/src/sgpp/optimization/sle/system/SLE.hpp b/optimization/src/sgpp/optimization/sle/system/SLE.hpp index 2f81813eac..916b2786fb 100644 --- a/optimization/src/sgpp/optimization/sle/system/SLE.hpp +++ b/optimization/src/sgpp/optimization/sle/system/SLE.hpp @@ -6,11 +6,11 @@ #ifndef SGPP_OPTIMIZATION_SLE_SYSTEM_SLE_HPP #define SGPP_OPTIMIZATION_SLE_SYSTEM_SLE_HPP -#include - #include #include +#include + namespace SGPP { namespace optimization { @@ -23,14 +23,12 @@ class SLE { /** * Constructor. */ - SLE() { - } + SLE() {} /** * Destructor. */ - virtual ~SLE() { - } + virtual ~SLE() {} /** * Pure virtual method for checking if a matrix entry vanishes or not. @@ -58,8 +56,7 @@ class SLE { * @param x vector to be multiplied * @param[out] y \f$y = Ax\f$ */ - virtual void matrixVectorMultiplication(const base::DataVector& x, - base::DataVector& y) { + virtual void matrixVectorMultiplication(const base::DataVector& x, base::DataVector& y) { const size_t n = getDimension(); y.resize(n); y.setAll(0.0); @@ -104,12 +101,9 @@ class SLE { * @return whether this system derives from CloneableSLE or not * (standard: false) */ - virtual bool isCloneable() const { - return false; - } + virtual bool isCloneable() const { return false; } }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_SLE_SYSTEM_SLE_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/TestScalarFunction.cpp b/optimization/src/sgpp/optimization/test_problems/TestScalarFunction.cpp index 789d439265..313e5df33f 100644 --- a/optimization/src/sgpp/optimization/test_problems/TestScalarFunction.cpp +++ b/optimization/src/sgpp/optimization/test_problems/TestScalarFunction.cpp @@ -10,14 +10,10 @@ namespace SGPP { namespace optimization { namespace test_problems { -TestScalarFunction::TestScalarFunction(size_t d) : - ScalarFunction(d), - displacement(d, 0.0), - xTmp(d) { -} +TestScalarFunction::TestScalarFunction(size_t d) + : ScalarFunction(d), displacement(d, 0.0), xTmp(d) {} -TestScalarFunction::~TestScalarFunction() { -} +TestScalarFunction::~TestScalarFunction() {} float_t TestScalarFunction::eval(const base::DataVector& x) { // displace vector before evaluation @@ -28,15 +24,11 @@ float_t TestScalarFunction::eval(const base::DataVector& x) { return evalUndisplaced(xTmp); } -const base::DataVector& TestScalarFunction::getDisplacement() const { - return displacement; -} +const base::DataVector& TestScalarFunction::getDisplacement() const { return displacement; } -void TestScalarFunction::setDisplacement( - const base::DataVector& displacement) { +void TestScalarFunction::setDisplacement(const base::DataVector& displacement) { this->displacement = displacement; } - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/TestScalarFunction.hpp b/optimization/src/sgpp/optimization/test_problems/TestScalarFunction.hpp index f901cff22b..2f320b30f2 100644 --- a/optimization/src/sgpp/optimization/test_problems/TestScalarFunction.hpp +++ b/optimization/src/sgpp/optimization/test_problems/TestScalarFunction.hpp @@ -6,11 +6,11 @@ #ifndef SGPP_OPTIMIZATION_TEST_PROBLEMS_TESTSCALARFUNCTION_HPP #define SGPP_OPTIMIZATION_TEST_PROBLEMS_TESTSCALARFUNCTION_HPP -#include - #include #include +#include + namespace SGPP { namespace optimization { namespace test_problems { @@ -39,7 +39,7 @@ class TestScalarFunction : public ScalarFunction { * * @param d dimension of the domain */ - TestScalarFunction(size_t d); + explicit TestScalarFunction(size_t d); /** * Destructor. @@ -79,9 +79,8 @@ class TestScalarFunction : public ScalarFunction { /// temporary vector for displacing base::DataVector xTmp; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_TESTSCALARFUNCTION_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/TestVectorFunction.cpp b/optimization/src/sgpp/optimization/test_problems/TestVectorFunction.cpp index 7e8c38e887..e543039259 100644 --- a/optimization/src/sgpp/optimization/test_problems/TestVectorFunction.cpp +++ b/optimization/src/sgpp/optimization/test_problems/TestVectorFunction.cpp @@ -10,17 +10,12 @@ namespace SGPP { namespace optimization { namespace test_problems { -TestVectorFunction::TestVectorFunction(size_t d, size_t m) : - VectorFunction(d, m), - displacement(d, 0.0), - xTmp(d) { -} +TestVectorFunction::TestVectorFunction(size_t d, size_t m) + : VectorFunction(d, m), displacement(d, 0.0), xTmp(d) {} -TestVectorFunction::~TestVectorFunction() { -} +TestVectorFunction::~TestVectorFunction() {} -void TestVectorFunction::eval(const base::DataVector& x, - base::DataVector& value) { +void TestVectorFunction::eval(const base::DataVector& x, base::DataVector& value) { // displace vector before evaluation for (size_t t = 0; t < d; t++) { xTmp[t] = x[t] + displacement[t]; @@ -29,15 +24,11 @@ void TestVectorFunction::eval(const base::DataVector& x, evalUndisplaced(xTmp, value); } -const base::DataVector& TestVectorFunction::getDisplacement() const { - return displacement; -} +const base::DataVector& TestVectorFunction::getDisplacement() const { return displacement; } -void TestVectorFunction::setDisplacement( - const base::DataVector& displacement) { +void TestVectorFunction::setDisplacement(const base::DataVector& displacement) { this->displacement = displacement; } - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/TestVectorFunction.hpp b/optimization/src/sgpp/optimization/test_problems/TestVectorFunction.hpp index f46f63e684..3b210df57b 100644 --- a/optimization/src/sgpp/optimization/test_problems/TestVectorFunction.hpp +++ b/optimization/src/sgpp/optimization/test_problems/TestVectorFunction.hpp @@ -6,11 +6,11 @@ #ifndef SGPP_OPTIMIZATION_TEST_PROBLEMS_TESTVECTORFUNCTION_HPP #define SGPP_OPTIMIZATION_TEST_PROBLEMS_TESTVECTORFUNCTION_HPP -#include - #include #include +#include + namespace SGPP { namespace optimization { namespace test_problems { @@ -51,8 +51,7 @@ class TestVectorFunction : public VectorFunction { * @param[out] value \f$\vec{f}(\vec{x} + \vec{d})\f$ * with displacement \f$\vec{d}\f$ */ - virtual void eval(const base::DataVector& x, - base::DataVector& value) override; + void eval(const base::DataVector& x, base::DataVector& value) override; /** * Pure virtual method for evaluating the undisplaced function. @@ -60,8 +59,7 @@ class TestVectorFunction : public VectorFunction { * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) = 0; + virtual void evalUndisplaced(const base::DataVector& x, base::DataVector& value) = 0; /** * @return currently used displacement @@ -79,9 +77,8 @@ class TestVectorFunction : public VectorFunction { /// temporary vector for displacing base::DataVector xTmp; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_TESTVECTORFUNCTION_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/ConstrainedTestProblem.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/ConstrainedTestProblem.cpp index c9b409cfbd..5dd7a31db0 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/ConstrainedTestProblem.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/ConstrainedTestProblem.cpp @@ -11,13 +11,9 @@ namespace SGPP { namespace optimization { namespace test_problems { -ConstrainedTestProblem::ConstrainedTestProblem(size_t d) : - d(d), - displacement(d, 0.0) { -} +ConstrainedTestProblem::ConstrainedTestProblem(size_t d) : d(d), displacement(d, 0.0) {} -ConstrainedTestProblem::~ConstrainedTestProblem() { -} +ConstrainedTestProblem::~ConstrainedTestProblem() {} float_t ConstrainedTestProblem::getOptimalPoint(base::DataVector& x) { // reverse displace optimal point @@ -36,8 +32,7 @@ void ConstrainedTestProblem::generateDisplacement(float_t stdDev) { do { for (size_t t = 0; t < d; t++) { // every component is normally distributed - displacement[t] = - RandomNumberGenerator::getInstance().getGaussianRN(stdDev); + displacement[t] = RandomNumberGenerator::getInstance().getGaussianRN(stdDev); } } while (!isDisplacementFeasible()); @@ -48,12 +43,9 @@ void ConstrainedTestProblem::generateDisplacement(float_t stdDev) { getEqualityConstraintFunction().setDisplacement(displacement); } -const base::DataVector& ConstrainedTestProblem::getDisplacement() const { - return displacement; -} +const base::DataVector& ConstrainedTestProblem::getDisplacement() const { return displacement; } -void ConstrainedTestProblem::setDisplacement( - const base::DataVector& displacement) { +void ConstrainedTestProblem::setDisplacement(const base::DataVector& displacement) { this->displacement = displacement; // set the displacement also in the objective function and // in the constraint functions @@ -76,7 +68,6 @@ bool ConstrainedTestProblem::isDisplacementFeasible() { return true; } - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/ConstrainedTestProblem.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/ConstrainedTestProblem.hpp index 1d3bab2cd1..9e9c0eeec2 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/ConstrainedTestProblem.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/ConstrainedTestProblem.hpp @@ -6,12 +6,12 @@ #ifndef SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_CONSTRAINEDTESTPROBLEM_HPP #define SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_CONSTRAINEDTESTPROBLEM_HPP -#include - #include #include #include +#include + namespace SGPP { namespace optimization { namespace test_problems { @@ -36,7 +36,7 @@ class ConstrainedTestProblem { * * @param d dimension of the domain */ - ConstrainedTestProblem(size_t d); + explicit ConstrainedTestProblem(size_t d); /** * Destructor. @@ -136,9 +136,8 @@ class ConstrainedTestProblem { */ virtual bool isDisplacementFeasible(); }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_CONSTRAINEDTESTPROBLEM_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/Floudas.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/Floudas.cpp index 11731443b8..6b76b9b62c 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/Floudas.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/Floudas.cpp @@ -11,27 +11,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -Floudas::Floudas() : - ConstrainedTestProblem(2), - f(), - g(), - h() { -} +Floudas::Floudas() : ConstrainedTestProblem(2), f(), g(), h() {} -Floudas::~Floudas() { -} +Floudas::~Floudas() {} -TestScalarFunction& Floudas::getObjectiveFunction() { - return f; -} +TestScalarFunction& Floudas::getObjectiveFunction() { return f; } -TestVectorFunction& Floudas::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& Floudas::getInequalityConstraintFunction() { return g; } -TestVectorFunction& Floudas::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& Floudas::getEqualityConstraintFunction() { return h; } float_t Floudas::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -40,41 +28,27 @@ float_t Floudas::getOptimalPointUndisplaced(base::DataVector& x) { return -5.50801327159531; } +FloudasObjective::FloudasObjective() : TestScalarFunction(2) {} +FloudasObjective::~FloudasObjective() {} -FloudasObjective::FloudasObjective() : - TestScalarFunction(2) { -} - -FloudasObjective::~FloudasObjective() { -} - -float_t FloudasObjective::evalUndisplaced( - const base::DataVector& x) { +float_t FloudasObjective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 3.0 * x[0]; const float_t x2 = 4.0 * x[1]; return -x1 - x2; } -void FloudasObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new FloudasObjective(*this)); +void FloudasObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new FloudasObjective(*this)); } +FloudasInequalityConstraint::FloudasInequalityConstraint() : TestVectorFunction(2, 2) {} +FloudasInequalityConstraint::~FloudasInequalityConstraint() {} -FloudasInequalityConstraint::FloudasInequalityConstraint() : - TestVectorFunction(2, 2) { -} - -FloudasInequalityConstraint::~FloudasInequalityConstraint() { -} - -void FloudasInequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void FloudasInequalityConstraint::evalUndisplaced(const base::DataVector& x, + base::DataVector& value) { const float_t x1 = 3.0 * x[0]; const float_t x2 = 4.0 * x[1]; @@ -83,36 +57,23 @@ void FloudasInequalityConstraint::evalUndisplaced( const float_t x1p4 = x1p3 * x1; value[0] = x2 - (2.0 * x1p4 - 8.0 * x1p3 + 8.0 * x1p2 + 2.0); - value[1] = x2 - (4.0 * x1p4 - 32.0 * x1p3 + - 88.0 * x1p2 - 96.0 * x1 + 36.0); + value[1] = x2 - (4.0 * x1p4 - 32.0 * x1p3 + 88.0 * x1p2 - 96.0 * x1 + 36.0); } -void FloudasInequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new FloudasInequalityConstraint(*this)); +void FloudasInequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new FloudasInequalityConstraint(*this)); } +FloudasEqualityConstraint::FloudasEqualityConstraint() : TestVectorFunction(2, 0) {} +FloudasEqualityConstraint::~FloudasEqualityConstraint() {} -FloudasEqualityConstraint::FloudasEqualityConstraint() : - TestVectorFunction(2, 0) { -} - -FloudasEqualityConstraint::~FloudasEqualityConstraint() { -} +void FloudasEqualityConstraint::evalUndisplaced(const base::DataVector& x, + base::DataVector& value) {} -void FloudasEqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { -} - -void FloudasEqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new FloudasEqualityConstraint(*this)); -} - -} -} +void FloudasEqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new FloudasEqualityConstraint(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/Floudas.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/Floudas.hpp index c5be4b6dba..7e37458522 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/Floudas.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/Floudas.hpp @@ -37,14 +37,12 @@ class FloudasObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -58,8 +56,7 @@ class FloudasObjective : public TestScalarFunction { * 96 \bar{x}_1 - 36 * \end{pmatrix}\f] */ -class FloudasInequalityConstraint : - public TestVectorFunction { +class FloudasInequalityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -75,14 +72,12 @@ class FloudasInequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -90,8 +85,7 @@ class FloudasInequalityConstraint : * * Definition: empty, i.e., no constraint */ -class FloudasEqualityConstraint : - public TestVectorFunction { +class FloudasEqualityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -107,14 +101,12 @@ class FloudasEqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -162,8 +154,7 @@ class Floudas : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -173,9 +164,8 @@ class Floudas : public ConstrainedTestProblem { /// equality constraint function FloudasEqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_FLOUDAS_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G03.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/G03.cpp index f6b1375c81..0c7c6569a8 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G03.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G03.cpp @@ -12,27 +12,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -G03::G03(size_t d) : - ConstrainedTestProblem(d), - f(d), - g(d), - h(d) { -} +G03::G03(size_t d) : ConstrainedTestProblem(d), f(d), g(d), h(d) {} -G03::~G03() { -} +G03::~G03() {} -TestScalarFunction& G03::getObjectiveFunction() { - return f; -} +TestScalarFunction& G03::getObjectiveFunction() { return f; } -TestVectorFunction& G03::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& G03::getInequalityConstraintFunction() { return g; } -TestVectorFunction& G03::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& G03::getEqualityConstraintFunction() { return h; } float_t G03::getOptimalPointUndisplaced(base::DataVector& x) { const float_t dDbl = static_cast(d); @@ -41,17 +29,11 @@ float_t G03::getOptimalPointUndisplaced(base::DataVector& x) { return -std::pow(dDbl, -0.5 * dDbl); } +G03Objective::G03Objective(size_t d) : TestScalarFunction(d) {} +G03Objective::~G03Objective() {} -G03Objective::G03Objective(size_t d) : - TestScalarFunction(d) { -} - -G03Objective::~G03Objective() { -} - -float_t G03Objective::evalUndisplaced( - const base::DataVector& x) { +float_t G03Objective::evalUndisplaced(const base::DataVector& x) { float_t result = -1.0; for (size_t t = 0; t < d; t++) { @@ -61,44 +43,25 @@ float_t G03Objective::evalUndisplaced( return result; } -void G03Objective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G03Objective(*this)); +void G03Objective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G03Objective(*this)); } +G03InequalityConstraint::G03InequalityConstraint(size_t d) : TestVectorFunction(d, 0) {} +G03InequalityConstraint::~G03InequalityConstraint() {} -G03InequalityConstraint::G03InequalityConstraint(size_t d) : - TestVectorFunction(d, 0) { -} - -G03InequalityConstraint::~G03InequalityConstraint() { -} - -void G03InequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { -} +void G03InequalityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) {} -void G03InequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G03InequalityConstraint(*this)); +void G03InequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G03InequalityConstraint(*this)); } +G03EqualityConstraint::G03EqualityConstraint(size_t d) : TestVectorFunction(d, 1) {} +G03EqualityConstraint::~G03EqualityConstraint() {} -G03EqualityConstraint::G03EqualityConstraint(size_t d) : - TestVectorFunction(d, 1) { -} - -G03EqualityConstraint::~G03EqualityConstraint() { -} - -void G03EqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void G03EqualityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) { float_t result = -1.0; for (size_t t = 0; t < d; t++) { @@ -108,12 +71,9 @@ void G03EqualityConstraint::evalUndisplaced( value[0] = result; } -void G03EqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G03EqualityConstraint(*this)); -} - -} -} +void G03EqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G03EqualityConstraint(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G03.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/G03.hpp index 3c79cb3c2e..66cfa6320c 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G03.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G03.hpp @@ -28,7 +28,7 @@ class G03Objective : public TestScalarFunction { * * @param d number of parameters */ - G03Objective(size_t d); + explicit G03Objective(size_t d); /** * Destructor. @@ -39,14 +39,12 @@ class G03Objective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -54,15 +52,14 @@ class G03Objective : public TestScalarFunction { * * Definition: empty, i.e., no constraint */ -class G03InequalityConstraint : - public TestVectorFunction { +class G03InequalityConstraint : public TestVectorFunction { public: /** * Constructor. * * @param d number of parameters */ - G03InequalityConstraint(size_t d); + explicit G03InequalityConstraint(size_t d); /** * Destructor. @@ -73,14 +70,12 @@ class G03InequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -90,15 +85,14 @@ class G03InequalityConstraint : * \f[\bar{h}(\bar{\vec{x}}) := * \norm{\bar{\vec{x}}}_2^2 - 1\f] */ -class G03EqualityConstraint : - public TestVectorFunction { +class G03EqualityConstraint : public TestVectorFunction { public: /** * Constructor. * * @param d number of parameters */ - G03EqualityConstraint(size_t d); + explicit G03EqualityConstraint(size_t d); /** * Destructor. @@ -109,14 +103,12 @@ class G03EqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -138,7 +130,7 @@ class G03 : public ConstrainedTestProblem { * * @param d number of parameters */ - G03(size_t d); + explicit G03(size_t d); /** * Destructor. @@ -166,8 +158,7 @@ class G03 : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -177,9 +168,8 @@ class G03 : public ConstrainedTestProblem { /// equality constraint function G03EqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_G03_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G04.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/G04.cpp index 517ff1b126..bae3920783 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G04.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G04.cpp @@ -12,27 +12,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -G04::G04() : - ConstrainedTestProblem(5), - f(), - g(), - h() { -} +G04::G04() : ConstrainedTestProblem(5), f(), g(), h() {} -G04::~G04() { -} +G04::~G04() {} -TestScalarFunction& G04::getObjectiveFunction() { - return f; -} +TestScalarFunction& G04::getObjectiveFunction() { return f; } -TestVectorFunction& G04::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& G04::getInequalityConstraintFunction() { return g; } -TestVectorFunction& G04::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& G04::getEqualityConstraintFunction() { return h; } float_t G04::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(5); @@ -44,91 +32,56 @@ float_t G04::getOptimalPointUndisplaced(base::DataVector& x) { return -30665.54; } +G04Objective::G04Objective() : TestScalarFunction(5) {} +G04Objective::~G04Objective() {} -G04Objective::G04Objective() : - TestScalarFunction(5) { -} - -G04Objective::~G04Objective() { -} - -float_t G04Objective::evalUndisplaced( - const base::DataVector& x) { +float_t G04Objective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 24.0 * x[0] + 78.0; - //const float_t x2 = 12.0 * x[1] + 33.0; + // const float_t x2 = 12.0 * x[1] + 33.0; const float_t x3 = 18.0 * x[2] + 27.0; - //const float_t x4 = 18.0 * x[3] + 27.0; + // const float_t x4 = 18.0 * x[3] + 27.0; const float_t x5 = 18.0 * x[4] + 27.0; - return 5.3578547 * x3 * x3 + 0.8356891 * x1 * x5 + 37.293239 * x1 - - 40792.141; + return 5.3578547 * x3 * x3 + 0.8356891 * x1 * x5 + 37.293239 * x1 - 40792.141; } -void G04Objective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G04Objective(*this)); +void G04Objective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G04Objective(*this)); } +G04InequalityConstraint::G04InequalityConstraint() : TestVectorFunction(5, 6) {} +G04InequalityConstraint::~G04InequalityConstraint() {} -G04InequalityConstraint::G04InequalityConstraint() : - TestVectorFunction(5, 6) { -} - -G04InequalityConstraint::~G04InequalityConstraint() { -} - -void G04InequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void G04InequalityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) { const float_t x1 = 24.0 * x[0] + 78.0; const float_t x2 = 12.0 * x[1] + 33.0; const float_t x3 = 18.0 * x[2] + 27.0; const float_t x4 = 18.0 * x[3] + 27.0; const float_t x5 = 18.0 * x[4] + 27.0; - value[0] = 85.334407 + 0.0056858 * x2 * x5 + 0.0006262 * x1 * x4 - - 0.0022053 * x3 * x5 - 92.0; - value[1] = -85.334407 - 0.0056858 * x2 * x5 - 0.0006262 * x1 * x4 + - 0.0022053 * x3 * x5; - value[2] = 80.51249 + 0.0071317 * x2 * x5 + 0.0029955 * x1 * x2 + - 0.0021813 * x3 * x3 - 110.0; - value[3] = -80.51249 - 0.0071317 * x2 * x5 - 0.0029955 * x1 * x2 - - 0.0021813 * x3 * x3 + 90.0; - value[4] = 9.300961 + 0.0047026 * x3 * x5 + 0.0012547 * x1 * x3 + - 0.0019085 * x3 * x4 - 25.0; - value[5] = -9.300961 - 0.0047026 * x3 * x5 - 0.0012547 * x1 * x3 - - 0.0019085 * x3 * x4 + 20.0; + value[0] = 85.334407 + 0.0056858 * x2 * x5 + 0.0006262 * x1 * x4 - 0.0022053 * x3 * x5 - 92.0; + value[1] = -85.334407 - 0.0056858 * x2 * x5 - 0.0006262 * x1 * x4 + 0.0022053 * x3 * x5; + value[2] = 80.51249 + 0.0071317 * x2 * x5 + 0.0029955 * x1 * x2 + 0.0021813 * x3 * x3 - 110.0; + value[3] = -80.51249 - 0.0071317 * x2 * x5 - 0.0029955 * x1 * x2 - 0.0021813 * x3 * x3 + 90.0; + value[4] = 9.300961 + 0.0047026 * x3 * x5 + 0.0012547 * x1 * x3 + 0.0019085 * x3 * x4 - 25.0; + value[5] = -9.300961 - 0.0047026 * x3 * x5 - 0.0012547 * x1 * x3 - 0.0019085 * x3 * x4 + 20.0; } -void G04InequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G04InequalityConstraint(*this)); +void G04InequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G04InequalityConstraint(*this)); } +G04EqualityConstraint::G04EqualityConstraint() : TestVectorFunction(5, 0) {} +G04EqualityConstraint::~G04EqualityConstraint() {} -G04EqualityConstraint::G04EqualityConstraint() : - TestVectorFunction(5, 0) { -} - -G04EqualityConstraint::~G04EqualityConstraint() { -} +void G04EqualityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) {} -void G04EqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { -} - -void G04EqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G04EqualityConstraint(*this)); -} - -} -} +void G04EqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G04EqualityConstraint(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G04.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/G04.hpp index 0e6609648e..518cb3da50 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G04.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G04.hpp @@ -38,14 +38,12 @@ class G04Objective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -71,8 +69,7 @@ class G04Objective : public TestScalarFunction { * 20 * \end{pmatrix}\f] */ -class G04InequalityConstraint : - public TestVectorFunction { +class G04InequalityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -88,14 +85,12 @@ class G04InequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -103,8 +98,7 @@ class G04InequalityConstraint : * * Definition: empty, i.e., no constraint */ -class G04EqualityConstraint : - public TestVectorFunction { +class G04EqualityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -120,14 +114,12 @@ class G04EqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -176,8 +168,7 @@ class G04 : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -187,9 +178,8 @@ class G04 : public ConstrainedTestProblem { /// equality constraint function G04EqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_G04_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G05.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/G05.cpp index 8cb2d4565c..9826d168b0 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G05.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G05.cpp @@ -12,27 +12,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -G05::G05() : - ConstrainedTestProblem(4), - f(), - g(), - h() { -} +G05::G05() : ConstrainedTestProblem(4), f(), g(), h() {} -G05::~G05() { -} +G05::~G05() {} -TestScalarFunction& G05::getObjectiveFunction() { - return f; -} +TestScalarFunction& G05::getObjectiveFunction() { return f; } -TestVectorFunction& G05::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& G05::getInequalityConstraintFunction() { return g; } -TestVectorFunction& G05::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& G05::getEqualityConstraintFunction() { return h; } float_t G05::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(4); @@ -43,46 +31,30 @@ float_t G05::getOptimalPointUndisplaced(base::DataVector& x) { return 5126.4981; } +G05Objective::G05Objective() : TestScalarFunction(4) {} +G05Objective::~G05Objective() {} -G05Objective::G05Objective() : - TestScalarFunction(4) { -} - -G05Objective::~G05Objective() { -} - -float_t G05Objective::evalUndisplaced( - const base::DataVector& x) { +float_t G05Objective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 1200.0 * x[0]; const float_t x2 = 1200.0 * x[1]; - //const float_t x3 = 1.1 * x[2] - 0.55; - //const float_t x4 = 1.1 * x[3] - 0.55; + // const float_t x3 = 1.1 * x[2] - 0.55; + // const float_t x4 = 1.1 * x[3] - 0.55; - return 3.0 * x1 + 0.000001 * std::pow(x1, 3.0) + 2.0 * x2 + - (0.000002 / 3.0) * std::pow(x2, 3.0); + return 3.0 * x1 + 0.000001 * std::pow(x1, 3.0) + 2.0 * x2 + (0.000002 / 3.0) * std::pow(x2, 3.0); } -void G05Objective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G05Objective(*this)); +void G05Objective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G05Objective(*this)); } +G05InequalityConstraint::G05InequalityConstraint() : TestVectorFunction(4, 2) {} +G05InequalityConstraint::~G05InequalityConstraint() {} -G05InequalityConstraint::G05InequalityConstraint() : - TestVectorFunction(4, 2) { -} - -G05InequalityConstraint::~G05InequalityConstraint() { -} - -void G05InequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { - //const float_t x1 = 1200.0 * x[0]; - //const float_t x2 = 1200.0 * x[1]; +void G05InequalityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) { + // const float_t x1 = 1200.0 * x[0]; + // const float_t x2 = 1200.0 * x[1]; const float_t x3 = 1.1 * x[2] - 0.55; const float_t x4 = 1.1 * x[3] - 0.55; @@ -90,43 +62,28 @@ void G05InequalityConstraint::evalUndisplaced( value[1] = -x3 + x4 - 0.55; } -void G05InequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G05InequalityConstraint(*this)); +void G05InequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G05InequalityConstraint(*this)); } +G05EqualityConstraint::G05EqualityConstraint() : TestVectorFunction(4, 3) {} +G05EqualityConstraint::~G05EqualityConstraint() {} -G05EqualityConstraint::G05EqualityConstraint() : - TestVectorFunction(4, 3) { -} - -G05EqualityConstraint::~G05EqualityConstraint() { -} - -void G05EqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void G05EqualityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) { const float_t x1 = 1200.0 * x[0]; const float_t x2 = 1200.0 * x[1]; const float_t x3 = 1.1 * x[2] - 0.55; const float_t x4 = 1.1 * x[3] - 0.55; - value[0] = 1000.0 * std::sin(-x3 - 0.25) + - 1000.0 * std::sin(-x4 - 0.25) + 894.8 - x1; - value[1] = 1000.0 * std::sin(x3 - 0.25) + - 1000.0 * std::sin(x3 - x4 - 0.25) + 894.8 - x2; - value[2] = 1000.0 * std::sin(x4 - 0.25) + - 1000.0 * std::sin(x4 - x3 - 0.25) + 1294.8; -} - -void G05EqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G05EqualityConstraint(*this)); + value[0] = 1000.0 * std::sin(-x3 - 0.25) + 1000.0 * std::sin(-x4 - 0.25) + 894.8 - x1; + value[1] = 1000.0 * std::sin(x3 - 0.25) + 1000.0 * std::sin(x3 - x4 - 0.25) + 894.8 - x2; + value[2] = 1000.0 * std::sin(x4 - 0.25) + 1000.0 * std::sin(x4 - x3 - 0.25) + 1294.8; } +void G05EqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G05EqualityConstraint(*this)); } -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G05.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/G05.hpp index ff25c9aff6..1248fedac5 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G05.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G05.hpp @@ -38,14 +38,12 @@ class G05Objective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -58,8 +56,7 @@ class G05Objective : public TestScalarFunction { * -\bar{x}_3 + \bar{x}_4 - 11/20 * \end{pmatrix}\f] */ -class G05InequalityConstraint : - public TestVectorFunction { +class G05InequalityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -75,14 +72,12 @@ class G05InequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -102,8 +97,7 @@ class G05InequalityConstraint : * 1294.8 * \end{pmatrix}\f] */ -class G05EqualityConstraint : - public TestVectorFunction { +class G05EqualityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -119,14 +113,12 @@ class G05EqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -174,8 +166,7 @@ class G05 : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -185,9 +176,8 @@ class G05 : public ConstrainedTestProblem { /// equality constraint function G05EqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_G05_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G06.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/G06.cpp index 9a6b6f63c4..6e6de0a468 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G06.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G06.cpp @@ -12,27 +12,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -G06::G06() : - ConstrainedTestProblem(2), - f(), - g(), - h() { -} +G06::G06() : ConstrainedTestProblem(2), f(), g(), h() {} -G06::~G06() { -} +G06::~G06() {} -TestScalarFunction& G06::getObjectiveFunction() { - return f; -} +TestScalarFunction& G06::getObjectiveFunction() { return f; } -TestVectorFunction& G06::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& G06::getInequalityConstraintFunction() { return g; } -TestVectorFunction& G06::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& G06::getEqualityConstraintFunction() { return h; } float_t G06::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -41,42 +29,26 @@ float_t G06::getOptimalPointUndisplaced(base::DataVector& x) { return -6961.81387558014; } +G06Objective::G06Objective() : TestScalarFunction(2) {} +G06Objective::~G06Objective() {} -G06Objective::G06Objective() : - TestScalarFunction(2) { -} - -G06Objective::~G06Objective() { -} - -float_t G06Objective::evalUndisplaced( - const base::DataVector& x) { +float_t G06Objective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 87.0 * x[0] + 13.0; const float_t x2 = 100.0 * x[1]; - return 3.0 * x1 + 0.000001 * std::pow(x1, 3.0) + 2.0 * x2 + - (0.000002 / 3.0) * std::pow(x2, 3.0); + return 3.0 * x1 + 0.000001 * std::pow(x1, 3.0) + 2.0 * x2 + (0.000002 / 3.0) * std::pow(x2, 3.0); } -void G06Objective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G06Objective(*this)); +void G06Objective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G06Objective(*this)); } +G06InequalityConstraint::G06InequalityConstraint() : TestVectorFunction(2, 2) {} +G06InequalityConstraint::~G06InequalityConstraint() {} -G06InequalityConstraint::G06InequalityConstraint() : - TestVectorFunction(2, 2) { -} - -G06InequalityConstraint::~G06InequalityConstraint() { -} - -void G06InequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void G06InequalityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) { const float_t x1 = 87.0 * x[0] + 13.0; const float_t x2 = 100.0 * x[1]; @@ -84,32 +56,19 @@ void G06InequalityConstraint::evalUndisplaced( value[1] = std::pow(x1 - 6.0, 2.0) + std::pow(x2 - 5.0, 2.0) - 82.81; } -void G06InequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G06InequalityConstraint(*this)); +void G06InequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G06InequalityConstraint(*this)); } +G06EqualityConstraint::G06EqualityConstraint() : TestVectorFunction(2, 0) {} +G06EqualityConstraint::~G06EqualityConstraint() {} -G06EqualityConstraint::G06EqualityConstraint() : - TestVectorFunction(2, 0) { -} - -G06EqualityConstraint::~G06EqualityConstraint() { -} +void G06EqualityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) {} -void G06EqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { -} - -void G06EqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G06EqualityConstraint(*this)); -} - -} -} +void G06EqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G06EqualityConstraint(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G06.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/G06.hpp index 6e6aee3ea2..ae9280b327 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G06.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G06.hpp @@ -37,14 +37,12 @@ class G06Objective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -57,8 +55,7 @@ class G06Objective : public TestScalarFunction { * (\bar{x}_1 - 6)^2 + (\bar{x}_2 - 5)^2 - 82.81 * \end{pmatrix}\f] */ -class G06InequalityConstraint : - public TestVectorFunction { +class G06InequalityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -74,14 +71,12 @@ class G06InequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -89,8 +84,7 @@ class G06InequalityConstraint : * * Definition: empty, i.e., no constraint */ -class G06EqualityConstraint : - public TestVectorFunction { +class G06EqualityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -106,14 +100,12 @@ class G06EqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -161,8 +153,7 @@ class G06 : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -172,9 +163,8 @@ class G06 : public ConstrainedTestProblem { /// equality constraint function G06EqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_G06_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G08.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/G08.cpp index 25bafc21d2..f3ad6f1638 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G08.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G08.cpp @@ -12,27 +12,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -G08::G08() : - ConstrainedTestProblem(2), - f(), - g(), - h() { -} +G08::G08() : ConstrainedTestProblem(2), f(), g(), h() {} -G08::~G08() { -} +G08::~G08() {} -TestScalarFunction& G08::getObjectiveFunction() { - return f; -} +TestScalarFunction& G08::getObjectiveFunction() { return f; } -TestVectorFunction& G08::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& G08::getInequalityConstraintFunction() { return g; } -TestVectorFunction& G08::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& G08::getEqualityConstraintFunction() { return h; } float_t G08::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -41,42 +29,27 @@ float_t G08::getOptimalPointUndisplaced(base::DataVector& x) { return -0.095825; } +G08Objective::G08Objective() : TestScalarFunction(2) {} +G08Objective::~G08Objective() {} -G08Objective::G08Objective() : - TestScalarFunction(2) { -} - -G08Objective::~G08Objective() { -} - -float_t G08Objective::evalUndisplaced( - const base::DataVector& x) { +float_t G08Objective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 10.0 * x[0]; const float_t x2 = 10.0 * x[1]; - return -std::pow(std::sin(2.0 * M_PI * x1), 3.0) * - std::sin(2.0 * M_PI * x2) / (x1 * x1 * x1 * (x1 + x2)); + return -std::pow(std::sin(2.0 * M_PI * x1), 3.0) * std::sin(2.0 * M_PI * x2) / + (x1 * x1 * x1 * (x1 + x2)); } -void G08Objective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G08Objective(*this)); +void G08Objective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G08Objective(*this)); } +G08InequalityConstraint::G08InequalityConstraint() : TestVectorFunction(2, 2) {} +G08InequalityConstraint::~G08InequalityConstraint() {} -G08InequalityConstraint::G08InequalityConstraint() : - TestVectorFunction(2, 2) { -} - -G08InequalityConstraint::~G08InequalityConstraint() { -} - -void G08InequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void G08InequalityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) { const float_t x1 = 10.0 * x[0]; const float_t x2 = 10.0 * x[1]; @@ -84,32 +57,19 @@ void G08InequalityConstraint::evalUndisplaced( value[1] = 1.0 - x1 + std::pow(x2 - 4.0, 2.0); } -void G08InequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G08InequalityConstraint(*this)); +void G08InequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G08InequalityConstraint(*this)); } +G08EqualityConstraint::G08EqualityConstraint() : TestVectorFunction(2, 0) {} +G08EqualityConstraint::~G08EqualityConstraint() {} -G08EqualityConstraint::G08EqualityConstraint() : - TestVectorFunction(2, 0) { -} - -G08EqualityConstraint::~G08EqualityConstraint() { -} +void G08EqualityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) {} -void G08EqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { -} - -void G08EqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G08EqualityConstraint(*this)); -} - -} -} +void G08EqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G08EqualityConstraint(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G08.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/G08.hpp index 29068e5c4b..a0a901b713 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G08.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G08.hpp @@ -38,14 +38,12 @@ class G08Objective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -58,8 +56,7 @@ class G08Objective : public TestScalarFunction { * 1 - \bar{x}_1 + (\bar{x}_2 - 4)^2 * \end{pmatrix}\f] */ -class G08InequalityConstraint : - public TestVectorFunction { +class G08InequalityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -75,14 +72,12 @@ class G08InequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -90,8 +85,7 @@ class G08InequalityConstraint : * * Definition: empty, i.e., no constraint */ -class G08EqualityConstraint : - public TestVectorFunction { +class G08EqualityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -107,14 +101,12 @@ class G08EqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -162,8 +154,7 @@ class G08 : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -173,9 +164,8 @@ class G08 : public ConstrainedTestProblem { /// equality constraint function G08EqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_G08_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G09.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/G09.cpp index 22e51822de..e9397fa5d2 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G09.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G09.cpp @@ -12,27 +12,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -G09::G09() : - ConstrainedTestProblem(7), - f(), - g(), - h() { -} +G09::G09() : ConstrainedTestProblem(7), f(), g(), h() {} -G09::~G09() { -} +G09::~G09() {} -TestScalarFunction& G09::getObjectiveFunction() { - return f; -} +TestScalarFunction& G09::getObjectiveFunction() { return f; } -TestVectorFunction& G09::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& G09::getInequalityConstraintFunction() { return g; } -TestVectorFunction& G09::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& G09::getEqualityConstraintFunction() { return h; } float_t G09::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(7); @@ -46,17 +34,11 @@ float_t G09::getOptimalPointUndisplaced(base::DataVector& x) { return 680.6300573; } +G09Objective::G09Objective() : TestScalarFunction(7) {} +G09Objective::~G09Objective() {} -G09Objective::G09Objective() : - TestScalarFunction(7) { -} - -G09Objective::~G09Objective() { -} - -float_t G09Objective::evalUndisplaced( - const base::DataVector& x) { +float_t G09Objective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 20.0 * x[0] - 10.0; const float_t x2 = 20.0 * x[1] - 10.0; const float_t x3 = 20.0 * x[2] - 10.0; @@ -65,30 +47,20 @@ float_t G09Objective::evalUndisplaced( const float_t x6 = 20.0 * x[5] - 10.0; const float_t x7 = 20.0 * x[6] - 10.0; - return std::pow(x1 - 10.0, 2.0) + 5.0 * std::pow(x2 - 12.0, 2.0) + - std::pow(x3, 4.0) + 3.0 * std::pow(x4 - 11.0, 2.0) + - 10.0 * std::pow(x5, 6.0) + 7.0 * x6 * x6 + std::pow(x7, 4.0) - - 4.0 * x6 * x7 - 10.0 * x6 - 8.0 * x7; + return std::pow(x1 - 10.0, 2.0) + 5.0 * std::pow(x2 - 12.0, 2.0) + std::pow(x3, 4.0) + + 3.0 * std::pow(x4 - 11.0, 2.0) + 10.0 * std::pow(x5, 6.0) + 7.0 * x6 * x6 + + std::pow(x7, 4.0) - 4.0 * x6 * x7 - 10.0 * x6 - 8.0 * x7; } -void G09Objective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G09Objective(*this)); +void G09Objective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G09Objective(*this)); } +G09InequalityConstraint::G09InequalityConstraint() : TestVectorFunction(7, 4) {} +G09InequalityConstraint::~G09InequalityConstraint() {} -G09InequalityConstraint::G09InequalityConstraint() : - TestVectorFunction(7, 4) { -} - -G09InequalityConstraint::~G09InequalityConstraint() { -} - -void G09InequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void G09InequalityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) { const float_t x1 = 20.0 * x[0] - 10.0; const float_t x2 = 20.0 * x[1] - 10.0; const float_t x3 = 20.0 * x[2] - 10.0; @@ -97,40 +69,25 @@ void G09InequalityConstraint::evalUndisplaced( const float_t x6 = 20.0 * x[5] - 10.0; const float_t x7 = 20.0 * x[6] - 10.0; - value[0] = -127.0 + 2.0 * x1 * x1 + 3.0 * std::pow(x2, 4.0) + x3 + - 4.0 * x4 * x4 + 5.0 * x5; + value[0] = -127.0 + 2.0 * x1 * x1 + 3.0 * std::pow(x2, 4.0) + x3 + 4.0 * x4 * x4 + 5.0 * x5; value[1] = -282.0 + 7.0 * x1 + 3.0 * x2 + 10.0 * x3 * x3 + x4 - x5; value[2] = -196.0 + 23.0 * x1 + x2 * x2 + 6.0 * x6 * x6 - 8.0 * x7; - value[3] = 4.0 * x1 * x1 + x2 * x2 - 3.0 * x1 * x2 + 2.0 * x3 * x3 + - 5.0 * x6 - 11.0 * x7; + value[3] = 4.0 * x1 * x1 + x2 * x2 - 3.0 * x1 * x2 + 2.0 * x3 * x3 + 5.0 * x6 - 11.0 * x7; } -void G09InequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G09InequalityConstraint(*this)); +void G09InequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G09InequalityConstraint(*this)); } +G09EqualityConstraint::G09EqualityConstraint() : TestVectorFunction(7, 0) {} +G09EqualityConstraint::~G09EqualityConstraint() {} -G09EqualityConstraint::G09EqualityConstraint() : - TestVectorFunction(7, 0) { -} - -G09EqualityConstraint::~G09EqualityConstraint() { -} +void G09EqualityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) {} -void G09EqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { -} - -void G09EqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G09EqualityConstraint(*this)); -} - -} -} +void G09EqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G09EqualityConstraint(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G09.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/G09.hpp index 833b56b9da..44db5793b6 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G09.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G09.hpp @@ -39,14 +39,12 @@ class G09Objective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -65,8 +63,7 @@ class G09Objective : public TestScalarFunction { * 2 \bar{x}_3^2 + 5 \bar{x}_6 - 11 \bar{x}_7 * \end{pmatrix}\f] */ -class G09InequalityConstraint : - public TestVectorFunction { +class G09InequalityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -82,14 +79,12 @@ class G09InequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -97,8 +92,7 @@ class G09InequalityConstraint : * * Definition: empty, i.e., no constraint */ -class G09EqualityConstraint : - public TestVectorFunction { +class G09EqualityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -114,14 +108,12 @@ class G09EqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -169,8 +161,7 @@ class G09 : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -180,9 +171,8 @@ class G09 : public ConstrainedTestProblem { /// equality constraint function G09EqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_G09_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G10.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/G10.cpp index 355ea2899e..c4a28ee58c 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G10.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G10.cpp @@ -12,27 +12,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -G10::G10() : - ConstrainedTestProblem(8), - f(), - g(), - h() { -} +G10::G10() : ConstrainedTestProblem(8), f(), g(), h() {} -G10::~G10() { -} +G10::~G10() {} -TestScalarFunction& G10::getObjectiveFunction() { - return f; -} +TestScalarFunction& G10::getObjectiveFunction() { return f; } -TestVectorFunction& G10::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& G10::getInequalityConstraintFunction() { return g; } -TestVectorFunction& G10::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& G10::getEqualityConstraintFunction() { return h; } float_t G10::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(8); @@ -47,47 +35,32 @@ float_t G10::getOptimalPointUndisplaced(base::DataVector& x) { return 7049.3307; } +G10Objective::G10Objective() : TestScalarFunction(8) {} +G10Objective::~G10Objective() {} -G10Objective::G10Objective() : - TestScalarFunction(8) { -} - -G10Objective::~G10Objective() { -} - -float_t G10Objective::evalUndisplaced( - const base::DataVector& x) { +float_t G10Objective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 9900.0 * x[0] + 100.0; const float_t x2 = 9000.0 * x[1] + 1000.0; const float_t x3 = 9000.0 * x[2] + 1000.0; - //const float_t x4 = 990.0 * x[3] + 10.0; - //const float_t x5 = 990.0 * x[4] + 10.0; - //const float_t x6 = 990.0 * x[5] + 10.0; - //const float_t x7 = 990.0 * x[6] + 10.0; - //const float_t x8 = 990.0 * x[7] + 10.0; + // const float_t x4 = 990.0 * x[3] + 10.0; + // const float_t x5 = 990.0 * x[4] + 10.0; + // const float_t x6 = 990.0 * x[5] + 10.0; + // const float_t x7 = 990.0 * x[6] + 10.0; + // const float_t x8 = 990.0 * x[7] + 10.0; return x1 + x2 + x3; } -void G10Objective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G10Objective(*this)); +void G10Objective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G10Objective(*this)); } +G10InequalityConstraint::G10InequalityConstraint() : TestVectorFunction(8, 6) {} +G10InequalityConstraint::~G10InequalityConstraint() {} -G10InequalityConstraint::G10InequalityConstraint() : - TestVectorFunction(8, 6) { -} - -G10InequalityConstraint::~G10InequalityConstraint() { -} - -void G10InequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void G10InequalityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) { const float_t x1 = 9900.0 * x[0] + 100.0; const float_t x2 = 9000.0 * x[1] + 1000.0; const float_t x3 = 9000.0 * x[2] + 1000.0; @@ -105,32 +78,19 @@ void G10InequalityConstraint::evalUndisplaced( value[5] = -x3 * x8 + 1250000.0 + x3 * x5 - 2500.0 * x5; } -void G10InequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G10InequalityConstraint(*this)); +void G10InequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G10InequalityConstraint(*this)); } +G10EqualityConstraint::G10EqualityConstraint() : TestVectorFunction(8, 0) {} +G10EqualityConstraint::~G10EqualityConstraint() {} -G10EqualityConstraint::G10EqualityConstraint() : - TestVectorFunction(8, 0) { -} - -G10EqualityConstraint::~G10EqualityConstraint() { -} +void G10EqualityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) {} -void G10EqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { -} - -void G10EqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G10EqualityConstraint(*this)); -} - -} -} +void G10EqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G10EqualityConstraint(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G10.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/G10.hpp index 95a7dc0ba0..02df702b49 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G10.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G10.hpp @@ -37,14 +37,12 @@ class G10Objective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -64,8 +62,7 @@ class G10Objective : public TestScalarFunction { * 2500 \bar{x}_5 * \end{pmatrix}\f] */ -class G10InequalityConstraint : - public TestVectorFunction { +class G10InequalityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -81,14 +78,12 @@ class G10InequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -96,8 +91,7 @@ class G10InequalityConstraint : * * Definition: empty, i.e., no constraint */ -class G10EqualityConstraint : - public TestVectorFunction { +class G10EqualityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -113,14 +107,12 @@ class G10EqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -170,8 +162,7 @@ class G10 : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -181,9 +172,8 @@ class G10 : public ConstrainedTestProblem { /// equality constraint function G10EqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_G10_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G11.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/G11.cpp index bddfc99474..650d2bb793 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G11.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G11.cpp @@ -12,27 +12,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -G11::G11() : - ConstrainedTestProblem(2), - f(), - g(), - h() { -} +G11::G11() : ConstrainedTestProblem(2), f(), g(), h() {} -G11::~G11() { -} +G11::~G11() {} -TestScalarFunction& G11::getObjectiveFunction() { - return f; -} +TestScalarFunction& G11::getObjectiveFunction() { return f; } -TestVectorFunction& G11::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& G11::getInequalityConstraintFunction() { return g; } -TestVectorFunction& G11::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& G11::getEqualityConstraintFunction() { return h; } float_t G11::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -41,73 +29,45 @@ float_t G11::getOptimalPointUndisplaced(base::DataVector& x) { return 0.75; } +G11Objective::G11Objective() : TestScalarFunction(2) {} +G11Objective::~G11Objective() {} -G11Objective::G11Objective() : - TestScalarFunction(2) { -} - -G11Objective::~G11Objective() { -} - -float_t G11Objective::evalUndisplaced( - const base::DataVector& x) { +float_t G11Objective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 2.0 * x[0] - 1.0; const float_t x2 = 2.0 * x[1] - 1.0; return x1 * x1 + std::pow(x2 - 1.0, 2.0); } -void G11Objective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G11Objective(*this)); +void G11Objective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G11Objective(*this)); } +G11InequalityConstraint::G11InequalityConstraint() : TestVectorFunction(2, 0) {} +G11InequalityConstraint::~G11InequalityConstraint() {} -G11InequalityConstraint::G11InequalityConstraint() : - TestVectorFunction(2, 0) { -} - -G11InequalityConstraint::~G11InequalityConstraint() { -} - -void G11InequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { -} +void G11InequalityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) {} -void G11InequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G11InequalityConstraint(*this)); +void G11InequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G11InequalityConstraint(*this)); } +G11EqualityConstraint::G11EqualityConstraint() : TestVectorFunction(2, 1) {} +G11EqualityConstraint::~G11EqualityConstraint() {} -G11EqualityConstraint::G11EqualityConstraint() : - TestVectorFunction(2, 1) { -} - -G11EqualityConstraint::~G11EqualityConstraint() { -} - -void G11EqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void G11EqualityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) { const float_t x1 = 2.0 * x[0] - 1.0; const float_t x2 = 2.0 * x[1] - 1.0; value[0] = x2 - x1 * x1; } -void G11EqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G11EqualityConstraint(*this)); -} - -} -} +void G11EqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G11EqualityConstraint(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G11.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/G11.hpp index b8ed8522e0..6c309ddafa 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G11.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G11.hpp @@ -37,14 +37,12 @@ class G11Objective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -52,8 +50,7 @@ class G11Objective : public TestScalarFunction { * * Definition: empty, i.e., no constraint */ -class G11InequalityConstraint : - public TestVectorFunction { +class G11InequalityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -69,14 +66,12 @@ class G11InequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -86,8 +81,7 @@ class G11InequalityConstraint : * \f[\bar{h}(\bar{\vec{x}}) := * \bar{x}_2 - \bar{x}_1^2\f] */ -class G11EqualityConstraint : - public TestVectorFunction { +class G11EqualityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -103,14 +97,12 @@ class G11EqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -158,8 +150,7 @@ class G11 : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -169,9 +160,8 @@ class G11 : public ConstrainedTestProblem { /// equality constraint function G11EqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_G11_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G12.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/G12.cpp index d3df98367b..d0e0f6c498 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G12.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G12.cpp @@ -12,27 +12,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -G12::G12() : - ConstrainedTestProblem(3), - f(), - g(), - h() { -} +G12::G12() : ConstrainedTestProblem(3), f(), g(), h() {} -G12::~G12() { -} +G12::~G12() {} -TestScalarFunction& G12::getObjectiveFunction() { - return f; -} +TestScalarFunction& G12::getObjectiveFunction() { return f; } -TestVectorFunction& G12::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& G12::getInequalityConstraintFunction() { return g; } -TestVectorFunction& G12::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& G12::getEqualityConstraintFunction() { return h; } float_t G12::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(3); @@ -40,43 +28,28 @@ float_t G12::getOptimalPointUndisplaced(base::DataVector& x) { return -1; } +G12Objective::G12Objective() : TestScalarFunction(3) {} +G12Objective::~G12Objective() {} -G12Objective::G12Objective() : - TestScalarFunction(3) { -} - -G12Objective::~G12Objective() { -} - -float_t G12Objective::evalUndisplaced( - const base::DataVector& x) { +float_t G12Objective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 10.0 * x[0]; const float_t x2 = 10.0 * x[1]; const float_t x3 = 10.0 * x[2]; - return (std::pow(x1 - 5.0, 2.0) + std::pow(x2 - 5.0, 2.0) + - std::pow(x3 - 5.0, 2.0)) / 100.0 - 1.0; + return (std::pow(x1 - 5.0, 2.0) + std::pow(x2 - 5.0, 2.0) + std::pow(x3 - 5.0, 2.0)) / 100.0 - + 1.0; } -void G12Objective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G12Objective(*this)); +void G12Objective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G12Objective(*this)); } +G12InequalityConstraint::G12InequalityConstraint() : TestVectorFunction(3, 1) {} +G12InequalityConstraint::~G12InequalityConstraint() {} -G12InequalityConstraint::G12InequalityConstraint() : - TestVectorFunction(3, 1) { -} - -G12InequalityConstraint::~G12InequalityConstraint() { -} - -void G12InequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void G12InequalityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) { const float_t x1 = 10.0 * x[0]; const float_t x2 = 10.0 * x[1]; const float_t x3 = 10.0 * x[2]; @@ -85,8 +58,8 @@ void G12InequalityConstraint::evalUndisplaced( for (float_t y1 = 1.0; y1 <= 9.0; y1++) { for (float_t y2 = 1.0; y2 <= 9.0; y2++) { for (float_t y3 = 1.0; y3 <= 9.0; y3++) { - const float_t tmp = std::pow(x1 - y1, 2.0) + - std::pow(x2 - y2, 2.0) + std::pow(x3 - y3, 2.0) - 0.0625; + const float_t tmp = + std::pow(x1 - y1, 2.0) + std::pow(x2 - y2, 2.0) + std::pow(x3 - y3, 2.0) - 0.0625; if (tmp < result) { result = tmp; @@ -98,32 +71,19 @@ void G12InequalityConstraint::evalUndisplaced( value[0] = result; } -void G12InequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G12InequalityConstraint(*this)); +void G12InequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G12InequalityConstraint(*this)); } +G12EqualityConstraint::G12EqualityConstraint() : TestVectorFunction(3, 0) {} +G12EqualityConstraint::~G12EqualityConstraint() {} -G12EqualityConstraint::G12EqualityConstraint() : - TestVectorFunction(3, 0) { -} - -G12EqualityConstraint::~G12EqualityConstraint() { -} +void G12EqualityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) {} -void G12EqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { -} - -void G12EqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G12EqualityConstraint(*this)); -} - -} -} +void G12EqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G12EqualityConstraint(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G12.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/G12.hpp index 8fe30830d8..e2e36dffe7 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G12.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G12.hpp @@ -37,14 +37,12 @@ class G12Objective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -55,8 +53,7 @@ class G12Objective : public TestScalarFunction { * \min_{y_1,y_2,y_3 = 1,\dotsc,9} * \norm{\bar{\vec{x}} - \vec{y}}_2^2 - 1/16\f] */ -class G12InequalityConstraint : - public TestVectorFunction { +class G12InequalityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -72,14 +69,12 @@ class G12InequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -87,8 +82,7 @@ class G12InequalityConstraint : * * Definition: empty, i.e., no constraint */ -class G12EqualityConstraint : - public TestVectorFunction { +class G12EqualityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -104,14 +98,12 @@ class G12EqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -159,8 +151,7 @@ class G12 : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -170,9 +161,8 @@ class G12 : public ConstrainedTestProblem { /// equality constraint function G12EqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_G12_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G13.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/G13.cpp index 5df2fc80b3..840549c91d 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G13.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G13.cpp @@ -12,27 +12,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -G13::G13() : - ConstrainedTestProblem(5), - f(), - g(), - h() { -} +G13::G13() : ConstrainedTestProblem(5), f(), g(), h() {} -G13::~G13() { -} +G13::~G13() {} -TestScalarFunction& G13::getObjectiveFunction() { - return f; -} +TestScalarFunction& G13::getObjectiveFunction() { return f; } -TestVectorFunction& G13::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& G13::getInequalityConstraintFunction() { return g; } -TestVectorFunction& G13::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& G13::getEqualityConstraintFunction() { return h; } float_t G13::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(5); @@ -44,17 +32,11 @@ float_t G13::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0539498; } +G13Objective::G13Objective() : TestScalarFunction(5) {} +G13Objective::~G13Objective() {} -G13Objective::G13Objective() : - TestScalarFunction(5) { -} - -G13Objective::~G13Objective() { -} - -float_t G13Objective::evalUndisplaced( - const base::DataVector& x) { +float_t G13Objective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 4.6 * x[0] - 2.3; const float_t x2 = 4.6 * x[1] - 2.3; const float_t x3 = 6.4 * x[2] - 3.2; @@ -64,44 +46,25 @@ float_t G13Objective::evalUndisplaced( return std::exp(x1 * x2 * x3 * x4 * x5); } -void G13Objective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G13Objective(*this)); +void G13Objective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G13Objective(*this)); } +G13InequalityConstraint::G13InequalityConstraint() : TestVectorFunction(5, 0) {} +G13InequalityConstraint::~G13InequalityConstraint() {} -G13InequalityConstraint::G13InequalityConstraint() : - TestVectorFunction(5, 0) { -} - -G13InequalityConstraint::~G13InequalityConstraint() { -} - -void G13InequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { -} +void G13InequalityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) {} -void G13InequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G13InequalityConstraint(*this)); +void G13InequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G13InequalityConstraint(*this)); } +G13EqualityConstraint::G13EqualityConstraint() : TestVectorFunction(5, 3) {} +G13EqualityConstraint::~G13EqualityConstraint() {} -G13EqualityConstraint::G13EqualityConstraint() : - TestVectorFunction(5, 3) { -} - -G13EqualityConstraint::~G13EqualityConstraint() { -} - -void G13EqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void G13EqualityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) { const float_t x1 = 4.6 * x[0] - 2.3; const float_t x2 = 4.6 * x[1] - 2.3; const float_t x3 = 6.4 * x[2] - 3.2; @@ -113,12 +76,9 @@ void G13EqualityConstraint::evalUndisplaced( value[2] = x1 * x1 * x1 + x2 * x2 * x2 + 1.0; } -void G13EqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new G13EqualityConstraint(*this)); -} - -} -} +void G13EqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new G13EqualityConstraint(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/G13.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/G13.hpp index 4ffbd93938..6b05c9e982 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/G13.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/G13.hpp @@ -37,14 +37,12 @@ class G13Objective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -52,8 +50,7 @@ class G13Objective : public TestScalarFunction { * * Definition: empty, i.e., no constraint */ -class G13InequalityConstraint : - public TestVectorFunction { +class G13InequalityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -69,14 +66,12 @@ class G13InequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -90,8 +85,7 @@ class G13InequalityConstraint : * \bar{x}_1^3 + \bar{x}_2^3 + 1 * \end{pmatrix}\f] */ -class G13EqualityConstraint : - public TestVectorFunction { +class G13EqualityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -107,14 +101,12 @@ class G13EqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -162,8 +154,7 @@ class G13 : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -173,9 +164,8 @@ class G13 : public ConstrainedTestProblem { /// equality constraint function G13EqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_G13_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/Simionescu.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/Simionescu.cpp index 784ed685c1..ffe5bf3c12 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/Simionescu.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/Simionescu.cpp @@ -12,27 +12,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -Simionescu::Simionescu() : - ConstrainedTestProblem(2), - f(), - g(), - h() { -} +Simionescu::Simionescu() : ConstrainedTestProblem(2), f(), g(), h() {} -Simionescu::~Simionescu() { -} +Simionescu::~Simionescu() {} -TestScalarFunction& Simionescu::getObjectiveFunction() { - return f; -} +TestScalarFunction& Simionescu::getObjectiveFunction() { return f; } -TestVectorFunction& Simionescu::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& Simionescu::getInequalityConstraintFunction() { return g; } -TestVectorFunction& Simionescu::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& Simionescu::getEqualityConstraintFunction() { return h; } float_t Simionescu::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -41,40 +29,26 @@ float_t Simionescu::getOptimalPointUndisplaced(base::DataVector& x) { return -0.072; } +SimionescuObjective::SimionescuObjective() : TestScalarFunction(2) {} +SimionescuObjective::~SimionescuObjective() {} -SimionescuObjective::SimionescuObjective() : - TestScalarFunction(2) { -} - -SimionescuObjective::~SimionescuObjective() { -} - -float_t SimionescuObjective::evalUndisplaced( - const base::DataVector& x) { +float_t SimionescuObjective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 2.5 * x[0] - 1.25; const float_t x2 = 2.5 * x[1] - 1.25; return 0.1 * x1 * x2; } -void SimionescuObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new SimionescuObjective(*this)); +void SimionescuObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new SimionescuObjective(*this)); } +SimionescuInequalityConstraint::SimionescuInequalityConstraint() : TestVectorFunction(2, 1) {} +SimionescuInequalityConstraint::~SimionescuInequalityConstraint() {} -SimionescuInequalityConstraint::SimionescuInequalityConstraint() : - TestVectorFunction(2, 1) { -} - -SimionescuInequalityConstraint::~SimionescuInequalityConstraint() { -} - -void SimionescuInequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void SimionescuInequalityConstraint::evalUndisplaced(const base::DataVector& x, + base::DataVector& value) { const float_t rT = 1; const float_t rS = 0.2; const float_t n = 8.0; @@ -85,32 +59,20 @@ void SimionescuInequalityConstraint::evalUndisplaced( value[0] = x1 * x1 + x2 * x2 - tmp * tmp; } -void SimionescuInequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new SimionescuInequalityConstraint(*this)); +void SimionescuInequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new SimionescuInequalityConstraint(*this)); } +SimionescuEqualityConstraint::SimionescuEqualityConstraint() : TestVectorFunction(2, 0) {} +SimionescuEqualityConstraint::~SimionescuEqualityConstraint() {} -SimionescuEqualityConstraint::SimionescuEqualityConstraint() : - TestVectorFunction(2, 0) { -} - -SimionescuEqualityConstraint::~SimionescuEqualityConstraint() { -} +void SimionescuEqualityConstraint::evalUndisplaced(const base::DataVector& x, + base::DataVector& value) {} -void SimionescuEqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { -} - -void SimionescuEqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new SimionescuEqualityConstraint(*this)); -} - -} -} +void SimionescuEqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new SimionescuEqualityConstraint(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/Simionescu.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/Simionescu.hpp index 34fc2a1564..e569a987d5 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/Simionescu.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/Simionescu.hpp @@ -37,14 +37,12 @@ class SimionescuObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -55,8 +53,7 @@ class SimionescuObjective : public TestScalarFunction { * \bar{x}_1^2 + \bar{x}_2^2 - \left(1 + \frac{1}{5} * \cos\!\Big(8 \arctan(\bar{x}_1/\bar{x}_2)\Big)\right)\f] */ -class SimionescuInequalityConstraint : - public TestVectorFunction { +class SimionescuInequalityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -72,14 +69,12 @@ class SimionescuInequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -87,8 +82,7 @@ class SimionescuInequalityConstraint : * * Definition: empty, i.e., no constraint */ -class SimionescuEqualityConstraint : - public TestVectorFunction { +class SimionescuEqualityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -104,14 +98,12 @@ class SimionescuEqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -159,8 +151,7 @@ class Simionescu : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -170,9 +161,8 @@ class Simionescu : public ConstrainedTestProblem { /// equality constraint function SimionescuEqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_SIMIONESCU_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/Soland.cpp b/optimization/src/sgpp/optimization/test_problems/constrained/Soland.cpp index a8e19abfe1..05dd77b945 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/Soland.cpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/Soland.cpp @@ -13,27 +13,15 @@ namespace SGPP { namespace optimization { namespace test_problems { -Soland::Soland() : - ConstrainedTestProblem(2), - f(), - g(), - h() { -} +Soland::Soland() : ConstrainedTestProblem(2), f(), g(), h() {} -Soland::~Soland() { -} +Soland::~Soland() {} -TestScalarFunction& Soland::getObjectiveFunction() { - return f; -} +TestScalarFunction& Soland::getObjectiveFunction() { return f; } -TestVectorFunction& Soland::getInequalityConstraintFunction() { - return g; -} +TestVectorFunction& Soland::getInequalityConstraintFunction() { return g; } -TestVectorFunction& Soland::getEqualityConstraintFunction() { - return h; -} +TestVectorFunction& Soland::getEqualityConstraintFunction() { return h; } float_t Soland::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -42,73 +30,46 @@ float_t Soland::getOptimalPointUndisplaced(base::DataVector& x) { return -16.738893184394644; } +SolandObjective::SolandObjective() : TestScalarFunction(2) {} +SolandObjective::~SolandObjective() {} -SolandObjective::SolandObjective() : - TestScalarFunction(2) { -} - -SolandObjective::~SolandObjective() { -} - -float_t SolandObjective::evalUndisplaced( - const base::DataVector& x) { +float_t SolandObjective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 2.0 * x[0]; const float_t x2 = 3.0 * x[1]; return -12.0 * x1 - 7.0 * x2 + x2 * x2; } -void SolandObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new SolandObjective(*this)); +void SolandObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new SolandObjective(*this)); } +SolandInequalityConstraint::SolandInequalityConstraint() : TestVectorFunction(2, 0) {} +SolandInequalityConstraint::~SolandInequalityConstraint() {} -SolandInequalityConstraint::SolandInequalityConstraint() : - TestVectorFunction(2, 0) { -} - -SolandInequalityConstraint::~SolandInequalityConstraint() { -} - -void SolandInequalityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { -} +void SolandInequalityConstraint::evalUndisplaced(const base::DataVector& x, + base::DataVector& value) {} -void SolandInequalityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new SolandInequalityConstraint(*this)); +void SolandInequalityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new SolandInequalityConstraint(*this)); } +SolandEqualityConstraint::SolandEqualityConstraint() : TestVectorFunction(2, 1) {} +SolandEqualityConstraint::~SolandEqualityConstraint() {} -SolandEqualityConstraint::SolandEqualityConstraint() : - TestVectorFunction(2, 1) { -} - -SolandEqualityConstraint::~SolandEqualityConstraint() { -} - -void SolandEqualityConstraint::evalUndisplaced( - const base::DataVector& x, - base::DataVector& value) { +void SolandEqualityConstraint::evalUndisplaced(const base::DataVector& x, base::DataVector& value) { const float_t x1 = 2.0 * x[0]; const float_t x2 = 3.0 * x[1]; value[0] = -2.0 * std::pow(x1, 4.0) + 2.0 - x2; } -void SolandEqualityConstraint::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new SolandEqualityConstraint(*this)); -} - -} -} +void SolandEqualityConstraint::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new SolandEqualityConstraint(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/constrained/Soland.hpp b/optimization/src/sgpp/optimization/test_problems/constrained/Soland.hpp index d737f6d3c0..5cdd7a3553 100644 --- a/optimization/src/sgpp/optimization/test_problems/constrained/Soland.hpp +++ b/optimization/src/sgpp/optimization/test_problems/constrained/Soland.hpp @@ -37,14 +37,12 @@ class SolandObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -52,8 +50,7 @@ class SolandObjective : public TestScalarFunction { * * Definition: empty, i.e., no constraint */ -class SolandInequalityConstraint : - public TestVectorFunction { +class SolandInequalityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -69,14 +66,12 @@ class SolandInequalityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -86,8 +81,7 @@ class SolandInequalityConstraint : * \f[\bar{h}(\bar{\vec{x}}) := * -2 \bar{x}_1^4 - \bar{x}_2 + 2\f] */ -class SolandEqualityConstraint : - public TestVectorFunction { +class SolandEqualityConstraint : public TestVectorFunction { public: /** * Constructor. @@ -103,14 +97,12 @@ class SolandEqualityConstraint : * @param x point \f$\vec{x} \in \mathbb{R}^d\f$ * @param[out] value \f$\vec{f}(\vec{x})\f$ */ - virtual void evalUndisplaced(const base::DataVector& x, - base::DataVector& value) override; + void evalUndisplaced(const base::DataVector& x, base::DataVector& value) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -158,8 +150,7 @@ class Soland : public ConstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function @@ -169,9 +160,8 @@ class Soland : public ConstrainedTestProblem { /// equality constraint function SolandEqualityConstraint h; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_CONSTRAINED_SOLAND_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/AbsoluteValue.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/AbsoluteValue.cpp index 9dd0a8e610..e83590a252 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/AbsoluteValue.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/AbsoluteValue.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -AbsoluteValue::AbsoluteValue(size_t d) : - UnconstrainedTestProblem(d), - f(d) { -} +AbsoluteValue::AbsoluteValue(size_t d) : UnconstrainedTestProblem(d), f(d) {} -AbsoluteValue::~AbsoluteValue() { -} +AbsoluteValue::~AbsoluteValue() {} -TestScalarFunction& AbsoluteValue::getObjectiveFunction() { - return f; -} +TestScalarFunction& AbsoluteValue::getObjectiveFunction() { return f; } float_t AbsoluteValue::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(d); @@ -34,15 +28,11 @@ float_t AbsoluteValue::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0; } -AbsoluteValueObjective::AbsoluteValueObjective(size_t d) : - TestScalarFunction(d) { -} +AbsoluteValueObjective::AbsoluteValueObjective(size_t d) : TestScalarFunction(d) {} -AbsoluteValueObjective::~AbsoluteValueObjective() { -} +AbsoluteValueObjective::~AbsoluteValueObjective() {} -float_t AbsoluteValueObjective::evalUndisplaced( - const base::DataVector& x) { +float_t AbsoluteValueObjective::evalUndisplaced(const base::DataVector& x) { float_t result = 0.0; for (size_t t = 0; t < d; t++) { @@ -52,12 +42,9 @@ float_t AbsoluteValueObjective::evalUndisplaced( return result; } -void AbsoluteValueObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new AbsoluteValueObjective(*this)); -} - -} -} +void AbsoluteValueObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new AbsoluteValueObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/AbsoluteValue.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/AbsoluteValue.hpp index 12f2e633bb..161741afef 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/AbsoluteValue.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/AbsoluteValue.hpp @@ -27,7 +27,7 @@ class AbsoluteValueObjective : public TestScalarFunction { * * @param d dimension of the domain */ - AbsoluteValueObjective(size_t d); + explicit AbsoluteValueObjective(size_t d); /** * Destructor. @@ -38,14 +38,12 @@ class AbsoluteValueObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -65,7 +63,7 @@ class AbsoluteValue : public UnconstrainedTestProblem { * * @param d dimension of the domain */ - AbsoluteValue(size_t d); + explicit AbsoluteValue(size_t d); /** * Destructor. @@ -83,16 +81,14 @@ class AbsoluteValue : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function AbsoluteValueObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_ABSOLUTEVALUE_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Ackley.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Ackley.cpp index 74241b80fb..d2bb9ea540 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Ackley.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Ackley.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Ackley::Ackley(size_t d) : - UnconstrainedTestProblem(d), - f(d) { -} +Ackley::Ackley(size_t d) : UnconstrainedTestProblem(d), f(d) {} -Ackley::~Ackley() { -} +Ackley::~Ackley() {} -TestScalarFunction& Ackley::getObjectiveFunction() { - return f; -} +TestScalarFunction& Ackley::getObjectiveFunction() { return f; } float_t Ackley::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(d); @@ -30,15 +24,11 @@ float_t Ackley::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0; } -AckleyObjective::AckleyObjective(size_t d) : - TestScalarFunction(d) { -} +AckleyObjective::AckleyObjective(size_t d) : TestScalarFunction(d) {} -AckleyObjective::~AckleyObjective() { -} +AckleyObjective::~AckleyObjective() {} -float_t AckleyObjective::evalUndisplaced( - const base::DataVector& x) { +float_t AckleyObjective::evalUndisplaced(const base::DataVector& x) { float_t result = 0.0; float_t arg1 = 0.0; @@ -50,21 +40,15 @@ float_t AckleyObjective::evalUndisplaced( arg2 += std::cos(2.0 * M_PI * xt); } - result = 20.0 * - (1.0 - - std::exp(-0.2 * - std::sqrt(arg1 / static_cast(d)))); + result = 20.0 * (1.0 - std::exp(-0.2 * std::sqrt(arg1 / static_cast(d)))); result += M_E - std::exp(arg2 / static_cast(d)); return result; } -void AckleyObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new AckleyObjective(*this)); -} - -} -} +void AckleyObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new AckleyObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Ackley.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Ackley.hpp index c3440c0844..430ce1b050 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Ackley.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Ackley.hpp @@ -29,7 +29,7 @@ class AckleyObjective : public TestScalarFunction { * * @param d dimension of the domain */ - AckleyObjective(size_t d); + explicit AckleyObjective(size_t d); /** * Destructor. @@ -40,14 +40,12 @@ class AckleyObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -67,7 +65,7 @@ class Ackley : public UnconstrainedTestProblem { * * @param d dimension of the domain */ - Ackley(size_t d); + explicit Ackley(size_t d); /** * Destructor. @@ -85,16 +83,14 @@ class Ackley : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function AckleyObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_ACKLEY_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Beale.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Beale.cpp index 9e7ba7b068..3bc554e43a 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Beale.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Beale.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Beale::Beale() : - UnconstrainedTestProblem(2), - f() { -} +Beale::Beale() : UnconstrainedTestProblem(2), f() {} -Beale::~Beale() { -} +Beale::~Beale() {} -TestScalarFunction& Beale::getObjectiveFunction() { - return f; -} +TestScalarFunction& Beale::getObjectiveFunction() { return f; } float_t Beale::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -31,15 +25,11 @@ float_t Beale::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0; } -BealeObjective::BealeObjective() : - TestScalarFunction(2) { -} +BealeObjective::BealeObjective() : TestScalarFunction(2) {} -BealeObjective::~BealeObjective() { -} +BealeObjective::~BealeObjective() {} -float_t BealeObjective::evalUndisplaced( - const base::DataVector& x) { +float_t BealeObjective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 10.0 * x[0] - 5.0; const float_t x2 = 10.0 * x[1] - 5.0; const float_t tmp1 = 1.5 - x1 * (1.0 - x2); @@ -49,12 +39,9 @@ float_t BealeObjective::evalUndisplaced( return tmp1 * tmp1 + tmp2 * tmp2 + tmp3 * tmp3; } -void BealeObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new BealeObjective(*this)); -} - -} -} +void BealeObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new BealeObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Beale.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Beale.hpp index 8401aea31d..70d414d56e 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Beale.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Beale.hpp @@ -39,14 +39,12 @@ class BealeObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -82,16 +80,14 @@ class Beale : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function BealeObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_BEALE_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Branin.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Branin.cpp index 6e94852954..40f6b99bb4 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Branin.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Branin.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Branin::Branin() : - UnconstrainedTestProblem(2), - f() { -} +Branin::Branin() : UnconstrainedTestProblem(2), f() {} -Branin::~Branin() { -} +Branin::~Branin() {} -TestScalarFunction& Branin::getObjectiveFunction() { - return f; -} +TestScalarFunction& Branin::getObjectiveFunction() { return f; } float_t Branin::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -31,30 +25,21 @@ float_t Branin::getOptimalPointUndisplaced(base::DataVector& x) { return 5.0 / (4.0 * M_PI); } -BraninObjective::BraninObjective() : - TestScalarFunction(2) { -} +BraninObjective::BraninObjective() : TestScalarFunction(2) {} -BraninObjective::~BraninObjective() { -} +BraninObjective::~BraninObjective() {} -float_t BraninObjective::evalUndisplaced( - const base::DataVector& x) { +float_t BraninObjective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 15.0 * x[0] - 5.0; const float_t x2 = 15.0 * x[1]; - const float_t tmp = x2 - 5.1 * x1 * x1 / (4.0 * M_PI * M_PI) + - 5.0 * x1 / M_PI - 6.0; + const float_t tmp = x2 - 5.1 * x1 * x1 / (4.0 * M_PI * M_PI) + 5.0 * x1 / M_PI - 6.0; - return tmp * tmp + - 10.0 * (1.0 - 1.0 / (8.0 * M_PI)) * std::cos(x1) + 10.0; + return tmp * tmp + 10.0 * (1.0 - 1.0 / (8.0 * M_PI)) * std::cos(x1) + 10.0; } -void BraninObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new BraninObjective(*this)); -} - -} -} +void BraninObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new BraninObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Branin.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Branin.hpp index 86df033a5d..762b818165 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Branin.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Branin.hpp @@ -7,9 +7,9 @@ #define SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_BRANIN_HPP #include +#include #include -#include namespace SGPP { namespace optimization { @@ -40,14 +40,12 @@ class BraninObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -83,16 +81,14 @@ class Branin : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function BraninObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_BRANIN_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/BubbleWrap.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/BubbleWrap.cpp index c61a6c014a..c4ba80a837 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/BubbleWrap.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/BubbleWrap.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -BubbleWrap::BubbleWrap(size_t d) : - UnconstrainedTestProblem(d), - f(d) { -} +BubbleWrap::BubbleWrap(size_t d) : UnconstrainedTestProblem(d), f(d) {} -BubbleWrap::~BubbleWrap() { -} +BubbleWrap::~BubbleWrap() {} -TestScalarFunction& BubbleWrap::getObjectiveFunction() { - return f; -} +TestScalarFunction& BubbleWrap::getObjectiveFunction() { return f; } float_t BubbleWrap::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(d); @@ -30,15 +24,11 @@ float_t BubbleWrap::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0; } -BubbleWrapObjective::BubbleWrapObjective(size_t d) : - TestScalarFunction(d) { -} +BubbleWrapObjective::BubbleWrapObjective(size_t d) : TestScalarFunction(d) {} -BubbleWrapObjective::~BubbleWrapObjective() { -} +BubbleWrapObjective::~BubbleWrapObjective() {} -float_t BubbleWrapObjective::evalUndisplaced( - const base::DataVector& x) { +float_t BubbleWrapObjective::evalUndisplaced(const base::DataVector& x) { float_t product = 1.0; for (size_t t = 0; t < d; t++) { @@ -49,12 +39,9 @@ float_t BubbleWrapObjective::evalUndisplaced( return 1.0 - product; } -void BubbleWrapObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new BubbleWrapObjective(*this)); -} - -} -} +void BubbleWrapObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new BubbleWrapObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/BubbleWrap.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/BubbleWrap.hpp index ab9d2a00fc..8f71557eca 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/BubbleWrap.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/BubbleWrap.hpp @@ -7,9 +7,9 @@ #define SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_BUBBLEWRAP_HPP #include +#include #include -#include namespace SGPP { namespace optimization { @@ -29,7 +29,7 @@ class BubbleWrapObjective : public TestScalarFunction { * * @param d dimension of the domain */ - BubbleWrapObjective(size_t d); + explicit BubbleWrapObjective(size_t d); /** * Destructor. @@ -40,14 +40,12 @@ class BubbleWrapObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -67,7 +65,7 @@ class BubbleWrap : public UnconstrainedTestProblem { * * @param d dimension of the domain */ - BubbleWrap(size_t d); + explicit BubbleWrap(size_t d); /** * Destructor. @@ -85,16 +83,14 @@ class BubbleWrap : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function BubbleWrapObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_BUBBLEWRAP_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/EasomYang.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/EasomYang.cpp index 363bba5544..b41f01aeb8 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/EasomYang.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/EasomYang.cpp @@ -11,17 +11,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -EasomYang::EasomYang(size_t d) : - UnconstrainedTestProblem(d), - f(d) { -} +EasomYang::EasomYang(size_t d) : UnconstrainedTestProblem(d), f(d) {} -EasomYang::~EasomYang() { -} +EasomYang::~EasomYang() {} -TestScalarFunction& EasomYang::getObjectiveFunction() { - return f; -} +TestScalarFunction& EasomYang::getObjectiveFunction() { return f; } float_t EasomYang::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(d); @@ -29,15 +23,11 @@ float_t EasomYang::getOptimalPointUndisplaced(base::DataVector& x) { return -1.0; } -EasomYangObjective::EasomYangObjective(size_t d) : - TestScalarFunction(d) { -} +EasomYangObjective::EasomYangObjective(size_t d) : TestScalarFunction(d) {} -EasomYangObjective::~EasomYangObjective() { -} +EasomYangObjective::~EasomYangObjective() {} -float_t EasomYangObjective::evalUndisplaced( - const base::DataVector& x) { +float_t EasomYangObjective::evalUndisplaced(const base::DataVector& x) { float_t sum = 0.0; float_t product = 1.0; @@ -51,12 +41,9 @@ float_t EasomYangObjective::evalUndisplaced( return -std::exp(-sum) * product; } -void EasomYangObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new EasomYangObjective(*this)); -} - -} -} +void EasomYangObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new EasomYangObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/EasomYang.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/EasomYang.hpp index 46d95b02a2..23a4a009d1 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/EasomYang.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/EasomYang.hpp @@ -7,9 +7,9 @@ #define SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_EASOM_HPP #include +#include #include -#include namespace SGPP { namespace optimization { @@ -30,7 +30,7 @@ class EasomYangObjective : public TestScalarFunction { * * @param d dimension of the domain */ - EasomYangObjective(size_t d); + explicit EasomYangObjective(size_t d); /** * Destructor. @@ -41,14 +41,12 @@ class EasomYangObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -68,7 +66,7 @@ class EasomYang : public UnconstrainedTestProblem { * * @param d dimension of the domain */ - EasomYang(size_t d); + explicit EasomYang(size_t d); /** * Destructor. @@ -86,16 +84,14 @@ class EasomYang : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function EasomYangObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_EASOM_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Eggholder.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Eggholder.cpp index 71276242d3..e163cce7ca 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Eggholder.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Eggholder.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Eggholder::Eggholder() : - UnconstrainedTestProblem(2), - f() { -} +Eggholder::Eggholder() : UnconstrainedTestProblem(2), f() {} -Eggholder::~Eggholder() { -} +Eggholder::~Eggholder() {} -TestScalarFunction& Eggholder::getObjectiveFunction() { - return f; -} +TestScalarFunction& Eggholder::getObjectiveFunction() { return f; } float_t Eggholder::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -36,29 +30,21 @@ bool Eggholder::isDisplacementFeasible() { return UnconstrainedTestProblem::isDisplacementFeasible(); } -EggholderObjective::EggholderObjective() : - TestScalarFunction(2) { -} +EggholderObjective::EggholderObjective() : TestScalarFunction(2) {} -EggholderObjective::~EggholderObjective() { -} +EggholderObjective::~EggholderObjective() {} -float_t EggholderObjective::evalUndisplaced( - const base::DataVector& x) { +float_t EggholderObjective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 1024.0 * x[0] - 512.0; const float_t x2 = 1024.0 * x[1] - 512.0; - return -(x2 + 47.0) * - std::sin(std::sqrt(std::abs(x1 / 2.0 + x2 + 47.0))) - + return -(x2 + 47.0) * std::sin(std::sqrt(std::abs(x1 / 2.0 + x2 + 47.0))) - x1 * std::sin(std::sqrt(std::abs(x1 - (x2 + 47.0)))); } -void EggholderObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new EggholderObjective(*this)); -} - -} -} +void EggholderObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new EggholderObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Eggholder.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Eggholder.hpp index 7f18743d6a..84e3b4e08b 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Eggholder.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Eggholder.hpp @@ -7,9 +7,9 @@ #define SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_EGGHOLDER_HPP #include +#include #include -#include namespace SGPP { namespace optimization { @@ -41,14 +41,12 @@ class EggholderObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -87,8 +85,7 @@ class Eggholder : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /** @@ -102,10 +99,8 @@ class Eggholder : public UnconstrainedTestProblem { /// objective function EggholderObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_EGGHOLDER_HPP */ - diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/GoldsteinPrice.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/GoldsteinPrice.cpp index c5f6024d30..d84c92bad6 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/GoldsteinPrice.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/GoldsteinPrice.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -GoldsteinPrice::GoldsteinPrice() : - UnconstrainedTestProblem(2), - f() { -} +GoldsteinPrice::GoldsteinPrice() : UnconstrainedTestProblem(2), f() {} -GoldsteinPrice::~GoldsteinPrice() { -} +GoldsteinPrice::~GoldsteinPrice() {} -TestScalarFunction& GoldsteinPrice::getObjectiveFunction() { - return f; -} +TestScalarFunction& GoldsteinPrice::getObjectiveFunction() { return f; } float_t GoldsteinPrice::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -31,33 +25,27 @@ float_t GoldsteinPrice::getOptimalPointUndisplaced(base::DataVector& x) { return 3.0; } -GoldsteinPriceObjective::GoldsteinPriceObjective() : - TestScalarFunction(2) { -} +GoldsteinPriceObjective::GoldsteinPriceObjective() : TestScalarFunction(2) {} -GoldsteinPriceObjective::~GoldsteinPriceObjective() { -} +GoldsteinPriceObjective::~GoldsteinPriceObjective() {} -float_t GoldsteinPriceObjective::evalUndisplaced( - const base::DataVector& x) { +float_t GoldsteinPriceObjective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 4.0 * x[0] - 2.0; const float_t x2 = 4.0 * x[1] - 2.0; - return (1.0 + (x1 + x2 + 1.0) * (x1 + x2 + 1.0) * - (19.0 - 14.0 * x1 + 3.0 * x1 * x1 - 14.0 * x2 + - 6.0 * x1 * x2 + 3.0 * x2 * x2)) * - (30.0 + (2.0 * x1 - 3.0 * x2) * (2.0 * x1 - 3.0 * x2) * - (18.0 - 32.0 * x1 + 12.0 * x1 * x1 + 48.0 * x2 - - 36.0 * x1 * x2 + 27.0 * x2 * x2)); + return (1.0 + + (x1 + x2 + 1.0) * (x1 + x2 + 1.0) * + (19.0 - 14.0 * x1 + 3.0 * x1 * x1 - 14.0 * x2 + 6.0 * x1 * x2 + 3.0 * x2 * x2)) * + (30.0 + + (2.0 * x1 - 3.0 * x2) * (2.0 * x1 - 3.0 * x2) * + (18.0 - 32.0 * x1 + 12.0 * x1 * x1 + 48.0 * x2 - 36.0 * x1 * x2 + 27.0 * x2 * x2)); } -void GoldsteinPriceObjective::clone( - std::unique_ptr& clone) const { +void GoldsteinPriceObjective::clone(std::unique_ptr& clone) const { clone = std::unique_ptr( - new GoldsteinPriceObjective(*this)); -} - -} -} + new GoldsteinPriceObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/GoldsteinPrice.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/GoldsteinPrice.hpp index c6578579c9..1e6e8c7a5c 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/GoldsteinPrice.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/GoldsteinPrice.hpp @@ -41,14 +41,12 @@ class GoldsteinPriceObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -84,16 +82,14 @@ class GoldsteinPrice : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function GoldsteinPriceObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_GOLDSTEINPRICE_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Griewank.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Griewank.cpp index d62598f4b4..66442e525d 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Griewank.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Griewank.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Griewank::Griewank(size_t d) : - UnconstrainedTestProblem(d), - f(d) { -} +Griewank::Griewank(size_t d) : UnconstrainedTestProblem(d), f(d) {} -Griewank::~Griewank() { -} +Griewank::~Griewank() {} -TestScalarFunction& Griewank::getObjectiveFunction() { - return f; -} +TestScalarFunction& Griewank::getObjectiveFunction() { return f; } float_t Griewank::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(d); @@ -30,15 +24,11 @@ float_t Griewank::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0; } -GriewankObjective::GriewankObjective(size_t d) : - TestScalarFunction(d) { -} +GriewankObjective::GriewankObjective(size_t d) : TestScalarFunction(d) {} -GriewankObjective::~GriewankObjective() { -} +GriewankObjective::~GriewankObjective() {} -float_t GriewankObjective::evalUndisplaced( - const base::DataVector& x) { +float_t GriewankObjective::evalUndisplaced(const base::DataVector& x) { float_t result = 1.0; float_t tmp = 1.0; @@ -52,12 +42,9 @@ float_t GriewankObjective::evalUndisplaced( return result; } -void GriewankObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new GriewankObjective(*this)); -} - -} -} +void GriewankObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new GriewankObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Griewank.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Griewank.hpp index 655910ec6a..d5161dc3ed 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Griewank.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Griewank.hpp @@ -7,9 +7,9 @@ #define SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_GRIEWANK_HPP #include +#include #include -#include namespace SGPP { namespace optimization { @@ -30,7 +30,7 @@ class GriewankObjective : public TestScalarFunction { * * @param d dimension of the domain */ - GriewankObjective(size_t d); + explicit GriewankObjective(size_t d); /** * Destructor. @@ -41,14 +41,12 @@ class GriewankObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -68,7 +66,7 @@ class Griewank : public UnconstrainedTestProblem { * * @param d dimension of the domain */ - Griewank(size_t d); + explicit Griewank(size_t d); /** * Destructor. @@ -86,16 +84,14 @@ class Griewank : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function GriewankObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_GRIEWANK_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman3.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman3.cpp index 6bcd8c6731..e744392fc8 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman3.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman3.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Hartman3::Hartman3() : - UnconstrainedTestProblem(3), - f() { -} +Hartman3::Hartman3() : UnconstrainedTestProblem(3), f() {} -Hartman3::~Hartman3() { -} +Hartman3::~Hartman3() {} -TestScalarFunction& Hartman3::getObjectiveFunction() { - return f; -} +TestScalarFunction& Hartman3::getObjectiveFunction() { return f; } float_t Hartman3::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(3); @@ -32,15 +26,11 @@ float_t Hartman3::getOptimalPointUndisplaced(base::DataVector& x) { return -3.862784507551574; } -Hartman3Objective::Hartman3Objective() : - TestScalarFunction(3) { -} +Hartman3Objective::Hartman3Objective() : TestScalarFunction(3) {} -Hartman3Objective::~Hartman3Objective() { -} +Hartman3Objective::~Hartman3Objective() {} -float_t Hartman3Objective::evalUndisplaced( - const base::DataVector& x) { +float_t Hartman3Objective::evalUndisplaced(const base::DataVector& x) { return -1.0 * std::exp(-3.0 * (x[0] - 0.3689) * (x[0] - 0.3689) - 10.0 * (x[1] - 0.1170) * (x[1] - 0.1170) - 30.0 * (x[2] - 0.2673) * (x[2] - 0.2673)) - @@ -55,12 +45,9 @@ float_t Hartman3Objective::evalUndisplaced( 35.0 * (x[2] - 0.8828) * (x[2] - 0.8828)); } -void Hartman3Objective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new Hartman3Objective(*this)); -} - -} -} +void Hartman3Objective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new Hartman3Objective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman3.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman3.hpp index 4eb2dc293c..875acabb50 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman3.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman3.hpp @@ -7,9 +7,9 @@ #define SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_HARTMAN3_HPP #include +#include #include -#include namespace SGPP { namespace optimization { @@ -54,14 +54,12 @@ class Hartman3Objective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -97,16 +95,14 @@ class Hartman3 : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function Hartman3Objective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_HARTMAN3_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman6.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman6.cpp index 259ca855db..9a30547ce0 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman6.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman6.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Hartman6::Hartman6() : - UnconstrainedTestProblem(6), - f() { -} +Hartman6::Hartman6() : UnconstrainedTestProblem(6), f() {} -Hartman6::~Hartman6() { -} +Hartman6::~Hartman6() {} -TestScalarFunction& Hartman6::getObjectiveFunction() { - return f; -} +TestScalarFunction& Hartman6::getObjectiveFunction() { return f; } float_t Hartman6::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(6); @@ -35,15 +29,11 @@ float_t Hartman6::getOptimalPointUndisplaced(base::DataVector& x) { return -3.322368011415512; } -Hartman6Objective::Hartman6Objective() : - TestScalarFunction(6) { -} +Hartman6Objective::Hartman6Objective() : TestScalarFunction(6) {} -Hartman6Objective::~Hartman6Objective() { -} +Hartman6Objective::~Hartman6Objective() {} -float_t Hartman6Objective::evalUndisplaced( - const base::DataVector& x) { +float_t Hartman6Objective::evalUndisplaced(const base::DataVector& x) { return -1.0 * std::exp(-10.0 * (x[0] - 0.1312) * (x[0] - 0.1312) - 3.0 * (x[1] - 0.1696) * (x[1] - 0.1696) - 17.0 * (x[2] - 0.5569) * (x[2] - 0.5569) - @@ -70,12 +60,9 @@ float_t Hartman6Objective::evalUndisplaced( 14.0 * (x[5] - 0.0381) * (x[5] - 0.0381)); } -void Hartman6Objective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new Hartman6Objective(*this)); -} - -} -} +void Hartman6Objective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new Hartman6Objective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman6.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman6.hpp index e86c53eb57..c2a6e12bca 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman6.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Hartman6.hpp @@ -7,9 +7,9 @@ #define SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_HARTMAN6_HPP #include +#include #include -#include namespace SGPP { namespace optimization { @@ -54,14 +54,12 @@ class Hartman6Objective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -98,16 +96,14 @@ class Hartman6 : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function Hartman6Objective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_HARTMAN6_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Himmelblau.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Himmelblau.cpp index ebb98b182f..c7d5eba308 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Himmelblau.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Himmelblau.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Himmelblau::Himmelblau() : - UnconstrainedTestProblem(2), - f() { -} +Himmelblau::Himmelblau() : UnconstrainedTestProblem(2), f() {} -Himmelblau::~Himmelblau() { -} +Himmelblau::~Himmelblau() {} -TestScalarFunction& Himmelblau::getObjectiveFunction() { - return f; -} +TestScalarFunction& Himmelblau::getObjectiveFunction() { return f; } float_t Himmelblau::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -31,15 +25,11 @@ float_t Himmelblau::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0; } -HimmelblauObjective::HimmelblauObjective() : - TestScalarFunction(2) { -} +HimmelblauObjective::HimmelblauObjective() : TestScalarFunction(2) {} -HimmelblauObjective::~HimmelblauObjective() { -} +HimmelblauObjective::~HimmelblauObjective() {} -float_t HimmelblauObjective::evalUndisplaced( - const base::DataVector& x) { +float_t HimmelblauObjective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 10.0 * x[0] - 5.0; const float_t x2 = 10.0 * x[1] - 5.0; @@ -47,12 +37,9 @@ float_t HimmelblauObjective::evalUndisplaced( (x1 + x2 * x2 - 7.0) * (x1 + x2 * x2 - 7.0); } -void HimmelblauObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new HimmelblauObjective(*this)); -} - -} -} +void HimmelblauObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new HimmelblauObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Himmelblau.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Himmelblau.hpp index 87bdd432c8..be2bbfac09 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Himmelblau.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Himmelblau.hpp @@ -37,14 +37,12 @@ class HimmelblauObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -81,16 +79,14 @@ class Himmelblau : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function HimmelblauObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_HIMMELBLAU_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/HoelderTable.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/HoelderTable.cpp index 517c12ee1a..ec8eac802d 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/HoelderTable.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/HoelderTable.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -HoelderTable::HoelderTable() : - UnconstrainedTestProblem(2), - f() { -} +HoelderTable::HoelderTable() : UnconstrainedTestProblem(2), f() {} -HoelderTable::~HoelderTable() { -} +HoelderTable::~HoelderTable() {} -TestScalarFunction& HoelderTable::getObjectiveFunction() { - return f; -} +TestScalarFunction& HoelderTable::getObjectiveFunction() { return f; } float_t HoelderTable::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -32,38 +26,31 @@ float_t HoelderTable::getOptimalPointUndisplaced(base::DataVector& x) { } bool HoelderTable::isDisplacementFeasible() { - if ((displacement[0] > 0.005) || (displacement[0] < -0.005) || - (displacement[1] > 0.01) || (displacement[1] < -0.01)) { + if ((displacement[0] > 0.005) || (displacement[0] < -0.005) || (displacement[1] > 0.01) || + (displacement[1] < -0.01)) { return false; } return UnconstrainedTestProblem::isDisplacementFeasible(); } -HoelderTableObjective::HoelderTableObjective() : - TestScalarFunction(2) { -} +HoelderTableObjective::HoelderTableObjective() : TestScalarFunction(2) {} -HoelderTableObjective::~HoelderTableObjective() { -} +HoelderTableObjective::~HoelderTableObjective() {} -float_t HoelderTableObjective::evalUndisplaced( - const base::DataVector& x) { +float_t HoelderTableObjective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 20.0 * x[0] - 10.0; const float_t x2 = 20.0 * x[1] - 10.0; - return -std::abs( - std::sin(x1) * std::cos(x2) * std::exp( - std::abs(1.0 - std::sqrt(x1 * x1 + x2 * x2) / M_PI))); + return -std::abs(std::sin(x1) * std::cos(x2) * + std::exp(std::abs(1.0 - std::sqrt(x1 * x1 + x2 * x2) / M_PI))); } -void HoelderTableObjective::clone( - std::unique_ptr& clone) const { +void HoelderTableObjective::clone(std::unique_ptr& clone) const { clone = std::unique_ptr( - new HoelderTableObjective(*this)); -} - -} -} + new HoelderTableObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/HoelderTable.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/HoelderTable.hpp index 07a4f10d30..1b95c86454 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/HoelderTable.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/HoelderTable.hpp @@ -7,9 +7,9 @@ #define SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_HOELDERTABLE_HPP #include +#include #include -#include namespace SGPP { namespace optimization { @@ -39,14 +39,12 @@ class HoelderTableObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -85,8 +83,7 @@ class HoelderTable : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /** @@ -99,9 +96,8 @@ class HoelderTable : public UnconstrainedTestProblem { /// objective function HoelderTableObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_HOELDERTABLE_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/IncreasingPower.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/IncreasingPower.cpp index 9f25c96842..ff3d178db4 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/IncreasingPower.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/IncreasingPower.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -IncreasingPower::IncreasingPower(size_t d) : - UnconstrainedTestProblem(d), - f(d) { -} +IncreasingPower::IncreasingPower(size_t d) : UnconstrainedTestProblem(d), f(d) {} -IncreasingPower::~IncreasingPower() { -} +IncreasingPower::~IncreasingPower() {} -TestScalarFunction& IncreasingPower::getObjectiveFunction() { - return f; -} +TestScalarFunction& IncreasingPower::getObjectiveFunction() { return f; } float_t IncreasingPower::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(d); @@ -34,31 +28,23 @@ float_t IncreasingPower::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0; } -IncreasingPowerObjective::IncreasingPowerObjective(size_t d) : - TestScalarFunction(d) { -} +IncreasingPowerObjective::IncreasingPowerObjective(size_t d) : TestScalarFunction(d) {} -IncreasingPowerObjective::~IncreasingPowerObjective() { -} +IncreasingPowerObjective::~IncreasingPowerObjective() {} -float_t IncreasingPowerObjective::evalUndisplaced( - const base::DataVector& x) { +float_t IncreasingPowerObjective::evalUndisplaced(const base::DataVector& x) { float_t result = 0.0; for (size_t t = 0; t < d; t++) { - result += std::pow(std::abs(x[t] - 1.0 / std::pow(2.0, t + 1)), - t + 2); + result += std::pow(std::abs(x[t] - 1.0 / std::pow(2.0, t + 1)), t + 2); } return result; } -void IncreasingPowerObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new IncreasingPowerObjective(*this)); -} - -} -} +void IncreasingPowerObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new IncreasingPowerObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/IncreasingPower.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/IncreasingPower.hpp index 30955cd169..de3766a6d1 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/IncreasingPower.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/IncreasingPower.hpp @@ -7,9 +7,9 @@ #define SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_INCREASINGPOWER_HPP #include +#include #include -#include namespace SGPP { namespace optimization { @@ -29,7 +29,7 @@ class IncreasingPowerObjective : public TestScalarFunction { * * @param d dimension of the domain */ - IncreasingPowerObjective(size_t d); + explicit IncreasingPowerObjective(size_t d); /** * Destructor. @@ -40,14 +40,12 @@ class IncreasingPowerObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -67,7 +65,7 @@ class IncreasingPower : public UnconstrainedTestProblem { * * @param d dimension of the domain */ - IncreasingPower(size_t d); + explicit IncreasingPower(size_t d); /** * Destructor. @@ -85,16 +83,14 @@ class IncreasingPower : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function IncreasingPowerObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_INCREASINGPOWER_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Michalewicz.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Michalewicz.cpp index 33f809c615..b0257bb9d9 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Michalewicz.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Michalewicz.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Michalewicz::Michalewicz() : - UnconstrainedTestProblem(2), - f() { -} +Michalewicz::Michalewicz() : UnconstrainedTestProblem(2), f() {} -Michalewicz::~Michalewicz() { -} +Michalewicz::~Michalewicz() {} -TestScalarFunction& Michalewicz::getObjectiveFunction() { - return f; -} +TestScalarFunction& Michalewicz::getObjectiveFunction() { return f; } float_t Michalewicz::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -31,29 +25,21 @@ float_t Michalewicz::getOptimalPointUndisplaced(base::DataVector& x) { return -1.801303410098554; } -MichalewiczObjective::MichalewiczObjective() : - TestScalarFunction(2) { -} +MichalewiczObjective::MichalewiczObjective() : TestScalarFunction(2) {} -MichalewiczObjective::~MichalewiczObjective() { -} +MichalewiczObjective::~MichalewiczObjective() {} -float_t MichalewiczObjective::evalUndisplaced( - const base::DataVector& x) { +float_t MichalewiczObjective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 5.0 * x[0]; const float_t x2 = 5.0 * x[1]; return -std::sin(x1) * std::pow(std::sin(x1 * x1 / M_PI), 20.0) - - std::sin(x2) * std::pow(std::sin(2.0 * x2 * x2 / M_PI), - 20.0); + std::sin(x2) * std::pow(std::sin(2.0 * x2 * x2 / M_PI), 20.0); } -void MichalewiczObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new MichalewiczObjective(*this)); -} - -} -} +void MichalewiczObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new MichalewiczObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Michalewicz.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Michalewicz.hpp index d7c02e61ec..11838f62e3 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Michalewicz.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Michalewicz.hpp @@ -38,14 +38,12 @@ class MichalewiczObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -81,16 +79,14 @@ class Michalewicz : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function MichalewiczObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_MICHALEWICZ_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Mladineo.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Mladineo.cpp index 5c2f465f04..bb530a266d 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Mladineo.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Mladineo.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Mladineo::Mladineo() : - UnconstrainedTestProblem(2), - f() { -} +Mladineo::Mladineo() : UnconstrainedTestProblem(2), f() {} -Mladineo::~Mladineo() { -} +Mladineo::~Mladineo() {} -TestScalarFunction& Mladineo::getObjectiveFunction() { - return f; -} +TestScalarFunction& Mladineo::getObjectiveFunction() { return f; } float_t Mladineo::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -32,37 +26,29 @@ float_t Mladineo::getOptimalPointUndisplaced(base::DataVector& x) { } bool Mladineo::isDisplacementFeasible() { - if ((displacement[0] > 0) || (displacement[0] < -0.01) || - (displacement[1] > 0) || (displacement[1] < -0.01)) { + if ((displacement[0] > 0) || (displacement[0] < -0.01) || (displacement[1] > 0) || + (displacement[1] < -0.01)) { return false; } return UnconstrainedTestProblem::isDisplacementFeasible(); } -MladineoObjective::MladineoObjective() : - TestScalarFunction(2) { -} +MladineoObjective::MladineoObjective() : TestScalarFunction(2) {} -MladineoObjective::~MladineoObjective() { -} +MladineoObjective::~MladineoObjective() {} -float_t MladineoObjective::evalUndisplaced( - const base::DataVector& x) { +float_t MladineoObjective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 0.99 * x[0] + 0.01; const float_t x2 = 0.99 * x[1] + 0.01; return 1.0 + (x1 * x1 + x2 * x2) / 2.0 - - std::cos(10.0 * std::log(2.0 * x1)) * - std::cos(10.0 * std::log(3.0 * x2)); + std::cos(10.0 * std::log(2.0 * x1)) * std::cos(10.0 * std::log(3.0 * x2)); } -void MladineoObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new MladineoObjective(*this)); -} - -} -} +void MladineoObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new MladineoObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Mladineo.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Mladineo.hpp index 8e1a4624d9..5bee08d62e 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Mladineo.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Mladineo.hpp @@ -7,9 +7,9 @@ #define SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_MLADINEO_HPP #include +#include #include -#include namespace SGPP { namespace optimization { @@ -39,14 +39,12 @@ class MladineoObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -82,8 +80,7 @@ class Mladineo : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /** @@ -96,9 +93,8 @@ class Mladineo : public UnconstrainedTestProblem { /// objective function MladineoObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_MLADINEO_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Perm.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Perm.cpp index 5540381644..e759459b24 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Perm.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Perm.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Perm::Perm(size_t d) : - UnconstrainedTestProblem(d), - f(d) { -} +Perm::Perm(size_t d) : UnconstrainedTestProblem(d), f(d) {} -Perm::~Perm() { -} +Perm::~Perm() {} -TestScalarFunction& Perm::getObjectiveFunction() { - return f; -} +TestScalarFunction& Perm::getObjectiveFunction() { return f; } float_t Perm::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(d); @@ -35,15 +29,11 @@ float_t Perm::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0; } -PermObjective::PermObjective(size_t d) : - TestScalarFunction(d) { -} +PermObjective::PermObjective(size_t d) : TestScalarFunction(d) {} -PermObjective::~PermObjective() { -} +PermObjective::~PermObjective() {} -float_t PermObjective::evalUndisplaced( - const base::DataVector& x) { +float_t PermObjective::evalUndisplaced(const base::DataVector& x) { float_t result = 0.0; const float_t dDbl = static_cast(d); @@ -55,8 +45,7 @@ float_t PermObjective::evalUndisplaced( const float_t xt = dDbl * (2.0 * x[t] - 1.0); const float_t tDbl = static_cast(t + 1); - innerSum += (std::pow(tDbl, iDbl) + 1.0) * - (std::pow(xt / tDbl, iDbl) - 1.0); + innerSum += (std::pow(tDbl, iDbl) + 1.0) * (std::pow(xt / tDbl, iDbl) - 1.0); } result += std::pow(innerSum, 2.0); @@ -65,12 +54,9 @@ float_t PermObjective::evalUndisplaced( return result; } -void PermObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new PermObjective(*this)); -} - -} -} +void PermObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new PermObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Perm.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Perm.hpp index c55e415d8e..eb2856da12 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Perm.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Perm.hpp @@ -29,7 +29,7 @@ class PermObjective : public TestScalarFunction { * * @param d dimension of the domain */ - PermObjective(size_t d); + explicit PermObjective(size_t d); /** * Destructor. @@ -40,14 +40,12 @@ class PermObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -67,7 +65,7 @@ class Perm : public UnconstrainedTestProblem { * * @param d dimension of the domain */ - Perm(size_t d); + explicit Perm(size_t d); /** * Destructor. @@ -85,16 +83,14 @@ class Perm : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function PermObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_PERM_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Rastrigin.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Rastrigin.cpp index ddd085f382..b5a3538244 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Rastrigin.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Rastrigin.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Rastrigin::Rastrigin(size_t d) : - UnconstrainedTestProblem(d), - f(d) { -} +Rastrigin::Rastrigin(size_t d) : UnconstrainedTestProblem(d), f(d) {} -Rastrigin::~Rastrigin() { -} +Rastrigin::~Rastrigin() {} -TestScalarFunction& Rastrigin::getObjectiveFunction() { - return f; -} +TestScalarFunction& Rastrigin::getObjectiveFunction() { return f; } float_t Rastrigin::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(d); @@ -30,15 +24,11 @@ float_t Rastrigin::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0; } -RastriginObjective::RastriginObjective(size_t d) : - TestScalarFunction(d) { -} +RastriginObjective::RastriginObjective(size_t d) : TestScalarFunction(d) {} -RastriginObjective::~RastriginObjective() { -} +RastriginObjective::~RastriginObjective() {} -float_t RastriginObjective::evalUndisplaced( - const base::DataVector& x) { +float_t RastriginObjective::evalUndisplaced(const base::DataVector& x) { float_t result = 10.0 * static_cast(d); for (size_t t = 0; t < d; t++) { @@ -49,12 +39,9 @@ float_t RastriginObjective::evalUndisplaced( return result; } -void RastriginObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new RastriginObjective(*this)); -} - -} -} +void RastriginObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new RastriginObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Rastrigin.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Rastrigin.hpp index 7d871d6dac..2fa662dd91 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Rastrigin.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Rastrigin.hpp @@ -7,9 +7,9 @@ #define SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_RASTRIGIN_HPP #include +#include #include -#include namespace SGPP { namespace optimization { @@ -29,7 +29,7 @@ class RastriginObjective : public TestScalarFunction { * * @param d dimension of the domain */ - RastriginObjective(size_t d); + explicit RastriginObjective(size_t d); /** * Destructor. @@ -40,14 +40,12 @@ class RastriginObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -67,7 +65,7 @@ class Rastrigin : public UnconstrainedTestProblem { * * @param d dimension of the domain */ - Rastrigin(size_t d); + explicit Rastrigin(size_t d); /** * Destructor. @@ -85,16 +83,14 @@ class Rastrigin : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function RastriginObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_RASTRIGIN_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Rosenbrock.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Rosenbrock.cpp index c496d6eee7..203ab2c31c 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Rosenbrock.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Rosenbrock.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Rosenbrock::Rosenbrock(size_t d) : - UnconstrainedTestProblem(d), - f(d) { -} +Rosenbrock::Rosenbrock(size_t d) : UnconstrainedTestProblem(d), f(d) {} -Rosenbrock::~Rosenbrock() { -} +Rosenbrock::~Rosenbrock() {} -TestScalarFunction& Rosenbrock::getObjectiveFunction() { - return f; -} +TestScalarFunction& Rosenbrock::getObjectiveFunction() { return f; } float_t Rosenbrock::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(d); @@ -30,15 +24,11 @@ float_t Rosenbrock::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0; } -RosenbrockObjective::RosenbrockObjective(size_t d) : - TestScalarFunction(d) { -} +RosenbrockObjective::RosenbrockObjective(size_t d) : TestScalarFunction(d) {} -RosenbrockObjective::~RosenbrockObjective() { -} +RosenbrockObjective::~RosenbrockObjective() {} -float_t RosenbrockObjective::evalUndisplaced( - const base::DataVector& x) { +float_t RosenbrockObjective::evalUndisplaced(const base::DataVector& x) { float_t result = 0.0; float_t xt = 15.0 * x[0] - 5.0; @@ -55,12 +45,9 @@ float_t RosenbrockObjective::evalUndisplaced( return result; } -void RosenbrockObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new RosenbrockObjective(*this)); -} - -} -} +void RosenbrockObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new RosenbrockObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Rosenbrock.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Rosenbrock.hpp index 573ce425bb..ad8e222aaa 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Rosenbrock.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Rosenbrock.hpp @@ -29,7 +29,7 @@ class RosenbrockObjective : public TestScalarFunction { * * @param d dimension of the domain */ - RosenbrockObjective(size_t d); + explicit RosenbrockObjective(size_t d); /** * Destructor. @@ -40,14 +40,12 @@ class RosenbrockObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -67,7 +65,7 @@ class Rosenbrock : public UnconstrainedTestProblem { * * @param d dimension of the domain */ - Rosenbrock(size_t d); + explicit Rosenbrock(size_t d); /** * Destructor. @@ -85,16 +83,14 @@ class Rosenbrock : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function RosenbrockObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_ROSENBROCK_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/SHCB.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/SHCB.cpp index 14e6bd7a23..172f4a79d3 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/SHCB.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/SHCB.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -SHCB::SHCB() : - UnconstrainedTestProblem(2), - f() { -} +SHCB::SHCB() : UnconstrainedTestProblem(2), f() {} -SHCB::~SHCB() { -} +SHCB::~SHCB() {} -TestScalarFunction& SHCB::getObjectiveFunction() { - return f; -} +TestScalarFunction& SHCB::getObjectiveFunction() { return f; } float_t SHCB::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(2); @@ -31,28 +25,21 @@ float_t SHCB::getOptimalPointUndisplaced(base::DataVector& x) { return -1.031628453489877; } -SHCBObjective::SHCBObjective() : - TestScalarFunction(2) { -} +SHCBObjective::SHCBObjective() : TestScalarFunction(2) {} -SHCBObjective::~SHCBObjective() { -} +SHCBObjective::~SHCBObjective() {} -float_t SHCBObjective::evalUndisplaced( - const base::DataVector& x) { +float_t SHCBObjective::evalUndisplaced(const base::DataVector& x) { const float_t x1 = 10.0 * x[0] - 5.0; const float_t x2 = 10.0 * x[1] - 5.0; - return x1 * x1 * (4.0 - 2.1 * x1 * x1 + x1 * x1 * x1 * x1 / 3.0) + - x1 * x2 + 4.0 * x2 * x2 * (x2 * x2 - 1.0); + return x1 * x1 * (4.0 - 2.1 * x1 * x1 + x1 * x1 * x1 * x1 / 3.0) + x1 * x2 + + 4.0 * x2 * x2 * (x2 * x2 - 1.0); } -void SHCBObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new SHCBObjective(*this)); -} - -} -} +void SHCBObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new SHCBObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/SHCB.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/SHCB.hpp index 3813e04207..5b62d2637a 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/SHCB.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/SHCB.hpp @@ -39,14 +39,12 @@ class SHCBObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -82,16 +80,14 @@ class SHCB : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function SHCBObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_SHCB_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Schwefel.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Schwefel.cpp index 4f7bd5b15d..42cbc5d3c4 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Schwefel.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Schwefel.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Schwefel::Schwefel(size_t d) : - UnconstrainedTestProblem(d), - f(d) { -} +Schwefel::Schwefel(size_t d) : UnconstrainedTestProblem(d), f(d) {} -Schwefel::~Schwefel() { -} +Schwefel::~Schwefel() {} -TestScalarFunction& Schwefel::getObjectiveFunction() { - return f; -} +TestScalarFunction& Schwefel::getObjectiveFunction() { return f; } float_t Schwefel::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(d); @@ -30,15 +24,11 @@ float_t Schwefel::getOptimalPointUndisplaced(base::DataVector& x) { return -418.9828872724337 * static_cast(d); } -SchwefelObjective::SchwefelObjective(size_t d) : - TestScalarFunction(d) { -} +SchwefelObjective::SchwefelObjective(size_t d) : TestScalarFunction(d) {} -SchwefelObjective::~SchwefelObjective() { -} +SchwefelObjective::~SchwefelObjective() {} -float_t SchwefelObjective::evalUndisplaced( - const base::DataVector& x) { +float_t SchwefelObjective::evalUndisplaced(const base::DataVector& x) { float_t result = 0.0; for (size_t t = 0; t < d; t++) { @@ -49,12 +39,9 @@ float_t SchwefelObjective::evalUndisplaced( return result; } -void SchwefelObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new SchwefelObjective(*this)); -} - -} -} +void SchwefelObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new SchwefelObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Schwefel.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Schwefel.hpp index ce8dc0eeba..5d376a8046 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Schwefel.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Schwefel.hpp @@ -28,7 +28,7 @@ class SchwefelObjective : public TestScalarFunction { * * @param d dimension of the domain */ - SchwefelObjective(size_t d); + explicit SchwefelObjective(size_t d); /** * Destructor. @@ -39,14 +39,12 @@ class SchwefelObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -66,7 +64,7 @@ class Schwefel : public UnconstrainedTestProblem { * * @param d dimension of the domain */ - Schwefel(size_t d); + explicit Schwefel(size_t d); /** * Destructor. @@ -84,16 +82,14 @@ class Schwefel : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function SchwefelObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_SCHWEFEL_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Sphere.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Sphere.cpp index 1e57d294f5..5e91f9f489 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Sphere.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Sphere.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -Sphere::Sphere(size_t d) : - UnconstrainedTestProblem(d), - f(d) { -} +Sphere::Sphere(size_t d) : UnconstrainedTestProblem(d), f(d) {} -Sphere::~Sphere() { -} +Sphere::~Sphere() {} -TestScalarFunction& Sphere::getObjectiveFunction() { - return f; -} +TestScalarFunction& Sphere::getObjectiveFunction() { return f; } float_t Sphere::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(d); @@ -30,15 +24,11 @@ float_t Sphere::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0; } -SphereObjective::SphereObjective(size_t d) : - TestScalarFunction(d) { -} +SphereObjective::SphereObjective(size_t d) : TestScalarFunction(d) {} -SphereObjective::~SphereObjective() { -} +SphereObjective::~SphereObjective() {} -float_t SphereObjective::evalUndisplaced( - const base::DataVector& x) { +float_t SphereObjective::evalUndisplaced(const base::DataVector& x) { float_t result = 0.0; for (size_t t = 0; t < d; t++) { @@ -49,12 +39,9 @@ float_t SphereObjective::evalUndisplaced( return result; } -void SphereObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new SphereObjective(*this)); -} - -} -} +void SphereObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new SphereObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/Sphere.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/Sphere.hpp index 0d92def018..f84a237799 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/Sphere.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/Sphere.hpp @@ -27,7 +27,7 @@ class SphereObjective : public TestScalarFunction { * * @param d dimension of the domain */ - SphereObjective(size_t d); + explicit SphereObjective(size_t d); /** * Destructor. @@ -38,14 +38,12 @@ class SphereObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; }; /** @@ -65,7 +63,7 @@ class Sphere : public UnconstrainedTestProblem { * * @param d dimension of the domain */ - Sphere(size_t d); + explicit Sphere(size_t d); /** * Destructor. @@ -83,16 +81,14 @@ class Sphere : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function SphereObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_SPHERE_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/TremblingParabola.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/TremblingParabola.cpp index 77760a85f3..5cfeae917b 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/TremblingParabola.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/TremblingParabola.cpp @@ -12,17 +12,11 @@ namespace SGPP { namespace optimization { namespace test_problems { -TremblingParabola::TremblingParabola(size_t d, size_t p) : - UnconstrainedTestProblem(d), - f(d, p) { -} +TremblingParabola::TremblingParabola(size_t d, size_t p) : UnconstrainedTestProblem(d), f(d, p) {} -TremblingParabola::~TremblingParabola() { -} +TremblingParabola::~TremblingParabola() {} -TestScalarFunction& TremblingParabola::getObjectiveFunction() { - return f; -} +TestScalarFunction& TremblingParabola::getObjectiveFunction() { return f; } float_t TremblingParabola::getOptimalPointUndisplaced(base::DataVector& x) { x.resize(d); @@ -30,19 +24,12 @@ float_t TremblingParabola::getOptimalPointUndisplaced(base::DataVector& x) { return 0.0; } -TremblingParabolaObjective::TremblingParabolaObjective( - size_t d, size_t p) : - TestScalarFunction(d), - p(p), - bSplineBasis(p), - g0(splineTrembling(0.0)) { -} +TremblingParabolaObjective::TremblingParabolaObjective(size_t d, size_t p) + : TestScalarFunction(d), p(p), bSplineBasis(p), g0(splineTrembling(0.0)) {} -TremblingParabolaObjective::~TremblingParabolaObjective() { -} +TremblingParabolaObjective::~TremblingParabolaObjective() {} -float_t TremblingParabolaObjective::evalUndisplaced( - const base::DataVector& x) { +float_t TremblingParabolaObjective::evalUndisplaced(const base::DataVector& x) { float_t result = 0.0; /*for (size_t t = 0; t < d; t++) { @@ -77,12 +64,9 @@ inline float_t TremblingParabolaObjective::splineTrembling(float_t x) const { return result; } -void TremblingParabolaObjective::clone( - std::unique_ptr& clone) const { - clone = std::unique_ptr( - new TremblingParabolaObjective(*this)); -} - -} -} +void TremblingParabolaObjective::clone(std::unique_ptr& clone) const { + clone = std::unique_ptr(new TremblingParabolaObjective(*this)); } +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/TremblingParabola.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/TremblingParabola.hpp index c193d7e56e..4e1eb04052 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/TremblingParabola.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/TremblingParabola.hpp @@ -48,14 +48,12 @@ class TremblingParabolaObjective : public TestScalarFunction { * @param x point \f$\vec{x} \in [0, 1]^d\f$ * @return \f$f(\vec{x})\f$ */ - virtual float_t evalUndisplaced(const base::DataVector& x) - override; + float_t evalUndisplaced(const base::DataVector& x) override; /** * @param[out] clone pointer to cloned object */ - virtual void clone(std::unique_ptr& clone) - const override; + void clone(std::unique_ptr& clone) const override; protected: const size_t p; @@ -102,16 +100,14 @@ class TremblingParabola : public UnconstrainedTestProblem { * @return minimal function value * \f$f(\vec{x}_\opt)\f$ */ - virtual float_t getOptimalPointUndisplaced(base::DataVector& x) - override; + float_t getOptimalPointUndisplaced(base::DataVector& x) override; protected: /// objective function TremblingParabolaObjective f; }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_TREMBLINGPARABOLA_HPP */ diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/UnconstrainedTestProblem.cpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/UnconstrainedTestProblem.cpp index 44fed014a3..983768110a 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/UnconstrainedTestProblem.cpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/UnconstrainedTestProblem.cpp @@ -11,13 +11,9 @@ namespace SGPP { namespace optimization { namespace test_problems { -UnconstrainedTestProblem::UnconstrainedTestProblem(size_t d) : - d(d), - displacement(d, 0.0) { -} +UnconstrainedTestProblem::UnconstrainedTestProblem(size_t d) : d(d), displacement(d, 0.0) {} -UnconstrainedTestProblem::~UnconstrainedTestProblem() { -} +UnconstrainedTestProblem::~UnconstrainedTestProblem() {} float_t UnconstrainedTestProblem::getOptimalPoint(base::DataVector& x) { // reverse displace optimal point @@ -35,8 +31,7 @@ void UnconstrainedTestProblem::generateDisplacement(float_t stdDev) { do { for (size_t t = 0; t < d; t++) { // every component is normally distributed - displacement[t] = - RandomNumberGenerator::getInstance().getGaussianRN(stdDev); + displacement[t] = RandomNumberGenerator::getInstance().getGaussianRN(stdDev); } } while (!isDisplacementFeasible()); @@ -44,12 +39,9 @@ void UnconstrainedTestProblem::generateDisplacement(float_t stdDev) { getObjectiveFunction().setDisplacement(displacement); } -const base::DataVector& UnconstrainedTestProblem::getDisplacement() const { - return displacement; -} +const base::DataVector& UnconstrainedTestProblem::getDisplacement() const { return displacement; } -void UnconstrainedTestProblem::setDisplacement( - const base::DataVector& displacement) { +void UnconstrainedTestProblem::setDisplacement(const base::DataVector& displacement) { this->displacement = displacement; // set the displacement also in the objective function getObjectiveFunction().setDisplacement(displacement); @@ -69,7 +61,6 @@ bool UnconstrainedTestProblem::isDisplacementFeasible() { return true; } - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/test_problems/unconstrained/UnconstrainedTestProblem.hpp b/optimization/src/sgpp/optimization/test_problems/unconstrained/UnconstrainedTestProblem.hpp index 226c1400c5..823d3dc7ad 100644 --- a/optimization/src/sgpp/optimization/test_problems/unconstrained/UnconstrainedTestProblem.hpp +++ b/optimization/src/sgpp/optimization/test_problems/unconstrained/UnconstrainedTestProblem.hpp @@ -6,11 +6,11 @@ #ifndef SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_UNCONSTRAINEDTESTPROBLEM_HPP #define SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_UNCONSTRAINEDTESTPROBLEM_HPP -#include - #include #include +#include + namespace SGPP { namespace optimization { namespace test_problems { @@ -33,7 +33,7 @@ class UnconstrainedTestProblem { * * @param d dimension of the domain */ - UnconstrainedTestProblem(size_t d); + explicit UnconstrainedTestProblem(size_t d); /** * Destructor. @@ -123,9 +123,8 @@ class UnconstrainedTestProblem { */ virtual bool isDisplacementFeasible(); }; - -} -} -} +} // namespace test_problems +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TEST_PROBLEMS_UNCONSTRAINED_UNCONSTRAINEDTESTPROBLEM_HPP */ diff --git a/optimization/src/sgpp/optimization/tools/FileIO.cpp b/optimization/src/sgpp/optimization/tools/FileIO.cpp index 2087b972da..003c2b98dd 100644 --- a/optimization/src/sgpp/optimization/tools/FileIO.cpp +++ b/optimization/src/sgpp/optimization/tools/FileIO.cpp @@ -10,6 +10,8 @@ #include #include +#include +#include // namespace namespace SGPP { namespace optimization { @@ -78,23 +80,22 @@ const char* getTypeString(const std::vector& A) { return "string "; } -void writeGrid(const std::string& filename, - const base::GridStorage& gridStorage) { +void writeGrid(const std::string& filename, const base::GridStorage& gridStorage) { const size_t N = gridStorage.size(); const base::DataVector functionValues(N, 0.0); writeGrid(filename, gridStorage, functionValues); } -void writeGrid(const std::string& filename, - const base::GridStorage& gridStorage, +void writeGrid(const std::string& filename, const base::GridStorage& gridStorage, const base::DataVector& functionValues) { const size_t N = gridStorage.size(); const size_t d = gridStorage.dim(); if (functionValues.getSize() != N) { - throw std::invalid_argument("functionValues must have as many " - "elements as there are grid " - "points in gridStorage."); + throw std::invalid_argument( + "functionValues must have as many " + "elements as there are grid " + "points in gridStorage."); } std::ofstream f; @@ -125,14 +126,12 @@ void writeGrid(const std::string& filename, } } -void readGrid(const std::string& filename, - base::GridStorage& gridStorage) { +void readGrid(const std::string& filename, base::GridStorage& gridStorage) { base::DataVector functionValues(0); readGrid(filename, gridStorage, functionValues); } -void readGrid(const std::string& filename, - base::GridStorage& gridStorage, +void readGrid(const std::string& filename, base::GridStorage& gridStorage, base::DataVector& functionValues) { std::ifstream f; f.exceptions(std::ifstream::failbit | std::ifstream::badbit); @@ -164,11 +163,9 @@ void readGrid(const std::string& filename, } } -void writeMatrix(const std::string& filename, - base::DataMatrix& A) { +void writeMatrix(const std::string& filename, base::DataMatrix& A) { // convert DataMatrix to std::vector - const std::vector AVector(A.getPointer(), A.getPointer() + - A.getNrows() * A.getNcols()); + const std::vector AVector(A.getPointer(), A.getPointer() + A.getNrows() * A.getNcols()); writeMatrix(filename, AVector, A.getNrows(), A.getNcols()); } @@ -180,11 +177,9 @@ void readMatrix(const std::string& filename, base::DataMatrix& A) { A = base::DataMatrix(&AVector[0], m, n); } -void writeVector(const std::string& filename, - base::DataVector& x) { +void writeVector(const std::string& filename, base::DataVector& x) { // convert DataVector to std::vector - const std::vector xVector(x.getPointer(), - x.getPointer() + x.getSize()); + const std::vector xVector(x.getPointer(), x.getPointer() + x.getSize()); writeMatrix(filename, xVector, 1, x.getSize()); } @@ -195,7 +190,6 @@ void readVector(const std::string& filename, base::DataVector& x) { x.resize(xVector.size()); x = base::DataVector(&xVector[0], xVector.size()); } - -} -} -} +} // namespace file_io +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/tools/FileIO.hpp b/optimization/src/sgpp/optimization/tools/FileIO.hpp index a38b3d2808..05fb5aeb29 100644 --- a/optimization/src/sgpp/optimization/tools/FileIO.hpp +++ b/optimization/src/sgpp/optimization/tools/FileIO.hpp @@ -8,13 +8,15 @@ #include -#include -#include - #include #include #include +#include +#include +#include +#include + namespace SGPP { namespace optimization { @@ -132,8 +134,7 @@ const char* getTypeString(const std::vector& A); * @param filename filename of the file to be written * @param gridStorage grid storage containing the grid points */ -void writeGrid(const std::string& filename, - const base::GridStorage& gridStorage); +void writeGrid(const std::string& filename, const base::GridStorage& gridStorage); /** * Write a grid (grid points and function values) to a file. @@ -157,8 +158,7 @@ void writeGrid(const std::string& filename, * @param gridStorage grid storage containing the grid points * @param functionValues vector of function values */ -void writeGrid(const std::string& filename, - const base::GridStorage& gridStorage, +void writeGrid(const std::string& filename, const base::GridStorage& gridStorage, const base::DataVector& functionValues); /** @@ -168,8 +168,7 @@ void writeGrid(const std::string& filename, * @param filename filename of the file to be read * @param[out] gridStorage grid storage containing the grid points */ -void readGrid(const std::string& filename, - base::GridStorage& gridStorage); +void readGrid(const std::string& filename, base::GridStorage& gridStorage); /** * Read a grid (grid points and function values) from a file. @@ -179,8 +178,7 @@ void readGrid(const std::string& filename, * @param[out] gridStorage grid storage containing the grid points * @param[out] functionValues vector of function values */ -void readGrid(const std::string& filename, - base::GridStorage& gridStorage, +void readGrid(const std::string& filename, base::GridStorage& gridStorage, base::DataVector& functionValues); /** @@ -214,8 +212,7 @@ void writeMatrix(const std::string& filename, base::DataMatrix& A); * @param n number of columns */ template -void writeMatrix(const std::string& filename, - const std::vector& A, size_t m, size_t n) { +void writeMatrix(const std::string& filename, const std::vector& A, size_t m, size_t n) { std::ofstream f; f.exceptions(std::ofstream::failbit | std::ofstream::badbit); const char* type = getTypeString(A); @@ -252,8 +249,7 @@ void readMatrix(const std::string& filename, base::DataMatrix& A); * @param[out] n number of columns */ template -void readMatrix(const std::string& filename, - std::vector& A, size_t& m, size_t& n) { +void readMatrix(const std::string& filename, std::vector& A, size_t& m, size_t& n) { std::ifstream f; f.exceptions(std::ofstream::failbit | std::ofstream::badbit); const char* type = getTypeString(A); @@ -269,9 +265,10 @@ void readMatrix(const std::string& filename, type2[16] = 0; if (std::string(type) != std::string(type2)) { - throw std::invalid_argument("The type of the entries in the file " - "differ from the type of the " - "entries of A."); + throw std::invalid_argument( + "The type of the entries in the file " + "differ from the type of the " + "entries of A."); } A.empty(); @@ -326,9 +323,8 @@ void readVector(const std::string& filename, std::vector& x) { size_t m, n; readMatrix(filename, x, m, n); } - -} -} -} +} // namespace file_io +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TOOLS_FILEIO_HPP */ diff --git a/optimization/src/sgpp/optimization/tools/Math.cpp b/optimization/src/sgpp/optimization/tools/Math.cpp index ee0154a620..e7740c9455 100644 --- a/optimization/src/sgpp/optimization/tools/Math.cpp +++ b/optimization/src/sgpp/optimization/tools/Math.cpp @@ -42,9 +42,9 @@ void schurDecomposition(base::DataMatrix& A, base::DataMatrix& V) { const float_t dPlus = A(m - 1, m - 1) + A(m - 2, m - 2); const float_t dMinus = A(m - 1, m - 1) - A(m - 2, m - 2); const float_t sigma = (dMinus >= 0.0) ? 1.0 : -1.0; - const float_t lambda = dPlus / 2.0 + sigma / 2.0 * std::sqrt( - dMinus * dMinus + - 4.0 * A(m - 1, m - 2) * A(m - 2, m - 1)); + const float_t lambda = + dPlus / 2.0 + + sigma / 2.0 * std::sqrt(dMinus * dMinus + 4.0 * A(m - 1, m - 2) * A(m - 2, m - 1)); // calculate A(1:m,1:m) - lambda*eye(m) for (size_t i = 0; i < m; i++) { @@ -275,9 +275,7 @@ void hessenbergForm(base::DataMatrix& A, base::DataMatrix& V) { for (size_t p = 0; p < m; p++) { for (size_t q = 0; q < m; q++) { - entry += QTilde(i - k - 1, p) * - A(p + k + 1, q + k + 1) * - QTilde(q, j - k - 1); + entry += QTilde(i - k - 1, p) * A(p + k + 1, q + k + 1) * QTilde(q, j - k - 1); } } @@ -304,9 +302,7 @@ void hessenbergForm(base::DataMatrix& A, base::DataMatrix& V) { } } -void householderTransformation(const base::DataMatrix& A, - size_t i, size_t j, - base::DataMatrix& Q) { +void householderTransformation(const base::DataMatrix& A, size_t i, size_t j, base::DataMatrix& Q) { // dimension of matrix const size_t n = A.getNrows(); // dimension of transformation @@ -335,7 +331,6 @@ void householderTransformation(const base::DataMatrix& A, } } } - -} -} -} +} // namespace math +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/tools/Math.hpp b/optimization/src/sgpp/optimization/tools/Math.hpp index 3b382666f9..b12476b09e 100644 --- a/optimization/src/sgpp/optimization/tools/Math.hpp +++ b/optimization/src/sgpp/optimization/tools/Math.hpp @@ -78,12 +78,9 @@ void hessenbergForm(base::DataMatrix& A, base::DataMatrix& V); * @param[out] Q transformation matrix * (must have correct size \f$(n-i) \times (n-i)\f$) */ -void householderTransformation(const base::DataMatrix& A, - size_t i, size_t j, - base::DataMatrix& Q); - -} -} -} +void householderTransformation(const base::DataMatrix& A, size_t i, size_t j, base::DataMatrix& Q); +} // namespace math +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TOOLS_MATH_HPP */ diff --git a/optimization/src/sgpp/optimization/tools/MutexType.hpp b/optimization/src/sgpp/optimization/tools/MutexType.hpp index 0ce2e01790..db9107fa2c 100644 --- a/optimization/src/sgpp/optimization/tools/MutexType.hpp +++ b/optimization/src/sgpp/optimization/tools/MutexType.hpp @@ -32,9 +32,7 @@ class MutexType { /** * Constructor. */ - MutexType() { - omp_init_nest_lock(&_lock); - } + MutexType() { omp_init_nest_lock(&_lock); } /** * Custom copy constructor to prevent copying the lock. @@ -60,23 +58,17 @@ class MutexType { /** * Destructor. */ - ~MutexType() { - omp_destroy_nest_lock(&_lock); - } + ~MutexType() { omp_destroy_nest_lock(&_lock); } /** * Lock the MutexType. */ - void lock() { - omp_set_nest_lock(&_lock); - } + void lock() { omp_set_nest_lock(&_lock); } /** * Unlock the MutexType. */ - void unlock() { - omp_unset_nest_lock(&_lock); - } + void unlock() { omp_unset_nest_lock(&_lock); } protected: /// OpenMP lock @@ -88,16 +80,13 @@ class MutexType { // dummy definition in case SG++ is compiled without OpenMP class MutexType { public: - void lock() { - } + void lock() {} - void unlock() { - } + void unlock() {} }; #endif /* _OPENMP */ - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TOOLS_MUTEXTYPE_HPP */ diff --git a/optimization/src/sgpp/optimization/tools/Printer.cpp b/optimization/src/sgpp/optimization/tools/Printer.cpp index fba141b7e8..6493797641 100644 --- a/optimization/src/sgpp/optimization/tools/Printer.cpp +++ b/optimization/src/sgpp/optimization/tools/Printer.cpp @@ -11,6 +11,7 @@ #include #include +#include #ifndef _WIN32 #include #include @@ -19,18 +20,17 @@ namespace SGPP { namespace optimization { -Printer::Printer() : - verbose(DEFAULT_VERBOSITY), - statusPrintingEnabled(true), - statusLevel(0), - indentationLevel(0), - cursorInClearLine(true), - lastMsgLength(0), - lastDuration(0.0), - lineLengthLimit(0), - indentation(INDENTATION_LENGTH, INDENTATION_CHAR), - stream(&std::cout) { - +Printer::Printer() + : verbose(DEFAULT_VERBOSITY), + statusPrintingEnabled(true), + statusLevel(0), + indentationLevel(0), + cursorInClearLine(true), + lastMsgLength(0), + lastDuration(0.0), + lineLengthLimit(0), + indentation(INDENTATION_LENGTH, INDENTATION_CHAR), + stream(&std::cout) { #ifndef _WIN32 struct winsize w; @@ -41,6 +41,11 @@ Printer::Printer() : #endif } +Printer& Printer::getInstance() { + static Printer printer; + return printer; +} + void Printer::printStatusBegin(const std::string& msg) { ScopedLock lock(mutex); @@ -80,13 +85,10 @@ void Printer::printStatusUpdate(const std::string& msg) { } std::string printMsg = msg; - const size_t totalIndentationLength = - indentationLevel * INDENTATION_LENGTH; + const size_t totalIndentationLength = indentationLevel * INDENTATION_LENGTH; - if ((lineLengthLimit > 0) && (totalIndentationLength + - printMsg.length() > lineLengthLimit)) { - printMsg = printMsg.substr(0, lineLengthLimit - - totalIndentationLength - 3) + "..."; + if ((lineLengthLimit > 0) && (totalIndentationLength + printMsg.length() > lineLengthLimit)) { + printMsg = printMsg.substr(0, lineLengthLimit - totalIndentationLength - 3) + "..."; } // print indentation @@ -100,8 +102,8 @@ void Printer::printStatusUpdate(const std::string& msg) { // new message is too short ==> print spaces to hide the old one and // go back again if (lastMsgLength > printMsg.length()) { - (*stream) << std::string(lastMsgLength - printMsg.length(), ' ') << - std::string(lastMsgLength - printMsg.length(), '\b'); + (*stream) << std::string(lastMsgLength - printMsg.length(), ' ') + << std::string(lastMsgLength - printMsg.length(), '\b'); } (*stream) << std::flush; @@ -157,8 +159,7 @@ void Printer::printStatusEnd(const std::string& msg) { // print message std::string time_msg = - "Done in " + - std::to_string(static_cast(1000.0 * lastDuration)) + "ms"; + "Done in " + std::to_string(static_cast(1000.0 * lastDuration)) + "ms"; if (msg == "") { (*stream) << time_msg << "."; @@ -187,35 +188,23 @@ bool Printer::isStatusPrintingEnabled() { return statusPrintingEnabled; } -float_t Printer::getLastDurationSecs() const { - return lastDuration; -} +float_t Printer::getLastDurationSecs() const { return lastDuration; } -MutexType& Printer::getMutex() { - return mutex; -} +MutexType& Printer::getMutex() { return mutex; } -std::ostream* Printer::getStream() const { - return stream; -} +std::ostream* Printer::getStream() const { return stream; } -void Printer::setStream(std::ostream* stream) { - this->stream = stream; -} +void Printer::setStream(std::ostream* stream) { this->stream = stream; } -size_t Printer::getLineLengthLimit() { - return lineLengthLimit; -} +size_t Printer::getLineLengthLimit() { return lineLengthLimit; } void Printer::setLineLengthLimit(size_t lineLengthLimit) { this->lineLengthLimit = lineLengthLimit; } -void Printer::printIterativeGridGenerator( - const IterativeGridGenerator& grid_gen) const { +void Printer::printIterativeGridGenerator(const IterativeGridGenerator& grid_gen) const { base::GridStorage& gridStorage = *grid_gen.getGrid().getStorage(); - const base::DataVector& functionValues = - grid_gen.getFunctionValues(); + const base::DataVector& functionValues = grid_gen.getFunctionValues(); for (size_t i = 0; i < gridStorage.size(); i++) { if (i > 0) { @@ -251,6 +240,5 @@ void Printer::printSLE(SLE& system) const { (*stream) << "]\n"; } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/tools/Printer.hpp b/optimization/src/sgpp/optimization/tools/Printer.hpp index 9be5137d75..8e90fb9802 100644 --- a/optimization/src/sgpp/optimization/tools/Printer.hpp +++ b/optimization/src/sgpp/optimization/tools/Printer.hpp @@ -6,10 +6,6 @@ #ifndef SGPP_OPTIMIZATION_TOOLS_PRINTER_HPP #define SGPP_OPTIMIZATION_TOOLS_PRINTER_HPP -#include -#include -#include - #include #include @@ -19,6 +15,12 @@ #include #include +#include +#include +#include +#include +#include + namespace SGPP { namespace optimization { @@ -30,8 +32,7 @@ namespace optimization { * @return stream */ template -inline std::ostream& operator<<(std::ostream& stream, - const std::vector& x) { +inline std::ostream& operator<<(std::ostream& stream, const std::vector& x) { for (size_t i = 0; i < x.size(); i++) { stream << ((i > 0) ? ", " : "[") << x[i]; } @@ -46,8 +47,7 @@ inline std::ostream& operator<<(std::ostream& stream, * @param x vector * @return stream */ -inline std::ostream& operator<<(std::ostream& stream, - const base::DataVector& x) { +inline std::ostream& operator<<(std::ostream& stream, const base::DataVector& x) { return stream << x.toString(); } @@ -58,8 +58,7 @@ inline std::ostream& operator<<(std::ostream& stream, * @param x pointer to grid point * @return stream */ -inline std::ostream& operator<<(std::ostream& stream, - const SGPP::base::GridIndex& x) { +inline std::ostream& operator<<(std::ostream& stream, const SGPP::base::GridIndex& x) { base::DataVector xCoord(x.dim()); for (size_t t = 0; t < x.dim(); t++) { @@ -86,10 +85,7 @@ class Printer { /** * @return singleton instance */ - inline static Printer& getInstance() { - static Printer printer; - return printer; - } + static Printer& getInstance(); /** * Call at the beginning of a time-consuming operation. @@ -152,16 +148,12 @@ class Printer { /** * @return current verbosity level */ - inline int getVerbosity() const { - return verbose; - } + inline int getVerbosity() const { return verbose; } /** * @param level new verbosity level */ - inline void setVerbosity(int level) { - verbose = level; - } + inline void setVerbosity(int level) { verbose = level; } /** * @return running-time of the last operation terminated by @@ -199,8 +191,7 @@ class Printer { * * @param gridGen grid to be printed */ - void printIterativeGridGenerator( - const IterativeGridGenerator& gridGen) const; + void printIterativeGridGenerator(const IterativeGridGenerator& gridGen) const; /** * Print a system of linear equations. @@ -257,8 +248,7 @@ class Printer { */ void operator=(const Printer&) = delete; }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TOOLS_PRINTER_HPP */ diff --git a/optimization/src/sgpp/optimization/tools/RandomNumberGenerator.cpp b/optimization/src/sgpp/optimization/tools/RandomNumberGenerator.cpp index 6dfcdb8124..4cce492c6b 100644 --- a/optimization/src/sgpp/optimization/tools/RandomNumberGenerator.cpp +++ b/optimization/src/sgpp/optimization/tools/RandomNumberGenerator.cpp @@ -3,16 +3,19 @@ // use, please see the copyright notice provided with SG++ or at // sgpp.sparsegrids.org -#include - #include #include +#include + namespace SGPP { namespace optimization { -RandomNumberGenerator::RandomNumberGenerator() { - setSeed(); +RandomNumberGenerator::RandomNumberGenerator() { setSeed(); } + +RandomNumberGenerator& RandomNumberGenerator::getInstance() { + static RandomNumberGenerator rng; + return rng; } float_t RandomNumberGenerator::getUniformRN(float_t a, float_t b) { @@ -25,24 +28,18 @@ size_t RandomNumberGenerator::getUniformIndexRN(size_t size) { return distr(generator); } -float_t RandomNumberGenerator::getGaussianRN(float_t stdDev, - float_t mean) { +float_t RandomNumberGenerator::getGaussianRN(float_t stdDev, float_t mean) { std::normal_distribution distr(mean, stdDev); return distr(generator); } -RandomNumberGenerator::SeedType RandomNumberGenerator::getSeed() const { - return seed; -} +RandomNumberGenerator::SeedType RandomNumberGenerator::getSeed() const { return seed; } -void RandomNumberGenerator::setSeed() { - setSeed(static_cast(std::time(0))); -} +void RandomNumberGenerator::setSeed() { setSeed(static_cast(std::time(0))); } void RandomNumberGenerator::setSeed(RandomNumberGenerator::SeedType seed) { this->seed = seed; generator.seed(seed); } - -} -} +} // namespace optimization +} // namespace SGPP diff --git a/optimization/src/sgpp/optimization/tools/RandomNumberGenerator.hpp b/optimization/src/sgpp/optimization/tools/RandomNumberGenerator.hpp index aaeec3da06..cd899aecbf 100644 --- a/optimization/src/sgpp/optimization/tools/RandomNumberGenerator.hpp +++ b/optimization/src/sgpp/optimization/tools/RandomNumberGenerator.hpp @@ -24,10 +24,7 @@ class RandomNumberGenerator { /** * @return singleton instance */ - inline static RandomNumberGenerator& getInstance() { - static RandomNumberGenerator rng; - return rng; - } + static RandomNumberGenerator& getInstance(); /** * Generate a uniform pseudo-random number. @@ -95,7 +92,7 @@ class RandomNumberGenerator { */ void operator=(const RandomNumberGenerator&) = delete; }; -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TOOLS_RANDOMNUMBERGENERATOR_HPP */ diff --git a/optimization/src/sgpp/optimization/tools/ScopedLock.hpp b/optimization/src/sgpp/optimization/tools/ScopedLock.hpp index 714b20cdc6..934061366d 100644 --- a/optimization/src/sgpp/optimization/tools/ScopedLock.hpp +++ b/optimization/src/sgpp/optimization/tools/ScopedLock.hpp @@ -26,16 +26,12 @@ class ScopedLock { * * @param m MutexType object to be wrapped */ - ScopedLock(MutexType& m) : mut(m), locked(true) { - mut.lock(); - } + explicit ScopedLock(MutexType& m) : mut(m), locked(true) { mut.lock(); } /** * Destructor, unlocks the MutexType object. */ - ~ScopedLock() { - unlock(); - } + ~ScopedLock() { unlock(); } /** * Unlocks the MutexType object, if locked. @@ -78,8 +74,7 @@ class ScopedLock { */ void operator=(const ScopedLock& other); }; - -} -} +} // namespace optimization +} // namespace SGPP #endif /* SGPP_OPTIMIZATION_TOOLS_SCOPEDLOCK_HPP */ diff --git a/parallel/SConscript b/parallel/SConscript index 098503a98d..20f7380afa 100755 --- a/parallel/SConscript +++ b/parallel/SConscript @@ -12,6 +12,7 @@ Import('BUILD_DIR') Import('moduleName') Import('headerSourceList') Import('headerDestList') +Import('lintAction') env_parallel = env.Clone() # can only build without mpi support, skip those files @@ -108,7 +109,11 @@ if env['USE_STATICLIB']: for i, _ in enumerate(moduleDependencies): moduleDependencies[i] = "%sstatic" % moduleDependencies[i] Export('libname') -srcs = [] + +cpps = [] +hpps = [] +objs = [] + for currentFolder, subdirNames, fileNames in os.walk("."): if currentFolder.startswith(os.path.join(".", "src", "sgpp", "parallel", "exampleApplication")): continue # ignore exampleApplication when compiling normally. @@ -121,15 +126,15 @@ for currentFolder, subdirNames, fileNames in os.walk("."): continue if fileName in ArBBOnlyFiles: continue - srcs.append(os.path.join(currentFolder, fileName)) + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env_parallel.SharedObject(cpp)) if currentFolder != 'src': for fileName in fnmatch.filter(fileNames, '*.hpp'): - headerSourceList.append(os.path.join(moduleName, currentFolder, fileName)) - headerDestList.append(os.path.join(currentFolder, fileName).split(os.sep,1)[1]) - -objs = [] -for sourceFile in srcs: - objs.append(env_parallel.SharedObject(sourceFile)) + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + headerSourceList.append(os.path.join(moduleName, hpp)) + headerDestList.append(hpp.split(os.sep, 1)[1]) if env['USE_STATICLIB']: libsuffix = env['LIBSUFFIX'] @@ -152,6 +157,11 @@ for lib_str in moduleDependencies: libInstall = env_parallel.Install(BUILD_DIR, lib) +if env['RUN_CPPLINT']: + for path in cpps + hpps: + lintCommand = env.Command(path + ".lint", path, lintAction) + env.Depends(lib, lintCommand) + if not env['NO_UNIT_TESTS'] and env['SG_PYTHON']: Import('testTargetList') py_test_env = env.Clone() diff --git a/pde/SConscript b/pde/SConscript index 7dadcbb250..b487d16b65 100755 --- a/pde/SConscript +++ b/pde/SConscript @@ -16,6 +16,7 @@ Import('installTargetList') Import('exampleTargetList') Import('headerSourceList') Import('headerDestList') +Import('lintAction') moduleDependencies = ['sgppsolver', 'sgppbase'] Export('moduleDependencies') @@ -27,18 +28,21 @@ if env['USE_STATICLIB']: moduleDependencies[i] = "%sstatic" % moduleDependencies[i] Export('libname') -srcs = [] +cpps = [] +hpps = [] +objs = [] + for currentFolder, subdirNames, fileNames in os.walk("src"): for fileName in fnmatch.filter(fileNames, '*.cpp'): - srcs.append(os.path.join(currentFolder, fileName)) + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) if currentFolder != 'src': for fileName in fnmatch.filter(fileNames, '*.hpp'): - headerSourceList.append(os.path.join(moduleName, currentFolder, fileName)) - headerDestList.append(os.path.join(currentFolder, fileName).split(os.sep,1)[1]) - -objs = [] -for sourceFile in srcs: - objs.append(env.SharedObject(sourceFile)) + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + headerSourceList.append(os.path.join(moduleName, hpp)) + headerDestList.append(hpp.split(os.sep, 1)[1]) if env['USE_STATICLIB']: # building static libraries is the same for unix and windows platforms @@ -63,6 +67,11 @@ for lib_str in moduleDependencies: libInstall = env.Install(BUILD_DIR, lib) +if env['RUN_CPPLINT']: + for path in cpps + hpps: + lintCommand = env.Command(path + ".lint", path, lintAction) + env.Depends(lib, lintCommand) + if not env['NO_UNIT_TESTS'] and env['SG_PYTHON']: Import('testTargetList') py_test_env = env.Clone() diff --git a/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystem.cpp b/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystem.cpp index 0e2895e983..4b7201dedc 100644 --- a/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystem.cpp +++ b/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystem.cpp @@ -7,17 +7,16 @@ #include #include -using namespace SGPP::op_factory; - #include +#include namespace SGPP { namespace pde { HeatEquationParabolicPDESolverSystem::HeatEquationParabolicPDESolverSystem( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, float_t a, - float_t TimestepSize, std::string OperationMode) { + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, float_t a, float_t TimestepSize, + std::string OperationMode) { this->a = a; this->tOperationMode = OperationMode; this->TimestepSize = TimestepSize; @@ -26,21 +25,19 @@ HeatEquationParabolicPDESolverSystem::HeatEquationParabolicPDESolverSystem( this->InnerGrid = NULL; this->alpha_inner = NULL; - this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector( - SparseGrid.getStorage()); + this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector(SparseGrid.getStorage()); this->GridConverter = new SGPP::base::DirichletGridConverter(); - this->OpLaplaceBound = createOperationLaplace(SparseGrid); + this->OpLaplaceBound = op_factory::createOperationLaplace(SparseGrid); this->OpMassBound = SGPP::op_factory::createOperationLTwoDotProduct(SparseGrid); // create the inner grid - this->GridConverter->buildInnerGridWithCoefs(*this->BoundGrid, - *this->alpha_complete, &this->InnerGrid, &this->alpha_inner); + this->GridConverter->buildInnerGridWithCoefs(*this->BoundGrid, *this->alpha_complete, + &this->InnerGrid, &this->alpha_inner); - //Create needed operations, on inner grid - this->OpLaplaceInner = createOperationLaplace(*this->InnerGrid); - this->OpMassInner = SGPP::op_factory::createOperationLTwoDotProduct( - *this->InnerGrid); + // Create needed operations, on inner grid + this->OpLaplaceInner = op_factory::createOperationLaplace(*this->InnerGrid); + this->OpMassInner = SGPP::op_factory::createOperationLTwoDotProduct(*this->InnerGrid); // right hand side if System this->rhs = new SGPP::base::DataVector(1); @@ -66,8 +63,8 @@ HeatEquationParabolicPDESolverSystem::~HeatEquationParabolicPDESolverSystem() { delete this->rhs; } -void HeatEquationParabolicPDESolverSystem::applyMassMatrixComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void HeatEquationParabolicPDESolverSystem::applyMassMatrixComplete(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { result.setAll(0.0); SGPP::base::DataVector temp(alpha.getSize()); @@ -78,19 +75,19 @@ void HeatEquationParabolicPDESolverSystem::applyMassMatrixComplete( result.add(temp); } -void HeatEquationParabolicPDESolverSystem::applyLOperatorComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void HeatEquationParabolicPDESolverSystem::applyLOperatorComplete(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { result.setAll(0.0); SGPP::base::DataVector temp(alpha.getSize()); // Apply the laplace Operator rate this->OpLaplaceBound->mult(alpha, temp); - result.axpy((-1.0)*this->a, temp); + result.axpy((-1.0) * this->a, temp); } -void HeatEquationParabolicPDESolverSystem::applyMassMatrixInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void HeatEquationParabolicPDESolverSystem::applyMassMatrixInner(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { result.setAll(0.0); SGPP::base::DataVector temp(alpha.getSize()); @@ -101,29 +98,24 @@ void HeatEquationParabolicPDESolverSystem::applyMassMatrixInner( result.add(temp); } -void HeatEquationParabolicPDESolverSystem::applyLOperatorInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void HeatEquationParabolicPDESolverSystem::applyLOperatorInner(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { result.setAll(0.0); SGPP::base::DataVector temp(alpha.getSize()); // Apply the laplace Operator rate this->OpLaplaceInner->mult(alpha, temp); - result.axpy((-1.0)*this->a, temp); + result.axpy((-1.0) * this->a, temp); } void HeatEquationParabolicPDESolverSystem::finishTimestep() { // Replace the inner coefficients on the boundary grid - this->GridConverter->updateBoundaryCoefs(*this->alpha_complete, - *this->alpha_inner); + this->GridConverter->updateBoundaryCoefs(*this->alpha_complete, *this->alpha_inner); } -void HeatEquationParabolicPDESolverSystem::coarsenAndRefine( - bool isLastTimestep) { -} +void HeatEquationParabolicPDESolverSystem::coarsenAndRefine(bool isLastTimestep) {} -void HeatEquationParabolicPDESolverSystem::startTimestep() { -} - -} -} \ No newline at end of file +void HeatEquationParabolicPDESolverSystem::startTimestep() {} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystem.hpp b/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystem.hpp index 397f8100a3..da99ae0feb 100644 --- a/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystem.hpp +++ b/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystem.hpp @@ -12,6 +12,7 @@ #include +#include namespace SGPP { namespace pde { @@ -20,8 +21,7 @@ namespace pde { * This class implements the ParabolicPDESolverSystem for the * Heat Equation. */ -class HeatEquationParabolicPDESolverSystem : public - OperationParabolicPDESolverSystemDirichlet { +class HeatEquationParabolicPDESolverSystem : public OperationParabolicPDESolverSystemDirichlet { private: /// the heat coefficient float_t a; @@ -34,17 +34,13 @@ class HeatEquationParabolicPDESolverSystem : public /// the LTwoDotProduct Operation (Mass Matrix), on inner grid SGPP::base::OperationMatrix* OpMassInner; - void applyMassMatrixComplete(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + void applyMassMatrixComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - void applyLOperatorComplete(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + void applyLOperatorComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - void applyMassMatrixInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + void applyMassMatrixInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - void applyLOperatorInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + void applyLOperatorInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); public: /** @@ -54,11 +50,12 @@ class HeatEquationParabolicPDESolverSystem : public * @param alpha the sparse grid's coefficients * @param a the heat coefficient * @param TimestepSize the size of one timestep used in the ODE Solver - * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for explicit Euler, + * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for + * explicit Euler, * ImEul for implicit Euler, CrNic for Crank Nicolson solver */ - HeatEquationParabolicPDESolverSystem(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& alpha, float_t a, float_t TimestepSize, + HeatEquationParabolicPDESolverSystem(SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, + float_t a, float_t TimestepSize, std::string OperationMode = "ExEul"); /** @@ -72,8 +69,7 @@ class HeatEquationParabolicPDESolverSystem : public virtual void startTimestep(); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* HEATEQUATIONPARABOLICPDESOLVERSYSTEM_HPP */ \ No newline at end of file +#endif /* HEATEQUATIONPARABOLICPDESOLVERSYSTEM_HPP */ diff --git a/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystemParallelOMP.cpp b/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystemParallelOMP.cpp old mode 100755 new mode 100644 index 3671ac2492..1a266aa338 --- a/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystemParallelOMP.cpp +++ b/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystemParallelOMP.cpp @@ -10,7 +10,6 @@ #include #include -using namespace SGPP::op_factory; #ifdef _OPENMP #include @@ -18,13 +17,15 @@ using namespace SGPP::op_factory; #include +#include +#include namespace SGPP { namespace pde { HeatEquationParabolicPDESolverSystemParallelOMP::HeatEquationParabolicPDESolverSystemParallelOMP( - SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, float_t a, - float_t TimestepSize, std::string OperationMode) { + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& alpha, float_t a, float_t TimestepSize, + std::string OperationMode) { this->a = a; this->tOperationMode = OperationMode; this->TimestepSize = TimestepSize; @@ -33,27 +34,26 @@ HeatEquationParabolicPDESolverSystemParallelOMP::HeatEquationParabolicPDESolverS this->InnerGrid = NULL; this->alpha_inner = NULL; - this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector( - SparseGrid.getStorage()); + this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector(SparseGrid.getStorage()); this->GridConverter = new SGPP::base::DirichletGridConverter(); - this->OpLaplaceBound = createOperationLaplace(SparseGrid); + this->OpLaplaceBound = op_factory::createOperationLaplace(SparseGrid); this->OpMassBound = SGPP::op_factory::createOperationLTwoDotProduct(SparseGrid); // create the inner grid - this->GridConverter->buildInnerGridWithCoefs(*this->BoundGrid, - *this->alpha_complete, &this->InnerGrid, &this->alpha_inner); + this->GridConverter->buildInnerGridWithCoefs(*this->BoundGrid, *this->alpha_complete, + &this->InnerGrid, &this->alpha_inner); - //Create needed operations, on inner grid - this->OpLaplaceInner = createOperationLaplace(*this->InnerGrid); - this->OpMassInner = SGPP::op_factory::createOperationLTwoDotProduct( - *this->InnerGrid); + // Create needed operations, on inner grid + this->OpLaplaceInner = op_factory::createOperationLaplace(*this->InnerGrid); + this->OpMassInner = SGPP::op_factory::createOperationLTwoDotProduct(*this->InnerGrid); // right hand side if System this->rhs = NULL; } -HeatEquationParabolicPDESolverSystemParallelOMP::~HeatEquationParabolicPDESolverSystemParallelOMP() { +HeatEquationParabolicPDESolverSystemParallelOMP:: + ~HeatEquationParabolicPDESolverSystemParallelOMP() { delete this->OpLaplaceBound; delete this->OpMassBound; delete this->OpLaplaceInner; @@ -76,25 +76,24 @@ HeatEquationParabolicPDESolverSystemParallelOMP::~HeatEquationParabolicPDESolver } void HeatEquationParabolicPDESolverSystemParallelOMP::applyMassMatrixComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); SGPP::base::DataVector temp(alpha.getSize()); - ((StdUpDown*)(this->OpMassBound))->multParallelBuildingBlock(alpha, temp); + reinterpret_cast(this->OpMassBound)->multParallelBuildingBlock(alpha, temp); result.add(temp); } void HeatEquationParabolicPDESolverSystemParallelOMP::applyLOperatorComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); SGPP::base::DataVector temp(alpha.getSize()); temp.setAll(0.0); - std::vector algoDims = - this->InnerGrid->getStorage()->getAlgorithmicDimensions(); + std::vector algoDims = this->InnerGrid->getStorage()->getAlgorithmicDimensions(); size_t nDims = algoDims.size(); #ifdef _OPENMP omp_lock_t Mutex; @@ -103,14 +102,15 @@ void HeatEquationParabolicPDESolverSystemParallelOMP::applyLOperatorComplete( // Apply Laplace, parallel in Dimensions for (size_t i = 0; i < nDims; i++) { - #pragma omp task firstprivate(i) shared(alpha, temp, result, algoDims) +#pragma omp task firstprivate(i) shared(alpha, temp, result, algoDims) { SGPP::base::DataVector myResult(result.getSize()); /// discuss methods in order to avoid this cast - ((UpDownOneOpDim*)(this->OpLaplaceBound))->multParallelBuildingBlock(alpha, myResult, algoDims[i]); + reinterpret_cast(this->OpLaplaceBound) + ->multParallelBuildingBlock(alpha, myResult, algoDims[i]); - // semaphore +// semaphore #ifdef _OPENMP omp_set_lock(&Mutex); #endif @@ -121,35 +121,34 @@ void HeatEquationParabolicPDESolverSystemParallelOMP::applyLOperatorComplete( } } - #pragma omp taskwait +#pragma omp taskwait #ifdef _OPENMP omp_destroy_lock(&Mutex); #endif - result.axpy((-1.0)*this->a, temp); + result.axpy((-1.0) * this->a, temp); } void HeatEquationParabolicPDESolverSystemParallelOMP::applyMassMatrixInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); SGPP::base::DataVector temp(alpha.getSize()); - ((StdUpDown*)(this->OpMassInner))->multParallelBuildingBlock(alpha, temp); + reinterpret_cast(this->OpMassInner)->multParallelBuildingBlock(alpha, temp); result.add(temp); } void HeatEquationParabolicPDESolverSystemParallelOMP::applyLOperatorInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); SGPP::base::DataVector temp(alpha.getSize()); temp.setAll(0.0); - std::vector algoDims = - this->InnerGrid->getStorage()->getAlgorithmicDimensions(); + std::vector algoDims = this->InnerGrid->getStorage()->getAlgorithmicDimensions(); size_t nDims = algoDims.size(); #ifdef _OPENMP omp_lock_t Mutex; @@ -158,14 +157,15 @@ void HeatEquationParabolicPDESolverSystemParallelOMP::applyLOperatorInner( // Apply Laplace, parallel in Dimensions for (size_t i = 0; i < nDims; i++) { - #pragma omp task firstprivate(i) shared(alpha, temp, result, algoDims) +#pragma omp task firstprivate(i) shared(alpha, temp, result, algoDims) { SGPP::base::DataVector myResult(result.getSize()); /// discuss methods in order to avoid this cast - ((UpDownOneOpDim*)(this->OpLaplaceInner))->multParallelBuildingBlock(alpha, myResult, algoDims[i]); + reinterpret_cast(this->OpLaplaceInner) + ->multParallelBuildingBlock(alpha, myResult, algoDims[i]); - // semaphore +// semaphore #ifdef _OPENMP omp_set_lock(&Mutex); #endif @@ -176,31 +176,26 @@ void HeatEquationParabolicPDESolverSystemParallelOMP::applyLOperatorInner( } } - #pragma omp taskwait +#pragma omp taskwait #ifdef _OPENMP omp_destroy_lock(&Mutex); #endif - result.axpy((-1.0)*this->a, temp); + result.axpy((-1.0) * this->a, temp); } void HeatEquationParabolicPDESolverSystemParallelOMP::finishTimestep() { // Replace the inner coefficients on the boundary grid - this->GridConverter->updateBoundaryCoefs(*this->alpha_complete, - *this->alpha_inner); -} - -void HeatEquationParabolicPDESolverSystemParallelOMP::coarsenAndRefine( - bool isLastTimestep) { + this->GridConverter->updateBoundaryCoefs(*this->alpha_complete, *this->alpha_inner); } +void HeatEquationParabolicPDESolverSystemParallelOMP::coarsenAndRefine(bool isLastTimestep) {} -void HeatEquationParabolicPDESolverSystemParallelOMP::startTimestep() { -} +void HeatEquationParabolicPDESolverSystemParallelOMP::startTimestep() {} -void HeatEquationParabolicPDESolverSystemParallelOMP::mult( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void HeatEquationParabolicPDESolverSystemParallelOMP::mult(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { result.setAll(0.0); if (this->tOperationMode == "ExEul") { @@ -209,57 +204,50 @@ void HeatEquationParabolicPDESolverSystemParallelOMP::mult( SGPP::base::DataVector temp(result.getSize()); SGPP::base::DataVector temp2(result.getSize()); - #pragma omp parallel shared(alpha, result, temp, temp2) +#pragma omp parallel shared(alpha, result, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha, temp) - { - applyMassMatrixInner(alpha, temp); - } +#pragma omp task shared(alpha, temp) + { applyMassMatrixInner(alpha, temp); } - #pragma omp task shared (alpha, temp2) - { - applyLOperatorInner(alpha, temp2); - } +#pragma omp task shared(alpha, temp2) + { applyLOperatorInner(alpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result.add(temp); - result.axpy((-1.0)*this->TimestepSize, temp2); + result.axpy((-1.0) * this->TimestepSize, temp2); } else if (this->tOperationMode == "CrNic") { SGPP::base::DataVector temp(result.getSize()); SGPP::base::DataVector temp2(result.getSize()); - #pragma omp parallel shared(alpha, result, temp, temp2) +#pragma omp parallel shared(alpha, result, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha, temp) - { - applyMassMatrixInner(alpha, temp); - } +#pragma omp task shared(alpha, temp) + { applyMassMatrixInner(alpha, temp); } - #pragma omp task shared (alpha, temp2) - { - applyLOperatorInner(alpha, temp2); - } +#pragma omp task shared(alpha, temp2) + { applyLOperatorInner(alpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result.add(temp); - result.axpy((-0.5)*this->TimestepSize, temp2); + result.axpy((-0.5) * this->TimestepSize, temp2); } else { - throw new SGPP::base::algorithm_exception(" HeatEquationParabolicPDESolverSystemParallelOMP::mult : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + " HeatEquationParabolicPDESolverSystemParallelOMP::mult : An unknown operation mode was " + "specified!"); } } -SGPP::base::DataVector* -HeatEquationParabolicPDESolverSystemParallelOMP::generateRHS() { +SGPP::base::DataVector* HeatEquationParabolicPDESolverSystemParallelOMP::generateRHS() { SGPP::base::DataVector rhs_complete(this->alpha_complete->getSize()); if (this->tOperationMode == "ExEul") { @@ -269,21 +257,17 @@ HeatEquationParabolicPDESolverSystemParallelOMP::generateRHS() { SGPP::base::DataVector temp2(rhs_complete.getSize()); SGPP::base::DataVector myAlpha(*this->alpha_complete); - #pragma omp parallel shared(myAlpha, temp, temp2) +#pragma omp parallel shared(myAlpha, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myAlpha, temp) - { - applyMassMatrixComplete(myAlpha, temp); - } +#pragma omp task shared(myAlpha, temp) + { applyMassMatrixComplete(myAlpha, temp); } - #pragma omp task shared (myAlpha, temp2) - { - applyLOperatorComplete(myAlpha, temp2); - } +#pragma omp task shared(myAlpha, temp2) + { applyLOperatorComplete(myAlpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } @@ -300,28 +284,26 @@ HeatEquationParabolicPDESolverSystemParallelOMP::generateRHS() { SGPP::base::DataVector temp2(rhs_complete.getSize()); SGPP::base::DataVector myAlpha(*this->alpha_complete); - #pragma omp parallel shared(myAlpha, temp, temp2) +#pragma omp parallel shared(myAlpha, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myAlpha, temp) - { - applyMassMatrixComplete(myAlpha, temp); - } +#pragma omp task shared(myAlpha, temp) + { applyMassMatrixComplete(myAlpha, temp); } - #pragma omp task shared (myAlpha, temp2) - { - applyLOperatorComplete(myAlpha, temp2); - } +#pragma omp task shared(myAlpha, temp2) + { applyLOperatorComplete(myAlpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } rhs_complete.add(temp); - rhs_complete.axpy((0.5)*this->TimestepSize, temp2); + rhs_complete.axpy((0.5) * this->TimestepSize, temp2); } else { - throw new SGPP::base::algorithm_exception("HeatEquationParabolicPDESolverSystemParallelOMP::generateRHS : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + "HeatEquationParabolicPDESolverSystemParallelOMP::generateRHS : An unknown operation mode " + "was specified!"); } this->startTimestep(); @@ -341,52 +323,46 @@ HeatEquationParabolicPDESolverSystemParallelOMP::generateRHS() { SGPP::base::DataVector temp(alpha_bound.getSize()); SGPP::base::DataVector temp2(alpha_bound.getSize()); - #pragma omp parallel shared(alpha_bound, temp, temp2) +#pragma omp parallel shared(alpha_bound, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha_bound, temp) - { - applyMassMatrixComplete(alpha_bound, temp); - } +#pragma omp task shared(alpha_bound, temp) + { applyMassMatrixComplete(alpha_bound, temp); } - #pragma omp task shared (alpha_bound, temp2) - { - applyLOperatorComplete(alpha_bound, temp2); - } +#pragma omp task shared(alpha_bound, temp2) + { applyLOperatorComplete(alpha_bound, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result_complete.add(temp); - result_complete.axpy((-1.0)*this->TimestepSize, temp2); + result_complete.axpy((-1.0) * this->TimestepSize, temp2); } else if (this->tOperationMode == "CrNic") { SGPP::base::DataVector temp(alpha_bound.getSize()); SGPP::base::DataVector temp2(alpha_bound.getSize()); - #pragma omp parallel shared(alpha_bound, temp, temp2) +#pragma omp parallel shared(alpha_bound, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha_bound, temp) - { - applyMassMatrixComplete(alpha_bound, temp); - } +#pragma omp task shared(alpha_bound, temp) + { applyMassMatrixComplete(alpha_bound, temp); } - #pragma omp task shared (alpha_bound, temp2) - { - applyLOperatorComplete(alpha_bound, temp2); - } +#pragma omp task shared(alpha_bound, temp2) + { applyLOperatorComplete(alpha_bound, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result_complete.add(temp); - result_complete.axpy((-0.5)*this->TimestepSize, temp2); + result_complete.axpy((-0.5) * this->TimestepSize, temp2); } else { - throw new SGPP::base::algorithm_exception("HeatEquationParabolicPDESolverSystemParallelOMP::generateRHS : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + "HeatEquationParabolicPDESolverSystemParallelOMP::generateRHS : An unknown operation mode " + "was specified!"); } rhs_complete.sub(result_complete); @@ -400,6 +376,5 @@ HeatEquationParabolicPDESolverSystemParallelOMP::generateRHS() { return this->rhs; } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystemParallelOMP.hpp b/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystemParallelOMP.hpp old mode 100755 new mode 100644 index 2ad6f66ba0..ef7e83caff --- a/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystemParallelOMP.hpp +++ b/pde/src/sgpp/pde/algorithm/HeatEquationParabolicPDESolverSystemParallelOMP.hpp @@ -12,6 +12,7 @@ #include +#include namespace SGPP { namespace pde { @@ -20,8 +21,8 @@ namespace pde { * This class implements the ParabolicPDESolverSystem for the * Heat Equation. */ -class HeatEquationParabolicPDESolverSystemParallelOMP : public - OperationParabolicPDESolverSystemDirichlet { +class HeatEquationParabolicPDESolverSystemParallelOMP + : public OperationParabolicPDESolverSystemDirichlet { protected: /// the heat coefficient float_t a; @@ -34,17 +35,13 @@ class HeatEquationParabolicPDESolverSystemParallelOMP : public /// the LTwoDotProduct Operation (Mass Matrix), on inner grid SGPP::base::OperationMatrix* OpMassInner; - void applyMassMatrixComplete(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + void applyMassMatrixComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - void applyLOperatorComplete(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + void applyLOperatorComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - void applyMassMatrixInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + void applyMassMatrixInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - void applyLOperatorInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + void applyLOperatorInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); public: /** @@ -54,12 +51,14 @@ class HeatEquationParabolicPDESolverSystemParallelOMP : public * @param alpha the sparse grid's coefficients * @param a the heat coefficient * @param TimestepSize the size of one timestep used in the ODE Solver - * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for explicit Euler, + * @param OperationMode specifies in which solver this matrix is used, valid values are: ExEul for + * explicit Euler, * ImEul for implicit Euler, CrNic for Crank Nicolson solver */ HeatEquationParabolicPDESolverSystemParallelOMP(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& alpha, float_t a, float_t TimestepSize, - std::string OperationMode = "ExEul"); + SGPP::base::DataVector& alpha, float_t a, + float_t TimestepSize, + std::string OperationMode = "ExEul"); /** * Std-Destructor @@ -72,13 +71,11 @@ class HeatEquationParabolicPDESolverSystemParallelOMP : public virtual void startTimestep(); - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual SGPP::base::DataVector* generateRHS(); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* HEATEQUATIONPARABOLICPDESOLVERSYSTEMPARALLELOMP_HPP */ \ No newline at end of file +#endif /* HEATEQUATIONPARABOLICPDESOLVERSYSTEMPARALLELOMP_HPP */ diff --git a/pde/src/sgpp/pde/algorithm/PoissonEquationEllipticPDESolverSystemDirichlet.cpp b/pde/src/sgpp/pde/algorithm/PoissonEquationEllipticPDESolverSystemDirichlet.cpp old mode 100755 new mode 100644 index 745c13a280..d4bf39603f --- a/pde/src/sgpp/pde/algorithm/PoissonEquationEllipticPDESolverSystemDirichlet.cpp +++ b/pde/src/sgpp/pde/algorithm/PoissonEquationEllipticPDESolverSystemDirichlet.cpp @@ -7,36 +7,32 @@ #include #include -using namespace SGPP::op_factory; - #include - namespace SGPP { namespace pde { PoissonEquationEllipticPDESolverSystemDirichlet::PoissonEquationEllipticPDESolverSystemDirichlet( - SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& rhs) : OperationEllipticPDESolverSystemDirichlet( - SparseGrid, rhs) { - this->Laplace_Complete = createOperationLaplace(*this->BoundGrid); - this->Laplace_Inner = createOperationLaplace(*this->InnerGrid); + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& rhs) + : OperationEllipticPDESolverSystemDirichlet(SparseGrid, rhs) { + this->Laplace_Complete = op_factory::createOperationLaplace(*this->BoundGrid); + this->Laplace_Inner = op_factory::createOperationLaplace(*this->InnerGrid); } -PoissonEquationEllipticPDESolverSystemDirichlet::~PoissonEquationEllipticPDESolverSystemDirichlet() { +PoissonEquationEllipticPDESolverSystemDirichlet:: + ~PoissonEquationEllipticPDESolverSystemDirichlet() { delete this->Laplace_Complete; delete this->Laplace_Inner; } void PoissonEquationEllipticPDESolverSystemDirichlet::applyLOperatorInner( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { Laplace_Inner->mult(alpha, result); } void PoissonEquationEllipticPDESolverSystemDirichlet::applyLOperatorComplete( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { Laplace_Complete->mult(alpha, result); } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/algorithm/PoissonEquationEllipticPDESolverSystemDirichlet.hpp b/pde/src/sgpp/pde/algorithm/PoissonEquationEllipticPDESolverSystemDirichlet.hpp old mode 100755 new mode 100644 index 1fc264e338..8e6427ea84 --- a/pde/src/sgpp/pde/algorithm/PoissonEquationEllipticPDESolverSystemDirichlet.hpp +++ b/pde/src/sgpp/pde/algorithm/PoissonEquationEllipticPDESolverSystemDirichlet.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -20,17 +19,15 @@ namespace pde { * * For the mult-routine only the Laplace-Operator is required */ -class PoissonEquationEllipticPDESolverSystemDirichlet : public - OperationEllipticPDESolverSystemDirichlet { +class PoissonEquationEllipticPDESolverSystemDirichlet + : public OperationEllipticPDESolverSystemDirichlet { protected: SGPP::base::OperationMatrix* Laplace_Inner; SGPP::base::OperationMatrix* Laplace_Complete; - void applyLOperatorComplete(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + void applyLOperatorComplete(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); - void applyLOperatorInner(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + void applyLOperatorInner(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); public: /** @@ -40,15 +37,14 @@ class PoissonEquationEllipticPDESolverSystemDirichlet : public * @param rhs the right hand side for solving the elliptic PDE */ PoissonEquationEllipticPDESolverSystemDirichlet(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& rhs); + SGPP::base::DataVector& rhs); /** * Destructor */ virtual ~PoissonEquationEllipticPDESolverSystemDirichlet(); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* POISSONEQUATIONELLIPTICPDESOLVERSYSTEMDIRICHLET_HPP */ \ No newline at end of file +#endif /* POISSONEQUATIONELLIPTICPDESOLVERSYSTEMDIRICHLET_HPP */ diff --git a/pde/src/sgpp/pde/algorithm/StdUpDown.cpp b/pde/src/sgpp/pde/algorithm/StdUpDown.cpp index e6c0308edc..aa3209244e 100644 --- a/pde/src/sgpp/pde/algorithm/StdUpDown.cpp +++ b/pde/src/sgpp/pde/algorithm/StdUpDown.cpp @@ -7,34 +7,29 @@ #include - namespace SGPP { namespace pde { -StdUpDown::StdUpDown(SGPP::base::GridStorage* storage) : storage(storage), - algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()) { -} +StdUpDown::StdUpDown(SGPP::base::GridStorage* storage) + : storage(storage), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()) {} -StdUpDown::~StdUpDown() { -} +StdUpDown::~StdUpDown() {} -void StdUpDown::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +void StdUpDown::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataVector beta(result.getSize()); result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait - { - this->updown(alpha, beta, this->numAlgoDims_ - 1); - } +#pragma omp single nowait + { this->updown(alpha, beta, this->numAlgoDims_ - 1); } } result.add(beta); } void StdUpDown::multParallelBuildingBlock(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { + SGPP::base::DataVector& result) { SGPP::base::DataVector beta(result.getSize()); result.setAll(0.0); @@ -43,49 +38,47 @@ void StdUpDown::multParallelBuildingBlock(SGPP::base::DataVector& alpha, result.add(beta); } -void StdUpDown::updown(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void StdUpDown::updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { size_t curNumAlgoDims = this->numAlgoDims_; size_t curMaxParallelDims = this->maxParallelDims_; - //Unidirectional scheme + // Unidirectional scheme if (dim > 0) { // Reordering ups and downs SGPP::base::DataVector temp(alpha.getSize()); SGPP::base::DataVector result_temp(alpha.getSize()); SGPP::base::DataVector temp_two(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) { up(alpha, temp, this->algoDims[dim]); updown(temp, result, dim - 1); } - - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, result_temp) - { +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, \ + result_temp) + { // NOLINT(whitespace/braces) updown(alpha, temp_two, dim - 1); down(temp_two, result_temp, this->algoDims[dim]); } - #pragma omp taskwait +#pragma omp taskwait result.add(result_temp); } else { // Terminates dimension recursion SGPP::base::DataVector temp(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) up(alpha, result, this->algoDims[dim]); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) down(alpha, temp, this->algoDims[dim]); - #pragma omp taskwait +#pragma omp taskwait result.add(temp); } } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/algorithm/StdUpDown.hpp b/pde/src/sgpp/pde/algorithm/StdUpDown.hpp index af107dd4ea..72aa798251 100644 --- a/pde/src/sgpp/pde/algorithm/StdUpDown.hpp +++ b/pde/src/sgpp/pde/algorithm/StdUpDown.hpp @@ -6,8 +6,6 @@ #ifndef STDUPDOWN_HPP #define STDUPDOWN_HPP -#include - #include #include #include @@ -18,6 +16,7 @@ #include +#include namespace SGPP { namespace pde { @@ -26,23 +25,21 @@ namespace pde { * Implements a standard Up/Down Schema without any operation dim. * */ -class StdUpDown: public SGPP::base::OperationMatrix { +class StdUpDown : public SGPP::base::OperationMatrix { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - StdUpDown(SGPP::base::GridStorage* storage); + explicit StdUpDown(SGPP::base::GridStorage* storage); /** * Destructor */ virtual ~StdUpDown(); - - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** * this functions provides the same functionality as the normal mult routine. @@ -58,9 +55,7 @@ class StdUpDown: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - void multParallelBuildingBlock(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); - + void multParallelBuildingBlock(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); protected: typedef SGPP::base::GridStorage::grid_iterator grid_iterator; @@ -81,8 +76,7 @@ class StdUpDown: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - void updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + void updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * 1D up Operation @@ -91,8 +85,7 @@ class StdUpDown: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim) = 0; + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D down Operation @@ -101,11 +94,9 @@ class StdUpDown: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim) = 0; + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* STDUPDOWN_HPP */ \ No newline at end of file +#endif /* STDUPDOWN_HPP */ diff --git a/pde/src/sgpp/pde/algorithm/UpDownFourOpDims.cpp b/pde/src/sgpp/pde/algorithm/UpDownFourOpDims.cpp index 115cb0748f..b9ee10b391 100644 --- a/pde/src/sgpp/pde/algorithm/UpDownFourOpDims.cpp +++ b/pde/src/sgpp/pde/algorithm/UpDownFourOpDims.cpp @@ -7,106 +7,88 @@ #include - namespace SGPP { namespace pde { -UpDownFourOpDims::UpDownFourOpDims(SGPP::base::GridStorage* storage, - float_t**** * coef) : storage(storage), coefs((*coef)), - algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()) { +UpDownFourOpDims::UpDownFourOpDims(SGPP::base::GridStorage* storage, float_t***** coef) + : storage(storage), + coefs((*coef)), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()) { generateMap(); } -UpDownFourOpDims::UpDownFourOpDims(SGPP::base::GridStorage* storage) : storage( - storage), coefs(NULL), algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()) { +UpDownFourOpDims::UpDownFourOpDims(SGPP::base::GridStorage* storage) + : storage(storage), + coefs(NULL), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()) { generateMap(); } -UpDownFourOpDims::~UpDownFourOpDims() { -} +UpDownFourOpDims::~UpDownFourOpDims() {} void UpDownFourOpDims::generateMap() { // Build the function mapping // unidirectional... - fnMap.insert( std::make_pair( 0, - &SGPP::pde::UpDownFourOpDims::specialOpUnidirectional )); + fnMap.insert(std::make_pair(0, &SGPP::pde::UpDownFourOpDims::specialOpUnidirectional)); // singles... - fnMap.insert( std::make_pair( 1, &SGPP::pde::UpDownFourOpDims::specialOpFour )); - fnMap.insert( std::make_pair( 2, - &SGPP::pde::UpDownFourOpDims::specialOpThree )); - fnMap.insert( std::make_pair( 4, &SGPP::pde::UpDownFourOpDims::specialOpTwo )); - fnMap.insert( std::make_pair( 8, &SGPP::pde::UpDownFourOpDims::specialOpOne )); + fnMap.insert(std::make_pair(1, &SGPP::pde::UpDownFourOpDims::specialOpFour)); + fnMap.insert(std::make_pair(2, &SGPP::pde::UpDownFourOpDims::specialOpThree)); + fnMap.insert(std::make_pair(4, &SGPP::pde::UpDownFourOpDims::specialOpTwo)); + fnMap.insert(std::make_pair(8, &SGPP::pde::UpDownFourOpDims::specialOpOne)); // float_ts - fnMap.insert( std::make_pair( 3, - &SGPP::pde::UpDownFourOpDims::specialOpThreeAndOpFour )); - fnMap.insert( std::make_pair( 5, - &SGPP::pde::UpDownFourOpDims::specialOpTwoAndOpFour )); - fnMap.insert( std::make_pair( 6, - &SGPP::pde::UpDownFourOpDims::specialOpTwoAndOpThree )); - fnMap.insert( std::make_pair( 9, - &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpFour )); - fnMap.insert( std::make_pair( 10, - &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpThree )); - fnMap.insert( std::make_pair( 12, - &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpTwo )); + fnMap.insert(std::make_pair(3, &SGPP::pde::UpDownFourOpDims::specialOpThreeAndOpFour)); + fnMap.insert(std::make_pair(5, &SGPP::pde::UpDownFourOpDims::specialOpTwoAndOpFour)); + fnMap.insert(std::make_pair(6, &SGPP::pde::UpDownFourOpDims::specialOpTwoAndOpThree)); + fnMap.insert(std::make_pair(9, &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpFour)); + fnMap.insert(std::make_pair(10, &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpThree)); + fnMap.insert(std::make_pair(12, &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpTwo)); // triples - fnMap.insert( std::make_pair( 7, - &SGPP::pde::UpDownFourOpDims::specialOpTwoAndOpThreeAndOpFour )); - fnMap.insert( std::make_pair( 11, - &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpThreeAndOpFour )); - fnMap.insert( std::make_pair( 13, - &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpTwoAndOpFour )); - fnMap.insert( std::make_pair( 14, - &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpTwoAndOpThree )); + fnMap.insert(std::make_pair(7, &SGPP::pde::UpDownFourOpDims::specialOpTwoAndOpThreeAndOpFour)); + fnMap.insert(std::make_pair(11, &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpThreeAndOpFour)); + fnMap.insert(std::make_pair(13, &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpTwoAndOpFour)); + fnMap.insert(std::make_pair(14, &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpTwoAndOpThree)); // quadruple - fnMap.insert( std::make_pair( 15, - &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpTwoAndOpThreeAndOpFour )); + fnMap.insert( + std::make_pair(15, &SGPP::pde::UpDownFourOpDims::specialOpOneAndOpTwoAndOpThreeAndOpFour)); } -void UpDownFourOpDims::updown(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { +void UpDownFourOpDims::updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, + size_t op_dim_four) { size_t num = 0; - if (dim == op_dim_one) - num += 8; + if (dim == op_dim_one) num += 8; - if (dim == op_dim_two) - num += 4; + if (dim == op_dim_two) num += 4; - if (dim == op_dim_three) - num += 2; + if (dim == op_dim_three) num += 2; - if (dim == op_dim_four) - num += 1; + if (dim == op_dim_four) num += 1; // Call the relevant function... MFP fp = fnMap[num]; - (this->*fp)(alpha, result, dim, op_dim_one, op_dim_two, op_dim_three, - op_dim_four); + (this->*fp)(alpha, result, dim, op_dim_one, op_dim_two, op_dim_three, op_dim_four); } -void UpDownFourOpDims::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +void UpDownFourOpDims::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { for (size_t k = 0; k < this->numAlgoDims_; k++) { for (size_t l = 0; l < this->numAlgoDims_; l++) { - - #pragma omp task firstprivate(i, j) shared(alpha, result) +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -114,224 +96,213 @@ void UpDownFourOpDims::mult(SGPP::base::DataVector& alpha, if (this->coefs[i][j][k][l] != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j, k, l); - #pragma omp critical - { - result.axpy(this->coefs[i][j][k][l], beta); - } +#pragma omp critical + { result.axpy(this->coefs[i][j][k][l], beta); } } - } else - { + } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j, k, l); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } - } } } } - #pragma omp taskwait +#pragma omp taskwait } } } -void UpDownFourOpDims::specialOpX(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, - void (SGPP::pde::UpDownFourOpDims::*pt2UpFunc)(SGPP::base::DataVector&, - SGPP::base::DataVector&, size_t), - void (SGPP::pde::UpDownFourOpDims::*pt2DownFunc)(SGPP::base::DataVector&, - SGPP::base::DataVector&, size_t), size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { +void UpDownFourOpDims::specialOpX( + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + void (SGPP::pde::UpDownFourOpDims::*pt2UpFunc)(SGPP::base::DataVector&, SGPP::base::DataVector&, + size_t), + void (SGPP::pde::UpDownFourOpDims::*pt2DownFunc)(SGPP::base::DataVector&, + SGPP::base::DataVector&, size_t), + size_t dim, size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { size_t curNumAlgoDims = this->numAlgoDims_; size_t curMaxParallelDims = this->maxParallelDims_; - //Unidirectional scheme + // Unidirectional scheme if (dim > 0) { // Reordering ups and downs SGPP::base::DataVector temp(alpha.getSize()); SGPP::base::DataVector result_temp(alpha.getSize()); SGPP::base::DataVector temp_two(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) { (this->*pt2UpFunc)(alpha, temp, this->algoDims[dim]); - updown(temp, result, dim - 1, op_dim_one, op_dim_two, op_dim_three, - op_dim_four); + updown(temp, result, dim - 1, op_dim_one, op_dim_two, op_dim_three, op_dim_four); } - // Same from the other direction: - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, result_temp) - { - updown(alpha, temp_two, dim - 1, op_dim_one, op_dim_two, op_dim_three, - op_dim_four); +// Same from the other direction: +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, \ + result_temp) + { // NOLINT(whitespace/braces) + updown(alpha, temp_two, dim - 1, op_dim_one, op_dim_two, op_dim_three, op_dim_four); (this->*pt2DownFunc)(temp_two, result_temp, this->algoDims[dim]); } - #pragma omp taskwait +#pragma omp taskwait result.add(result_temp); } else { // Terminates dimension recursion SGPP::base::DataVector temp(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) (this->*pt2UpFunc)(alpha, result, this->algoDims[dim]); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) (this->*pt2DownFunc)(alpha, temp, this->algoDims[dim]); - #pragma omp taskwait +#pragma omp taskwait result.add(temp); } } void UpDownFourOpDims::specialOpUnidirectional(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { - specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::up, - &SGPP::pde::UpDownFourOpDims::down, dim, op_dim_one, op_dim_two, op_dim_three, - op_dim_four); + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { + specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::up, &SGPP::pde::UpDownFourOpDims::down, + dim, op_dim_one, op_dim_two, op_dim_three, op_dim_four); } -void UpDownFourOpDims::specialOpOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { +void UpDownFourOpDims::specialOpOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimOne, - &SGPP::pde::UpDownFourOpDims::downOpDimOne, dim, op_dim_one, op_dim_two, - op_dim_three, op_dim_four); + &SGPP::pde::UpDownFourOpDims::downOpDimOne, dim, op_dim_one, op_dim_two, op_dim_three, + op_dim_four); } -void UpDownFourOpDims::specialOpTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { +void UpDownFourOpDims::specialOpTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimTwo, - &SGPP::pde::UpDownFourOpDims::downOpDimTwo, dim, op_dim_one, op_dim_two, - op_dim_three, op_dim_four); - + &SGPP::pde::UpDownFourOpDims::downOpDimTwo, dim, op_dim_one, op_dim_two, op_dim_three, + op_dim_four); } -void UpDownFourOpDims::specialOpThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { +void UpDownFourOpDims::specialOpThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimThree, &SGPP::pde::UpDownFourOpDims::downOpDimThree, dim, op_dim_one, op_dim_two, op_dim_three, op_dim_four); } -void UpDownFourOpDims::specialOpFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { +void UpDownFourOpDims::specialOpFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimFour, - &SGPP::pde::UpDownFourOpDims::downOpDimFour, dim, op_dim_one, op_dim_two, - op_dim_three, op_dim_four); + &SGPP::pde::UpDownFourOpDims::downOpDimFour, dim, op_dim_one, op_dim_two, op_dim_three, + op_dim_four); } void UpDownFourOpDims::specialOpOneAndOpTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimOneAndOpDimTwo, - &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimTwo, dim, op_dim_one, - op_dim_two, op_dim_three, op_dim_four); + &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimTwo, dim, op_dim_one, op_dim_two, + op_dim_three, op_dim_four); } void UpDownFourOpDims::specialOpOneAndOpThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimOneAndOpDimThree, - &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimThree, dim, op_dim_one, - op_dim_two, op_dim_three, op_dim_four); + &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimThree, dim, op_dim_one, op_dim_two, + op_dim_three, op_dim_four); } void UpDownFourOpDims::specialOpOneAndOpFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimOneAndOpDimFour, - &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimFour, dim, op_dim_one, - op_dim_two, op_dim_three, op_dim_four); + &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimFour, dim, op_dim_one, op_dim_two, + op_dim_three, op_dim_four); } void UpDownFourOpDims::specialOpTwoAndOpThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimTwoAndOpDimThree, - &SGPP::pde::UpDownFourOpDims::downOpDimTwoAndOpDimThree, dim, op_dim_one, - op_dim_two, op_dim_three, op_dim_four); + &SGPP::pde::UpDownFourOpDims::downOpDimTwoAndOpDimThree, dim, op_dim_one, op_dim_two, + op_dim_three, op_dim_four); } void UpDownFourOpDims::specialOpTwoAndOpFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimTwoAndOpDimFour, - &SGPP::pde::UpDownFourOpDims::downOpDimTwoAndOpDimFour, dim, op_dim_one, - op_dim_two, op_dim_three, op_dim_four); + &SGPP::pde::UpDownFourOpDims::downOpDimTwoAndOpDimFour, dim, op_dim_one, op_dim_two, + op_dim_three, op_dim_four); } void UpDownFourOpDims::specialOpThreeAndOpFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { - specialOpX(alpha, result, - &SGPP::pde::UpDownFourOpDims::upOpDimThreeAndOpDimFour, - &SGPP::pde::UpDownFourOpDims::downOpDimThreeAndOpDimFour, dim, op_dim_one, - op_dim_two, op_dim_three, op_dim_four); + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { + specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimThreeAndOpDimFour, + &SGPP::pde::UpDownFourOpDims::downOpDimThreeAndOpDimFour, dim, op_dim_one, op_dim_two, + op_dim_three, op_dim_four); } -void UpDownFourOpDims::specialOpOneAndOpTwoAndOpThree( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, - size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, - size_t op_dim_four) { - specialOpX(alpha, result, - &SGPP::pde::UpDownFourOpDims::upOpDimOneAndOpDimTwoAndOpDimThree, - &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimTwoAndOpDimThree, dim, - op_dim_one, op_dim_two, op_dim_three, op_dim_four); +void UpDownFourOpDims::specialOpOneAndOpTwoAndOpThree(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { + specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimOneAndOpDimTwoAndOpDimThree, + &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimTwoAndOpDimThree, dim, op_dim_one, + op_dim_two, op_dim_three, op_dim_four); } -void UpDownFourOpDims::specialOpOneAndOpTwoAndOpFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, - size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, - size_t op_dim_four) { - specialOpX(alpha, result, - &SGPP::pde::UpDownFourOpDims::upOpDimOneAndOpDimTwoAndOpDimFour, - &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimTwoAndOpDimFour, dim, - op_dim_one, op_dim_two, op_dim_three, op_dim_four); +void UpDownFourOpDims::specialOpOneAndOpTwoAndOpFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { + specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimOneAndOpDimTwoAndOpDimFour, + &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimTwoAndOpDimFour, dim, op_dim_one, + op_dim_two, op_dim_three, op_dim_four); } -void UpDownFourOpDims::specialOpOneAndOpThreeAndOpFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, - size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, - size_t op_dim_four) { - specialOpX(alpha, result, - &SGPP::pde::UpDownFourOpDims::upOpDimOneAndOpDimThreeAndOpDimFour, - &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimThreeAndOpDimFour, dim, - op_dim_one, op_dim_two, op_dim_three, op_dim_four); +void UpDownFourOpDims::specialOpOneAndOpThreeAndOpFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { + specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimOneAndOpDimThreeAndOpDimFour, + &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimThreeAndOpDimFour, dim, op_dim_one, + op_dim_two, op_dim_three, op_dim_four); } -void UpDownFourOpDims::specialOpTwoAndOpThreeAndOpFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, - size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, - size_t op_dim_four) { - specialOpX(alpha, result, - &SGPP::pde::UpDownFourOpDims::upOpDimTwoAndOpDimThreeAndOpDimFour, - &SGPP::pde::UpDownFourOpDims::downOpDimTwoAndOpDimThreeAndOpDimFour, dim, - op_dim_one, op_dim_two, op_dim_three, op_dim_four); +void UpDownFourOpDims::specialOpTwoAndOpThreeAndOpFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four) { + specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimTwoAndOpDimThreeAndOpDimFour, + &SGPP::pde::UpDownFourOpDims::downOpDimTwoAndOpDimThreeAndOpDimFour, dim, op_dim_one, + op_dim_two, op_dim_three, op_dim_four); } void UpDownFourOpDims::specialOpOneAndOpTwoAndOpThreeAndOpFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, - size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, - size_t op_dim_four) { + SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, + size_t op_dim_two, size_t op_dim_three, size_t op_dim_four) { specialOpX(alpha, result, &SGPP::pde::UpDownFourOpDims::upOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour, - &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour, - dim, op_dim_one, op_dim_two, op_dim_three, op_dim_four); -} - - - + &SGPP::pde::UpDownFourOpDims::downOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour, dim, + op_dim_one, op_dim_two, op_dim_three, op_dim_four); } -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/algorithm/UpDownFourOpDims.hpp b/pde/src/sgpp/pde/algorithm/UpDownFourOpDims.hpp index 4bf8b85ec8..7404119c56 100644 --- a/pde/src/sgpp/pde/algorithm/UpDownFourOpDims.hpp +++ b/pde/src/sgpp/pde/algorithm/UpDownFourOpDims.hpp @@ -6,9 +6,6 @@ #ifndef UPDOWNFOUROPDIMS_HPP #define UPDOWNFOUROPDIMS_HPP -#include -#include - #include #include #include @@ -20,6 +17,8 @@ #include +#include +#include namespace SGPP { namespace pde { @@ -28,7 +27,7 @@ namespace pde { * Implements the Up/Down scheme with four dimensions with special operations: i,j,k,l * */ -class UpDownFourOpDims: public SGPP::base::OperationMatrix { +class UpDownFourOpDims : public SGPP::base::OperationMatrix { public: /** * Constructor @@ -36,30 +35,29 @@ class UpDownFourOpDims: public SGPP::base::OperationMatrix { * @param storage the grid's SGPP::base::GridStorage object * @param coef 4d tensor that contains the constant coefficients of this operation */ - UpDownFourOpDims(SGPP::base::GridStorage* storage, float_t**** * coef); + UpDownFourOpDims(SGPP::base::GridStorage* storage, float_t***** coef); /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - UpDownFourOpDims(SGPP::base::GridStorage* storage); + explicit UpDownFourOpDims(SGPP::base::GridStorage* storage); /** * Destructor */ virtual ~UpDownFourOpDims(); - - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); protected: typedef SGPP::base::GridStorage::grid_iterator grid_iterator; - /// Function pointer type. This is used in fnMap to map the particular dimension situation to the relevant method handler. - typedef void (SGPP::pde::UpDownFourOpDims::*MFP)(SGPP::base::DataVector&, - SGPP::base::DataVector&, size_t, size_t, size_t, size_t, size_t); + /// Function pointer type. This is used in fnMap to map the particular dimension situation to the + /// relevant method handler. + typedef void (SGPP::pde::UpDownFourOpDims::*MFP)(SGPP::base::DataVector&, SGPP::base::DataVector&, + size_t, size_t, size_t, size_t, size_t); /// Pointer to the grid's storage object SGPP::base::GridStorage* storage; @@ -72,7 +70,8 @@ class UpDownFourOpDims: public SGPP::base::OperationMatrix { /// max number of parallel stages (dimension recursive calls) static const size_t maxParallelDims_ = TASKS_PARALLEL_UPDOWN; - /// Map of integer to function pointer. This is used to map the dimension situation to the relevant method handler. + /// Map of integer to function pointer. This is used to map the dimension situation to the + /// relevant method handler. std::map fnMap; /** @@ -91,34 +90,31 @@ class UpDownFourOpDims: public SGPP::base::OperationMatrix { * @param op_dim_three the dimension in which to use the third gradient * @param op_dim_four the dimension in which to use the fourth gradient */ - void updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim, size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, - size_t op_dim_four); + void updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); // Unidirectional - void specialOpUnidirectional(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + void specialOpUnidirectional(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four); // Singles - void specialOpOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim, size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, - size_t op_dim_four); - void specialOpTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim, size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, - size_t op_dim_four); - void specialOpThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); - void specialOpFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + void specialOpOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + void specialOpTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + void specialOpThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, + size_t op_dim_four); + void specialOpFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); void specialOpX(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, void (SGPP::pde::UpDownFourOpDims::*pt2UpFunc)(SGPP::base::DataVector&, - SGPP::base::DataVector&, size_t), + SGPP::base::DataVector&, size_t), void (SGPP::pde::UpDownFourOpDims::*pt2DownFunc)(SGPP::base::DataVector&, - SGPP::base::DataVector&, size_t), size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + SGPP::base::DataVector&, size_t), + size_t dim, size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, + size_t op_dim_four); // Doubles @@ -133,90 +129,103 @@ class UpDownFourOpDims: public SGPP::base::OperationMatrix { * @param op_dim_three the dimension in which to use the third gradient * @param op_dim_four the dimension in which to use the fourth gradient */ - void specialOpOneAndOpTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + void specialOpOneAndOpTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, + size_t op_dim_four); /** * If the current dimension is equal to the both special operation dimensions one and three. - * For an explanation of the parameters of this method, see the documentation for the method specialOpOneAndOpTwo in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * specialOpOneAndOpTwo in this class. */ - void specialOpOneAndOpThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + void specialOpOneAndOpThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, + size_t op_dim_four); /** * If the current dimension is equal to the both special operation dimensions one and four. - * For an explanation of the parameters of this method, see the documentation for the method specialOpOneAndOpTwo in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * specialOpOneAndOpTwo in this class. */ - void specialOpOneAndOpFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + void specialOpOneAndOpFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, + size_t op_dim_four); /** * If the current dimension is equal to the both special operation dimensions two and three. - * For an explanation of the parameters of this method, see the documentation for the method specialOpOneAndOpTwo in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * specialOpOneAndOpTwo in this class. */ - void specialOpTwoAndOpThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + void specialOpTwoAndOpThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, + size_t op_dim_four); /** * If the current dimension is equal to the both special operation dimensions two and four. - * For an explanation of the parameters of this method, see the documentation for the method specialOpOneAndOpTwo in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * specialOpOneAndOpTwo in this class. */ - void specialOpTwoAndOpFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + void specialOpTwoAndOpFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, + size_t op_dim_four); /** * If the current dimension is equal to the both special operation dimensions three and four. - * For an explanation of the parameters of this method, see the documentation for the method specialOpOneAndOpTwo in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * specialOpOneAndOpTwo in this class. */ - void specialOpThreeAndOpFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + void specialOpThreeAndOpFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four); /** * If the current dimension is equal to the all special operation dimensions one, two and three. - * For an explanation of the parameters of this method, see the documentation for the method specialOpOneAndOpTwo in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * specialOpOneAndOpTwo in this class. */ - void specialOpOneAndOpTwoAndOpThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + void specialOpOneAndOpTwoAndOpThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four); /** * If the current dimension is equal to the all special operation dimensions one, two and four. - * For an explanation of the parameters of this method, see the documentation for the method specialOpOneAndOpTwo in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * specialOpOneAndOpTwo in this class. */ - void specialOpOneAndOpTwoAndOpFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + void specialOpOneAndOpTwoAndOpFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four); /** * If the current dimension is equal to the all special operation dimensions one, three and four. - * For an explanation of the parameters of this method, see the documentation for the method specialOpOneAndOpTwo in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * specialOpOneAndOpTwo in this class. */ void specialOpOneAndOpThreeAndOpFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, + size_t op_dim_four); /** * If the current dimension is equal to the all special operation dimensions two, three and four. - * For an explanation of the parameters of this method, see the documentation for the method specialOpOneAndOpTwo in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * specialOpOneAndOpTwo in this class. */ void specialOpTwoAndOpThreeAndOpFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, size_t op_dim_three, + size_t op_dim_four); /** - * If the current dimension is equal to the all special operation dimensions one, two, three and four. - * For an explanation of the parameters of this method, see the documentation for the method specialOpOneAndOpTwo in this class. + * If the current dimension is equal to the all special operation dimensions one, two, three and + * four. + * For an explanation of the parameters of this method, see the documentation for the method + * specialOpOneAndOpTwo in this class. */ void specialOpOneAndOpTwoAndOpThreeAndOpFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two, size_t op_dim_three, size_t op_dim_four); - + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two, + size_t op_dim_three, size_t op_dim_four); /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -227,8 +236,7 @@ class UpDownFourOpDims: public SGPP::base::OperationMatrix { * @param result vector to store the results in * @param dim dimension in which to apply the up-part */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim) = 0; + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -239,8 +247,7 @@ class UpDownFourOpDims: public SGPP::base::OperationMatrix { * @param result vector to store the results in * @param dim dimension in which to apply the down-part */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim) = 0; + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D down if the current dim is equal to i. @@ -249,215 +256,246 @@ class UpDownFourOpDims: public SGPP::base::OperationMatrix { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D up if the current dim is equal to i. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D down if the current dim is equal to j. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D up if the current dim is equal to j. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D down if the current dim is equal to k. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void downOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void downOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D up if the current dim is equal to k. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void upOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D down if the current dim is equal to l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void downOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void downOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D up if the current dim is equal to l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void upOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D down if the current dim is equal to i and j. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void downOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D up if the current dim is equal to i and j. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D down if the current dim is equal to i and k. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void downOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D up if the current dim is equal to i and k. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void upOpDimOneAndOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D down if the current dim is equal to i and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void downOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D up if the current dim is equal to i and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void upOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDimOneAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D down if the current dim is equal to j and k. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void downOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D up if the current dim is equal to j and k. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void upOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D down if the current dim is equal to j and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void downOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D up if the current dim is equal to j and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void upOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D down if the current dim is equal to k and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void downOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D up if the current dim is equal to k and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void upOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D down if the current dim is equal to i and j and k. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void downOpDimOneAndOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D up if the current dim is equal to i and j and k. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void upOpDimOneAndOpDimTwoAndOpDimThree(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D down if the current dim is equal to i and j and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void downOpDimOneAndOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D up if the current dim is equal to i and j and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void upOpDimOneAndOpDimTwoAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D down if the current dim is equal to i and k and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void downOpDimOneAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) = 0; + virtual void downOpDimOneAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D up if the current dim is equal to i and k and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void upOpDimOneAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D down if the current dim is equal to j and k and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void downOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) = 0; + virtual void downOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D up if the current dim is equal to j and k and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ virtual void upOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; - + SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D down if the current dim is equal to i and j and k and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void downOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; + virtual void downOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D up if the current dim is equal to i and j and k and l. - * For an explanation of the parameters of this method, see the documentation for the method downOpDimOne in this class. + * For an explanation of the parameters of this method, see the documentation for the method + * downOpDimOne in this class. */ - virtual void upOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDimOneAndOpDimTwoAndOpDimThreeAndOpDimFour(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) = 0; }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* UPDOWNFOUROPDIMS_HPP */ \ No newline at end of file +#endif /* UPDOWNFOUROPDIMS_HPP */ diff --git a/pde/src/sgpp/pde/algorithm/UpDownOneOpDim.cpp b/pde/src/sgpp/pde/algorithm/UpDownOneOpDim.cpp index 22da2875e5..da688ddf88 100644 --- a/pde/src/sgpp/pde/algorithm/UpDownOneOpDim.cpp +++ b/pde/src/sgpp/pde/algorithm/UpDownOneOpDim.cpp @@ -7,34 +7,32 @@ #include - namespace SGPP { namespace pde { -UpDownOneOpDim::UpDownOneOpDim(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : storage(storage), coefs(&coef), - algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()) { -} +UpDownOneOpDim::UpDownOneOpDim(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef) + : storage(storage), + coefs(&coef), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()) {} -UpDownOneOpDim::UpDownOneOpDim(SGPP::base::GridStorage* storage): storage( - storage), coefs(NULL), algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()) { -} +UpDownOneOpDim::UpDownOneOpDim(SGPP::base::GridStorage* storage) + : storage(storage), + coefs(NULL), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()) {} -UpDownOneOpDim::~UpDownOneOpDim() { -} +UpDownOneOpDim::~UpDownOneOpDim() {} -void UpDownOneOpDim::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +void UpDownOneOpDim::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { - #pragma omp task firstprivate(i) shared(alpha, result) +#pragma omp task firstprivate(i) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -42,31 +40,26 @@ void UpDownOneOpDim::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i); - #pragma omp critical - { - result.axpy(this->coefs->get(i), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i), beta); } } - } else - { + } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } - #pragma omp taskwait +#pragma omp taskwait } } - } void UpDownOneOpDim::multParallelBuildingBlock(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t operationDim) { + SGPP::base::DataVector& result, + size_t operationDim) { result.setAll(0.0); SGPP::base::DataVector beta(result.getSize()); @@ -84,98 +77,98 @@ void UpDownOneOpDim::multParallelBuildingBlock(SGPP::base::DataVector& alpha, } } -void UpDownOneOpDim::updown(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim) { +void UpDownOneOpDim::updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim) { size_t curNumAlgoDims = this->numAlgoDims_; size_t curMaxParallelDims = this->maxParallelDims_; if (dim == op_dim) { specialOP(alpha, result, dim, op_dim); } else { - //Unidirectional scheme + // Unidirectional scheme if (dim > 0) { // Reordering ups and downs SGPP::base::DataVector temp(alpha.getSize()); SGPP::base::DataVector result_temp(alpha.getSize()); SGPP::base::DataVector temp_two(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) { up(alpha, temp, this->algoDims[dim]); updown(temp, result, dim - 1, op_dim); } - // Same from the other direction: - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, result_temp) - { +// Same from the other direction: +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, \ + result_temp) + { // NOLINT(whitespace/braces) updown(alpha, temp_two, dim - 1, op_dim); down(temp_two, result_temp, this->algoDims[dim]); } - #pragma omp taskwait +#pragma omp taskwait result.add(result_temp); } else { // Terminates dimension recursion SGPP::base::DataVector temp(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) up(alpha, result, this->algoDims[dim]); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) down(alpha, temp, this->algoDims[dim]); - #pragma omp taskwait +#pragma omp taskwait result.add(temp); } - } } -void UpDownOneOpDim::specialOP(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim) { +void UpDownOneOpDim::specialOP(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim) { size_t curNumAlgoDims = this->numAlgoDims_; size_t curMaxParallelDims = this->maxParallelDims_; - //Unidirectional scheme + // Unidirectional scheme if (dim > 0) { // Reordering ups and downs SGPP::base::DataVector temp(alpha.getSize()); SGPP::base::DataVector result_temp(alpha.getSize()); SGPP::base::DataVector temp_two(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) { upOpDim(alpha, temp, this->algoDims[dim]); updown(temp, result, dim - 1, op_dim); } - // Same from the other direction: - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, result_temp) - { +// Same from the other direction: +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, \ + result_temp) + { // NOLINT(whitespace/braces) updown(alpha, temp_two, dim - 1, op_dim); downOpDim(temp_two, result_temp, this->algoDims[dim]); } - #pragma omp taskwait +#pragma omp taskwait result.add(result_temp); } else { // Terminates dimension recursion SGPP::base::DataVector temp(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) upOpDim(alpha, result, this->algoDims[dim]); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) downOpDim(alpha, temp, this->algoDims[dim]); - #pragma omp taskwait +#pragma omp taskwait result.add(temp); } } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/algorithm/UpDownOneOpDim.hpp b/pde/src/sgpp/pde/algorithm/UpDownOneOpDim.hpp index 0b22360f5f..a26e0c2128 100644 --- a/pde/src/sgpp/pde/algorithm/UpDownOneOpDim.hpp +++ b/pde/src/sgpp/pde/algorithm/UpDownOneOpDim.hpp @@ -6,8 +6,6 @@ #ifndef UPDOWNONEOPDIM_HPP #define UPDOWNONEOPDIM_HPP -#include - #include #include #include @@ -18,6 +16,7 @@ #include +#include namespace SGPP { namespace pde { @@ -28,13 +27,14 @@ namespace pde { * Parallelization with OpenMP 2 / 3 is supported! * */ -class UpDownOneOpDim: public SGPP::base::OperationMatrix { +class UpDownOneOpDim : public SGPP::base::OperationMatrix { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients; one per dimension + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients; one per dimension */ UpDownOneOpDim(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); @@ -43,15 +43,14 @@ class UpDownOneOpDim: public SGPP::base::OperationMatrix { * * @param storage the grid's SGPP::base::GridStorage object */ - UpDownOneOpDim(SGPP::base::GridStorage* storage); + explicit UpDownOneOpDim(SGPP::base::GridStorage* storage); /** * Destructor */ virtual ~UpDownOneOpDim(); - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** * This functions provides the same functionality as the normal mult routine. @@ -72,9 +71,8 @@ class UpDownOneOpDim: public SGPP::base::OperationMatrix { * @param result vector to store the results in * @param operationDim Dimension in which the special operator is applied */ - void multParallelBuildingBlock(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t operationDim); - + void multParallelBuildingBlock(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t operationDim); protected: typedef SGPP::base::GridStorage::grid_iterator grid_iterator; @@ -98,8 +96,8 @@ class UpDownOneOpDim: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - void updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim, size_t op_dim); + void updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t op_dim); /** * All calculations for gradient_dim, parallel version using OpenMP 3 @@ -109,8 +107,8 @@ class UpDownOneOpDim: public SGPP::base::OperationMatrix { * @param dim the current dimension in the recursion * @param op_dim the dimension in that a special operation is applied */ - virtual void specialOP(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim); + virtual void specialOP(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t op_dim); /** * std 1D up operation @@ -119,8 +117,7 @@ class UpDownOneOpDim: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim) = 0; + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * std 1D down operation @@ -129,8 +126,7 @@ class UpDownOneOpDim: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim) = 0; + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * special 1D down operation that is only executed in one direction @@ -139,8 +135,8 @@ class UpDownOneOpDim: public SGPP::base::OperationMatrix { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * special 1D up operation that is only executed in one direction @@ -149,11 +145,10 @@ class UpDownOneOpDim: public SGPP::base::OperationMatrix { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* UPDOWNONEOPDIM_HPP */ \ No newline at end of file +#endif /* UPDOWNONEOPDIM_HPP */ diff --git a/pde/src/sgpp/pde/algorithm/UpDownOneOpDimEnhanced.cpp b/pde/src/sgpp/pde/algorithm/UpDownOneOpDimEnhanced.cpp index 968b07abf4..c6a3f09b10 100644 --- a/pde/src/sgpp/pde/algorithm/UpDownOneOpDimEnhanced.cpp +++ b/pde/src/sgpp/pde/algorithm/UpDownOneOpDimEnhanced.cpp @@ -7,38 +7,35 @@ #include - namespace SGPP { namespace pde { UpDownOneOpDimEnhanced::UpDownOneOpDimEnhanced(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : storage(storage), coefs(&coef), - algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()) { -} + SGPP::base::DataVector& coef) + : storage(storage), + coefs(&coef), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()) {} UpDownOneOpDimEnhanced::UpDownOneOpDimEnhanced(SGPP::base::GridStorage* storage) - : storage(storage), coefs(NULL), algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()) { -} + : storage(storage), + coefs(NULL), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()) {} -UpDownOneOpDimEnhanced::~UpDownOneOpDimEnhanced() { -} +UpDownOneOpDimEnhanced::~UpDownOneOpDimEnhanced() {} -void UpDownOneOpDimEnhanced::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +void UpDownOneOpDimEnhanced::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { SGPP::base::DataMatrix beta(result.getSize(), this->numAlgoDims_); SGPP::base::DataMatrix maAlpha(alpha.getSize(), this->numAlgoDims_); result.setAll(0.0); maAlpha.expand(alpha); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait - { - this->updown(maAlpha, beta, this->numAlgoDims_ - 1); - } +#pragma omp single nowait + { this->updown(maAlpha, beta, this->numAlgoDims_ - 1); } } if (coefs == NULL) { @@ -48,8 +45,8 @@ void UpDownOneOpDimEnhanced::mult(SGPP::base::DataVector& alpha, } } -void UpDownOneOpDimEnhanced::multParallelBuildingBlock(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result) { +void UpDownOneOpDimEnhanced::multParallelBuildingBlock(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { SGPP::base::DataMatrix beta(result.getSize(), this->numAlgoDims_); SGPP::base::DataMatrix maAlpha(alpha.getSize(), this->numAlgoDims_); @@ -65,48 +62,48 @@ void UpDownOneOpDimEnhanced::multParallelBuildingBlock(SGPP::base::DataVector& } } -void UpDownOneOpDimEnhanced::updown(SGPP::base::DataMatrix& alpha, - SGPP::base::DataMatrix& result, size_t dim) { +void UpDownOneOpDimEnhanced::updown(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, + size_t dim) { size_t curNumAlgoDims = this->numAlgoDims_; size_t curMaxParallelDims = this->maxParallelDims_; - //Unidirectional scheme + // Unidirectional scheme if (dim > 0) { // Reordering ups and downs SGPP::base::DataMatrix temp(alpha.getNrows(), this->numAlgoDims_); SGPP::base::DataMatrix result_temp(alpha.getNrows(), this->numAlgoDims_); SGPP::base::DataMatrix temp_two(alpha.getNrows(), this->numAlgoDims_); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) { up(alpha, temp, dim); updown(temp, result, dim - 1); } - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, result_temp) - { +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, \ + result_temp) + { // NOLINT(whitespace/braces) updown(alpha, temp_two, dim - 1); down(temp_two, result_temp, dim); } - #pragma omp taskwait +#pragma omp taskwait result.add(result_temp); } else { // Terminates dimension recursion SGPP::base::DataMatrix temp(alpha.getNrows(), this->numAlgoDims_); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) up(alpha, result, dim); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) down(alpha, temp, dim); - #pragma omp taskwait +#pragma omp taskwait result.add(temp); } } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/algorithm/UpDownOneOpDimEnhanced.hpp b/pde/src/sgpp/pde/algorithm/UpDownOneOpDimEnhanced.hpp index c07b09cf26..a2052478c4 100644 --- a/pde/src/sgpp/pde/algorithm/UpDownOneOpDimEnhanced.hpp +++ b/pde/src/sgpp/pde/algorithm/UpDownOneOpDimEnhanced.hpp @@ -6,8 +6,6 @@ #ifndef UPDOWNONEOPDIMENHANCED_HPP #define UPDOWNONEOPDIMENHANCED_HPP -#include - #include #include #include @@ -19,6 +17,7 @@ #include +#include namespace SGPP { namespace pde { @@ -29,32 +28,30 @@ namespace pde { * afterwards. * */ -class UpDownOneOpDimEnhanced: public SGPP::base::OperationMatrix { +class UpDownOneOpDimEnhanced : public SGPP::base::OperationMatrix { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients; one per dimension + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients; one per dimension */ - UpDownOneOpDimEnhanced(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + UpDownOneOpDimEnhanced(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - UpDownOneOpDimEnhanced(SGPP::base::GridStorage* storage); + explicit UpDownOneOpDimEnhanced(SGPP::base::GridStorage* storage); /** * Destructor */ virtual ~UpDownOneOpDimEnhanced(); - - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** * this functions provides the same functionality as the normal mult routine. @@ -70,9 +67,7 @@ class UpDownOneOpDimEnhanced: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - void multParallelBuildingBlock(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); - + void multParallelBuildingBlock(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); protected: typedef SGPP::base::GridStorage::grid_iterator grid_iterator; @@ -95,8 +90,7 @@ class UpDownOneOpDimEnhanced: public SGPP::base::OperationMatrix { * @param alpha matrix of coefficients * @param result matrix to store the results of all dimensions */ - void updown(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, - size_t dim); + void updown(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, size_t dim); /** * 1D up Operation @@ -105,8 +99,7 @@ class UpDownOneOpDimEnhanced: public SGPP::base::OperationMatrix { * @param alpha matrix of coefficients * @param result matrix to store the results of all dimensions */ - virtual void up(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, - size_t dim) = 0; + virtual void up(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, size_t dim) = 0; /** * 1D down Operation @@ -115,11 +108,9 @@ class UpDownOneOpDimEnhanced: public SGPP::base::OperationMatrix { * @param alpha matrix of coefficients * @param result matrix to store the results of all dimensions */ - virtual void down(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, - size_t dim) = 0; + virtual void down(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, size_t dim) = 0; }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* STDUPDOWN_HPP */ \ No newline at end of file +#endif /* STDUPDOWN_HPP */ diff --git a/pde/src/sgpp/pde/algorithm/UpDownOneOpDimWithShadow.cpp b/pde/src/sgpp/pde/algorithm/UpDownOneOpDimWithShadow.cpp index b0280b572c..5b71c649ad 100644 --- a/pde/src/sgpp/pde/algorithm/UpDownOneOpDimWithShadow.cpp +++ b/pde/src/sgpp/pde/algorithm/UpDownOneOpDimWithShadow.cpp @@ -8,33 +8,28 @@ #include - namespace SGPP { namespace pde { -UpDownOneOpDimWithShadow::UpDownOneOpDimWithShadow(SGPP::base::GridStorage* - storage, - SGPP::base::GridStorage* shadowStorage) { +UpDownOneOpDimWithShadow::UpDownOneOpDimWithShadow(SGPP::base::GridStorage* storage, + SGPP::base::GridStorage* shadowStorage) { this->storage = storage; this->shadowStorage = shadowStorage; } -UpDownOneOpDimWithShadow::~UpDownOneOpDimWithShadow() { -} - -void UpDownOneOpDimWithShadow::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +UpDownOneOpDimWithShadow::~UpDownOneOpDimWithShadow() {} +void UpDownOneOpDimWithShadow::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { expandGrid(); - //Create new Datavectors for the grid including shadow points. + // Create new Datavectors for the grid including shadow points. SGPP::base::DataVector alpha_temp(storage->size()); SGPP::base::DataVector result_temp(storage->size()); alpha_temp.setAll(0.0); result_temp.setAll(0.0); - //Copy the alpha vector ... the old points remain the same, the new points are zero. + // Copy the alpha vector ... the old points remain the same, the new points are zero. for (size_t i = 0; i < alpha.getSize(); i++) { alpha_temp[i] = alpha[i]; } @@ -46,14 +41,13 @@ void UpDownOneOpDimWithShadow::mult(SGPP::base::DataVector& alpha, this->updown(alpha_temp, beta, storage->dim() - 1, i); result_temp.add(beta); - } - //Remove shadow grid points from the grid + // Remove shadow grid points from the grid shrinkGrid(); - //Copy the result in the actual result vector. The values for the shadow - //grid points are just needed for data transport, thus they can be omitted + // Copy the result in the actual result vector. The values for the shadow + // grid points are just needed for data transport, thus they can be omitted for (size_t i = 0; i < storage->size(); i++) { result[i] = result_temp[i]; } @@ -71,13 +65,12 @@ void UpDownOneOpDimWithShadow::shrinkGrid() { } } -void UpDownOneOpDimWithShadow::updown(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, +void UpDownOneOpDimWithShadow::updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, size_t op_dim) { if (dim == op_dim) { specialOP(alpha, result, dim, op_dim); } else { - //Unidirectional scheme + // Unidirectional scheme if (dim > 0) { // Reordering ups and downs SGPP::base::DataVector temp(alpha.getSize()); @@ -102,14 +95,13 @@ void UpDownOneOpDimWithShadow::updown(SGPP::base::DataVector& alpha, result.add(temp); } - } } void UpDownOneOpDimWithShadow::specialOP(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, - size_t dim, size_t op_dim) { - //Unidirectional scheme + SGPP::base::DataVector& result, size_t dim, + size_t op_dim) { + // Unidirectional scheme if (dim > 0) { // Reordering ups and downs SGPP::base::DataVector temp(alpha.getSize()); @@ -135,6 +127,5 @@ void UpDownOneOpDimWithShadow::specialOP(SGPP::base::DataVector& alpha, result.add(temp); } } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/algorithm/UpDownOneOpDimWithShadow.hpp b/pde/src/sgpp/pde/algorithm/UpDownOneOpDimWithShadow.hpp index 7c95a0d48a..993230c133 100644 --- a/pde/src/sgpp/pde/algorithm/UpDownOneOpDimWithShadow.hpp +++ b/pde/src/sgpp/pde/algorithm/UpDownOneOpDimWithShadow.hpp @@ -12,10 +12,8 @@ #include - #include - namespace SGPP { namespace pde { @@ -26,9 +24,8 @@ namespace pde { * accordingly. * */ -class UpDownOneOpDimWithShadow: public SGPP::base::OperationMatrix { +class UpDownOneOpDimWithShadow : public SGPP::base::OperationMatrix { public: - /** * Constructor * @@ -43,9 +40,7 @@ class UpDownOneOpDimWithShadow: public SGPP::base::OperationMatrix { */ virtual ~UpDownOneOpDimWithShadow(); - - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); protected: typedef SGPP::base::GridStorage::grid_iterator grid_iterator; @@ -62,8 +57,8 @@ class UpDownOneOpDimWithShadow: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - void updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim, size_t op_dim); + void updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t op_dim); /** * This functions adds all grid points of the shadow storage into the actual grid. @@ -84,9 +79,8 @@ class UpDownOneOpDimWithShadow: public SGPP::base::OperationMatrix { * @param dim the current dimension in the recursion * @param op_dim the dimension in that a special operation is applied */ - virtual void specialOP(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim); - + virtual void specialOP(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t op_dim); /** * std 1D up operation @@ -95,8 +89,7 @@ class UpDownOneOpDimWithShadow: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim) = 0; + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * std 1D down operation @@ -105,8 +98,7 @@ class UpDownOneOpDimWithShadow: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim) = 0; + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * special 1D down operation that is only executed in one direction @@ -115,8 +107,8 @@ class UpDownOneOpDimWithShadow: public SGPP::base::OperationMatrix { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * special 1D up operation that is only executed in one direction @@ -125,11 +117,10 @@ class UpDownOneOpDimWithShadow: public SGPP::base::OperationMatrix { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* UPDOWNONEOPDIMWITHSHADOW_HPP */ \ No newline at end of file +#endif /* UPDOWNONEOPDIMWITHSHADOW_HPP */ diff --git a/pde/src/sgpp/pde/algorithm/UpDownTwoOpDims.cpp b/pde/src/sgpp/pde/algorithm/UpDownTwoOpDims.cpp index 6000c6fc8f..714edfb15d 100644 --- a/pde/src/sgpp/pde/algorithm/UpDownTwoOpDims.cpp +++ b/pde/src/sgpp/pde/algorithm/UpDownTwoOpDims.cpp @@ -7,37 +7,35 @@ #include - namespace SGPP { namespace pde { -UpDownTwoOpDims::UpDownTwoOpDims(SGPP::base::GridStorage* storage, - SGPP::base::DataMatrix& coef) : storage(storage), coefs(&coef), - algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()) { -} +UpDownTwoOpDims::UpDownTwoOpDims(SGPP::base::GridStorage* storage, SGPP::base::DataMatrix& coef) + : storage(storage), + coefs(&coef), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()) {} -UpDownTwoOpDims::UpDownTwoOpDims(SGPP::base::GridStorage* storage) : storage( - storage), coefs(NULL), algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()) { -} +UpDownTwoOpDims::UpDownTwoOpDims(SGPP::base::GridStorage* storage) + : storage(storage), + coefs(NULL), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()) {} -UpDownTwoOpDims::~UpDownTwoOpDims() { -} +UpDownTwoOpDims::~UpDownTwoOpDims() {} -void UpDownTwoOpDims::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { +void UpDownTwoOpDims::mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { result.setAll(0.0); - #pragma omp parallel +#pragma omp parallel { - #pragma omp single nowait +#pragma omp single nowait { for (size_t i = 0; i < this->numAlgoDims_; i++) { for (size_t j = 0; j < this->numAlgoDims_; j++) { // use the operator's symmetry - if ( j <= i) { - #pragma omp task firstprivate(i, j) shared(alpha, result) + if (j <= i) { +#pragma omp task firstprivate(i, j) shared(alpha, result) { SGPP::base::DataVector beta(result.getSize()); @@ -45,59 +43,50 @@ void UpDownTwoOpDims::mult(SGPP::base::DataVector& alpha, if (this->coefs->get(i, j) != 0.0) { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.axpy(this->coefs->get(i, j), beta); - } +#pragma omp critical + { result.axpy(this->coefs->get(i, j), beta); } } - } else - { + } else { this->updown(alpha, beta, this->numAlgoDims_ - 1, i, j); - #pragma omp critical - { - result.add(beta); - } +#pragma omp critical + { result.add(beta); } } } } } } - #pragma omp taskwait +#pragma omp taskwait } } } void UpDownTwoOpDims::multParallelBuildingBlock(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t operationDimOne, - size_t operationDimTwo) { + SGPP::base::DataVector& result, + size_t operationDimOne, size_t operationDimTwo) { result.setAll(0.0); SGPP::base::DataVector beta(result.getSize()); // use the operator's symmetry - if ( operationDimTwo <= operationDimOne) { + if (operationDimTwo <= operationDimOne) { if (this->coefs != NULL) { if (this->coefs->get(operationDimOne, operationDimTwo) != 0.0) { - this->updown(alpha, beta, this->numAlgoDims_ - 1, operationDimOne, - operationDimTwo); + this->updown(alpha, beta, this->numAlgoDims_ - 1, operationDimOne, operationDimTwo); result.axpy(this->coefs->get(operationDimOne, operationDimTwo), beta); } } else { - this->updown(alpha, beta, this->numAlgoDims_ - 1, operationDimOne, - operationDimTwo); + this->updown(alpha, beta, this->numAlgoDims_ - 1, operationDimOne, operationDimTwo); result.add(beta); } } } -void UpDownTwoOpDims::updown(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two) { +void UpDownTwoOpDims::updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two) { if ((dim == op_dim_one) && (dim == op_dim_two)) { specialOpOneAndOpTwo(alpha, result, dim, op_dim_one, op_dim_two); - } else if ((dim == op_dim_one || dim == op_dim_two) - && (op_dim_one != op_dim_two)) { + } else if ((dim == op_dim_one || dim == op_dim_two) && (op_dim_one != op_dim_two)) { if (dim == op_dim_one) { specialOpOne(alpha, result, dim, op_dim_one, op_dim_two); } @@ -109,180 +98,181 @@ void UpDownTwoOpDims::updown(SGPP::base::DataVector& alpha, size_t curNumAlgoDims = this->numAlgoDims_; size_t curMaxParallelDims = this->maxParallelDims_; - //Unidirectional scheme + // Unidirectional scheme if (dim > 0) { // Reordering ups and downs SGPP::base::DataVector temp(alpha.getSize()); SGPP::base::DataVector result_temp(alpha.getSize()); SGPP::base::DataVector temp_two(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) { up(alpha, temp, this->algoDims[dim]); updown(temp, result, dim - 1, op_dim_one, op_dim_two); } - // Same from the other direction: - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, result_temp) - { +// Same from the other direction: +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, \ + result_temp) + { // NOLINT(whitespace/braces) updown(alpha, temp_two, dim - 1, op_dim_one, op_dim_two); down(temp_two, result_temp, this->algoDims[dim]); } - #pragma omp taskwait +#pragma omp taskwait result.add(result_temp); } else { // Terminates dimension recursion SGPP::base::DataVector temp(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) up(alpha, result, this->algoDims[dim]); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) down(alpha, temp, this->algoDims[dim]); - #pragma omp taskwait +#pragma omp taskwait result.add(temp); } } } -void UpDownTwoOpDims::specialOpOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two) { +void UpDownTwoOpDims::specialOpOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two) { size_t curNumAlgoDims = this->numAlgoDims_; size_t curMaxParallelDims = this->maxParallelDims_; - //Unidirectional scheme + // Unidirectional scheme if (dim > 0) { // Reordering ups and downs SGPP::base::DataVector temp(alpha.getSize()); SGPP::base::DataVector result_temp(alpha.getSize()); SGPP::base::DataVector temp_two(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) { upOpDimOne(alpha, temp, this->algoDims[dim]); updown(temp, result, dim - 1, op_dim_one, op_dim_two); } - // Same from the other direction: - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, result_temp) - { +// Same from the other direction: +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, \ + result_temp) + { // NOLINT(whitespace/braces) updown(alpha, temp_two, dim - 1, op_dim_one, op_dim_two); downOpDimOne(temp_two, result_temp, this->algoDims[dim]); } - #pragma omp taskwait +#pragma omp taskwait result.add(result_temp); } else { // Terminates dimension recursion SGPP::base::DataVector temp(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) upOpDimOne(alpha, result, this->algoDims[dim]); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) downOpDimOne(alpha, temp, this->algoDims[dim]); - #pragma omp taskwait +#pragma omp taskwait result.add(temp); } } -void UpDownTwoOpDims::specialOpTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two) { +void UpDownTwoOpDims::specialOpTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two) { size_t curNumAlgoDims = this->numAlgoDims_; size_t curMaxParallelDims = this->maxParallelDims_; - //Unidirectional scheme + // Unidirectional scheme if (dim > 0) { // Reordering ups and downs SGPP::base::DataVector temp(alpha.getSize()); SGPP::base::DataVector result_temp(alpha.getSize()); SGPP::base::DataVector temp_two(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) { upOpDimTwo(alpha, temp, this->algoDims[dim]); updown(temp, result, dim - 1, op_dim_one, op_dim_two); } - // Same from the other direction: - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, result_temp) - { +// Same from the other direction: +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, \ + result_temp) + { // NOLINT(whitespace/braces) updown(alpha, temp_two, dim - 1, op_dim_one, op_dim_two); downOpDimTwo(temp_two, result_temp, this->algoDims[dim]); } - #pragma omp taskwait +#pragma omp taskwait result.add(result_temp); } else { // Terminates dimension recursion SGPP::base::DataVector temp(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) upOpDimTwo(alpha, result, this->algoDims[dim]); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) downOpDimTwo(alpha, temp, this->algoDims[dim]); - #pragma omp taskwait +#pragma omp taskwait result.add(temp); } } void UpDownTwoOpDims::specialOpOneAndOpTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two) { + SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two) { size_t curNumAlgoDims = this->numAlgoDims_; size_t curMaxParallelDims = this->maxParallelDims_; - //Unidirectional scheme + // Unidirectional scheme if (dim > 0) { // Reordering ups and downs SGPP::base::DataVector temp(alpha.getSize()); SGPP::base::DataVector result_temp(alpha.getSize()); SGPP::base::DataVector temp_two(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp, result) { upOpDimOneAndOpDimTwo(alpha, temp, this->algoDims[dim]); updown(temp, result, dim - 1, op_dim_one, op_dim_two); } - // Same from the other direction: - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, result_temp) - { +// Same from the other direction: +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp_two, \ + result_temp) + { // NOLINT(whitespace/braces) updown(alpha, temp_two, dim - 1, op_dim_one, op_dim_two); downOpDimOneAndOpDimTwo(temp_two, result_temp, this->algoDims[dim]); } - #pragma omp taskwait +#pragma omp taskwait result.add(result_temp); } else { // Terminates dimension recursion SGPP::base::DataVector temp(alpha.getSize()); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, result) upOpDimOneAndOpDimTwo(alpha, result, this->algoDims[dim]); - #pragma omp task if(curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) +#pragma omp task if (curNumAlgoDims - dim <= curMaxParallelDims) shared(alpha, temp) downOpDimOneAndOpDimTwo(alpha, temp, this->algoDims[dim]); - #pragma omp taskwait +#pragma omp taskwait result.add(temp); } } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/algorithm/UpDownTwoOpDims.hpp b/pde/src/sgpp/pde/algorithm/UpDownTwoOpDims.hpp index c6b9b7483d..ef9cc66116 100644 --- a/pde/src/sgpp/pde/algorithm/UpDownTwoOpDims.hpp +++ b/pde/src/sgpp/pde/algorithm/UpDownTwoOpDims.hpp @@ -6,8 +6,6 @@ #ifndef UPDOWNTWOOPDIMS_HPP #define UPDOWNTWOOPDIMS_HPP -#include - #include #include #include @@ -19,6 +17,7 @@ #include +#include namespace SGPP { namespace pde { @@ -35,7 +34,7 @@ namespace pde { * before executing this Up/down scheme! * */ -class UpDownTwoOpDims: public SGPP::base::OperationMatrix { +class UpDownTwoOpDims : public SGPP::base::OperationMatrix { public: /** * Constructor @@ -50,15 +49,14 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * * @param storage the grid's SGPP::base::GridStorage object */ - UpDownTwoOpDims(SGPP::base::GridStorage* storage); + explicit UpDownTwoOpDims(SGPP::base::GridStorage* storage); /** * Destructor */ virtual ~UpDownTwoOpDims(); - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** * this functions provides the same functionality as the normal mult routine. @@ -71,8 +69,10 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * in a better parallel efficiency on systems with 4 or more cores hence fewer barriers * are needed. * - * For a full calculation of this operator, in mult serval number of up/downs are needed. This number - * is equal to the square of the number of the grid's dimensions. All different steps can be executed + * For a full calculation of this operator, in mult serval number of up/downs are needed. This + * number + * is equal to the square of the number of the grid's dimensions. All different steps can be + * executed * in parallel. Here only one up/Down is executed, identified by its special dimensions. * * Attention: A symmetric operator is assumed: This method only start a calculation if @@ -83,8 +83,8 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * @param operationDimOne Dimension in which the first special operator is applied * @param operationDimTwo Dimension in which the second special operator is applied */ - void multParallelBuildingBlock(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t operationDimOne, size_t operationDimTwo); + void multParallelBuildingBlock(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t operationDimOne, size_t operationDimTwo); protected: typedef SGPP::base::GridStorage::grid_iterator grid_iterator; @@ -109,8 +109,8 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - void updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim, size_t op_dim_one, size_t op_dim_two); + void updown(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two); /** * All calculations for gradient, parallel version using OpenMP 3 @@ -121,8 +121,8 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * @param op_dim_one the dimension in which to use the first gradient * @param op_dim_two the dimension in which to use the second gradient */ - void specialOpOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim, size_t op_dim_one, size_t op_dim_two); + void specialOpOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two); /** * All calculations for gradient, Part 2, parallel version using OpenMP 3 @@ -133,8 +133,8 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * @param op_dim_one the dimension in which to use the first gradient * @param op_dim_two the dimension in which to use the second gradient */ - void specialOpTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim, size_t op_dim_one, size_t op_dim_two); + void specialOpTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t op_dim_one, size_t op_dim_two); /** * if the current dimension is equal to the both special operation dimensions @@ -145,9 +145,8 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * @param op_dim_one the dimension in which to use the first gradient * @param op_dim_two the dimension in which to use the second gradient */ - void specialOpOneAndOpTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t op_dim_one, - size_t op_dim_two); + void specialOpOneAndOpTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim, size_t op_dim_one, size_t op_dim_two); /** * Up-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -158,8 +157,7 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim) = 0; + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -170,8 +168,7 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim) = 0; + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) = 0; /** * 1D down if the current dim is equal to i @@ -180,8 +177,8 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void downOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D up if the current dim is equal to i @@ -190,8 +187,8 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOne(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDimOne(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D down if the current dim is equal to j @@ -200,8 +197,8 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * @param result vector with the result of this operation * @param dim the dimension in that down-Gradient is applied */ - virtual void downOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void downOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D up if the current dim is equal to j @@ -210,8 +207,8 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; /** * 1D down, if the current dim is equal to i and j @@ -230,11 +227,10 @@ class UpDownTwoOpDims: public SGPP::base::OperationMatrix { * @param result vector with the result of this operation * @param dim the dimension in that up-Gradient is applied */ - virtual void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) = 0; + virtual void upOpDimOneAndOpDimTwo(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) = 0; }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* UPDOWNTWOOPDIMS_HPP */ \ No newline at end of file +#endif /* UPDOWNTWOOPDIMS_HPP */ diff --git a/pde/src/sgpp/pde/application/EllipticPDESolver.cpp b/pde/src/sgpp/pde/application/EllipticPDESolver.cpp index 2197e6d02b..c664a49a43 100644 --- a/pde/src/sgpp/pde/application/EllipticPDESolver.cpp +++ b/pde/src/sgpp/pde/application/EllipticPDESolver.cpp @@ -7,15 +7,11 @@ #include - namespace SGPP { namespace pde { -EllipticPDESolver::EllipticPDESolver() : PDESolver() { -} - -EllipticPDESolver::~EllipticPDESolver() { -} +EllipticPDESolver::EllipticPDESolver() : PDESolver() {} -} -} \ No newline at end of file +EllipticPDESolver::~EllipticPDESolver() {} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/application/EllipticPDESolver.hpp b/pde/src/sgpp/pde/application/EllipticPDESolver.hpp index 93bb569314..4b4bbd4538 100644 --- a/pde/src/sgpp/pde/application/EllipticPDESolver.hpp +++ b/pde/src/sgpp/pde/application/EllipticPDESolver.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -20,8 +19,6 @@ namespace pde { * */ class EllipticPDESolver : public PDESolver { - protected: - public: /** * Std-Constructor of the solver @@ -37,18 +34,17 @@ class EllipticPDESolver : public PDESolver { * abstract method to solve an elliptic PDE. All solver of elliptic PDEs * have to implement this method. * - * @param alpha the coefficients of the Sparse Gird's basis functions will be in this vector after solving + * @param alpha the coefficients of the Sparse Gird's basis functions will be in this vector after + * solving * @param rhs the right hand side of the SLE * @param maxCGIterations the maximum of interation in the CG solver * @param epsilonCG the epsilon used in the CG * @param verbose enables verbose output during solving */ - virtual void solvePDE(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& rhs, size_t maxCGIterations, float_t epsilonCG, - bool verbose = false) = 0; + virtual void solvePDE(SGPP::base::DataVector& alpha, SGPP::base::DataVector& rhs, + size_t maxCGIterations, float_t epsilonCG, bool verbose = false) = 0; }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* ELLIPTICPDESOLVER_HPP */ \ No newline at end of file +#endif /* ELLIPTICPDESOLVER_HPP */ diff --git a/pde/src/sgpp/pde/application/HeatEquationSolver.cpp b/pde/src/sgpp/pde/application/HeatEquationSolver.cpp index 1e3c8795b0..d1c35f1dc7 100644 --- a/pde/src/sgpp/pde/application/HeatEquationSolver.cpp +++ b/pde/src/sgpp/pde/application/HeatEquationSolver.cpp @@ -12,15 +12,13 @@ #include #include #include -#include -#include -#include - -using namespace SGPP::solver; -using namespace SGPP::base; #include +#include +#include +#include +#include namespace SGPP { namespace pde { @@ -36,13 +34,13 @@ HeatEquationSolver::~HeatEquationSolver() { } } -void HeatEquationSolver::constructGrid(BoundingBox& BoundingBox, int level) { +void HeatEquationSolver::constructGrid(base::BoundingBox& BoundingBox, int level) { this->dim = BoundingBox.getDimensions(); this->levels = level; - this->myGrid = new LinearBoundaryGrid(BoundingBox); + this->myGrid = new base::LinearBoundaryGrid(BoundingBox); - GridGenerator* myGenerator = this->myGrid->createGridGenerator(); + base::GridGenerator* myGenerator = this->myGrid->createGridGenerator(); myGenerator->regular(levels); delete myGenerator; @@ -52,30 +50,27 @@ void HeatEquationSolver::constructGrid(BoundingBox& BoundingBox, int level) { this->bGridConstructed = true; } -void HeatEquationSolver::setHeatCoefficient(float_t a) { - this->a = a; -} +void HeatEquationSolver::setHeatCoefficient(float_t a) { this->a = a; } -void HeatEquationSolver::solveExplicitEuler(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose, bool generateAnimation, - size_t numEvalsAnimation) { +void HeatEquationSolver::solveExplicitEuler(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose, + bool generateAnimation, size_t numEvalsAnimation) { if (this->bGridConstructed) { this->myScreen->writeStartSolve("Multidimensional Heat Equation Solver"); float_t dNeededTime; - Euler* myEuler = new Euler("ExEul", numTimesteps, timestepsize, - generateAnimation, numEvalsAnimation, this->myScreen); - ConjugateGradients* myCG = new ConjugateGradients(maxCGIterations, epsilonCG); + solver::Euler* myEuler = new solver::Euler( + "ExEul", numTimesteps, timestepsize, generateAnimation, numEvalsAnimation, this->myScreen); + solver::ConjugateGradients* myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); #ifdef _OPENMP - HeatEquationParabolicPDESolverSystemParallelOMP* myHESolver = new - HeatEquationParabolicPDESolverSystemParallelOMP(*this->myGrid, alpha, this->a, - timestepsize, "ExEul"); + HeatEquationParabolicPDESolverSystemParallelOMP* myHESolver = + new HeatEquationParabolicPDESolverSystemParallelOMP(*this->myGrid, alpha, this->a, + timestepsize, "ExEul"); #else - HeatEquationParabolicPDESolverSystem* myHESolver = new - HeatEquationParabolicPDESolverSystem(*this->myGrid, alpha, this->a, - timestepsize, "ExEul"); + HeatEquationParabolicPDESolverSystem* myHESolver = new HeatEquationParabolicPDESolverSystem( + *this->myGrid, alpha, this->a, timestepsize, "ExEul"); #endif - SGppStopwatch* myStopwatch = new SGppStopwatch(); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); myStopwatch->start(); myEuler->solve(*myCG, *myHESolver, verbose); @@ -90,30 +85,30 @@ void HeatEquationSolver::solveExplicitEuler(size_t numTimesteps, delete myCG; delete myEuler; } else { - throw new application_exception("HeatEquationSolver::solveExplicitEuler : A grid wasn't constructed before!"); + throw new base::application_exception( + "HeatEquationSolver::solveExplicitEuler : A grid wasn't constructed before!"); } } -void HeatEquationSolver::solveImplicitEuler(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose, bool generateAnimation, - size_t numEvalsAnimation) { +void HeatEquationSolver::solveImplicitEuler(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose, + bool generateAnimation, size_t numEvalsAnimation) { if (this->bGridConstructed) { this->myScreen->writeStartSolve("Multidimensional Heat Equation Solver"); float_t dNeededTime; - Euler* myEuler = new Euler("ImEul", numTimesteps, timestepsize, - generateAnimation, numEvalsAnimation, this->myScreen); - ConjugateGradients* myCG = new ConjugateGradients(maxCGIterations, epsilonCG); + solver::Euler* myEuler = new solver::Euler( + "ImEul", numTimesteps, timestepsize, generateAnimation, numEvalsAnimation, this->myScreen); + solver::ConjugateGradients* myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); #ifdef _OPENMP - HeatEquationParabolicPDESolverSystemParallelOMP* myHESolver = new - HeatEquationParabolicPDESolverSystemParallelOMP(*this->myGrid, alpha, this->a, - timestepsize, "ImEul"); + HeatEquationParabolicPDESolverSystemParallelOMP* myHESolver = + new HeatEquationParabolicPDESolverSystemParallelOMP(*this->myGrid, alpha, this->a, + timestepsize, "ImEul"); #else - HeatEquationParabolicPDESolverSystem* myHESolver = new - HeatEquationParabolicPDESolverSystem(*this->myGrid, alpha, this->a, - timestepsize, "ImEul"); + HeatEquationParabolicPDESolverSystem* myHESolver = new HeatEquationParabolicPDESolverSystem( + *this->myGrid, alpha, this->a, timestepsize, "ImEul"); #endif - SGppStopwatch* myStopwatch = new SGppStopwatch(); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); myStopwatch->start(); myEuler->solve(*myCG, *myHESolver, verbose); @@ -129,27 +124,27 @@ void HeatEquationSolver::solveImplicitEuler(size_t numTimesteps, delete myCG; delete myEuler; } else { - throw new application_exception("HeatEquationSolver::solveImplicitEuler : A grid wasn't constructed before!"); + throw new base::application_exception( + "HeatEquationSolver::solveImplicitEuler : A grid wasn't constructed before!"); } } -void HeatEquationSolver::solveCrankNicolson(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, size_t NumImEul) { +void HeatEquationSolver::solveCrankNicolson(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, size_t NumImEul) { if (this->bGridConstructed) { this->myScreen->writeStartSolve("Multidimensional Heat Equation Solver"); float_t dNeededTime; - ConjugateGradients* myCG = new ConjugateGradients(maxCGIterations, epsilonCG); + solver::ConjugateGradients* myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); #ifdef _OPENMP - HeatEquationParabolicPDESolverSystemParallelOMP* myHESolver = new - HeatEquationParabolicPDESolverSystemParallelOMP(*this->myGrid, alpha, this->a, - timestepsize, "CrNic"); + HeatEquationParabolicPDESolverSystemParallelOMP* myHESolver = + new HeatEquationParabolicPDESolverSystemParallelOMP(*this->myGrid, alpha, this->a, + timestepsize, "CrNic"); #else - HeatEquationParabolicPDESolverSystem* myHESolver = new - HeatEquationParabolicPDESolverSystem(*this->myGrid, alpha, this->a, - timestepsize, "CrNic"); + HeatEquationParabolicPDESolverSystem* myHESolver = new HeatEquationParabolicPDESolverSystem( + *this->myGrid, alpha, this->a, timestepsize, "CrNic"); #endif - SGppStopwatch* myStopwatch = new SGppStopwatch(); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); size_t numCNSteps; size_t numIESteps; @@ -162,9 +157,9 @@ void HeatEquationSolver::solveCrankNicolson(size_t numTimesteps, numIESteps = NumImEul; - Euler* myEuler = new Euler("ImEul", numIESteps, timestepsize, false, 0, - this->myScreen); - CrankNicolson* myCN = new CrankNicolson(numCNSteps, timestepsize); + solver::Euler* myEuler = + new solver::Euler("ImEul", numIESteps, timestepsize, false, 0, this->myScreen); + solver::CrankNicolson* myCN = new solver::CrankNicolson(numCNSteps, timestepsize); myStopwatch->start(); @@ -186,19 +181,19 @@ void HeatEquationSolver::solveCrankNicolson(size_t numTimesteps, delete myCN; delete myEuler; } else { - throw new application_exception("HeatEquationSolver::solveCrankNicolson : A grid wasn't constructed before!"); + throw new base::application_exception( + "HeatEquationSolver::solveCrankNicolson : A grid wasn't constructed before!"); } } -void HeatEquationSolver::initGridWithSmoothHeat(DataVector& alpha, float_t mu, - float_t sigma, float_t factor) { +void HeatEquationSolver::initGridWithSmoothHeat(base::DataVector& alpha, float_t mu, float_t sigma, + float_t factor) { if (this->bGridConstructed) { float_t tmp; float_t* dblFuncValues = new float_t[this->dim]; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); for (size_t j = 0; j < this->dim; j++) { @@ -210,8 +205,9 @@ void HeatEquationSolver::initGridWithSmoothHeat(DataVector& alpha, float_t mu, tmp = 1.0; for (size_t j = 0; j < this->dim; j++) { - tmp *= factor * factor * ((1.0 / (sigma * 2.0 * 3.145)) * exp((-0.5) * (( - dblFuncValues[j] - mu) / sigma) * ((dblFuncValues[j] - mu) / sigma))); + tmp *= factor * factor * + ((1.0 / (sigma * 2.0 * 3.145)) * exp((-0.5) * ((dblFuncValues[j] - mu) / sigma) * + ((dblFuncValues[j] - mu) / sigma))); } alpha[i] = tmp; @@ -219,32 +215,32 @@ void HeatEquationSolver::initGridWithSmoothHeat(DataVector& alpha, float_t mu, delete[] dblFuncValues; - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + SGPP::op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("HeatEquationSolver::initGridWithSmoothHeat : A grid wasn't constructed before!"); + throw new base::application_exception( + "HeatEquationSolver::initGridWithSmoothHeat : A grid wasn't constructed before!"); } } void HeatEquationSolver::initScreen() { - this->myScreen = new ScreenOutput(); + this->myScreen = new base::ScreenOutput(); this->myScreen->writeTitle("SGpp - Heat Equation Solver, 1.0.0", "Alexander Heinecke, (C) 2009-2011"); } -void HeatEquationSolver::storeInnerRHS(DataVector& alpha, std::string tFilename, +void HeatEquationSolver::storeInnerRHS(base::DataVector& alpha, std::string tFilename, float_t timestepsize) { if (this->bGridConstructed) { - HeatEquationParabolicPDESolverSystem* myHESolver = new - HeatEquationParabolicPDESolverSystem(*this->myGrid, alpha, this->a, - timestepsize, "ImEul"); - SGppStopwatch* myStopwatch = new SGppStopwatch(); + HeatEquationParabolicPDESolverSystem* myHESolver = new HeatEquationParabolicPDESolverSystem( + *this->myGrid, alpha, this->a, timestepsize, "ImEul"); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); myStopwatch->start(); std::cout << "Exporting inner right-hand-side..." << std::endl; - DataVector* rhs_inner = myHESolver->generateRHS(); + base::DataVector* rhs_inner = myHESolver->generateRHS(); size_t nCoefs = rhs_inner->getSize(); std::ofstream outfile(tFilename.c_str()); @@ -254,32 +250,34 @@ void HeatEquationSolver::storeInnerRHS(DataVector& alpha, std::string tFilename, } outfile.close(); - std::cout << "Exporting inner right-hand-side... DONE! (" << myStopwatch->stop() - << " s)" << std::endl << std::endl << std::endl; + std::cout << "Exporting inner right-hand-side... DONE! (" << myStopwatch->stop() << " s)" + << std::endl + << std::endl + << std::endl; delete myHESolver; } else { - throw new application_exception("HeatEquationSolver::storeInnerMatrix : A grid wasn't constructed before!"); + throw new base::application_exception( + "HeatEquationSolver::storeInnerMatrix : A grid wasn't constructed before!"); } } -void HeatEquationSolver::storeInnerSolution(DataVector& alpha, - size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, - float_t epsilonCG, std::string tFilename) { +void HeatEquationSolver::storeInnerSolution(base::DataVector& alpha, size_t numTimesteps, + float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, std::string tFilename) { if (this->bGridConstructed) { - Euler* myEuler = new Euler("ImEul", numTimesteps, timestepsize, false, 0, - this->myScreen); - ConjugateGradients* myCG = new ConjugateGradients(maxCGIterations, epsilonCG); - HeatEquationParabolicPDESolverSystem* myHESolver = new - HeatEquationParabolicPDESolverSystem(*this->myGrid, alpha, this->a, - timestepsize, "ImEul"); - SGppStopwatch* myStopwatch = new SGppStopwatch(); + solver::Euler* myEuler = + new solver::Euler("ImEul", numTimesteps, timestepsize, false, 0, this->myScreen); + solver::ConjugateGradients* myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); + HeatEquationParabolicPDESolverSystem* myHESolver = new HeatEquationParabolicPDESolverSystem( + *this->myGrid, alpha, this->a, timestepsize, "ImEul"); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); myStopwatch->start(); std::cout << "Exporting inner solution..." << std::endl; myEuler->solve(*myCG, *myHESolver, false); - DataVector* alpha_solve = myHESolver->getGridCoefficientsForCG(); + base::DataVector* alpha_solve = myHESolver->getGridCoefficientsForCG(); size_t nCoefs = alpha_solve->getSize(); std::ofstream outfile(tFilename.c_str()); @@ -295,11 +293,9 @@ void HeatEquationSolver::storeInnerSolution(DataVector& alpha, delete myCG; delete myEuler; } else { - throw new application_exception("HeatEquationSolver::solveImplicitEuler : A grid wasn't constructed before!"); + throw new base::application_exception( + "HeatEquationSolver::solveImplicitEuler : A grid wasn't constructed before!"); } - -} - - } -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/application/HeatEquationSolver.hpp b/pde/src/sgpp/pde/application/HeatEquationSolver.hpp index a73840ebf9..5833e25fe0 100644 --- a/pde/src/sgpp/pde/application/HeatEquationSolver.hpp +++ b/pde/src/sgpp/pde/application/HeatEquationSolver.hpp @@ -16,16 +16,15 @@ #include #include +#include +#include + #include #include #include #include #include -#include -#include - - namespace SGPP { namespace pde { @@ -57,18 +56,18 @@ class HeatEquationSolver : public ParabolicPDESolver { void constructGrid(SGPP::base::BoundingBox& myBoundingBox, int level); - virtual void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, + virtual void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, bool generateAnimation = false, size_t numEvalsAnimation = 20); - virtual void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, + virtual void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, bool generateAnimation = false, size_t numEvalsAnimation = 20); - virtual void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, + virtual void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, size_t NumImEul = 0); /** @@ -87,8 +86,8 @@ class HeatEquationSolver : public ParabolicPDESolver { * @param sigma the sigma of the normal distribution * @param factor a factor that is used to stretch the function values */ - void initGridWithSmoothHeat(SGPP::base::DataVector& alpha, float_t mu, - float_t sigma, float_t factor); + void initGridWithSmoothHeat(SGPP::base::DataVector& alpha, float_t mu, float_t sigma, + float_t factor); /** * Inits the screen object @@ -103,8 +102,7 @@ class HeatEquationSolver : public ParabolicPDESolver { * @param tFilename file into which the rhs is written * @param timestepsize the size of the timesteps */ - void storeInnerRHS(SGPP::base::DataVector& alpha, std::string tFilename, - float_t timestepsize); + void storeInnerRHS(SGPP::base::DataVector& alpha, std::string tFilename, float_t timestepsize); /** * Routine to export the solution of the inner system which @@ -117,12 +115,10 @@ class HeatEquationSolver : public ParabolicPDESolver { * @param epsilonCG the epsilon used in the C * @param tFilename file into which the rhs is written */ - void storeInnerSolution(SGPP::base::DataVector& alpha, size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - std::string tFilename); + void storeInnerSolution(SGPP::base::DataVector& alpha, size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, std::string tFilename); }; - -} -} +} // namespace pde +} // namespace SGPP #endif /* HEATEQUATIONSOLVER_HPP */ diff --git a/pde/src/sgpp/pde/application/HeatEquationSolverWithStretching.cpp b/pde/src/sgpp/pde/application/HeatEquationSolverWithStretching.cpp index bf39eeea29..73721ddebd 100644 --- a/pde/src/sgpp/pde/application/HeatEquationSolverWithStretching.cpp +++ b/pde/src/sgpp/pde/application/HeatEquationSolverWithStretching.cpp @@ -13,17 +13,14 @@ #include #include -using namespace SGPP::base; -using namespace SGPP::solver; - #include +#include namespace SGPP { namespace pde { -HeatEquationSolverWithStretching::HeatEquationSolverWithStretching() : - ParabolicPDESolver() { +HeatEquationSolverWithStretching::HeatEquationSolverWithStretching() : ParabolicPDESolver() { this->bGridConstructed = false; this->myScreen = NULL; } @@ -34,14 +31,13 @@ HeatEquationSolverWithStretching::~HeatEquationSolverWithStretching() { } } -void HeatEquationSolverWithStretching::constructGrid(Stretching& stretching, - int level) { +void HeatEquationSolverWithStretching::constructGrid(base::Stretching& stretching, int level) { this->dim = stretching.getDimensions(); this->levels = level; - this->myGrid = new LinearStretchedBoundaryGrid(stretching); + this->myGrid = new base::LinearStretchedBoundaryGrid(stretching); - GridGenerator* myGenerator = this->myGrid->createGridGenerator(); + base::GridGenerator* myGenerator = this->myGrid->createGridGenerator(); myGenerator->regular(this->levels); delete myGenerator; @@ -51,35 +47,32 @@ void HeatEquationSolverWithStretching::constructGrid(Stretching& stretching, this->bGridConstructed = true; } -void HeatEquationSolverWithStretching::constructGrid(BoundingBox& BoundingBox, - int level) { +void HeatEquationSolverWithStretching::constructGrid(base::BoundingBox& BoundingBox, int level) { std::cout << "I'm not supposed to be here, me is constructGrid\n"; } -void HeatEquationSolverWithStretching::setHeatCoefficient(float_t a) { - this->a = a; -} +void HeatEquationSolverWithStretching::setHeatCoefficient(float_t a) { this->a = a; } -void HeatEquationSolverWithStretching::solveExplicitEuler(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose, bool generateAnimation, - size_t numEvalsAnimation) { +void HeatEquationSolverWithStretching::solveExplicitEuler(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose, + bool generateAnimation, + size_t numEvalsAnimation) { if (this->bGridConstructed) { this->myScreen->writeStartSolve("Multidimensional Heat Equation Solver"); float_t dNeededTime; - Euler* myEuler = new Euler("ExEul", numTimesteps, timestepsize, - generateAnimation, numEvalsAnimation, this->myScreen); - ConjugateGradients* myCG = new ConjugateGradients(maxCGIterations, epsilonCG); + solver::Euler* myEuler = new solver::Euler( + "ExEul", numTimesteps, timestepsize, generateAnimation, numEvalsAnimation, this->myScreen); + solver::ConjugateGradients* myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); #ifdef _OPENMP - HeatEquationParabolicPDESolverSystemParallelOMP* myHESolver = new - HeatEquationParabolicPDESolverSystemParallelOMP(*this->myGrid, alpha, this->a, - timestepsize, "ExEul"); + HeatEquationParabolicPDESolverSystemParallelOMP* myHESolver = + new HeatEquationParabolicPDESolverSystemParallelOMP(*this->myGrid, alpha, this->a, + timestepsize, "ExEul"); #else - HeatEquationParabolicPDESolverSystem* myHESolver = new - HeatEquationParabolicPDESolverSystem(*this->myGrid, alpha, this->a, - timestepsize, "ExEul"); + HeatEquationParabolicPDESolverSystem* myHESolver = new HeatEquationParabolicPDESolverSystem( + *this->myGrid, alpha, this->a, timestepsize, "ExEul"); #endif - SGppStopwatch* myStopwatch = new SGppStopwatch(); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); myStopwatch->start(); myEuler->solve(*myCG, *myHESolver, verbose); @@ -94,30 +87,31 @@ void HeatEquationSolverWithStretching::solveExplicitEuler(size_t numTimesteps, delete myCG; delete myEuler; } else { - throw new application_exception("HeatEquationSolverWithStretching::solveExplicitEuler : A grid wasn't constructed before!"); + throw new base::application_exception( + "HeatEquationSolverWithStretching::solveExplicitEuler : A grid wasn't constructed before!"); } } -void HeatEquationSolverWithStretching::solveImplicitEuler(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, bool verbose, bool generateAnimation, - size_t numEvalsAnimation) { +void HeatEquationSolverWithStretching::solveImplicitEuler(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, bool verbose, + bool generateAnimation, + size_t numEvalsAnimation) { if (this->bGridConstructed) { this->myScreen->writeStartSolve("Multidimensional Heat Equation Solver"); float_t dNeededTime; - Euler* myEuler = new Euler("ImEul", numTimesteps, timestepsize, - generateAnimation, numEvalsAnimation, this->myScreen); - ConjugateGradients* myCG = new ConjugateGradients(maxCGIterations, epsilonCG); + solver::Euler* myEuler = new solver::Euler( + "ImEul", numTimesteps, timestepsize, generateAnimation, numEvalsAnimation, this->myScreen); + solver::ConjugateGradients* myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); #ifdef _OPENMP - HeatEquationParabolicPDESolverSystemParallelOMP* myHESolver = new - HeatEquationParabolicPDESolverSystemParallelOMP(*this->myGrid, alpha, this->a, - timestepsize, "ImEul"); + HeatEquationParabolicPDESolverSystemParallelOMP* myHESolver = + new HeatEquationParabolicPDESolverSystemParallelOMP(*this->myGrid, alpha, this->a, + timestepsize, "ImEul"); #else - HeatEquationParabolicPDESolverSystem* myHESolver = new - HeatEquationParabolicPDESolverSystem(*this->myGrid, alpha, this->a, - timestepsize, "ImEul"); + HeatEquationParabolicPDESolverSystem* myHESolver = new HeatEquationParabolicPDESolverSystem( + *this->myGrid, alpha, this->a, timestepsize, "ImEul"); #endif - SGppStopwatch* myStopwatch = new SGppStopwatch(); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); myStopwatch->start(); myEuler->solve(*myCG, *myHESolver, verbose); @@ -133,27 +127,28 @@ void HeatEquationSolverWithStretching::solveImplicitEuler(size_t numTimesteps, delete myCG; delete myEuler; } else { - throw new application_exception("HeatEquationSolverWithStretching::solveImplicitEuler : A grid wasn't constructed before!"); + throw new base::application_exception( + "HeatEquationSolverWithStretching::solveImplicitEuler : A grid wasn't constructed before!"); } } -void HeatEquationSolverWithStretching::solveCrankNicolson(size_t numTimesteps, - float_t timestepsize, size_t maxCGIterations, float_t epsilonCG, - DataVector& alpha, size_t NumImEul) { +void HeatEquationSolverWithStretching::solveCrankNicolson(size_t numTimesteps, float_t timestepsize, + size_t maxCGIterations, float_t epsilonCG, + base::DataVector& alpha, + size_t NumImEul) { if (this->bGridConstructed) { this->myScreen->writeStartSolve("Multidimensional Heat Equation Solver"); float_t dNeededTime; - ConjugateGradients* myCG = new ConjugateGradients(maxCGIterations, epsilonCG); + solver::ConjugateGradients* myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); #ifdef _OPENMP - HeatEquationParabolicPDESolverSystemParallelOMP* myHESolver = new - HeatEquationParabolicPDESolverSystemParallelOMP(*this->myGrid, alpha, this->a, - timestepsize, "CrNic"); + HeatEquationParabolicPDESolverSystemParallelOMP* myHESolver = + new HeatEquationParabolicPDESolverSystemParallelOMP(*this->myGrid, alpha, this->a, + timestepsize, "CrNic"); #else - HeatEquationParabolicPDESolverSystem* myHESolver = new - HeatEquationParabolicPDESolverSystem(*this->myGrid, alpha, this->a, - timestepsize, "CrNic"); + HeatEquationParabolicPDESolverSystem* myHESolver = new HeatEquationParabolicPDESolverSystem( + *this->myGrid, alpha, this->a, timestepsize, "CrNic"); #endif - SGppStopwatch* myStopwatch = new SGppStopwatch(); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); size_t numCNSteps; size_t numIESteps; @@ -166,9 +161,9 @@ void HeatEquationSolverWithStretching::solveCrankNicolson(size_t numTimesteps, numIESteps = NumImEul; - Euler* myEuler = new Euler("ImEul", numIESteps, timestepsize, false, 0, - this->myScreen); - CrankNicolson* myCN = new CrankNicolson(numCNSteps, timestepsize); + solver::Euler* myEuler = + new solver::Euler("ImEul", numIESteps, timestepsize, false, 0, this->myScreen); + solver::CrankNicolson* myCN = new solver::CrankNicolson(numCNSteps, timestepsize); myStopwatch->start(); @@ -190,19 +185,20 @@ void HeatEquationSolverWithStretching::solveCrankNicolson(size_t numTimesteps, delete myCN; delete myEuler; } else { - throw new application_exception("HeatEquationSolverWithStretching::solveCrankNicolson : A grid wasn't constructed before!"); + throw new base::application_exception( + "HeatEquationSolverWithStretching::solveCrankNicolson : A grid wasn't constructed before!"); } } -void HeatEquationSolverWithStretching::initGridWithSmoothHeat(DataVector& alpha, - float_t mu, float_t sigma, float_t factor) { +void HeatEquationSolverWithStretching::initGridWithSmoothHeat(base::DataVector& alpha, float_t mu, + float_t sigma, float_t factor) { if (this->bGridConstructed) { float_t tmp; float_t* dblFuncValues = new float_t[this->dim]; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringStretching( - *this->myStretching); + std::string coords = + this->myGridStorage->get(i)->getCoordsStringStretching(*this->myStretching); std::stringstream coordsStream(coords); for (size_t j = 0; j < this->dim; j++) { @@ -214,8 +210,9 @@ void HeatEquationSolverWithStretching::initGridWithSmoothHeat(DataVector& alpha, tmp = 1.0; for (size_t j = 0; j < this->dim; j++) { - tmp *= factor * factor * ((1.0 / (sigma * 2.0 * 3.145)) * exp((-0.5) * (( - dblFuncValues[j] - mu) / sigma) * ((dblFuncValues[j] - mu) / sigma))); + tmp *= factor * factor * + ((1.0 / (sigma * 2.0 * 3.145)) * exp((-0.5) * ((dblFuncValues[j] - mu) / sigma) * + ((dblFuncValues[j] - mu) / sigma))); } alpha[i] = tmp; @@ -223,52 +220,59 @@ void HeatEquationSolverWithStretching::initGridWithSmoothHeat(DataVector& alpha, delete[] dblFuncValues; - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + SGPP::op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("HeatEquationSolverWithStretching::initGridWithSmoothHeat : A grid wasn't constructed before!"); + throw new base::application_exception( + "HeatEquationSolverWithStretching::initGridWithSmoothHeat : A grid wasn't constructed " + "before!"); } } void HeatEquationSolverWithStretching::initScreen() { - this->myScreen = new ScreenOutput(); + this->myScreen = new base::ScreenOutput(); this->myScreen->writeTitle("SGpp - Heat Equation Solver With Stretching, 1.0.1", "Alexander Heinecke, Sarpkan Selcuk (C) 2009-2011"); } -void HeatEquationSolverWithStretching::printGrid(DataVector& alpha, - float_t PointesPerDimension, std::string tfilename) const { - GridPrinterForStretching myPrinter(*this->myGrid); +void HeatEquationSolverWithStretching::printGrid(base::DataVector& alpha, + float_t PointesPerDimension, + std::string tfilename) const { + base::GridPrinterForStretching myPrinter(*this->myGrid); myPrinter.printGrid(alpha, tfilename, static_cast(PointesPerDimension)); } -void HeatEquationSolverWithStretching::printGridDomain(DataVector& alpha, - float_t PointesPerDimension, BoundingBox& GridArea, - std::string tfilename) const { - throw new application_exception("HeatEquationSolverWithStretching::printGridDomain : BoundingBox not supported with this solver, use printGridDomainStretching instead "); +void HeatEquationSolverWithStretching::printGridDomain(base::DataVector& alpha, + float_t PointesPerDimension, + base::BoundingBox& GridArea, + std::string tfilename) const { + throw new base::application_exception( + "HeatEquationSolverWithStretching::printGridDomain : BoundingBox not supported with this " + "solver, use printGridDomainStretching instead "); } -void HeatEquationSolverWithStretching::printGridDomainStretching( - DataVector& alpha, float_t PointesPerDimension, Stretching& GridArea, - std::string tfilename) const { - GridPrinterForStretching myPrinter(*this->myGrid); +void HeatEquationSolverWithStretching::printGridDomainStretching(base::DataVector& alpha, + float_t PointesPerDimension, + base::Stretching& GridArea, + std::string tfilename) const { + base::GridPrinterForStretching myPrinter(*this->myGrid); myPrinter.printGridDomainStretching(alpha, tfilename, GridArea, static_cast(PointesPerDimension)); } -void HeatEquationSolverWithStretching::printSparseGrid(DataVector& alpha, - std::string tfilename, bool bSurplus) const { - GridPrinterForStretching myPrinter(*this->myGrid); +void HeatEquationSolverWithStretching::printSparseGrid(base::DataVector& alpha, + std::string tfilename, bool bSurplus) const { + base::GridPrinterForStretching myPrinter(*this->myGrid); myPrinter.printSparseGrid(alpha, tfilename, bSurplus); } -void HeatEquationSolverWithStretching::printSparseGridExpTransform( - DataVector& alpha, std::string tfilename, bool bSurplus) const { - GridPrinterForStretching myPrinter(*this->myGrid); +void HeatEquationSolverWithStretching::printSparseGridExpTransform(base::DataVector& alpha, + std::string tfilename, + bool bSurplus) const { + base::GridPrinterForStretching myPrinter(*this->myGrid); myPrinter.printSparseGridExpTransform(alpha, tfilename, bSurplus); } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/application/HeatEquationSolverWithStretching.hpp b/pde/src/sgpp/pde/application/HeatEquationSolverWithStretching.hpp index 892aec01fd..4581fbeac2 100644 --- a/pde/src/sgpp/pde/application/HeatEquationSolverWithStretching.hpp +++ b/pde/src/sgpp/pde/application/HeatEquationSolverWithStretching.hpp @@ -6,11 +6,10 @@ #ifndef HEATEQUATIONSOLVERWITHSTRETCHING_HPP #define HEATEQUATIONSOLVERWITHSTRETCHING_HPP - #include -//#include -//#include +// #include +// #include #include #include @@ -21,16 +20,15 @@ #include #include +#include +#include + #include #include #include #include #include -#include -#include - - namespace SGPP { namespace pde { @@ -48,7 +46,7 @@ class HeatEquationSolverWithStretching : public ParabolicPDESolver { float_t a; /// screen object used in this solver SGPP::base::ScreenOutput* myScreen; - ////BoundingBox replacement + /// BoundingBox replacement SGPP::base::Stretching* myStretching; public: @@ -66,19 +64,16 @@ class HeatEquationSolverWithStretching : public ParabolicPDESolver { void constructGrid(SGPP::base::BoundingBox& myStretching, int level); - void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false, bool generateAnimation = false, - size_t numEvalsAnimation = 20); + void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, + bool generateAnimation = false, size_t numEvalsAnimation = 20); - void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - bool verbose = false, bool generateAnimation = false, - size_t numEvalsAnimation = 20); + void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, + bool generateAnimation = false, size_t numEvalsAnimation = 20); - void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, - size_t NumImEul = 0); + void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, size_t NumImEul = 0); /** * This method sets the heat coefficient of the regarded material @@ -104,8 +99,8 @@ class HeatEquationSolverWithStretching : public ParabolicPDESolver { * @param sigma the sigma of the normal distribution * @param factor a factor that is used to stretch the function values */ - void initGridWithSmoothHeat(SGPP::base::DataVector& alpha, float_t mu, - float_t sigma, float_t factor); + void initGridWithSmoothHeat(SGPP::base::DataVector& alpha, float_t mu, float_t sigma, + float_t factor); /** * Inits the grid with a constant heat @@ -150,12 +145,12 @@ class HeatEquationSolverWithStretching : public ParabolicPDESolver { * @param GridArea the area in which the function should be plotted * @param tfilename absolute path to file into which the grid's evaluation is written */ - void printGridDomainStretching(SGPP::base::DataVector& alpha, - float_t PointesPerDimension, SGPP::base::Stretching& GridArea, - std::string tfilename) const; + void printGridDomainStretching(SGPP::base::DataVector& alpha, float_t PointesPerDimension, + SGPP::base::Stretching& GridArea, std::string tfilename) const; /** - * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis value + * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis + * value * or their hierarchical surplus * * This function is available for all dimensions @@ -164,11 +159,11 @@ class HeatEquationSolverWithStretching : public ParabolicPDESolver { * @param tfilename absoulte path to the file the grid is written into * @param bSurplus specifies whether the surplus (true) or the node basis value (false) is written */ - void printSparseGrid(SGPP::base::DataVector& alpha, std::string tfilename, - bool bSurplus) const; + void printSparseGrid(SGPP::base::DataVector& alpha, std::string tfilename, bool bSurplus) const; /** - * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis value + * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis + * value * or their hierarchical surplus * * This function is available for all dimensions. @@ -180,12 +175,10 @@ class HeatEquationSolverWithStretching : public ParabolicPDESolver { * @param tfilename absoulte path to the file the grid is written into * @param bSurplus specifies whether the surplus (true) or the node basis value (false) is written */ - void printSparseGridExpTransform(SGPP::base::DataVector& alpha, - std::string tfilename, bool bSurplus) const; - + void printSparseGridExpTransform(SGPP::base::DataVector& alpha, std::string tfilename, + bool bSurplus) const; }; - -} -} +} // namespace pde +} // namespace SGPP #endif /* HEATEQUATIONSOLVERWITHSTRETCHING_HPP */ diff --git a/pde/src/sgpp/pde/application/PDESolver.cpp b/pde/src/sgpp/pde/application/PDESolver.cpp index c2e4522417..45fd8961d4 100644 --- a/pde/src/sgpp/pde/application/PDESolver.cpp +++ b/pde/src/sgpp/pde/application/PDESolver.cpp @@ -11,6 +11,8 @@ #include #include +#include + #include #include #include @@ -18,15 +20,12 @@ #include #include -#include - - namespace SGPP { namespace pde { -PDESolver::PDESolver(): levels(0), dim(0), myBoundingBox(nullptr), - myGridStorage(nullptr), myGrid(nullptr) { - //initializers may be wrong - David +PDESolver::PDESolver() + : levels(0), dim(0), myBoundingBox(nullptr), myGridStorage(nullptr), myGrid(nullptr) { + // initializers may be wrong - David bGridConstructed = false; } @@ -37,16 +36,15 @@ PDESolver::~PDESolver() { } void PDESolver::getGridNormalDistribution(SGPP::base::DataVector& alpha, - std::vector& norm_mu, - std::vector& norm_sigma) { + std::vector& norm_mu, + std::vector& norm_sigma) { if (bGridConstructed) { float_t tmp; float_t value; SGPP::base::StdNormalDistribution myNormDistr; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(* - (this->myBoundingBox)); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*(this->myBoundingBox)); std::stringstream coordsStream(coords); value = 1.0; @@ -61,7 +59,7 @@ void PDESolver::getGridNormalDistribution(SGPP::base::DataVector& alpha, } } else { throw new SGPP::base::application_exception( - "PDESolver::getGridNormalDistribution : The grid wasn't initialized before!"); + "PDESolver::getGridNormalDistribution : The grid wasn't initialized before!"); } } @@ -72,7 +70,8 @@ void PDESolver::deleteGrid() { myBoundingBox = NULL; myGridStorage = NULL; } else { - throw new SGPP::base::application_exception("PDESolver::deleteGrid : The grid wasn't initialized before!"); + throw new SGPP::base::application_exception( + "PDESolver::deleteGrid : The grid wasn't initialized before!"); } } @@ -102,14 +101,15 @@ std::string PDESolver::getGrid() const { // Serialize the grid myGrid->serialize(gridSer); } else { - throw new SGPP::base::application_exception("PDESolver::getGrid : The grid wasn't initialized before!"); + throw new SGPP::base::application_exception( + "PDESolver::getGrid : The grid wasn't initialized before!"); } return gridSer; } -void PDESolver::refineInitialGridSurplus(SGPP::base::DataVector& alpha, - int numRefinePoints, float_t dThreshold) { +void PDESolver::refineInitialGridSurplus(SGPP::base::DataVector& alpha, int numRefinePoints, + float_t dThreshold) { size_t nRefinements; if (numRefinePoints < 0) { @@ -119,9 +119,8 @@ void PDESolver::refineInitialGridSurplus(SGPP::base::DataVector& alpha, } if (bGridConstructed) { - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(&alpha, nRefinements, - dThreshold); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = + new SGPP::base::SurplusRefinementFunctor(&alpha, nRefinements, dThreshold); myGrid->createGridGenerator()->refine(myRefineFunc); @@ -130,13 +129,14 @@ void PDESolver::refineInitialGridSurplus(SGPP::base::DataVector& alpha, alpha.resize(myGridStorage->size()); } else { throw new SGPP::base::application_exception( - "PDESolver::refineIntialGridSurplus : The grid wasn't initialized before!"); + "PDESolver::refineIntialGridSurplus : The grid wasn't initialized before!"); } } void PDESolver::refineInitialGridSurplusSubDomain(SGPP::base::DataVector& alpha, - int numRefinePoints, float_t dThreshold, - std::vector& norm_mu, std::vector& norm_sigma) { + int numRefinePoints, float_t dThreshold, + std::vector& norm_mu, + std::vector& norm_sigma) { size_t nRefinements; if (numRefinePoints < 0) { @@ -150,13 +150,12 @@ void PDESolver::refineInitialGridSurplusSubDomain(SGPP::base::DataVector& alpha, // calculate multidimensional normal distribution and apply to alpha on it this->getGridNormalDistribution(stdNormDist, norm_mu, norm_sigma); - //printSparseGrid(stdNormDist, "normalDistribution.grid.gnuplot", true); + // printSparseGrid(stdNormDist, "normalDistribution.grid.gnuplot", true); stdNormDist.componentwise_mult(alpha); - //printSparseGrid(stdNormDist, "normalDistribution_refine.grid.gnuplot", true); + // printSparseGrid(stdNormDist, "normalDistribution_refine.grid.gnuplot", true); - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(&stdNormDist, - nRefinements, dThreshold); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = + new SGPP::base::SurplusRefinementFunctor(&stdNormDist, nRefinements, dThreshold); myGrid->createGridGenerator()->refine(myRefineFunc); @@ -165,20 +164,19 @@ void PDESolver::refineInitialGridSurplusSubDomain(SGPP::base::DataVector& alpha, alpha.resize(myGridStorage->size()); } else { throw new SGPP::base::application_exception( - "PDESolver::refineIntialGridSurplusSubDomain : The grid wasn't initialized before!"); + "PDESolver::refineIntialGridSurplusSubDomain : The grid wasn't initialized before!"); } } -void PDESolver::refineInitialGridSurplusToMaxLevel(SGPP::base::DataVector& - alpha, float_t dThreshold, +void PDESolver::refineInitialGridSurplusToMaxLevel( + SGPP::base::DataVector& alpha, float_t dThreshold, SGPP::base::GridStorage::index_type::level_type maxLevel) { if (bGridConstructed) { size_t nRefinements = - myGrid->createGridGenerator()->getNumberOfRefinablePointsToMaxLevel(maxLevel); + myGrid->createGridGenerator()->getNumberOfRefinablePointsToMaxLevel(maxLevel); - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(&alpha, nRefinements, - dThreshold); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = + new SGPP::base::SurplusRefinementFunctor(&alpha, nRefinements, dThreshold); myGrid->createGridGenerator()->refineMaxLevel(myRefineFunc, maxLevel); @@ -187,30 +185,28 @@ void PDESolver::refineInitialGridSurplusToMaxLevel(SGPP::base::DataVector& alpha.resize(myGridStorage->size()); } else { throw new SGPP::base::application_exception( - "PDESolver::refineInitialGridSurplusToMaxLevel : The grid wasn't initialized before!"); + "PDESolver::refineInitialGridSurplusToMaxLevel : The grid wasn't initialized before!"); } } void PDESolver::refineInitialGridSurplusToMaxLevelSubDomain( - SGPP::base::DataVector& alpha, float_t dThreshold, - SGPP::base::GridStorage::index_type::level_type maxLevel, - std::vector& norm_mu, - std::vector& norm_sigma) { + SGPP::base::DataVector& alpha, float_t dThreshold, + SGPP::base::GridStorage::index_type::level_type maxLevel, std::vector& norm_mu, + std::vector& norm_sigma) { if (bGridConstructed) { size_t nRefinements = - myGrid->createGridGenerator()->getNumberOfRefinablePointsToMaxLevel(maxLevel); + myGrid->createGridGenerator()->getNumberOfRefinablePointsToMaxLevel(maxLevel); SGPP::base::DataVector stdNormDist(alpha.getSize()); // calculate multidimensional normal distribution and apply to alpha on it this->getGridNormalDistribution(stdNormDist, norm_mu, norm_sigma); - //printSparseGrid(stdNormDist, "normalDistribution.grid.gnuplot", true); + // printSparseGrid(stdNormDist, "normalDistribution.grid.gnuplot", true); stdNormDist.componentwise_mult(alpha); - //printSparseGrid(stdNormDist, "normalDistribution_refine.grid.gnuplot", true); + // printSparseGrid(stdNormDist, "normalDistribution_refine.grid.gnuplot", true); - SGPP::base::SurplusRefinementFunctor* myRefineFunc = new - SGPP::base::SurplusRefinementFunctor(&stdNormDist, - nRefinements, dThreshold); + SGPP::base::SurplusRefinementFunctor* myRefineFunc = + new SGPP::base::SurplusRefinementFunctor(&stdNormDist, nRefinements, dThreshold); myGrid->createGridGenerator()->refineMaxLevel(myRefineFunc, maxLevel); @@ -219,19 +215,18 @@ void PDESolver::refineInitialGridSurplusToMaxLevelSubDomain( alpha.resize(myGridStorage->size()); } else { throw new SGPP::base::application_exception( - "PDESolver::refineInitialGridSurplusToMaxLevelSubDomain : The grid wasn't initialized before!"); + "PDESolver::refineInitialGridSurplusToMaxLevelSubDomain : The grid wasn't initialized " + "before!"); } } -void PDESolver::coarsenInitialGridSurplus(SGPP::base::DataVector& alpha, - float_t dThreshold) { +void PDESolver::coarsenInitialGridSurplus(SGPP::base::DataVector& alpha, float_t dThreshold) { if (bGridConstructed) { SGPP::base::GridGenerator* myGenerator = myGrid->createGridGenerator(); size_t numCoarsen = myGenerator->getNumberOfRemovablePoints(); size_t originalGridSize = myGrid->getStorage()->size(); - SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = new - SGPP::base::SurplusCoarseningFunctor(&alpha, - numCoarsen, dThreshold); + SGPP::base::SurplusCoarseningFunctor* myCoarsenFunctor = + new SGPP::base::SurplusCoarseningFunctor(&alpha, numCoarsen, dThreshold); myGenerator->coarsenNFirstOnly(myCoarsenFunctor, &alpha, originalGridSize); @@ -239,7 +234,7 @@ void PDESolver::coarsenInitialGridSurplus(SGPP::base::DataVector& alpha, delete myGenerator; } else { throw new SGPP::base::application_exception( - "PDESolver::coarsenInitialGridSurplus : The grid wasn't initialized before!"); + "PDESolver::coarsenInitialGridSurplus : The grid wasn't initialized before!"); } } @@ -248,64 +243,61 @@ void PDESolver::printLevelIndexGrid(std::string tfilename) const { myPrinter.printLevelIndexGrid(tfilename); } -void PDESolver::printGrid(SGPP::base::DataVector& alpha, - float_t PointesPerDimension, std::string tfilename) const { +void PDESolver::printGrid(SGPP::base::DataVector& alpha, float_t PointesPerDimension, + std::string tfilename) const { SGPP::base::GridPrinter myPrinter(*this->myGrid); myPrinter.printGrid(alpha, tfilename, static_cast(PointesPerDimension)); } -void PDESolver::printGridDomain(SGPP::base::DataVector& alpha, - float_t PointesPerDimension, +void PDESolver::printGridDomain(SGPP::base::DataVector& alpha, float_t PointesPerDimension, SGPP::base::BoundingBox& GridArea, std::string tfilename) const { SGPP::base::GridPrinter myPrinter(*this->myGrid); - myPrinter.printGridDomain(alpha, tfilename, GridArea, - static_cast(PointesPerDimension)); + myPrinter.printGridDomain(alpha, tfilename, GridArea, static_cast(PointesPerDimension)); } -void PDESolver::printSparseGrid(SGPP::base::DataVector& alpha, - std::string tfilename, bool bSurplus) const { +void PDESolver::printSparseGrid(SGPP::base::DataVector& alpha, std::string tfilename, + bool bSurplus) const { SGPP::base::GridPrinter myPrinter(*this->myGrid); myPrinter.printSparseGrid(alpha, tfilename, bSurplus); } -void PDESolver::printSparseGridExpTransform(SGPP::base::DataVector& alpha, - std::string tfilename, bool bSurplus) const { +void PDESolver::printSparseGridExpTransform(SGPP::base::DataVector& alpha, std::string tfilename, + bool bSurplus) const { SGPP::base::GridPrinter myPrinter(*this->myGrid); myPrinter.printSparseGridExpTransform(alpha, tfilename, bSurplus); } -float_t PDESolver::evaluatePoint(std::vector& evalPoint, - SGPP::base::DataVector& alpha) { +float_t PDESolver::evaluatePoint(std::vector& evalPoint, SGPP::base::DataVector& alpha) { float_t result = 0.0; if (bGridConstructed) { - SGPP::base::OperationEval* myEval = SGPP::op_factory::createOperationEval( - *myGrid); + SGPP::base::OperationEval* myEval = SGPP::op_factory::createOperationEval(*myGrid); result = myEval->eval(alpha, evalPoint); delete myEval; } else { - throw new SGPP::base::application_exception("PDESolver::evaluatePoint : A grid wasn't constructed before!"); + throw new SGPP::base::application_exception( + "PDESolver::evaluatePoint : A grid wasn't constructed before!"); } return result; } -void PDESolver::evaluateCuboid(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& OptionPrices, +void PDESolver::evaluateCuboid(SGPP::base::DataVector& alpha, SGPP::base::DataVector& OptionPrices, SGPP::base::DataMatrix& EvaluationPoints) { if (bGridConstructed) { if (OptionPrices.getSize() != EvaluationPoints.getNrows()) { throw new SGPP::base::application_exception( - "PDESolver::evaluateCuboid : The size of the price vector doesn't match the size of the evaluation points' vector!"); + "PDESolver::evaluateCuboid : The size of the price vector doesn't match the size of the " + "evaluation points' vector!"); } SGPP::base::OperationMultipleEval* myOpMultEval = - SGPP::op_factory::createOperationMultipleEval(*myGrid, - EvaluationPoints); + SGPP::op_factory::createOperationMultipleEval(*myGrid, EvaluationPoints); myOpMultEval->mult(alpha, OptionPrices); delete myOpMultEval; } else { - throw new SGPP::base::application_exception("PDESolver::evaluateCuboid : A grid wasn't constructed before!"); + throw new SGPP::base::application_exception( + "PDESolver::evaluateCuboid : A grid wasn't constructed before!"); } } @@ -313,7 +305,8 @@ size_t PDESolver::getNumberGridPoints() const { if (bGridConstructed) { return myGridStorage->size(); } else { - throw new SGPP::base::application_exception("PDESolver::getNumberGridPoints : A grid wasn't constructed before!"); + throw new SGPP::base::application_exception( + "PDESolver::getNumberGridPoints : A grid wasn't constructed before!"); } } @@ -321,7 +314,8 @@ size_t PDESolver::getNumberInnerGridPoints() const { if (bGridConstructed) { return myGridStorage->getNumInnerPoints(); } else { - throw new SGPP::base::application_exception("PDESolver::getNumberGridPoints : A grid wasn't constructed before!"); + throw new SGPP::base::application_exception( + "PDESolver::getNumberGridPoints : A grid wasn't constructed before!"); } } @@ -329,9 +323,9 @@ size_t PDESolver::getNumberDimensions() const { if (bGridConstructed) { return myGridStorage->dim(); } else { - throw new SGPP::base::application_exception("PDESolver::getNumberDimensions : A grid wasn't constructed before!"); + throw new SGPP::base::application_exception( + "PDESolver::getNumberDimensions : A grid wasn't constructed before!"); } } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/application/PDESolver.hpp b/pde/src/sgpp/pde/application/PDESolver.hpp index badc2b7682..12829ad521 100644 --- a/pde/src/sgpp/pde/application/PDESolver.hpp +++ b/pde/src/sgpp/pde/application/PDESolver.hpp @@ -12,10 +12,10 @@ #include #include -#include -// #include +#include +#include namespace SGPP { namespace pde { @@ -45,16 +45,16 @@ class PDESolver { * of a normal distribution given by norm_mu and norm_sigma. * The result is stored dehierarchized in alpha. * - * @param alpha contains dehierarchized sparse grid coefficients containing the values of the multi dimensional normal distribution after call + * @param alpha contains dehierarchized sparse grid coefficients containing the values of the + * multi dimensional normal distribution after call * @param norm_mu the expected values of the normal distribution for every grid dimension * @param norm_sigma the standard deviation of the normal distribution for every grid dimension */ virtual void getGridNormalDistribution(SGPP::base::DataVector& alpha, - std::vector& norm_mu, std::vector& norm_sigma); + std::vector& norm_mu, + std::vector& norm_sigma); public: - - /** * Std-Constructor of the solver */ @@ -71,8 +71,7 @@ class PDESolver { * @param myBoundingBox reference to a bounding box that describes the grid * @param level number of the regular's grid levels */ - virtual void constructGrid(SGPP::base::BoundingBox& myBoundingBox, - int level) = 0; + virtual void constructGrid(SGPP::base::BoundingBox& myBoundingBox, int level) = 0; /** * Sets the grid used in this BlackScholes Solver by an given serialized string @@ -100,11 +99,12 @@ class PDESolver { * first. The number of grid points to refine may be specified by the numRefinePoints parameter. * * @param alpha a SGPP::base::DataVector containing the grids coefficients - * @param numRefinePoints the number of grid points that should be refined; if this smaller than zero -> all refineable points will be refined + * @param numRefinePoints the number of grid points that should be refined; if this smaller than + * zero -> all refineable points will be refined * @param dThreshold Threshold for a point's surplus for refining this point */ - void refineInitialGridSurplus(SGPP::base::DataVector& alpha, - int numRefinePoints, float_t dThreshold); + void refineInitialGridSurplus(SGPP::base::DataVector& alpha, int numRefinePoints, + float_t dThreshold); /** * Refines a grid by taking the grid's coefficients into account. This refinement method @@ -116,8 +116,8 @@ class PDESolver { * @param dThreshold Threshold for a point's surplus for refining this point * @param maxLevel maxLevel of refinement */ - void refineInitialGridSurplusToMaxLevel(SGPP::base::DataVector& alpha, - float_t dThreshold, SGPP::base::GridStorage::index_type::level_type maxLevel); + void refineInitialGridSurplusToMaxLevel(SGPP::base::DataVector& alpha, float_t dThreshold, + SGPP::base::GridStorage::index_type::level_type maxLevel); /** * Refines a grid by taking the grid's coefficients into account. This refinement method @@ -129,13 +129,14 @@ class PDESolver { * and norm_sigma which are d-dimensional vectors. * * @param alpha a SGPP::base::DataVector containing the grids coefficients - * @param numRefinePoints the number of grid points that should be refined; if this smaller than zero -> all refineable points will be refined + * @param numRefinePoints the number of grid points that should be refined; if this smaller than + * zero -> all refineable points will be refined * @param dThreshold Threshold for a point's surplus for refining this point * @param norm_mu the expected values of the normal distribution for every grid dimension * @param norm_sigma the standard deviation of the normal distribution for every grid dimension */ - void refineInitialGridSurplusSubDomain(SGPP::base::DataVector& alpha, - int numRefinePoints, float_t dThreshold, std::vector& norm_mu, + void refineInitialGridSurplusSubDomain(SGPP::base::DataVector& alpha, int numRefinePoints, + float_t dThreshold, std::vector& norm_mu, std::vector& norm_sigma); /** @@ -154,9 +155,10 @@ class PDESolver { * @param norm_mu the expected values of the normal distribution for every grid dimension * @param norm_sigma the standard deviation of the normal distribution for every grid dimension */ - void refineInitialGridSurplusToMaxLevelSubDomain(SGPP::base::DataVector& alpha, - float_t dThreshold, SGPP::base::GridStorage::index_type::level_type maxLevel, - std::vector& norm_mu, std::vector& norm_sigma); + void refineInitialGridSurplusToMaxLevelSubDomain( + SGPP::base::DataVector& alpha, float_t dThreshold, + SGPP::base::GridStorage::index_type::level_type maxLevel, std::vector& norm_mu, + std::vector& norm_sigma); /** * Coarsens a grid by taking the grid's coefficients into account. This coarsen method @@ -166,8 +168,7 @@ class PDESolver { * @param alpha a SGPP::base::DataVector containing the grids coefficients * @param dThreshold Threshold for a point's surplus for coarsening this point */ - void coarsenInitialGridSurplus(SGPP::base::DataVector& alpha, - float_t dThreshold); + void coarsenInitialGridSurplus(SGPP::base::DataVector& alpha, float_t dThreshold); /** * Determines the value of the function in the d-dimensional space @@ -177,19 +178,19 @@ class PDESolver { * * @return price of option for given point */ - float_t evaluatePoint(std::vector& evalPoint, - SGPP::base::DataVector& alpha); + float_t evaluatePoint(std::vector& evalPoint, SGPP::base::DataVector& alpha); /** * Evaluates the sparse grid's function given by the stored grid and the alpha coefficients. * on different points specified in EvaluationPoints and stores the result into FunctionValues. * * @param alpha the sparse grid's coefficients - * @param FunctionValues SGPP::base::DataVector into the which the result of function's evaluation is stored - * @param EvaluationPoints SGPP::base::DataMatrix that contains the points at which the sparse grid's function is evaluated + * @param FunctionValues SGPP::base::DataVector into the which the result of function's evaluation + * is stored + * @param EvaluationPoints SGPP::base::DataMatrix that contains the points at which the sparse + * grid's function is evaluated */ - void evaluateCuboid(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& FunctionValues, + void evaluateCuboid(SGPP::base::DataVector& alpha, SGPP::base::DataVector& FunctionValues, SGPP::base::DataMatrix& EvaluationPoints); /** @@ -209,8 +210,8 @@ class PDESolver { * @param PointesPerDimension the distance between evaluation points * @param tfilename absolute path to file into which the grid's evaluation is written */ - virtual void printGrid(SGPP::base::DataVector& alpha, - float_t PointesPerDimension, std::string tfilename) const; + virtual void printGrid(SGPP::base::DataVector& alpha, float_t PointesPerDimension, + std::string tfilename) const; /** * This is some kind of debug functionality. It writes a file, @@ -223,12 +224,12 @@ class PDESolver { * @param GridArea the area in which the function should be plotted * @param tfilename absolute path to file into which the grid's evaluation is written */ - virtual void printGridDomain(SGPP::base::DataVector& alpha, - float_t PointesPerDimension, SGPP::base::BoundingBox& GridArea, - std::string tfilename) const; + virtual void printGridDomain(SGPP::base::DataVector& alpha, float_t PointesPerDimension, + SGPP::base::BoundingBox& GridArea, std::string tfilename) const; /** - * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis value + * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis + * value * or their hierarchical surplus * * This function is available for all dimensions @@ -237,11 +238,12 @@ class PDESolver { * @param tfilename absoulte path to the file the grid is written into * @param bSurplus specifies whether the surplus (true) or the node basis value (false) is written */ - virtual void printSparseGrid(SGPP::base::DataVector& alpha, - std::string tfilename, bool bSurplus) const; + virtual void printSparseGrid(SGPP::base::DataVector& alpha, std::string tfilename, + bool bSurplus) const; /** - * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis value + * Prints the SGPP::base::Grid Points of the Sparse SGPP::base::Grid either with their node basis + * value * or their hierarchical surplus * * This function is available for all dimensions. @@ -253,8 +255,8 @@ class PDESolver { * @param tfilename absoulte path to the file the grid is written into * @param bSurplus specifies whether the surplus (true) or the node basis value (false) is written */ - virtual void printSparseGridExpTransform(SGPP::base::DataVector& alpha, - std::string tfilename, bool bSurplus) const; + virtual void printSparseGridExpTransform(SGPP::base::DataVector& alpha, std::string tfilename, + bool bSurplus) const; /** * use this to determine the number of grid points, used to solve @@ -276,12 +278,12 @@ class PDESolver { * use this the determine the number of dimensions that are currently used * in the solver. * - * @return returns the number of the grid's dimensions, if the grid isn't constructed, yet it returns 0 + * @return returns the number of the grid's dimensions, if the grid isn't constructed, yet it + * returns 0 */ size_t getNumberDimensions() const; }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* PDESOLVER_HPP */ \ No newline at end of file +#endif /* PDESOLVER_HPP */ diff --git a/pde/src/sgpp/pde/application/ParabolicPDESolver.cpp b/pde/src/sgpp/pde/application/ParabolicPDESolver.cpp index 42e88cd510..55128d3625 100644 --- a/pde/src/sgpp/pde/application/ParabolicPDESolver.cpp +++ b/pde/src/sgpp/pde/application/ParabolicPDESolver.cpp @@ -7,15 +7,11 @@ #include - namespace SGPP { namespace pde { -ParabolicPDESolver::ParabolicPDESolver() : PDESolver() { -} - -ParabolicPDESolver::~ParabolicPDESolver() { -} +ParabolicPDESolver::ParabolicPDESolver() : PDESolver() {} -} -} \ No newline at end of file +ParabolicPDESolver::~ParabolicPDESolver() {} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/application/ParabolicPDESolver.hpp b/pde/src/sgpp/pde/application/ParabolicPDESolver.hpp index 3d0a16bd73..56f9e12995 100644 --- a/pde/src/sgpp/pde/application/ParabolicPDESolver.hpp +++ b/pde/src/sgpp/pde/application/ParabolicPDESolver.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -22,9 +21,9 @@ namespace pde { class ParabolicPDESolver : public PDESolver { protected: /// the size of one timestep - //float_t timestepSize; + // float_t timestepSize; /// The number of timesteps that are executed during solving - //size_t nTimesteps; + // size_t nTimesteps; public: /** @@ -46,11 +45,12 @@ class ParabolicPDESolver : public PDESolver { * @param epsilonCG the epsilon used in the CG * @param alpha the coefficients of the Sparse Gird's basis functions * @param verbose enables verbose output during solving - * @param generateAnimation set this to true, if you want to generate a grid output in every timestep + * @param generateAnimation set this to true, if you want to generate a grid output in every + * timestep * @param numEvalsAnimation specifies the evaluation per dimension when a animation is created */ - virtual void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, + virtual void solveImplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, bool generateAnimation = false, size_t numEvalsAnimation = 20) = 0; @@ -63,11 +63,12 @@ class ParabolicPDESolver : public PDESolver { * @param epsilonCG the epsilon used in the CG * @param alpha the coefficients of the Sparse Gird's basis functions * @param verbose enables verbose output during solving - * @param generateAnimation set this to true, if you want to generate a grid output in every timestep + * @param generateAnimation set this to true, if you want to generate a grid output in every + * timestep * @param numEvalsAnimation specifies the evaluation per dimension when a animation is created */ - virtual void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, + virtual void solveExplicitEuler(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, bool verbose = false, bool generateAnimation = false, size_t numEvalsAnimation = 20) = 0; @@ -79,14 +80,14 @@ class ParabolicPDESolver : public PDESolver { * @param maxCGIterations the maximum of interation in the CG solver * @param epsilonCG the epsilon used in the CG * @param alpha the coefficients of the Sparse Gird's basis functions - * @param NumImEul specifies how many ImEul steps should be executed before CrNic is used, default is 0 + * @param NumImEul specifies how many ImEul steps should be executed before CrNic is used, default + * is 0 */ - virtual void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, - size_t maxCGIterations, float_t epsilonCG, SGPP::base::DataVector& alpha, + virtual void solveCrankNicolson(size_t numTimesteps, float_t timestepsize, size_t maxCGIterations, + float_t epsilonCG, SGPP::base::DataVector& alpha, size_t NumImEul = 0) = 0; }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* PARABOLICPDESOLVER_HPP */ \ No newline at end of file +#endif /* PARABOLICPDESOLVER_HPP */ diff --git a/pde/src/sgpp/pde/application/PoissonEquationSolver.cpp b/pde/src/sgpp/pde/application/PoissonEquationSolver.cpp index a52bf1a8c1..09b270faaa 100644 --- a/pde/src/sgpp/pde/application/PoissonEquationSolver.cpp +++ b/pde/src/sgpp/pde/application/PoissonEquationSolver.cpp @@ -10,14 +10,13 @@ #include #include #include -#include -#include -#include -using namespace SGPP::solver; -using namespace SGPP::base; #include +#include +#include +#include +#include namespace SGPP { namespace pde { @@ -33,13 +32,13 @@ PoissonEquationSolver::~PoissonEquationSolver() { } } -void PoissonEquationSolver::constructGrid(BoundingBox& BoundingBox, int level) { +void PoissonEquationSolver::constructGrid(base::BoundingBox& BoundingBox, int level) { this->dim = BoundingBox.getDimensions(); this->levels = level; - this->myGrid = new LinearBoundaryGrid(BoundingBox); + this->myGrid = new base::LinearBoundaryGrid(BoundingBox); - GridGenerator* myGenerator = this->myGrid->createGridGenerator(); + base::GridGenerator* myGenerator = this->myGrid->createGridGenerator(); myGenerator->regular(this->levels); delete myGenerator; @@ -49,31 +48,32 @@ void PoissonEquationSolver::constructGrid(BoundingBox& BoundingBox, int level) { this->bGridConstructed = true; } -void PoissonEquationSolver::solvePDE(DataVector& alpha, DataVector& rhs, +void PoissonEquationSolver::solvePDE(base::DataVector& alpha, base::DataVector& rhs, size_t maxCGIterations, float_t epsilonCG, bool verbose) { float_t dTimeAlpha = 0.0; float_t dTimeRHS = 0.0; float_t dTimeSolver = 0.0; - SGppStopwatch* myStopwatch = new SGppStopwatch(); - ConjugateGradients* myCG = new ConjugateGradients(maxCGIterations, epsilonCG); - PoissonEquationEllipticPDESolverSystemDirichlet* mySystem = new - PoissonEquationEllipticPDESolverSystemDirichlet(*(this->myGrid), rhs); + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); + solver::ConjugateGradients* myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); + PoissonEquationEllipticPDESolverSystemDirichlet* mySystem = + new PoissonEquationEllipticPDESolverSystemDirichlet(*(this->myGrid), rhs); - std::cout << "Gridpoints (complete grid): " << - mySystem->getNumGridPointsComplete() << std::endl; - std::cout << "Gridpoints (inner grid): " << mySystem->getNumGridPointsInner() << - std::endl << std::endl << std::endl; + std::cout << "Gridpoints (complete grid): " << mySystem->getNumGridPointsComplete() << std::endl; + std::cout << "Gridpoints (inner grid): " << mySystem->getNumGridPointsInner() << std::endl + << std::endl + << std::endl; myStopwatch->start(); - DataVector* alpha_solve = mySystem->getGridCoefficientsForCG(); + base::DataVector* alpha_solve = mySystem->getGridCoefficientsForCG(); dTimeAlpha = myStopwatch->stop(); std::cout << "coefficients has been initialized for solving!" << std::endl; myStopwatch->start(); - DataVector* rhs_solve = mySystem->generateRHS(); + base::DataVector* rhs_solve = mySystem->generateRHS(); dTimeRHS = myStopwatch->stop(); - std::cout << "right hand side has been initialized for solving!" << std::endl << - std::endl << std::endl; + std::cout << "right hand side has been initialized for solving!" << std::endl + << std::endl + << std::endl; myStopwatch->start(); myCG->solve(*mySystem, *alpha_solve, *rhs_solve, true, verbose, 0.0); @@ -83,33 +83,33 @@ void PoissonEquationSolver::solvePDE(DataVector& alpha, DataVector& rhs, dTimeSolver = myStopwatch->stop(); std::cout << std::endl << std::endl; - std::cout << "Gridpoints (complete grid): " << - mySystem->getNumGridPointsComplete() << std::endl; - std::cout << "Gridpoints (inner grid): " << mySystem->getNumGridPointsInner() << - std::endl << std::endl << std::endl; + std::cout << "Gridpoints (complete grid): " << mySystem->getNumGridPointsComplete() << std::endl; + std::cout << "Gridpoints (inner grid): " << mySystem->getNumGridPointsInner() << std::endl + << std::endl + << std::endl; std::cout << "Timings for solving Poisson Equation" << std::endl; std::cout << "------------------------------------" << std::endl; std::cout << "Time for creating CG coeffs: " << dTimeAlpha << std::endl; std::cout << "Time for creating RHS: " << dTimeRHS << std::endl; std::cout << "Time for solving: " << dTimeSolver << std::endl << std::endl; - std::cout << "Time: " << dTimeAlpha + dTimeRHS + dTimeSolver << std::endl << - std::endl << std::endl; + std::cout << "Time: " << dTimeAlpha + dTimeRHS + dTimeSolver << std::endl + << std::endl + << std::endl; delete myCG; - delete mySystem; // alpha_solver and rhs_solve are allocated and freed here!! + delete mySystem; // alpha_solver and rhs_solve are allocated and freed here!! delete myStopwatch; } -void PoissonEquationSolver::initGridWithSmoothHeat(DataVector& alpha, - float_t mu, float_t sigma, float_t factor) { +void PoissonEquationSolver::initGridWithSmoothHeat(base::DataVector& alpha, float_t mu, + float_t sigma, float_t factor) { if (this->bGridConstructed) { float_t tmp; float_t* dblFuncValues = new float_t[this->dim]; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); bool isInner = true; @@ -117,8 +117,8 @@ void PoissonEquationSolver::initGridWithSmoothHeat(DataVector& alpha, coordsStream >> tmp; // determine if a grid point is an inner grid point - if ((tmp != this->myBoundingBox->getBoundary(j).leftBoundary - && tmp != this->myBoundingBox->getBoundary(j).rightBoundary)) { + if ((tmp != this->myBoundingBox->getBoundary(j).leftBoundary && + tmp != this->myBoundingBox->getBoundary(j).rightBoundary)) { // Nothtin to do, test is that qay hence == for floating point values is unsave } else { isInner = false; @@ -131,8 +131,9 @@ void PoissonEquationSolver::initGridWithSmoothHeat(DataVector& alpha, tmp = 1.0; for (size_t j = 0; j < this->dim; j++) { - tmp *= factor * factor * ((1.0 / (sigma * 2.0 * 3.145)) * exp((-0.5) * (( - dblFuncValues[j] - mu) / sigma) * ((dblFuncValues[j] - mu) / sigma))); + tmp *= factor * factor * + ((1.0 / (sigma * 2.0 * 3.145)) * exp((-0.5) * ((dblFuncValues[j] - mu) / sigma) * + ((dblFuncValues[j] - mu) / sigma))); } } else { tmp = 0.0; @@ -143,24 +144,24 @@ void PoissonEquationSolver::initGridWithSmoothHeat(DataVector& alpha, delete[] dblFuncValues; - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + SGPP::op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("HeatEquationSolver::initGridWithSmoothHeat : A grid wasn't constructed before!"); + throw new base::application_exception( + "HeatEquationSolver::initGridWithSmoothHeat : A grid wasn't constructed before!"); } } -void PoissonEquationSolver::initGridWithSmoothHeatFullDomain(DataVector& alpha, - float_t mu, float_t sigma, float_t factor) { +void PoissonEquationSolver::initGridWithSmoothHeatFullDomain(base::DataVector& alpha, float_t mu, + float_t sigma, float_t factor) { if (this->bGridConstructed) { float_t tmp; float_t* dblFuncValues = new float_t[this->dim]; for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); for (size_t j = 0; j < this->dim; j++) { @@ -172,8 +173,9 @@ void PoissonEquationSolver::initGridWithSmoothHeatFullDomain(DataVector& alpha, tmp = 1.0; for (size_t j = 0; j < this->dim; j++) { - tmp *= factor * factor * ((1.0 / (sigma * 2.0 * 3.145)) * exp((-0.5) * (( - dblFuncValues[j] - mu) / sigma) * ((dblFuncValues[j] - mu) / sigma))); + tmp *= factor * factor * + ((1.0 / (sigma * 2.0 * 3.145)) * exp((-0.5) * ((dblFuncValues[j] - mu) / sigma) * + ((dblFuncValues[j] - mu) / sigma))); } alpha[i] = tmp; @@ -181,31 +183,30 @@ void PoissonEquationSolver::initGridWithSmoothHeatFullDomain(DataVector& alpha, delete[] dblFuncValues; - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + SGPP::op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("HeatEquationSolver::initGridWithSmoothHeatFullDomain : A grid wasn't constructed before!"); + throw new base::application_exception( + "HeatEquationSolver::initGridWithSmoothHeatFullDomain : A grid wasn't constructed before!"); } } -void PoissonEquationSolver::initGridWithExpHeat(DataVector& alpha, - float_t factor) { +void PoissonEquationSolver::initGridWithExpHeat(base::DataVector& alpha, float_t factor) { if (this->bGridConstructed) { float_t tmp; float_t* dblFuncValues = new float_t[this->dim]; float_t* rightBound = new float_t[this->dim]; - BoundingBox* tmpBB = this->myGrid->getBoundingBox(); + base::BoundingBox* tmpBB = this->myGrid->getBoundingBox(); for (size_t j = 0; j < this->dim; j++) { rightBound[j] = (tmpBB->getBoundary(j)).rightBoundary; } for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); bool isInner = true; tmp = 0.0; @@ -214,8 +215,8 @@ void PoissonEquationSolver::initGridWithExpHeat(DataVector& alpha, coordsStream >> tmp; // determine if a grid point is an inner grid point - if ((tmp != this->myBoundingBox->getBoundary(j).leftBoundary - && tmp != this->myBoundingBox->getBoundary(j).rightBoundary)) { + if ((tmp != this->myBoundingBox->getBoundary(j).leftBoundary && + tmp != this->myBoundingBox->getBoundary(j).rightBoundary)) { // Nothtin to do, test is that qay hence == for floating point values is unsave } else { isInner = false; @@ -239,31 +240,30 @@ void PoissonEquationSolver::initGridWithExpHeat(DataVector& alpha, delete[] dblFuncValues; - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + SGPP::op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("PoissonEquationSolver::initGridWithExpHeat : A grid wasn't constructed before!"); + throw new base::application_exception( + "PoissonEquationSolver::initGridWithExpHeat : A grid wasn't constructed before!"); } } -void PoissonEquationSolver::initGridWithExpHeatFullDomain(DataVector& alpha, - float_t factor) { +void PoissonEquationSolver::initGridWithExpHeatFullDomain(base::DataVector& alpha, float_t factor) { if (this->bGridConstructed) { float_t tmp; float_t* dblFuncValues = new float_t[this->dim]; float_t* rightBound = new float_t[this->dim]; - BoundingBox* tmpBB = this->myGrid->getBoundingBox(); + base::BoundingBox* tmpBB = this->myGrid->getBoundingBox(); for (size_t j = 0; j < this->dim; j++) { rightBound[j] = (tmpBB->getBoundary(j)).rightBoundary; } for (size_t i = 0; i < this->myGrid->getStorage()->size(); i++) { - std::string coords = this->myGridStorage->get(i)->getCoordsStringBB( - *this->myBoundingBox); + std::string coords = this->myGridStorage->get(i)->getCoordsStringBB(*this->myBoundingBox); std::stringstream coordsStream(coords); tmp = 0.0; @@ -284,24 +284,24 @@ void PoissonEquationSolver::initGridWithExpHeatFullDomain(DataVector& alpha, delete[] dblFuncValues; - OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*this->myGrid); + base::OperationHierarchisation* myHierarchisation = + SGPP::op_factory::createOperationHierarchisation(*this->myGrid); myHierarchisation->doHierarchisation(alpha); delete myHierarchisation; } else { - throw new application_exception("PoissonEquationSolver::initGridWithExpHeat : A grid wasn't constructed before!"); + throw new base::application_exception( + "PoissonEquationSolver::initGridWithExpHeat : A grid wasn't constructed before!"); } } -void PoissonEquationSolver::storeInnerRHS(DataVector& alpha, - std::string tFilename) { - SGppStopwatch* myStopwatch = new SGppStopwatch(); - PoissonEquationEllipticPDESolverSystemDirichlet* mySystem = new - PoissonEquationEllipticPDESolverSystemDirichlet(*(this->myGrid), alpha); +void PoissonEquationSolver::storeInnerRHS(base::DataVector& alpha, std::string tFilename) { + base::SGppStopwatch* myStopwatch = new base::SGppStopwatch(); + PoissonEquationEllipticPDESolverSystemDirichlet* mySystem = + new PoissonEquationEllipticPDESolverSystemDirichlet(*(this->myGrid), alpha); std::cout << "Exporting inner right-hand-side..." << std::endl; myStopwatch->start(); - DataVector* rhs_inner = mySystem->generateRHS(); + base::DataVector* rhs_inner = mySystem->generateRHS(); size_t nCoefs = rhs_inner->getSize(); std::ofstream outfile(tFilename.c_str()); @@ -311,23 +311,25 @@ void PoissonEquationSolver::storeInnerRHS(DataVector& alpha, } outfile.close(); - std::cout << "Exporting inner right-hand-side... DONE! (" << myStopwatch->stop() - << " s)" << std::endl << std::endl << std::endl; + std::cout << "Exporting inner right-hand-side... DONE! (" << myStopwatch->stop() << " s)" + << std::endl + << std::endl + << std::endl; - delete mySystem; // rhs_inner are allocated and freed here!! + delete mySystem; // rhs_inner are allocated and freed here!! delete myStopwatch; } -void PoissonEquationSolver::storeInnerSolution(DataVector& alpha, - size_t maxCGIterations, float_t epsilonCG, std::string tFilename) { - ConjugateGradients* myCG = new ConjugateGradients(maxCGIterations, epsilonCG); - PoissonEquationEllipticPDESolverSystemDirichlet* mySystem = new - PoissonEquationEllipticPDESolverSystemDirichlet(*(this->myGrid), alpha); +void PoissonEquationSolver::storeInnerSolution(base::DataVector& alpha, size_t maxCGIterations, + float_t epsilonCG, std::string tFilename) { + solver::ConjugateGradients* myCG = new solver::ConjugateGradients(maxCGIterations, epsilonCG); + PoissonEquationEllipticPDESolverSystemDirichlet* mySystem = + new PoissonEquationEllipticPDESolverSystemDirichlet(*(this->myGrid), alpha); std::cout << "Exporting inner solution..." << std::endl; - DataVector* alpha_solve = mySystem->getGridCoefficientsForCG(); - DataVector* rhs_solve = mySystem->generateRHS(); + base::DataVector* alpha_solve = mySystem->getGridCoefficientsForCG(); + base::DataVector* rhs_solve = mySystem->generateRHS(); myCG->solve(*mySystem, *alpha_solve, *rhs_solve, true, false, 0.0); @@ -343,14 +345,13 @@ void PoissonEquationSolver::storeInnerSolution(DataVector& alpha, std::cout << "Exporting inner solution... DONE!" << std::endl; delete myCG; - delete mySystem; // alpha_solver and rhs_solve are allocated and freed here!! + delete mySystem; // alpha_solver and rhs_solve are allocated and freed here!! } void PoissonEquationSolver::initScreen() { - this->myScreen = new ScreenOutput(); + this->myScreen = new base::ScreenOutput(); this->myScreen->writeTitle("SGpp - Poisson Equation Solver, 1.0.0", "Alexander Heinecke, (C) 2009-2011"); } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/application/PoissonEquationSolver.hpp b/pde/src/sgpp/pde/application/PoissonEquationSolver.hpp index 7856e78a18..b25b10767f 100644 --- a/pde/src/sgpp/pde/application/PoissonEquationSolver.hpp +++ b/pde/src/sgpp/pde/application/PoissonEquationSolver.hpp @@ -6,7 +6,6 @@ #ifndef POISSONEQUATIONSOLVER_HPP #define POISSONEQUATIONSOLVER_HPP - #include #include @@ -16,16 +15,15 @@ #include +#include +#include + #include #include #include #include #include -#include -#include - - namespace SGPP { namespace pde { @@ -55,8 +53,8 @@ class PoissonEquationSolver : public EllipticPDESolver { void constructGrid(SGPP::base::BoundingBox& myBoundingBox, int level); - void solvePDE(SGPP::base::DataVector& alpha, SGPP::base::DataVector& rhs, - size_t maxCGIterations, float_t epsilonCG, bool verbose = false); + void solvePDE(SGPP::base::DataVector& alpha, SGPP::base::DataVector& rhs, size_t maxCGIterations, + float_t epsilonCG, bool verbose = false); /** * Inits the grid with a smooth heat distribution (based on @@ -70,8 +68,8 @@ class PoissonEquationSolver : public EllipticPDESolver { * @param sigma the sigma of the normal distribution * @param factor a factor that is used to stretch the function values */ - void initGridWithSmoothHeat(SGPP::base::DataVector& alpha, float_t mu, - float_t sigma, float_t factor); + void initGridWithSmoothHeat(SGPP::base::DataVector& alpha, float_t mu, float_t sigma, + float_t factor); /** * Inits the grid with a smooth heat distribution (based on @@ -86,8 +84,8 @@ class PoissonEquationSolver : public EllipticPDESolver { * @param sigma the sigma of the normal distribution * @param factor a factor that is used to stretch the function values */ - void initGridWithSmoothHeatFullDomain(SGPP::base::DataVector& alpha, float_t mu, - float_t sigma, float_t factor); + void initGridWithSmoothHeatFullDomain(SGPP::base::DataVector& alpha, float_t mu, float_t sigma, + float_t factor); /** * Inits the grid with a heat distribution based on @@ -111,8 +109,7 @@ class PoissonEquationSolver : public EllipticPDESolver { * @param alpha reference to the coefficient's vector * @param factor a constant factor used to enlarge the exp-functions input parameter */ - void initGridWithExpHeatFullDomain(SGPP::base::DataVector& alpha, - float_t factor = 1.0); + void initGridWithExpHeatFullDomain(SGPP::base::DataVector& alpha, float_t factor = 1.0); /** * Routine to export the RHS of the inner system which has to be @@ -132,16 +129,15 @@ class PoissonEquationSolver : public EllipticPDESolver { * @param epsilonCG the epsilon used in the C * @param tFilename file into which the rhs is written */ - void storeInnerSolution(SGPP::base::DataVector& alpha, size_t maxCGIterations, - float_t epsilonCG, std::string tFilename); + void storeInnerSolution(SGPP::base::DataVector& alpha, size_t maxCGIterations, float_t epsilonCG, + std::string tFilename); /** * Inits the screen object */ void initScreen(); }; - -} -} +} // namespace pde +} // namespace SGPP #endif /* POISSONEQUATIONSOLVER_HPP */ diff --git a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedDownBBLinearBoundary.cpp b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedDownBBLinearBoundary.cpp index 7b57d3dca1..3af6815534 100644 --- a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedDownBBLinearBoundary.cpp +++ b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedDownBBLinearBoundary.cpp @@ -7,19 +7,18 @@ #include - namespace SGPP { namespace pde { LaplaceEnhancedDownBBLinearBoundary::LaplaceEnhancedDownBBLinearBoundary( - SGPP::base::GridStorage* storage) : LaplaceEnhancedDownBBLinear(storage) { -} + SGPP::base::GridStorage* storage) + : LaplaceEnhancedDownBBLinear(storage) {} -LaplaceEnhancedDownBBLinearBoundary::~LaplaceEnhancedDownBBLinearBoundary() { -} +LaplaceEnhancedDownBBLinearBoundary::~LaplaceEnhancedDownBBLinearBoundary() {} -void LaplaceEnhancedDownBBLinearBoundary::operator()(SGPP::base::DataMatrix& - source, SGPP::base::DataMatrix& result, grid_iterator& index, size_t dim) { +void LaplaceEnhancedDownBBLinearBoundary::operator()(SGPP::base::DataMatrix& source, + SGPP::base::DataMatrix& result, + grid_iterator& index, size_t dim) { q_ = this->boundingBox->getIntervalWidth(this->algoDims[dim]); t_ = this->boundingBox->getIntervalOffset(this->algoDims[dim]); float_t q_reci = 1.0 / q_; @@ -101,7 +100,7 @@ void LaplaceEnhancedDownBBLinearBoundary::operator()(SGPP::base::DataMatrix& } } - for ( ; i < this->numAlgoDims_; i++) { + for (; i < this->numAlgoDims_; i++) { float_t fl = source.get(seq_left, i); float_t fr = source.get(seq_right, i); @@ -140,7 +139,7 @@ void LaplaceEnhancedDownBBLinearBoundary::operator()(SGPP::base::DataMatrix& float_t fr1 = source.get(seq_right, i); float_t fr2 = source.get(seq_right, i + 1); #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 __m128d fl_xmm = _mm_set_pd(fl2, fl1); __m128d fr_xmm = _mm_set_pd(fr2, fr1); #endif @@ -181,7 +180,7 @@ void LaplaceEnhancedDownBBLinearBoundary::operator()(SGPP::base::DataMatrix& calcL2Boundary(fl1, fr1, seq_left, seq_right, i, cur_algo_dim_, 1.0); calcL2Boundary(fl2, fr2, seq_left, seq_right, i + 1, cur_algo_dim_, 1.0); #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 if (!index.hint()) { index.resetToLevelOne(dim); @@ -236,7 +235,7 @@ void LaplaceEnhancedDownBBLinearBoundary::operator()(SGPP::base::DataMatrix& } } - for ( ; i < this->numAlgoDims_; i++) { + for (; i < this->numAlgoDims_; i++) { float_t fl = source.get(seq_left, i); float_t fr = source.get(seq_right, i); @@ -259,7 +258,6 @@ void LaplaceEnhancedDownBBLinearBoundary::operator()(SGPP::base::DataMatrix& index.resetToLevelOne(dim); if (!this->storage->end(index.seq())) { - rec(fl, fr, i, index); } @@ -270,23 +268,24 @@ void LaplaceEnhancedDownBBLinearBoundary::operator()(SGPP::base::DataMatrix& } } -void LaplaceEnhancedDownBBLinearBoundary::calcL2Boundary(float_t fl, float_t fr, - size_t seq_left, size_t seq_right, size_t dim, size_t algo_dim, float_t q) { +void LaplaceEnhancedDownBBLinearBoundary::calcL2Boundary(float_t fl, float_t fr, size_t seq_left, + size_t seq_right, size_t dim, + size_t algo_dim, float_t q) { if (this->boundingBox->hasDirichletBoundaryLeft(algo_dim)) ptr_result_[(seq_left * this->numAlgoDims_) + dim] = 0.0; else - ptr_result_[(seq_left * this->numAlgoDims_) + dim] = (1.0 / 3.0) * fl * q; + ptr_result_[(seq_left * this->numAlgoDims_) + dim] = (1.0 / 3.0) * fl * q; if (this->boundingBox->hasDirichletBoundaryRight(algo_dim)) ptr_result_[(seq_right * this->numAlgoDims_) + dim] = 0.0; else - ptr_result_[(seq_right * this->numAlgoDims_) + dim] = (( - 1.0 / 3.0) * fr * q) + ((1.0 / 6.0) * fl * q); + ptr_result_[(seq_right * this->numAlgoDims_) + dim] = + ((1.0 / 3.0) * fr * q) + ((1.0 / 6.0) * fl * q); } -void LaplaceEnhancedDownBBLinearBoundary::calcGradBoundary(float_t fl, - float_t fr, size_t seq_left, size_t seq_right, size_t dim, size_t algo_dim, - float_t q_reci) { +void LaplaceEnhancedDownBBLinearBoundary::calcGradBoundary(float_t fl, float_t fr, size_t seq_left, + size_t seq_right, size_t dim, + size_t algo_dim, float_t q_reci) { if (this->boundingBox->hasDirichletBoundaryLeft(algo_dim)) ptr_result_[(seq_left * this->numAlgoDims_) + dim] = 0.0; else @@ -295,11 +294,8 @@ void LaplaceEnhancedDownBBLinearBoundary::calcGradBoundary(float_t fl, if (this->boundingBox->hasDirichletBoundaryRight(cur_algo_dim_)) ptr_result_[(seq_right * this->numAlgoDims_) + dim] = 0.0; else - ptr_result_[(seq_right * this->numAlgoDims_) + dim] = fr + (( - -1.0 * q_reci) * fl); + ptr_result_[(seq_right * this->numAlgoDims_) + dim] = fr + ((-1.0 * q_reci) * fl); } -// namespace pde -} -// namespace SGPP -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedDownBBLinearBoundary.hpp b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedDownBBLinearBoundary.hpp index 9dfad5e024..41c5147181 100644 --- a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedDownBBLinearBoundary.hpp +++ b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedDownBBLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -34,8 +33,8 @@ class LaplaceEnhancedDownBBLinearBoundary : public LaplaceEnhancedDownBBLinear { * @param algo_dim current algorithmic dimension * @param q stretching of basis function in the current algorithmic dimension */ - void calcL2Boundary(float_t fl, float_t fr, size_t seq_left, size_t seq_right, - size_t dim, size_t algo_dim, float_t q); + void calcL2Boundary(float_t fl, float_t fr, size_t seq_left, size_t seq_right, size_t dim, + size_t algo_dim, float_t q); /** * calculates the gradient down operation on level 0 basis functions @@ -48,8 +47,8 @@ class LaplaceEnhancedDownBBLinearBoundary : public LaplaceEnhancedDownBBLinear { * @param algo_dim current algorithmic dimension * @param q_reci reciprocal of stretching of basis function in the current algorithmic dimension */ - void calcGradBoundary(float_t fl, float_t fr, size_t seq_left, size_t seq_right, - size_t dim, size_t algo_dim, float_t q_reci); + void calcGradBoundary(float_t fl, float_t fr, size_t seq_left, size_t seq_right, size_t dim, + size_t algo_dim, float_t q_reci); public: /** @@ -57,7 +56,7 @@ class LaplaceEnhancedDownBBLinearBoundary : public LaplaceEnhancedDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - LaplaceEnhancedDownBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit LaplaceEnhancedDownBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -68,18 +67,17 @@ class LaplaceEnhancedDownBBLinearBoundary : public LaplaceEnhancedDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * on a grid with Dirichlet 0 boundary conditions. * - * @param source SGPP::base::DataMatrix that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataMatrix that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataMatrix that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction', here all downs are calculated */ - virtual void operator()(SGPP::base::DataMatrix& source, - SGPP::base::DataMatrix& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataMatrix& source, SGPP::base::DataMatrix& result, + grid_iterator& index, size_t dim); }; -// namespace detail -} -// namespace SGPP -} +} // namespace pde +} // namespace SGPP #endif /* LAPLACEENHANCEDDOWNBBLINEARBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedUpBBLinearBoundary.cpp b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedUpBBLinearBoundary.cpp old mode 100755 new mode 100644 index b015a3c9dd..35e786388f --- a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedUpBBLinearBoundary.cpp +++ b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedUpBBLinearBoundary.cpp @@ -7,19 +7,18 @@ #include - namespace SGPP { namespace pde { LaplaceEnhancedUpBBLinearBoundary::LaplaceEnhancedUpBBLinearBoundary( - SGPP::base::GridStorage* storage) : LaplaceEnhancedUpBBLinear(storage) { -} + SGPP::base::GridStorage* storage) + : LaplaceEnhancedUpBBLinear(storage) {} -LaplaceEnhancedUpBBLinearBoundary::~LaplaceEnhancedUpBBLinearBoundary() { -} +LaplaceEnhancedUpBBLinearBoundary::~LaplaceEnhancedUpBBLinearBoundary() {} -void LaplaceEnhancedUpBBLinearBoundary::operator()(SGPP::base::DataMatrix& - source, SGPP::base::DataMatrix& result, grid_iterator& index, size_t dim) { +void LaplaceEnhancedUpBBLinearBoundary::operator()(SGPP::base::DataMatrix& source, + SGPP::base::DataMatrix& result, + grid_iterator& index, size_t dim) { q_ = this->boundingBox->getIntervalWidth(this->algoDims[dim]); t_ = this->boundingBox->getIntervalOffset(this->algoDims[dim]); float_t q_reci = 1.0 / q_; @@ -95,7 +94,7 @@ void LaplaceEnhancedUpBBLinearBoundary::operator()(SGPP::base::DataMatrix& } } - for ( ; i < this->numAlgoDims_; i++) { + for (; i < this->numAlgoDims_; i++) { if (dim == i) { if (!index.hint()) { index.resetToLevelOne(dim); @@ -167,7 +166,7 @@ void LaplaceEnhancedUpBBLinearBoundary::operator()(SGPP::base::DataMatrix& float_t fl2 = 0.0; float_t fr2 = 0.0; #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 __m128d fl_xmm = _mm_set1_pd(0.0); __m128d fr_xmm = _mm_set1_pd(0.0); @@ -236,7 +235,7 @@ void LaplaceEnhancedUpBBLinearBoundary::operator()(SGPP::base::DataMatrix& } } - for ( ; i < this->numAlgoDims_; i++) { + for (; i < this->numAlgoDims_; i++) { if (dim == i) { if (!index.hint()) { index.resetToLevelOne(dim); @@ -269,13 +268,14 @@ void LaplaceEnhancedUpBBLinearBoundary::operator()(SGPP::base::DataMatrix& } } -void LaplaceEnhancedUpBBLinearBoundary::calcL2Boundary(float_t fl, float_t fr, - size_t seq_left, size_t seq_right, size_t dim, size_t algo_dim, float_t q) { +void LaplaceEnhancedUpBBLinearBoundary::calcL2Boundary(float_t fl, float_t fr, size_t seq_left, + size_t seq_right, size_t dim, + size_t algo_dim, float_t q) { if (this->boundingBox->hasDirichletBoundaryLeft(algo_dim)) ptr_result_[(seq_left * this->numAlgoDims_) + dim] = 0.0; else - ptr_result_[(seq_left * this->numAlgoDims_) + dim] = fl + (( - 1.0 / 6.0) * ptr_source_[(seq_right * this->numAlgoDims_) + dim] * q); + ptr_result_[(seq_left * this->numAlgoDims_) + dim] = + fl + ((1.0 / 6.0) * ptr_source_[(seq_right * this->numAlgoDims_) + dim] * q); if (this->boundingBox->hasDirichletBoundaryRight(algo_dim)) ptr_result_[(seq_right * this->numAlgoDims_) + dim] = 0.0; @@ -283,14 +283,14 @@ void LaplaceEnhancedUpBBLinearBoundary::calcL2Boundary(float_t fl, float_t fr, ptr_result_[(seq_right * this->numAlgoDims_) + dim] = fr; } -void LaplaceEnhancedUpBBLinearBoundary::calcGradBoundary(float_t fl, float_t fr, - size_t seq_left, size_t seq_right, size_t dim, size_t algo_dim, - float_t q_reci) { +void LaplaceEnhancedUpBBLinearBoundary::calcGradBoundary(float_t fl, float_t fr, size_t seq_left, + size_t seq_right, size_t dim, + size_t algo_dim, float_t q_reci) { if (this->boundingBox->hasDirichletBoundaryLeft(algo_dim)) ptr_result_[(seq_left * this->numAlgoDims_) + dim] = 0.0; else - ptr_result_[(seq_left * this->numAlgoDims_) + dim] = ((-1.0 * q_reci) * - ptr_source_[(seq_right * this->numAlgoDims_) + dim]); + ptr_result_[(seq_left * this->numAlgoDims_) + dim] = + ((-1.0 * q_reci) * ptr_source_[(seq_right * this->numAlgoDims_) + dim]); if (this->boundingBox->hasDirichletBoundaryRight(cur_algo_dim_)) ptr_result_[(seq_right * this->numAlgoDims_) + dim] = 0.0; @@ -298,7 +298,5 @@ void LaplaceEnhancedUpBBLinearBoundary::calcGradBoundary(float_t fl, float_t fr, ptr_result_[(seq_right * this->numAlgoDims_) + dim] = 0.0; } -// namespace pde -} -// namespace SGPP -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedUpBBLinearBoundary.hpp b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedUpBBLinearBoundary.hpp old mode 100755 new mode 100644 index 4a82f98568..06874f1e89 --- a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedUpBBLinearBoundary.hpp +++ b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/LaplaceEnhancedUpBBLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -34,8 +33,8 @@ class LaplaceEnhancedUpBBLinearBoundary : public LaplaceEnhancedUpBBLinear { * @param algo_dim current algorithmic dimension * @param q stretching of basis function in the current algorithmic dimension */ - void calcL2Boundary(float_t fl, float_t fr, size_t seq_left, size_t seq_right, - size_t dim, size_t algo_dim, float_t q); + void calcL2Boundary(float_t fl, float_t fr, size_t seq_left, size_t seq_right, size_t dim, + size_t algo_dim, float_t q); /** * calculates the gradient up operation on level 0 basis functions @@ -48,8 +47,8 @@ class LaplaceEnhancedUpBBLinearBoundary : public LaplaceEnhancedUpBBLinear { * @param algo_dim current algorithmic dimension * @param q_reci reciprocal of stretching of basis function in the current algorithmic dimension */ - void calcGradBoundary(float_t fl, float_t fr, size_t seq_left, size_t seq_right, - size_t dim, size_t algo_dim, float_t q_reci); + void calcGradBoundary(float_t fl, float_t fr, size_t seq_left, size_t seq_right, size_t dim, + size_t algo_dim, float_t q_reci); public: /** @@ -57,7 +56,7 @@ class LaplaceEnhancedUpBBLinearBoundary : public LaplaceEnhancedUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - LaplaceEnhancedUpBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit LaplaceEnhancedUpBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -68,18 +67,17 @@ class LaplaceEnhancedUpBBLinearBoundary : public LaplaceEnhancedUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataMatrix& source, - SGPP::base::DataMatrix& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataMatrix& source, SGPP::base::DataMatrix& result, + grid_iterator& index, size_t dim); }; -// namespace detail -} -// namespace SGPP -} +} // namespace pde +} // namespace SGPP #endif /* LAPLACEENHANCEDUPBBLINEARBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiDownBBLinearBoundary.cpp b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiDownBBLinearBoundary.cpp index e947946aa1..7b5db1ff40 100644 --- a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiDownBBLinearBoundary.cpp +++ b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiDownBBLinearBoundary.cpp @@ -7,21 +7,19 @@ #include - namespace SGPP { namespace pde { -PhiPhiDownBBLinearBoundary::PhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* - storage) : PhiPhiDownBBLinear(storage) { -} +PhiPhiDownBBLinearBoundary::PhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage) + : PhiPhiDownBBLinear(storage) {} -PhiPhiDownBBLinearBoundary::~PhiPhiDownBBLinearBoundary() { -} +PhiPhiDownBBLinearBoundary::~PhiPhiDownBBLinearBoundary() {} void PhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { - //std::cout << dim << std::endl; - //std::cout << index.toString() << std::endl; + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { + // std::cout << dim << std::endl; + // std::cout << index.toString() << std::endl; float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -56,13 +54,13 @@ void PhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, if (useBB) { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary + result[seq_left] = 0.0; // left_boundary } else { result[seq_left] = ((1.0 / 3.0) * left_boundary) * q; } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = ((1.0 / 3.0) * right_boundary) * q; @@ -84,13 +82,13 @@ void PhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } else { // check boundary conditions if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary + result[seq_left] = 0.0; // left_boundary } else { result[seq_left] = (1.0 / 3.0) * left_boundary; } if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = (1.0 / 3.0) * right_boundary; @@ -112,7 +110,5 @@ void PhiPhiDownBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail -} -// namespace SGPP -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiDownBBLinearBoundary.hpp b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiDownBBLinearBoundary.hpp index cd284f0035..7aebf9f491 100644 --- a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiDownBBLinearBoundary.hpp +++ b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiDownBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace pde { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \phi(x) \phi(x) dx\f$ @@ -31,7 +28,7 @@ class PhiPhiDownBBLinearBoundary : public PhiPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - PhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit PhiPhiDownBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,24 +39,24 @@ class PhiPhiDownBBLinearBoundary : public PhiPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * * On level zero the getfixDirechletBoundaries of the storage object evaluated * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace pde +} // namespace SGPP -#endif /* PHIPHIDOWNBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* PHIPHIDOWNBBLINEARBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiUpBBLinearBoundary.cpp b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiUpBBLinearBoundary.cpp index 109d3c14f5..958d124408 100644 --- a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiUpBBLinearBoundary.cpp +++ b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiUpBBLinearBoundary.cpp @@ -7,19 +7,17 @@ #include - namespace SGPP { namespace pde { -PhiPhiUpBBLinearBoundary::PhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* - storage) : PhiPhiUpBBLinear(storage) { -} +PhiPhiUpBBLinearBoundary::PhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage) + : PhiPhiUpBBLinear(storage) {} -PhiPhiUpBBLinearBoundary::~PhiPhiUpBBLinearBoundary() { -} +PhiPhiUpBBLinearBoundary::~PhiPhiUpBBLinearBoundary() {} void PhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -56,9 +54,9 @@ void PhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // up ////////////////////////////////////// - //Left + // Left if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { result[seq_left] = fl; result[seq_left] += (((1.0 / 6.0) * source[seq_right]) * q); @@ -66,7 +64,7 @@ void PhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // Right if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -95,9 +93,9 @@ void PhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // up ////////////////////////////////////// - //Left + // Left if (this->boundingBox->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { result[seq_left] = fl; result[seq_left] += ((1.0 / 6.0) * source[seq_right]); @@ -105,7 +103,7 @@ void PhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, // Right if (this->boundingBox->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -114,7 +112,5 @@ void PhiPhiUpBBLinearBoundary::operator()(SGPP::base::DataVector& source, } } -// namespace detail -} -// namespace SGPP -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiUpBBLinearBoundary.hpp b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiUpBBLinearBoundary.hpp index 8801580f38..cb84e677b5 100644 --- a/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiUpBBLinearBoundary.hpp +++ b/pde/src/sgpp/pde/basis/linear/boundary/algorithm_sweep/PhiPhiUpBBLinearBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace pde { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \phi(x) \phi(x) dx\f$ @@ -31,7 +28,7 @@ class PhiPhiUpBBLinearBoundary : public PhiPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - PhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); + explicit PhiPhiUpBBLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class PhiPhiUpBBLinearBoundary : public PhiPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace pde +} // namespace SGPP -#endif /* PHIPHIUPBBLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* PHIPHIUPBBLINEARBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/basis/linear/noboundary/DowndPhidPhiBBIterativeLinear.cpp b/pde/src/sgpp/pde/basis/linear/noboundary/DowndPhidPhiBBIterativeLinear.cpp index 221c0ba0a2..ec30f5cb1f 100644 --- a/pde/src/sgpp/pde/basis/linear/noboundary/DowndPhidPhiBBIterativeLinear.cpp +++ b/pde/src/sgpp/pde/basis/linear/noboundary/DowndPhidPhiBBIterativeLinear.cpp @@ -8,19 +8,16 @@ #include - namespace SGPP { namespace pde { -DowndPhidPhiBBIterativeLinear::DowndPhidPhiBBIterativeLinear( - SGPP::base::GridStorage* storage) : storage(storage) { -} +DowndPhidPhiBBIterativeLinear::DowndPhidPhiBBIterativeLinear(SGPP::base::GridStorage* storage) + : storage(storage) {} -DowndPhidPhiBBIterativeLinear::~DowndPhidPhiBBIterativeLinear() { -} +DowndPhidPhiBBIterativeLinear::~DowndPhidPhiBBIterativeLinear() {} void DowndPhidPhiBBIterativeLinear::operator()(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // Bounding Box handling SGPP::base::BoundingBox* boundingBox = this->storage->getBoundingBox(); float_t q = boundingBox->getIntervalWidth(dim); @@ -35,7 +32,7 @@ void DowndPhidPhiBBIterativeLinear::operator()(SGPP::base::DataVector& alpha, SGPP::base::GridStorage::index_type::level_type level; SGPP::base::GridStorage::index_type::index_type index; (*storage)[i]->get(dim, level, index); - //only affects the diagonal of the stiffness matrix + // only affects the diagonal of the stiffness matrix result[i] = alpha[i] * (Qqout * (static_cast(1 << (level + 1)))); } } else { @@ -44,11 +41,10 @@ void DowndPhidPhiBBIterativeLinear::operator()(SGPP::base::DataVector& alpha, SGPP::base::GridStorage::index_type::level_type level; SGPP::base::GridStorage::index_type::index_type index; (*storage)[i]->get(dim, level, index); - //only affects the diagonal of the stiffness matrix + // only affects the diagonal of the stiffness matrix result[i] = alpha[i] * static_cast(1 << (level + 1)); } } } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linear/noboundary/DowndPhidPhiBBIterativeLinear.hpp b/pde/src/sgpp/pde/basis/linear/noboundary/DowndPhidPhiBBIterativeLinear.hpp index c3e977921e..bb17558748 100644 --- a/pde/src/sgpp/pde/basis/linear/noboundary/DowndPhidPhiBBIterativeLinear.hpp +++ b/pde/src/sgpp/pde/basis/linear/noboundary/DowndPhidPhiBBIterativeLinear.hpp @@ -11,7 +11,6 @@ #include - namespace SGPP { namespace pde { @@ -38,26 +37,26 @@ class DowndPhidPhiBBIterativeLinear { * * @param storage Pointer to the grid's storage object */ - DowndPhidPhiBBIterativeLinear(SGPP::base::GridStorage* storage); + explicit DowndPhidPhiBBIterativeLinear(SGPP::base::GridStorage* storage); /** * Destructor */ - ~DowndPhidPhiBBIterativeLinear(); + virtual ~DowndPhidPhiBBIterativeLinear(); /** * This operations performs the calculation of Down in the direction of dimension dim - * of following bilinearform: \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ + * of following bilinearform: \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} + * dx\f$ * * @param alpha SGPP::base::DataVector that contains the gridpoint's coefficients * @param result SGPP::base::DataVector that contains the result of the down operation * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void operator()(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* DOWNDPHIDPHIDOWNBBITERATIVELINEAR_HPP */ \ No newline at end of file +#endif /* DOWNDPHIDPHIDOWNBBITERATIVELINEAR_HPP */ diff --git a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedDownBBLinear.cpp b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedDownBBLinear.cpp index 357274a077..7d3d9e924b 100644 --- a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedDownBBLinear.cpp +++ b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedDownBBLinear.cpp @@ -7,37 +7,41 @@ #include - namespace SGPP { namespace pde { -LaplaceEnhancedDownBBLinear::LaplaceEnhancedDownBBLinear( - SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()), - algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()), - ptr_source_(NULL), ptr_result_(NULL), - cur_algo_dim_(0), q_(0.0), t_(0.0) +LaplaceEnhancedDownBBLinear::LaplaceEnhancedDownBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), + boundingBox(storage->getBoundingBox()), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()), + ptr_source_(NULL), + ptr_result_(NULL), + cur_algo_dim_(0), + q_(0.0), + t_(0.0) #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 - , half_in_(_mm_set1_pd(0.5)), - twothird_(_mm_set1_pd(2.0 / 3.0)) +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 + , + half_in_(_mm_set1_pd(0.5)), + twothird_(_mm_set1_pd(2.0 / 3.0)) #endif #else #ifdef __SSE3__ - , half_in_(_mm_set1_pd(0.5)), - twothird_(_mm_set1_pd(2.0 / 3.0)) + , + half_in_(_mm_set1_pd(0.5)), + twothird_(_mm_set1_pd(2.0 / 3.0)) #endif #endif - // ,h_table_(NULL),grad_table_(NULL) +// ,h_table_(NULL),grad_table_(NULL) { } -LaplaceEnhancedDownBBLinear::~LaplaceEnhancedDownBBLinear() { -} +LaplaceEnhancedDownBBLinear::~LaplaceEnhancedDownBBLinear() {} void LaplaceEnhancedDownBBLinear::operator()(SGPP::base::DataMatrix& source, - SGPP::base::DataMatrix& result, grid_iterator& index, size_t dim) { + SGPP::base::DataMatrix& result, grid_iterator& index, + size_t dim) { q_ = this->boundingBox->getIntervalWidth(this->algoDims[dim]); t_ = this->boundingBox->getIntervalOffset(this->algoDims[dim]); @@ -70,7 +74,7 @@ void LaplaceEnhancedDownBBLinear::operator()(SGPP::base::DataMatrix& source, } } - for ( ; i < this->numAlgoDims_; i++) { + for (; i < this->numAlgoDims_; i++) { float_t fl = 0.0; float_t fr = 0.0; @@ -87,7 +91,7 @@ void LaplaceEnhancedDownBBLinear::operator()(SGPP::base::DataMatrix& source, float_t fl = 0.0; float_t fr = 0.0; #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 __m128d fl_xmm = _mm_set1_pd(0.0); __m128d fr_xmm = _mm_set1_pd(0.0); #endif @@ -104,7 +108,7 @@ void LaplaceEnhancedDownBBLinear::operator()(SGPP::base::DataMatrix& source, rec_LG(fl, fr, i, index); } else { #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 rec_LL(fl_xmm, fr_xmm, i, index); #else rec_LL(fl, fr, fl, fr, i, index); @@ -119,7 +123,7 @@ void LaplaceEnhancedDownBBLinear::operator()(SGPP::base::DataMatrix& source, } } - for ( ; i < this->numAlgoDims_; i++) { + for (; i < this->numAlgoDims_; i++) { float_t fl = 0.0; float_t fr = 0.0; @@ -135,8 +139,7 @@ void LaplaceEnhancedDownBBLinear::operator()(SGPP::base::DataMatrix& source, // delete[] grad_table_; } -void LaplaceEnhancedDownBBLinear::rec(float_t fl, float_t fr, size_t dim, - grid_iterator& index) { +void LaplaceEnhancedDownBBLinear::rec(float_t fl, float_t fr, size_t dim, grid_iterator& index) { size_t seq = index.seq(); SGPP::base::GridStorage::index_type::level_type l; SGPP::base::GridStorage::index_type::index_type i; @@ -149,8 +152,8 @@ void LaplaceEnhancedDownBBLinear::rec(float_t fl, float_t fr, size_t dim, // L2 scalar product float_t tmp_m = ((fl + fr) * 0.5); - ptr_result_[(seq * this->numAlgoDims_) + dim] = (((h * tmp_m) + ((( - 2.0 / 3.0) * h) * alpha_value))); + ptr_result_[(seq * this->numAlgoDims_) + dim] = + (((h * tmp_m) + (((2.0 / 3.0) * h) * alpha_value))); float_t fm = tmp_m + alpha_value; if (!index.hint()) { @@ -179,8 +182,8 @@ void LaplaceEnhancedDownBBLinear::rec_grad(size_t dim, grid_iterator& index) { float_t alpha_value = ptr_source_[(seq * this->numAlgoDims_) + dim]; // Gradient just in selected dimension - ptr_result_[(seq * this->numAlgoDims_) + dim] = (static_cast(1 << - (l + 1)) * alpha_value); + ptr_result_[(seq * this->numAlgoDims_) + dim] = + (static_cast(1 << (l + 1)) * alpha_value); if (!index.hint()) { index.leftChild(cur_algo_dim_); @@ -200,20 +203,18 @@ void LaplaceEnhancedDownBBLinear::rec_grad(size_t dim, grid_iterator& index) { } #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 -void LaplaceEnhancedDownBBLinear::rec_LL(__m128d fl, __m128d fr, size_t dim, - grid_iterator& index) +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 +void LaplaceEnhancedDownBBLinear::rec_LL(__m128d fl, __m128d fr, size_t dim, grid_iterator& index) #else -void LaplaceEnhancedDownBBLinear::rec_LL(float_t fl, float_t fr, float_t fl2, - float_t fr2, size_t dim, grid_iterator& index) +void LaplaceEnhancedDownBBLinear::rec_LL(float_t fl, float_t fr, float_t fl2, float_t fr2, + size_t dim, grid_iterator& index) #endif #else #ifdef __SSE3__ -void LaplaceEnhancedDownBBLinear::rec_LL(__m128d fl, __m128d fr, size_t dim, - grid_iterator& index) +void LaplaceEnhancedDownBBLinear::rec_LL(__m128d fl, __m128d fr, size_t dim, grid_iterator& index) #else -void LaplaceEnhancedDownBBLinear::rec_LL(float_t fl, float_t fr, float_t fl2, - float_t fr2, size_t dim, grid_iterator& index) +void LaplaceEnhancedDownBBLinear::rec_LL(float_t fl, float_t fr, float_t fl2, float_t fr2, + size_t dim, grid_iterator& index) #endif #endif { @@ -225,17 +226,16 @@ void LaplaceEnhancedDownBBLinear::rec_LL(float_t fl, float_t fr, float_t fl2, // mesh-width float_t h = 1.0 / static_cast(1 << l); - // L2 scalar product +// L2 scalar product #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 // with intrinsics __m128d h_in = _mm_loaddup_pd(&h); __m128d fl_in = fl; __m128d fr_in = fr; __m128d alpha = _mm_loadu_pd(&ptr_source_[(seq * this->numAlgoDims_) + dim]); __m128d tmp = _mm_mul_pd(_mm_add_pd(fl_in, fr_in), half_in_); - __m128d res = _mm_add_pd(_mm_mul_pd(h_in, tmp), _mm_mul_pd(alpha, - _mm_mul_pd(h_in, twothird_))); + __m128d res = _mm_add_pd(_mm_mul_pd(h_in, tmp), _mm_mul_pd(alpha, _mm_mul_pd(h_in, twothird_))); __m128d new_fm = _mm_add_pd(alpha, tmp); _mm_storeu_pd(&ptr_result_[(seq * this->numAlgoDims_) + dim], res); #else @@ -258,8 +258,7 @@ void LaplaceEnhancedDownBBLinear::rec_LL(float_t fl, float_t fr, float_t fl2, __m128d fr_in = fr; __m128d alpha = _mm_loadu_pd(&ptr_source_[(seq * this->numAlgoDims_) + dim]); __m128d tmp = _mm_mul_pd(_mm_add_pd(fl_in, fr_in), half_in_); - __m128d res = _mm_add_pd(_mm_mul_pd(h_in, tmp), _mm_mul_pd(alpha, - _mm_mul_pd(h_in, twothird_))); + __m128d res = _mm_add_pd(_mm_mul_pd(h_in, tmp), _mm_mul_pd(alpha, _mm_mul_pd(h_in, twothird_))); __m128d new_fm = _mm_add_pd(alpha, tmp); _mm_storeu_pd(&ptr_result_[(seq * this->numAlgoDims_) + dim], res); #else @@ -281,7 +280,7 @@ void LaplaceEnhancedDownBBLinear::rec_LL(float_t fl, float_t fr, float_t fl2, if (!storage->end(index.seq())) { #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 rec_LL(fl, new_fm, dim, index); #else rec_LL(fl, fm, fl2, fm2, dim, index); @@ -299,7 +298,7 @@ void LaplaceEnhancedDownBBLinear::rec_LL(float_t fl, float_t fr, float_t fl2, if (!storage->end(index.seq())) { #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 rec_LL(new_fm, fr, dim, index); #else rec_LL(fm, fr, fm2, fr2, dim, index); @@ -317,8 +316,7 @@ void LaplaceEnhancedDownBBLinear::rec_LL(float_t fl, float_t fr, float_t fl2, } } -void LaplaceEnhancedDownBBLinear::rec_LG(float_t fl, float_t fr, size_t dim, - grid_iterator& index) { +void LaplaceEnhancedDownBBLinear::rec_LG(float_t fl, float_t fr, size_t dim, grid_iterator& index) { size_t seq = index.seq(); SGPP::base::GridStorage::index_type::level_type l; SGPP::base::GridStorage::index_type::index_type i; @@ -332,11 +330,11 @@ void LaplaceEnhancedDownBBLinear::rec_LG(float_t fl, float_t fr, size_t dim, // L2 scalar product float_t tmp_m = ((fl + fr) * 0.5); - ptr_result_[(seq * this->numAlgoDims_) + dim] = (((h * tmp_m) + ((( - 2.0 / 3.0) * h) * alpha_value))); + ptr_result_[(seq * this->numAlgoDims_) + dim] = + (((h * tmp_m) + (((2.0 / 3.0) * h) * alpha_value))); // Gradient in second dimension - ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = (static_cast(1 << - (l + 1)) * alpha_value2); + ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = + (static_cast(1 << (l + 1)) * alpha_value2); float_t fm = tmp_m + alpha_value; @@ -357,8 +355,7 @@ void LaplaceEnhancedDownBBLinear::rec_LG(float_t fl, float_t fr, size_t dim, } } -void LaplaceEnhancedDownBBLinear::rec_GL(float_t fl, float_t fr, size_t dim, - grid_iterator& index) { +void LaplaceEnhancedDownBBLinear::rec_GL(float_t fl, float_t fr, size_t dim, grid_iterator& index) { size_t seq = index.seq(); SGPP::base::GridStorage::index_type::level_type l; SGPP::base::GridStorage::index_type::index_type i; @@ -373,11 +370,11 @@ void LaplaceEnhancedDownBBLinear::rec_GL(float_t fl, float_t fr, size_t dim, float_t tmp_m = ((fl + fr) * 0.5); // Gradient in second dimension - ptr_result_[(seq * this->numAlgoDims_) + dim] = ((static_cast(1 << - (l + 1))) * alpha_value); + ptr_result_[(seq * this->numAlgoDims_) + dim] = + ((static_cast(1 << (l + 1))) * alpha_value); // L2 scalar product - ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = (((h * tmp_m) + ((( - 2.0 / 3.0) * h) * alpha_value2))); + ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = + (((h * tmp_m) + (((2.0 / 3.0) * h) * alpha_value2))); float_t fm = tmp_m + alpha_value2; @@ -398,8 +395,7 @@ void LaplaceEnhancedDownBBLinear::rec_GL(float_t fl, float_t fr, size_t dim, } } -void LaplaceEnhancedDownBBLinear::recBB(float_t fl, float_t fr, size_t dim, - grid_iterator& index) { +void LaplaceEnhancedDownBBLinear::recBB(float_t fl, float_t fr, size_t dim, grid_iterator& index) { size_t seq = index.seq(); SGPP::base::GridStorage::index_type::level_type l; SGPP::base::GridStorage::index_type::index_type i; @@ -412,8 +408,8 @@ void LaplaceEnhancedDownBBLinear::recBB(float_t fl, float_t fr, size_t dim, // L2 scalar product float_t tmp_m = ((fl + fr) * 0.5); - ptr_result_[(seq * this->numAlgoDims_) + dim] = (((h * tmp_m) + ((( - 2.0 / 3.0) * h) * alpha_value)) * q_); + ptr_result_[(seq * this->numAlgoDims_) + dim] = + (((h * tmp_m) + (((2.0 / 3.0) * h) * alpha_value)) * q_); float_t fm = tmp_m + alpha_value; if (!index.hint()) { @@ -433,8 +429,8 @@ void LaplaceEnhancedDownBBLinear::recBB(float_t fl, float_t fr, size_t dim, } } -void LaplaceEnhancedDownBBLinear::recBB_LL(float_t fl, float_t fr, float_t fl2, - float_t fr2, size_t dim, grid_iterator& index) { +void LaplaceEnhancedDownBBLinear::recBB_LL(float_t fl, float_t fr, float_t fl2, float_t fr2, + size_t dim, grid_iterator& index) { size_t seq = index.seq(); SGPP::base::GridStorage::index_type::level_type l; SGPP::base::GridStorage::index_type::index_type i; @@ -449,10 +445,10 @@ void LaplaceEnhancedDownBBLinear::recBB_LL(float_t fl, float_t fr, float_t fl2, // L2 scalar product float_t tmp_m = ((fl + fr) * 0.5); float_t tmp_m2 = ((fl2 + fr2) * 0.5); - ptr_result_[(seq * this->numAlgoDims_) + dim] = (((h * tmp_m) + ((( - 2.0 / 3.0) * h) * alpha_value)) * q_); - ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = (((h * tmp_m2) + ((( - 2.0 / 3.0) * h) * alpha_value2)) * q_); + ptr_result_[(seq * this->numAlgoDims_) + dim] = + (((h * tmp_m) + (((2.0 / 3.0) * h) * alpha_value)) * q_); + ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = + (((h * tmp_m2) + (((2.0 / 3.0) * h) * alpha_value2)) * q_); float_t fm = tmp_m + alpha_value; float_t fm2 = tmp_m2 + alpha_value2; @@ -474,7 +470,7 @@ void LaplaceEnhancedDownBBLinear::recBB_LL(float_t fl, float_t fr, float_t fl2, } void LaplaceEnhancedDownBBLinear::recBB_LG(float_t fl, float_t fr, size_t dim, - grid_iterator& index) { + grid_iterator& index) { size_t seq = index.seq(); SGPP::base::GridStorage::index_type::level_type l; SGPP::base::GridStorage::index_type::index_type i; @@ -488,11 +484,11 @@ void LaplaceEnhancedDownBBLinear::recBB_LG(float_t fl, float_t fr, size_t dim, // L2 scalar product float_t tmp_m = ((fl + fr) * 0.5); - ptr_result_[(seq * this->numAlgoDims_) + dim] = (((h * tmp_m) + ((( - 2.0 / 3.0) * h) * alpha_value)) * q_); + ptr_result_[(seq * this->numAlgoDims_) + dim] = + (((h * tmp_m) + (((2.0 / 3.0) * h) * alpha_value)) * q_); // Gradient in second dimension - ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = ((static_cast - (1 << (l + 1)) / q_) * alpha_value2); + ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = + ((static_cast(1 << (l + 1)) / q_) * alpha_value2); float_t fm = tmp_m + alpha_value; @@ -514,7 +510,7 @@ void LaplaceEnhancedDownBBLinear::recBB_LG(float_t fl, float_t fr, size_t dim, } void LaplaceEnhancedDownBBLinear::recBB_GL(float_t fl, float_t fr, size_t dim, - grid_iterator& index) { + grid_iterator& index) { size_t seq = index.seq(); SGPP::base::GridStorage::index_type::level_type l; SGPP::base::GridStorage::index_type::index_type i; @@ -528,11 +524,11 @@ void LaplaceEnhancedDownBBLinear::recBB_GL(float_t fl, float_t fr, size_t dim, float_t tmp_m = ((fl + fr) * 0.5); // Gradient in second dimension - ptr_result_[(seq * this->numAlgoDims_) + dim] = ((static_cast(1 << - (l + 1)) / q_) * alpha_value); + ptr_result_[(seq * this->numAlgoDims_) + dim] = + ((static_cast(1 << (l + 1)) / q_) * alpha_value); // L2 scalar product - ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = (((h * tmp_m) + ((( - 2.0 / 3.0) * h) * alpha_value2)) * q_); + ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = + (((h * tmp_m) + (((2.0 / 3.0) * h) * alpha_value2)) * q_); float_t fm = tmp_m + alpha_value2; if (!index.hint()) { @@ -561,8 +557,8 @@ void LaplaceEnhancedDownBBLinear::recBB_grad(size_t dim, grid_iterator& index) { float_t alpha_value = ptr_source_[(seq * this->numAlgoDims_) + dim]; // Gradient just in selected dimension - ptr_result_[(seq * this->numAlgoDims_) + dim] = ((static_cast(1 << - (l + 1)) / q_) * alpha_value); + ptr_result_[(seq * this->numAlgoDims_) + dim] = + ((static_cast(1 << (l + 1)) / q_) * alpha_value); if (!index.hint()) { index.leftChild(cur_algo_dim_); @@ -581,7 +577,5 @@ void LaplaceEnhancedDownBBLinear::recBB_grad(size_t dim, grid_iterator& index) { } } -// namespace pde -} -// namespace SGPP -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedDownBBLinear.hpp b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedDownBBLinear.hpp index be477c64f0..d27740cdc9 100644 --- a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedDownBBLinear.hpp +++ b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedDownBBLinear.hpp @@ -6,7 +6,7 @@ #ifndef LAPLACEENHANCEDDOWNBBLINEAR_HPP #define LAPLACEENHANCEDDOWNBBLINEAR_HPP -//#define MAX_TABLE_DEPTH 32 +// #define MAX_TABLE_DEPTH 32 #include #include @@ -18,6 +18,7 @@ #include +#include namespace SGPP { namespace pde { @@ -33,8 +34,8 @@ class LaplaceEnhancedDownBBLinear { protected: typedef SGPP::base::GridStorage::grid_iterator grid_iterator; - //float_t* h_table_; - //float_t* grad_table_; + // float_t* h_table_; + // float_t* grad_table_; /// Pointer to the SGPP::base::GridStorage Object SGPP::base::GridStorage* storage; /// Pointer to the bounding box Obejct @@ -54,7 +55,7 @@ class LaplaceEnhancedDownBBLinear { /// translation of basis function in current algorithmic domain float_t t_; #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 /// const. vector holding 1/2 in both components const __m128d half_in_; /// const. vector holding 3/3 in both components @@ -75,7 +76,7 @@ class LaplaceEnhancedDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - LaplaceEnhancedDownBBLinear(SGPP::base::GridStorage* storage); + explicit LaplaceEnhancedDownBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -86,16 +87,16 @@ class LaplaceEnhancedDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * on a grid with Dirichlet 0 boundary conditions. * - * @param source SGPP::base::DataMatrix that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataMatrix that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataMatrix that contains the result of the down operation * @param index an iterator object of the grid * @param dim current fixed dimension of the 'execution direction', here all downs are calculated */ - virtual void operator()(SGPP::base::DataMatrix& source, - SGPP::base::DataMatrix& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataMatrix& source, SGPP::base::DataMatrix& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down (L2 scalar product) without Bounding Box * @@ -107,7 +108,7 @@ class LaplaceEnhancedDownBBLinear { void rec(float_t fl, float_t fr, size_t dim, grid_iterator& index); #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 /** * recursive function for the calculation of merged-Down (L2 scalar products) without Bounding Box * @@ -128,8 +129,7 @@ class LaplaceEnhancedDownBBLinear { * @param dim current fixed dimension of the 'execution direction', here all downs are calculated * @param index an iterator object of the grid */ - void rec_LL(float_t fl, float_t fr, float_t fl2, float_t fr2, size_t dim, - grid_iterator& index); + void rec_LL(float_t fl, float_t fr, float_t fl2, float_t fr2, size_t dim, grid_iterator& index); #endif #else #ifdef __SSE3__ @@ -153,13 +153,13 @@ class LaplaceEnhancedDownBBLinear { * @param dim current fixed dimension of the 'execution direction', here all downs are calculated * @param index an iterator object of the grid */ - void rec_LL(float_t fl, float_t fr, float_t fl2, float_t fr2, size_t dim, - grid_iterator& index); + void rec_LL(float_t fl, float_t fr, float_t fl2, float_t fr2, size_t dim, grid_iterator& index); #endif #endif /** - * recursive function for the calculation of merged-Down (L2 scalar product and gradient) without Bounding Box + * recursive function for the calculation of merged-Down (L2 scalar product and gradient) without + * Bounding Box * * @param fl first function value on the left boundary, L2 scalar product * @param fr first function value on the right boundary, L2 scalar product @@ -169,7 +169,8 @@ class LaplaceEnhancedDownBBLinear { void rec_LG(float_t fl, float_t fr, size_t dim, grid_iterator& index); /** - * recursive function for the calculation of merged-Down (gradient and L2 scalar product) without Bounding Box + * recursive function for the calculation of merged-Down (gradient and L2 scalar product) without + * Bounding Box * * @param fl first function value on the left boundary, L2 scalar product * @param fr first function value on the right boundary, L2 scalar product @@ -205,11 +206,11 @@ class LaplaceEnhancedDownBBLinear { * @param dim current fixed dimension of the 'execution direction', here all downs are calculated * @param index an iterator object of the grid */ - void recBB_LL(float_t fl, float_t fr, float_t fl2, float_t fr2, size_t dim, - grid_iterator& index); + void recBB_LL(float_t fl, float_t fr, float_t fl2, float_t fr2, size_t dim, grid_iterator& index); /** - * recursive function for the calculation of merged-Down (L2 scalar product and gradient) with Bounding Box + * recursive function for the calculation of merged-Down (L2 scalar product and gradient) with + * Bounding Box * * @param fl first function value on the left boundary, L2 scalar product * @param fr first function value on the right boundary, L2 scalar product @@ -219,7 +220,8 @@ class LaplaceEnhancedDownBBLinear { void recBB_LG(float_t fl, float_t fr, size_t dim, grid_iterator& index); /** - * recursive function for the calculation of merged-Down (gradient and L2 scalar product) with Bounding Box + * recursive function for the calculation of merged-Down (gradient and L2 scalar product) with + * Bounding Box * * @param fl first function value on the left boundary, L2 scalar product * @param fr first function value on the right boundary, L2 scalar product @@ -236,9 +238,7 @@ class LaplaceEnhancedDownBBLinear { void recBB_grad(size_t dim, grid_iterator& index); }; -// namespace detail -} -// namespace SGPP -} +} // namespace pde +} // namespace SGPP #endif /* LAPLACEENHANCEDDOWNBBLINEAR_HPP */ diff --git a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedUpBBLinear.cpp b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedUpBBLinear.cpp index 68e43682bc..e3c0f0f687 100644 --- a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedUpBBLinear.cpp +++ b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedUpBBLinear.cpp @@ -7,34 +7,38 @@ #include - namespace SGPP { namespace pde { -LaplaceEnhancedUpBBLinear::LaplaceEnhancedUpBBLinear(SGPP::base::GridStorage* - storage) : - storage(storage), boundingBox(storage->getBoundingBox()), - algoDims(storage->getAlgorithmicDimensions()), - numAlgoDims_(storage->getAlgorithmicDimensions().size()), - ptr_source_(NULL), ptr_result_(NULL), - cur_algo_dim_(0), q_(0.0), t_(0.0) +LaplaceEnhancedUpBBLinear::LaplaceEnhancedUpBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), + boundingBox(storage->getBoundingBox()), + algoDims(storage->getAlgorithmicDimensions()), + numAlgoDims_(storage->getAlgorithmicDimensions().size()), + ptr_source_(NULL), + ptr_result_(NULL), + cur_algo_dim_(0), + q_(0.0), + t_(0.0) #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 - , half_in_(_mm_set1_pd(0.5)) +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 + , + half_in_(_mm_set1_pd(0.5)) #endif #else #ifdef __SSE3__ - , half_in_(_mm_set1_pd(0.5)) + , + half_in_(_mm_set1_pd(0.5)) #endif #endif { } -LaplaceEnhancedUpBBLinear::~LaplaceEnhancedUpBBLinear() { -} +LaplaceEnhancedUpBBLinear::~LaplaceEnhancedUpBBLinear() {} void LaplaceEnhancedUpBBLinear::operator()(SGPP::base::DataMatrix& source, - SGPP::base::DataMatrix& result, grid_iterator& index, size_t dim) { + SGPP::base::DataMatrix& result, grid_iterator& index, + size_t dim) { q_ = this->boundingBox->getIntervalWidth(this->algoDims[dim]); t_ = this->boundingBox->getIntervalOffset(this->algoDims[dim]); @@ -63,7 +67,7 @@ void LaplaceEnhancedUpBBLinear::operator()(SGPP::base::DataMatrix& source, } } - for ( ; i < this->numAlgoDims_; i++) { + for (; i < this->numAlgoDims_; i++) { if (dim == i) { recBB_grad(i, index); } else { @@ -86,7 +90,7 @@ void LaplaceEnhancedUpBBLinear::operator()(SGPP::base::DataMatrix& source, rec_LG(fl, fr, i, index); } else { #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 __m128d fl_xmm = _mm_set1_pd(0.0); __m128d fr_xmm = _mm_set1_pd(0.0); @@ -117,7 +121,7 @@ void LaplaceEnhancedUpBBLinear::operator()(SGPP::base::DataMatrix& source, } } - for ( ; i < this->numAlgoDims_; i++) { + for (; i < this->numAlgoDims_; i++) { if (dim == i) { rec_grad(i, index); } else { @@ -129,8 +133,7 @@ void LaplaceEnhancedUpBBLinear::operator()(SGPP::base::DataMatrix& source, } } -void LaplaceEnhancedUpBBLinear::rec(float_t& fl, float_t& fr, size_t dim, - grid_iterator& index) { +void LaplaceEnhancedUpBBLinear::rec(float_t& fl, float_t& fr, size_t dim, grid_iterator& index) { size_t seq = index.seq(); float_t fml = 0.0; @@ -164,34 +167,31 @@ void LaplaceEnhancedUpBBLinear::rec(float_t& fl, float_t& fr, size_t dim, // transposed operations: ptr_result_[(seq * this->numAlgoDims_) + dim] = fm; - float_t tmp = (fm / 2.0) + (alpha_value / static_cast(1 << - (current_level + 1))); + float_t tmp = (fm / 2.0) + (alpha_value / static_cast(1 << (current_level + 1))); fl = tmp + fl; fr = tmp + fr; } #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 -void LaplaceEnhancedUpBBLinear::rec_LL(__m128d& fl, __m128d& fr, size_t dim, - grid_iterator& index) +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 +void LaplaceEnhancedUpBBLinear::rec_LL(__m128d& fl, __m128d& fr, size_t dim, grid_iterator& index) #else -void LaplaceEnhancedUpBBLinear::rec_LL(float_t& fl, float_t& fr, float_t& fl2, - float_t& fr2, size_t dim, grid_iterator& index) +void LaplaceEnhancedUpBBLinear::rec_LL(float_t& fl, float_t& fr, float_t& fl2, float_t& fr2, + size_t dim, grid_iterator& index) #endif #else #ifdef __SSE3__ -void LaplaceEnhancedUpBBLinear::rec_LL(__m128d& fl, __m128d& fr, size_t dim, - grid_iterator& index) +void LaplaceEnhancedUpBBLinear::rec_LL(__m128d& fl, __m128d& fr, size_t dim, grid_iterator& index) #else -void LaplaceEnhancedUpBBLinear::rec_LL(float_t& fl, float_t& fr, float_t& fl2, - float_t& fr2, size_t dim, grid_iterator& index) +void LaplaceEnhancedUpBBLinear::rec_LL(float_t& fl, float_t& fr, float_t& fl2, float_t& fr2, + size_t dim, grid_iterator& index) #endif #endif { size_t seq = index.seq(); #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 fl = _mm_set1_pd(0.0); fr = _mm_set1_pd(0.0); __m128d fml = _mm_set1_pd(0.0); @@ -225,7 +225,7 @@ void LaplaceEnhancedUpBBLinear::rec_LL(float_t& fl, float_t& fr, float_t& fl2, if (!storage->end(index.seq())) { #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 rec_LL(fl, fml, dim, index); #else rec_LL(fl, fml, fl2, fml2, dim, index); @@ -243,7 +243,7 @@ void LaplaceEnhancedUpBBLinear::rec_LL(float_t& fl, float_t& fr, float_t& fl2, if (!storage->end(index.seq())) { #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 rec_LL(fmr, fr, dim, index); #else rec_LL(fmr, fr, fmr2, fr2, dim, index); @@ -262,7 +262,7 @@ void LaplaceEnhancedUpBBLinear::rec_LL(float_t& fl, float_t& fr, float_t& fl2, index.get(cur_algo_dim_, current_level, current_index); #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 // mesh-width +1 level float_t h = 1.0 / static_cast(1 << (current_level + 1)); __m128d h_in = _mm_loaddup_pd(&h); @@ -282,10 +282,8 @@ void LaplaceEnhancedUpBBLinear::rec_LL(float_t& fl, float_t& fr, float_t& fl2, ptr_result_[(seq * this->numAlgoDims_) + dim] = fm; ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = fm2; - float_t tmp = (fm / 2.0) + (alpha_value / static_cast(1 << - (current_level + 1))); - float_t tmp2 = (fm2 / 2.0) + (alpha_value2 / static_cast(1 << - (current_level + 1))); + float_t tmp = (fm / 2.0) + (alpha_value / static_cast(1 << (current_level + 1))); + float_t tmp2 = (fm2 / 2.0) + (alpha_value2 / static_cast(1 << (current_level + 1))); fl = tmp + fl; fr = tmp + fr; @@ -293,9 +291,6 @@ void LaplaceEnhancedUpBBLinear::rec_LL(float_t& fl, float_t& fr, float_t& fl2, fr2 = tmp2 + fr2; #endif - - - #else #ifdef __SSE3__ // mesh-width +1 level @@ -317,10 +312,8 @@ void LaplaceEnhancedUpBBLinear::rec_LL(float_t& fl, float_t& fr, float_t& fl2, ptr_result_[(seq * this->numAlgoDims_) + dim] = fm; ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = fm2; - float_t tmp = (fm / 2.0) + (alpha_value / static_cast(1 << - (current_level + 1))); - float_t tmp2 = (fm2 / 2.0) + (alpha_value2 / static_cast(1 << - (current_level + 1))); + float_t tmp = (fm / 2.0) + (alpha_value / static_cast(1 << (current_level + 1))); + float_t tmp2 = (fm2 / 2.0) + (alpha_value2 / static_cast(1 << (current_level + 1))); fl = tmp + fl; fr = tmp + fr; @@ -330,8 +323,7 @@ void LaplaceEnhancedUpBBLinear::rec_LL(float_t& fl, float_t& fr, float_t& fl2, #endif } -void LaplaceEnhancedUpBBLinear::rec_GL(float_t& fl, float_t& fr, size_t dim, - grid_iterator& index) { +void LaplaceEnhancedUpBBLinear::rec_GL(float_t& fl, float_t& fr, size_t dim, grid_iterator& index) { size_t seq = index.seq(); float_t fml = 0.0; @@ -366,15 +358,13 @@ void LaplaceEnhancedUpBBLinear::rec_GL(float_t& fl, float_t& fr, size_t dim, ptr_result_[(seq * this->numAlgoDims_) + dim] = 0.0; ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = fm; - float_t tmp = (fm / 2.0) + (alpha_value / static_cast(1 << - (current_level + 1))); + float_t tmp = (fm / 2.0) + (alpha_value / static_cast(1 << (current_level + 1))); fl = tmp + fl; fr = tmp + fr; } -void LaplaceEnhancedUpBBLinear::rec_LG(float_t& fl, float_t& fr, size_t dim, - grid_iterator& index) { +void LaplaceEnhancedUpBBLinear::rec_LG(float_t& fl, float_t& fr, size_t dim, grid_iterator& index) { size_t seq = index.seq(); float_t fml = 0.0; @@ -409,8 +399,7 @@ void LaplaceEnhancedUpBBLinear::rec_LG(float_t& fl, float_t& fr, size_t dim, ptr_result_[(seq * this->numAlgoDims_) + dim] = fm; ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = 0.0; - float_t tmp = (fm / 2.0) + (alpha_value / static_cast(1 << - (current_level + 1))); + float_t tmp = (fm / 2.0) + (alpha_value / static_cast(1 << (current_level + 1))); fl = tmp + fl; fr = tmp + fr; @@ -439,8 +428,7 @@ void LaplaceEnhancedUpBBLinear::rec_grad(size_t dim, grid_iterator& index) { } } -void LaplaceEnhancedUpBBLinear::recBB(float_t& fl, float_t& fr, size_t dim, - grid_iterator& index) { +void LaplaceEnhancedUpBBLinear::recBB(float_t& fl, float_t& fr, size_t dim, grid_iterator& index) { size_t seq = index.seq(); float_t fml = 0.0; @@ -474,15 +462,15 @@ void LaplaceEnhancedUpBBLinear::recBB(float_t& fl, float_t& fr, size_t dim, // transposed operations: ptr_result_[(seq * this->numAlgoDims_) + dim] = fm; - float_t tmp = ((fm / 2.0) + ((alpha_value / static_cast(1 << - (current_level + 1))) * q_)); + float_t tmp = + ((fm / 2.0) + ((alpha_value / static_cast(1 << (current_level + 1))) * q_)); fl = tmp + fl; fr = tmp + fr; } -void LaplaceEnhancedUpBBLinear::recBB_LL(float_t& fl, float_t& fr, float_t& fl2, - float_t& fr2, size_t dim, grid_iterator& index) { +void LaplaceEnhancedUpBBLinear::recBB_LL(float_t& fl, float_t& fr, float_t& fl2, float_t& fr2, + size_t dim, grid_iterator& index) { size_t seq = index.seq(); float_t fml = 0.0; @@ -521,10 +509,9 @@ void LaplaceEnhancedUpBBLinear::recBB_LL(float_t& fl, float_t& fr, float_t& fl2, ptr_result_[(seq * this->numAlgoDims_) + dim] = fm; ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = fm2; - float_t tmp = (fm / 2.0) + ((alpha_value / static_cast(1 << - (current_level + 1))) * q_); - float_t tmp2 = (fm2 / 2.0) + ((alpha_value2 / static_cast(1 << - (current_level + 1))) * q_); + float_t tmp = (fm / 2.0) + ((alpha_value / static_cast(1 << (current_level + 1))) * q_); + float_t tmp2 = + (fm2 / 2.0) + ((alpha_value2 / static_cast(1 << (current_level + 1))) * q_); fl = tmp + fl; fr = tmp + fr; @@ -533,7 +520,7 @@ void LaplaceEnhancedUpBBLinear::recBB_LL(float_t& fl, float_t& fr, float_t& fl2, } void LaplaceEnhancedUpBBLinear::recBB_GL(float_t& fl, float_t& fr, size_t dim, - grid_iterator& index) { + grid_iterator& index) { size_t seq = index.seq(); float_t fml = 0.0; @@ -568,15 +555,14 @@ void LaplaceEnhancedUpBBLinear::recBB_GL(float_t& fl, float_t& fr, size_t dim, ptr_result_[(seq * this->numAlgoDims_) + dim] = 0.0; ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = fm; - float_t tmp = (fm / 2.0) + ((alpha_value / static_cast(1 << - (current_level + 1))) * q_); + float_t tmp = (fm / 2.0) + ((alpha_value / static_cast(1 << (current_level + 1))) * q_); fl = tmp + fl; fr = tmp + fr; } void LaplaceEnhancedUpBBLinear::recBB_LG(float_t& fl, float_t& fr, size_t dim, - grid_iterator& index) { + grid_iterator& index) { size_t seq = index.seq(); float_t fml = 0.0; @@ -611,8 +597,7 @@ void LaplaceEnhancedUpBBLinear::recBB_LG(float_t& fl, float_t& fr, size_t dim, ptr_result_[(seq * this->numAlgoDims_) + dim] = fm; ptr_result_[(seq * this->numAlgoDims_) + dim + 1] = 0.0; - float_t tmp = (fm / 2.0) + ((alpha_value / static_cast(1 << - (current_level + 1))) * q_); + float_t tmp = (fm / 2.0) + ((alpha_value / static_cast(1 << (current_level + 1))) * q_); fl = tmp + fl; fr = tmp + fr; @@ -641,7 +626,5 @@ void LaplaceEnhancedUpBBLinear::recBB_grad(size_t dim, grid_iterator& index) { } } -// namespace pde -} -// namespace SGPP -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedUpBBLinear.hpp b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedUpBBLinear.hpp index abfaab86e0..f794d852fc 100644 --- a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedUpBBLinear.hpp +++ b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/LaplaceEnhancedUpBBLinear.hpp @@ -16,6 +16,7 @@ #include +#include namespace SGPP { namespace pde { @@ -50,7 +51,7 @@ class LaplaceEnhancedUpBBLinear { /// translation of basis function in current algorithmic domain float_t t_; #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 /// const. vector holding 1/2 in both components const __m128d half_in_; #endif @@ -60,13 +61,14 @@ class LaplaceEnhancedUpBBLinear { const __m128d half_in_; #endif #endif + public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - LaplaceEnhancedUpBBLinear(SGPP::base::GridStorage* storage); + explicit LaplaceEnhancedUpBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -77,16 +79,16 @@ class LaplaceEnhancedUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataMatrix& source, - SGPP::base::DataMatrix& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataMatrix& source, SGPP::base::DataMatrix& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up (L2 scalar product) without Bounding Box * @@ -98,7 +100,7 @@ class LaplaceEnhancedUpBBLinear { void rec(float_t& fl, float_t& fr, size_t dim, grid_iterator& index); #if 1 -#if defined(__SSE3__) && USE_DOUBLE_PRECISION==1 +#if defined(__SSE3__) && USE_DOUBLE_PRECISION == 1 /** * recursive function for the calculation of merged-Down (L2 scalar products) without Bounding Box * @@ -150,7 +152,8 @@ class LaplaceEnhancedUpBBLinear { #endif /** - * recursive function for the calculation of merged-Up (gradient and L2 scalar product) without Bounding Box + * recursive function for the calculation of merged-Up (gradient and L2 scalar product) without + * Bounding Box * * @param fl first function value on the left boundary, L2 scalar product * @param fr first function value on the right boundary, L2 scalar product @@ -160,7 +163,8 @@ class LaplaceEnhancedUpBBLinear { void rec_LG(float_t& fl, float_t& fr, size_t dim, grid_iterator& index); /** - * recursive function for the calculation of merged-Up (L2 scalar product and gradient) without Bounding Box + * recursive function for the calculation of merged-Up (L2 scalar product and gradient) without + * Bounding Box * * @param fl first function value on the left boundary, L2 scalar product * @param fr first function value on the right boundary, L2 scalar product @@ -200,7 +204,8 @@ class LaplaceEnhancedUpBBLinear { grid_iterator& index); /** - * recursive function for the calculation of merged-Up (L2 scalar product and gradient) with Bounding Box + * recursive function for the calculation of merged-Up (L2 scalar product and gradient) with + * Bounding Box * * @param fl first function value on the left boundary, L2 scalar product * @param fr first function value on the right boundary, L2 scalar product @@ -210,7 +215,8 @@ class LaplaceEnhancedUpBBLinear { void recBB_LG(float_t& fl, float_t& fr, size_t dim, grid_iterator& index); /** - * recursive function for the calculation of merged-Up (gradient and L2 scalar product) with Bounding Box + * recursive function for the calculation of merged-Up (gradient and L2 scalar product) with + * Bounding Box * * @param fl first function value on the left boundary, L2 scalar product * @param fr first function value on the right boundary, L2 scalar product @@ -227,9 +233,7 @@ class LaplaceEnhancedUpBBLinear { void recBB_grad(size_t dim, grid_iterator& index); }; -// namespace detail -} -// namespace SGPP -} +} // namespace pde +} // namespace SGPP #endif /* LAPLACEENHANCEDUPBBLINEAR_HPP */ diff --git a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiDownBBLinear.cpp b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiDownBBLinear.cpp index 40212feb74..c671b638ad 100644 --- a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiDownBBLinear.cpp +++ b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiDownBBLinear.cpp @@ -7,23 +7,18 @@ #include - namespace SGPP { namespace pde { +PhiPhiDownBBLinear::PhiPhiDownBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} +PhiPhiDownBBLinear::~PhiPhiDownBBLinear() {} -PhiPhiDownBBLinear::PhiPhiDownBBLinear(SGPP::base::GridStorage* storage) : - storage(storage), boundingBox(storage->getBoundingBox()) { -} - -PhiPhiDownBBLinear::~PhiPhiDownBBLinear() { -} - -void PhiPhiDownBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { - //std::cout << dim << std::endl; - //std::cout << index.toString() << std::endl; +void PhiPhiDownBBLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { + // std::cout << dim << std::endl; + // std::cout << index.toString() << std::endl; float_t q = this->boundingBox->getIntervalWidth(dim); float_t t = this->boundingBox->getIntervalOffset(dim); @@ -41,9 +36,8 @@ void PhiPhiDownBBLinear::operator()(SGPP::base::DataVector& source, } } -void PhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { +void PhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -79,9 +73,9 @@ void PhiPhiDownBBLinear::rec(SGPP::base::DataVector& source, } } -void PhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr, float_t q, float_t t) { +void PhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr, float_t q, + float_t t) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -95,8 +89,7 @@ void PhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, float_t tmp_m = ((fl + fr) / 2.0); // integration - result[seq] = ((h * tmp_m) + (((2.0 / 3.0) * h) * alpha_value)) * - q; // diagonal entry + result[seq] = ((h * tmp_m) + (((2.0 / 3.0) * h) * alpha_value)) * q; // diagonal entry // dehierarchisation float_t fm = tmp_m + alpha_value; @@ -118,7 +111,5 @@ void PhiPhiDownBBLinear::recBB(SGPP::base::DataVector& source, } } -// namespace detail -} -// namespace SGPP -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiDownBBLinear.hpp b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiDownBBLinear.hpp index 370d319080..9dff29978e 100644 --- a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiDownBBLinear.hpp +++ b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiDownBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace pde { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \phi(x) \phi(x) dx\f$ @@ -36,7 +33,7 @@ class PhiPhiDownBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - PhiPhiDownBBLinear(SGPP::base::GridStorage* storage); + explicit PhiPhiDownBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class PhiPhiDownBBLinear { * This operations performs the calculation of down in the direction of dimension dim * on a grid with Dirichlet 0 boundary conditions. * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down without Bounding Box * @@ -67,8 +64,8 @@ class PhiPhiDownBBLinear { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); /** * recursive function for the calculation of Down with Bouding Box @@ -82,13 +79,11 @@ class PhiPhiDownBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr, float_t q, float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace pde +} // namespace SGPP -#endif /* PHIPHIDOWNBBLINEAR_HPP */ \ No newline at end of file +#endif /* PHIPHIDOWNBBLINEAR_HPP */ diff --git a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiUpBBLinear.cpp b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiUpBBLinear.cpp index ceeceb5b2a..838692dc4e 100644 --- a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiUpBBLinear.cpp +++ b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiUpBBLinear.cpp @@ -7,21 +7,16 @@ #include - namespace SGPP { namespace pde { +PhiPhiUpBBLinear::PhiPhiUpBBLinear(SGPP::base::GridStorage* storage) + : storage(storage), boundingBox(storage->getBoundingBox()) {} +PhiPhiUpBBLinear::~PhiPhiUpBBLinear() {} -PhiPhiUpBBLinear::PhiPhiUpBBLinear(SGPP::base::GridStorage* storage) : storage( - storage), boundingBox(storage->getBoundingBox()) { -} - -PhiPhiUpBBLinear::~PhiPhiUpBBLinear() { -} - -void PhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void PhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = boundingBox->getIntervalWidth(dim); float_t t = boundingBox->getIntervalOffset(dim); @@ -42,9 +37,8 @@ void PhiPhiUpBBLinear::operator()(SGPP::base::DataVector& source, } } -void PhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void PhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -78,16 +72,15 @@ void PhiPhiUpBBLinear::rec(SGPP::base::DataVector& source, // transposed operations: result[seq] = fm; - float_t tmp = (fm / 2.0) + (alpha_value / static_cast(1 << - (current_level + 1))); + float_t tmp = (fm / 2.0) + (alpha_value / static_cast(1 << (current_level + 1))); fl = tmp + fl; fr = tmp + fr; } -void PhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr, float_t q, float_t t) { +void PhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr, float_t q, + float_t t) { size_t seq = index.seq(); fl = fr = 0.0; @@ -107,7 +100,7 @@ void PhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, index.stepRight(dim); if (!storage->end(index.seq())) { - recBB(source, result, index, dim, fmr, fr, q , t); + recBB(source, result, index, dim, fmr, fr, q, t); } index.up(dim); @@ -121,14 +114,11 @@ void PhiPhiUpBBLinear::recBB(SGPP::base::DataVector& source, // transposed operations: result[seq] = fm; - float_t tmp = ((fm / 2.0) + ((alpha_value / static_cast(1 << - (current_level + 1))) * q)); + float_t tmp = ((fm / 2.0) + ((alpha_value / static_cast(1 << (current_level + 1))) * q)); fl = tmp + fl; fr = tmp + fr; } -// namespace detail -} -// namespace SGPP -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiUpBBLinear.hpp b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiUpBBLinear.hpp index b88a0b9688..8b64b9ea92 100644 --- a/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiUpBBLinear.hpp +++ b/pde/src/sgpp/pde/basis/linear/noboundary/algorithm_sweep/PhiPhiUpBBLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace pde { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \phi(x) \phi(x) dx\f$ @@ -36,7 +33,7 @@ class PhiPhiUpBBLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - PhiPhiUpBBLinear(SGPP::base::GridStorage* storage); + explicit PhiPhiUpBBLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class PhiPhiUpBBLinear { * This operations performs the calculation of up in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up without bounding Box support * @@ -67,8 +64,8 @@ class PhiPhiUpBBLinear { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); /** * recursive function for the calculation of Up with Bounding Box Support @@ -82,14 +79,11 @@ class PhiPhiUpBBLinear { * @param q interval width in the current dimension dim * @param t interval offset in current dimension dim */ - void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr, float_t q, - float_t t); + void recBB(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr, float_t q, float_t t); }; -// namespace detail - -} // namespace SGPP -} +} // namespace pde +} // namespace SGPP -#endif /* PHIPHIUPBBLINEAR_HPP */ \ No newline at end of file +#endif /* PHIPHIUPBBLINEAR_HPP */ diff --git a/pde/src/sgpp/pde/basis/linearstretched/boundary/DowndPhidPhiBBIterativeLinearStretchedBoundary.cpp b/pde/src/sgpp/pde/basis/linearstretched/boundary/DowndPhidPhiBBIterativeLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index 77446f4d52..48b9656cb3 --- a/pde/src/sgpp/pde/basis/linearstretched/boundary/DowndPhidPhiBBIterativeLinearStretchedBoundary.cpp +++ b/pde/src/sgpp/pde/basis/linearstretched/boundary/DowndPhidPhiBBIterativeLinearStretchedBoundary.cpp @@ -8,20 +8,18 @@ #include - namespace SGPP { namespace pde { DowndPhidPhiBBIterativeLinearStretchedBoundary::DowndPhidPhiBBIterativeLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : storage(storage) { -} + SGPP::base::GridStorage* storage) + : storage(storage) {} -DowndPhidPhiBBIterativeLinearStretchedBoundary::~DowndPhidPhiBBIterativeLinearStretchedBoundary() { -} - -void DowndPhidPhiBBIterativeLinearStretchedBoundary::operator()( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +DowndPhidPhiBBIterativeLinearStretchedBoundary::~DowndPhidPhiBBIterativeLinearStretchedBoundary() {} +void DowndPhidPhiBBIterativeLinearStretchedBoundary::operator()(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // Bounding Box handling SGPP::base::Stretching* stretching = this->storage->getStretching(); float_t q = stretching->getIntervalWidth(dim); @@ -40,7 +38,7 @@ void DowndPhidPhiBBIterativeLinearStretchedBoundary::operator()( if (level == 0) { if (index == 0) { if (!stretching->hasDirichletBoundaryLeft(dim)) { - //only affects the diagonal of the stiffness matrix + // only affects the diagonal of the stiffness matrix result[i] += Qqout * alpha[i]; // down @@ -57,13 +55,12 @@ void DowndPhidPhiBBIterativeLinearStretchedBoundary::operator()( if (index == 1) { if (!stretching->hasDirichletBoundaryRight(dim)) { - //only affects the diagonal of the stiffness matrix + // only affects the diagonal of the stiffness matrix result[i] += Qqout * alpha[i]; } } - } - //only affects the diagonal of the stiffness matrix - else { + } else { + // only affects the diagonal of the stiffness matrix result[i] = alpha[i] * (Qqout * pow(2.0, static_cast(level + 1))); } } @@ -77,7 +74,7 @@ void DowndPhidPhiBBIterativeLinearStretchedBoundary::operator()( if (level == 0) { if (index == 0) { if (!stretching->hasDirichletBoundaryLeft(dim)) { - //only affects the diagonal of the stiffness matrix + // only affects the diagonal of the stiffness matrix result[i] += alpha[i]; // down @@ -94,18 +91,16 @@ void DowndPhidPhiBBIterativeLinearStretchedBoundary::operator()( if (index == 1) { if (!stretching->hasDirichletBoundaryRight(dim)) { - //only affects the diagonal of the stiffness matrix + // only affects the diagonal of the stiffness matrix result[i] += alpha[i]; } } - } - //only affects the diagonal of the stiffness matrix - else { + } else { + // only affects the diagonal of the stiffness matrix result[i] = alpha[i] * pow(2.0, static_cast(level + 1)); } } } } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linearstretched/boundary/DowndPhidPhiBBIterativeLinearStretchedBoundary.hpp b/pde/src/sgpp/pde/basis/linearstretched/boundary/DowndPhidPhiBBIterativeLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 96a6b94712..81aadc22ca --- a/pde/src/sgpp/pde/basis/linearstretched/boundary/DowndPhidPhiBBIterativeLinearStretchedBoundary.hpp +++ b/pde/src/sgpp/pde/basis/linearstretched/boundary/DowndPhidPhiBBIterativeLinearStretchedBoundary.hpp @@ -11,7 +11,6 @@ #include - namespace SGPP { namespace pde { @@ -38,8 +37,7 @@ class DowndPhidPhiBBIterativeLinearStretchedBoundary { * * @param storage Pointer to the grid's storage object */ - DowndPhidPhiBBIterativeLinearStretchedBoundary(SGPP::base::GridStorage* - storage); + explicit DowndPhidPhiBBIterativeLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -48,17 +46,17 @@ class DowndPhidPhiBBIterativeLinearStretchedBoundary { /** * This operations performs the calculation of Down in the direction of dimension dim - * of following bilinearform: \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ + * of following bilinearform: \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} + * dx\f$ * * @param alpha SGPP::base::DataVector that contains the gridpoint's coefficients * @param result SGPP::base::DataVector that contains the result of the down operation * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void operator()(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* DOWNDPHIDPHIDOWNBBITERATIVELINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* DOWNDPHIDPHIDOWNBBITERATIVELINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/basis/linearstretched/boundary/UpdPhidPhiBBIterativeLinearStretchedBoundary.cpp b/pde/src/sgpp/pde/basis/linearstretched/boundary/UpdPhidPhiBBIterativeLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index 710edf4200..dd0fb799d6 --- a/pde/src/sgpp/pde/basis/linearstretched/boundary/UpdPhidPhiBBIterativeLinearStretchedBoundary.cpp +++ b/pde/src/sgpp/pde/basis/linearstretched/boundary/UpdPhidPhiBBIterativeLinearStretchedBoundary.cpp @@ -8,20 +8,18 @@ #include - namespace SGPP { namespace pde { UpdPhidPhiBBIterativeLinearStretchedBoundary::UpdPhidPhiBBIterativeLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : storage(storage) { -} - -UpdPhidPhiBBIterativeLinearStretchedBoundary::~UpdPhidPhiBBIterativeLinearStretchedBoundary() { -} + SGPP::base::GridStorage* storage) + : storage(storage) {} -void UpdPhidPhiBBIterativeLinearStretchedBoundary::operator()( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +UpdPhidPhiBBIterativeLinearStretchedBoundary::~UpdPhidPhiBBIterativeLinearStretchedBoundary() {} +void UpdPhidPhiBBIterativeLinearStretchedBoundary::operator()(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // Bounding Box handling SGPP::base::Stretching* stretching = this->storage->getStretching(); float_t q = stretching->getIntervalWidth(dim); @@ -70,6 +68,5 @@ void UpdPhidPhiBBIterativeLinearStretchedBoundary::operator()( } } } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linearstretched/boundary/UpdPhidPhiBBIterativeLinearStretchedBoundary.hpp b/pde/src/sgpp/pde/basis/linearstretched/boundary/UpdPhidPhiBBIterativeLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 0643fe9e69..0a2cc55053 --- a/pde/src/sgpp/pde/basis/linearstretched/boundary/UpdPhidPhiBBIterativeLinearStretchedBoundary.hpp +++ b/pde/src/sgpp/pde/basis/linearstretched/boundary/UpdPhidPhiBBIterativeLinearStretchedBoundary.hpp @@ -11,7 +11,6 @@ #include - namespace SGPP { namespace pde { @@ -38,7 +37,7 @@ class UpdPhidPhiBBIterativeLinearStretchedBoundary { * * @param storage Pointer to the grid's storage object */ - UpdPhidPhiBBIterativeLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit UpdPhidPhiBBIterativeLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,17 +46,17 @@ class UpdPhidPhiBBIterativeLinearStretchedBoundary { /** * This operations performs the calculation of Up in the direction of dimension dim - * of following bilinearform: \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ + * of following bilinearform: \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} + * dx\f$ * * @param alpha SGPP::base::DataVector that contains the gridpoint's coefficients * @param result SGPP::base::DataVector that contains the result of the down operation * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void operator()(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* UPDPHIDPHIDOWNBBITERATIVELINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* UPDPHIDPHIDOWNBBITERATIVELINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiDownBBLinearStretchedBoundary.cpp b/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiDownBBLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index 36f9d7137a..20e40b1193 --- a/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiDownBBLinearStretchedBoundary.cpp +++ b/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiDownBBLinearStretchedBoundary.cpp @@ -7,23 +7,18 @@ #include - namespace SGPP { namespace pde { - - SGPP::pde::PhiPhiDownBBLinearStretchedBoundary::PhiPhiDownBBLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : SGPP::pde::PhiPhiDownBBLinearStretched( - storage) { -} + SGPP::base::GridStorage* storage) + : SGPP::pde::PhiPhiDownBBLinearStretched(storage) {} -SGPP::pde::PhiPhiDownBBLinearStretchedBoundary::~PhiPhiDownBBLinearStretchedBoundary() { -} +SGPP::pde::PhiPhiDownBBLinearStretchedBoundary::~PhiPhiDownBBLinearStretchedBoundary() {} -void SGPP::pde::PhiPhiDownBBLinearStretchedBoundary::operator()( - SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim) { +void SGPP::pde::PhiPhiDownBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = this->stretching->getIntervalWidth(dim); // float_t t = this->stretching->getIntervalOffset(dim); @@ -50,13 +45,13 @@ void SGPP::pde::PhiPhiDownBBLinearStretchedBoundary::operator()( // check boundary conditions if (this->stretching->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; //left_boundary + result[seq_left] = 0.0; // left_boundary } else { result[seq_left] = ((1.0 / 3.0) * left_boundary) * q; } if (this->stretching->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //right_boundary; + result[seq_right] = 0.0; // right_boundary; } else { result[seq_right] = ((1.0 / 3.0) * right_boundary) * q; @@ -75,10 +70,7 @@ void SGPP::pde::PhiPhiDownBBLinearStretchedBoundary::operator()( index.resetToLeftLevelZero(dim); } - } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiDownBBLinearStretchedBoundary.hpp b/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiDownBBLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 35e94be438..8c583912fb --- a/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiDownBBLinearStretchedBoundary.hpp +++ b/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiDownBBLinearStretchedBoundary.hpp @@ -11,15 +11,11 @@ #include - #include - namespace SGPP { namespace pde { - - /** * Implementation of SGPP::base::sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \phi(x) \phi(x) dx\f$ @@ -32,7 +28,7 @@ class PhiPhiDownBBLinearStretchedBoundary : public PhiPhiDownBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - PhiPhiDownBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit PhiPhiDownBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -43,24 +39,24 @@ class PhiPhiDownBBLinearStretchedBoundary : public PhiPhiDownBBLinearStretched { * This operations performs the calculation of down in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * * On level zero the getfixDirechletBoundaries of the storage object evaluated * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace pde +} // namespace SGPP -#endif /* PHIPHIDOWNBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* PHIPHIDOWNBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiUpBBLinearStretchedBoundary.cpp b/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiUpBBLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index c5ef47c752..96b0244cee --- a/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiUpBBLinearStretchedBoundary.cpp +++ b/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiUpBBLinearStretchedBoundary.cpp @@ -7,25 +7,21 @@ #include - namespace SGPP { namespace pde { - - PhiPhiUpBBLinearStretchedBoundary::PhiPhiUpBBLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : PhiPhiUpBBLinearStretched(storage) { -} + SGPP::base::GridStorage* storage) + : PhiPhiUpBBLinearStretched(storage) {} -PhiPhiUpBBLinearStretchedBoundary::~PhiPhiUpBBLinearStretchedBoundary() { -} +PhiPhiUpBBLinearStretchedBoundary::~PhiPhiUpBBLinearStretchedBoundary() {} -void PhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& - source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void PhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& source, + SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t q = this->stretching->getIntervalWidth(dim); // float_t t = this->stretching->getIntervalOffset(dim); - // get boundary values float_t fl = 0.0; float_t fr = 0.0; @@ -34,7 +30,7 @@ void PhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& index.resetToLevelOne(dim); if (!this->storage->end(index.seq())) { - //This will be changed to rec + // This will be changed to rec rec(source, result, index, dim, fl, fr); } @@ -53,9 +49,9 @@ void PhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& // up ////////////////////////////////////// - //Left + // Left if (this->stretching->hasDirichletBoundaryLeft(dim)) { - result[seq_left] = 0.0; // source[seq_left]; + result[seq_left] = 0.0; // source[seq_left]; } else { result[seq_left] = fl; result[seq_left] += (((1.0 / 6.0) * source[seq_right]) * q); @@ -63,7 +59,7 @@ void PhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& // Right if (this->stretching->hasDirichletBoundaryRight(dim)) { - result[seq_right] = 0.0; //source[seq_right]; + result[seq_right] = 0.0; // source[seq_right]; } else { result[seq_right] = fr; } @@ -71,7 +67,5 @@ void PhiPhiUpBBLinearStretchedBoundary::operator()(SGPP::base::DataVector& index.resetToLeftLevelZero(dim); } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiUpBBLinearStretchedBoundary.hpp b/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiUpBBLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 73781d60b9..f99766bf9a --- a/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiUpBBLinearStretchedBoundary.hpp +++ b/pde/src/sgpp/pde/basis/linearstretched/boundary/algorithm_sweep/PhiPhiUpBBLinearStretchedBoundary.hpp @@ -13,12 +13,9 @@ #include - namespace SGPP { namespace pde { - - /** * Implementation of SGPP::base::sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \phi(x) \phi(x) dx\f$ @@ -31,7 +28,7 @@ class PhiPhiUpBBLinearStretchedBoundary : public PhiPhiUpBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - PhiPhiUpBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit PhiPhiUpBBLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,22 +39,22 @@ class PhiPhiUpBBLinearStretchedBoundary : public PhiPhiUpBBLinearStretched { * This operations performs the calculation of up in the direction of dimension dim * * For level zero it's assumed, that both ansatz-functions do exist: 0,0 and 0,1 - * If one is missing this code might produce some bad errors (segmentation fault, wrong calculation + * If one is missing this code might produce some bad errors (segmentation fault, wrong + * calculation * result) * So please assure that both functions do exist! * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); }; -// namespace detail - -} // namespace SGPP -} +} // namespace pde +} // namespace SGPP -#endif /* PHIPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* PHIPHIUPBBLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/basis/linearstretched/noboundary/DowndPhidPhiBBIterativeLinearStretched.cpp b/pde/src/sgpp/pde/basis/linearstretched/noboundary/DowndPhidPhiBBIterativeLinearStretched.cpp old mode 100755 new mode 100644 index b67bdeb420..1b5c6ccb58 --- a/pde/src/sgpp/pde/basis/linearstretched/noboundary/DowndPhidPhiBBIterativeLinearStretched.cpp +++ b/pde/src/sgpp/pde/basis/linearstretched/noboundary/DowndPhidPhiBBIterativeLinearStretched.cpp @@ -8,19 +8,18 @@ #include - namespace SGPP { namespace pde { DowndPhidPhiBBIterativeLinearStretched::DowndPhidPhiBBIterativeLinearStretched( - SGPP::base::GridStorage* storage) : storage(storage) { -} + SGPP::base::GridStorage* storage) + : storage(storage) {} -DowndPhidPhiBBIterativeLinearStretched::~DowndPhidPhiBBIterativeLinearStretched() { -} +DowndPhidPhiBBIterativeLinearStretched::~DowndPhidPhiBBIterativeLinearStretched() {} -void DowndPhidPhiBBIterativeLinearStretched::operator()( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void DowndPhidPhiBBIterativeLinearStretched::operator()(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { SGPP::base::Stretching* stretching = this->storage->getStretching(); // float_t q = stretching->getIntervalWidth(dim); // @@ -64,16 +63,14 @@ void DowndPhidPhiBBIterativeLinearStretched::operator()( SGPP::base::GridStorage::index_type::index_type index; (*storage)[i]->get(dim, level, index); float_t posl = 0, posr = 0, posc = 0; - stretching->getAdjacentPositions(static_cast(level), - static_cast(index), dim, posc, posl, posr ); + stretching->getAdjacentPositions(static_cast(level), static_cast(index), dim, posc, + posl, posr); float_t baseLength = posr - posl; float_t leftLength = posc - posl; float_t rightLength = posr - posc; - //only affects the diagonal of the stiffness matrix + // only affects the diagonal of the stiffness matrix result[i] = alpha[i] * baseLength / (leftLength * rightLength); } - -} - } -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linearstretched/noboundary/DowndPhidPhiBBIterativeLinearStretched.hpp b/pde/src/sgpp/pde/basis/linearstretched/noboundary/DowndPhidPhiBBIterativeLinearStretched.hpp old mode 100755 new mode 100644 index f0a0496786..037f63f7a5 --- a/pde/src/sgpp/pde/basis/linearstretched/noboundary/DowndPhidPhiBBIterativeLinearStretched.hpp +++ b/pde/src/sgpp/pde/basis/linearstretched/noboundary/DowndPhidPhiBBIterativeLinearStretched.hpp @@ -11,7 +11,6 @@ #include - namespace SGPP { namespace pde { @@ -38,7 +37,7 @@ class DowndPhidPhiBBIterativeLinearStretched { * * @param storage Pointer to the grid's storage object */ - DowndPhidPhiBBIterativeLinearStretched(SGPP::base::GridStorage* storage); + explicit DowndPhidPhiBBIterativeLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,17 +46,17 @@ class DowndPhidPhiBBIterativeLinearStretched { /** * This operations performs the calculation of Down in the direction of dimension dim - * of following bilinearform: \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ + * of following bilinearform: \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} + * dx\f$ * * @param alpha SGPP::base::DataVector that contains the gridpoint's coefficients * @param result SGPP::base::DataVector that contains the result of the down operation * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void operator()(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* DOWNDPHIDPHIDOWNBBITERATIVELINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* DOWNDPHIDPHIDOWNBBITERATIVELINEARSTRETCHED_HPP */ diff --git a/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiDownBBLinearStretched.cpp b/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiDownBBLinearStretched.cpp old mode 100755 new mode 100644 index 374d248976..19f9dbbad6 --- a/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiDownBBLinearStretched.cpp +++ b/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiDownBBLinearStretched.cpp @@ -5,33 +5,25 @@ #include - #include - namespace SGPP { namespace pde { +PhiPhiDownBBLinearStretched::PhiPhiDownBBLinearStretched(SGPP::base::GridStorage* storage) + : storage(storage), stretching(storage->getStretching()) {} - -PhiPhiDownBBLinearStretched::PhiPhiDownBBLinearStretched( - SGPP::base::GridStorage* storage) : storage(storage), - stretching(storage->getStretching()) { -} - -PhiPhiDownBBLinearStretched::~PhiPhiDownBBLinearStretched() { -} +PhiPhiDownBBLinearStretched::~PhiPhiDownBBLinearStretched() {} void PhiPhiDownBBLinearStretched::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { rec(source, result, index, dim, 0.0, 0.0); - } void PhiPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { - + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -43,18 +35,18 @@ void PhiPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, float_t posl = 0, posr = 0, currentPosition = 0; this->stretching->getAdjacentPositions(static_cast(current_level), - static_cast(current_index), dim, currentPosition, posl, posr ); + static_cast(current_index), dim, currentPosition, + posl, posr); float_t baseLength = posr - posl; float_t leftLength = currentPosition - posl; float_t rightLength = posr - currentPosition; // integration - result[seq] = (1.0 / 3.0) * (baseLength) * alpha_value + fl / 6.0 * - (baseLength + rightLength) + fr / 6.0 * (baseLength + leftLength); + result[seq] = (1.0 / 3.0) * (baseLength)*alpha_value + fl / 6.0 * (baseLength + rightLength) + + fr / 6.0 * (baseLength + leftLength); // dehierarchisation - float_t fm = (fr - fl) * (leftLength) / (baseLength) + fl + alpha_value; - + float_t fm = (fr - fl) * (leftLength) / (baseLength) + fl + alpha_value; if (!index.hint()) { index.leftChild(dim); @@ -73,7 +65,5 @@ void PhiPhiDownBBLinearStretched::rec(SGPP::base::DataVector& source, } } -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiDownBBLinearStretched.hpp b/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiDownBBLinearStretched.hpp old mode 100755 new mode 100644 index 36fb49961f..8e1692612f --- a/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiDownBBLinearStretched.hpp +++ b/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiDownBBLinearStretched.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace pde { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \phi(x) \phi(x) dx\f$ @@ -36,7 +33,7 @@ class PhiPhiDownBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - PhiPhiDownBBLinearStretched(SGPP::base::GridStorage* storage); + explicit PhiPhiDownBBLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class PhiPhiDownBBLinearStretched { * This operations performs the calculation of down in the direction of dimension dim * on a grid with Dirichlet 0 boundary conditions. * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down with SGPP::base::Stretching * @@ -67,14 +64,11 @@ class PhiPhiDownBBLinearStretched { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); - + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace pde +} // namespace SGPP -#endif /* PHIPHIDOWNBBLINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* PHIPHIDOWNBBLINEARSTRETCHED_HPP */ diff --git a/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiUpBBLinearStretched.cpp b/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiUpBBLinearStretched.cpp old mode 100755 new mode 100644 index 8791ccc61f..8a81344c4b --- a/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiUpBBLinearStretched.cpp +++ b/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiUpBBLinearStretched.cpp @@ -5,37 +5,28 @@ #include - #include - namespace SGPP { namespace pde { +PhiPhiUpBBLinearStretched::PhiPhiUpBBLinearStretched(SGPP::base::GridStorage* storage) + : storage(storage), stretching(storage->getStretching()) {} - -PhiPhiUpBBLinearStretched::PhiPhiUpBBLinearStretched(SGPP::base::GridStorage* - storage) : storage(storage), stretching(storage->getStretching()) { -} - -PhiPhiUpBBLinearStretched::~PhiPhiUpBBLinearStretched() { -} +PhiPhiUpBBLinearStretched::~PhiPhiUpBBLinearStretched() {} void PhiPhiUpBBLinearStretched::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { - + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { // get boundary values float_t fl = 0.0; float_t fr = 0.0; rec(source, result, index, dim, fl, fr); - } -void PhiPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { - +void PhiPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); fl = fr = 0.0; @@ -64,7 +55,8 @@ void PhiPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, index.get(dim, current_level, current_index); float_t posl = 0, posr = 0, currentPosition = 0; this->stretching->getAdjacentPositions(static_cast(current_level), - static_cast(current_index), dim, currentPosition, posl, posr ); + static_cast(current_index), dim, currentPosition, + posl, posr); float_t baseLength = posr - posl; float_t leftLength = currentPosition - posl; float_t rightLength = posr - currentPosition; @@ -76,14 +68,10 @@ void PhiPhiUpBBLinearStretched::rec(SGPP::base::DataVector& source, // transposed operations: result[seq] = fm; - fl = (1.0 / 6.0) * (baseLength + rightLength) * alpha_value + fl + fm * - (rightLength / baseLength); - fr = (1.0 / 6.0) * (baseLength + leftLength) * alpha_value + fr + fm * - (leftLength / baseLength); + fl = + (1.0 / 6.0) * (baseLength + rightLength) * alpha_value + fl + fm * (rightLength / baseLength); + fr = (1.0 / 6.0) * (baseLength + leftLength) * alpha_value + fr + fm * (leftLength / baseLength); } - -// namespace detail - -} // namespace SGPP -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiUpBBLinearStretched.hpp b/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiUpBBLinearStretched.hpp old mode 100755 new mode 100644 index 79f15e9fac..98fa6179e1 --- a/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiUpBBLinearStretched.hpp +++ b/pde/src/sgpp/pde/basis/linearstretched/noboundary/algorithm_sweep/PhiPhiUpBBLinearStretched.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace pde { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \phi(x) \phi(x) dx\f$ @@ -36,7 +33,7 @@ class PhiPhiUpBBLinearStretched { * * @param storage the grid's SGPP::base::GridStorage object */ - PhiPhiUpBBLinearStretched(SGPP::base::GridStorage* storage); + explicit PhiPhiUpBBLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,16 +44,16 @@ class PhiPhiUpBBLinearStretched { * This operations performs the calculation of up in the direction of dimension dim * on a grid with fix Dirichlet 0 boundary conditions * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim); + virtual void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up without bounding Box support * @@ -67,15 +64,11 @@ class PhiPhiUpBBLinearStretched { * @param fl function value on the left boundary, reference parameter * @param fr function value on the right boundary, reference parameter */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); - - + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); }; -// namespace detail - -} // namespace SGPP -} +} // namespace pde +} // namespace SGPP -#endif /* PHIPHIUPBBLINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* PHIPHIUPBBLINEARSTRETCHED_HPP */ diff --git a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiDownModLinear.cpp b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiDownModLinear.cpp index c08605fb1f..dcf0e4886b 100644 --- a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiDownModLinear.cpp +++ b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiDownModLinear.cpp @@ -7,27 +7,20 @@ #include - namespace SGPP { namespace pde { +PhiPhiDownModLinear::PhiPhiDownModLinear(SGPP::base::GridStorage* storage) : storage(storage) {} +PhiPhiDownModLinear::~PhiPhiDownModLinear() {} -PhiPhiDownModLinear::PhiPhiDownModLinear(SGPP::base::GridStorage* storage) : - storage(storage) { -} - -PhiPhiDownModLinear::~PhiPhiDownModLinear() { -} - -void PhiPhiDownModLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void PhiPhiDownModLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { rec(source, result, index, dim, 0.0, 0.0); } -void PhiPhiDownModLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t fl, - float_t fr) { +void PhiPhiDownModLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t fl, float_t fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -42,51 +35,41 @@ void PhiPhiDownModLinear::rec(SGPP::base::DataVector& source, // level 1, constant function if (l == 1) { - //integration + // integration result[seq] = 0.0 + alpha_value; - //dehierarchisation + // dehierarchisation fm = (fl + fr) / 2.0 + alpha_value; - //boundary value + // boundary value fl += alpha_value; fr += alpha_value; - } - // left boundary - else if (i == 1) { - //integration - result[seq] = 2.0 / 3.0 * h * (2.0 * fl + fr) - + 8.0 / 3.0 * h * alpha_value; + } else if (i == 1) { // left boundary + // integration + result[seq] = 2.0 / 3.0 * h * (2.0 * fl + fr) + 8.0 / 3.0 * h * alpha_value; - //dehierarchisation + // dehierarchisation fm = (fl + fr) / 2.0 + alpha_value; - //boundary value + // boundary value fl += 2.0 * alpha_value; - } - // right boundary - else if (static_cast(i) == static_cast((1 << l) - 1)) { - //integration - result[seq] = 2.0 / 3.0 * h * (fl + 2.0 * fr) - + 8.0 / 3.0 * h * alpha_value; + } else if (static_cast(i) == static_cast((1 << l) - 1)) { // right boundary + // integration + result[seq] = 2.0 / 3.0 * h * (fl + 2.0 * fr) + 8.0 / 3.0 * h * alpha_value; - //dehierarchisation + // dehierarchisation fm = (fl + fr) / 2.0 + alpha_value; - //boundary value + // boundary value fr += 2.0 * alpha_value; - } - // inner functions - else { - //integration - result[seq] = h * (fl + fr) / 2.0 - + 2.0 / 3.0 * h * alpha_value; + } else { // inner functions + // integration + result[seq] = h * (fl + fr) / 2.0 + 2.0 / 3.0 * h * alpha_value; - //dehierarchisation + // dehierarchisation fm = (fl + fr) / 2.0 + alpha_value; - //boundary value - + // boundary value } if (!index.hint()) { @@ -105,8 +88,5 @@ void PhiPhiDownModLinear::rec(SGPP::base::DataVector& source, index.up(dim); } } - - - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiDownModLinear.hpp b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiDownModLinear.hpp old mode 100755 new mode 100644 index ef128b6cc3..3429fcf536 --- a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiDownModLinear.hpp +++ b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiDownModLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace pde { - - /** * Implementation of sweep operator (): 1D Down for * Bilinearform \f$\int_{x} \phi(x) \phi(x) dx\f$ @@ -34,7 +31,7 @@ class PhiPhiDownModLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - PhiPhiDownModLinear(SGPP::base::GridStorage* storage); + explicit PhiPhiDownModLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -44,7 +41,8 @@ class PhiPhiDownModLinear { /** * This operations performs the calculation of down in the direction of dimension dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -53,7 +51,6 @@ class PhiPhiDownModLinear { grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Down * @@ -64,13 +61,10 @@ class PhiPhiDownModLinear { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t fl, float_t fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t fl, float_t fr); }; +} // namespace pde +} // namespace SGPP - - -} -} - -#endif /* PHIPHIDOWNMODLINEAR_HPP */ \ No newline at end of file +#endif /* PHIPHIDOWNMODLINEAR_HPP */ diff --git a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiUpModLinear.cpp b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiUpModLinear.cpp index 5edd9b1f94..ef3556dda5 100644 --- a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiUpModLinear.cpp +++ b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiUpModLinear.cpp @@ -7,29 +7,22 @@ #include - namespace SGPP { namespace pde { +PhiPhiUpModLinear::PhiPhiUpModLinear(SGPP::base::GridStorage* storage) : storage(storage) {} +PhiPhiUpModLinear::~PhiPhiUpModLinear() {} -PhiPhiUpModLinear::PhiPhiUpModLinear(SGPP::base::GridStorage* storage) : - storage(storage) { -} - -PhiPhiUpModLinear::~PhiPhiUpModLinear() { -} - -void PhiPhiUpModLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void PhiPhiUpModLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t fl = 0.0; float_t fr = 0.0; rec(source, result, index, dim, fl, fr); } -void PhiPhiUpModLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& fl, - float_t& fr) { +void PhiPhiUpModLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& fl, float_t& fr) { size_t seq = index.seq(); float_t alpha_value = source[seq]; @@ -67,31 +60,22 @@ void PhiPhiUpModLinear::rec(SGPP::base::DataVector& source, fl += fm / 2.0 + alpha_value; fr += fm / 2.0 + alpha_value; - } - // left boundary - else if (i == 1) { + } else if (i == 1) { // left boundary result[seq] = 2.0 * fl + fm; fl += fm / 2.0 + 4.0 / 3.0 * h * alpha_value; fr += fm / 2.0 + 2.0 / 3.0 * h * alpha_value; - } - // right boundary - else if (static_cast(i) == static_cast((1 << l) - 1)) { + } else if (static_cast(i) == static_cast((1 << l) - 1)) { // right boundary result[seq] = 2.0 * fr + fm; fl += fm / 2.0 + 2.0 / 3.0 * h * alpha_value; fr += fm / 2.0 + 4.0 / 3.0 * h * alpha_value; - } - // inner functions - else { + } else { // inner functions result[seq] = fm; fl += fm / 2.0 + h / 2.0 * alpha_value; fr += fm / 2.0 + h / 2.0 * alpha_value; } } - - - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiUpModLinear.hpp b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiUpModLinear.hpp old mode 100755 new mode 100644 index c98535833e..a54b38b8b1 --- a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiUpModLinear.hpp +++ b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/PhiPhiUpModLinear.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace pde { - - /** * Implementation of sweep operator (): 1D Up for * Bilinearform \f$\int_{x} \phi(x) \phi(x) dx\f$ @@ -34,7 +31,7 @@ class PhiPhiUpModLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - PhiPhiUpModLinear(SGPP::base::GridStorage* storage); + explicit PhiPhiUpModLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -44,7 +41,8 @@ class PhiPhiUpModLinear { /** * This operations performs the calculation of up in the direction of dimension dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -53,7 +51,6 @@ class PhiPhiUpModLinear { grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of Up * @@ -64,13 +61,10 @@ class PhiPhiUpModLinear { * @param fl function value on the left boundary * @param fr function value on the right boundary */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& fl, float_t& fr); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& fl, float_t& fr); }; +} // namespace pde +} // namespace SGPP - - -} -} - -#endif /* PHIPHIUPMODLINEAR_HPP */ \ No newline at end of file +#endif /* PHIPHIUPMODLINEAR_HPP */ diff --git a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiDownModLinear.cpp b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiDownModLinear.cpp index ebf7b9ceb7..f2f8420032 100644 --- a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiDownModLinear.cpp +++ b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiDownModLinear.cpp @@ -7,26 +7,21 @@ #include - namespace SGPP { namespace pde { +dPhidPhiDownModLinear::dPhidPhiDownModLinear(SGPP::base::GridStorage* storage) : storage(storage) {} - -dPhidPhiDownModLinear::dPhidPhiDownModLinear(SGPP::base::GridStorage* storage) : - storage(storage) { -} - -dPhidPhiDownModLinear::~dPhidPhiDownModLinear() { -} +dPhidPhiDownModLinear::~dPhidPhiDownModLinear() {} void dPhidPhiDownModLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { rec(source, result, index, dim, 0.0); } -void dPhidPhiDownModLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t f) { +void dPhidPhiDownModLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t f) { size_t seq = index.seq(); SGPP::base::GridStorage::index_type::level_type l; SGPP::base::GridStorage::index_type::index_type i; @@ -40,20 +35,15 @@ void dPhidPhiDownModLinear::rec(SGPP::base::DataVector& source, // level 1, constant function if (l == 1) { f_local = 0.0; - result[seq] = 0.0 - + 0.0; - } - // left boundary & right boundary - else if ((i == 1) || (static_cast(i) == static_cast((1 << l) - 1))) { + result[seq] = 0.0 + 0.0; + } else if ((i == 1) || (static_cast(i) == static_cast((1 << l) - 1))) { + // left boundary & right boundary f_local = ht * alpha_value; - result[seq] = 2.0 * f - + 2.0 * f_local; - } - // inner functions - else { + result[seq] = 2.0 * f + 2.0 * f_local; + } else { + // inner functions f_local = ht * alpha_value; - result[seq] = 0.0 - + 2.0 * f_local; + result[seq] = 0.0 + 2.0 * f_local; } if (!index.hint()) { @@ -71,10 +61,6 @@ void dPhidPhiDownModLinear::rec(SGPP::base::DataVector& source, index.up(dim); } - -} - - - } -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiDownModLinear.hpp b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiDownModLinear.hpp old mode 100755 new mode 100644 index dcdbc7b9cc..ea7dfbb871 --- a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiDownModLinear.hpp +++ b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiDownModLinear.hpp @@ -11,15 +11,13 @@ #include - namespace SGPP { namespace pde { - - /** * Implementation of sweep operator (): 1D Down for - * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{\partial x} \frac{\partial \phi(x)}{\partial x} dx\f$ + * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{\partial x} \frac{\partial \phi(x)}{\partial x} + * dx\f$ * on mod-linear grids */ class dPhidPhiDownModLinear { @@ -34,7 +32,7 @@ class dPhidPhiDownModLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - dPhidPhiDownModLinear(SGPP::base::GridStorage* storage); + explicit dPhidPhiDownModLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,9 +40,11 @@ class dPhidPhiDownModLinear { ~dPhidPhiDownModLinear(); /** - * This operations performs the calculation of downGradient in the direction of dimension dim + * This operations performs the calculation of downGradient in the direction of dimension + * dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -53,7 +53,6 @@ class dPhidPhiDownModLinear { grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of downGradient * @@ -63,13 +62,10 @@ class dPhidPhiDownModLinear { * @param dim the dimension in which the operation is executed * @param f function value in the middle */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t f); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t f); }; +} // namespace pde +} // namespace SGPP - - -} -} - -#endif /* DPHIDPHIDOWNMODLINEAR_HPP */ \ No newline at end of file +#endif /* DPHIDPHIDOWNMODLINEAR_HPP */ diff --git a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiUpModLinear.cpp b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiUpModLinear.cpp index a26ca99feb..62ad6bc3a7 100644 --- a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiUpModLinear.cpp +++ b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiUpModLinear.cpp @@ -7,27 +7,21 @@ #include - namespace SGPP { namespace pde { +dPhidPhiUpModLinear::dPhidPhiUpModLinear(SGPP::base::GridStorage* storage) : storage(storage) {} +dPhidPhiUpModLinear::~dPhidPhiUpModLinear() {} -dPhidPhiUpModLinear::dPhidPhiUpModLinear(SGPP::base::GridStorage* storage) : - storage(storage) { -} - -dPhidPhiUpModLinear::~dPhidPhiUpModLinear() { -} - -void dPhidPhiUpModLinear::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { +void dPhidPhiUpModLinear::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim) { float_t f = 0.0; rec(source, result, index, dim, f); } -void dPhidPhiUpModLinear::rec(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, grid_iterator& index, size_t dim, float_t& f) { +void dPhidPhiUpModLinear::rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, + grid_iterator& index, size_t dim, float_t& f) { size_t seq = index.seq(); SGPP::base::GridStorage::index_type::level_type l; @@ -59,9 +53,7 @@ void dPhidPhiUpModLinear::rec(SGPP::base::DataVector& source, } result[seq] = 0.0; - } - // left boundary - else if (i == 1) { + } else if (i == 1) { // left boundary f = 0.0; if (!index.hint()) { @@ -77,9 +69,7 @@ void dPhidPhiUpModLinear::rec(SGPP::base::DataVector& source, result[seq] = ht * f; f += 2.0 * alpha_value; - } - // right boundary - else if (static_cast(i) == static_cast((1 << l) - 1)) { + } else if (static_cast(i) == static_cast((1 << l) - 1)) { // right boundary f = 0.0; if (!index.hint()) { @@ -97,8 +87,5 @@ void dPhidPhiUpModLinear::rec(SGPP::base::DataVector& source, f += 2.0 * alpha_value; } } - - - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiUpModLinear.hpp b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiUpModLinear.hpp old mode 100755 new mode 100644 index 12a85a6ec1..4d797beeb0 --- a/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiUpModLinear.hpp +++ b/pde/src/sgpp/pde/basis/modlinear/algorithm_sweep/dPhidPhiUpModLinear.hpp @@ -11,15 +11,13 @@ #include - namespace SGPP { namespace pde { - - /** * Implementation of sweep operator (): 1D Up for - * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{\partial x} \frac{\partial \phi(x)}{\partial x} dx\f$ + * Bilinearform \f$\int_{x} \frac{\partial \phi(x)}{\partial x} \frac{\partial \phi(x)}{\partial x} + * dx\f$ * on mod-linear grids */ class dPhidPhiUpModLinear { @@ -34,7 +32,7 @@ class dPhidPhiUpModLinear { * * @param storage the grid's SGPP::base::GridStorage object */ - dPhidPhiUpModLinear(SGPP::base::GridStorage* storage); + explicit dPhidPhiUpModLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -44,7 +42,8 @@ class dPhidPhiUpModLinear { /** * This operations performs the calculation of upGradient in the direction of dimension dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -53,7 +52,6 @@ class dPhidPhiUpModLinear { grid_iterator& index, size_t dim); protected: - /** * recursive function for the calculation of upGradient * @@ -63,13 +61,10 @@ class dPhidPhiUpModLinear { * @param dim the dimension in which the operation is executed * @param f function value in the middle */ - void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, - grid_iterator& index, size_t dim, float_t& f); + void rec(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, + size_t dim, float_t& f); }; +} // namespace pde +} // namespace SGPP - - -} -} - -#endif /* DPHIDPHIUPMODLINEAR_HPP */ \ No newline at end of file +#endif /* DPHIDPHIUPMODLINEAR_HPP */ diff --git a/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceDownGradientPrewavelet.cpp b/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceDownGradientPrewavelet.cpp old mode 100755 new mode 100644 index 7ed5f3d5e2..070792d6bd --- a/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceDownGradientPrewavelet.cpp +++ b/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceDownGradientPrewavelet.cpp @@ -7,22 +7,17 @@ #include - namespace SGPP { namespace pde { -LaplaceDownGradientPrewavelet::LaplaceDownGradientPrewavelet( - SGPP::base::GridStorage* storage) : - storage(storage) { -} +LaplaceDownGradientPrewavelet::LaplaceDownGradientPrewavelet(SGPP::base::GridStorage* storage) + : storage(storage) {} -LaplaceDownGradientPrewavelet::~LaplaceDownGradientPrewavelet() { -} +LaplaceDownGradientPrewavelet::~LaplaceDownGradientPrewavelet() {} void LaplaceDownGradientPrewavelet::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, - grid_iterator& index, size_t dim) { - + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { size_t _seql2, _seql1, _seq, _seqr1, _seqr2 = 0; float_t _vall2, _vall1, _val, _valr1, _valr2 = 0; @@ -31,27 +26,27 @@ void LaplaceDownGradientPrewavelet::operator()(SGPP::base::DataVector& source, float_t h; - index.get(dim, l_old, i_old); //save iterator and restore afterwards - max_level = index.getGridDepth(dim); //How many levels to decent? + index.get(dim, l_old, i_old); // save iterator and restore afterwards + max_level = index.getGridDepth(dim); // How many levels to decent? - //We need the temp_values of the level above + // We need the temp_values of the level above float_t* temp_current = new float_t[1]; float_t* temp_old; - //Level 1----------------------------------------------------------- + // Level 1----------------------------------------------------------- _seq = index.seq(); temp_current[0] = 4 * source[_seq]; result[_seq] = 4 * source[_seq]; - //Is there a second level? + // Is there a second level? if (max_level == 1) { - //No, delete temp and return + // No, delete temp and return delete[] temp_current; index.set(dim, l_old, i_old); return; } - //Level 2----------------------------------------------------------- + // Level 2----------------------------------------------------------- l = 2; h = static_cast(1 << l); temp_old = temp_current; @@ -61,32 +56,30 @@ void LaplaceDownGradientPrewavelet::operator()(SGPP::base::DataVector& source, index.stepRight(dim); _seqr1 = index.seq(); - //Calculate new temp variables + // Calculate new temp variables temp_current[0] = 2.4 * h * source[_seql1] + 0.8 * h * source[_seqr1]; - temp_current[1] = temp_old[0] - 2.2 * h * (source[_seql1] - + source[_seqr1]); + temp_current[1] = temp_old[0] - 2.2 * h * (source[_seql1] + source[_seqr1]); temp_current[2] = 2.4 * h * source[_seqr1] + 0.8 * h * source[_seql1]; - //Calculate results - _vall1 = source[_seql1];//We save the variables to enable work in sito. + // Calculate results + _vall1 = source[_seql1]; // We save the variables to enable work in sito. _valr1 = source[_seqr1]; - result[_seql1] = -0.6 * temp_old[0] + 3.56 * h * _vall1 + 2.28 * h - * _valr1; - result[_seqr1] = -0.6 * temp_old[0] + 3.56 * h * _valr1 + 2.28 * h - * _vall1; + result[_seql1] = -0.6 * temp_old[0] + 3.56 * h * _vall1 + 2.28 * h * _valr1; + result[_seqr1] = -0.6 * temp_old[0] + 3.56 * h * _valr1 + 2.28 * h * _vall1; - //All other levels-------------------------------------------------- + // All other levels-------------------------------------------------- for (l = 3; l <= max_level; l++) { h = static_cast(1 << l); index.set(dim, l, 1); - //Calculate new temp-Variables ################################################ + // Calculate new temp-Variables ################################################ delete[] temp_old; temp_old = temp_current; temp_current = new float_t[(1 << l) - 1]; - if (l != max_level) { //If we are in the last iteration, we don't need any more temp-variables, thus skip the calculation - //Ramp up + if (l != max_level) { // If we are in the last iteration, we don't need any more + // temp-variables, thus skip the calculation + // Ramp up _seql2 = index.seq(); _vall2 = storage->end(_seql2) ? 0.0 : source[_seql2]; @@ -102,30 +95,30 @@ void LaplaceDownGradientPrewavelet::operator()(SGPP::base::DataVector& source, _seqr2 = index.seq(); _valr2 = storage->end(_seqr2) ? 0.0 : source[_seqr2]; - temp_current[0] = 2.4 * h * _vall2// SGPP::base::Grid-point - + 0.8 * h * _vall1; //right neighbor + temp_current[0] = 2.4 * h * _vall2 // SGPP::base::Grid-point + + 0.8 * h * _vall1; // right neighbor - temp_current[1] = temp_old[0]// - - 2.2 * h * _vall2 // left neighbor - - 2.3 * h * _vall1 // right neighbor - - 0.1 * h * _valr1; //right-right neighbor + temp_current[1] = temp_old[0] // + - 2.2 * h * _vall2 // left neighbor + - 2.3 * h * _vall1 // right neighbor + - 0.1 * h * _valr1; // right-right neighbor - for (i = 2; (int)i < (1 << l) - 3; i++) { - if (i % 2 == 0) { //On SGPP::base::Grid-Points - if ((int)i == (1 << l) - 4) { - temp_current[i] = 3.2 * h * _valr1 //current grid point - + 0.8 * h * (_vall1 + _valr2); //neighbors left and right + for (i = 2; static_cast(i) < (1 << l) - 3; i++) { + if (i % 2 == 0) { // On SGPP::base::Grid-Points + if (static_cast(i) == (1 << l) - 4) { + temp_current[i] = 3.2 * h * _valr1 // current grid point + + 0.8 * h * (_vall1 + _valr2); // neighbors left and right } else { - temp_current[i] = 3.2 * h * _vall1 //current grid point - + 0.8 * h * (_vall2 + _valr1); //neighbors left and right + temp_current[i] = 3.2 * h * _vall1 // current grid point + + 0.8 * h * (_vall2 + _valr1); // neighbors left and right } - } else { //between grid points - temp_current[i] = temp_old[(i - 1) / 2] //temp-value from above - - 2.3 * h * (_vall1 + _valr1)//left and right neighbor - - 0.1 * h * (_vall2 + _valr2);//left-left and right-right neighbor + } else { // between grid points + temp_current[i] = temp_old[(i - 1) / 2] // temp-value from above + - 2.3 * h * (_vall1 + _valr1) // left and right neighbor + - 0.1 * h * (_vall2 + _valr2); // left-left and right-right neighbor - //forward indoces except in the last iteration - if ((int)i != (1 << l) - 5) { + // forward indoces except in the last iteration + if (static_cast(i) != (1 << l) - 5) { _vall2 = _vall1; _vall1 = _valr1; _valr1 = _valr2; @@ -133,25 +126,22 @@ void LaplaceDownGradientPrewavelet::operator()(SGPP::base::DataVector& source, _seq = index.seq(); _valr2 = storage->end(_seq) ? 0.0 : source[_seq]; } - } } - //Two temp-values left - temp_current[(1 << l) - 3] = temp_old[((1 << l) - 4) / 2] // - - 2.2 * h * _valr2 - 2.3 * h * _valr1 //left and right neighbor - - 0.1 * h * _vall1; //left-left neighbor - - temp_current[(1 << l) - 2] = 2.4 * h * _valr2 + 0.8 * h - * _valr1; //On SGPP::base::Grid-point - + // Two temp-values left + temp_current[(1 << l) - 3] = temp_old[((1 << l) - 4) / 2] // + - 2.2 * h * _valr2 - 2.3 * h * _valr1 // left and right neighbor + - 0.1 * h * _vall1; // left-left neighbor + temp_current[(1 << l) - 2] = 2.4 * h * _valr2 + 0.8 * h * _valr1; // On + // SGPP::base::Grid-point } // End of temp-value calculation ################################################ // Calculate result ################################################ - //Ramp-up + // Ramp-up index.set(dim, l, 1); _seql2 = index.seq(); _vall2 = storage->end(_seql2) ? 0.0 : source[_seql2]; @@ -175,16 +165,16 @@ void LaplaceDownGradientPrewavelet::operator()(SGPP::base::DataVector& source, } if (!storage->end(_seql2)) - result[_seql2] = -0.6 * temp_old[0] + 3.56 * h * _vall2 //current point - + 2.42 * h * _vall1 //right neighbor - + 0.14 * h * _val; //right-right neighbor + result[_seql2] = -0.6 * temp_old[0] + 3.56 * h * _vall2 // current point + + 2.42 * h * _vall1 // right neighbor + + 0.14 * h * _val; // right-right neighbor if (!storage->end(_seql1)) - result[_seql1] = -0.6 * (temp_old[0] + temp_old[1]) // - + 6.12 * h * _vall1 //current point - + 2.42 * h * _vall2 //left neighbor - + 2.56 * h * _val //right neighbor - + 0.14 * h * _valr1; //right-right neighbor + result[_seql1] = -0.6 * (temp_old[0] + temp_old[1]) // + + 6.12 * h * _vall1 // current point + + 2.42 * h * _vall2 // left neighbor + + 2.56 * h * _val // right neighbor + + 0.14 * h * _valr1; // right-right neighbor if (l == 3) { /* level = 3, that means we have only 4 gridpoints, thus we have to @@ -203,17 +193,15 @@ void LaplaceDownGradientPrewavelet::operator()(SGPP::base::DataVector& source, _vall1 = _vall2; _seql1 = _seql2; } else { - - for (i = 5; (int)i < (1 << l) - 4; i += 2) { + for (i = 5; static_cast(i) < (1 << l) - 4; i += 2) { if (!storage->end(_seq)) - result[_seq] = -0.6 * (temp_old[(i - 3) / 2] - + temp_old[(i - 1) / 2]) // - + 6.12 * h * _val //current point - + 2.56 * h * (_vall1 + _valr1) //left and right neighbor - + 0.14 * h * (_vall2 + _valr2); //left-left and right-right neighbor - - if ((int)i != (1 << l) - 5) { - //forward indices, except during the last iteration + result[_seq] = -0.6 * (temp_old[(i - 3) / 2] + temp_old[(i - 1) / 2]) // + + 6.12 * h * _val // current point + + 2.56 * h * (_vall1 + _valr1) // left and right neighbor + + 0.14 * h * (_vall2 + _valr2); // left-left and right-right neighbor + + if (static_cast(i) != (1 << l) - 5) { + // forward indices, except during the last iteration _vall2 = _vall1; _vall1 = _val; _val = _valr1; @@ -227,21 +215,19 @@ void LaplaceDownGradientPrewavelet::operator()(SGPP::base::DataVector& source, } } - //Again, two points left + // Again, two points left if (!storage->end(_seqr1)) - result[_seqr1] = -0.6 * (temp_old[(1 << (l - 1)) - 3] - + temp_old[(1 << (l - 1)) - 2]) // - + 6.12 * h * _valr1 //current point - + 2.42 * h * _valr2 //right neighbor - + 2.56 * h * _val //left neighbor - + 0.14 * h * _vall1; //left-left neighbor + result[_seqr1] = -0.6 * (temp_old[(1 << (l - 1)) - 3] + temp_old[(1 << (l - 1)) - 2]) // + + 6.12 * h * _valr1 // current point + + 2.42 * h * _valr2 // right neighbor + + 2.56 * h * _val // left neighbor + + 0.14 * h * _vall1; // left-left neighbor if (!storage->end(_seqr2)) - result[_seqr2] = -0.6 * temp_old[(1 << (l - 1)) - 2]// - + 3.56 * h * _valr2 //current point - + 2.42 * h * _valr1 //left neighbor - + 0.14 * h * _val; //left-left neighbor - + result[_seqr2] = -0.6 * temp_old[(1 << (l - 1)) - 2] // + + 3.56 * h * _valr2 // current point + + 2.42 * h * _valr1 // left neighbor + + 0.14 * h * _val; // left-left neighbor } index.set(dim, l_old, i_old); @@ -250,6 +236,5 @@ void LaplaceDownGradientPrewavelet::operator()(SGPP::base::DataVector& source, delete[] temp_old; temp_old = 0; } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceDownGradientPrewavelet.hpp b/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceDownGradientPrewavelet.hpp old mode 100755 new mode 100644 index f882ad6679..5bd9080dfd --- a/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceDownGradientPrewavelet.hpp +++ b/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceDownGradientPrewavelet.hpp @@ -11,17 +11,20 @@ #include - namespace SGPP { namespace pde { - - /** * Implements the downGradient Method needed for the Laplace operator on prewavelet grids. * The calculation is done iterative and utilizes the following temp variables: * \f{eqnarray*}{ - * t_{k,j}&=&\frac{1}{h_{k}}\left(\frac{32}{10}u_{k,j}+\frac{8}{10}u_{k,j\pm2}\right) \quad(k,j)\in G_{n}^{1}\\ t_{k,j}&=&\frac{1}{h_{k}}\left(\frac{24}{10}u_{k,j}+\frac{8}{10}u_{k,j\pm2}\right) \quad(k,j)\in G_{n}^{1}\mbox{ and next to border}\\ t_{k,j}&=&t_{k-1,\frac{j}{2}}-\frac{1}{h_{k}}\left(\frac{23}{10}u_{k,j\pm1}+\frac{1}{10}u_{k,j\pm3}\right) \quad(k,j)\notin G_{n}^{1}\\ t_{k,j}&=&t_{k-1,\frac{j}{2}}-\frac{1}{h_{k}}\left(\frac{22}{10}u_{k,j\pm1}+\frac{1}{10}u_{k,j\pm3}\right) \quad(k,j)\notin G_{n}^{1}\mbox{ and \ensuremath{(k,j\pm1)}next to border} + * t_{k,j}&=&\frac{1}{h_{k}}\left(\frac{32}{10}u_{k,j}+\frac{8}{10}u_{k,j\pm2}\right) \quad(k,j)\in + G_{n}^{1}\\ t_{k,j}&=&\frac{1}{h_{k}}\left(\frac{24}{10}u_{k,j}+\frac{8}{10}u_{k,j\pm2}\right) + \quad(k,j)\in G_{n}^{1}\mbox{ and next to border}\\ + t_{k,j}&=&t_{k-1,\frac{j}{2}}-\frac{1}{h_{k}}\left(\frac{23}{10}u_{k,j\pm1}+\frac{1}{10}u_{k,j\pm3}\right) + \quad(k,j)\notin G_{n}^{1}\\ + t_{k,j}&=&t_{k-1,\frac{j}{2}}-\frac{1}{h_{k}}\left(\frac{22}{10}u_{k,j\pm1}+\frac{1}{10}u_{k,j\pm3}\right) + \quad(k,j)\notin G_{n}^{1}\mbox{ and \ensuremath{(k,j\pm1)}next to border} * \f} * * The calculation of the results is as follows: @@ -29,14 +32,17 @@ namespace pde { r_{k,j}&=&-\frac{6}{10}t_{k-1,\frac{j\pm1}{2}}\\ &&+\frac{1}{h_{k}}u_{k,j}\cdot\left[\frac{612}{100}\mbox{ if \ensuremath{(k,j)} inner point, or } \frac{356}{100}\mbox{ if \ensuremath{(k,j)} border point}\right]\\ - &&+\frac{1}{h_{k}}u_{k,j\pm2}\cdot\left[\frac{256}{100} \mbox{ if \ensuremath{(k,j)} and \ensuremath{(k,j\pm2)} inner point, or } + &&+\frac{1}{h_{k}}u_{k,j\pm2}\cdot\left[\frac{256}{100} \mbox{ if \ensuremath{(k,j)} and + \ensuremath{(k,j\pm2)} inner point, or } \frac{242}{100} \mbox{ if \ensuremath{(k,j)} or \ensuremath{(k,j\pm2)} border point, or } \frac{228}{100} \mbox{ if \ensuremath{(k,j)} border point}\right]\\ &&+\frac{1}{h_{k}}u_{k,j\pm4}\cdot\frac{14}{100}\\r_{1,1}&=&4u_{1,1} * \f} - * Please note, that all values of gridpoints outside of the sparse grid are treated as 0. The following + * Please note, that all values of gridpoints outside of the sparse grid are treated as 0. The + following * picture depicts all involved grid points and temp values in order to calculate a specific point: - * \image html prewavelets_down.png "All involved gridpoint for the up algorithm (red) and temp points between grid points (green). The gray line indicates the support of the prewavelet." + * \image html prewavelets_down.png "All involved gridpoint for the up algorithm (red) and temp + points between grid points (green). The gray line indicates the support of the prewavelet." */ class LaplaceDownGradientPrewavelet { @@ -51,7 +57,7 @@ class LaplaceDownGradientPrewavelet { * * @param storage the grid's SGPP::base::GridStorage object */ - LaplaceDownGradientPrewavelet(SGPP::base::GridStorage* storage); + explicit LaplaceDownGradientPrewavelet(SGPP::base::GridStorage* storage); /** * Destructor @@ -59,9 +65,11 @@ class LaplaceDownGradientPrewavelet { ~LaplaceDownGradientPrewavelet(); /** - * This operations performs the calculation of downGradient in the direction of dimension dim + * This operations performs the calculation of downGradient in the direction of dimension + * dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -69,8 +77,7 @@ class LaplaceDownGradientPrewavelet { void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* LAPLACEDOWNGRADIENTPREWAVELET_HPP */ \ No newline at end of file +#endif /* LAPLACEDOWNGRADIENTPREWAVELET_HPP */ diff --git a/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpGradientPrewavelet.cpp b/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpGradientPrewavelet.cpp old mode 100755 new mode 100644 index c61a52800e..efa653f7af --- a/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpGradientPrewavelet.cpp +++ b/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpGradientPrewavelet.cpp @@ -5,24 +5,19 @@ #include - #include - namespace SGPP { namespace pde { -LaplaceUpGradientPrewavelet::LaplaceUpGradientPrewavelet( - SGPP::base::GridStorage* storage) : - storage(storage) { -} +LaplaceUpGradientPrewavelet::LaplaceUpGradientPrewavelet(SGPP::base::GridStorage* storage) + : storage(storage) {} -LaplaceUpGradientPrewavelet::~LaplaceUpGradientPrewavelet() { -} +LaplaceUpGradientPrewavelet::~LaplaceUpGradientPrewavelet() {} void LaplaceUpGradientPrewavelet::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, - grid_iterator& index, size_t dim) { + SGPP::base::DataVector& result, grid_iterator& index, + size_t dim) { SGPP::base::GridStorage::index_type::level_type l = index.getGridDepth(dim); SGPP::base::GridStorage::index_type::index_type i; @@ -39,8 +34,7 @@ void LaplaceUpGradientPrewavelet::operator()(SGPP::base::DataVector& source, float_t h; - if (l == 1) - return; + if (l == 1) return; index.set(dim, l, 1); _seqr = index.seq(); @@ -48,7 +42,7 @@ void LaplaceUpGradientPrewavelet::operator()(SGPP::base::DataVector& source, float_t* temp_current = new float_t[(1 << (l - 1)) - 1]; - for (i = 0; i < (unsigned int) (1 << (l - 1)) - 1; i++) { + for (i = 0; i < (unsigned int)(1 << (l - 1)) - 1; i++) { _seql = _seqr; _vall = _valr; index.set(dim, l, 2 * i + 3); @@ -66,41 +60,34 @@ void LaplaceUpGradientPrewavelet::operator()(SGPP::base::DataVector& source, _seq = index.seq(); if (!storage->end(_seq)) - result[_seq] = 0.9 * h * (2 * temp_current[i] - temp_current[i - + 1]) - 0.6 * h * (-temp_current[i + 2] + 2 - * temp_current[i + 1] - temp_current[i]) + 0.1 * h - * (-temp_current[i + 1] + 2 * temp_current[i + 2] - - temp_current[i + 3]); + result[_seq] = + 0.9 * h * (2 * temp_current[i] - temp_current[i + 1]) - + 0.6 * h * (-temp_current[i + 2] + 2 * temp_current[i + 1] - temp_current[i]) + + 0.1 * h * (-temp_current[i + 1] + 2 * temp_current[i + 2] - temp_current[i + 3]); i = 2; index.set(dim, l, i + 1); _seq = index.seq(); if (!storage->end(_seq)) - result[_seq] = h * (2 * temp_current[i] - temp_current[i + 1] - - temp_current[i - 1]) + -0.6 * h * (-temp_current[i - + 2] + 2 * temp_current[i + 1] - 2 * temp_current[i]) - - 0.6 * h * (-temp_current[i - 2] + 2 * temp_current[i - - 1]) + 0.1 * h * (-temp_current[i + 1] + 2 - * temp_current[i + 2] - temp_current[i + 3]) + 0.1 * h - * (-temp_current[i - 1] + 2 * temp_current[i - 2]); - - for (i = 4; i < (unsigned int) (1 << l) - 4; i = i + 2) { + result[_seq] = + h * (2 * temp_current[i] - temp_current[i + 1] - temp_current[i - 1]) + + -0.6 * h * (-temp_current[i + 2] + 2 * temp_current[i + 1] - 2 * temp_current[i]) - + 0.6 * h * (-temp_current[i - 2] + 2 * temp_current[i - 1]) + + 0.1 * h * (-temp_current[i + 1] + 2 * temp_current[i + 2] - temp_current[i + 3]) + + 0.1 * h * (-temp_current[i - 1] + 2 * temp_current[i - 2]); + + for (i = 4; i < (unsigned int)(1 << l) - 4; i = i + 2) { index.set(dim, l, i + 1); _seq = index.seq(); if (!storage->end(_seq)) - result[_seq] = h * (2 * temp_current[i] - temp_current[i - + 1] - temp_current[i - 1]) - 0.6 * h - * (-temp_current[i + 2] + 2 * temp_current[i + 1] - - 2 * temp_current[i]) - 0.6 * h - * (-temp_current[i - 2] + 2 * temp_current[i - 1]) - + 0.1 * h - * (-temp_current[i + 1] + 2 - * temp_current[i + 2] - - temp_current[i + 3]) + 0.1 * h - * (-temp_current[i - 1] + 2 * temp_current[i - 2] - - temp_current[i - 3]); + result[_seq] = + h * (2 * temp_current[i] - temp_current[i + 1] - temp_current[i - 1]) - + 0.6 * h * (-temp_current[i + 2] + 2 * temp_current[i + 1] - 2 * temp_current[i]) - + 0.6 * h * (-temp_current[i - 2] + 2 * temp_current[i - 1]) + + 0.1 * h * (-temp_current[i + 1] + 2 * temp_current[i + 2] - temp_current[i + 3]) + + 0.1 * h * (-temp_current[i - 1] + 2 * temp_current[i - 2] - temp_current[i - 3]); } i = (1 << l) - 4; @@ -108,39 +95,34 @@ void LaplaceUpGradientPrewavelet::operator()(SGPP::base::DataVector& source, _seq = index.seq(); if (!storage->end(_seq)) - result[_seq] = h * (2 * temp_current[i] - temp_current[i + 1] - - temp_current[i - 1]) + -0.6 * h * (-temp_current[i - + 2] + 2 * temp_current[i + 1] - 2 * temp_current[i]) - - 0.6 * h * (-temp_current[i - 2] + 2 * temp_current[i - - 1]) + 0.1 * h * (-temp_current[i + 1] + 2 - * temp_current[i + 2]) + 0.1 * h - * (-temp_current[i - 1] + 2 * temp_current[i - 2] - - temp_current[i - 3]); + result[_seq] = + h * (2 * temp_current[i] - temp_current[i + 1] - temp_current[i - 1]) + + -0.6 * h * (-temp_current[i + 2] + 2 * temp_current[i + 1] - 2 * temp_current[i]) - + 0.6 * h * (-temp_current[i - 2] + 2 * temp_current[i - 1]) + + 0.1 * h * (-temp_current[i + 1] + 2 * temp_current[i + 2]) + + 0.1 * h * (-temp_current[i - 1] + 2 * temp_current[i - 2] - temp_current[i - 3]); i = (1 << l) - 2; index.set(dim, l, i + 1); _seq = index.seq(); if (!storage->end(_seq)) - result[_seq] = 0.9 * h * (2 * temp_current[i] - temp_current[i - - 1]) - 0.6 * h * (-temp_current[i - 2] + 2 - * temp_current[i - 1] - temp_current[i]) + 0.1 * h - * (-temp_current[i - 1] + 2 * temp_current[i - 2] - - temp_current[i - 3]); + result[_seq] = + 0.9 * h * (2 * temp_current[i] - temp_current[i - 1]) - + 0.6 * h * (-temp_current[i - 2] + 2 * temp_current[i - 1] - temp_current[i]) + + 0.1 * h * (-temp_current[i - 1] + 2 * temp_current[i - 2] - temp_current[i - 3]); index.set(dim, l, 1); _seqr = index.seq(); _valr = storage->end(_seqr) ? 0.0 : source[_seqr]; - for (i = 0; i < (unsigned int) (1 << (l - 1)) - 1; i++) { - + for (i = 0; i < (unsigned int)(1 << (l - 1)) - 1; i++) { _seql = _seqr; _vall = _valr; index.set(dim, l, 2 * i + 3); _seqr = index.seq(); _valr = storage->end(_seqr) ? 0.0 : source[_seqr]; - temp_current[i] = -0.6 * (_vall + _valr) + temp_current[2 * i - + 1]; + temp_current[i] = -0.6 * (_vall + _valr) + temp_current[2 * i + 1]; } } @@ -151,10 +133,9 @@ void LaplaceUpGradientPrewavelet::operator()(SGPP::base::DataVector& source, _seql = index.seq(); if (!storage->end(_seql)) { - result[_seql] = 0.9 * h * (2 * temp_current[0] - - temp_current[1]) - 0.6 * h * (-temp_current[2] + 2 - * temp_current[1] - temp_current[0]) + 0.1 * h - * (-temp_current[1] + 2 * temp_current[2]); + result[_seql] = 0.9 * h * (2 * temp_current[0] - temp_current[1]) - + 0.6 * h * (-temp_current[2] + 2 * temp_current[1] - temp_current[0]) + + 0.1 * h * (-temp_current[1] + 2 * temp_current[2]); _vall = source[_seql]; } else { _vall = 0.0; @@ -164,16 +145,15 @@ void LaplaceUpGradientPrewavelet::operator()(SGPP::base::DataVector& source, _seqr = index.seq(); if (!storage->end(_seqr)) { - result[_seqr] = 0.9 * h * (2 * temp_current[2] - - temp_current[1]) - 0.6 * h * (-temp_current[0] + 2 - * temp_current[1] - temp_current[2]) + 0.1 * h - * (-temp_current[1] + 2 * temp_current[0]); + result[_seqr] = 0.9 * h * (2 * temp_current[2] - temp_current[1]) - + 0.6 * h * (-temp_current[0] + 2 * temp_current[1] - temp_current[2]) + + 0.1 * h * (-temp_current[1] + 2 * temp_current[0]); _valr = source[_seqr]; - } else + } else { _valr = 0.0; + } - temp_current[0] = -0.6 * (_vall + _valr) - + temp_current[1]; + temp_current[0] = -0.6 * (_vall + _valr) + temp_current[1]; l = 1; } @@ -185,10 +165,9 @@ void LaplaceUpGradientPrewavelet::operator()(SGPP::base::DataVector& source, result[_seq] = 2 * h * temp_current[0]; } - //I dont think thats necessary, but just to be sure! + // I dont think thats necessary, but just to be sure! index.set(dim, l_old, i_old); delete[] temp_current; - -} -} } +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpGradientPrewavelet.hpp b/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpGradientPrewavelet.hpp old mode 100755 new mode 100644 index 88d81e78da..310fbe53f9 --- a/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpGradientPrewavelet.hpp +++ b/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpGradientPrewavelet.hpp @@ -11,14 +11,12 @@ #include - namespace SGPP { namespace pde { - - /** - * Implements the upGradient Method needed for the Laplace operator on prewavelet grids. The calculation + * Implements the upGradient Method needed for the Laplace operator on prewavelet grids. The + * calculation * is done iterative and utilizes the following temp variables: * \f[ * t_{k,j}=-\frac{6}{10}u_{k,j\pm1}+t_{k+1,2j}\qquad(k,j)\notin G_{n}^{1} @@ -31,9 +29,11 @@ namespace pde { * \f{eqnarray*}{ * r_{k,j}&=&\frac{9}{10}\frac{1}{h_{k}}\left(2t_{k+1,2j}-t_{k+1,2(j\pm1)}\right)\\&&-\frac{6}{10}\frac{1}{h_{k}}\left(-t_{k+1,2(j\pm2)}+2t_{k+1,2(j\pm1)}-t_{k+1,2j}\right)\\&&+\frac{1}{10}\frac{1}{h_{k}}\left(-t_{k+1,2(j\pm1)}+2t_{k+1,2(j\pm2)}-t_{k+1,2(j\pm2)}\right) * \f} - * Please note, that all values of gridpoints outside of the sparse grid are treated as 0. The following + * Please note, that all values of gridpoints outside of the sparse grid are treated as 0. The + * following * picture depicts all involved grid points and temp values in order to calculate a specific point: - * \image html prewavelets_up.png "All involved gridpoint for the up algorithm (red) and temp points between grid points (green). The gray line indicates the support of the prewavelet." + * \image html prewavelets_up.png "All involved gridpoint for the up algorithm (red) and temp points + * between grid points (green). The gray line indicates the support of the prewavelet." */ class LaplaceUpGradientPrewavelet { protected: @@ -47,7 +47,7 @@ class LaplaceUpGradientPrewavelet { * * @param storage the grid's SGPP::base::GridStorage object */ - LaplaceUpGradientPrewavelet(SGPP::base::GridStorage* storage); + explicit LaplaceUpGradientPrewavelet(SGPP::base::GridStorage* storage); /** * Destructor @@ -57,7 +57,8 @@ class LaplaceUpGradientPrewavelet { /** * This operations performs the calculation of upGradient in the direction of dimension dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the down operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -65,8 +66,7 @@ class LaplaceUpGradientPrewavelet { void operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* LAPLACEUPGRADIENTMODLINEAR_HPP */ \ No newline at end of file +#endif /* LAPLACEUPGRADIENTMODLINEAR_HPP */ diff --git a/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpPrewavelet.cpp b/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpPrewavelet.cpp old mode 100755 new mode 100644 index 1ff56ff0a9..c74a3eb0c2 --- a/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpPrewavelet.cpp +++ b/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpPrewavelet.cpp @@ -5,24 +5,16 @@ #include - #include - namespace SGPP { namespace pde { -LaplaceUpPrewavelet::LaplaceUpPrewavelet(SGPP::base::GridStorage* storage) : - storage(storage) { -} +LaplaceUpPrewavelet::LaplaceUpPrewavelet(SGPP::base::GridStorage* storage) : storage(storage) {} +LaplaceUpPrewavelet::~LaplaceUpPrewavelet() {} -LaplaceUpPrewavelet::~LaplaceUpPrewavelet() { -} - -void LaplaceUpPrewavelet::operator()(SGPP::base::DataVector& source, - SGPP::base::DataVector& result, +void LaplaceUpPrewavelet::operator()(SGPP::base::DataVector& source, SGPP::base::DataVector& result, grid_iterator& index, size_t dim) { - size_t seq = index.seq(); SGPP::base::GridStorage::index_type::level_type l; SGPP::base::GridStorage::index_type::index_type i; @@ -36,12 +28,12 @@ void LaplaceUpPrewavelet::operator()(SGPP::base::DataVector& source, float_t _val, _vall1, _vall2, _valr1, _valr2; float_t h; bool hasChilds = false; - //GridStorage::index_type::level_type max_level = getGridDepth(index, dim); + // GridStorage::index_type::level_type max_level = getGridDepth(index, dim); index.get(dim, l, i); index.get(dim, l_old, i_old); - //Level 1 + // Level 1 result[seq] = 1.0 / 3.0 * source[seq]; @@ -49,36 +41,31 @@ void LaplaceUpPrewavelet::operator()(SGPP::base::DataVector& source, return; } - //Level 2 + // Level 2 l = 2; h = static_cast(1 << l); index.set(dim, 2, 1); - if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) - hasChilds = true; + if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) hasChilds = true; _seql1 = index.seq(); _vall1 = storage->end(_seql1) ? 0.0 : source[_seql1]; index.set(dim, 2, 3); - if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) - hasChilds = true; + if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) hasChilds = true; _seqr1 = index.seq(); _valr1 = storage->end(_seqr1) ? 0.0 : source[_seqr1]; - if (!storage->end(_seql1)) - result[_seql1] = 11.0 / 75.0 * _vall1 + 1.0 / 25.0 * _valr1; + if (!storage->end(_seql1)) result[_seql1] = 11.0 / 75.0 * _vall1 + 1.0 / 25.0 * _valr1; - if (!storage->end(_seqr1)) - result[_seqr1] = 11.0 / 75.0 * _valr1 + 1.0 / 25.0 * _vall1; + if (!storage->end(_seqr1)) result[_seqr1] = 11.0 / 75.0 * _valr1 + 1.0 / 25.0 * _vall1; // // result[_seql1] = 11.0 / 75.0 * source[_seql1]; // result[_seqr1] = 11.0 / 75.0 * source[_seqr1]; - if (!hasChilds) { index.set(dim, l_old, i_old); return; @@ -89,36 +76,33 @@ void LaplaceUpPrewavelet::operator()(SGPP::base::DataVector& source, hasChilds = false; h = 1.0 / (1 << l); - last_index = (1 << (l - 1)) - 1; //Number of Points in this level + last_index = (1 << (l - 1)) - 1; // Number of Points in this level index.set(dim, l, 1); - if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) - hasChilds = true; + if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) hasChilds = true; _seq = index.seq(); _val = storage->end(_seq) ? 0.0 : source[_seq]; index.set(dim, l, 3); - if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) - hasChilds = true; + if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) hasChilds = true; _seqr1 = index.seq(); _valr1 = storage->end(_seqr1) ? 0.0 : source[_seqr1]; index.set(dim, l, 5); - if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) - hasChilds = true; + if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) hasChilds = true; _seqr2 = index.seq(); _valr2 = storage->end(_seqr2) ? 0.0 : source[_seqr2]; if (!storage->end(_seq)) - result[_seq] = 44.0 / 75.0 * h * _val // - + 11.0 / 75.0 * h * _valr1// - - 1.0 / 75.0 * h * _valr2;// + result[_seq] = 44.0 / 75.0 * h * _val // + + 11.0 / 75.0 * h * _valr1 // + - 1.0 / 75.0 * h * _valr2; // _seql1 = _seq; _seq = _seqr1; @@ -128,19 +112,18 @@ void LaplaceUpPrewavelet::operator()(SGPP::base::DataVector& source, _valr1 = _valr2; index.set(dim, l, 7); - if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) - hasChilds = true; + if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) hasChilds = true; _seqr2 = index.seq(); _valr2 = storage->end(_seqr2) ? 0.0 : source[_seqr2]; if (!storage->end(_seq)) - result[_seq] = 11.0 / 75.0 * h * _vall1 // - + 18.0 / 25.0 * h * _val // - + 2.0 / 15.0 * h * _valr1// - - 1.0 / 75.0 * h * _valr2;// + result[_seq] = 11.0 / 75.0 * h * _vall1 // + + 18.0 / 25.0 * h * _val // + + 2.0 / 15.0 * h * _valr1 // + - 1.0 / 75.0 * h * _valr2; // - //Main loop-------------------------------------- + // Main loop-------------------------------------- for (i = 2; i < last_index - 1; i++) { _seql1 = _seq; @@ -152,23 +135,20 @@ void LaplaceUpPrewavelet::operator()(SGPP::base::DataVector& source, _valr1 = _valr2; index.set(dim, l, i * 2 + 5); - if (!hasChilds && (index.hintLeft(dim) - || index.hintRight(dim))) - hasChilds = true; + if (!hasChilds && (index.hintLeft(dim) || index.hintRight(dim))) hasChilds = true; _seqr2 = index.seq(); _valr2 = storage->end(_seqr2) ? 0.0 : source[_seqr2]; if (!storage->end(_seq)) - result[_seq] = -1.0 / 75.0 * h * _vall2 // - + 2.0 / 15.0 * h * _vall1 // - + 18.0 / 25.0 * h * _val // - + 2.0 / 15.0 * h * _valr1// - - 1.0 / 75.0 * h * _valr2;// - + result[_seq] = -1.0 / 75.0 * h * _vall2 // + + 2.0 / 15.0 * h * _vall1 // + + 18.0 / 25.0 * h * _val // + + 2.0 / 15.0 * h * _valr1 // + - 1.0 / 75.0 * h * _valr2; // } - //Main loop-------------------------------------- + // Main loop-------------------------------------- _seql1 = _seq; _seq = _seqr1; @@ -179,10 +159,10 @@ void LaplaceUpPrewavelet::operator()(SGPP::base::DataVector& source, _valr1 = _valr2; if (!storage->end(_seq)) - result[_seq] = 11.0 / 75.0 * h * _valr1 // - + 18.0 / 25.0 * h * _val // - + 2.0 / 15.0 * h * _vall1// - - 1.0 / 75.0 * h * _vall2;// + result[_seq] = 11.0 / 75.0 * h * _valr1 // + + 18.0 / 25.0 * h * _val // + + 2.0 / 15.0 * h * _vall1 // + - 1.0 / 75.0 * h * _vall2; // _seql1 = _seq; _seq = _seqr1; @@ -191,18 +171,15 @@ void LaplaceUpPrewavelet::operator()(SGPP::base::DataVector& source, _val = _valr1; if (!storage->end(_seq)) - result[_seq] = 44.0 / 75.0 * h * _val // - + 11.0 / 75.0 * h * _vall1// - - 1.0 / 75.0 * h * _vall2;// + result[_seq] = 44.0 / 75.0 * h * _val // + + 11.0 / 75.0 * h * _vall1 // + - 1.0 / 75.0 * h * _vall2; // if (!hasChilds) { index.set(dim, l_old, i_old); return; } - } - -} - -} } +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpPrewavelet.hpp b/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpPrewavelet.hpp old mode 100755 new mode 100644 index 6ded19d682..28063e8401 --- a/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpPrewavelet.hpp +++ b/pde/src/sgpp/pde/basis/prewavelet/algorithm_sweep/LaplaceUpPrewavelet.hpp @@ -11,12 +11,9 @@ #include - namespace SGPP { namespace pde { - - /** * Implements the down Method needed for the Laplace operator on prewavelet grids. * Here, the prewavlets have an advantage over the normal linear base due to the semi @@ -25,7 +22,8 @@ namespace pde { * \f{eqnarray*}{ * m_{(1,1)(1,1)}&=&\frac{1}{3}\\m_{(2,1)(2,3)}&=&\frac{1}{25}\\m_{(l,1)(l,1)}&=&m_{(l,2^{l}-1)(l,2^{l}-1)}=\frac{44}{75}h_{l}\\m_{(l,1)(l,3)}&=&m_{(l,2^{l}-1)(l,2^{l}-3)}=\frac{11}{75}h_{l}\\m_{(l,i)(l,i)}&=&\frac{18}{25}h_{l}\\m_{(l,i)(l,i\pm2)}&=&\frac{2}{15}h_{l}\\m_{(l,i)(l,i\pm4)}&=&-\frac{11}{75}h_{l} * \f} - * With that, the calculation of the entire matrix is completed, thus no additional up-part is needed. + * With that, the calculation of the entire matrix is completed, thus no additional up-part is + * needed. */ class LaplaceUpPrewavelet { protected: @@ -39,7 +37,7 @@ class LaplaceUpPrewavelet { * * @param storage the grid's SGPP::base::GridStorage object */ - LaplaceUpPrewavelet(SGPP::base::GridStorage* storage); + explicit LaplaceUpPrewavelet(SGPP::base::GridStorage* storage); /** * Destructor @@ -49,7 +47,8 @@ class LaplaceUpPrewavelet { /** * This operations performs the calculation of down in the direction of dimension dim * - * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from the vector of the laplace operation) + * @param source SGPP::base::DataVector that contains the gridpoint's coefficients (values from + * the vector of the laplace operation) * @param result SGPP::base::DataVector that contains the result of the up operation * @param index a iterator object of the grid * @param dim current fixed dimension of the 'execution direction' @@ -58,12 +57,8 @@ class LaplaceUpPrewavelet { grid_iterator& index, size_t dim); protected: - }; +} // namespace pde +} // namespace SGPP - - -} -} - -#endif /* LAPLACEUPPREWAVELET_HPP */ \ No newline at end of file +#endif /* LAPLACEUPPREWAVELET_HPP */ diff --git a/pde/src/sgpp/pde/operation/PdeOpFactory.cpp b/pde/src/sgpp/pde/operation/PdeOpFactory.cpp index 853555b89a..719ba2ccf8 100644 --- a/pde/src/sgpp/pde/operation/PdeOpFactory.cpp +++ b/pde/src/sgpp/pde/operation/PdeOpFactory.cpp @@ -5,8 +5,6 @@ #include -#include - #include #include @@ -32,61 +30,59 @@ #include +#include namespace SGPP { namespace op_factory { base::OperationMatrix* createOperationLaplace(base::Grid& grid) { - if (grid.getType() == base::GridType::Linear) { return new pde::OperationLaplaceLinear(grid.getStorage()); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new pde::OperationLaplaceLinearBoundary(grid.getStorage()); - } else if (grid.getType() == base::GridType::ModLinear ) { + } else if (grid.getType() == base::GridType::ModLinear) { return new pde::OperationLaplaceModLinear(grid.getStorage()); - } else if (grid.getType() == base::GridType::Prewavelet ) { + } else if (grid.getType() == base::GridType::Prewavelet) { return new pde::OperationLaplacePrewavelet(grid.getStorage(), - ((base::PrewaveletGrid*) &grid)->getShadowStorage()); - } else if (grid.getType() == base::GridType::LinearStretched ) { + ((base::PrewaveletGrid*)&grid)->getShadowStorage()); + } else if (grid.getType() == base::GridType::LinearStretched) { return new pde::OperationLaplaceLinearStretched(grid.getStorage()); - } else if (grid.getType() == base::GridType::LinearStretchedBoundary ) { + } else if (grid.getType() == base::GridType::LinearStretchedBoundary) { return new pde::OperationLaplaceLinearStretchedBoundary(grid.getStorage()); } else { throw base::factory_exception("OperationLaplace is not implemented for this grid type."); } } -base::OperationMatrix* createOperationLaplace(base::Grid& grid, - SGPP::base::DataVector& coef) { - +base::OperationMatrix* createOperationLaplace(base::Grid& grid, SGPP::base::DataVector& coef) { if (grid.getType() == base::GridType::Linear) { return new pde::OperationLaplaceLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new pde::OperationLaplaceLinearBoundary(grid.getStorage(), coef); } else { - throw base::factory_exception("OperationLaplace (with coefficients) is not implemented for this grid type."); + throw base::factory_exception( + "OperationLaplace (with coefficients) is not implemented for this grid type."); } } base::OperationMatrix* createOperationLTwoDotProduct(base::Grid& grid) { - if (grid.getType() == base::GridType::Linear) { return new pde::OperationLTwoDotProductLinear(grid.getStorage()); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new pde::OperationLTwoDotProductLinearBoundary(grid.getStorage()); } else if (grid.getType() == base::GridType::LinearStretched) { return new pde::OperationLTwoDotProductLinearStretched(grid.getStorage()); } else if (grid.getType() == base::GridType::LinearStretchedBoundary) { - return new pde::OperationLTwoDotProductLinearStretchedBoundary( - grid.getStorage()); + return new pde::OperationLTwoDotProductLinearStretchedBoundary(grid.getStorage()); } else if (grid.getType() == base::GridType::Periodic) { return new pde::OperationMatrixLTwoDotPeriodic(grid.getStorage()); - } else + } else { throw base::factory_exception("OperationLTwoDotProduct is not implemented for this grid type."); + } } base::OperationMatrix* createOperationLTwoDotExplicit(base::Grid& grid) { @@ -96,46 +92,48 @@ base::OperationMatrix* createOperationLTwoDotExplicit(base::Grid& grid) { return new pde::OperationMatrixLTwoDotExplicitLinearBoundary(&grid); } else if (grid.getType() == base::GridType::Periodic) { return new pde::OperationMatrixLTwoDotExplicitPeriodic(&grid); - } else - throw base::factory_exception("OperationLTwoDotExplicit is not implemented for this grid type."); + } else { + throw base::factory_exception( + "OperationLTwoDotExplicit is not implemented for this grid type."); + } } -base::OperationMatrix* createOperationLTwoDotExplicit(base::DataMatrix* m, - base::Grid& grid) { +base::OperationMatrix* createOperationLTwoDotExplicit(base::DataMatrix* m, base::Grid& grid) { if (grid.getType() == base::GridType::Linear) { return new pde::OperationMatrixLTwoDotExplicitLinear(m, &grid); } else if (grid.getType() == base::GridType::LinearL0Boundary) { return new pde::OperationMatrixLTwoDotExplicitLinearBoundary(m, &grid); } else if (grid.getType() == base::GridType::Periodic) { return new pde::OperationMatrixLTwoDotExplicitPeriodic(m, &grid); - } else - throw base::factory_exception("OperationLTwoDotExplicit is not implemented for this grid type."); + } else { + throw base::factory_exception( + "OperationLTwoDotExplicit is not implemented for this grid type."); + } } base::OperationMatrix* createOperationLaplaceEnhanced(base::Grid& grid) { - if (grid.getType() == base::GridType::Linear) { return new pde::OperationLaplaceEnhancedLinear(grid.getStorage()); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new pde::OperationLaplaceEnhancedLinearBoundary(grid.getStorage()); } else { - throw base::factory_exception("OperationLaplaceEnhanced is not implemented for this grid type."); + throw base::factory_exception( + "OperationLaplaceEnhanced is not implemented for this grid type."); } } base::OperationMatrix* createOperationLaplaceEnhanced(base::Grid& grid, - SGPP::base::DataVector& coef) { - + SGPP::base::DataVector& coef) { if (grid.getType() == base::GridType::Linear) { return new pde::OperationLaplaceEnhancedLinear(grid.getStorage(), coef); - } else if (grid.getType() == base::GridType::LinearL0Boundary - || grid.getType() == base::GridType::LinearBoundary) { + } else if (grid.getType() == base::GridType::LinearL0Boundary || + grid.getType() == base::GridType::LinearBoundary) { return new pde::OperationLaplaceEnhancedLinearBoundary(grid.getStorage(), coef); } else { - throw base::factory_exception("OperationLaplaceEnhanced is not implemented for this grid type."); + throw base::factory_exception( + "OperationLaplaceEnhanced is not implemented for this grid type."); } } - -} -} +} // namespace op_factory +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/PdeOpFactory.hpp b/pde/src/sgpp/pde/operation/PdeOpFactory.hpp index 03594bbe7c..296aad06af 100644 --- a/pde/src/sgpp/pde/operation/PdeOpFactory.hpp +++ b/pde/src/sgpp/pde/operation/PdeOpFactory.hpp @@ -16,7 +16,6 @@ #include - namespace SGPP { namespace op_factory { @@ -36,8 +35,7 @@ base::OperationMatrix* createOperationLaplace(base::Grid& grid); * @param coef Coefficient vector for OperationLaplace * @return Pointer to the new OperationMatrix object for the Grid grid */ -base::OperationMatrix* createOperationLaplace(base::Grid& grid, - SGPP::base::DataVector& coef); +base::OperationMatrix* createOperationLaplace(base::Grid& grid, SGPP::base::DataVector& coef); /** * Factory method, returning an OperationLTwoDotProduct (OperationMatrix) for the grid at hand. * Note: object has to be freed after use. @@ -65,8 +63,7 @@ base::OperationMatrix* createOperationLTwoDotExplicit(base::Grid& grid); * @param m DataMatrix in which the data is stored * @return Pointer to the new OperationMatrix object for the Grid grid */ -base::OperationMatrix* createOperationLTwoDotExplicit(base::DataMatrix* m, - base::Grid& grid); +base::OperationMatrix* createOperationLTwoDotExplicit(base::DataMatrix* m, base::Grid& grid); /** * Factory method, returning an OperationLaplace (OperationMatrix) for the grid at hand. @@ -90,10 +87,8 @@ base::OperationMatrix* createOperationLaplaceEnhanced(base::Grid& grid); * @return Pointer to the new OperationMatrix object for the Grid grid */ base::OperationMatrix* createOperationLaplaceEnhanced(base::Grid& grid, - SGPP::base::DataVector& coef); - -} - -} + SGPP::base::DataVector& coef); +} // namespace op_factory +} // namespace SGPP #endif /*PDE_OP_FACTORY_HPP*/ diff --git a/pde/src/sgpp/pde/operation/hash/DowndPhidPhiBBIterativeLinearBoundary.cpp b/pde/src/sgpp/pde/operation/hash/DowndPhidPhiBBIterativeLinearBoundary.cpp index c08b11e794..3c3bab496c 100644 --- a/pde/src/sgpp/pde/operation/hash/DowndPhidPhiBBIterativeLinearBoundary.cpp +++ b/pde/src/sgpp/pde/operation/hash/DowndPhidPhiBBIterativeLinearBoundary.cpp @@ -8,19 +8,17 @@ #include - namespace SGPP { namespace pde { DowndPhidPhiBBIterativeLinearBoundary::DowndPhidPhiBBIterativeLinearBoundary( - SGPP::base::GridStorage* storage) : storage(storage) { -} + SGPP::base::GridStorage* storage) + : storage(storage) {} -DowndPhidPhiBBIterativeLinearBoundary::~DowndPhidPhiBBIterativeLinearBoundary() { -} +DowndPhidPhiBBIterativeLinearBoundary::~DowndPhidPhiBBIterativeLinearBoundary() {} -void DowndPhidPhiBBIterativeLinearBoundary::operator()(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void DowndPhidPhiBBIterativeLinearBoundary::operator()(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // Bounding Box handling SGPP::base::BoundingBox* boundingBox = this->storage->getBoundingBox(); float_t q = boundingBox->getIntervalWidth(dim); @@ -39,7 +37,7 @@ void DowndPhidPhiBBIterativeLinearBoundary::operator()(SGPP::base::DataVector& if (level == 0) { if (index == 0) { if (!boundingBox->hasDirichletBoundaryLeft(dim)) { - //only affects the diagonal of the stiffness matrix + // only affects the diagonal of the stiffness matrix result[i] += Qqout * alpha[i]; // down @@ -56,13 +54,12 @@ void DowndPhidPhiBBIterativeLinearBoundary::operator()(SGPP::base::DataVector& if (index == 1) { if (!boundingBox->hasDirichletBoundaryRight(dim)) { - //only affects the diagonal of the stiffness matrix + // only affects the diagonal of the stiffness matrix result[i] += Qqout * alpha[i]; } } - } - //only affects the diagonal of the stiffness matrix - else { + } else { + // only affects the diagonal of the stiffness matrix result[i] = alpha[i] * (Qqout * static_cast(1 << (level + 1))); } } @@ -76,7 +73,7 @@ void DowndPhidPhiBBIterativeLinearBoundary::operator()(SGPP::base::DataVector& if (level == 0) { if (index == 0) { if (!boundingBox->hasDirichletBoundaryLeft(dim)) { - //only affects the diagonal of the stiffness matrix + // only affects the diagonal of the stiffness matrix result[i] += alpha[i]; // down @@ -93,18 +90,16 @@ void DowndPhidPhiBBIterativeLinearBoundary::operator()(SGPP::base::DataVector& if (index == 1) { if (!boundingBox->hasDirichletBoundaryRight(dim)) { - //only affects the diagonal of the stiffness matrix + // only affects the diagonal of the stiffness matrix result[i] += alpha[i]; } } - } - //only affects the diagonal of the stiffness matrix - else { + } else { + // only affects the diagonal of the stiffness matrix result[i] = alpha[i] * static_cast(1 << (level + 1)); } } } } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/DowndPhidPhiBBIterativeLinearBoundary.hpp b/pde/src/sgpp/pde/operation/hash/DowndPhidPhiBBIterativeLinearBoundary.hpp index 22ff430a61..4c72958611 100644 --- a/pde/src/sgpp/pde/operation/hash/DowndPhidPhiBBIterativeLinearBoundary.hpp +++ b/pde/src/sgpp/pde/operation/hash/DowndPhidPhiBBIterativeLinearBoundary.hpp @@ -11,7 +11,6 @@ #include - namespace SGPP { namespace pde { @@ -38,26 +37,26 @@ class DowndPhidPhiBBIterativeLinearBoundary { * * @param storage Pointer to the grid's storage object */ - DowndPhidPhiBBIterativeLinearBoundary(SGPP::base::GridStorage* storage); + explicit DowndPhidPhiBBIterativeLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor */ - ~DowndPhidPhiBBIterativeLinearBoundary(); + virtual ~DowndPhidPhiBBIterativeLinearBoundary(); /** * This operations performs the calculation of Down in the direction of dimension dim - * of following bilinearform: \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ + * of following bilinearform: \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} + * dx\f$ * * @param alpha SGPP::base::DataVector that contains the gridpoint's coefficients * @param result SGPP::base::DataVector that contains the result of the down operation * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void operator()(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* DOWNDPHIDPHIDOWNBBITERATIVELINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* DOWNDPHIDPHIDOWNBBITERATIVELINEARBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystem.cpp b/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystem.cpp old mode 100755 new mode 100644 index 90fa9e8d88..a2f96c5fac --- a/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystem.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystem.cpp @@ -8,18 +8,14 @@ #include - namespace SGPP { namespace pde { -OperationEllipticPDESolverSystem::OperationEllipticPDESolverSystem( - SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& rhs) : BoundGrid(&SparseGrid), rhs(&rhs), - numGridpointsComplete(SparseGrid.getSize()) { -} +OperationEllipticPDESolverSystem::OperationEllipticPDESolverSystem(SGPP::base::Grid& SparseGrid, + SGPP::base::DataVector& rhs) + : BoundGrid(&SparseGrid), rhs(&rhs), numGridpointsComplete(SparseGrid.getSize()) {} -OperationEllipticPDESolverSystem::~OperationEllipticPDESolverSystem() { -} +OperationEllipticPDESolverSystem::~OperationEllipticPDESolverSystem() {} size_t OperationEllipticPDESolverSystem::getNumGridPointsComplete() { return this->numGridpointsComplete; @@ -28,6 +24,5 @@ size_t OperationEllipticPDESolverSystem::getNumGridPointsComplete() { size_t OperationEllipticPDESolverSystem::getNumGridPointsInner() { return this->numGridpointsInner; } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystem.hpp b/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystem.hpp old mode 100755 new mode 100644 index 43fcbe8a3b..923f692556 --- a/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystem.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystem.hpp @@ -12,7 +12,6 @@ #include - namespace SGPP { namespace pde { @@ -44,8 +43,7 @@ class OperationEllipticPDESolverSystem : public SGPP::base::OperationMatrix { * @param SparseGrid the grid, for which the system should be solved * @param rhs the right hand side of the corresponding system */ - OperationEllipticPDESolverSystem(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& rhs); + OperationEllipticPDESolverSystem(SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& rhs); /** * Destructor @@ -56,10 +54,10 @@ class OperationEllipticPDESolverSystem : public SGPP::base::OperationMatrix { * Multiplicates a vector with the matrix \f$ L \f$ * * @param alpha SGPP::base::DataVector that contains the ansatzfunctions' coefficients - * @param result SGPP::base::DataVector into which the result of the space discretization operation is stored + * @param result SGPP::base::DataVector into which the result of the space discretization + * operation is stored */ - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) = 0; + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) = 0; /** * generates the right hand side of the system @@ -82,8 +80,7 @@ class OperationEllipticPDESolverSystem : public SGPP::base::OperationMatrix { */ size_t getNumGridPointsInner(); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* OPERATIONELLITPICPDESOLVERMATRIX_HPP */ \ No newline at end of file +#endif /* OPERATIONELLITPICPDESOLVERMATRIX_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemDirichlet.cpp b/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemDirichlet.cpp old mode 100755 new mode 100644 index 1ebee7c09e..ebca5dafcc --- a/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemDirichlet.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemDirichlet.cpp @@ -6,24 +6,21 @@ #include #include -#include - #include +#include namespace SGPP { namespace pde { OperationEllipticPDESolverSystemDirichlet::OperationEllipticPDESolverSystemDirichlet( - SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& rhs) : OperationEllipticPDESolverSystem(SparseGrid, - rhs) { - this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector( - SparseGrid.getStorage()); + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& rhs) + : OperationEllipticPDESolverSystem(SparseGrid, rhs) { + this->BoundaryUpdate = new SGPP::base::DirichletUpdateVector(SparseGrid.getStorage()); this->GridConverter = new SGPP::base::DirichletGridConverter(); - this->GridConverter->buildInnerGridWithCoefs(*this->BoundGrid, *this->rhs, - &(this->InnerGrid), &(this->rhs_inner)); + this->GridConverter->buildInnerGridWithCoefs(*this->BoundGrid, *this->rhs, &(this->InnerGrid), + &(this->rhs_inner)); this->numGridpointsInner = this->InnerGrid->getSize(); @@ -38,13 +35,12 @@ OperationEllipticPDESolverSystemDirichlet::~OperationEllipticPDESolverSystemDiri delete this->GridConverter; } -void OperationEllipticPDESolverSystemDirichlet::mult(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result) { +void OperationEllipticPDESolverSystemDirichlet::mult(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { applyLOperatorInner(alpha, result); } -SGPP::base::DataVector* -OperationEllipticPDESolverSystemDirichlet::generateRHS() { +SGPP::base::DataVector* OperationEllipticPDESolverSystemDirichlet::generateRHS() { if (this->InnerGrid != NULL) { SGPP::base::DataVector alpha_tmp_complete(*(this->rhs)); SGPP::base::DataVector rhs_tmp_complete(*(this->rhs)); @@ -55,14 +51,14 @@ OperationEllipticPDESolverSystemDirichlet::generateRHS() { this->GridConverter->calcInnerCoefs(rhs_tmp_complete, *(this->rhs_inner)); this->rhs_inner->mult(-1.0); } else { - throw new SGPP::base::algorithm_exception("OperationEllipticPDESolverSystemDirichlet::generateRHS : No inner grid exists!"); + throw new SGPP::base::algorithm_exception( + "OperationEllipticPDESolverSystemDirichlet::generateRHS : No inner grid exists!"); } return this->rhs_inner; } -SGPP::base::DataVector* -OperationEllipticPDESolverSystemDirichlet::getGridCoefficientsForCG() { +SGPP::base::DataVector* OperationEllipticPDESolverSystemDirichlet::getGridCoefficientsForCG() { if (this->InnerGrid != NULL) { if (this->alpha_inner != NULL) { delete this->alpha_inner; @@ -71,16 +67,18 @@ OperationEllipticPDESolverSystemDirichlet::getGridCoefficientsForCG() { this->alpha_inner = new SGPP::base::DataVector(this->InnerGrid->getSize()); this->alpha_inner->setAll(0.0); } else { - throw new SGPP::base::algorithm_exception("OperationEllipticPDESolverSystemDirichlet::getGridCoefficientsForCG : No inner grid exists!"); + throw new SGPP::base::algorithm_exception( + "OperationEllipticPDESolverSystemDirichlet::getGridCoefficientsForCG : No inner grid " + "exists!"); } return this->alpha_inner; } void OperationEllipticPDESolverSystemDirichlet::getSolutionBoundGrid( - SGPP::base::DataVector& Solution, SGPP::base::DataVector& SolutionInner) { + SGPP::base::DataVector& Solution, SGPP::base::DataVector& SolutionInner) { Solution = *(this->rhs); this->GridConverter->updateBoundaryCoefs(Solution, SolutionInner); } -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemDirichlet.hpp b/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemDirichlet.hpp old mode 100755 new mode 100644 index baf1493826..9554ab2aed --- a/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemDirichlet.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemDirichlet.hpp @@ -10,10 +10,9 @@ #include #include -#include - #include +#include namespace SGPP { namespace pde { @@ -35,8 +34,7 @@ namespace pde { * * The inner grid is constructed during the constructor call! */ -class OperationEllipticPDESolverSystemDirichlet : public - OperationEllipticPDESolverSystem { +class OperationEllipticPDESolverSystemDirichlet : public OperationEllipticPDESolverSystem { protected: /// Pointer to the alphas (ansatzfunctions' coefficients; inner points only) SGPP::base::DataVector* alpha_inner; @@ -75,15 +73,14 @@ class OperationEllipticPDESolverSystemDirichlet : public * @param rhs the right hand side of the corresponding system */ OperationEllipticPDESolverSystemDirichlet(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& rhs); + SGPP::base::DataVector& rhs); /** * Destructor */ virtual ~OperationEllipticPDESolverSystemDirichlet(); - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual SGPP::base::DataVector* generateRHS(); @@ -99,13 +96,14 @@ class OperationEllipticPDESolverSystemDirichlet : public /** * Gets the solution for the complete grid * - * @param Solution SGPP::base::DataVector that must have a dimension equal to the bound's grid dimension, the result is written to Solution + * @param Solution SGPP::base::DataVector that must have a dimension equal to the bound's grid + * dimension, the result is written to Solution * @param SolutionInner Solution on the inner grid */ virtual void getSolutionBoundGrid(SGPP::base::DataVector& Solution, SGPP::base::DataVector& SolutionInner); }; -} -} +} // namespace pde +} // namespace SGPP -#endif /* OPERATIONELLIPTICPDESOLVERMATRIXDIRICHLET_HPP */ \ No newline at end of file +#endif /* OPERATIONELLIPTICPDESOLVERMATRIXDIRICHLET_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemFreeBoundaries.cpp b/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemFreeBoundaries.cpp old mode 100755 new mode 100644 index ce7ef9b097..987a1193db --- a/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemFreeBoundaries.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemFreeBoundaries.cpp @@ -8,28 +8,22 @@ #include - namespace SGPP { namespace pde { OperationEllipticPDESolverSystemFreeBoundaries::OperationEllipticPDESolverSystemFreeBoundaries( - SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& rhs) : OperationEllipticPDESolverSystem(SparseGrid, - rhs) { -} + SGPP::base::Grid& SparseGrid, SGPP::base::DataVector& rhs) + : OperationEllipticPDESolverSystem(SparseGrid, rhs) {} -OperationEllipticPDESolverSystemFreeBoundaries::~OperationEllipticPDESolverSystemFreeBoundaries() { -} +OperationEllipticPDESolverSystemFreeBoundaries::~OperationEllipticPDESolverSystemFreeBoundaries() {} -void OperationEllipticPDESolverSystemFreeBoundaries::mult( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void OperationEllipticPDESolverSystemFreeBoundaries::mult(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { applyLOperator(alpha, result); } -SGPP::base::DataVector* -OperationEllipticPDESolverSystemFreeBoundaries::generateRHS() { +SGPP::base::DataVector* OperationEllipticPDESolverSystemFreeBoundaries::generateRHS() { return this->rhs; } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemFreeBoundaries.hpp b/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemFreeBoundaries.hpp old mode 100755 new mode 100644 index 4ff82f921a..ee689d6cef --- a/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemFreeBoundaries.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationEllipticPDESolverSystemFreeBoundaries.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -26,18 +25,15 @@ namespace pde { * rhs: right hand sider) * */ -class OperationEllipticPDESolverSystemFreeBoundaries : public - OperationEllipticPDESolverSystem { +class OperationEllipticPDESolverSystemFreeBoundaries : public OperationEllipticPDESolverSystem { protected: - /** * applies the PDE's system matrix, on complete grid - with boundaries * * @param alpha the coefficients of the sparse grid's ansatzfunctions * @param result reference to the SGPP::base::DataVector into which the result is written */ - virtual void applyLOperator(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) = 0; + virtual void applyLOperator(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) = 0; public: /** @@ -47,20 +43,18 @@ class OperationEllipticPDESolverSystemFreeBoundaries : public * @param rhs the right hand side of the corresponding system */ OperationEllipticPDESolverSystemFreeBoundaries(SGPP::base::Grid& SparseGrid, - SGPP::base::DataVector& rhs); + SGPP::base::DataVector& rhs); /** * Destructor */ virtual ~OperationEllipticPDESolverSystemFreeBoundaries(); - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual SGPP::base::DataVector* generateRHS(); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* OPERATIONELLITPTICPDESOLVERMATRIXFREEBOUNDARIES_HPP */ \ No newline at end of file +#endif /* OPERATIONELLITPTICPDESOLVERMATRIXFREEBOUNDARIES_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinear.cpp b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinear.cpp index 790e8a7766..2cfffc1510 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinear.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinear.cpp @@ -12,16 +12,13 @@ #include - namespace SGPP { namespace pde { -OperationLTwoDotProductLinear::OperationLTwoDotProductLinear( - SGPP::base::GridStorage* storage) : StdUpDown(storage) { -} +OperationLTwoDotProductLinear::OperationLTwoDotProductLinear(SGPP::base::GridStorage* storage) + : StdUpDown(storage) {} -OperationLTwoDotProductLinear::~OperationLTwoDotProductLinear() { -} +OperationLTwoDotProductLinear::~OperationLTwoDotProductLinear() {} void OperationLTwoDotProductLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { @@ -33,13 +30,12 @@ void OperationLTwoDotProductLinear::up(SGPP::base::DataVector& alpha, } void OperationLTwoDotProductLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinear.hpp b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinear.hpp index 224163342f..8e5ffdc447 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinear.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -18,14 +17,14 @@ namespace pde { * Implements the standard L 2 scalar product on linear grids (no boundaries) * */ -class OperationLTwoDotProductLinear: public StdUpDown { +class OperationLTwoDotProductLinear : public StdUpDown { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLTwoDotProductLinear(SGPP::base::GridStorage* storage); + explicit OperationLTwoDotProductLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,8 +41,7 @@ class OperationLTwoDotProductLinear: public StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -54,11 +52,9 @@ class OperationLTwoDotProductLinear: public StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* OPERATIONLTWODOTPRODUCTLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONLTWODOTPRODUCTLINEAR_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearBoundary.cpp b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearBoundary.cpp index 21a5a36098..3f23f9b349 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearBoundary.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearBoundary.cpp @@ -12,19 +12,17 @@ #include - namespace SGPP { namespace pde { OperationLTwoDotProductLinearBoundary::OperationLTwoDotProductLinearBoundary( - SGPP::base::GridStorage* storage) : StdUpDown(storage) { -} + SGPP::base::GridStorage* storage) + : StdUpDown(storage) {} -OperationLTwoDotProductLinearBoundary::~OperationLTwoDotProductLinearBoundary() { -} +OperationLTwoDotProductLinearBoundary::~OperationLTwoDotProductLinearBoundary() {} void OperationLTwoDotProductLinearBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi PhiPhiUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -33,13 +31,12 @@ void OperationLTwoDotProductLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationLTwoDotProductLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearBoundary.hpp b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearBoundary.hpp index 88b6e8d028..dc7552dbc3 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearBoundary.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -18,14 +17,14 @@ namespace pde { * Implements the standard L 2 scalar product on linear boundary grids * */ -class OperationLTwoDotProductLinearBoundary: public StdUpDown { +class OperationLTwoDotProductLinearBoundary : public StdUpDown { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLTwoDotProductLinearBoundary(SGPP::base::GridStorage* storage); + explicit OperationLTwoDotProductLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -42,8 +41,7 @@ class OperationLTwoDotProductLinearBoundary: public StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -54,11 +52,9 @@ class OperationLTwoDotProductLinearBoundary: public StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* OPERATIONLTWODOTPRODUCTLINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONLTWODOTPRODUCTLINEARBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretched.cpp b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretched.cpp old mode 100755 new mode 100644 index 28dc5e73cf..071628bc25 --- a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretched.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretched.cpp @@ -10,22 +10,19 @@ #include - #include - namespace SGPP { namespace pde { OperationLTwoDotProductLinearStretched::OperationLTwoDotProductLinearStretched( - SGPP::base::GridStorage* storage) : StdUpDown(storage) { -} + SGPP::base::GridStorage* storage) + : StdUpDown(storage) {} -OperationLTwoDotProductLinearStretched::~OperationLTwoDotProductLinearStretched() { -} +OperationLTwoDotProductLinearStretched::~OperationLTwoDotProductLinearStretched() {} void OperationLTwoDotProductLinearStretched::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi PhiPhiUpBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -34,13 +31,12 @@ void OperationLTwoDotProductLinearStretched::up(SGPP::base::DataVector& alpha, } void OperationLTwoDotProductLinearStretched::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { // phi * phi PhiPhiDownBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretched.hpp b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretched.hpp old mode 100755 new mode 100644 index 7f37f7ea71..dfb4a8af8c --- a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretched.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretched.hpp @@ -8,10 +8,8 @@ #include - #include - namespace SGPP { namespace pde { @@ -19,14 +17,14 @@ namespace pde { * Implements the standard L 2 scalar product on linear grids (no boundaries) * */ -class OperationLTwoDotProductLinearStretched: public StdUpDown { +class OperationLTwoDotProductLinearStretched : public StdUpDown { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLTwoDotProductLinearStretched(SGPP::base::GridStorage* storage); + explicit OperationLTwoDotProductLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -43,8 +41,7 @@ class OperationLTwoDotProductLinearStretched: public StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -55,11 +52,9 @@ class OperationLTwoDotProductLinearStretched: public StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* OPERATIONLTWODOTPRODUCTLINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* OPERATIONLTWODOTPRODUCTLINEARSTRETCHED_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretchedBoundary.cpp b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index 2107fb83dc..c5d229cef2 --- a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretchedBoundary.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretchedBoundary.cpp @@ -10,22 +10,20 @@ #include - #include - namespace SGPP { namespace pde { OperationLTwoDotProductLinearStretchedBoundary::OperationLTwoDotProductLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : StdUpDown(storage) { -} + SGPP::base::GridStorage* storage) + : StdUpDown(storage) {} -OperationLTwoDotProductLinearStretchedBoundary::~OperationLTwoDotProductLinearStretchedBoundary() { -} +OperationLTwoDotProductLinearStretchedBoundary::~OperationLTwoDotProductLinearStretchedBoundary() {} -void OperationLTwoDotProductLinearStretchedBoundary::up( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationLTwoDotProductLinearStretchedBoundary::up(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // phi * phi PhiPhiUpBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -33,14 +31,14 @@ void OperationLTwoDotProductLinearStretchedBoundary::up( s.sweep1D_Boundary(alpha, result, dim); } -void OperationLTwoDotProductLinearStretchedBoundary::down( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationLTwoDotProductLinearStretchedBoundary::down(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { // phi * phi PhiPhiDownBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretchedBoundary.hpp b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index a37ee866fb..d478fe10dd --- a/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretchedBoundary.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLTwoDotProductLinearStretchedBoundary.hpp @@ -8,10 +8,8 @@ #include - #include - namespace SGPP { namespace pde { @@ -19,15 +17,14 @@ namespace pde { * Implements the standard L 2 scalar product on linear boundary grids * */ -class OperationLTwoDotProductLinearStretchedBoundary: public StdUpDown { +class OperationLTwoDotProductLinearStretchedBoundary : public StdUpDown { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLTwoDotProductLinearStretchedBoundary(SGPP::base::GridStorage* - storage); + explicit OperationLTwoDotProductLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -44,8 +41,7 @@ class OperationLTwoDotProductLinearStretchedBoundary: public StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); /** * Down-step in dimension dim for \f$(\phi_i(x),\phi_j(x))_{L_2}\f$. @@ -56,11 +52,9 @@ class OperationLTwoDotProductLinearStretchedBoundary: public StdUpDown { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* OPERATIONLTWODOTPRODUCTLINEARSTRETCHEDBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONLTWODOTPRODUCTLINEARSTRETCHEDBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinear.cpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinear.cpp index 33b937acb0..83bbf65f57 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinear.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinear.cpp @@ -12,23 +12,17 @@ #include - namespace SGPP { namespace pde { -OperationLaplaceEnhancedLinear::OperationLaplaceEnhancedLinear( - SGPP::base::GridStorage* storage) : - UpDownOneOpDimEnhanced(storage) { -} +OperationLaplaceEnhancedLinear::OperationLaplaceEnhancedLinear(SGPP::base::GridStorage* storage) + : UpDownOneOpDimEnhanced(storage) {} -OperationLaplaceEnhancedLinear::OperationLaplaceEnhancedLinear( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : - UpDownOneOpDimEnhanced(storage, coef) { -} +OperationLaplaceEnhancedLinear::OperationLaplaceEnhancedLinear(SGPP::base::GridStorage* storage, + SGPP::base::DataVector& coef) + : UpDownOneOpDimEnhanced(storage, coef) {} -OperationLaplaceEnhancedLinear::~OperationLaplaceEnhancedLinear() { -} +OperationLaplaceEnhancedLinear::~OperationLaplaceEnhancedLinear() {} void OperationLaplaceEnhancedLinear::up(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, size_t dim) { @@ -39,12 +33,11 @@ void OperationLaplaceEnhancedLinear::up(SGPP::base::DataMatrix& alpha, } void OperationLaplaceEnhancedLinear::down(SGPP::base::DataMatrix& alpha, - SGPP::base::DataMatrix& result, size_t dim) { + SGPP::base::DataMatrix& result, size_t dim) { LaplaceEnhancedDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinear.hpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinear.hpp index 45b8f0e886..ce32b76a07 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinear.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -19,23 +18,23 @@ namespace pde { * the UpDownOneOpDimEnhanced method. * */ -class OperationLaplaceEnhancedLinear: public UpDownOneOpDimEnhanced { +class OperationLaplaceEnhancedLinear : public UpDownOneOpDimEnhanced { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLaplaceEnhancedLinear(SGPP::base::GridStorage* storage); + explicit OperationLaplaceEnhancedLinear(SGPP::base::GridStorage* storage); /** * Constructor of OperationLaplaceLinear * * @param storage Pointer to the grid's gridstorage obejct - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients; one per dimension + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients; one per dimension */ - OperationLaplaceEnhancedLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationLaplaceEnhancedLinear(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor @@ -50,8 +49,7 @@ class OperationLaplaceEnhancedLinear: public UpDownOneOpDimEnhanced { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, - size_t dim); + virtual void up(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, size_t dim); /** * Down-step @@ -60,11 +58,9 @@ class OperationLaplaceEnhancedLinear: public UpDownOneOpDimEnhanced { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, - size_t dim); + virtual void down(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, size_t dim); }; - -} -} +} // namespace pde +} // namespace SGPP #endif /* OPERATIONLAPLACEENHANCEDLINEAR_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinearBoundary.cpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinearBoundary.cpp old mode 100755 new mode 100644 index e150baa494..7dbde51a9a --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinearBoundary.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinearBoundary.cpp @@ -12,24 +12,21 @@ #include - namespace SGPP { namespace pde { OperationLaplaceEnhancedLinearBoundary::OperationLaplaceEnhancedLinearBoundary( - SGPP::base::GridStorage* storage) : UpDownOneOpDimEnhanced(storage) { -} + SGPP::base::GridStorage* storage) + : UpDownOneOpDimEnhanced(storage) {} OperationLaplaceEnhancedLinearBoundary::OperationLaplaceEnhancedLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : UpDownOneOpDimEnhanced(storage, coef) { -} + SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef) + : UpDownOneOpDimEnhanced(storage, coef) {} -OperationLaplaceEnhancedLinearBoundary::~OperationLaplaceEnhancedLinearBoundary() { -} +OperationLaplaceEnhancedLinearBoundary::~OperationLaplaceEnhancedLinearBoundary() {} void OperationLaplaceEnhancedLinearBoundary::up(SGPP::base::DataMatrix& alpha, - SGPP::base::DataMatrix& result, size_t dim) { + SGPP::base::DataMatrix& result, size_t dim) { LaplaceEnhancedUpBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -37,12 +34,11 @@ void OperationLaplaceEnhancedLinearBoundary::up(SGPP::base::DataMatrix& alpha, } void OperationLaplaceEnhancedLinearBoundary::down(SGPP::base::DataMatrix& alpha, - SGPP::base::DataMatrix& result, size_t dim) { + SGPP::base::DataMatrix& result, size_t dim) { LaplaceEnhancedDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinearBoundary.hpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinearBoundary.hpp old mode 100755 new mode 100644 index bea59dbcfa..982a4f3d80 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinearBoundary.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceEnhancedLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -19,20 +18,21 @@ namespace pde { * the UpDownOneOpDimEnhanced method. * */ -class OperationLaplaceEnhancedLinearBoundary: public UpDownOneOpDimEnhanced { +class OperationLaplaceEnhancedLinearBoundary : public UpDownOneOpDimEnhanced { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLaplaceEnhancedLinearBoundary(SGPP::base::GridStorage* storage); + explicit OperationLaplaceEnhancedLinearBoundary(SGPP::base::GridStorage* storage); /** * Constructor of OperationLaplaceLinear * * @param storage Pointer to the grid's gridstorage obejct - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients; one per dimension + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients; one per dimension */ OperationLaplaceEnhancedLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); @@ -50,8 +50,7 @@ class OperationLaplaceEnhancedLinearBoundary: public UpDownOneOpDimEnhanced { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void up(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, - size_t dim); + virtual void up(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, size_t dim); /** * Down-step @@ -60,11 +59,9 @@ class OperationLaplaceEnhancedLinearBoundary: public UpDownOneOpDimEnhanced { * @param alpha vector of coefficients * @param result vector to store the results in */ - virtual void down(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, - size_t dim); + virtual void down(SGPP::base::DataMatrix& alpha, SGPP::base::DataMatrix& result, size_t dim); }; - -} -} +} // namespace pde +} // namespace SGPP #endif /* OPERATIONLAPLACEENHANCEDLINEARBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinear.cpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinear.cpp index 89c7ae6d90..108df1047d 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinear.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinear.cpp @@ -14,23 +14,21 @@ #include - namespace SGPP { namespace pde { OperationLaplaceLinear::OperationLaplaceLinear(SGPP::base::GridStorage* storage) - : UpDownOneOpDim(storage) { -} + : UpDownOneOpDim(storage) {} OperationLaplaceLinear::OperationLaplaceLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : UpDownOneOpDim(storage, coef) { -} + SGPP::base::DataVector& coef) + : UpDownOneOpDim(storage, coef) {} -OperationLaplaceLinear::~OperationLaplaceLinear() { -} +OperationLaplaceLinear::~OperationLaplaceLinear() {} void OperationLaplaceLinear::specialOP(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t gradient_dim) { + SGPP::base::DataVector& result, size_t dim, + size_t gradient_dim) { // In direction gradient_dim we only calculate the norm of the gradient // The up-part is empty, thus omitted if (dim > 0) { @@ -43,15 +41,15 @@ void OperationLaplaceLinear::specialOP(SGPP::base::DataVector& alpha, } } -void OperationLaplaceLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLaplaceLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { PhiPhiUpBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } -void OperationLaplaceLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLaplaceLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { PhiPhiDownBBLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); @@ -63,9 +61,7 @@ void OperationLaplaceLinear::downOpDim(SGPP::base::DataVector& alpha, myDown(alpha, result, dim); } -void OperationLaplaceLinear::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file +void OperationLaplaceLinear::upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) {} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinear.hpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinear.hpp old mode 100755 new mode 100644 index 7d90f4851b..1e05368814 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinear.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -18,46 +17,41 @@ namespace pde { * Implementation for linear functions of Laplace Operation, linear grids without boundaries * */ -class OperationLaplaceLinear: public UpDownOneOpDim { +class OperationLaplaceLinear : public UpDownOneOpDim { public: /** * Constructor of OperationLaplaceLinear * * @param storage Pointer to the grid's gridstorage obejct */ - OperationLaplaceLinear(SGPP::base::GridStorage* storage); + explicit OperationLaplaceLinear(SGPP::base::GridStorage* storage); /** * Constructor of OperationLaplaceLinear * * @param storage Pointer to the grid's gridstorage obejct - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients; one per dimension + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients; one per dimension */ - OperationLaplaceLinear(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationLaplaceLinear(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor */ virtual ~OperationLaplaceLinear(); - virtual void specialOP(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t gradient_dim); + virtual void specialOP(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t gradient_dim); - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* OPERATIONLAPLACELINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONLAPLACELINEAR_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearBoundary.cpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearBoundary.cpp index 033b64c312..4a9e8f0cd9 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearBoundary.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearBoundary.cpp @@ -17,21 +17,17 @@ #include - namespace SGPP { namespace pde { -OperationLaplaceLinearBoundary::OperationLaplaceLinearBoundary( - SGPP::base::GridStorage* storage) : UpDownOneOpDim(storage) { -} +OperationLaplaceLinearBoundary::OperationLaplaceLinearBoundary(SGPP::base::GridStorage* storage) + : UpDownOneOpDim(storage) {} -OperationLaplaceLinearBoundary::OperationLaplaceLinearBoundary( - SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef) : UpDownOneOpDim(storage, coef) { -} +OperationLaplaceLinearBoundary::OperationLaplaceLinearBoundary(SGPP::base::GridStorage* storage, + SGPP::base::DataVector& coef) + : UpDownOneOpDim(storage, coef) {} -OperationLaplaceLinearBoundary::~OperationLaplaceLinearBoundary() { -} +OperationLaplaceLinearBoundary::~OperationLaplaceLinearBoundary() {} void OperationLaplaceLinearBoundary::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { @@ -41,23 +37,22 @@ void OperationLaplaceLinearBoundary::up(SGPP::base::DataVector& alpha, } void OperationLaplaceLinearBoundary::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { PhiPhiDownBBLinearBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } void OperationLaplaceLinearBoundary::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { DowndPhidPhiBBIterativeLinearBoundary myDown(this->storage); myDown(alpha, result, dim); } void OperationLaplaceLinearBoundary::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { UpdPhidPhiBBIterativeLinearBoundary myUp(this->storage); myUp(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearBoundary.hpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearBoundary.hpp old mode 100755 new mode 100644 index 84f4dab2a9..a752e30ff3 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearBoundary.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearBoundary.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -18,45 +17,39 @@ namespace pde { * Implementation of Laplace for linear functions with boundaries * */ -class OperationLaplaceLinearBoundary: public UpDownOneOpDim { +class OperationLaplaceLinearBoundary : public UpDownOneOpDim { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLaplaceLinearBoundary(SGPP::base::GridStorage* storage); + explicit OperationLaplaceLinearBoundary(SGPP::base::GridStorage* storage); /** * Constructor of OperationLaplaceLinear * * @param storage Pointer to the grid's gridstorage obejct - * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's constant coefficients; one per dimension + * @param coef reference to a SGPP::base::DataVector object that contains the bilinear form's + * constant coefficients; one per dimension */ - OperationLaplaceLinearBoundary(SGPP::base::GridStorage* storage, - SGPP::base::DataVector& coef); + OperationLaplaceLinearBoundary(SGPP::base::GridStorage* storage, SGPP::base::DataVector& coef); /** * Destructor */ virtual ~OperationLaplaceLinearBoundary(); - protected: - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* OPERATIONLAPLACELINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* OPERATIONLAPLACELINEARBOUNDARY_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretched.cpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretched.cpp old mode 100755 new mode 100644 index 2de75f5e99..7f48d0f1d6 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretched.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretched.cpp @@ -12,22 +12,19 @@ #include - #include - namespace SGPP { namespace pde { -OperationLaplaceLinearStretched::OperationLaplaceLinearStretched( - SGPP::base::GridStorage* storage) : UpDownOneOpDim(storage) { -} +OperationLaplaceLinearStretched::OperationLaplaceLinearStretched(SGPP::base::GridStorage* storage) + : UpDownOneOpDim(storage) {} -OperationLaplaceLinearStretched::~OperationLaplaceLinearStretched() { -} +OperationLaplaceLinearStretched::~OperationLaplaceLinearStretched() {} void OperationLaplaceLinearStretched::specialOP(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t gradient_dim) { + SGPP::base::DataVector& result, size_t dim, + size_t gradient_dim) { // In direction gradient_dim we only calculate the norm of the gradient // The up-part is empty, thus omitted if (dim > 0) { @@ -41,28 +38,26 @@ void OperationLaplaceLinearStretched::specialOP(SGPP::base::DataVector& alpha, } void OperationLaplaceLinearStretched::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { PhiPhiUpBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } void OperationLaplaceLinearStretched::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { PhiPhiDownBBLinearStretched func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } void OperationLaplaceLinearStretched::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { DowndPhidPhiBBIterativeLinearStretched myDown(this->storage); myDown(alpha, result, dim); } void OperationLaplaceLinearStretched::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { -} - -} -} \ No newline at end of file + SGPP::base::DataVector& result, size_t dim) {} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretched.hpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretched.hpp old mode 100755 new mode 100644 index c7620de8c9..aba9990128 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretched.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretched.hpp @@ -8,10 +8,8 @@ #include - #include - namespace SGPP { namespace pde { @@ -19,14 +17,14 @@ namespace pde { * Implementation for linear functions of Laplace Operation, linear grids without boundaries * */ -class OperationLaplaceLinearStretched: public UpDownOneOpDim { +class OperationLaplaceLinearStretched : public UpDownOneOpDim { public: /** * Constructor of OperationLaplaceLinearStretched * * @param storage Pointer to the grid's gridstorage obejct */ - OperationLaplaceLinearStretched(SGPP::base::GridStorage* storage); + explicit OperationLaplaceLinearStretched(SGPP::base::GridStorage* storage); /** * Destructor @@ -34,23 +32,18 @@ class OperationLaplaceLinearStretched: public UpDownOneOpDim { virtual ~OperationLaplaceLinearStretched(); protected: - virtual void specialOP(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim, size_t gradient_dim); + virtual void specialOP(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim, + size_t gradient_dim); - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* OPERATIONLAPLACELINEARSTRETCHED_HPP */ \ No newline at end of file +#endif /* OPERATIONLAPLACELINEARSTRETCHED_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretchedBoundary.cpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretchedBoundary.cpp old mode 100755 new mode 100644 index 00161fc087..bbcaa40ae2 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretchedBoundary.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretchedBoundary.cpp @@ -17,42 +17,40 @@ #include - namespace SGPP { namespace pde { OperationLaplaceLinearStretchedBoundary::OperationLaplaceLinearStretchedBoundary( - SGPP::base::GridStorage* storage) : UpDownOneOpDim(storage) { -} + SGPP::base::GridStorage* storage) + : UpDownOneOpDim(storage) {} -OperationLaplaceLinearStretchedBoundary::~OperationLaplaceLinearStretchedBoundary() { -} +OperationLaplaceLinearStretchedBoundary::~OperationLaplaceLinearStretchedBoundary() {} void OperationLaplaceLinearStretchedBoundary::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { PhiPhiUpBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } -void OperationLaplaceLinearStretchedBoundary::down(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationLaplaceLinearStretchedBoundary::down(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { PhiPhiDownBBLinearStretchedBoundary func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D_Boundary(alpha, result, dim); } -void OperationLaplaceLinearStretchedBoundary::downOpDim( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationLaplaceLinearStretchedBoundary::downOpDim(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, + size_t dim) { DowndPhidPhiBBIterativeLinearStretchedBoundary myDown(this->storage); myDown(alpha, result, dim); } -void OperationLaplaceLinearStretchedBoundary::upOpDim(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void OperationLaplaceLinearStretchedBoundary::upOpDim(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { UpdPhidPhiBBIterativeLinearStretchedBoundary myUp(this->storage); myUp(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretchedBoundary.hpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretchedBoundary.hpp old mode 100755 new mode 100644 index 06a187d146..bca7593dcc --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretchedBoundary.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceLinearStretchedBoundary.hpp @@ -8,10 +8,8 @@ #include - #include - namespace SGPP { namespace pde { @@ -19,36 +17,30 @@ namespace pde { * Implementation of Laplace for linear functions with boundaries * */ -class OperationLaplaceLinearStretchedBoundary: public UpDownOneOpDim { +class OperationLaplaceLinearStretchedBoundary : public UpDownOneOpDim { public: /** * Constructor * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLaplaceLinearStretchedBoundary(SGPP::base::GridStorage* storage); + explicit OperationLaplaceLinearStretchedBoundary(SGPP::base::GridStorage* storage); /** * Destructor */ virtual ~OperationLaplaceLinearStretchedBoundary(); - protected: - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* OPERATIONLAPLACELINEARBOUNDARYSTRETCHED_HPP */ \ No newline at end of file +#endif /* OPERATIONLAPLACELINEARBOUNDARYSTRETCHED_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceModLinear.cpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceModLinear.cpp index 407cbe71a5..6b73b8515e 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceModLinear.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceModLinear.cpp @@ -14,27 +14,24 @@ #include - namespace SGPP { namespace pde { -OperationLaplaceModLinear::OperationLaplaceModLinear(SGPP::base::GridStorage* - storage) : UpDownOneOpDim(storage) { -} +OperationLaplaceModLinear::OperationLaplaceModLinear(SGPP::base::GridStorage* storage) + : UpDownOneOpDim(storage) {} -OperationLaplaceModLinear::~OperationLaplaceModLinear() { -} +OperationLaplaceModLinear::~OperationLaplaceModLinear() {} -void OperationLaplaceModLinear::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLaplaceModLinear::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { result.setAll(0.0); PhiPhiUpModLinear func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } -void OperationLaplaceModLinear::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLaplaceModLinear::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { result.setAll(0.0); PhiPhiDownModLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -42,7 +39,7 @@ void OperationLaplaceModLinear::down(SGPP::base::DataVector& alpha, } void OperationLaplaceModLinear::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { result.setAll(0.0); dPhidPhiDownModLinear func(this->storage); SGPP::base::sweep s(func, this->storage); @@ -56,6 +53,5 @@ void OperationLaplaceModLinear::upOpDim(SGPP::base::DataVector& alpha, SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplaceModLinear.hpp b/pde/src/sgpp/pde/operation/hash/OperationLaplaceModLinear.hpp old mode 100755 new mode 100644 index f27b445b20..e2adc797f4 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplaceModLinear.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplaceModLinear.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -25,7 +24,7 @@ class OperationLaplaceModLinear : public UpDownOneOpDim { * * @param storage the grid's SGPP::base::GridStorage object */ - OperationLaplaceModLinear(SGPP::base::GridStorage* storage); + explicit OperationLaplaceModLinear(SGPP::base::GridStorage* storage); /** * Destructor @@ -33,20 +32,15 @@ class OperationLaplaceModLinear : public UpDownOneOpDim { virtual ~OperationLaplaceModLinear(); protected: - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* OPERATIONLAPLACEMODLINEAR_HPP */ \ No newline at end of file +#endif /* OPERATIONLAPLACEMODLINEAR_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplacePrewavelet.cpp b/pde/src/sgpp/pde/operation/hash/OperationLaplacePrewavelet.cpp old mode 100755 new mode 100644 index 420102577a..b13886ef3d --- a/pde/src/sgpp/pde/operation/hash/OperationLaplacePrewavelet.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplacePrewavelet.cpp @@ -10,43 +10,37 @@ #include - namespace SGPP { namespace pde { -OperationLaplacePrewavelet::OperationLaplacePrewavelet(SGPP::base::GridStorage* - storage, SGPP::base::GridStorage* shadowstorage) : - UpDownOneOpDimWithShadow(storage, shadowstorage) { - -} +OperationLaplacePrewavelet::OperationLaplacePrewavelet(SGPP::base::GridStorage* storage, + SGPP::base::GridStorage* shadowstorage) + : UpDownOneOpDimWithShadow(storage, shadowstorage) {} -OperationLaplacePrewavelet::~OperationLaplacePrewavelet() { -} +OperationLaplacePrewavelet::~OperationLaplacePrewavelet() {} -void OperationLaplacePrewavelet::up(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { +void OperationLaplacePrewavelet::up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) { LaplaceUpPrewavelet func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } -void OperationLaplacePrewavelet::down(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { -} +void OperationLaplacePrewavelet::down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim) {} void OperationLaplacePrewavelet::downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { LaplaceDownGradientPrewavelet func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } void OperationLaplacePrewavelet::upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim) { + SGPP::base::DataVector& result, size_t dim) { LaplaceUpGradientPrewavelet func(this->storage); SGPP::base::sweep s(func, this->storage); s.sweep1D(alpha, result, dim); } - -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationLaplacePrewavelet.hpp b/pde/src/sgpp/pde/operation/hash/OperationLaplacePrewavelet.hpp old mode 100755 new mode 100644 index d3a30ef870..ac95784997 --- a/pde/src/sgpp/pde/operation/hash/OperationLaplacePrewavelet.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationLaplacePrewavelet.hpp @@ -15,19 +15,19 @@ #include #include -#include - -using namespace SGPP::base; #include +#include namespace SGPP { namespace pde { /** * Implementation for linear functions of Laplace Operation, prewavelet grids without boundaries. - * With prewavelets the calculation of the gradient part of the up down algorithm is the more complicated - * one whereas the normal part is eased. For details on the implementation please refer to the documentation + * With prewavelets the calculation of the gradient part of the up down algorithm is the more + * complicated + * one whereas the normal part is eased. For details on the implementation please refer to the + * documentation * of the detail-classes LaplaceDownGradientPrewavelet.hpp, LaplaceUpGradientPrewavelet.hpp and * LaplaceDownPrewavelet.hpp. */ @@ -48,21 +48,15 @@ class OperationLaplacePrewavelet : public UpDownOneOpDimWithShadow { virtual ~OperationLaplacePrewavelet(); protected: + virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void up(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); - - virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, - size_t dim); + virtual void down(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void downOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void downOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); - virtual void upOpDim(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void upOpDim(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* OPERATIONLAPLACEPREWAVELET_HPP */ \ No newline at end of file +#endif /* OPERATIONLAPLACEPREWAVELET_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinear.cpp b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinear.cpp index 828f0e7456..b800d57624 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinear.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinear.cpp @@ -6,29 +6,27 @@ #include #include #include -#include -#include -#include #include +#include +#include +#include +#include namespace SGPP { namespace pde { OperationMatrixLTwoDotExplicitLinear::OperationMatrixLTwoDotExplicitLinear( - SGPP::base::DataMatrix* m, - SGPP::base::Grid* grid) : - ownsMatrix_(false) { + SGPP::base::DataMatrix* m, SGPP::base::Grid* grid) + : ownsMatrix_(false) { m_ = m; buildMatrix(grid); } -OperationMatrixLTwoDotExplicitLinear::OperationMatrixLTwoDotExplicitLinear( - SGPP::base::Grid* grid) : - ownsMatrix_(true) { - m_ = new SGPP::base::DataMatrix(grid->getStorage()->size(), - grid->getStorage()->size()); +OperationMatrixLTwoDotExplicitLinear::OperationMatrixLTwoDotExplicitLinear(SGPP::base::Grid* grid) + : ownsMatrix_(true) { + m_ = new SGPP::base::DataMatrix(grid->getStorage()->size(), grid->getStorage()->size()); buildMatrix(grid); } @@ -53,32 +51,30 @@ void OperationMatrixLTwoDotExplicitLinear::buildMatrix(SGPP::base::Grid* grid) { if (lik == ljk) { if (iik == ijk) { - //Use formula for identical ansatz functions: + // Use formula for identical ansatz functions: res *= 2 / lik / 3; } else { - //Different index, but same level => ansatz functions do not overlap: + // Different index, but same level => ansatz functions do not overlap: res = 0.; break; } } else { - if (std::max((iik - 1) / lik, (ijk - 1) / ljk) - >= std::min((iik + 1) / lik, (ijk + 1) / ljk)) { - //Ansatz functions do not not overlap: + if (std::max((iik - 1) / lik, (ijk - 1) / ljk) >= + std::min((iik + 1) / lik, (ijk + 1) / ljk)) { + // Ansatz functions do not not overlap: res = 0.; break; } else { - //Use formula for different overlapping ansatz functions: - if (lik > ljk) { //Phi_i_k is the "smaller" ansatz function - float_t diff = (iik / lik) - (ijk / ljk); // x_i_k - x_j_k - float_t temp_res = fabs(diff - (1 / lik)) - + fabs(diff + (1 / lik)) - fabs(diff); + // Use formula for different overlapping ansatz functions: + if (lik > ljk) { // Phi_i_k is the "smaller" ansatz function + float_t diff = (iik / lik) - (ijk / ljk); // x_i_k - x_j_k + float_t temp_res = fabs(diff - (1 / lik)) + fabs(diff + (1 / lik)) - fabs(diff); temp_res *= ljk; temp_res = (1 - temp_res) / lik; res *= temp_res; - } else { //Phi_j_k is the "smaller" ansatz function - float_t diff = (ijk / ljk) - (iik / lik); // x_j_k - x_i_k - float_t temp_res = fabs(diff - (1 / ljk)) - + fabs(diff + (1 / ljk)) - fabs(diff); + } else { // Phi_j_k is the "smaller" ansatz function + float_t diff = (ijk / ljk) - (iik / lik); // x_j_k - x_i_k + float_t temp_res = fabs(diff - (1 / ljk)) + fabs(diff + (1 / ljk)) - fabs(diff); temp_res *= lik; temp_res = (1 - temp_res) / ljk; res *= temp_res; @@ -94,13 +90,11 @@ void OperationMatrixLTwoDotExplicitLinear::buildMatrix(SGPP::base::Grid* grid) { } OperationMatrixLTwoDotExplicitLinear::~OperationMatrixLTwoDotExplicitLinear() { - if (ownsMatrix_) - delete m_; + if (ownsMatrix_) delete m_; } void OperationMatrixLTwoDotExplicitLinear::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { - + SGPP::base::DataVector& result) { size_t nrows = m_->getNrows(); size_t ncols = m_->getNcols(); @@ -110,7 +104,7 @@ void OperationMatrixLTwoDotExplicitLinear::mult(SGPP::base::DataVector& alpha, float_t* data = m_->getPointer(); - //Standard matrix multiplication: + // Standard matrix multiplication: float_t temp = 0.; size_t acc = 0; diff --git a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinear.hpp b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinear.hpp index e39ae59e10..bef772e5d7 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinear.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinear.hpp @@ -12,14 +12,13 @@ #include - namespace SGPP { namespace pde { /** * Explicit representation of the matrix \f$(\Phi_i,\Phi_j)_{L2}\f$ for a sparse grid */ -class OperationMatrixLTwoDotExplicitLinear: public SGPP::base::OperationMatrix { +class OperationMatrixLTwoDotExplicitLinear : public SGPP::base::OperationMatrix { public: /** * Constructor that uses a external matrix pointer to construct the matrix, @@ -28,15 +27,14 @@ class OperationMatrixLTwoDotExplicitLinear: public SGPP::base::OperationMatrix { * @param m pointer to datamatrix of size (number of grid point) x (number of grid points) * @param grid the sparse grid */ - OperationMatrixLTwoDotExplicitLinear(SGPP::base::DataMatrix* m, - SGPP::base::Grid* grid); + OperationMatrixLTwoDotExplicitLinear(SGPP::base::DataMatrix* m, SGPP::base::Grid* grid); /** * Constructor that creates an own matrix * i.e. matrix is destroyed by the destructor of OperationMatrixLTwoDotExplicitLinearFullGrid * * @param grid the sparse grid */ - OperationMatrixLTwoDotExplicitLinear(SGPP::base::Grid* grid); + explicit OperationMatrixLTwoDotExplicitLinear(SGPP::base::Grid* grid); /** * Destructor @@ -49,8 +47,7 @@ class OperationMatrixLTwoDotExplicitLinear: public SGPP::base::OperationMatrix { * @param alpha DataVector that is multiplied to the matrix * @param result DataVector into which the result of multiplication is stored */ - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); private: /** @@ -64,4 +61,4 @@ class OperationMatrixLTwoDotExplicitLinear: public SGPP::base::OperationMatrix { } // namespace pde } // namespace SGPP -#endif /* OperationMatrixLTwoDotExplicitLinear_HPP_ */ \ No newline at end of file +#endif /* OperationMatrixLTwoDotExplicitLinear_HPP_ */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinearBoundary.cpp b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinearBoundary.cpp index 8b40815a9f..bbfe8ce454 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinearBoundary.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinearBoundary.cpp @@ -10,36 +10,30 @@ #include - namespace SGPP { namespace pde { OperationMatrixLTwoDotExplicitLinearBoundary::OperationMatrixLTwoDotExplicitLinearBoundary( - SGPP::base::DataMatrix* m, - SGPP::base::Grid* grid) : - ownsMatrix_(false) { + SGPP::base::DataMatrix* m, SGPP::base::Grid* grid) + : ownsMatrix_(false) { m_ = m; buildMatrix(grid); } OperationMatrixLTwoDotExplicitLinearBoundary::OperationMatrixLTwoDotExplicitLinearBoundary( - SGPP::base::Grid* grid) : - ownsMatrix_(true) { - m_ = new SGPP::base::DataMatrix(grid->getStorage()->size(), - grid->getStorage()->size()); + SGPP::base::Grid* grid) + : ownsMatrix_(true) { + m_ = new SGPP::base::DataMatrix(grid->getStorage()->size(), grid->getStorage()->size()); buildMatrix(grid); } OperationMatrixLTwoDotExplicitLinearBoundary::~OperationMatrixLTwoDotExplicitLinearBoundary() { - if (ownsMatrix_) - delete m_; + if (ownsMatrix_) delete m_; } -void OperationMatrixLTwoDotExplicitLinearBoundary::buildMatrix( - SGPP::base::Grid* grid) { - //Build matrix (in the moment just by multiplying the OperationMatrix with the unit vectors): - OperationMatrix* opMatrix = SGPP::op_factory::createOperationLTwoDotProduct( - *grid); +void OperationMatrixLTwoDotExplicitLinearBoundary::buildMatrix(SGPP::base::Grid* grid) { + // Build matrix (in the moment just by multiplying the OperationMatrix with the unit vectors): + OperationMatrix* opMatrix = SGPP::op_factory::createOperationLTwoDotProduct(*grid); size_t size = grid->getStorage()->size(); SGPP::base::DataVector unit(size); @@ -47,22 +41,19 @@ void OperationMatrixLTwoDotExplicitLinearBoundary::buildMatrix( SGPP::base::DataVector result(size); for (size_t i = 0; i < size; i++) { - //Compute i-th unit vector - if (i > 0) - unit.set(i - 1, 0.0); + // Compute i-th unit vector + if (i > 0) unit.set(i - 1, 0.0); unit.set(i, 1.0); - //Multiply with operation matrix + // Multiply with operation matrix opMatrix->mult(unit, result); m_->setColumn(i, result); } } -void OperationMatrixLTwoDotExplicitLinearBoundary::mult( - SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { - +void OperationMatrixLTwoDotExplicitLinearBoundary::mult(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { size_t nrows = m_->getNrows(); size_t ncols = m_->getNcols(); @@ -72,7 +63,7 @@ void OperationMatrixLTwoDotExplicitLinearBoundary::mult( float_t* data = m_->getPointer(); - //Standard matrix multiplication: + // Standard matrix multiplication: float_t temp = 0.; size_t acc = 0; diff --git a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinearBoundary.hpp b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinearBoundary.hpp index fabb76a950..3a822a85e9 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinearBoundary.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitLinearBoundary.hpp @@ -12,32 +12,31 @@ #include - namespace SGPP { namespace pde { /** * Explicit representation of the matrix \f$(\Phi_i,\Phi_j)_{L2}\f$ for a sparse grid */ -class OperationMatrixLTwoDotExplicitLinearBoundary: public - SGPP::base::OperationMatrix { +class OperationMatrixLTwoDotExplicitLinearBoundary : public SGPP::base::OperationMatrix { public: /** * Constructor that uses a external matrix pointer to construct the matrix, - * i.e. matrix is NOT destroyed by the destructor of OperationMatrixLTwoDotExplicitLinearBoundaryFullGrid + * i.e. matrix is NOT destroyed by the destructor of + * OperationMatrixLTwoDotExplicitLinearBoundaryFullGrid * * @param m pointer to datamatrix of size (number of grid point) x (number of grid points) * @param grid the sparse grid */ - OperationMatrixLTwoDotExplicitLinearBoundary(SGPP::base::DataMatrix* m, - SGPP::base::Grid* grid); + OperationMatrixLTwoDotExplicitLinearBoundary(SGPP::base::DataMatrix* m, SGPP::base::Grid* grid); /** * Constructor that creates an own matrix - * i.e. matrix is destroyed by the destructor of OperationMatrixLTwoDotExplicitLinearBoundaryFullGrid + * i.e. matrix is destroyed by the destructor of + * OperationMatrixLTwoDotExplicitLinearBoundaryFullGrid * * @param grid the sparse grid */ - OperationMatrixLTwoDotExplicitLinearBoundary(SGPP::base::Grid* grid); + explicit OperationMatrixLTwoDotExplicitLinearBoundary(SGPP::base::Grid* grid); /** * Destructor @@ -50,8 +49,7 @@ class OperationMatrixLTwoDotExplicitLinearBoundary: public * @param alpha DataVector that is multiplied to the matrix * @param result DataVector into which the result of multiplication is stored */ - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); private: /** @@ -65,4 +63,4 @@ class OperationMatrixLTwoDotExplicitLinearBoundary: public } // namespace pde } // namespace SGPP -#endif /* OperationMatrixLTwoDotExplicitLinearBoundary_HPP_ */ \ No newline at end of file +#endif /* OperationMatrixLTwoDotExplicitLinearBoundary_HPP_ */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitPeriodic.cpp b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitPeriodic.cpp index b6ca3ef852..b964060476 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitPeriodic.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitPeriodic.cpp @@ -6,35 +6,32 @@ #include #include #include + +#include + #include #include #include #include -#include - - namespace SGPP { namespace pde { OperationMatrixLTwoDotExplicitPeriodic::OperationMatrixLTwoDotExplicitPeriodic( - SGPP::base::DataMatrix* m, - SGPP::base::Grid* grid) : - ownsMatrix_(false) { + SGPP::base::DataMatrix* m, SGPP::base::Grid* grid) + : ownsMatrix_(false) { m_ = m; buildMatrix(grid); } OperationMatrixLTwoDotExplicitPeriodic::OperationMatrixLTwoDotExplicitPeriodic( - SGPP::base::Grid* grid) : - ownsMatrix_(true) { - m_ = new SGPP::base::DataMatrix(grid->getStorage()->size(), - grid->getStorage()->size()); + SGPP::base::Grid* grid) + : ownsMatrix_(true) { + m_ = new SGPP::base::DataMatrix(grid->getStorage()->size(), grid->getStorage()->size()); buildMatrix(grid); } -void OperationMatrixLTwoDotExplicitPeriodic::buildMatrix( - SGPP::base::Grid* grid) { +void OperationMatrixLTwoDotExplicitPeriodic::buildMatrix(SGPP::base::Grid* grid) { size_t gridSize = grid->getStorage()->size(); size_t gridDim = grid->getStorage()->dim(); @@ -59,7 +56,7 @@ void OperationMatrixLTwoDotExplicitPeriodic::buildMatrix( std::swap(iik, ijk); } - if (lik == 1) { // level 0 + if (lik == 1) { // level 0 if (ljk > 2) { lik = 2; iik = 1; @@ -70,10 +67,9 @@ void OperationMatrixLTwoDotExplicitPeriodic::buildMatrix( ijk = ijk - ljk / 2; } - //Use formula for different overlapping ansatz functions: - float_t diff = (ijk / ljk) - (iik / lik); // x_j_k - x_i_k - float_t temp_res = fabs(diff - (1 / ljk)) - + fabs(diff + (1 / ljk)) - fabs(diff); + // Use formula for different overlapping ansatz functions: + float_t diff = (ijk / ljk) - (iik / lik); // x_j_k - x_i_k + float_t temp_res = fabs(diff - (1 / ljk)) + fabs(diff + (1 / ljk)) - fabs(diff); temp_res *= lik; temp_res = (1 - temp_res) / ljk; res *= temp_res; @@ -85,26 +81,25 @@ void OperationMatrixLTwoDotExplicitPeriodic::buildMatrix( res *= 1.0 / (3 * ljk); } } else if (lik == ljk) { - if (iik == ijk) { // case 4 - //Use formula for identical ansatz functions: + if (iik == ijk) { // case 4 + // Use formula for identical ansatz functions: res *= 2.0 / lik / 3; - } else { //case 0 - //Different index, but same level => ansatz functions do not overlap: + } else { // case 0 + // Different index, but same level => ansatz functions do not overlap: res = 0.; break; } } else { - if (std::max((iik - 1) / lik, (ijk - 1) / ljk) - >= std::min((iik + 1) / lik, (ijk + 1) / ljk)) { - //Ansatz functions do not not overlap: + if (std::max((iik - 1) / lik, (ijk - 1) / ljk) >= + std::min((iik + 1) / lik, (ijk + 1) / ljk)) { + // Ansatz functions do not not overlap: res = 0.; break; } else { - //Use formula for different overlapping ansatz functions: + // Use formula for different overlapping ansatz functions: - float_t diff = (ijk / ljk) - (iik / lik); // x_j_k - x_i_k - float_t temp_res = fabs(diff - (1 / ljk)) - + fabs(diff + (1 / ljk)) - fabs(diff); + float_t diff = (ijk / ljk) - (iik / lik); // x_j_k - x_i_k + float_t temp_res = fabs(diff - (1 / ljk)) + fabs(diff + (1 / ljk)) - fabs(diff); temp_res *= lik; temp_res = (1 - temp_res) / ljk; res *= temp_res; @@ -119,13 +114,11 @@ void OperationMatrixLTwoDotExplicitPeriodic::buildMatrix( } OperationMatrixLTwoDotExplicitPeriodic::~OperationMatrixLTwoDotExplicitPeriodic() { - if (ownsMatrix_) - delete m_; + if (ownsMatrix_) delete m_; } void OperationMatrixLTwoDotExplicitPeriodic::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { - + SGPP::base::DataVector& result) { size_t nrows = m_->getNrows(); size_t ncols = m_->getNcols(); @@ -135,7 +128,7 @@ void OperationMatrixLTwoDotExplicitPeriodic::mult(SGPP::base::DataVector& alpha, float_t* data = m_->getPointer(); - //Standard matrix multiplication: + // Standard matrix multiplication: float_t temp = 0.; size_t acc = 0; @@ -152,7 +145,3 @@ void OperationMatrixLTwoDotExplicitPeriodic::mult(SGPP::base::DataVector& alpha, } // namespace pde } // namespace SGPP - - - - diff --git a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitPeriodic.hpp b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitPeriodic.hpp index 64e87bd3ed..73de9aa541 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitPeriodic.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotExplicitPeriodic.hpp @@ -6,22 +6,19 @@ #ifndef OPERATIONMATRIXLTWODOTEXPLICITPERIODIC_HPP #define OPERATIONMATRIXLTWODOTEXPLICITPERIODIC_HPP - #include #include #include #include - namespace SGPP { namespace pde { /** * Explicit representation of the matrix \f$(\Phi_i,\Phi_j)_{L2}\f$ for a sparse grid */ -class OperationMatrixLTwoDotExplicitPeriodic: public - SGPP::base::OperationMatrix { +class OperationMatrixLTwoDotExplicitPeriodic : public SGPP::base::OperationMatrix { public: /** * Constructor that uses a external matrix pointer to construct the matrix, @@ -29,14 +26,13 @@ class OperationMatrixLTwoDotExplicitPeriodic: public * @param m pointer to datamatrix of size (number of grid point) x (number of grid points) * @param grid the sparse grid */ - OperationMatrixLTwoDotExplicitPeriodic(SGPP::base::DataMatrix* m, - SGPP::base::Grid* grid); + OperationMatrixLTwoDotExplicitPeriodic(SGPP::base::DataMatrix* m, SGPP::base::Grid* grid); /** * Constructor that creates an own matrix * * @param grid the sparse grid */ - OperationMatrixLTwoDotExplicitPeriodic(SGPP::base::Grid* grid); + explicit OperationMatrixLTwoDotExplicitPeriodic(SGPP::base::Grid* grid); /** * Destructor @@ -49,8 +45,7 @@ class OperationMatrixLTwoDotExplicitPeriodic: public * @param alpha DataVector that is multiplied to the matrix * @param result DataVector into which the result of multiplication is stored */ - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); private: /** @@ -65,4 +60,4 @@ class OperationMatrixLTwoDotExplicitPeriodic: public } // namespace pde } // namespace SGPP -#endif /* OPERATIONMATRIXLTWODOTEXPLICITPERIODIC_HPP */ \ No newline at end of file +#endif /* OPERATIONMATRIXLTWODOTEXPLICITPERIODIC_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotPeriodic.cpp b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotPeriodic.cpp index a9dfbe6de6..65a76754f4 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotPeriodic.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotPeriodic.cpp @@ -8,20 +8,20 @@ #include +#include namespace SGPP { namespace pde { OperationMatrixLTwoDotPeriodic::OperationMatrixLTwoDotPeriodic( - SGPP::base::GridStorage* gridStorage) { + SGPP::base::GridStorage* gridStorage) { this->gridStorage = gridStorage; } -OperationMatrixLTwoDotPeriodic::~OperationMatrixLTwoDotPeriodic() { -} +OperationMatrixLTwoDotPeriodic::~OperationMatrixLTwoDotPeriodic() {} void OperationMatrixLTwoDotPeriodic::mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) { + SGPP::base::DataVector& result) { size_t nrows = gridStorage->size(); size_t ncols = gridStorage->size(); @@ -55,7 +55,7 @@ void OperationMatrixLTwoDotPeriodic::mult(SGPP::base::DataVector& alpha, std::swap(iik, ijk); } - if (lik == 1) { // level 0 + if (lik == 1) { // level 0 if (ljk > 2) { lik = 2; iik = 1; @@ -66,10 +66,9 @@ void OperationMatrixLTwoDotPeriodic::mult(SGPP::base::DataVector& alpha, ijk = ijk - ljk / 2; } - //Use formula for different overlapping ansatz functions: - float_t diff = (ijk / ljk) - (iik / lik); // x_j_k - x_i_k - float_t temp_res = fabs(diff - (1 / ljk)) - + fabs(diff + (1 / ljk)) - fabs(diff); + // Use formula for different overlapping ansatz functions: + float_t diff = (ijk / ljk) - (iik / lik); // x_j_k - x_i_k + float_t temp_res = fabs(diff - (1 / ljk)) + fabs(diff + (1 / ljk)) - fabs(diff); temp_res *= lik; temp_res = (1 - temp_res) / ljk; res *= temp_res; @@ -81,26 +80,25 @@ void OperationMatrixLTwoDotPeriodic::mult(SGPP::base::DataVector& alpha, res *= 1.0 / (3 * ljk); } } else if (lik == ljk) { - if (iik == ijk) { // case 4 - //Use formula for identical ansatz functions: + if (iik == ijk) { // case 4 + // Use formula for identical ansatz functions: res *= 2.0 / lik / 3; - } else { //case 0 - //Different index, but same level => ansatz functions do not overlap: + } else { // case 0 + // Different index, but same level => ansatz functions do not overlap: res = 0.; break; } } else { - if (std::max((iik - 1) / lik, (ijk - 1) / ljk) - >= std::min((iik + 1) / lik, (ijk + 1) / ljk)) { - //Ansatz functions do not not overlap: + if (std::max((iik - 1) / lik, (ijk - 1) / ljk) >= + std::min((iik + 1) / lik, (ijk + 1) / ljk)) { + // Ansatz functions do not not overlap: res = 0.; break; } else { - //Use formula for different overlapping ansatz functions: + // Use formula for different overlapping ansatz functions: - float_t diff = (ijk / ljk) - (iik / lik); // x_j_k - x_i_k - float_t temp_res = fabs(diff - (1 / ljk)) - + fabs(diff + (1 / ljk)) - fabs(diff); + float_t diff = (ijk / ljk) - (iik / lik); // x_j_k - x_i_k + float_t temp_res = fabs(diff - (1 / ljk)) + fabs(diff + (1 / ljk)) - fabs(diff); temp_res *= lik; temp_res = (1 - temp_res) / ljk; res *= temp_res; @@ -111,7 +109,7 @@ void OperationMatrixLTwoDotPeriodic::mult(SGPP::base::DataVector& alpha, row[j] = res; } - //Standard matrix multiplication: + // Standard matrix multiplication: float_t temp = 0.; for (size_t j = 0; j < ncols; j++) { @@ -121,5 +119,5 @@ void OperationMatrixLTwoDotPeriodic::mult(SGPP::base::DataVector& alpha, result[i] = temp; } } -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotPeriodic.hpp b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotPeriodic.hpp index c212587a9f..0d0279c644 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotPeriodic.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationMatrixLTwoDotPeriodic.hpp @@ -11,7 +11,6 @@ #include - namespace SGPP { namespace pde { @@ -19,14 +18,14 @@ namespace pde { * Implements the standard L 2 scalar product on periodic grids * */ -class OperationMatrixLTwoDotPeriodic: public SGPP::base::OperationMatrix { +class OperationMatrixLTwoDotPeriodic : public SGPP::base::OperationMatrix { public: /** * Constructor * * @param gridStorage pointer to the GridStorage of the grid */ - OperationMatrixLTwoDotPeriodic(SGPP::base::GridStorage* gridStorage); + explicit OperationMatrixLTwoDotPeriodic(SGPP::base::GridStorage* gridStorage); /** * Destructor @@ -39,15 +38,12 @@ class OperationMatrixLTwoDotPeriodic: public SGPP::base::OperationMatrix { * @param alpha DataVector that is multiplied to the matrix * @param result DataVector into which the result of multiplication is stored */ - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); - protected: + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); + protected: SGPP::base::GridStorage* gridStorage; }; - -} -} - +} // namespace pde +} // namespace SGPP #endif /* OPERATIONMATRIXLTWODOTPERIODIC_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemDirichlet.cpp b/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemDirichlet.cpp index 91d3668c24..c1c7974a92 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemDirichlet.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemDirichlet.cpp @@ -8,7 +8,6 @@ #include - namespace SGPP { namespace pde { @@ -17,14 +16,12 @@ OperationParabolicPDESolverSystemDirichlet::OperationParabolicPDESolverSystemDir this->numSumGridpointsComplete = 0; } -OperationParabolicPDESolverSystemDirichlet::~OperationParabolicPDESolverSystemDirichlet() { -} +OperationParabolicPDESolverSystemDirichlet::~OperationParabolicPDESolverSystemDirichlet() {} -void OperationParabolicPDESolverSystemDirichlet::mult(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result) { +void OperationParabolicPDESolverSystemDirichlet::mult(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { result.setAll(0.0); - if (this->tOperationMode == "ExEul") { applyMassMatrixInner(alpha, result); } else if (this->tOperationMode == "ImEul") { @@ -33,54 +30,45 @@ void OperationParabolicPDESolverSystemDirichlet::mult(SGPP::base::DataVector& SGPP::base::DataVector temp(result.getSize()); SGPP::base::DataVector temp2(result.getSize()); - #pragma omp parallel shared(alpha, result, temp, temp2) +#pragma omp parallel shared(alpha, result, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha, temp) - { - applyMassMatrixInner(alpha, temp); - } +#pragma omp task shared(alpha, temp) + { applyMassMatrixInner(alpha, temp); } - #pragma omp task shared (alpha, temp2) - { - applyLOperatorInner(alpha, temp2); - } +#pragma omp task shared(alpha, temp2) + { applyLOperatorInner(alpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result.add(temp); - result.axpy((-1.0)*this->TimestepSize, temp2); + result.axpy((-1.0) * this->TimestepSize, temp2); } else if (this->tOperationMode == "CrNic") { result.setAll(0.0); SGPP::base::DataVector temp(result.getSize()); SGPP::base::DataVector temp2(result.getSize()); - #pragma omp parallel shared(alpha, result, temp, temp2) +#pragma omp parallel shared(alpha, result, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha, temp) - { - applyMassMatrixInner(alpha, temp); - } +#pragma omp task shared(alpha, temp) + { applyMassMatrixInner(alpha, temp); } - #pragma omp task shared (alpha, temp2) - { - applyLOperatorInner(alpha, temp2); - } +#pragma omp task shared(alpha, temp2) + { applyLOperatorInner(alpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result.add(temp); - result.axpy((-0.5)*this->TimestepSize, temp2); - } else if (this->tOperationMode == "AdBas" - || this->tOperationMode == "AdBasC") { + result.axpy((-0.5) * this->TimestepSize, temp2); + } else if (this->tOperationMode == "AdBas" || this->tOperationMode == "AdBasC") { result.setAll(0.0); applyMassMatrixInner(alpha, result); @@ -99,7 +87,7 @@ void OperationParabolicPDESolverSystemDirichlet::mult(SGPP::base::DataVector& result.add(temp); applyLOperatorInner(alpha, temp); - result.axpy((-1.0)*this->TimestepSize, temp); + result.axpy((-1.0) * this->TimestepSize, temp); } else if (this->tOperationMode == "F23") { result.setAll(0.0); float_t tDiff = this->TimestepSize / this->TimestepSize_old; @@ -109,12 +97,12 @@ void OperationParabolicPDESolverSystemDirichlet::mult(SGPP::base::DataVector& result.mult(alpha0); } else { - throw new SGPP::base::algorithm_exception("OperationParabolicPDESolverSystem::mult : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + "OperationParabolicPDESolverSystem::mult : An unknown operation mode was specified!"); } } -SGPP::base::DataVector* -OperationParabolicPDESolverSystemDirichlet::generateRHS() { +SGPP::base::DataVector* OperationParabolicPDESolverSystemDirichlet::generateRHS() { SGPP::base::DataVector rhs_complete(this->alpha_complete->getSize()); if (this->tOperationMode == "ExEul") { @@ -124,21 +112,17 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { SGPP::base::DataVector temp2(rhs_complete.getSize()); SGPP::base::DataVector myAlpha(*this->alpha_complete); - #pragma omp parallel shared(myAlpha, temp, temp2) +#pragma omp parallel shared(myAlpha, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myAlpha, temp) - { - applyMassMatrixComplete(myAlpha, temp); - } +#pragma omp task shared(myAlpha, temp) + { applyMassMatrixComplete(myAlpha, temp); } - #pragma omp task shared (myAlpha, temp2) - { - applyLOperatorComplete(myAlpha, temp2); - } +#pragma omp task shared(myAlpha, temp2) + { applyLOperatorComplete(myAlpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } @@ -155,26 +139,22 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { SGPP::base::DataVector temp2(rhs_complete.getSize()); SGPP::base::DataVector myAlpha(*this->alpha_complete); - #pragma omp parallel shared(myAlpha, temp, temp2) +#pragma omp parallel shared(myAlpha, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myAlpha, temp) - { - applyMassMatrixComplete(myAlpha, temp); - } +#pragma omp task shared(myAlpha, temp) + { applyMassMatrixComplete(myAlpha, temp); } - #pragma omp task shared (myAlpha, temp2) - { - applyLOperatorComplete(myAlpha, temp2); - } +#pragma omp task shared(myAlpha, temp2) + { applyLOperatorComplete(myAlpha, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } rhs_complete.add(temp); - rhs_complete.axpy((0.5)*this->TimestepSize, temp2); + rhs_complete.axpy((0.5) * this->TimestepSize, temp2); } else if (this->tOperationMode == "AdBas") { rhs_complete.setAll(0.0); @@ -184,16 +164,14 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { applyMassMatrixComplete(*this->alpha_complete, temp); - #pragma omp parallel shared(myAlpha, temp) +#pragma omp parallel shared(myAlpha, temp) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myAlpha, temp) - { - applyLOperatorComplete(myAlpha, temp); - } +#pragma omp task shared(myAlpha, temp) + { applyLOperatorComplete(myAlpha, temp); } - #pragma omp taskwait +#pragma omp taskwait } } @@ -204,22 +182,20 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { applyMassMatrixComplete(*this->alpha_complete_old, temp_old); - #pragma omp parallel shared(myOldAlpha, temp_old) +#pragma omp parallel shared(myOldAlpha, temp_old) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (myOldAlpha, temp_old) - { - applyLOperatorComplete(myOldAlpha, temp_old); - } +#pragma omp task shared(myOldAlpha, temp_old) + { applyLOperatorComplete(myOldAlpha, temp_old); } - #pragma omp taskwait +#pragma omp taskwait } } temp_old.mult(this->TimestepSize / this->TimestepSize_old); temp.sub(temp_old); - rhs_complete.axpy((0.5)*this->TimestepSize, temp); + rhs_complete.axpy((0.5) * this->TimestepSize, temp); } else if (this->tOperationMode == "AdBasC") { rhs_complete.setAll(0.0); @@ -246,17 +222,16 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { SGPP::base::GridStorage::grid_map_iterator q; int length = 0; - for (SGPP::base::GridStorage::grid_map_iterator p = gs->begin(); p != gs->end(); - ++p) { + for (SGPP::base::GridStorage::grid_map_iterator p = gs->begin(); p != gs->end(); ++p) { q = ogs->find(p->first); if ((q->first)->equals(*p->first)) { size_t i = p->second; size_t j = q->second; - if (j < temp_tmp.getSize()) + if (j < temp_tmp.getSize()) { OldData[i] = DataTmp[j]; - else { + } else { OldData[i] = 0; } } else { @@ -305,7 +280,7 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { temp.add(temp3); */ - rhs_complete.axpy((0.5)*this->TimestepSize, temp); + rhs_complete.axpy((0.5) * this->TimestepSize, temp); } else if (this->tOperationMode == "MPR") { rhs_complete.setAll(0.0); @@ -317,14 +292,14 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { temp2.add(temp); applyLOperatorComplete(*this->alpha_complete, temp); - temp2.axpy((0.5)*this->TimestepSize, temp); - //rhs_complete.setAll(0.0); + temp2.axpy((0.5) * this->TimestepSize, temp); + // rhs_complete.setAll(0.0); applyMassMatrixComplete(*this->alpha_complete, temp); rhs_complete.add(temp); applyLOperatorComplete(temp2, temp); - rhs_complete.axpy((1.0)*this->TimestepSize, temp); + rhs_complete.axpy((1.0) * this->TimestepSize, temp); // applyMassMatrixComplete(*this->alpha_complete, rhs_complete); } else if (this->tOperationMode == "BDF2") { @@ -353,7 +328,6 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { float_t alpha1 = alpha0 * (tDiff - 1.0); float_t alpha2 = -alpha0 * (tDiff * tDiff / (tDiff + 1.0)); - SGPP::base::DataVector temp(this->alpha_complete->getSize()); SGPP::base::DataVector temp_old(this->alpha_complete->getSize()); @@ -370,7 +344,9 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { rhs_complete.add(temp); } else { - throw new SGPP::base::algorithm_exception("OperationParabolicPDESolverSystem::generateRHS : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + "OperationParabolicPDESolverSystem::generateRHS : An unknown operation mode was " + "specified!"); } // Now we have the right hand side, lets apply the riskfree rate for the next timestep @@ -391,52 +367,43 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { SGPP::base::DataVector temp(alpha_bound.getSize()); SGPP::base::DataVector temp2(alpha_bound.getSize()); - #pragma omp parallel shared(alpha_bound, temp, temp2) +#pragma omp parallel shared(alpha_bound, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha_bound, temp) - { - applyMassMatrixComplete(alpha_bound, temp); - } +#pragma omp task shared(alpha_bound, temp) + { applyMassMatrixComplete(alpha_bound, temp); } - #pragma omp task shared (alpha_bound, temp2) - { - applyLOperatorComplete(alpha_bound, temp2); - } +#pragma omp task shared(alpha_bound, temp2) + { applyLOperatorComplete(alpha_bound, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result_complete.add(temp); - result_complete.axpy((-1.0)*this->TimestepSize, temp2); + result_complete.axpy((-1.0) * this->TimestepSize, temp2); } else if (this->tOperationMode == "CrNic") { SGPP::base::DataVector temp(alpha_bound.getSize()); SGPP::base::DataVector temp2(alpha_bound.getSize()); - #pragma omp parallel shared(alpha_bound, temp, temp2) +#pragma omp parallel shared(alpha_bound, temp, temp2) { - #pragma omp single nowait +#pragma omp single nowait { - #pragma omp task shared (alpha_bound, temp) - { - applyMassMatrixComplete(alpha_bound, temp); - } +#pragma omp task shared(alpha_bound, temp) + { applyMassMatrixComplete(alpha_bound, temp); } - #pragma omp task shared (alpha_bound, temp2) - { - applyLOperatorComplete(alpha_bound, temp2); - } +#pragma omp task shared(alpha_bound, temp2) + { applyLOperatorComplete(alpha_bound, temp2); } - #pragma omp taskwait +#pragma omp taskwait } } result_complete.add(temp); - result_complete.axpy((-0.5)*this->TimestepSize, temp2); - } else if (this->tOperationMode == "AdBas" - || this->tOperationMode == "AdBasC") { + result_complete.axpy((-0.5) * this->TimestepSize, temp2); + } else if (this->tOperationMode == "AdBas" || this->tOperationMode == "AdBasC") { applyMassMatrixComplete(alpha_bound, result_complete); } else if (this->tOperationMode == "MPR") { applyMassMatrixComplete(alpha_bound, result_complete); @@ -449,10 +416,9 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { result_complete.add(temp); applyLOperatorComplete(alpha_bound, temp); - result_complete.axpy((-1.0)*this->TimestepSize, temp); + result_complete.axpy((-1.0) * this->TimestepSize, temp); } else if (this->tOperationMode == "F23") { - float_t tDiff = this->TimestepSize / this->TimestepSize_old; float_t alpha0 = 1.0 / (1.0 + tDiff); @@ -460,7 +426,9 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { result_complete.mult(alpha0); } else { - throw new SGPP::base::algorithm_exception("OperationParabolicPDESolverSystem::generateRHS : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + "OperationParabolicPDESolverSystem::generateRHS : An unknown operation mode was " + "specified!"); } rhs_complete.sub(result_complete); @@ -475,11 +443,10 @@ OperationParabolicPDESolverSystemDirichlet::generateRHS() { return this->rhs; } -SGPP::base::DataVector* -OperationParabolicPDESolverSystemDirichlet::getGridCoefficientsForCG() { +SGPP::base::DataVector* OperationParabolicPDESolverSystemDirichlet::getGridCoefficientsForCG() { this->GridConverter->calcInnerCoefs(*this->alpha_complete, *this->alpha_inner); return this->alpha_inner; } -} -} \ No newline at end of file +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemDirichlet.hpp b/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemDirichlet.hpp index 7f0108d3ed..aa501c3194 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemDirichlet.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemDirichlet.hpp @@ -12,7 +12,6 @@ #include - namespace SGPP { namespace pde { @@ -35,8 +34,8 @@ namespace pde { * on on the boundaries the iterative solver (CG or BiCGSTAB) has only to take * inner grid points into account. */ -class OperationParabolicPDESolverSystemDirichlet : public - SGPP::solver::OperationParabolicPDESolverSystem { +class OperationParabolicPDESolverSystemDirichlet + : public SGPP::solver::OperationParabolicPDESolverSystem { protected: /// Pointer to the alphas (ansatzfunctions' coefficients; inner points only) SGPP::base::DataVector* alpha_inner; @@ -98,10 +97,10 @@ class OperationParabolicPDESolverSystemDirichlet : public * Multiplicates a vector with the matrix * * @param alpha SGPP::base::DataVector that contains the ansatzfunctions' coefficients - * @param result SGPP::base::DataVector into which the result of the space discretization operation is stored + * @param result SGPP::base::DataVector into which the result of the space discretization + * operation is stored */ - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); /** * generates the right hand side of the system @@ -112,8 +111,7 @@ class OperationParabolicPDESolverSystemDirichlet : public virtual SGPP::base::DataVector* getGridCoefficientsForCG(); }; - -} -} +} // namespace pde +} // namespace SGPP #endif /* OPERATIONPARABOLICPDESOLVERSYSTEMDIRICHLET_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemFreeBoundaries.cpp b/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemFreeBoundaries.cpp index 4e05ffb58e..e77cacdd8e 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemFreeBoundaries.cpp +++ b/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemFreeBoundaries.cpp @@ -8,7 +8,6 @@ #include - namespace SGPP { namespace pde { @@ -17,11 +16,11 @@ OperationParabolicPDESolverSystemFreeBoundaries::OperationParabolicPDESolverSyst this->numSumGridpointsComplete = 0; } -OperationParabolicPDESolverSystemFreeBoundaries::~OperationParabolicPDESolverSystemFreeBoundaries() { -} +OperationParabolicPDESolverSystemFreeBoundaries:: + ~OperationParabolicPDESolverSystemFreeBoundaries() {} -void OperationParabolicPDESolverSystemFreeBoundaries::mult( - SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) { +void OperationParabolicPDESolverSystemFreeBoundaries::mult(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result) { if (this->tOperationMode == "ExEul") { applyMassMatrix(alpha, result); } else if (this->tOperationMode == "ImEul") { @@ -33,7 +32,7 @@ void OperationParabolicPDESolverSystemFreeBoundaries::mult( result.add(temp); applyLOperator(alpha, temp); - result.axpy((-1.0)*this->TimestepSize, temp); + result.axpy((-1.0) * this->TimestepSize, temp); } else if (this->tOperationMode == "CrNic") { result.setAll(0.0); @@ -43,7 +42,7 @@ void OperationParabolicPDESolverSystemFreeBoundaries::mult( result.add(temp); applyLOperator(alpha, temp); - result.axpy((-0.5)*this->TimestepSize, temp); + result.axpy((-0.5) * this->TimestepSize, temp); } else if (this->tOperationMode == "AdBas") { result.setAll(0.0); @@ -61,7 +60,7 @@ void OperationParabolicPDESolverSystemFreeBoundaries::mult( result.add(temp); applyLOperator(alpha, temp); - result.axpy((-1.0)*this->TimestepSize, temp); + result.axpy((-1.0) * this->TimestepSize, temp); } else if (this->tOperationMode == "F23") { result.setAll(0.0); float_t tDiff = this->TimestepSize / this->TimestepSize_old; @@ -71,12 +70,13 @@ void OperationParabolicPDESolverSystemFreeBoundaries::mult( result.mult(alpha0); } else { - throw new SGPP::base::algorithm_exception("OperationParabolicPDESolverSystemNeumann::mult : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + "OperationParabolicPDESolverSystemNeumann::mult : An unknown operation mode was " + "specified!"); } } -SGPP::base::DataVector* -OperationParabolicPDESolverSystemFreeBoundaries::generateRHS() { +SGPP::base::DataVector* OperationParabolicPDESolverSystemFreeBoundaries::generateRHS() { SGPP::base::DataVector rhs_complete(this->alpha_complete->getSize()); if (this->tOperationMode == "ExEul") { @@ -102,7 +102,7 @@ OperationParabolicPDESolverSystemFreeBoundaries::generateRHS() { rhs_complete.add(temp); applyLOperator(*this->alpha_complete, temp); - rhs_complete.axpy((0.5)*this->TimestepSize, temp); + rhs_complete.axpy((0.5) * this->TimestepSize, temp); } else if (this->tOperationMode == "AdBas") { rhs_complete.setAll(0.0); @@ -121,7 +121,7 @@ OperationParabolicPDESolverSystemFreeBoundaries::generateRHS() { temp_old.mult(this->TimestepSize / this->TimestepSize_old); temp.sub(temp_old); - rhs_complete.axpy((0.5)*this->TimestepSize, temp); + rhs_complete.axpy((0.5) * this->TimestepSize, temp); } else if (this->tOperationMode == "BDF2") { rhs_complete.setAll(0.0); @@ -148,7 +148,6 @@ OperationParabolicPDESolverSystemFreeBoundaries::generateRHS() { float_t alpha1 = alpha0 * (tDiff - 1.0); float_t alpha2 = -alpha0 * (tDiff * tDiff / (tDiff + 1.0)); - SGPP::base::DataVector temp(this->alpha_complete->getSize()); SGPP::base::DataVector temp_old(this->alpha_complete->getSize()); @@ -165,7 +164,9 @@ OperationParabolicPDESolverSystemFreeBoundaries::generateRHS() { rhs_complete.add(temp); } else { - throw new SGPP::base::algorithm_exception("OperationParabolicPDESolverSystemNeumann::generateRHS : An unknown operation mode was specified!"); + throw new SGPP::base::algorithm_exception( + "OperationParabolicPDESolverSystemNeumann::generateRHS : An unknown operation mode was " + "specified!"); } // Now we have the right hand side, lets apply the riskfree rate for the next timestep @@ -184,6 +185,5 @@ SGPP::base::DataVector* OperationParabolicPDESolverSystemFreeBoundaries::getGridCoefficientsForCG() { return this->alpha_complete; } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemFreeBoundaries.hpp b/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemFreeBoundaries.hpp index 44756823ed..3d7ed1d7e5 100644 --- a/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemFreeBoundaries.hpp +++ b/pde/src/sgpp/pde/operation/hash/OperationParabolicPDESolverSystemFreeBoundaries.hpp @@ -10,7 +10,6 @@ #include - namespace SGPP { namespace pde { @@ -28,8 +27,8 @@ namespace pde { * using an iterative SLE solver, that solving step is integrated in the * ODE Solver. */ -class OperationParabolicPDESolverSystemFreeBoundaries : public - SGPP::solver::OperationParabolicPDESolverSystem { +class OperationParabolicPDESolverSystemFreeBoundaries + : public SGPP::solver::OperationParabolicPDESolverSystem { protected: /** * applies the PDE's mass matrix, on complete grid - with boundaries @@ -37,8 +36,7 @@ class OperationParabolicPDESolverSystemFreeBoundaries : public * @param alpha the coefficients of the sparse grid's ansatzfunctions * @param result reference to the SGPP::base::DataVector into which the result is written */ - virtual void applyMassMatrix(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) = 0; + virtual void applyMassMatrix(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) = 0; /** * applies the PDE's system matrix, on complete grid - with boundaries @@ -46,8 +44,7 @@ class OperationParabolicPDESolverSystemFreeBoundaries : public * @param alpha the coefficients of the sparse grid's ansatzfunctions * @param result reference to the SGPP::base::DataVector into which the result is written */ - virtual void applyLOperator(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) = 0; + virtual void applyLOperator(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) = 0; public: /** @@ -60,15 +57,13 @@ class OperationParabolicPDESolverSystemFreeBoundaries : public */ virtual ~OperationParabolicPDESolverSystemFreeBoundaries(); - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result); + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result); virtual SGPP::base::DataVector* generateRHS(); virtual SGPP::base::DataVector* getGridCoefficientsForCG(); }; - -} -} +} // namespace pde +} // namespace SGPP #endif /* OPERATIONPARABOLICPDESOLVERSYSTEMFREEBOUNDARIES_HPP */ diff --git a/pde/src/sgpp/pde/operation/hash/UpdPhidPhiBBIterativeLinearBoundary.cpp b/pde/src/sgpp/pde/operation/hash/UpdPhidPhiBBIterativeLinearBoundary.cpp index 980ad2ad1d..c3d74003bd 100644 --- a/pde/src/sgpp/pde/operation/hash/UpdPhidPhiBBIterativeLinearBoundary.cpp +++ b/pde/src/sgpp/pde/operation/hash/UpdPhidPhiBBIterativeLinearBoundary.cpp @@ -8,19 +8,17 @@ #include - namespace SGPP { namespace pde { UpdPhidPhiBBIterativeLinearBoundary::UpdPhidPhiBBIterativeLinearBoundary( - SGPP::base::GridStorage* storage) : storage(storage) { -} + SGPP::base::GridStorage* storage) + : storage(storage) {} -UpdPhidPhiBBIterativeLinearBoundary::~UpdPhidPhiBBIterativeLinearBoundary() { -} +UpdPhidPhiBBIterativeLinearBoundary::~UpdPhidPhiBBIterativeLinearBoundary() {} -void UpdPhidPhiBBIterativeLinearBoundary::operator()(SGPP::base::DataVector& - alpha, SGPP::base::DataVector& result, size_t dim) { +void UpdPhidPhiBBIterativeLinearBoundary::operator()(SGPP::base::DataVector& alpha, + SGPP::base::DataVector& result, size_t dim) { // Bounding Box handling SGPP::base::BoundingBox* boundingBox = this->storage->getBoundingBox(); float_t q = boundingBox->getIntervalWidth(dim); @@ -69,6 +67,5 @@ void UpdPhidPhiBBIterativeLinearBoundary::operator()(SGPP::base::DataVector& } } } - -} -} +} // namespace pde +} // namespace SGPP diff --git a/pde/src/sgpp/pde/operation/hash/UpdPhidPhiBBIterativeLinearBoundary.hpp b/pde/src/sgpp/pde/operation/hash/UpdPhidPhiBBIterativeLinearBoundary.hpp index ab56920bf6..2bb2ce2fee 100644 --- a/pde/src/sgpp/pde/operation/hash/UpdPhidPhiBBIterativeLinearBoundary.hpp +++ b/pde/src/sgpp/pde/operation/hash/UpdPhidPhiBBIterativeLinearBoundary.hpp @@ -11,7 +11,6 @@ #include - namespace SGPP { namespace pde { @@ -38,7 +37,7 @@ class UpdPhidPhiBBIterativeLinearBoundary { * * @param storage Pointer to the grid's storage object */ - UpdPhidPhiBBIterativeLinearBoundary(SGPP::base::GridStorage* storage); + explicit UpdPhidPhiBBIterativeLinearBoundary(SGPP::base::GridStorage* storage); /** * Destructor @@ -47,17 +46,17 @@ class UpdPhidPhiBBIterativeLinearBoundary { /** * This operations performs the calculation of Up in the direction of dimension dim - * of following bilinearform: \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} dx\f$ + * of following bilinearform: \f$\int_{x} \frac{\partial \phi(x)}{x} \frac{\partial \phi(x)}{x} + * dx\f$ * * @param alpha SGPP::base::DataVector that contains the gridpoint's coefficients * @param result SGPP::base::DataVector that contains the result of the down operation * @param dim current fixed dimension of the 'execution direction' */ - virtual void operator()(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result, size_t dim); + virtual void operator()(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result, + size_t dim); }; +} // namespace pde +} // namespace SGPP -} -} - -#endif /* UPDPHIDPHIDOWNBBITERATIVELINEARBOUNDARY_HPP */ \ No newline at end of file +#endif /* UPDPHIDPHIDOWNBBITERATIVELINEARBOUNDARY_HPP */ diff --git a/pde/src/sgpp_pde.hpp b/pde/src/sgpp_pde.hpp index 01838a86b6..774e92a47e 100644 --- a/pde/src/sgpp_pde.hpp +++ b/pde/src/sgpp_pde.hpp @@ -6,7 +6,6 @@ #ifndef PDE_HPP #define PDE_HPP - #include #include #include diff --git a/quadrature/SConscript b/quadrature/SConscript index c7534c9d08..c1e7582c89 100755 --- a/quadrature/SConscript +++ b/quadrature/SConscript @@ -16,6 +16,7 @@ Import('installTargetList') Import('exampleTargetList') Import('headerSourceList') Import('headerDestList') +Import('lintAction') moduleDependencies = ['sgppbase'] Export('moduleDependencies') @@ -27,18 +28,21 @@ if env['USE_STATICLIB']: moduleDependencies[i] = "%sstatic" % moduleDependencies[i] Export('libname') -srcs = [] +cpps = [] +hpps = [] +objs = [] + for currentFolder, subdirNames, fileNames in os.walk("src"): for fileName in fnmatch.filter(fileNames, '*.cpp'): - srcs.append(os.path.join(currentFolder, fileName)) + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) if currentFolder != 'src': for fileName in fnmatch.filter(fileNames, '*.hpp'): - headerSourceList.append(os.path.join(moduleName, currentFolder, fileName)) - headerDestList.append(os.path.join(currentFolder, fileName).split(os.sep,1)[1]) - -objs = [] -for sourceFile in srcs: - objs.append(env.SharedObject(sourceFile)) + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + headerSourceList.append(os.path.join(moduleName, hpp)) + headerDestList.append(hpp.split(os.sep, 1)[1]) if env['USE_STATICLIB']: # building static libraries is the same for unix and windows platforms @@ -63,6 +67,11 @@ for lib_str in moduleDependencies: libInstall = env.Install(BUILD_DIR, lib) +if env['RUN_CPPLINT']: + for path in cpps + hpps: + lintCommand = env.Command(path + ".lint", path, lintAction) + env.Depends(lib, lintCommand) + if not env['NO_UNIT_TESTS'] and env['SG_PYTHON']: Import('testTargetList') py_test_env = env.Clone() diff --git a/quadrature/src/sgpp/quadrature/QuadratureOpFactory.cpp b/quadrature/src/sgpp/quadrature/QuadratureOpFactory.cpp index e5b216b964..eb4107f9a3 100644 --- a/quadrature/src/sgpp/quadrature/QuadratureOpFactory.cpp +++ b/quadrature/src/sgpp/quadrature/QuadratureOpFactory.cpp @@ -11,10 +11,8 @@ namespace SGPP { namespace op_factory { quadrature::OperationQuadratureMCAdvanced* createOperationQuadratureMCAdvanced( - base::Grid& grid, size_t numberOfSamples, - std::uint64_t seed) { - return new quadrature::OperationQuadratureMCAdvanced(grid, numberOfSamples, - seed); + base::Grid& grid, size_t numberOfSamples, std::uint64_t seed) { + return new quadrature::OperationQuadratureMCAdvanced(grid, numberOfSamples, seed); } } // namespace op_factory diff --git a/quadrature/src/sgpp/quadrature/QuadratureOpFactory.hpp b/quadrature/src/sgpp/quadrature/QuadratureOpFactory.hpp index 7ee4c97efa..75103f0ad3 100644 --- a/quadrature/src/sgpp/quadrature/QuadratureOpFactory.hpp +++ b/quadrature/src/sgpp/quadrature/QuadratureOpFactory.hpp @@ -10,11 +10,11 @@ * This file contains factory methods for operations. */ -#include #include - #include +#include + namespace SGPP { namespace op_factory { @@ -26,8 +26,7 @@ namespace op_factory { * @param seed Custom seed (defaults to default seed of mt19937_64) */ quadrature::OperationQuadratureMCAdvanced* createOperationQuadratureMCAdvanced( - base::Grid& grid, size_t numberOfSamples, - std::uint64_t seed = std::mt19937_64::default_seed); + base::Grid& grid, size_t numberOfSamples, std::uint64_t seed = std::mt19937_64::default_seed); } // namespace op_factory } // namespace SGPP diff --git a/quadrature/src/sgpp/quadrature/Random.cpp b/quadrature/src/sgpp/quadrature/Random.cpp index e22bf33854..f9f5dbbec5 100644 --- a/quadrature/src/sgpp/quadrature/Random.cpp +++ b/quadrature/src/sgpp/quadrature/Random.cpp @@ -13,9 +13,9 @@ namespace quadrature { bool Random::is_seeded = false; std::mt19937_64 Random::gen = std::mt19937_64(); std::uniform_int_distribution Random::distInt = - std::uniform_int_distribution(0, RAND_MAX); + std::uniform_int_distribution(0, RAND_MAX); std::uniform_real_distribution Random::distReal = - std::uniform_real_distribution(0, 1); + std::uniform_real_distribution(0, 1); void Random::seed(std::uint64_t seed_value) { gen.seed(seed_value); @@ -38,5 +38,5 @@ float_t Random::random_double() { return distReal(gen); } -} -} +} // namespace quadrature +} // namespace SGPP diff --git a/quadrature/src/sgpp/quadrature/Random.hpp b/quadrature/src/sgpp/quadrature/Random.hpp index b251672609..eba93593ea 100644 --- a/quadrature/src/sgpp/quadrature/Random.hpp +++ b/quadrature/src/sgpp/quadrature/Random.hpp @@ -5,10 +5,10 @@ #ifndef RANDOM_HPP #define RANDOM_HPP -#include #include +#include namespace SGPP { namespace quadrature { @@ -19,7 +19,6 @@ namespace quadrature { class Random { public: - /** * Manually seed the generator with a given seed. * @param seed_value the seed to use. @@ -43,7 +42,7 @@ class Random { static std::uniform_int_distribution distInt; static std::uniform_real_distribution distReal; }; -} -} +} // namespace quadrature +} // namespace SGPP #endif /* RANDOM_HPP */ diff --git a/quadrature/src/sgpp/quadrature/operation/hash/OperationQuadratureMCAdvanced.cpp b/quadrature/src/sgpp/quadrature/operation/hash/OperationQuadratureMCAdvanced.cpp index 76a95e7df8..66398834b4 100644 --- a/quadrature/src/sgpp/quadrature/operation/hash/OperationQuadratureMCAdvanced.cpp +++ b/quadrature/src/sgpp/quadrature/operation/hash/OperationQuadratureMCAdvanced.cpp @@ -7,8 +7,6 @@ #include #include #include -#include -#include #include #include #include @@ -16,20 +14,25 @@ #include #include +#include +#include +#include + namespace SGPP { namespace quadrature { -OperationQuadratureMCAdvanced::OperationQuadratureMCAdvanced( - SGPP::base::Grid& grid, size_t numberOfSamples, std::uint64_t seed) : - grid(&grid), numberOfSamples(numberOfSamples), seed(seed) { +OperationQuadratureMCAdvanced::OperationQuadratureMCAdvanced(SGPP::base::Grid& grid, + size_t numberOfSamples, + std::uint64_t seed) + : grid(&grid), numberOfSamples(numberOfSamples), seed(seed) { dimensions = grid.getStorage()->dim(); myGenerator = new SGPP::quadrature::NaiveSampleGenerator(dimensions, seed); } OperationQuadratureMCAdvanced::OperationQuadratureMCAdvanced(size_t dimensions, - size_t numberOfSamples, std::uint64_t seed) : - grid(NULL), numberOfSamples(numberOfSamples), dimensions(dimensions), - seed(seed) { + size_t numberOfSamples, + std::uint64_t seed) + : grid(NULL), numberOfSamples(numberOfSamples), dimensions(dimensions), seed(seed) { myGenerator = new SGPP::quadrature::NaiveSampleGenerator(dimensions, seed); } @@ -48,13 +51,12 @@ void OperationQuadratureMCAdvanced::useNaiveMonteCarlo() { } void OperationQuadratureMCAdvanced::useStratifiedMonteCarlo( - std::vector& strataPerDimension) { + std::vector& strataPerDimension) { if (myGenerator != NULL) { delete myGenerator; } - myGenerator = new SGPP::quadrature::StratifiedSampleGenerator( - strataPerDimension, seed); + myGenerator = new SGPP::quadrature::StratifiedSampleGenerator(strataPerDimension, seed); } void OperationQuadratureMCAdvanced::useLatinHypercubeMonteCarlo() { @@ -62,8 +64,8 @@ void OperationQuadratureMCAdvanced::useLatinHypercubeMonteCarlo() { delete myGenerator; } - myGenerator = new SGPP::quadrature::LatinHypercubeSampleGenerator( - dimensions, numberOfSamples, seed); + myGenerator = + new SGPP::quadrature::LatinHypercubeSampleGenerator(dimensions, numberOfSamples, seed); } void OperationQuadratureMCAdvanced::useQuasiMonteCarloWithHaltonSequences() { @@ -74,23 +76,20 @@ void OperationQuadratureMCAdvanced::useQuasiMonteCarloWithHaltonSequences() { myGenerator = new SGPP::quadrature::HaltonSampleGenerator(dimensions); } -float_t OperationQuadratureMCAdvanced::doQuadrature( - SGPP::base::DataVector& alpha) { - +float_t OperationQuadratureMCAdvanced::doQuadrature(SGPP::base::DataVector& alpha) { SGPP::base::DataMatrix dm(numberOfSamples, dimensions); myGenerator->getSamples(dm); SGPP::base::OperationMultipleEval* opEval = - SGPP::op_factory::createOperationMultipleEval(*grid, dm); + SGPP::op_factory::createOperationMultipleEval(*grid, dm); SGPP::base::DataVector res = SGPP::base::DataVector(numberOfSamples); opEval->mult(alpha, res); return res.sum() / static_cast(numberOfSamples); } -float_t OperationQuadratureMCAdvanced::doQuadratureFunc(FUNC func, - void* clientdata) { - //float_t* p = new float_t[dimensions]; +float_t OperationQuadratureMCAdvanced::doQuadratureFunc(FUNC func, void* clientdata) { + // float_t* p = new float_t[dimensions]; SGPP::base::DataMatrix dm(numberOfSamples, dimensions); myGenerator->getSamples(dm); @@ -101,22 +100,20 @@ float_t OperationQuadratureMCAdvanced::doQuadratureFunc(FUNC func, for (size_t i = 0; i < numberOfSamples; i++) { SGPP::base::DataVector dv(dimensions); dm.getRow(i, dv); - res += func(*reinterpret_cast(&dimensions), dv.getPointer(), - clientdata); + res += func(*reinterpret_cast(&dimensions), dv.getPointer(), clientdata); } - //delete p; + // delete p; return res / static_cast(numberOfSamples); } -float_t OperationQuadratureMCAdvanced::doQuadratureL2Error(FUNC func, - void* clientdata, SGPP::base::DataVector& alpha) { +float_t OperationQuadratureMCAdvanced::doQuadratureL2Error(FUNC func, void* clientdata, + SGPP::base::DataVector& alpha) { float_t x; float_t* p = new float_t[dimensions]; SGPP::base::DataVector point(dimensions); - SGPP::base::OperationEval* opEval = SGPP::op_factory::createOperationEval( - *grid); + SGPP::base::OperationEval* opEval = SGPP::op_factory::createOperationEval(*grid); // create number of paths (uniformly drawn from [0,1]^d) float_t res = 0; @@ -128,18 +125,14 @@ float_t OperationQuadratureMCAdvanced::doQuadratureL2Error(FUNC func, } res += pow( - func(*reinterpret_cast(&dimensions), p, clientdata) - - opEval->eval(alpha, point), 2); + func(*reinterpret_cast(&dimensions), p, clientdata) - opEval->eval(alpha, point), 2); } delete p; return sqrt(res / static_cast(numberOfSamples)); } -size_t OperationQuadratureMCAdvanced::getDimensions() { - return dimensions; -} +size_t OperationQuadratureMCAdvanced::getDimensions() { return dimensions; } -} - -} +} // namespace quadrature +} // namespace SGPP diff --git a/quadrature/src/sgpp/quadrature/operation/hash/OperationQuadratureMCAdvanced.hpp b/quadrature/src/sgpp/quadrature/operation/hash/OperationQuadratureMCAdvanced.hpp index 13b9a92127..832d16dc0a 100644 --- a/quadrature/src/sgpp/quadrature/operation/hash/OperationQuadratureMCAdvanced.hpp +++ b/quadrature/src/sgpp/quadrature/operation/hash/OperationQuadratureMCAdvanced.hpp @@ -11,12 +11,15 @@ #include #include +#include namespace SGPP { namespace quadrature { /** - * Typedef for general functions that can be passed to integration methods. Requires three parameters. First, the dimensionality, then dim-many coordinates, and then further client data for the function at hand. + * Typedef for general functions that can be passed to integration methods. Requires three + * parameters. First, the dimensionality, then dim-many coordinates, and then further client data + * for the function at hand. */ typedef float_t (*FUNC)(int, float_t*, void*); @@ -25,10 +28,8 @@ typedef float_t (*FUNC)(int, float_t*, void*); * using various Monte Carlo Methods (Advanced). */ -class OperationQuadratureMCAdvanced: public SGPP::base::OperationQuadrature { - +class OperationQuadratureMCAdvanced : public SGPP::base::OperationQuadrature { public: - /** * @brief Constructor of OperationQuadratureMCAdvanced, specifying a grid * object and the number of samples to use. @@ -82,8 +83,7 @@ class OperationQuadratureMCAdvanced: public SGPP::base::OperationQuadrature { * @param clientdata Optional data to pass to FUNC * @param alpha Coefficient vector for current grid */ - float_t doQuadratureL2Error(FUNC func, void* clientdata, - SGPP::base::DataVector& alpha); + float_t doQuadratureL2Error(FUNC func, void* clientdata, SGPP::base::DataVector& alpha); /** * @brief Initialize SampleGenerator for NaiveMC @@ -126,12 +126,11 @@ class OperationQuadratureMCAdvanced: public SGPP::base::OperationQuadrature { // seed for the sample generator std::uint64_t seed; - //SampleGenerator Instance + // SampleGenerator Instance SGPP::quadrature::SampleGenerator* myGenerator; - }; -} -} +} // namespace quadrature +} // namespace SGPP #endif /* OPERATIONQUADRATUREMCADVANCED_HPP */ diff --git a/quadrature/src/sgpp/quadrature/sampling/HaltonSampleGenerator.cpp b/quadrature/src/sgpp/quadrature/sampling/HaltonSampleGenerator.cpp index 47a2eb525f..c478eb1fff 100644 --- a/quadrature/src/sgpp/quadrature/sampling/HaltonSampleGenerator.cpp +++ b/quadrature/src/sgpp/quadrature/sampling/HaltonSampleGenerator.cpp @@ -4,28 +4,23 @@ // sgpp.sparsegrids.org #include - -#include #include +#include #include -using namespace SGPP::base; - namespace SGPP { namespace quadrature { -HaltonSampleGenerator::HaltonSampleGenerator(size_t dimensions, - std::uint64_t seed) : - SampleGenerator(dimensions, seed), - index(1), - baseVector(dimensions), - iVector(dimensions), - fVector(dimensions), - resultVector(dimensions), - distInt(0, 15) { - size_t basePrimes[] = - { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47 }; +HaltonSampleGenerator::HaltonSampleGenerator(size_t dimensions, std::uint64_t seed) + : SampleGenerator(dimensions, seed), + index(1), + baseVector(dimensions), + iVector(dimensions), + fVector(dimensions), + resultVector(dimensions), + distInt(0, 15) { + size_t basePrimes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47}; for (size_t i = 0; i < dimensions; i++) { baseVector[i] = basePrimes[distInt(rng)]; @@ -34,23 +29,19 @@ HaltonSampleGenerator::HaltonSampleGenerator(size_t dimensions, } } -HaltonSampleGenerator::~HaltonSampleGenerator() { -} +HaltonSampleGenerator::~HaltonSampleGenerator() {} void HaltonSampleGenerator::getSample(SGPP::base::DataVector& dv) { - for (size_t i = 0; i < dimensions; i++) { resultVector[i] = 0.; fVector[i] = 1. / static_cast(baseVector[i]); iVector[i] = static_cast(index); while (iVector[i] > 0) { - resultVector[i] = resultVector[i] - + fVector[i] - * ((float_t) ((size_t) iVector[i] % baseVector[i])); - iVector[i] = floor( - ((float_t) iVector[i]) / ((float_t) baseVector[i])); - fVector[i] = fVector[i] / ((float_t) baseVector[i]); + resultVector[i] = + resultVector[i] + fVector[i] * ((float_t)((size_t)iVector[i] % baseVector[i])); + iVector[i] = floor(((float_t)iVector[i]) / ((float_t)baseVector[i])); + fVector[i] = fVector[i] / ((float_t)baseVector[i]); } dv[i] = resultVector[i]; @@ -59,5 +50,5 @@ void HaltonSampleGenerator::getSample(SGPP::base::DataVector& dv) { index++; } -} -} +} // namespace quadrature +} // namespace SGPP diff --git a/quadrature/src/sgpp/quadrature/sampling/HaltonSampleGenerator.hpp b/quadrature/src/sgpp/quadrature/sampling/HaltonSampleGenerator.hpp index b99bb8ef4b..335b838b88 100644 --- a/quadrature/src/sgpp/quadrature/sampling/HaltonSampleGenerator.hpp +++ b/quadrature/src/sgpp/quadrature/sampling/HaltonSampleGenerator.hpp @@ -11,6 +11,8 @@ #include #include +#include + namespace SGPP { namespace quadrature { @@ -18,17 +20,15 @@ namespace quadrature { * */ class HaltonSampleGenerator : public SampleGenerator { - public: - /** * Standard constructor * * @param dimension number of dimensions used for sample generation * @param seed custom seed (defaults to default seed of mt19937_64) */ - HaltonSampleGenerator(size_t dimension, - std::uint64_t seed = std::mt19937_64::default_seed); + explicit HaltonSampleGenerator(size_t dimension, + std::uint64_t seed = std::mt19937_64::default_seed); /** * Destructor @@ -53,7 +53,7 @@ class HaltonSampleGenerator : public SampleGenerator { std::uniform_int_distribution distInt; }; -} -} +} // namespace quadrature +} // namespace SGPP #endif /* HALTONSAMPLEGENERATOR_HPP */ diff --git a/quadrature/src/sgpp/quadrature/sampling/LatinHypercubeSampleGenerator.cpp b/quadrature/src/sgpp/quadrature/sampling/LatinHypercubeSampleGenerator.cpp index 71e70b66bf..ec38026da9 100644 --- a/quadrature/src/sgpp/quadrature/sampling/LatinHypercubeSampleGenerator.cpp +++ b/quadrature/src/sgpp/quadrature/sampling/LatinHypercubeSampleGenerator.cpp @@ -4,30 +4,27 @@ // sgpp.sparsegrids.org #include +#include +#include #include #include #include #include -#include -#include - -using namespace SGPP::base; - namespace SGPP { namespace quadrature { LatinHypercubeSampleGenerator::LatinHypercubeSampleGenerator(size_t dimensions, - size_t numberOfStrata, std::uint64_t seed) : - SampleGenerator(dimensions, seed), - numberOfStrata( - numberOfStrata), // each dimension is divided in n strata to provide n sample points - numberOfCurrentSample(1), // index number of current sample [1, n] - sizeOfStrata(1. / static_cast - (numberOfStrata)), // equidistant split of [0,1] in n strata -> size of one stratum = 1 / n - uniformRealDist(0, 1) { - + size_t numberOfStrata, + std::uint64_t seed) + : SampleGenerator(dimensions, seed), + numberOfStrata( + numberOfStrata), // each dimension is divided in n strata to provide n sample points + numberOfCurrentSample(1), // index number of current sample [1, n] + // equidistant split of [0,1] in n strata -> size of one stratum = 1 / n + sizeOfStrata(1. / static_cast(numberOfStrata)), + uniformRealDist(0, 1) { for (size_t i = 0; i < dimensions; i++) { currentStrata.push_back(std::vector()); @@ -39,19 +36,18 @@ LatinHypercubeSampleGenerator::LatinHypercubeSampleGenerator(size_t dimensions, shuffleStrataSequence(); } -LatinHypercubeSampleGenerator::~LatinHypercubeSampleGenerator() { -} +LatinHypercubeSampleGenerator::~LatinHypercubeSampleGenerator() {} void LatinHypercubeSampleGenerator::getSample(SGPP::base::DataVector& sample) { - // compute random value inside the current stratum selected from the shuffled strata sequence for (size_t i = 0; i < dimensions; i++) { sample[i] = - (static_cast(currentStrata[i][numberOfCurrentSample - 1]) - + uniformRealDist(rng)) * sizeOfStrata; + (static_cast(currentStrata[i][numberOfCurrentSample - 1]) + uniformRealDist(rng)) * + sizeOfStrata; } - // select next sample from strata sequence. If one sequence is complete shuffle strata to get a new one. + // select next sample from strata sequence. + // If one sequence is complete shuffle strata to get a new one. if (numberOfCurrentSample < numberOfStrata) { numberOfCurrentSample++; } else { @@ -62,11 +58,9 @@ void LatinHypercubeSampleGenerator::getSample(SGPP::base::DataVector& sample) { void LatinHypercubeSampleGenerator::shuffleStrataSequence() { for (size_t i = 0; i < dimensions; i++) { - std::shuffle(currentStrata[i].begin(), - currentStrata[i].end(), - rng); + std::shuffle(currentStrata[i].begin(), currentStrata[i].end(), rng); } } -} -} +} // namespace quadrature +} // namespace SGPP diff --git a/quadrature/src/sgpp/quadrature/sampling/LatinHypercubeSampleGenerator.hpp b/quadrature/src/sgpp/quadrature/sampling/LatinHypercubeSampleGenerator.hpp index d05253479f..cea61b77a2 100644 --- a/quadrature/src/sgpp/quadrature/sampling/LatinHypercubeSampleGenerator.hpp +++ b/quadrature/src/sgpp/quadrature/sampling/LatinHypercubeSampleGenerator.hpp @@ -7,13 +7,12 @@ #define LATINHYPERCUBESAMPLEGENERATOR_HPP #include -#include -#include -#include - #include #include +#include +#include +#include namespace SGPP { namespace quadrature { @@ -25,9 +24,7 @@ namespace quadrature { * 1.0. */ class LatinHypercubeSampleGenerator : public SampleGenerator { - public: - /** * Standard constructor * @@ -54,7 +51,6 @@ class LatinHypercubeSampleGenerator : public SampleGenerator { void getSample(SGPP::base::DataVector& sample); private: - /** * This method generates one sample . * Implementation of the abstract Method getSample from SampelGenerator. @@ -72,13 +68,13 @@ class LatinHypercubeSampleGenerator : public SampleGenerator { float_t sizeOfStrata; // - std::vector< std::vector > currentStrata; + std::vector > currentStrata; // std::uniform_real_distribution uniformRealDist; }; -} -} +} // namespace quadrature +} // namespace SGPP #endif /* LATINHYPERCUBESAMPLEGENERATOR_HPP */ diff --git a/quadrature/src/sgpp/quadrature/sampling/NaiveSampleGenerator.cpp b/quadrature/src/sgpp/quadrature/sampling/NaiveSampleGenerator.cpp index f31fe5106f..85de6718d7 100644 --- a/quadrature/src/sgpp/quadrature/sampling/NaiveSampleGenerator.cpp +++ b/quadrature/src/sgpp/quadrature/sampling/NaiveSampleGenerator.cpp @@ -8,21 +8,15 @@ #include #include -using namespace SGPP::base; - namespace SGPP { namespace quadrature { -NaiveSampleGenerator::NaiveSampleGenerator(size_t dimension, - std::uint64_t seed) : - SampleGenerator(dimension, seed), - uniformRealDist(0, 1) { -} +NaiveSampleGenerator::NaiveSampleGenerator(size_t dimension, std::uint64_t seed) + : SampleGenerator(dimension, seed), uniformRealDist(0, 1) {} -NaiveSampleGenerator::~NaiveSampleGenerator() { -} +NaiveSampleGenerator::~NaiveSampleGenerator() {} -void NaiveSampleGenerator::getSample(DataVector& sample) { +void NaiveSampleGenerator::getSample(base::DataVector& sample) { // generate random sample with dimensionality corresponding to the // size of the given datavector (in 0 to 1) for (size_t i = 0; i < sample.getSize(); i++) { @@ -30,5 +24,5 @@ void NaiveSampleGenerator::getSample(DataVector& sample) { } } -} -} +} // namespace quadrature +} // namespace SGPP diff --git a/quadrature/src/sgpp/quadrature/sampling/NaiveSampleGenerator.hpp b/quadrature/src/sgpp/quadrature/sampling/NaiveSampleGenerator.hpp index 5e276547a1..5165095259 100644 --- a/quadrature/src/sgpp/quadrature/sampling/NaiveSampleGenerator.hpp +++ b/quadrature/src/sgpp/quadrature/sampling/NaiveSampleGenerator.hpp @@ -9,10 +9,9 @@ #include #include #include -#include - #include +#include namespace SGPP { namespace quadrature { @@ -24,17 +23,15 @@ namespace quadrature { * 1.0. */ class NaiveSampleGenerator : public SampleGenerator { - public: - /** * Standard constructor * * @param dimension number of dimensions used for sample generation * @param seed custom seed (defaults to default seed of mt19937_64) */ - NaiveSampleGenerator(size_t dimension, - std::uint64_t seed = std::mt19937_64::default_seed); + explicit NaiveSampleGenerator(size_t dimension, + std::uint64_t seed = std::mt19937_64::default_seed); /** * Destructor @@ -53,7 +50,7 @@ class NaiveSampleGenerator : public SampleGenerator { std::uniform_real_distribution uniformRealDist; }; -} -} +} // namespace quadrature +} // namespace SGPP #endif /* NAIVESAMPLEGENERATOR_HPP */ diff --git a/quadrature/src/sgpp/quadrature/sampling/SampleGenerator.cpp b/quadrature/src/sgpp/quadrature/sampling/SampleGenerator.cpp index 0e48da25a3..028fcc6e52 100644 --- a/quadrature/src/sgpp/quadrature/sampling/SampleGenerator.cpp +++ b/quadrature/src/sgpp/quadrature/sampling/SampleGenerator.cpp @@ -8,27 +8,22 @@ #include #include -using namespace SGPP::base; - namespace SGPP { namespace quadrature { -SampleGenerator::SampleGenerator(size_t dimensions, std::uint64_t seed) : - dimensions(dimensions), seed(seed) { +SampleGenerator::SampleGenerator(size_t dimensions, std::uint64_t seed) + : dimensions(dimensions), seed(seed) { rng.seed(seed); } -SampleGenerator::~SampleGenerator() { -} - -void SampleGenerator::getSamples(DataMatrix& samples) { +SampleGenerator::~SampleGenerator() {} +void SampleGenerator::getSamples(base::DataMatrix& samples) { // Number of columns has to correspond to the number of dimensions - if (samples.getNcols() != dimensions) - return; + if (samples.getNcols() != dimensions) return; // generate one sample for every row of the given DataMatrix - DataVector dv(dimensions); + base::DataVector dv(dimensions); for (size_t i = 0; i < samples.getNrows(); i++) { getSample(dv); @@ -36,13 +31,9 @@ void SampleGenerator::getSamples(DataMatrix& samples) { } } -size_t SampleGenerator::getDimensions() { - return dimensions; -} +size_t SampleGenerator::getDimensions() { return dimensions; } -void SampleGenerator::setDimensions(size_t dimensions) { - this->dimensions = dimensions; -} +void SampleGenerator::setDimensions(size_t dimensions) { this->dimensions = dimensions; } -} -} +} // namespace quadrature +} // namespace SGPP diff --git a/quadrature/src/sgpp/quadrature/sampling/SampleGenerator.hpp b/quadrature/src/sgpp/quadrature/sampling/SampleGenerator.hpp index 71e3839885..eae9d4603c 100644 --- a/quadrature/src/sgpp/quadrature/sampling/SampleGenerator.hpp +++ b/quadrature/src/sgpp/quadrature/sampling/SampleGenerator.hpp @@ -8,10 +8,10 @@ #include #include -#include - #include +#include + namespace SGPP { namespace quadrature { @@ -24,7 +24,6 @@ namespace quadrature { class SampleGenerator { public: - /** * Standard constructor * @@ -32,8 +31,7 @@ class SampleGenerator { * @param seed custom seed (defaults to default seed of mt19937_64) */ - SampleGenerator(size_t dimensions, - std::uint64_t seed = std::mt19937_64::default_seed); + explicit SampleGenerator(size_t dimensions, std::uint64_t seed = std::mt19937_64::default_seed); virtual ~SampleGenerator(); /** @@ -45,9 +43,7 @@ class SampleGenerator { * @param sample provide a DataVector to store the generated sample. */ - virtual void getSample(SGPP::base::DataVector& sample) { - } - ; + virtual void getSample(SGPP::base::DataVector& sample) {} /** * This method generates a given number of samples. The resulting @@ -85,7 +81,7 @@ class SampleGenerator { // random number generator std::mt19937_64 rng; }; -} -} +} // namespace quadrature +} // namespace SGPP #endif /* SAMPLEGENERATOR_HPP */ diff --git a/quadrature/src/sgpp/quadrature/sampling/SamplerTypes.hpp b/quadrature/src/sgpp/quadrature/sampling/SamplerTypes.hpp index 353bcc669a..2754f0bae4 100644 --- a/quadrature/src/sgpp/quadrature/sampling/SamplerTypes.hpp +++ b/quadrature/src/sgpp/quadrature/sampling/SamplerTypes.hpp @@ -11,12 +11,7 @@ namespace SGPP { namespace quadrature { -enum class SamplerTypes { - Naive, - Stratified, - LatinHypercube, - Halton -}; +enum class SamplerTypes { Naive, Stratified, LatinHypercube, Halton }; } // namespace quadrature } // namespace SGPP diff --git a/quadrature/src/sgpp/quadrature/sampling/StratifiedSampleGenerator.cpp b/quadrature/src/sgpp/quadrature/sampling/StratifiedSampleGenerator.cpp index 067d42fd27..98c19b497c 100644 --- a/quadrature/src/sgpp/quadrature/sampling/StratifiedSampleGenerator.cpp +++ b/quadrature/src/sgpp/quadrature/sampling/StratifiedSampleGenerator.cpp @@ -4,51 +4,43 @@ // sgpp.sparsegrids.org #include - -#include #include #include -using namespace SGPP::base; -using namespace std; +#include +#include namespace SGPP { namespace quadrature { -StratifiedSampleGenerator::StratifiedSampleGenerator(vector& - strataPerDimension, uint64_t seed) : - SampleGenerator(strataPerDimension.size(), seed), - numberOfStrata(strataPerDimension), - currentStrata(strataPerDimension.size()), - numberOfSamples(0), - numberOfCurrentSample(0), - sizeOfStrata(strataPerDimension.size()), - uniformRealDist(0, 1) { +StratifiedSampleGenerator::StratifiedSampleGenerator(std::vector& strataPerDimension, + uint64_t seed) + : SampleGenerator(strataPerDimension.size(), seed), + numberOfStrata(strataPerDimension), + currentStrata(strataPerDimension.size()), + numberOfSamples(0), + numberOfCurrentSample(0), + sizeOfStrata(strataPerDimension.size()), + uniformRealDist(0, 1) { // set counter to the first strata for each dimension // compute size of strata per dimension for (size_t i = 0; i < dimensions; i++) { - if (numberOfStrata[i] < 1) - numberOfStrata[i] = 1; + if (numberOfStrata[i] < 1) numberOfStrata[i] = 1; currentStrata[i] = 0; sizeOfStrata[i] = 1. / static_cast(this->numberOfStrata[i]); } - } -StratifiedSampleGenerator::~StratifiedSampleGenerator() { -} +StratifiedSampleGenerator::~StratifiedSampleGenerator() {} void StratifiedSampleGenerator::getSample(SGPP::base::DataVector& dv) { - // Check for correct dimension of the parameter vector - if (dv.getSize() != dimensions) - return; + if (dv.getSize() != dimensions) return; // Choose a random number inside the stratum selected for this dimension for (size_t i = 0; i < dimensions; i++) { - dv[i] = (static_cast(currentStrata[i]) + uniformRealDist(rng)) - * sizeOfStrata[i]; + dv[i] = (static_cast(currentStrata[i]) + uniformRealDist(rng)) * sizeOfStrata[i]; } // continue to the next stratum used for the next sample @@ -69,5 +61,5 @@ void StratifiedSampleGenerator::getNextStrata() { } } -} -} +} // namespace quadrature +} // namespace SGPP diff --git a/quadrature/src/sgpp/quadrature/sampling/StratifiedSampleGenerator.hpp b/quadrature/src/sgpp/quadrature/sampling/StratifiedSampleGenerator.hpp index 9613e9510f..772d78db03 100644 --- a/quadrature/src/sgpp/quadrature/sampling/StratifiedSampleGenerator.hpp +++ b/quadrature/src/sgpp/quadrature/sampling/StratifiedSampleGenerator.hpp @@ -8,10 +8,11 @@ #include #include -#include - #include +#include +#include + namespace SGPP { namespace quadrature { @@ -21,10 +22,8 @@ namespace quadrature { * one sample has already been generated for every strata, the next requested * sample will be placed into the first strata. */ -class StratifiedSampleGenerator: public SampleGenerator { - +class StratifiedSampleGenerator : public SampleGenerator { public: - /** * Standard constructor * @@ -74,10 +73,9 @@ class StratifiedSampleGenerator: public SampleGenerator { // std::uniform_real_distribution uniformRealDist; - }; -} -} +} // namespace quadrature +} // namespace SGPP #endif /* STRATIFIEDSAMPLEGENERATOR_HPP */ diff --git a/solver/SConscript b/solver/SConscript index 487d624421..5d3febbc14 100755 --- a/solver/SConscript +++ b/solver/SConscript @@ -17,6 +17,7 @@ Import('installTargetList') Import('exampleTargetList') Import('headerSourceList') Import('headerDestList') +Import('lintAction') moduleDependencies = ['sgppbase'] Export('moduleDependencies') @@ -28,19 +29,21 @@ if env['USE_STATICLIB']: moduleDependencies[i] = "%sstatic" % moduleDependencies[i] Export('libname') -srcs = [] +cpps = [] +hpps = [] +objs = [] + for currentFolder, subdirNames, fileNames in os.walk("src"): for fileName in fnmatch.filter(fileNames, '*.cpp'): - srcs.append(os.path.join(currentFolder, fileName)) + cpp = os.path.join(currentFolder, fileName) + cpps.append(cpp) + objs.append(env.SharedObject(cpp)) if currentFolder != 'src': for fileName in fnmatch.filter(fileNames, '*.hpp'): - headerSourceList.append(os.path.join(moduleName, currentFolder, fileName)) - headerDestList.append(os.path.join(currentFolder, fileName).split(os.sep,1)[1]) - -objs = [] -for sourceFile in srcs: - objs.append(env.SharedObject(sourceFile)) - # objs.append(sourceFile) + hpp = os.path.join(currentFolder, fileName) + hpps.append(hpp) + headerSourceList.append(os.path.join(moduleName, hpp)) + headerDestList.append(hpp.split(os.sep, 1)[1]) if env['USE_STATICLIB']: # building static libraries is the same for unix and windows platforms @@ -65,6 +68,11 @@ for lib_str in moduleDependencies: libInstall = env.Install(BUILD_DIR, lib) +if env['RUN_CPPLINT']: + for path in cpps + hpps: + lintCommand = env.Command(path + ".lint", path, lintAction) + env.Depends(lib, lintCommand) + if not env['NO_UNIT_TESTS'] and env['SG_PYTHON']: Import('testTargetList') py_test_env = env.Clone() diff --git a/solver/src/sgpp/solver/ODESolver.hpp b/solver/src/sgpp/solver/ODESolver.hpp index e81a8ca68c..9d1168fb43 100644 --- a/solver/src/sgpp/solver/ODESolver.hpp +++ b/solver/src/sgpp/solver/ODESolver.hpp @@ -15,7 +15,6 @@ #include - namespace SGPP { namespace solver { @@ -27,19 +26,20 @@ class ODESolver : public SGSolver { * @param imax number of maximum executed iterations * @param timestepSize the size of one timestep */ - ODESolver(size_t imax, float_t timestepSize) : SGSolver(imax, timestepSize) { - } + ODESolver(size_t imax, float_t timestepSize) : SGSolver(imax, timestepSize) {} /** * Std-Destructor */ - virtual ~ODESolver() { } + virtual ~ODESolver() {} /** * Pure virtual Function that defines a solve method for an ODE solver * - * @param LinearSystemSolver reference to an instance of a linear system solver that is used by this ODE solver - * @param System reference to an SGPP::base::OperationMatrix Object that implements the matrix vector multiplication + * @param LinearSystemSolver reference to an instance of a linear system solver that is used by + * this ODE solver + * @param System reference to an SGPP::base::OperationMatrix Object that implements the matrix + * vector multiplication * @param bIdentifyLastStep set this to true to tell System the last step * @param verbose prints information during execution of the solver */ @@ -48,7 +48,7 @@ class ODESolver : public SGSolver { bool bIdentifyLastStep = false, bool verbose = false) = 0; }; -} -} +} // namespace solver +} // namespace SGPP #endif /* ODESOLVER_HPP */ diff --git a/solver/src/sgpp/solver/SGSolver.hpp b/solver/src/sgpp/solver/SGSolver.hpp index d5a498215f..70ad0b1d55 100644 --- a/solver/src/sgpp/solver/SGSolver.hpp +++ b/solver/src/sgpp/solver/SGSolver.hpp @@ -7,11 +7,9 @@ #define SGSOLVER_HPP #include - -#include - #include +#include namespace SGPP { namespace solver { @@ -38,8 +36,8 @@ class SGSolver { * @param nMaximumIterations number of maximum executed iterations * @param epsilon the final error in the iterative solver, or the size of one timestep */ - SGSolver(size_t nMaximumIterations, - float_t epsilon) : nMaxIterations(nMaximumIterations), myEpsilon(epsilon) { + SGSolver(size_t nMaximumIterations, float_t epsilon) + : nMaxIterations(nMaximumIterations), myEpsilon(epsilon) { nIterations = 0; residuum = 0.0; } @@ -47,56 +45,45 @@ class SGSolver { /** * Std-Destructor */ - virtual ~SGSolver() { } - + virtual ~SGSolver() {} /** * function that returns the number of needed solve steps * * @return the number of needed solve steps of the sovler */ - size_t getNumberIterations() { - return nIterations; - } + size_t getNumberIterations() { return nIterations; } /** * function the returns the residuum (current or final), error of the solver * * @return the residuum */ - float_t getResiduum() { - return residuum; - } + float_t getResiduum() { return residuum; } /** * resets the number of maximum iterations * * @param nIterations the new number of maximum iterations */ - void setMaxIterations(size_t nIterations) { - nMaxIterations = nIterations; - } + void setMaxIterations(size_t nIterations) { nMaxIterations = nIterations; } /** * resets the epsilon, that is used in the SGSolver * * @param eps the new value of epsilon */ - void setEpsilon(float_t eps) { - myEpsilon = eps; - } + void setEpsilon(float_t eps) { myEpsilon = eps; } /** * gets the the epsilon, that is used in the SGSolver * * @return the epsilon, used in the solver */ - float_t getEpsilon() { - return myEpsilon; - } + float_t getEpsilon() { return myEpsilon; } }; -} -} +} // namespace solver +} // namespace SGPP #endif /* SGSOLVER_HPP */ diff --git a/solver/src/sgpp/solver/SGSolverSP.hpp b/solver/src/sgpp/solver/SGSolverSP.hpp index 306443133e..01bb9e59bb 100644 --- a/solver/src/sgpp/solver/SGSolverSP.hpp +++ b/solver/src/sgpp/solver/SGSolverSP.hpp @@ -7,11 +7,9 @@ #define SGSOLVERSP_HPP #include - -#include - #include +#include namespace SGPP { namespace solver { @@ -38,8 +36,8 @@ class SGSolverSP { * @param nMaximumIterations number of maximum executed iterations * @param epsilon the final error in the iterative solver, or the size of one timestep */ - SGSolverSP(size_t nMaximumIterations, - float epsilon) : nMaxIterations(nMaximumIterations), myEpsilon(epsilon) { + SGSolverSP(size_t nMaximumIterations, float epsilon) + : nMaxIterations(nMaximumIterations), myEpsilon(epsilon) { nIterations = 0; residuum = 0.0; } @@ -47,56 +45,45 @@ class SGSolverSP { /** * Std-Destructor */ - virtual ~SGSolverSP() { } - + virtual ~SGSolverSP() {} /** * function that returns the number of needed solve steps * * @return the number of needed solve steps of the sovler */ - size_t getNumberIterations() { - return nIterations; - } + size_t getNumberIterations() { return nIterations; } /** * function the returns the residuum (current or final), error of the solver * * @return the residuum */ - float getResiduum() { - return residuum; - } + float getResiduum() { return residuum; } /** * resets the number of maximum iterations * * @param nIterations the new number of maximum iterations */ - void setMaxIterations(size_t nIterations) { - nMaxIterations = nIterations; - } + void setMaxIterations(size_t nIterations) { nMaxIterations = nIterations; } /** * resets the epsilon, that is used in the SGSolver * * @param eps the new value of epsilon */ - void setEpsilon(float eps) { - myEpsilon = eps; - } + void setEpsilon(float eps) { myEpsilon = eps; } /** * gets the the epsilon, that is used in the SGSolver * * @return the epsilon, used in the solver */ - float getEpsilon() { - return myEpsilon; - } + float getEpsilon() { return myEpsilon; } }; -} -} +} // namespace solver +} // namespace SGPP #endif /* SGSOLVERSP_HPP */ diff --git a/solver/src/sgpp/solver/SLESolver.hpp b/solver/src/sgpp/solver/SLESolver.hpp index 01b3261193..fc4027902a 100644 --- a/solver/src/sgpp/solver/SLESolver.hpp +++ b/solver/src/sgpp/solver/SLESolver.hpp @@ -17,7 +17,6 @@ #include - namespace SGPP { namespace solver { @@ -29,30 +28,30 @@ class SLESolver : public SGSolver { * @param imax number of maximum executed iterations * @param epsilon the final error in the iterative solver */ - SLESolver(size_t imax, float_t epsilon) : SGSolver(imax, epsilon) { - } + SLESolver(size_t imax, float_t epsilon) : SGSolver(imax, epsilon) {} /** * Std-Destructor */ - virtual ~SLESolver() { } + virtual ~SLESolver() {} /** * Pure virtual Function that defines a solve method for an iterative solver * - * @param SystemMatrix reference to an SGPP::base::OperationMatrix Object that implements the matrix vector multiplication + * @param SystemMatrix reference to an SGPP::base::OperationMatrix Object that implements the + * matrix vector multiplication * @param alpha the sparse grid's coefficients which have to be determined * @param b the right hand side of the system of linear equations * @param reuse identifies if the alphas, stored in alpha at calling time, should be reused * @param verbose prints information during execution of the solver * @param max_threshold additional abort criteria for solver, default value is 10^-9! */ - virtual void solve(SGPP::base::OperationMatrix& SystemMatrix, - SGPP::base::DataVector& alpha, SGPP::base::DataVector& b, bool reuse = false, - bool verbose = false, float_t max_threshold = DEFAULT_RES_THRESHOLD) = 0; + virtual void solve(SGPP::base::OperationMatrix& SystemMatrix, SGPP::base::DataVector& alpha, + SGPP::base::DataVector& b, bool reuse = false, bool verbose = false, + float_t max_threshold = DEFAULT_RES_THRESHOLD) = 0; }; -} -} +} // namespace solver +} // namespace SGPP -#endif /* SLESOLVER_HPP */ \ No newline at end of file +#endif /* SLESOLVER_HPP */ diff --git a/solver/src/sgpp/solver/SLESolverSP.hpp b/solver/src/sgpp/solver/SLESolverSP.hpp index 1297a86922..fa2685a01d 100644 --- a/solver/src/sgpp/solver/SLESolverSP.hpp +++ b/solver/src/sgpp/solver/SLESolverSP.hpp @@ -17,7 +17,6 @@ #include - namespace SGPP { namespace solver { @@ -29,31 +28,30 @@ class SLESolverSP : public SGSolverSP { * @param imax number of maximum executed iterations * @param epsilon the final error in the iterative solver */ - SLESolverSP(size_t imax, float epsilon) : SGSolverSP(imax, epsilon) { - } + SLESolverSP(size_t imax, float epsilon) : SGSolverSP(imax, epsilon) {} /** * Std-Destructor */ - virtual ~SLESolverSP() { } + virtual ~SLESolverSP() {} /** * Pure virtual Function that defines a solve method for an iterative solver * - * @param SystemMatrix reference to an SGPP::base::OperationMatrix Object that implements the matrix vector multiplication + * @param SystemMatrix reference to an SGPP::base::OperationMatrix Object that implements the + * matrix vector multiplication * @param alpha the sparse grid's coefficients which have to be determined * @param b the right hand side of the system of linear equations * @param reuse identifies if the alphas, stored in alpha at calling time, should be reused * @param verbose prints information during execution of the solver * @param max_threshold additional abort criteria for solver, default value is 10^-9! */ - virtual void solve(SGPP::base::OperationMatrixSP& SystemMatrix, - SGPP::base::DataVectorSP& alpha, SGPP::base::DataVectorSP& b, - bool reuse = false, bool verbose = false, + virtual void solve(SGPP::base::OperationMatrixSP& SystemMatrix, SGPP::base::DataVectorSP& alpha, + SGPP::base::DataVectorSP& b, bool reuse = false, bool verbose = false, float max_threshold = DEFAULT_RES_THRESHOLD) = 0; }; -} -} +} // namespace solver +} // namespace SGPP -#endif /* SLESOLVER_HPP */ \ No newline at end of file +#endif /* SLESOLVER_HPP */ diff --git a/solver/src/sgpp/solver/TypesSolver.hpp b/solver/src/sgpp/solver/TypesSolver.hpp index 4b89748476..e4e1689f3c 100644 --- a/solver/src/sgpp/solver/TypesSolver.hpp +++ b/solver/src/sgpp/solver/TypesSolver.hpp @@ -6,10 +6,9 @@ #ifndef TYPESSOLVER_HPP #define TYPESSOLVER_HPP -#include - #include +#include namespace SGPP { @@ -18,10 +17,7 @@ namespace solver { /** * enum to address different SLE solvers in a standardized way */ -enum class SLESolverType { - CG, - BiCGSTAB -}; +enum class SLESolverType { CG, BiCGSTAB }; struct SLESolverConfiguration { SGPP::solver::SLESolverType type_; @@ -37,8 +33,7 @@ struct SLESolverSPConfiguration { float threshold_; }; -} - -} +} // namespace solver +} // namespace SGPP #endif /* TYPESSOLVER_HPP */ diff --git a/solver/src/sgpp/solver/ode/AdamsBashforth.cpp b/solver/src/sgpp/solver/ode/AdamsBashforth.cpp index 1e7f3fdb86..5f1af56c81 100644 --- a/solver/src/sgpp/solver/ode/AdamsBashforth.cpp +++ b/solver/src/sgpp/solver/ode/AdamsBashforth.cpp @@ -9,29 +9,25 @@ #include #include +#include + #include #include #include -#include - - namespace SGPP { namespace solver { -AdamsBashforth::AdamsBashforth(size_t imax, float_t timestepSize, - SGPP::base::ScreenOutput* screen) : ODESolver(imax, timestepSize), - myScreen(screen) { +AdamsBashforth::AdamsBashforth(size_t imax, float_t timestepSize, SGPP::base::ScreenOutput* screen) + : ODESolver(imax, timestepSize), myScreen(screen) { this->residuum = 0.0; - } -AdamsBashforth::~AdamsBashforth() { -} +AdamsBashforth::~AdamsBashforth() {} void AdamsBashforth::solve(SLESolver& LinearSystemSolver, - SGPP::solver::OperationParabolicPDESolverSystem& System, bool bIdentifyLastStep, - bool verbose) { + SGPP::solver::OperationParabolicPDESolverSystem& System, + bool bIdentifyLastStep, bool verbose) { size_t allIter = 0; SGPP::base::DataVector* rhs; @@ -44,30 +40,28 @@ void AdamsBashforth::solve(SLESolver& LinearSystemSolver, // generate right hand side rhs = System.generateRHS(); - // solve the system of the current timestep - LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, - false, -1.0); + LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, false, -1.0); allIter += LinearSystemSolver.getNumberIterations(); if (verbose == true) { if (myScreen == NULL) { std::cout << "Final residuum " << LinearSystemSolver.getResiduum() << "; with " - << LinearSystemSolver.getNumberIterations() << " Iterations (Total Iter.: " << - allIter << ")" << std::endl; + << LinearSystemSolver.getNumberIterations() + << " Iterations (Total Iter.: " << allIter << ")" << std::endl; } } if (myScreen != NULL) { std::stringstream soutput; - soutput << "Final residuum " << LinearSystemSolver.getResiduum() << "; with " << - LinearSystemSolver.getNumberIterations() << " Iterations (Total Iter.: " << - allIter << ")"; + soutput << "Final residuum " << LinearSystemSolver.getResiduum() << "; with " + << LinearSystemSolver.getNumberIterations() << " Iterations (Total Iter.: " << allIter + << ")"; if (i < this->nMaxIterations - 1) { - myScreen->update((size_t)(((float_t)(i + 1) * 100.0) / (( - float_t)this->nMaxIterations)), soutput.str()); + myScreen->update((size_t)(((float_t)(i + 1) * 100.0) / ((float_t) this->nMaxIterations)), + soutput.str()); } else { myScreen->update(100, soutput.str()); } @@ -86,7 +80,6 @@ void AdamsBashforth::solve(SLESolver& LinearSystemSolver, } System.saveAlpha(); - } // write some empty lines to console @@ -97,5 +90,5 @@ void AdamsBashforth::solve(SLESolver& LinearSystemSolver, this->nIterations = allIter; } -} -} +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/ode/AdamsBashforth.hpp b/solver/src/sgpp/solver/ode/AdamsBashforth.hpp index 4c29f7e1d7..6813075006 100644 --- a/solver/src/sgpp/solver/ode/AdamsBashforth.hpp +++ b/solver/src/sgpp/solver/ode/AdamsBashforth.hpp @@ -8,10 +8,9 @@ #include #include -#include - #include +#include namespace SGPP { namespace solver { @@ -34,8 +33,7 @@ class AdamsBashforth : public ODESolver { * @param timestepSize the size of one timestep * @param screen possible pointer to a SGPP::base::ScreenOutput object */ - AdamsBashforth(size_t imax, float_t timestepSize, - SGPP::base::ScreenOutput* screen = NULL); + AdamsBashforth(size_t imax, float_t timestepSize, SGPP::base::ScreenOutput* screen = NULL); /** * Std-Destructor @@ -47,7 +45,7 @@ class AdamsBashforth : public ODESolver { bool bIdentifyLastStep = false, bool verbose = false); }; -} -} +} // namespace solver +} // namespace SGPP #endif /* ADAMSBASHFORTH_HPP */ diff --git a/solver/src/sgpp/solver/ode/CrankNicolson.cpp b/solver/src/sgpp/solver/ode/CrankNicolson.cpp index c8b84423bf..6578c1f956 100644 --- a/solver/src/sgpp/solver/ode/CrankNicolson.cpp +++ b/solver/src/sgpp/solver/ode/CrankNicolson.cpp @@ -8,22 +8,20 @@ #include - namespace SGPP { namespace solver { CrankNicolson::CrankNicolson(size_t nTimesteps, float_t timestepSize, - SGPP::base::ScreenOutput* screen) : ODESolver(nTimesteps, timestepSize), - myScreen(screen) { + SGPP::base::ScreenOutput* screen) + : ODESolver(nTimesteps, timestepSize), myScreen(screen) { this->residuum = 0.0; } -CrankNicolson::~CrankNicolson() { -} +CrankNicolson::~CrankNicolson() {} void CrankNicolson::solve(SLESolver& LinearSystemSolver, - SGPP::solver::OperationParabolicPDESolverSystem& System, bool bIdentifyLastStep, - bool verbose) { + SGPP::solver::OperationParabolicPDESolverSystem& System, + bool bIdentifyLastStep, bool verbose) { size_t allIter = 0; SGPP::base::DataVector* rhs = NULL; @@ -32,27 +30,26 @@ void CrankNicolson::solve(SLESolver& LinearSystemSolver, rhs = System.generateRHS(); // solve the system of the current timestep - LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, - false, -1.0); + LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, false, -1.0); allIter += LinearSystemSolver.getNumberIterations(); if (verbose == true) { if (myScreen == NULL) { std::cout << "Final residuum " << LinearSystemSolver.getResiduum() << "; with " - << LinearSystemSolver.getNumberIterations() << " Iterations (Total Iter.: " << - allIter << ")" << std::endl; + << LinearSystemSolver.getNumberIterations() + << " Iterations (Total Iter.: " << allIter << ")" << std::endl; } } if (myScreen != NULL) { std::stringstream soutput; - soutput << "Final residuum " << LinearSystemSolver.getResiduum() << "; with " << - LinearSystemSolver.getNumberIterations() << " Iterations (Total Iter.: " << - allIter << ")"; + soutput << "Final residuum " << LinearSystemSolver.getResiduum() << "; with " + << LinearSystemSolver.getNumberIterations() << " Iterations (Total Iter.: " << allIter + << ")"; if (i < this->nMaxIterations - 1) { - myScreen->update((size_t)(((float_t)(i + 1) * 100.0) / (( - float_t)this->nMaxIterations)), soutput.str()); + myScreen->update((size_t)(((float_t)(i + 1) * 100.0) / ((float_t) this->nMaxIterations)), + soutput.str()); } else { myScreen->update(100, soutput.str()); } @@ -80,5 +77,5 @@ void CrankNicolson::solve(SLESolver& LinearSystemSolver, this->nIterations = allIter; } -} -} +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/ode/CrankNicolson.hpp b/solver/src/sgpp/solver/ode/CrankNicolson.hpp index f0e7695650..5993b89cf6 100644 --- a/solver/src/sgpp/solver/ode/CrankNicolson.hpp +++ b/solver/src/sgpp/solver/ode/CrankNicolson.hpp @@ -11,7 +11,6 @@ #include - namespace SGPP { namespace solver { @@ -36,8 +35,7 @@ class CrankNicolson : public ODESolver { * @param timestepSize the size of one timestep * @param screen possible pointer to a SGPP::base::ScreenOutput object */ - CrankNicolson(size_t nTimesteps, float_t timestepSize, - SGPP::base::ScreenOutput* screen = NULL); + CrankNicolson(size_t nTimesteps, float_t timestepSize, SGPP::base::ScreenOutput* screen = NULL); /** * Std-Destructor @@ -49,7 +47,7 @@ class CrankNicolson : public ODESolver { bool bIdentifyLastStep = false, bool verbose = false); }; -} -} +} // namespace solver +} // namespace SGPP #endif /* CRANKNICOLSON_HPP */ diff --git a/solver/src/sgpp/solver/ode/Euler.cpp b/solver/src/sgpp/solver/ode/Euler.cpp index edb9691d89..5ca1a9fd28 100644 --- a/solver/src/sgpp/solver/ode/Euler.cpp +++ b/solver/src/sgpp/solver/ode/Euler.cpp @@ -9,21 +9,22 @@ #include #include +#include + #include #include #include -#include - - namespace SGPP { namespace solver { -Euler::Euler(std::string Mode, size_t imax, float_t timestepSize, - bool generateAnimation, size_t numEvalsAnimation, - SGPP::base::ScreenOutput* screen) : ODESolver(imax, timestepSize), - bAnimation(generateAnimation), evalsAnimation(numEvalsAnimation), ExMode(Mode), - myScreen(screen) { +Euler::Euler(std::string Mode, size_t imax, float_t timestepSize, bool generateAnimation, + size_t numEvalsAnimation, SGPP::base::ScreenOutput* screen) + : ODESolver(imax, timestepSize), + bAnimation(generateAnimation), + evalsAnimation(numEvalsAnimation), + ExMode(Mode), + myScreen(screen) { this->residuum = 0.0; if (Mode != "ExEul" && Mode != "ImEul") { @@ -31,8 +32,7 @@ Euler::Euler(std::string Mode, size_t imax, float_t timestepSize, } } -Euler::~Euler() { -} +Euler::~Euler() {} void Euler::solve(SLESolver& LinearSystemSolver, SGPP::solver::OperationParabolicPDESolverSystem& System, bool bIdentifyLastStep, @@ -67,28 +67,27 @@ void Euler::solve(SLESolver& LinearSystemSolver, rhs = System.generateRHS(); // solve the system of the current timestep - LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, - false, -1.0); + LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, false, -1.0); allIter += LinearSystemSolver.getNumberIterations(); if (verbose == true) { if (myScreen == NULL) { std::cout << "Final residuum " << LinearSystemSolver.getResiduum() << "; with " - << LinearSystemSolver.getNumberIterations() << " Iterations (Total Iter.: " << - allIter << ")" << std::endl; + << LinearSystemSolver.getNumberIterations() + << " Iterations (Total Iter.: " << allIter << ")" << std::endl; } } if (myScreen != NULL) { std::stringstream soutput; - soutput << "Final residuum " << LinearSystemSolver.getResiduum() << "; with " << - LinearSystemSolver.getNumberIterations() << " Iterations (Total Iter.: " << - allIter << ")"; + soutput << "Final residuum " << LinearSystemSolver.getResiduum() << "; with " + << LinearSystemSolver.getNumberIterations() << " Iterations (Total Iter.: " << allIter + << ")"; if (i < this->nMaxIterations - 1) { - myScreen->update((size_t)(((float_t)(i + 1) * 100.0) / (( - float_t)this->nMaxIterations)), soutput.str()); + myScreen->update((size_t)(((float_t)(i + 1) * 100.0) / ((float_t) this->nMaxIterations)), + soutput.str()); } else { myScreen->update(100, soutput.str()); } @@ -130,5 +129,5 @@ void Euler::solve(SLESolver& LinearSystemSolver, this->nIterations = allIter; } -} -} +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/ode/Euler.hpp b/solver/src/sgpp/solver/ode/Euler.hpp index 24d2d487c7..b9ec4b1dac 100644 --- a/solver/src/sgpp/solver/ode/Euler.hpp +++ b/solver/src/sgpp/solver/ode/Euler.hpp @@ -8,10 +8,9 @@ #include #include -#include - #include +#include namespace SGPP { namespace solver { @@ -39,13 +38,13 @@ class Euler : public ODESolver { * @param Mode the mode of the euler that should be executed, must be ExEul or ImEul * @param imax number of maximum executed iterations * @param timestepSize the size of one timestep - * @param generateAnimation set this, if you want to create a grid evaluation in every time step, in order to create an animation + * @param generateAnimation set this, if you want to create a grid evaluation in every time step, + * in order to create an animation * @param numEvalsAnimation specifies the evaluation per dimension when a animation is created * @param screen possible pointer to a SGPP::base::ScreenOutput object */ - Euler(std::string Mode, size_t imax, float_t timestepSize, - bool generateAnimation = false, size_t numEvalsAnimation = 20, - SGPP::base::ScreenOutput* screen = NULL); + Euler(std::string Mode, size_t imax, float_t timestepSize, bool generateAnimation = false, + size_t numEvalsAnimation = 20, SGPP::base::ScreenOutput* screen = NULL); /** * Std-Destructor @@ -57,7 +56,7 @@ class Euler : public ODESolver { bool bIdentifyLastStep = false, bool verbose = false); }; -} -} +} // namespace solver +} // namespace SGPP #endif /* EULER_HPP */ diff --git a/solver/src/sgpp/solver/ode/StepsizeControl.cpp b/solver/src/sgpp/solver/ode/StepsizeControl.cpp index f9f638e43c..c2e518eaef 100644 --- a/solver/src/sgpp/solver/ode/StepsizeControl.cpp +++ b/solver/src/sgpp/solver/ode/StepsizeControl.cpp @@ -8,46 +8,43 @@ #include #include #include +#include #include #include #include #include -#include - +#include namespace SGPP { namespace solver { -StepsizeControl::StepsizeControl(size_t imax, float_t timestepSize, float_t eps, - float_t sc, SGPP::base::ScreenOutput* screen, float_t gamma) - : ODESolver(imax, timestepSize), myScreen(screen), _gamma(gamma) { +StepsizeControl::StepsizeControl(size_t imax, float_t timestepSize, float_t eps, float_t sc, + SGPP::base::ScreenOutput* screen, float_t gamma) + : ODESolver(imax, timestepSize), myScreen(screen), _gamma(gamma) { this->residuum = 0.0; this->myEps = eps; this->mySC = sc; useCoarsen = true; - } -StepsizeControl::~StepsizeControl() { -} +StepsizeControl::~StepsizeControl() {} -float_t StepsizeControl::norm(SGPP::solver::OperationParabolicPDESolverSystem& - System, SGPP::base::DataVector& dv1, SGPP::base::DataVector& dv2) { +float_t StepsizeControl::norm(SGPP::solver::OperationParabolicPDESolverSystem& System, + SGPP::base::DataVector& dv1, SGPP::base::DataVector& dv2) { return twoNorm(System, dv1, dv2); } -float_t StepsizeControl::twoNorm( - SGPP::solver::OperationParabolicPDESolverSystem& System, - SGPP::base::DataVector& dv1, SGPP::base::DataVector& dv2) { +float_t StepsizeControl::twoNorm(SGPP::solver::OperationParabolicPDESolverSystem& System, + SGPP::base::DataVector& dv1, SGPP::base::DataVector& dv2) { dv1.sub(dv2); return sqrt(dv1.dotProduct(dv1)); } -float_t StepsizeControl::maxNorm( - SGPP::solver::OperationParabolicPDESolverSystem& System, - SGPP::base::DataVector& YkImEul, SGPP::base::DataVector& YkImEulOld) { +float_t StepsizeControl::maxNorm(SGPP::solver::OperationParabolicPDESolverSystem& System, + SGPP::base::DataVector& YkImEul, + SGPP::base::DataVector& YkImEulOld) { float_t max = 0.0; float_t sc = this->mySC; @@ -60,8 +57,7 @@ float_t StepsizeControl::maxNorm( float_t t2 = std::max(fabs(Data[j]), fabs(OldData[j])); float_t tmpData = fabs(Data[j] - OldData[j]) / std::max(sc, t2); - if (max < fabs(tmpData)) - max = fabs(tmpData); + if (max < fabs(tmpData)) max = fabs(tmpData); } } else { // std::cout << "YK" << YkImEul.getSize()<< " YKold" << YkImEulOld.getSize() << std::endl; @@ -70,36 +66,34 @@ float_t StepsizeControl::maxNorm( SGPP::base::GridStorage* ogs = System.getOldGridStorage(); SGPP::base::GridStorage::grid_map_iterator q; - for (SGPP::base::GridStorage::grid_map_iterator p = gs->begin(); p != gs->end(); - ++p) { + for (SGPP::base::GridStorage::grid_map_iterator p = gs->begin(); p != gs->end(); ++p) { q = ogs->find(p->first); - // std::cout << "YK" << ((p->first)->toString() == (q->first)->toString() ) << " " << (p->first)->toString() << " YKold" << ((q->first)->equals(*p->first)) << " "<< (q->first)->toString() << std::endl; + // std::cout << "YK" << ((p->first)->toString() == (q->first)->toString() ) << + // " " << (p->first)->toString() << " YKold" << ((q->first)->equals(*p->first)) << + // " "<< (q->first)->toString() << std::endl; if ((q->first)->equals(*p->first)) { - auto i = p->second; auto j = q->second; - // std::cout <first)->toString() << " "<first)->toString() <<" "<first)->toString() << " "<first)->toString() <<" "<= epsilon) << std::endl; - + // std::cout << "u1 " << max << " e"<<(max >= epsilon) << std::endl; } return max; - } void StepsizeControl::solve(SLESolver& LinearSystemSolver, - SGPP::solver::OperationParabolicPDESolverSystem& System, bool bIdentifyLastStep, - bool verbose) { + SGPP::solver::OperationParabolicPDESolverSystem& System, + bool bIdentifyLastStep, bool verbose) { size_t allIter = 0; SGPP::base::DataVector* rhs; SGPP::base::DataVector YkAdBas(System.getGridCoefficients()->getSize()); @@ -110,8 +104,7 @@ void StepsizeControl::solve(SLESolver& LinearSystemSolver, float_t tmp_timestepsize_new = tmp_timestepsize; float_t epsilon = this->myEps; - float_t maxTimestep = static_cast (this->nMaxIterations) * - tmp_timestepsize; + float_t maxTimestep = static_cast(this->nMaxIterations) * tmp_timestepsize; size_t maxIter = this->nMaxIterations * 10000; @@ -119,8 +112,8 @@ void StepsizeControl::solve(SLESolver& LinearSystemSolver, std::ofstream fileout; - //fileout.open(filename.c_str()); - fileout.open(filename.c_str(), std::ofstream::app); // apend to file + // fileout.open(filename.c_str()); + fileout.open(filename.c_str(), std::ofstream::app); // apend to file fileout << std::endl; System.getGridCoefficientsForSC(YkImEul); @@ -128,8 +121,6 @@ void StepsizeControl::solve(SLESolver& LinearSystemSolver, rhs = NULL; for (size_t i = 0; i < maxIter && time < maxTimestep; i++) { - - YkAdBas.resize(System.getGridCoefficients()->getSize()); YkImEul.resize(System.getGridCoefficients()->getSize()); @@ -138,10 +129,9 @@ void StepsizeControl::solve(SLESolver& LinearSystemSolver, corrector(LinearSystemSolver, System, tmp_timestepsize, YkImEul, rhs); - float_t tmp = norm(System, YkImEul, YkAdBas); + float_t tmp = norm(System, YkImEul, YkAdBas); - tmp_timestepsize_new = nextTimestep(tmp_timestepsize, tmp_timestepsize_old, tmp, - epsilon); + tmp_timestepsize_new = nextTimestep(tmp_timestepsize, tmp_timestepsize_old, tmp, epsilon); if (0.8 * tmp_timestepsize > tmp_timestepsize_new) { if (_gamma <= 0.0) @@ -153,16 +143,16 @@ void StepsizeControl::solve(SLESolver& LinearSystemSolver, allIter += LinearSystemSolver.getNumberIterations(); } else { - fileout << i << " " << (tmp_timestepsize_new - tmp_timestepsize) << " " << time - << " " << tmp_timestepsize << std::endl; + fileout << i << " " << (tmp_timestepsize_new - tmp_timestepsize) << " " << time << " " + << tmp_timestepsize << std::endl; time += tmp_timestepsize; allIter += LinearSystemSolver.getNumberIterations(); if (verbose == true) { if (myScreen == NULL) { std::cout << "Final residuum " << LinearSystemSolver.getResiduum() << "; with " - << LinearSystemSolver.getNumberIterations() << " Iterations (Total Iter.: " << - allIter << ")" << std::endl; + << LinearSystemSolver.getNumberIterations() + << " Iterations (Total Iter.: " << allIter << ")" << std::endl; } } @@ -170,11 +160,11 @@ void StepsizeControl::solve(SLESolver& LinearSystemSolver, std::stringstream soutput; soutput << " Final residuum " << LinearSystemSolver.getResiduum() << "; with " - << LinearSystemSolver.getNumberIterations() << " Iterations (Total Iter.: " << - allIter << ")"; + << LinearSystemSolver.getNumberIterations() + << " Iterations (Total Iter.: " << allIter << ")"; if (i < this->nMaxIterations - 1) { - myScreen->update((size_t)(((float_t)(time) * 100.0) / ((float_t)maxTimestep)), + myScreen->update((size_t)(((float_t)(time)*100.0) / ((float_t)maxTimestep)), soutput.str()); } else { myScreen->update(100, soutput.str()); @@ -203,9 +193,7 @@ void StepsizeControl::solve(SLESolver& LinearSystemSolver, // adapt size of last time step tmp_timestepsize = std::min(tmp_timestepsize, maxTimestep - time); - } - } fileout.close(); @@ -214,11 +202,6 @@ void StepsizeControl::solve(SLESolver& LinearSystemSolver, if (myScreen != NULL) { myScreen->writeEmptyLines(2); } - - - -} -} - - } +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/ode/StepsizeControl.hpp b/solver/src/sgpp/solver/ode/StepsizeControl.hpp index 3ddeee6bda..d7992e1145 100644 --- a/solver/src/sgpp/solver/ode/StepsizeControl.hpp +++ b/solver/src/sgpp/solver/ode/StepsizeControl.hpp @@ -9,10 +9,10 @@ #include #include #include -#include -// + #include +#include namespace SGPP { namespace solver { @@ -27,7 +27,6 @@ class StepsizeControl : public ODESolver { /// identify of grid coarsening is used bool useCoarsen; - protected: /// Pointer to SGPP::base::ScreenOutput object SGPP::base::ScreenOutput* myScreen; @@ -50,8 +49,8 @@ class StepsizeControl : public ODESolver { virtual float_t norm(SGPP::solver::OperationParabolicPDESolverSystem& System, SGPP::base::DataVector& dv1, SGPP::base::DataVector& dv2); - virtual float_t nextTimestep(float_t tmp_timestepsize, - float_t tmp_timestepsize_old, float_t norm, float_t epsilon) = 0; + virtual float_t nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, float_t norm, + float_t epsilon) = 0; float_t twoNorm(SGPP::solver::OperationParabolicPDESolverSystem& System, SGPP::base::DataVector& dv1, SGPP::base::DataVector& dv2); @@ -64,7 +63,6 @@ class StepsizeControl : public ODESolver { /// damping factor float_t _gamma; - public: /** * Std-Constructer @@ -84,12 +82,11 @@ class StepsizeControl : public ODESolver { */ virtual ~StepsizeControl(); - void solve(SLESolver& LinearSystemSolver, - SGPP::solver::OperationParabolicPDESolverSystem& System, + void solve(SLESolver& LinearSystemSolver, SGPP::solver::OperationParabolicPDESolverSystem& System, bool bIdentifyLastStep = false, bool verbose = false); }; -} -} +} // namespace solver +} // namespace SGPP #endif /* STEPSIZECONTROL_H_ */ diff --git a/solver/src/sgpp/solver/ode/StepsizeControlBDF.cpp b/solver/src/sgpp/solver/ode/StepsizeControlBDF.cpp index a428a2263d..351fe32cb6 100644 --- a/solver/src/sgpp/solver/ode/StepsizeControlBDF.cpp +++ b/solver/src/sgpp/solver/ode/StepsizeControlBDF.cpp @@ -6,32 +6,30 @@ #include #include +#include + #include #include #include #include #include -#include - - namespace SGPP { namespace solver { -StepsizeControlBDF::StepsizeControlBDF(size_t nTimesteps, float_t timestepSize, - float_t eps, SGPP::base::ScreenOutput* screen) - : VarTimestep("AdBas", "BDF2", nTimesteps, timestepSize, eps, screen) { +StepsizeControlBDF::StepsizeControlBDF(size_t nTimesteps, float_t timestepSize, float_t eps, + SGPP::base::ScreenOutput* screen) + : VarTimestep("AdBas", "BDF2", nTimesteps, timestepSize, eps, screen) { std::stringstream fnsstream; - fnsstream << "Time_" << "SCBDF" << this->myEps << ".gnuplot"; + fnsstream << "Time_" + << "SCBDF" << this->myEps << ".gnuplot"; filename = fnsstream.str(); } -StepsizeControlBDF::~StepsizeControlBDF() { -} - -float_t StepsizeControlBDF::nextTimestep(float_t tmp_timestepsize, - float_t tmp_timestepsize_old, float_t norm, float_t epsilon) { +StepsizeControlBDF::~StepsizeControlBDF() {} +float_t StepsizeControlBDF::nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, + float_t norm, float_t epsilon) { // float_t deltaY = u/(3.0*(1.0+tmp_timestepsize/tmp_timestepsize_old)); /* float_t epsilon = 0.001; @@ -45,7 +43,6 @@ float_t StepsizeControlBDF::nextTimestep(float_t tmp_timestepsize, tmp_timestepsize_new = tmp_timestepsize * sqrt(epsilon/deltaY); */ return tmp_timestepsize * pow(epsilon / norm, (float_t)1.0 / (float_t)3.0); - -} } -} \ No newline at end of file +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/ode/StepsizeControlBDF.hpp b/solver/src/sgpp/solver/ode/StepsizeControlBDF.hpp index 3c34b2c0b0..396f8340a5 100644 --- a/solver/src/sgpp/solver/ode/StepsizeControlBDF.hpp +++ b/solver/src/sgpp/solver/ode/StepsizeControlBDF.hpp @@ -12,7 +12,6 @@ #include - namespace SGPP { namespace solver { @@ -24,11 +23,10 @@ namespace solver { * already implemented CG-method is used * */ -class StepsizeControlBDF : public VarTimestep { +class StepsizeControlBDF : public VarTimestep { protected: - - float_t nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, - float_t norm, float_t epsilon); + float_t nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, float_t norm, + float_t epsilon); public: /** @@ -46,10 +44,9 @@ class StepsizeControlBDF : public VarTimestep { * Std-Destructor */ virtual ~StepsizeControlBDF(); - }; -} -} +} // namespace solver +} // namespace SGPP -#endif /* STEPSIZECONTROLBDF_HPP */ \ No newline at end of file +#endif /* STEPSIZECONTROLBDF_HPP */ diff --git a/solver/src/sgpp/solver/ode/StepsizeControlEJ.cpp b/solver/src/sgpp/solver/ode/StepsizeControlEJ.cpp index d8160869bf..5bfe23e369 100644 --- a/solver/src/sgpp/solver/ode/StepsizeControlEJ.cpp +++ b/solver/src/sgpp/solver/ode/StepsizeControlEJ.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -17,31 +18,26 @@ #include #include -#include - - namespace SGPP { namespace solver { -StepsizeControlEJ::StepsizeControlEJ(std::string odesolver, size_t nTimesteps, - float_t timestepSize, float_t eps, float_t sc, SGPP::base::ScreenOutput* screen, +StepsizeControlEJ::StepsizeControlEJ(std::string odesolver, size_t nTimesteps, float_t timestepSize, + float_t eps, float_t sc, SGPP::base::ScreenOutput* screen, float_t gamma) - : StepsizeControl(nTimesteps, timestepSize, eps, sc, screen, gamma), - _odesolver(odesolver) { + : StepsizeControl(nTimesteps, timestepSize, eps, sc, screen, gamma), _odesolver(odesolver) { std::stringstream fnsstream; - fnsstream << "Time_" << "SCEJ" << this->myEps << "_" << this->mySC << - ".gnuplot"; + fnsstream << "Time_" + << "SCEJ" << this->myEps << "_" << this->mySC << ".gnuplot"; filename = fnsstream.str(); } -StepsizeControlEJ::~StepsizeControlEJ() { -} +StepsizeControlEJ::~StepsizeControlEJ() {} void StepsizeControlEJ::predictor(SLESolver& LinearSystemSolver, SGPP::solver::OperationParabolicPDESolverSystem& System, float_t tmp_timestepsize, SGPP::base::DataVector& dv, SGPP::base::DataVector& corr, SGPP::base::DataVector* rhs) { - //pred() + // pred() dv.resize(corr.getSize()); dv.setAll(0.0); dv.add(corr); @@ -51,7 +47,7 @@ void StepsizeControlEJ::corrector(SLESolver& LinearSystemSolver, SGPP::solver::OperationParabolicPDESolverSystem& System, float_t tmp_timestepsize, SGPP::base::DataVector& dv, SGPP::base::DataVector* rhs) { - //corr() + // corr() System.setODESolver(_odesolver); @@ -61,8 +57,7 @@ void StepsizeControlEJ::corrector(SLESolver& LinearSystemSolver, rhs = System.generateRHS(); // solve the system of the current timestep - LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, - false, -1.0); + LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, false, -1.0); System.finishTimestep(); dv.resize(System.getGridCoefficients()->getSize()); @@ -71,14 +66,14 @@ void StepsizeControlEJ::corrector(SLESolver& LinearSystemSolver, // end corr() } -float_t StepsizeControlEJ::norm(SGPP::solver::OperationParabolicPDESolverSystem& - System, SGPP::base::DataVector& dv1, SGPP::base::DataVector& dv2) { +float_t StepsizeControlEJ::norm(SGPP::solver::OperationParabolicPDESolverSystem& System, + SGPP::base::DataVector& dv1, SGPP::base::DataVector& dv2) { return maxNorm(System, dv1, dv2); } -float_t StepsizeControlEJ::nextTimestep(float_t tmp_timestepsize, - float_t tmp_timestepsize_old, float_t norm, float_t epsilon) { +float_t StepsizeControlEJ::nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, + float_t norm, float_t epsilon) { return tmp_timestepsize * epsilon / norm; } -} -} +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/ode/StepsizeControlEJ.hpp b/solver/src/sgpp/solver/ode/StepsizeControlEJ.hpp index 1e7a6772e4..75d3a5ffce 100644 --- a/solver/src/sgpp/solver/ode/StepsizeControlEJ.hpp +++ b/solver/src/sgpp/solver/ode/StepsizeControlEJ.hpp @@ -12,6 +12,7 @@ #include +#include namespace SGPP { namespace solver { @@ -36,12 +37,13 @@ class StepsizeControlEJ : public StepsizeControl { float_t tmp_timestepsize, SGPP::base::DataVector& dv, SGPP::base::DataVector* rhs); - virtual float_t nextTimestep(float_t tmp_timestepsize, - float_t tmp_timestepsize_old, float_t norm, float_t epsilon); + virtual float_t nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, float_t norm, + float_t epsilon); virtual float_t norm(SGPP::solver::OperationParabolicPDESolverSystem& System, SGPP::base::DataVector& dv1, SGPP::base::DataVector& dv2); std::string _odesolver; + public: /** * Std-Constructer @@ -54,9 +56,8 @@ class StepsizeControlEJ : public StepsizeControl { * @param screen possible pointer to a SGPP::base::ScreenOutput object * @param gamma used damping factor, default is 0.5 */ - StepsizeControlEJ(std::string odesolver, size_t nTimesteps, - float_t timestepSize, float_t eps, float_t sc, - SGPP::base::ScreenOutput* screen = NULL, float_t gamma = 0.5); + StepsizeControlEJ(std::string odesolver, size_t nTimesteps, float_t timestepSize, float_t eps, + float_t sc, SGPP::base::ScreenOutput* screen = NULL, float_t gamma = 0.5); /** * Std-Destructor @@ -64,7 +65,7 @@ class StepsizeControlEJ : public StepsizeControl { virtual ~StepsizeControlEJ(); }; -} -} +} // namespace solver +} // namespace SGPP #endif /* STEPSIZECONTROLEJ_HPP */ diff --git a/solver/src/sgpp/solver/ode/StepsizeControlH.cpp b/solver/src/sgpp/solver/ode/StepsizeControlH.cpp index e794b895c0..4f427bff5e 100644 --- a/solver/src/sgpp/solver/ode/StepsizeControlH.cpp +++ b/solver/src/sgpp/solver/ode/StepsizeControlH.cpp @@ -9,31 +9,28 @@ #include #include +#include + #include #include #include #include -#include - - namespace SGPP { namespace solver { -StepsizeControlH::StepsizeControlH(std::string odesolver, size_t imax, - float_t timestepSize, float_t eps, SGPP::base::ScreenOutput* screen, - float_t gamma) - : StepsizeControl(imax, timestepSize, eps, 1.0, screen, gamma), - _odesolver(odesolver) { +StepsizeControlH::StepsizeControlH(std::string odesolver, size_t imax, float_t timestepSize, + float_t eps, SGPP::base::ScreenOutput* screen, float_t gamma) + : StepsizeControl(imax, timestepSize, eps, 1.0, screen, gamma), _odesolver(odesolver) { this->residuum = 0.0; this->myEps = eps; std::stringstream fnsstream; - fnsstream << "Time_" << "SCH" << this->myEps << ".gnuplot"; + fnsstream << "Time_" + << "SCH" << this->myEps << ".gnuplot"; filename = fnsstream.str(); } -StepsizeControlH::~StepsizeControlH() { -} +StepsizeControlH::~StepsizeControlH() {} void StepsizeControlH::predictor(SLESolver& LinearSystemSolver, SGPP::solver::OperationParabolicPDESolverSystem& System, @@ -46,8 +43,7 @@ void StepsizeControlH::predictor(SLESolver& LinearSystemSolver, rhs = System.generateRHS(); // solve the system of the current timesteps - LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, - false, -1.0); + LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, false, -1.0); System.finishTimestep(); @@ -68,27 +64,23 @@ void StepsizeControlH::corrector(SLESolver& LinearSystemSolver, rhs = System.generateRHS(); // solve the system of the current timesteps - LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, - false, -1.0); + LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, false, -1.0); System.finishTimestep(); rhs = System.generateRHS(); - LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, - false, -1.0); + LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, false, -1.0); System.finishTimestep(); dv.resize(System.getGridCoefficients()->getSize()); System.getGridCoefficientsForSC(dv); } - -float_t StepsizeControlH::nextTimestep(float_t tmp_timestepsize, - float_t tmp_timestepsize_old, float_t norm, float_t epsilon) { +float_t StepsizeControlH::nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, + float_t norm, float_t epsilon) { float_t deltaY = 3.0 * norm / 4.0; return tmp_timestepsize * pow(epsilon / deltaY, (float_t)1.0 / (float_t)3.0); - -} -} } +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/ode/StepsizeControlH.hpp b/solver/src/sgpp/solver/ode/StepsizeControlH.hpp index a5a5df2f74..5921be919b 100644 --- a/solver/src/sgpp/solver/ode/StepsizeControlH.hpp +++ b/solver/src/sgpp/solver/ode/StepsizeControlH.hpp @@ -8,12 +8,11 @@ #include #include -#include #include -// #include +#include namespace SGPP { namespace solver { @@ -25,25 +24,21 @@ namespace solver { */ class StepsizeControlH : public StepsizeControl { private: - - void predictor(SLESolver& LinearSystemSolver, - SGPP::solver::OperationParabolicPDESolverSystem& System, - float_t tmp_timestepsize, SGPP::base::DataVector& dv, - SGPP::base::DataVector& corr, SGPP::base::DataVector* rhs); - void corrector(SLESolver& LinearSystemSolver, - SGPP::solver::OperationParabolicPDESolverSystem& System, - float_t tmp_timestepsize, SGPP::base::DataVector& dv, + SGPP::solver::OperationParabolicPDESolverSystem& System, float_t tmp_timestepsize, + SGPP::base::DataVector& dv, SGPP::base::DataVector& corr, SGPP::base::DataVector* rhs); + void corrector(SLESolver& LinearSystemSolver, + SGPP::solver::OperationParabolicPDESolverSystem& System, float_t tmp_timestepsize, + SGPP::base::DataVector& dv, SGPP::base::DataVector* rhs); - //float_t twoNorm(SGPP::base::DataVector &dv1, SGPP::base::DataVector &dv2); + // float_t twoNorm(SGPP::base::DataVector &dv1, SGPP::base::DataVector &dv2); - float_t nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, - float_t norm, float_t epsilon); + float_t nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, float_t norm, + float_t epsilon); std::string _odesolver; - public: /** * Std-Constructer @@ -55,8 +50,8 @@ class StepsizeControlH : public StepsizeControl { * @param screen possible pointer to a SGPP::base::ScreenOutput object * @param gamma damping factor */ - StepsizeControlH(std::string odesolver, size_t imax, float_t timestepSize, - float_t eps, SGPP::base::ScreenOutput* screen = NULL, float_t gamma = 0.9); + StepsizeControlH(std::string odesolver, size_t imax, float_t timestepSize, float_t eps, + SGPP::base::ScreenOutput* screen = NULL, float_t gamma = 0.9); /** * Std-Destructor @@ -64,7 +59,7 @@ class StepsizeControlH : public StepsizeControl { virtual ~StepsizeControlH(); }; -} -} +} // namespace solver +} // namespace SGPP #endif /* STEPSIZECONTROLH_HPP */ diff --git a/solver/src/sgpp/solver/ode/StepsizeControlMC.cpp b/solver/src/sgpp/solver/ode/StepsizeControlMC.cpp index 8f3dda8dd7..636530c517 100644 --- a/solver/src/sgpp/solver/ode/StepsizeControlMC.cpp +++ b/solver/src/sgpp/solver/ode/StepsizeControlMC.cpp @@ -9,36 +9,33 @@ #include #include +#include #include #include #include #include - -#include - +#include namespace SGPP { namespace solver { -StepsizeControlMC::StepsizeControlMC(size_t imax, float_t timestepSize, - float_t eps, SGPP::base::ScreenOutput* screen) - : VarTimestep("MPR", "CrNic", imax, timestepSize, eps, screen) { +StepsizeControlMC::StepsizeControlMC(size_t imax, float_t timestepSize, float_t eps, + SGPP::base::ScreenOutput* screen) + : VarTimestep("MPR", "CrNic", imax, timestepSize, eps, screen) { std::stringstream fnsstream; - fnsstream << "Time_" << "SCMC" << eps << ".gnuplot"; + fnsstream << "Time_" + << "SCMC" << eps << ".gnuplot"; filename = fnsstream.str(); - } -StepsizeControlMC::~StepsizeControlMC() { -} +StepsizeControlMC::~StepsizeControlMC() {} -float_t StepsizeControlMC::nextTimestep(float_t tmp_timestepsize, - float_t tmp_timestepsize_old, float_t norm, float_t epsilon) { +float_t StepsizeControlMC::nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, + float_t norm, float_t epsilon) { float_t deltaY = norm; - return tmp_timestepsize * std::max(0.67, std::min(1.5, pow(epsilon / deltaY, - (float_t)1.0 / (float_t)3.0))); - -} + return tmp_timestepsize * + std::max(0.67, std::min(1.5, pow(epsilon / deltaY, (float_t)1.0 / (float_t)3.0))); } -} \ No newline at end of file +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/ode/StepsizeControlMC.hpp b/solver/src/sgpp/solver/ode/StepsizeControlMC.hpp index ef80c5bd60..a091f46e47 100644 --- a/solver/src/sgpp/solver/ode/StepsizeControlMC.hpp +++ b/solver/src/sgpp/solver/ode/StepsizeControlMC.hpp @@ -8,12 +8,11 @@ #include #include -#include #include - #include +#include namespace SGPP { namespace solver { @@ -25,9 +24,8 @@ namespace solver { */ class StepsizeControlMC : public VarTimestep { protected: - - float_t nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, - float_t norm, float_t epsilon); + float_t nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, float_t norm, + float_t epsilon); public: /** @@ -47,7 +45,7 @@ class StepsizeControlMC : public VarTimestep { virtual ~StepsizeControlMC(); }; -} -} +} // namespace solver +} // namespace SGPP -#endif /* STEPSIZECONTROLMC_HPP */ \ No newline at end of file +#endif /* STEPSIZECONTROLMC_HPP */ diff --git a/solver/src/sgpp/solver/ode/VarTimestep.cpp b/solver/src/sgpp/solver/ode/VarTimestep.cpp index 03a80e5649..cc8b664645 100644 --- a/solver/src/sgpp/solver/ode/VarTimestep.cpp +++ b/solver/src/sgpp/solver/ode/VarTimestep.cpp @@ -9,34 +9,31 @@ #include #include +#include + #include #include #include #include #include -#include - - namespace SGPP { namespace solver { -VarTimestep::VarTimestep(std::string pred, std::string corr, size_t imax, - float_t timestepSize, float_t eps, SGPP::base::ScreenOutput* screen, - float_t gamma) - : StepsizeControl(imax, timestepSize, eps, 1.0, screen, gamma), - _predictor(pred), _corrector(corr) { - +VarTimestep::VarTimestep(std::string pred, std::string corr, size_t imax, float_t timestepSize, + float_t eps, SGPP::base::ScreenOutput* screen, float_t gamma) + : StepsizeControl(imax, timestepSize, eps, 1.0, screen, gamma), + _predictor(pred), + _corrector(corr) { std::stringstream fnsstream; - fnsstream << "Time_" << "VaTim" << eps << ".gnuplot"; + fnsstream << "Time_" + << "VaTim" << eps << ".gnuplot"; filename = fnsstream.str(); - } -VarTimestep::~VarTimestep() { -} +VarTimestep::~VarTimestep() {} void VarTimestep::predictor(SLESolver& LinearSystemSolver, SGPP::solver::OperationParabolicPDESolverSystem& System, @@ -50,8 +47,7 @@ void VarTimestep::predictor(SLESolver& LinearSystemSolver, rhs = System.generateRHS(); // solve the system of the current timestep - LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, - false, -1.0); + LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, false, -1.0); System.finishTimestep(); @@ -72,23 +68,19 @@ void VarTimestep::corrector(SLESolver& LinearSystemSolver, rhs = System.generateRHS(); // solve the system of the current timestep - LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, - false, -1.0); + LinearSystemSolver.solve(System, *System.getGridCoefficientsForCG(), *rhs, true, false, -1.0); System.finishTimestep(); System.getGridCoefficientsForSC(dv); } - -float_t VarTimestep::nextTimestep(float_t tmp_timestepsize, - float_t tmp_timestepsize_old, float_t norm, float_t epsilon) { - +float_t VarTimestep::nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, + float_t norm, float_t epsilon) { float_t deltaY = norm / (3.0 * (1.0 + tmp_timestepsize / tmp_timestepsize_old)); - return tmp_timestepsize * std::max(0.67, std::min(1.5, pow(epsilon / deltaY, - (float_t)1.0 / (float_t)3.0))); - -} -} + return tmp_timestepsize * + std::max(0.67, std::min(1.5, pow(epsilon / deltaY, (float_t)1.0 / (float_t)3.0))); } +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/ode/VarTimestep.hpp b/solver/src/sgpp/solver/ode/VarTimestep.hpp index 3e4f5206fb..2a6292766c 100644 --- a/solver/src/sgpp/solver/ode/VarTimestep.hpp +++ b/solver/src/sgpp/solver/ode/VarTimestep.hpp @@ -9,10 +9,9 @@ #include #include #include -#include -// #include +#include namespace SGPP { namespace solver { @@ -25,21 +24,19 @@ namespace solver { class VarTimestep : public StepsizeControl { protected: void predictor(SLESolver& LinearSystemSolver, - SGPP::solver::OperationParabolicPDESolverSystem& System, - float_t tmp_timestepsize, SGPP::base::DataVector& dv, - SGPP::base::DataVector& corr, SGPP::base::DataVector* rhs); - void corrector(SLESolver& LinearSystemSolver, - SGPP::solver::OperationParabolicPDESolverSystem& System, - float_t tmp_timestepsize, SGPP::base::DataVector& dv, + SGPP::solver::OperationParabolicPDESolverSystem& System, float_t tmp_timestepsize, + SGPP::base::DataVector& dv, SGPP::base::DataVector& corr, SGPP::base::DataVector* rhs); + void corrector(SLESolver& LinearSystemSolver, + SGPP::solver::OperationParabolicPDESolverSystem& System, float_t tmp_timestepsize, + SGPP::base::DataVector& dv, SGPP::base::DataVector* rhs); - virtual float_t nextTimestep(float_t tmp_timestepsize, - float_t tmp_timestepsize_old, float_t norm, float_t epsilon); + virtual float_t nextTimestep(float_t tmp_timestepsize, float_t tmp_timestepsize_old, float_t norm, + float_t epsilon); std::string _predictor; std::string _corrector; - public: /** * Std-Constructer @@ -52,9 +49,8 @@ class VarTimestep : public StepsizeControl { * @param screen possible pointer to a SGPP::base::ScreenOutput object * @param gamma damping factor */ - VarTimestep(std::string pred, std::string corr, size_t imax, - float_t timestepSize, float_t eps, SGPP::base::ScreenOutput* screen = NULL, - float_t gamma = -1); + VarTimestep(std::string pred, std::string corr, size_t imax, float_t timestepSize, float_t eps, + SGPP::base::ScreenOutput* screen = NULL, float_t gamma = -1); /** * Std-Destructor @@ -62,7 +58,7 @@ class VarTimestep : public StepsizeControl { virtual ~VarTimestep(); }; -} -} +} // namespace solver +} // namespace SGPP #endif /* VARTIMESTEP_HPP */ diff --git a/solver/src/sgpp/solver/operation/hash/OperationParabolicPDESolverSystem.cpp b/solver/src/sgpp/solver/operation/hash/OperationParabolicPDESolverSystem.cpp index 680c0d1e1c..d2070a379b 100644 --- a/solver/src/sgpp/solver/operation/hash/OperationParabolicPDESolverSystem.cpp +++ b/solver/src/sgpp/solver/operation/hash/OperationParabolicPDESolverSystem.cpp @@ -9,6 +9,7 @@ #include +#include namespace SGPP { namespace solver { @@ -19,40 +20,31 @@ OperationParabolicPDESolverSystem::OperationParabolicPDESolverSystem() { this->bnewODESolver = false; } -OperationParabolicPDESolverSystem::~OperationParabolicPDESolverSystem() { -} +OperationParabolicPDESolverSystem::~OperationParabolicPDESolverSystem() {} -SGPP::base::DataVector* -OperationParabolicPDESolverSystem::getGridCoefficients() { +SGPP::base::DataVector* OperationParabolicPDESolverSystem::getGridCoefficients() { return this->alpha_complete; } -SGPP::base::Grid* OperationParabolicPDESolverSystem::getGrid() { - return this->BoundGrid; -} +SGPP::base::Grid* OperationParabolicPDESolverSystem::getGrid() { return this->BoundGrid; } void OperationParabolicPDESolverSystem::setODESolver(std::string ode) { this->tOperationMode = ode; this->bnewODESolver = true; } -std::string OperationParabolicPDESolverSystem::getODESolver() { - return this->tOperationMode; -} +std::string OperationParabolicPDESolverSystem::getODESolver() { return this->tOperationMode; } -void OperationParabolicPDESolverSystem::setTimestepSize( - float_t newTimestepSize) { +void OperationParabolicPDESolverSystem::setTimestepSize(float_t newTimestepSize) { this->TimestepSize_old = this->TimestepSize; this->TimestepSize = newTimestepSize; } void OperationParabolicPDESolverSystem::abortTimestep() { delete this->secondGridStorage; - this->secondGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); + this->secondGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); - if ((this->alpha_complete)->getSize() != - (this->alpha_complete_tmp)->getSize()) { + if ((this->alpha_complete)->getSize() != (this->alpha_complete_tmp)->getSize()) { (this->alpha_complete)->resize((this->alpha_complete_tmp)->getSize()); } @@ -61,11 +53,9 @@ void OperationParabolicPDESolverSystem::abortTimestep() { void OperationParabolicPDESolverSystem::saveAlpha() { delete this->oldGridStorage; - this->oldGridStorage = new SGPP::base::GridStorage(* - (this->BoundGrid)->getStorage()); + this->oldGridStorage = new SGPP::base::GridStorage(*(this->BoundGrid)->getStorage()); - if ((this->alpha_complete_old)->getSize() != - (this->alpha_complete_tmp)->getSize()) + if ((this->alpha_complete_old)->getSize() != (this->alpha_complete_tmp)->getSize()) (this->alpha_complete_old)->resize((this->alpha_complete_tmp)->getSize()); *(this->alpha_complete_old) = *(this->alpha_complete_tmp); @@ -84,11 +74,10 @@ size_t OperationParabolicPDESolverSystem::getSumGridPointsInner() { return this->numSumGridpointsInner; } -void OperationParabolicPDESolverSystem::getGridCoefficientsForSC( - SGPP::base::DataVector& Values) { +void OperationParabolicPDESolverSystem::getGridCoefficientsForSC(SGPP::base::DataVector& Values) { Values = *(this->alpha_complete); SGPP::base::OperationHierarchisation* myHierarchisation = - SGPP::op_factory::createOperationHierarchisation(*BoundGrid); + SGPP::op_factory::createOperationHierarchisation(*BoundGrid); myHierarchisation->doDehierarchisation(Values); delete myHierarchisation; } @@ -97,15 +86,13 @@ SGPP::base::GridStorage* OperationParabolicPDESolverSystem::getGridStorage() { return (this->BoundGrid)->getStorage(); } -SGPP::base::GridStorage* -OperationParabolicPDESolverSystem::getOldGridStorage() { +SGPP::base::GridStorage* OperationParabolicPDESolverSystem::getOldGridStorage() { return oldGridStorage; } -SGPP::base::GridStorage* -OperationParabolicPDESolverSystem::getSecondGridStorage() { +SGPP::base::GridStorage* OperationParabolicPDESolverSystem::getSecondGridStorage() { return secondGridStorage; } -} -} +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/operation/hash/OperationParabolicPDESolverSystem.hpp b/solver/src/sgpp/solver/operation/hash/OperationParabolicPDESolverSystem.hpp index 4c49d212b2..d0c74633bd 100644 --- a/solver/src/sgpp/solver/operation/hash/OperationParabolicPDESolverSystem.hpp +++ b/solver/src/sgpp/solver/operation/hash/OperationParabolicPDESolverSystem.hpp @@ -12,6 +12,7 @@ #include +#include namespace SGPP { namespace solver { @@ -77,10 +78,10 @@ class OperationParabolicPDESolverSystem : public SGPP::base::OperationMatrix { * Multiplicates a vector with the matrix * * @param alpha SGPP::base::DataVector that contains the ansatzfunctions' coefficients - * @param result SGPP::base::DataVector into which the result of the space discretization operation is stored + * @param result SGPP::base::DataVector into which the result of the space discretization + * operation is stored */ - virtual void mult(SGPP::base::DataVector& alpha, - SGPP::base::DataVector& result) = 0; + virtual void mult(SGPP::base::DataVector& alpha, SGPP::base::DataVector& result) = 0; /** * generates the right hand side of the system @@ -97,7 +98,6 @@ class OperationParabolicPDESolverSystem : public SGPP::base::OperationMatrix { virtual void coarsenAndRefine(bool isLastTimestep = false) = 0; - /** * Implements some start jobs of every timestep, e.g.discounting boundaries */ @@ -174,7 +174,8 @@ class OperationParabolicPDESolverSystem : public SGPP::base::OperationMatrix { void saveAlpha(); /** - * stores the values of the (dehierarchized) grid in the SGPP::base::DataVector Values used by time step size control methods + * stores the values of the (dehierarchized) grid in the SGPP::base::DataVector Values used by + * time step size control methods * * @param Values SGPP::base::DataVector in which the values will be stored */ @@ -187,7 +188,7 @@ class OperationParabolicPDESolverSystem : public SGPP::base::OperationMatrix { SGPP::base::GridStorage* getSecondGridStorage(); }; -} -} +} // namespace solver +} // namespace SGPP #endif /* OPERATIONPARABOLICPDESOLVERSYSTEM_HPP */ diff --git a/solver/src/sgpp/solver/sle/BiCGStab.cpp b/solver/src/sgpp/solver/sle/BiCGStab.cpp index 1a4d939101..b359dbd98e 100644 --- a/solver/src/sgpp/solver/sle/BiCGStab.cpp +++ b/solver/src/sgpp/solver/sle/BiCGStab.cpp @@ -4,23 +4,19 @@ // sgpp.sparsegrids.org #include -#include - #include +#include namespace SGPP { namespace solver { -BiCGStab::BiCGStab(size_t imax, float_t epsilon) : SLESolver(imax, epsilon) { -} +BiCGStab::BiCGStab(size_t imax, float_t epsilon) : SLESolver(imax, epsilon) {} -BiCGStab::~BiCGStab() { -} +BiCGStab::~BiCGStab() {} -void BiCGStab::solve(SGPP::base::OperationMatrix& SystemMatrix, - SGPP::base::DataVector& alpha, SGPP::base::DataVector& b, bool reuse, - bool verbose, float_t max_threshold) { +void BiCGStab::solve(SGPP::base::OperationMatrix& SystemMatrix, SGPP::base::DataVector& alpha, + SGPP::base::DataVector& b, bool reuse, bool verbose, float_t max_threshold) { this->nIterations = 1; float_t epsilonSqd = this->myEpsilon * this->myEpsilon; @@ -29,7 +25,7 @@ void BiCGStab::solve(SGPP::base::OperationMatrix& SystemMatrix, alpha.setAll(0.0); } - //Calculate r0 + // Calculate r0 SGPP::base::DataVector r(alpha.getSize()); SystemMatrix.mult(alpha, r); r.sub(b); @@ -38,10 +34,10 @@ void BiCGStab::solve(SGPP::base::OperationMatrix& SystemMatrix, float_t delta = 0.0; if (verbose == true) { - std::cout << "delta_0 " << delta_0 << std::endl; + std::cout << "delta_0 " << delta_0 << std::endl; } - //Choose r0 as r + // Choose r0 as r SGPP::base::DataVector rZero(r); // Set p as r0 SGPP::base::DataVector p(rZero); @@ -66,7 +62,7 @@ void BiCGStab::solve(SGPP::base::OperationMatrix& SystemMatrix, s.setAll(0.0); SystemMatrix.mult(p, s); - //std::cout << "s " << s.get(0) << " " << s.get(1) << std::endl; + // std::cout << "s " << s.get(0) << " " << s.get(1) << std::endl; sigma = s.dotProduct(rZero); @@ -78,23 +74,23 @@ void BiCGStab::solve(SGPP::base::OperationMatrix& SystemMatrix, // w = r - a*s w = r; - w.axpy((-1.0)*a, s); + w.axpy((-1.0) * a, s); // v = Aw v.setAll(0.0); SystemMatrix.mult(w, v); - //std::cout << "v " << v.get(0) << " " << v.get(1) << std::endl; + // std::cout << "v " << v.get(0) << " " << v.get(1) << std::endl; omega = (v.dotProduct(w)) / (v.dotProduct(v)); // x = x - a*p - omega*w - alpha.axpy((-1.0)*a, p); - alpha.axpy((-1.0)*omega, w); + alpha.axpy((-1.0) * a, p); + alpha.axpy((-1.0) * omega, w); // r = r - a*s - omega*v - r.axpy((-1.0)*a, s); - r.axpy((-1.0)*omega, v); + r.axpy((-1.0) * a, s); + r.axpy((-1.0) * omega, v); rho_new = r.dotProduct(rZero); @@ -115,7 +111,7 @@ void BiCGStab::solve(SGPP::base::OperationMatrix& SystemMatrix, rho = rho_new; // p = r + beta*(p - omega*s) - p.axpy((-1.0)*omega, s); + p.axpy((-1.0) * omega, s); p.mult(beta); p.add(r); @@ -123,5 +119,5 @@ void BiCGStab::solve(SGPP::base::OperationMatrix& SystemMatrix, } } -} -} \ No newline at end of file +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/sle/BiCGStab.hpp b/solver/src/sgpp/solver/sle/BiCGStab.hpp index 48f4abe6c3..58bc6455b8 100644 --- a/solver/src/sgpp/solver/sle/BiCGStab.hpp +++ b/solver/src/sgpp/solver/sle/BiCGStab.hpp @@ -10,18 +10,14 @@ #include #include -#include - #include +#include namespace SGPP { namespace solver { class BiCGStab : public SLESolver { - private: - - public: /** * Std-Constructor @@ -41,12 +37,12 @@ class BiCGStab : public SLESolver { * http://www.numerik.math.tu-graz.ac.at/kurse/lgs/SIMNET6.pdf * http://netlib.org */ - virtual void solve(SGPP::base::OperationMatrix& SystemMatrix, - SGPP::base::DataVector& alpha, SGPP::base::DataVector& b, bool reuse = false, - bool verbose = false, float_t max_threshold = -1.0); + virtual void solve(SGPP::base::OperationMatrix& SystemMatrix, SGPP::base::DataVector& alpha, + SGPP::base::DataVector& b, bool reuse = false, bool verbose = false, + float_t max_threshold = -1.0); }; -} -} +} // namespace solver +} // namespace SGPP -#endif /*BICGSTAB_HPP */ \ No newline at end of file +#endif /*BICGSTAB_HPP */ diff --git a/solver/src/sgpp/solver/sle/BiCGStabSP.cpp b/solver/src/sgpp/solver/sle/BiCGStabSP.cpp index ac9b970f30..52ab52c808 100644 --- a/solver/src/sgpp/solver/sle/BiCGStabSP.cpp +++ b/solver/src/sgpp/solver/sle/BiCGStabSP.cpp @@ -5,24 +5,19 @@ #include -#include - #include +#include namespace SGPP { namespace solver { -BiCGStabSP::BiCGStabSP(size_t imax, - float epsilon) : SGPP::solver::SLESolverSP(imax, epsilon) { -} +BiCGStabSP::BiCGStabSP(size_t imax, float epsilon) : SGPP::solver::SLESolverSP(imax, epsilon) {} -BiCGStabSP::~BiCGStabSP() { -} +BiCGStabSP::~BiCGStabSP() {} -void BiCGStabSP::solve(SGPP::base::OperationMatrixSP& SystemMatrix, - SGPP::base::DataVectorSP& alpha, SGPP::base::DataVectorSP& b, bool reuse, - bool verbose, float max_threshold) { +void BiCGStabSP::solve(SGPP::base::OperationMatrixSP& SystemMatrix, SGPP::base::DataVectorSP& alpha, + SGPP::base::DataVectorSP& b, bool reuse, bool verbose, float max_threshold) { this->nIterations = 1; float epsilonSqd = this->myEpsilon * this->myEpsilon; @@ -31,7 +26,7 @@ void BiCGStabSP::solve(SGPP::base::OperationMatrixSP& SystemMatrix, alpha.setAll(0.0f); } - //Calculate r0 + // Calculate r0 SGPP::base::DataVectorSP r(alpha.getSize()); SystemMatrix.mult(alpha, r); r.sub(b); @@ -40,10 +35,10 @@ void BiCGStabSP::solve(SGPP::base::OperationMatrixSP& SystemMatrix, float delta = 0.0f; if (verbose == true) { - std::cout << "delta_0 " << delta_0 << std::endl; + std::cout << "delta_0 " << delta_0 << std::endl; } - //Choose r0 as r + // Choose r0 as r SGPP::base::DataVectorSP rZero(r); // Set p as r0 SGPP::base::DataVectorSP p(rZero); @@ -68,7 +63,7 @@ void BiCGStabSP::solve(SGPP::base::OperationMatrixSP& SystemMatrix, s.setAll(0.0f); SystemMatrix.mult(p, s); - //std::cout << "s " << s.get(0) << " " << s.get(1) << std::endl; + // std::cout << "s " << s.get(0) << " " << s.get(1) << std::endl; sigma = s.dotProduct(rZero); @@ -80,23 +75,23 @@ void BiCGStabSP::solve(SGPP::base::OperationMatrixSP& SystemMatrix, // w = r - a*s w = r; - w.axpy((-1.0f)*a, s); + w.axpy((-1.0f) * a, s); // v = Aw v.setAll(0.0f); SystemMatrix.mult(w, v); - //std::cout << "v " << v.get(0) << " " << v.get(1) << std::endl; + // std::cout << "v " << v.get(0) << " " << v.get(1) << std::endl; omega = (v.dotProduct(w)) / (v.dotProduct(v)); // x = x - a*p - omega*w - alpha.axpy((-1.0f)*a, p); - alpha.axpy((-1.0f)*omega, w); + alpha.axpy((-1.0f) * a, p); + alpha.axpy((-1.0f) * omega, w); // r = r - a*s - omega*v - r.axpy((-1.0f)*a, s); - r.axpy((-1.0f)*omega, v); + r.axpy((-1.0f) * a, s); + r.axpy((-1.0f) * omega, v); rho_new = r.dotProduct(rZero); @@ -117,7 +112,7 @@ void BiCGStabSP::solve(SGPP::base::OperationMatrixSP& SystemMatrix, rho = rho_new; // p = r + beta*(p - omega*s) - p.axpy((-1.0f)*omega, s); + p.axpy((-1.0f) * omega, s); p.mult(beta); p.add(r); @@ -125,5 +120,5 @@ void BiCGStabSP::solve(SGPP::base::OperationMatrixSP& SystemMatrix, } } -} -} \ No newline at end of file +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/sle/BiCGStabSP.hpp b/solver/src/sgpp/solver/sle/BiCGStabSP.hpp index ff6917d689..4d8e93b404 100644 --- a/solver/src/sgpp/solver/sle/BiCGStabSP.hpp +++ b/solver/src/sgpp/solver/sle/BiCGStabSP.hpp @@ -11,18 +11,14 @@ #include -#include - #include +#include namespace SGPP { namespace solver { class BiCGStabSP : public SLESolverSP { - private: - - public: /** * Std-Constructor @@ -42,12 +38,12 @@ class BiCGStabSP : public SLESolverSP { * http://www.numerik.math.tu-graz.ac.at/kurse/lgs/SIMNET6.pdf * http://netlib.org */ - virtual void solve(SGPP::base::OperationMatrixSP& SystemMatrix, - SGPP::base::DataVectorSP& alpha, SGPP::base::DataVectorSP& b, - bool reuse = false, bool verbose = false, float max_threshold = -1.0); + virtual void solve(SGPP::base::OperationMatrixSP& SystemMatrix, SGPP::base::DataVectorSP& alpha, + SGPP::base::DataVectorSP& b, bool reuse = false, bool verbose = false, + float max_threshold = -1.0); }; -} -} +} // namespace solver +} // namespace SGPP -#endif /* BICGSTABSP_HPP */ \ No newline at end of file +#endif /* BICGSTABSP_HPP */ diff --git a/solver/src/sgpp/solver/sle/ConjugateGradients.cpp b/solver/src/sgpp/solver/sle/ConjugateGradients.cpp index 4bbc5b63d3..6833148648 100644 --- a/solver/src/sgpp/solver/sle/ConjugateGradients.cpp +++ b/solver/src/sgpp/solver/sle/ConjugateGradients.cpp @@ -8,20 +8,16 @@ #endif #include -#include - #include +#include namespace SGPP { namespace solver { -ConjugateGradients::ConjugateGradients(size_t imax, - float_t epsilon) : SLESolver(imax, epsilon) { -} +ConjugateGradients::ConjugateGradients(size_t imax, float_t epsilon) : SLESolver(imax, epsilon) {} -ConjugateGradients::~ConjugateGradients() { -} +ConjugateGradients::~ConjugateGradients() {} void ConjugateGradients::solve(SGPP::base::OperationMatrix& SystemMatrix, SGPP::base::DataVector& alpha, SGPP::base::DataVector& b, bool reuse, @@ -57,12 +53,11 @@ void ConjugateGradients::solve(SGPP::base::OperationMatrix& SystemMatrix, SystemMatrix.mult(q, temp); r.sub(temp); delta_0 = r.dotProduct(r) * epsilonSquared; - //delta_0 = r.dotProduct(r); + // delta_0 = r.dotProduct(r); } else { alpha.setAll(0.0); } - // calculate the starting residuum SystemMatrix.mult(alpha, temp); @@ -75,22 +70,20 @@ void ConjugateGradients::solve(SGPP::base::OperationMatrix& SystemMatrix, if (reuse == false) { delta_0 = delta_new * epsilonSquared; - //delta_0 = delta_new; + // delta_0 = delta_new; } this->residuum = (delta_0 / epsilonSquared); - //this->residuum = delta_0; + // this->residuum = delta_0; this->calcStarting(); if (verbose == true) { - std::cout << "Starting norm of residuum: " << (delta_0 / epsilonSquared) << - std::endl; + std::cout << "Starting norm of residuum: " << (delta_0 / epsilonSquared) << std::endl; std::cout << "Target norm: " << (delta_0) << std::endl; } - while ((this->nIterations < this->nMaxIterations) && (delta_new > delta_0) - && (delta_new > max_threshold)) { - + while ((this->nIterations < this->nMaxIterations) && (delta_new > delta_0) && + (delta_new > max_threshold)) { // //SGPP::base::DataVector *myAlpha = this->myLearner->alpha_; // if (this->nIterations == 42) { // for (size_t j = 0; j < d.getSize();j++) { @@ -151,23 +144,19 @@ void ConjugateGradients::solve(SGPP::base::OperationMatrix& SystemMatrix, this->complete(); if (verbose == true) { - std::cout << "Number of iterations: " << this->nIterations << " (max. " << - this->nMaxIterations << ")" << std::endl; + std::cout << "Number of iterations: " << this->nIterations << " (max. " << this->nMaxIterations + << ")" << std::endl; std::cout << "Final norm of residuum: " << delta_new << std::endl; } } -void ConjugateGradients::starting() { -} +void ConjugateGradients::starting() {} -void ConjugateGradients::calcStarting() { -} +void ConjugateGradients::calcStarting() {} -void ConjugateGradients::iterationComplete() { -} +void ConjugateGradients::iterationComplete() {} -void ConjugateGradients::complete() { -} +void ConjugateGradients::complete() {} -} -} +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/sle/ConjugateGradients.hpp b/solver/src/sgpp/solver/sle/ConjugateGradients.hpp index b7bb4c67f0..2ad36f9bb5 100644 --- a/solver/src/sgpp/solver/sle/ConjugateGradients.hpp +++ b/solver/src/sgpp/solver/sle/ConjugateGradients.hpp @@ -9,10 +9,9 @@ #include #include -#include - #include +#include namespace SGPP { namespace solver { @@ -29,9 +28,9 @@ class ConjugateGradients : public SLESolver { */ virtual ~ConjugateGradients(); - virtual void solve(SGPP::base::OperationMatrix& SystemMatrix, - SGPP::base::DataVector& alpha, SGPP::base::DataVector& b, bool reuse = false, - bool verbose = false, float_t max_threshold = -1.0); + virtual void solve(SGPP::base::OperationMatrix& SystemMatrix, SGPP::base::DataVector& alpha, + SGPP::base::DataVector& b, bool reuse = false, bool verbose = false, + float_t max_threshold = -1.0); // Define functions for observer pattern in python @@ -46,7 +45,8 @@ class ConjugateGradients : public SLESolver { virtual void calcStarting(); /** - * function that signals that one iteration step of the CG method has been completed (used in python) + * function that signals that one iteration step of the CG method has been completed (used in + * python) */ virtual void iterationComplete(); @@ -56,7 +56,7 @@ class ConjugateGradients : public SLESolver { virtual void complete(); }; -} -} +} // namespace solver +} // namespace SGPP -#endif /* CONJUGATEGRADIENTS_HPP */ \ No newline at end of file +#endif /* CONJUGATEGRADIENTS_HPP */ diff --git a/solver/src/sgpp/solver/sle/ConjugateGradientsSP.cpp b/solver/src/sgpp/solver/sle/ConjugateGradientsSP.cpp index 0d4c7a729f..313ef4644a 100644 --- a/solver/src/sgpp/solver/sle/ConjugateGradientsSP.cpp +++ b/solver/src/sgpp/solver/sle/ConjugateGradientsSP.cpp @@ -10,20 +10,17 @@ #include - namespace SGPP { namespace solver { -ConjugateGradientsSP::ConjugateGradientsSP(size_t imax, - float epsilon) : SLESolverSP(imax, epsilon) { -} +ConjugateGradientsSP::ConjugateGradientsSP(size_t imax, float epsilon) + : SLESolverSP(imax, epsilon) {} -ConjugateGradientsSP::~ConjugateGradientsSP() { -} +ConjugateGradientsSP::~ConjugateGradientsSP() {} void ConjugateGradientsSP::solve(SGPP::base::OperationMatrixSP& SystemMatrix, - SGPP::base::DataVectorSP& alpha, SGPP::base::DataVectorSP& b, bool reuse, - bool verbose, float max_threshold) { + SGPP::base::DataVectorSP& alpha, SGPP::base::DataVectorSP& b, + bool reuse, bool verbose, float max_threshold) { if (verbose == true) { std::cout << "Starting Conjugated Gradients" << std::endl; } @@ -73,13 +70,12 @@ void ConjugateGradientsSP::solve(SGPP::base::OperationMatrixSP& SystemMatrix, this->residuum = (delta_0 / epsilonSquared); if (verbose == true) { - std::cout << "Starting norm of residuum: " << (delta_0 / epsilonSquared) << - std::endl; + std::cout << "Starting norm of residuum: " << (delta_0 / epsilonSquared) << std::endl; std::cout << "Target norm: " << (delta_0) << std::endl; } - while ((this->nIterations < this->nMaxIterations) && (delta_new > delta_0) - && (delta_new > max_threshold)) { + while ((this->nIterations < this->nMaxIterations) && (delta_new > delta_0) && + (delta_new > max_threshold)) { // q = A*d SystemMatrix.mult(d, q); @@ -100,7 +96,6 @@ void ConjugateGradientsSP::solve(SGPP::base::OperationMatrixSP& SystemMatrix, r.axpy(-a, q); } - // calculate new deltas and determine beta delta_old = delta_new; delta_new = r.dotProduct(r); @@ -125,23 +120,19 @@ void ConjugateGradientsSP::solve(SGPP::base::OperationMatrixSP& SystemMatrix, this->residuum = delta_new; if (verbose == true) { - std::cout << "Number of iterations: " << this->nIterations << " (max. " << - this->nMaxIterations << ")" << std::endl; + std::cout << "Number of iterations: " << this->nIterations << " (max. " << this->nMaxIterations + << ")" << std::endl; std::cout << "Final norm of residuum: " << delta_new << std::endl; } } -void ConjugateGradientsSP::starting() { -} +void ConjugateGradientsSP::starting() {} -void ConjugateGradientsSP::calcStarting() { -} +void ConjugateGradientsSP::calcStarting() {} -void ConjugateGradientsSP::iterationComplete() { -} +void ConjugateGradientsSP::iterationComplete() {} -void ConjugateGradientsSP::complete() { -} +void ConjugateGradientsSP::complete() {} -} -} \ No newline at end of file +} // namespace solver +} // namespace SGPP diff --git a/solver/src/sgpp/solver/sle/ConjugateGradientsSP.hpp b/solver/src/sgpp/solver/sle/ConjugateGradientsSP.hpp index 87c71ea8de..2e9a914923 100644 --- a/solver/src/sgpp/solver/sle/ConjugateGradientsSP.hpp +++ b/solver/src/sgpp/solver/sle/ConjugateGradientsSP.hpp @@ -11,10 +11,9 @@ #include -#include - #include +#include namespace SGPP { namespace solver { @@ -32,19 +31,21 @@ class ConjugateGradientsSP : public SLESolverSP { virtual ~ConjugateGradientsSP(); /** - * function that defines a solve method for an iterative solver. In contrast to the normal solve routine + * function that defines a solve method for an iterative solver. In contrast to the normal solve + * routine * this method operates on sinlge precision data. * - * @param SystemMatrix reference to an SGPP::base::OperationMatrix Object that implements the matrix vector multiplication + * @param SystemMatrix reference to an SGPP::base::OperationMatrix Object that implements the + * matrix vector multiplication * @param alpha the sparse grid's coefficients which have to be determined * @param b the right hand side of the system of linear equations * @param reuse identifies if the alphas, stored in alpha at calling time, should be reused * @param verbose prints information during execution of the solver * @param max_threshold additional abort criteria for solver */ - void solve(SGPP::base::OperationMatrixSP& SystemMatrix, - SGPP::base::DataVectorSP& alpha, SGPP::base::DataVectorSP& b, - bool reuse = false, bool verbose = false, float max_threshold = -1.0); + void solve(SGPP::base::OperationMatrixSP& SystemMatrix, SGPP::base::DataVectorSP& alpha, + SGPP::base::DataVectorSP& b, bool reuse = false, bool verbose = false, + float max_threshold = -1.0); // Define functions for observer pattern in python @@ -59,7 +60,8 @@ class ConjugateGradientsSP : public SLESolverSP { virtual void calcStarting(); /** - * function that signals that one iteration step of the CG method has been completed (used in python) + * function that signals that one iteration step of the CG method has been completed (used in + * python) */ virtual void iterationComplete(); @@ -69,7 +71,7 @@ class ConjugateGradientsSP : public SLESolverSP { virtual void complete(); }; -} -} +} // namespace solver +} // namespace SGPP -#endif /* CONJUGATEGRADIENTSSP_HPP */ \ No newline at end of file +#endif /* CONJUGATEGRADIENTSSP_HPP */ diff --git a/solver/src/sgpp_solver.hpp b/solver/src/sgpp_solver.hpp index effc6bbd5c..7b00c689e7 100644 --- a/solver/src/sgpp_solver.hpp +++ b/solver/src/sgpp_solver.hpp @@ -6,7 +6,6 @@ #ifndef SOLVER_HPP #define SOLVER_HPP - #include #include #include diff --git a/tools/cpplint.py b/tools/cpplint.py index 60ba3b9686..00b1954c5b 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -56,7 +56,7 @@ _USAGE = """ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...] [--counting=total|toplevel|detailed] [--root=subdir] - [--linelength=digits] + [--linelength=digits] [--ignorecfg=yes|no] [file] ... The style guidelines this tries to follow are those in @@ -71,7 +71,7 @@ suppresses errors of all categories on that line. The files passed in will be linted; at least one file must be provided. - Default linted extensions are .cc, .cpp, .cu, .cuh and .h. Change the + Default linted extensions are .cc, .cpp, .hpp, .cu, .cuh and .h. Change the extensions with the --extensions flag. Flags: @@ -123,7 +123,7 @@ linelength=digits This is the allowed line length for the project. The default value is - 80 characters. + 100 characters. Examples: --linelength=120 @@ -134,6 +134,10 @@ Examples: --extensions=hpp,cpp + ignorecfg=yes,no + Whether cpplint.py will ignore all CPPLINT.cfg files (see below). The + default is not to ignore. + cpplint.py supports per-directory configurations specified in CPPLINT.cfg files. CPPLINT.cfg file can contain a number of key=value pairs. Currently the following options are supported: @@ -500,8 +504,13 @@ # The allowed extensions for file names # This is set by --extensions flag. +# _valid_extensions = set(['cc', 'h', 'cpp', 'cu', 'cuh']) _valid_extensions = set(['cc', 'h', 'cpp', 'hpp', 'cu', 'cuh']) +# Whether to ignore CPPLINT.cfg if it exists. +# This is set by --ignorecfg flag. +_ignore_cfg = False + def ParseNolintSuppressions(filename, raw_line, linenum, error): """Updates the global list of error-suppressions. @@ -6139,7 +6148,7 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]): _SetVerboseLevel(vlevel) _BackupFilters() - if not ProcessConfigOverrides(filename): + if (not _ignore_cfg) and (not ProcessConfigOverrides(filename)): _RestoreFilters() return @@ -6249,7 +6258,8 @@ def ParseArguments(args): 'filter=', 'root=', 'linelength=', - 'extensions=']) + 'extensions=', + 'ignorecfg=']) except getopt.GetoptError: PrintUsage('Invalid arguments.') @@ -6290,6 +6300,11 @@ def ParseArguments(args): _valid_extensions = set(val.split(',')) except ValueError: PrintUsage('Extensions must be comma seperated list.') + elif opt == '--ignorecfg': + global _ignore_cfg + if val not in ('yes', 'no'): + PrintUsage('Valid ignorecfg options are yes and no') + _ignore_cfg = (val == 'yes') if not filenames: PrintUsage('No files were specified.')