Skip to content
Snippets Groups Projects
Verified Commit 79153ab1 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

C++20 modernization: use some concepts

parent c28b1b6e
Branches
Tags
No related merge requests found
Pipeline #10365 passed
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <cmath> #include <cmath>
#include <concepts>
#include <limits> #include <limits>
#include <numbers> #include <numbers>
#include <vector> #include <vector>
...@@ -41,7 +42,7 @@ using namespace std; ...@@ -41,7 +42,7 @@ using namespace std;
constexpr double lb = .02425; constexpr double lb = .02425;
constexpr double ub = .97575; constexpr double ub = .97575;
template<typename T> template<floating_point T>
T T
icdf(const T uniform) icdf(const T uniform)
/* /*
...@@ -105,7 +106,7 @@ icdf(const T uniform) ...@@ -105,7 +106,7 @@ icdf(const T uniform)
} }
void void
icdfm(int n, auto* U) icdfm(int n, floating_point auto* U)
{ {
#pragma omp parallel for #pragma omp parallel for
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
...@@ -114,7 +115,7 @@ icdfm(int n, auto* U) ...@@ -114,7 +115,7 @@ icdfm(int n, auto* U)
} }
void void
icdfmSigma(int d, int n, auto* U, const double* LowerCholSigma) icdfmSigma(int d, int n, floating_point auto* U, const double* LowerCholSigma)
{ {
double one = 1.0; double one = 1.0;
double zero = 0.0; double zero = 0.0;
...@@ -127,7 +128,7 @@ icdfmSigma(int d, int n, auto* U, const double* LowerCholSigma) ...@@ -127,7 +128,7 @@ icdfmSigma(int d, int n, auto* U, const double* LowerCholSigma)
} }
void void
usphere(int d, int n, auto* U) usphere(int d, int n, floating_point auto* U)
{ {
icdfm(n * d, U); icdfm(n * d, U);
#pragma omp parallel for #pragma omp parallel for
...@@ -145,7 +146,7 @@ usphere(int d, int n, auto* U) ...@@ -145,7 +146,7 @@ usphere(int d, int n, auto* U)
} }
void void
usphereRadius(int d, int n, double radius, auto* U) usphereRadius(int d, int n, double radius, floating_point auto* U)
{ {
icdfm(n * d, U); icdfm(n * d, U);
#pragma omp parallel for #pragma omp parallel for
......
/* Interface to quasi Monte Carlo sequences (à la Sobol) routines. /* Interface to quasi Monte Carlo sequences (à la Sobol) routines.
* *
* Copyright © 2010-2023 Dynare Team * Copyright © 2010-2024 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#ifndef SOBOL_HH #ifndef SOBOL_HH
#define SOBOL_HH #define SOBOL_HH
#include <concepts>
#include <cstdint> #include <cstdint>
#include <dynblas.h> // For the FORTRAN_WRAPPER macro #include <dynblas.h> // For the FORTRAN_WRAPPER macro
...@@ -48,7 +49,7 @@ sobol_block(int dimension, int block_size, int64_t seed, double* block) ...@@ -48,7 +49,7 @@ sobol_block(int dimension, int block_size, int64_t seed, double* block)
return seed; return seed;
} }
template<typename T> template<floating_point T>
void void
expand_unit_hypercube(int dimension, int block_size, T* block, const T* lower_bound, expand_unit_hypercube(int dimension, int block_size, T* block, const T* lower_bound,
const T* upper_bound) const T* upper_bound)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment