45 numberOfXNodes(0), numberOfYNodes(0),
46 verboseLevel(0), useBicubic(false)
53 numberOfXNodes(nx), numberOfYNodes(ny),
54 verboseLevel(0), useBicubic(false)
72 numberOfXNodes = right.numberOfXNodes;
73 numberOfYNodes = right.numberOfYNodes;
75 verboseLevel = right.verboseLevel;
76 useBicubic = right.useBicubic;
78 xVector = right.xVector;
79 yVector = right.yVector;
89 if (&right==
this) {
return *
this; }
94 numberOfXNodes = right.numberOfXNodes;
95 numberOfYNodes = right.numberOfYNodes;
97 verboseLevel = right.verboseLevel;
98 useBicubic = right.useBicubic;
110 xVector.resize(numberOfXNodes,0.);
111 yVector.resize(numberOfYNodes,0.);
112 value.resize(numberOfYNodes,0);
113 for(
size_t j=0; j<numberOfYNodes; ++j) {
115 v->resize(numberOfXNodes,0.);
124 for(
size_t j=0; j<numberOfYNodes; ++j) {
133 for(
size_t i=0; i<numberOfXNodes; ++i) {
134 xVector[i] = right.xVector[i];
136 for(
size_t j=0; j<numberOfYNodes; ++j) {
137 yVector[j] = right.yVector[j];
139 for(
size_t i=0; i<numberOfXNodes; ++i) {
148 size_t& idx,
size_t& idy)
const
156 }
else if(x > xVector[numberOfXNodes - 1]) {
157 x = xVector[numberOfXNodes - 1];
161 }
else if(y > yVector[numberOfYNodes - 1]) {
162 y = yVector[numberOfYNodes - 1];
181 return ((y2 - y)*(v11*(x2 - x) + v12*(x - x1)) +
182 ((y - y1)*(v21*(x2 - x) + v22*(x - x1))))/((x2 - x1)*(y2 - y1));
190 size_t idx,
size_t idy)
const
221 G4double f1x = DerivativeX(idx, idy, dx);
222 G4double f2x = DerivativeX(idx+1, idy, dx);
223 G4double f3x = DerivativeX(idx+1, idy+1, dx);
224 G4double f4x = DerivativeX(idx, idy+1, dx);
226 G4double f1y = DerivativeY(idx, idy, dy);
227 G4double f2y = DerivativeY(idx+1, idy, dy);
228 G4double f3y = DerivativeY(idx+1, idy+1, dy);
229 G4double f4y = DerivativeY(idx, idy+1, dy);
232 G4double f1xy = DerivativeXY(idx, idy, dxy);
233 G4double f2xy = DerivativeXY(idx+1, idy, dxy);
234 G4double f3xy = DerivativeXY(idx+1, idy+1, dxy);
235 G4double f4xy = DerivativeXY(idx, idy+1, dxy);
238 f1 + f1y*h2 + (3*(f4-f1) - 2*f1y - f4y)*h22 + (2*(f1 - f4) + f1y + f4y)*h23
239 + f1x*h1 + f1xy*h1*h2 +(3*(f4x - f1x) - 2*f1xy - f4xy)*h1*h22
240 + (2*(f1x - f4x) + f1xy + f4xy)*h1*h23
241 + (3*(f2 - f1) - 2*f1x - f2x)*h12 + (3*f2y - 3*f1y - 2*f1xy - f2xy)*h12*h2
242 + (9*(f1 - f2 + f3 - f4) + 6*f1x + 3*f2x - 3*f3x - 6*f4x + 6*f1y - 6*f2y
243 - 3*f3y + 3*f4y + 4*f1xy + 2*f2xy + f3xy + 2*f4xy)*h12*h22
244 + (6*(-f1 + f2 - f3 + f4) - 4*f1x - 2*f2x + 2*f3x + 4*f4x - 3*f1y
245 + 3*f2y + 3*f3y - 3*f4y - 2*f1xy - f2xy - f3xy - 2*f4xy)*h12*h23
246 + (2*(f1 - f2) + f1x + f2x)*h13 + (2*(f1y - f2y) + f1xy + f2xy)*h13*h2
247 + (6*(-f1 + f2 -f3 + f4) + 3*(-f1x - f2x + f3x + f4x) - 4*f1y
248 + 4*f2y + 2*f3y - 2*f4y - 2*f1xy - 2*f2xy - f3xy - f4xy)*h13*h22
249 + (4*(f1 - f2 + f3 - f4) + 2*(f1x + f2x - f3x - f4x)
250 + 2*(f1y - f2y - f3y + f4y) + f1xy + f2xy + f3xy + f4xy)*h13*h23;
257 const std::vector<G4double>& vecY)
260 numberOfXNodes = vecX.size();
261 numberOfYNodes = vecY.size();
263 for(
size_t i = 0; i<numberOfXNodes; ++i) {
264 xVector[i] = vecX[i];
266 for(
size_t j = 0; j<numberOfYNodes; ++j) {
267 yVector[j] = vecY[j];
277 out <<
G4int(type) <<
" " << numberOfXNodes <<
" " << numberOfYNodes
279 out << std::setprecision(5);
282 for(
size_t i = 0; i<numberOfXNodes-1; ++i) {
283 out << xVector[i] <<
" ";
285 out << xVector[numberOfXNodes-1] <<
G4endl;
286 for(
size_t j = 0; j<numberOfYNodes-1; ++j) {
287 out << yVector[j] <<
" ";
289 out << yVector[numberOfYNodes-1] <<
G4endl;
290 for(
size_t j = 0; j<numberOfYNodes; ++j) {
291 for(
size_t i = 0; i<numberOfXNodes-1; ++i) {
309 in >> k >> numberOfXNodes >> numberOfYNodes;
310 if (in.fail() || 0 >= numberOfXNodes || 0 >= numberOfYNodes ||
312 if( 0 >= numberOfXNodes || numberOfXNodes >=
INT_MAX) {
315 if( 0 >= numberOfYNodes || numberOfYNodes >=
INT_MAX) {
325 for(
size_t i = 0; i<numberOfXNodes; ++i) {
327 if (in.fail()) {
return false; }
329 for(
size_t j = 0; j<numberOfYNodes; ++j) {
331 if (in.fail()) {
return false; }
333 for(
size_t j = 0; j<numberOfYNodes; ++j) {
334 for(
size_t i = 0; i<numberOfXNodes; ++i) {
336 if (in.fail()) {
return false; }
350 for(
size_t j = 0; j<numberOfYNodes; ++j) {
351 for(
size_t i = 0; i<numberOfXNodes; ++i) {
365 size_t binmax = v.size() - 2;
367 if(z <= v[0]) { bin = 0; }
368 else if(z >= v[binmax]) { bin = binmax; }
370 bin = std::lower_bound(v.begin(), v.end(),
z) - v.begin() - 1;
385 }
else if(y > yVector[numberOfYNodes - 1]) {
386 y = yVector[numberOfYNodes - 1];
395 G4double del = yVector[idy+1] - yVector[idy];
397 res += (x2 - x1)*(y - yVector[idy])/del;
407 size_t nn = v.size();
408 if(1 >= nn) {
return 0.0; }
419 n2 = (n3 + n1 + 1)/2;
424 res += (y - v[n1])*(xVector[n3] - res)/del;
std::vector< G4double > G4PV2DDataVector
G4double GetValue(size_t idx, size_t idy) const
size_t FindBinLocation(G4double z, const G4PV2DDataVector &) const
size_t FindBinLocationX(G4double x, size_t lastidx) const
void CopyData(const G4Physics2DVector &vec)
void PutValue(size_t idx, size_t idy, G4double value)
G4double Value(G4double x, G4double y, size_t &lastidx, size_t &lastidy) const
const XML_Char int const XML_Char * value
G4Physics2DVector & operator=(const G4Physics2DVector &)
void Store(std::ofstream &fOut) const
G4bool Retrieve(std::ifstream &fIn)
G4double BicubicInterpolation(G4double x, G4double y, size_t idx, size_t idy) const
size_t FindBinLocationY(G4double y, size_t lastidy) const
void PutVectors(const std::vector< G4double > &vecX, const std::vector< G4double > &vecY)
void ScaleVector(G4double factor)
G4double FindLinearX(G4double rand, G4double y, size_t &lastidy) const