Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
@@ -73,7 +73,7 @@ class G4ConvergenceTester
inline G4double GetValueOfMinimizingFunction(std::vector<G4double> x)
{
return slope_fitting_function(x);
return slope_fitting_function(std::move(x));
}
void ComputeStatistics() { calStat(); }
@@ -64,7 +64,7 @@ class G4SimplexDownhill
private:
G4double getValue(std::vector<G4double> x)
{
return target->GetValueOfMinimizingFunction(x);
return target->GetValueOfMinimizingFunction(std::move(x));
}
void initialize();
@@ -113,12 +113,12 @@ void G4SimplexDownhill<T>::initialize()
{
std::vector<G4double> avec(numberOfVariable, 0.0);
avec[i] = 1.0;
currentSimplex[i] = avec;
currentSimplex[i] = std::move(avec);
}
// std::vector< G4double > avec ( numberOfVariable , 0.0 );
std::vector<G4double> avec(numberOfVariable, 1);
currentSimplex[numberOfVariable] = avec;
currentSimplex[numberOfVariable] = std::move(avec);
}
template <class T>
@@ -200,8 +200,6 @@ std::vector<G4double> G4SimplexDownhill<T>::getContractionPoint(
template <class T>
G4bool G4SimplexDownhill<T>::isItGoodEnough()
{
G4bool result = false;
G4double sum =
std::accumulate(currentHeights.begin(), currentHeights.end(), 0.0);
G4double average = sum / (numberOfVariable + 1);
@@ -212,11 +210,11 @@ G4bool G4SimplexDownhill<T>::isItGoodEnough()
delta += std::abs(currentHeights[i] - average);
}
if(delta / (numberOfVariable + 1) / average < max_ratio)
G4bool result = false;
if (average > 0.0)
{
result = true;
result = ((delta / (numberOfVariable + 1) / average) < max_ratio);
}
return result;
}
@@ -274,19 +272,19 @@ void G4SimplexDownhill<T>::doDownhill()
{
// EXPANSION
std::vector<G4double> expansionPoint =
getExpansionPoint(reflectionPoint, centroidPoint);
getExpansionPoint(reflectionPoint, std::move(centroidPoint));
G4double hh = getValue(expansionPoint);
if(hh <= h_L)
{
// Replace
currentSimplex[ih] = expansionPoint;
currentSimplex[ih] = std::move(expansionPoint);
// G4cout << "A" << G4endl;
}
else
{
// Replace
currentSimplex[ih] = reflectionPoint;
currentSimplex[ih] = std::move(reflectionPoint);
// G4cout << "B1" << G4endl;
}
}
@@ -295,7 +293,7 @@ void G4SimplexDownhill<T>::doDownhill()
if(h <= h_H2)
{
// Replace
currentSimplex[ih] = reflectionPoint;
currentSimplex[ih] = std::move(reflectionPoint);
// G4cout << "B2" << G4endl;
}
else
@@ -303,17 +301,17 @@ void G4SimplexDownhill<T>::doDownhill()
if(h <= h_H)
{
// Replace
currentSimplex[ih] = reflectionPoint;
currentSimplex[ih] = std::move(reflectionPoint);
// G4cout << "BC" << G4endl;
}
// CONTRACTION
std::vector<G4double> contractionPoint =
getContractionPoint(currentSimplex[ih], centroidPoint);
getContractionPoint(currentSimplex[ih], std::move(centroidPoint));
G4double hh = getValue(contractionPoint);
if(hh <= h_H)
{
// Replace
currentSimplex[ih] = contractionPoint;
currentSimplex[ih] = std::move(contractionPoint);
// G4cout << "C" << G4endl;
}
else
@@ -326,7 +324,7 @@ void G4SimplexDownhill<T>::doDownhill()
{
vec[k] = (currentSimplex[j][k] + currentSimplex[il][k]) / 2.0;
}
currentSimplex[j] = vec;
currentSimplex[j] = std::move(vec);
}
}
}
@@ -47,7 +47,7 @@ G4ChebyshevApproximation::G4ChebyshevApproximation(function pFunction, G4int n,
{
G4int i = 0, j = 0;
G4double rootSum = 0.0, cofj = 0.0;
G4double* tempFunction = new G4double[fNumber];
auto tempFunction = new G4double[fNumber];
G4double weight = 2.0 / fNumber;
G4double cof = 0.5 * weight * pi; // pi/n
@@ -93,7 +93,7 @@ G4ChebyshevApproximation::G4ChebyshevApproximation(function pFunction, G4int nx,
}
G4int i = 0, j = 0;
G4double rootSum = 0.0, cofj = 0.0;
G4double* tempFunction = new G4double[fNumber];
auto tempFunction = new G4double[fNumber];
G4double weight = 2.0 / fNumber;
G4double cof = 0.5 * weight * pi; // pi/nx
@@ -143,7 +143,7 @@ G4ChebyshevApproximation::G4ChebyshevApproximation(function pFunction,
{
G4int i = 0, j = 0;
G4double rootSum = 0.0, cofj = 0.0;
G4double* tempFunction = new G4double[fNumber];
auto tempFunction = new G4double[fNumber];
G4double weight = 2.0 / fNumber;
G4double cof = 0.5 * weight * pi; // pi/n
@@ -118,6 +118,8 @@ void G4ConvergenceTester::AddScore(G4double x)
void G4ConvergenceTester::calStat()
{
if (n == 0) return;
efficiency = G4double(nonzero_histories.size()) / n;
mean = sum / n;
@@ -223,10 +225,10 @@ void G4ConvergenceTester::calStat()
}
else
{
G4int i = G4int(nonzero_histories.size());
auto i = G4int(nonzero_histories.size());
// 5% criterion
G4int j = G4int(i * 0.05);
auto j = G4int(i * 0.05);
while(G4int(largest_scores.size()) > j)
{
largest_scores.pop_back();
@@ -623,7 +625,7 @@ void G4ConvergenceTester::check_stat_history(std::ostream& out)
second_ally[i] = fom_history[N + i];
}
pearson_r = calc_Pearson_r(G4int(N), first_ally, second_ally);
pearson_r = calc_Pearson_r(G4int(N), std::move(first_ally), std::move(second_ally));
t = pearson_r * std::sqrt((N - 2) / (1 - pearson_r * pearson_r));
if(t < 0.429318)
@@ -691,7 +693,7 @@ void G4ConvergenceTester::calc_slope_fit(const std::vector<G4double>&)
{
// create PDF bins
G4double max = largest_scores.front();
G4int last = G4int(largest_scores.size());
auto last = G4int(largest_scores.size());
G4double min = 0.0;
if(largest_scores.back() != 0)
{
@@ -65,7 +65,7 @@ G4DataInterpolation::G4DataInterpolation(G4double pX[], G4double pY[],
G4int i = 0;
G4double p = 0.0, qn = 0.0, sig = 0.0, un = 0.0;
const G4double maxDerivative = 0.99e30;
G4double* u = new G4double[fNumber - 1];
auto u = new G4double[fNumber - 1];
for(i = 0; i < fNumber; ++i)
{
@@ -152,8 +152,8 @@ G4double G4DataInterpolation::PolynomInterpolation(G4double pX,
G4int i = 0, j = 1, k = 0;
G4double mult = 0.0, difi = 0.0, deltaLow = 0.0, deltaUp = 0.0, cd = 0.0,
y = 0.0;
G4double* c = new G4double[fNumber];
G4double* d = new G4double[fNumber];
auto c = new G4double[fNumber];
auto d = new G4double[fNumber];
G4double diff = std::fabs(pX - fArgument[0]);
for(i = 0; i < fNumber; ++i)
{
@@ -205,7 +205,7 @@ void G4DataInterpolation::PolIntCoefficient(G4double cof[]) const
G4int i = 0, j = 0;
G4double factor;
G4double reducedY = 0.0, mult = 1.0;
G4double* tempArgument = new G4double[fNumber];
auto tempArgument = new G4double[fNumber];
for(i = 0; i < fNumber; ++i)
{
@@ -252,8 +252,8 @@ G4double G4DataInterpolation::RationalPolInterpolation(G4double pX,
G4int i = 0, j = 1, k = 0;
const G4double tolerance = 1.6e-24;
G4double mult = 0.0, difi = 0.0, cd = 0.0, y = 0.0, cof = 0.0;
G4double* c = new G4double[fNumber];
G4double* d = new G4double[fNumber];
auto c = new G4double[fNumber];
auto d = new G4double[fNumber];
G4double diff = std::fabs(pX - fArgument[0]);
for(i = 0; i < fNumber; ++i)
{
@@ -31,6 +31,8 @@
#include "G4GaussHermiteQ.hh"
#include "G4PhysicalConstants.hh"
#include <limits>
// ----------------------------------------------------------
//
// Constructor for Gauss-Hermite
@@ -87,7 +89,12 @@ G4GaussHermiteQ::G4GaussHermiteQ(function pFunction, G4int nHermite)
}
temp = std::sqrt((G4double) 2 * nHermite) * temp2;
newton1 = newton0;
newton0 = newton1 - temp1 / temp;
G4double ratio = std::numeric_limits<G4double>::max();
if(temp > 0.0)
{
ratio = temp1 / temp;
}
newton0 = newton1 - ratio;
if(std::fabs(newton0 - newton1) <= tolerance)
{
break;