Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
@@ -23,52 +23,56 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: G4AdjointInterpolator.cc 71508 2013-06-17 11:57:13Z gcosmo $
//
#include "G4AdjointCSMatrix.hh"
#include "G4AdjointInterpolator.hh"
G4AdjointInterpolator* G4AdjointInterpolator::theInstance = 0;
G4ThreadLocal G4AdjointInterpolator* G4AdjointInterpolator::theInstance = 0;
///////////////////////////////////////////////////////
//
G4AdjointInterpolator* G4AdjointInterpolator::GetAdjointInterpolator()
{ if(theInstance == 0) {
static G4AdjointInterpolator interpolator;
theInstance = &interpolator;
}
return theInstance;
{
return GetInstance();
}
///////////////////////////////////////////////////////
//
G4AdjointInterpolator* G4AdjointInterpolator::GetInstance()
{ if(theInstance == 0) {
static G4AdjointInterpolator interpolator;
theInstance = &interpolator;
{
if(!theInstance)
{
theInstance = new G4AdjointInterpolator;
}
return theInstance;
return theInstance;
}
///////////////////////////////////////////////////////
//
G4AdjointInterpolator::G4AdjointInterpolator()
{;
{
}
///////////////////////////////////////////////////////
//
G4AdjointInterpolator::~G4AdjointInterpolator()
{;
{
}
///////////////////////////////////////////////////////
//
G4double G4AdjointInterpolator::LinearInterpolation(G4double& x,G4double& x1,G4double& x2,G4double& y1,G4double& y2)
{ G4double res = y1+ (x-x1)*(y2-y1)/(x2-x1);
{
G4double res = y1+ (x-x1)*(y2-y1)/(x2-x1);
//G4cout<<"Linear "<<res<<G4endl;
return res;
}
///////////////////////////////////////////////////////
//
G4double G4AdjointInterpolator::LogarithmicInterpolation(G4double& x,G4double& x1,G4double& x2,G4double& y1,G4double& y2)
{ if (y1<=0 || y2<=0 || x1<=0) return LinearInterpolation(x,x1,x2,y1,y2);
{
if (y1<=0 || y2<=0 || x1<=0) return LinearInterpolation(x,x1,x2,y1,y2);
G4double B=std::log(y2/y1)/std::log(x2/x1);
//G4cout<<"x1,x2,y1,y2 "<<x1<<'\t'<<x2<<'\t'<<y1<<'\t'<<y2<<'\t'<<G4endl;
G4double A=y1/std::pow(x1,B);
@@ -76,15 +80,18 @@ G4double G4AdjointInterpolator::LogarithmicInterpolation(G4double& x,G4double& x
// G4cout<<"Log "<<res<<G4endl;
return res;
}
///////////////////////////////////////////////////////
//
G4double G4AdjointInterpolator::ExponentialInterpolation(G4double& x,G4double& x1,G4double& x2,G4double& y1,G4double& y2)
{ G4double B=(std::log(y2)-std::log(y1));
{
G4double B=(std::log(y2)-std::log(y1));
B=B/(x2-x1);
G4double A=y1*std::exp(-B*x1);
G4double res=A*std::exp(B*x);
return res;
}
///////////////////////////////////////////////////////
//
G4double G4AdjointInterpolator::Interpolation(G4double& x,G4double& x1,G4double& x2,G4double& y1,G4double& y2,G4String InterPolMethod)
@@ -103,10 +110,12 @@ G4double G4AdjointInterpolator::Interpolation(G4double& x,G4double& x1,G4double&
return -1111111111.;
}
}
///////////////////////////////////////////////////////
//
size_t G4AdjointInterpolator::FindPosition(G4double& x,std::vector<G4double>& x_vec,size_t , size_t ) //only valid if x_vec is monotically increasing
{ //most rapid nethod could be used probably
{
//most rapid nethod could be used probably
//It is important to put std::vector<G4double>& such that the vector itself is used and not a copy
@@ -151,7 +160,8 @@ size_t G4AdjointInterpolator::FindPosition(G4double& x,std::vector<G4double>& x
///////////////////////////////////////////////////////
//
size_t G4AdjointInterpolator::FindPositionForLogVector(G4double& log_x,std::vector<G4double>& log_x_vec) //only valid if x_vec is monotically increasing
{ //most rapid nethod could be used probably
{
//most rapid nethod could be used probably
//It is important to put std::vector<G4double>& such that the vector itself is used and not a copy
return FindPosition(log_x, log_x_vec);
/*
@@ -171,10 +181,12 @@ size_t G4AdjointInterpolator::FindPositionForLogVector(G4double& log_x,std::vec
}
///////////////////////////////////////////////////////
//
G4double G4AdjointInterpolator::Interpolate(G4double& x,std::vector<G4double>& x_vec,std::vector<G4double>& y_vec,G4String InterPolMethod)
{ size_t i=FindPosition(x,x_vec);
{
size_t i=FindPosition(x,x_vec);
//G4cout<<i<<G4endl;
//G4cout<<x<<G4endl;
//G4cout<<x_vec[i]<<G4endl;
@@ -185,7 +197,8 @@ G4double G4AdjointInterpolator::Interpolate(G4double& x,std::vector<G4double>& x
//
G4double G4AdjointInterpolator::InterpolateWithIndexVector(G4double& x,std::vector<G4double>& x_vec,std::vector<G4double>& y_vec,
std::vector<size_t>& index_vec,G4double x0, G4double dx) //only linear interpolation possible
{ size_t ind=0;
{
size_t ind=0;
if (x>x0) ind=int((x-x0)/dx);
if (ind >= index_vec.size()-1) ind= index_vec.size()-2;
size_t ind1 = index_vec[ind];
@@ -196,17 +209,15 @@ G4double G4AdjointInterpolator::InterpolateWithIndexVector(G4double& x,std::vect
ind2=ind11;
}
ind=FindPosition(x,x_vec,ind1,ind2);
return Interpolation( x,x_vec[ind],x_vec[ind+1],y_vec[ind],y_vec[ind+1],"Lin");
}
///////////////////////////////////////////////////////
//
G4double G4AdjointInterpolator::InterpolateForLogVector(G4double& log_x,std::vector<G4double>& log_x_vec,std::vector<G4double>& log_y_vec)
{ //size_t i=0;
{
//size_t i=0;
size_t i=FindPositionForLogVector(log_x,log_x_vec);
/*G4cout<<"In interpolate "<<G4endl;
G4cout<<i<<G4endl;
@@ -217,6 +228,5 @@ G4double G4AdjointInterpolator::InterpolateForLogVector(G4double& log_x,std::vec
G4cout<<log_y_vec[i+1]<<G4endl;*/
G4double log_y=LinearInterpolation(log_x,log_x_vec[i],log_x_vec[i+1],log_y_vec[i],log_y_vec[i+1]);
return log_y;
return log_y;
}