Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
DoubleAc.cpp File Reference
#include <iomanip>
#include "wcpplib/util/FunNameStack.h"
#include "wcpplib/math/minmax.h"
#include "wcpplib/math/DoubleAc.h"

Go to the source code of this file.

Functions

DoubleAc sqrt (const DoubleAc &f)
 
DoubleAc square (const DoubleAc &f)
 
DoubleAc pow (const DoubleAc &f, double p)
 
DoubleAc exp (const DoubleAc &f)
 
DoubleAc sin (const DoubleAc &f)
 
DoubleAc cos (const DoubleAc &f)
 
DoubleAc asin (const DoubleAc &f)
 
DoubleAc acos (const DoubleAc &f)
 
DoubleAc pow (const DoubleAc &, const DoubleAc &)
 
std::ostream & operator<< (std::ostream &file, const DoubleAc &f)
 

Function Documentation

◆ acos()

DoubleAc acos ( const DoubleAc f)

Definition at line 488 of file DoubleAc.cpp.

488 {
489 if (fabs(f.get()) > 1) {
490 mcerr << "ERROR in inline DoubleAc acos(const DoubleAc& f):\n"
491 << "fabs(f.get()) > 1: f.get()=" << f.get() << '\n';
492 spexit(mcerr);
493 }
494 double d = std::acos(f.get());
495 double da;
496 if (f.left_limit() < -1.0)
497 da = std::acos(-1.0);
498 else
499 da = std::acos(f.left_limit());
500 double di;
501 if (f.right_limit() > 1.0)
502 di = std::acos(1.0);
503 else
504 di = std::acos(f.right_limit());
505 return DoubleAc(d, di, da);
506}
DoubleAc fabs(const DoubleAc &f)
Definition: DoubleAc.h:616
#define spexit(stream)
Definition: FunNameStack.h:536
double left_limit(void) const
Definition: DoubleAc.h:79
double right_limit(void) const
Definition: DoubleAc.h:83
double get(void) const
Definition: DoubleAc.h:76
#define mcerr
Definition: prstream.h:135

Referenced by Heed::spquadr::apos(), Garfield::Medium::ElectronAttachment(), Garfield::Medium::ElectronDiffusion(), Garfield::Medium::ElectronTownsend(), Garfield::Medium::ElectronVelocity(), Garfield::MediumMagboltz::GetElectronCollision(), Garfield::Medium::HoleAttachment(), Garfield::Medium::HoleDiffusion(), Garfield::Medium::HoleTownsend(), Garfield::Medium::HoleVelocity(), Garfield::Medium::IonDiffusion(), Garfield::Medium::IonDissociation(), Garfield::Medium::IonVelocity(), Heed::HeedDeltaElectron::physics_after_new_speed(), and Heed::theta_two_part().

◆ asin()

DoubleAc asin ( const DoubleAc f)

Definition at line 468 of file DoubleAc.cpp.

468 {
469 if (fabs(f.get()) > 1) {
470 mcerr << "ERROR in inline DoubleAc asin(const DoubleAc& f):\n"
471 << "fabs(f.get()) > 1: f.get()=" << f.get() << '\n';
472 spexit(mcerr);
473 }
474 double d = std::asin(f.get());
475 double di;
476 if (f.left_limit() < -1.0)
477 di = std::asin(-1.0);
478 else
479 di = std::asin(f.left_limit());
480 double da;
481 if (f.right_limit() > 1.0)
482 da = std::asin(1.0);
483 else
484 da = std::asin(f.right_limit());
485 return DoubleAc(d, di, da);
486}

Referenced by Garfield::Medium::ElectronAttachment(), Garfield::Medium::ElectronDiffusion(), Garfield::Medium::ElectronTownsend(), Garfield::Medium::ElectronVelocity(), Heed::ElElasticScat::fill_hist_low_scat(), Garfield::MediumMagboltz::GetElectronCollision(), Heed::HeedDeltaElectronCS::HeedDeltaElectronCS(), Garfield::Medium::HoleAttachment(), Garfield::Medium::HoleDiffusion(), Garfield::Medium::HoleTownsend(), Garfield::Medium::HoleVelocity(), Garfield::Medium::IonDiffusion(), Garfield::Medium::IonDissociation(), Garfield::Medium::IonVelocity(), and Heed::theta_two_part().

◆ cos()

DoubleAc cos ( const DoubleAc f)

Definition at line 431 of file DoubleAc.cpp.

431 {
432 double d = std::cos(f.get());
433 double di = std::cos(f.left_limit());
434 double da = std::cos(f.right_limit());
435 long n = left_round(f.get() / M_PI - 1.0);
436 long ni = left_round(f.left_limit() / M_PI - 1.0);
437 long na = left_round(f.right_limit() / M_PI - 1.0);
438 int seven = even_num(n);
439 if (seven == 1) {
440 if (ni < n) {
441 di = -1.0;
442 da = find_max(di, da);
443 if (na > n) {
444 da = 1.0;
445 }
446 } else if (na > n) {
447 da = 1.0;
448 di = find_min(di, da);
449 }
450 } else {
451 double temp = di;
452 di = da;
453 da = temp;
454 if (ni < n) {
455 da = 1.0;
456 di = find_min(di, da);
457 if (na > n) {
458 di = -1.0;
459 }
460 } else if (na > n) {
461 di = -1.0;
462 da = find_max(di, da);
463 }
464 }
465 return DoubleAc(d, di, da);
466}
DoubleAc find_min(const DoubleAc &a, const DoubleAc &b)
Definition: DoubleAc.h:627
DoubleAc find_max(const DoubleAc &a, const DoubleAc &b)
Definition: DoubleAc.h:655
int even_num(long n)
Definition: minmax.h:105
long left_round(double f)
Definition: minmax.h:99

Referenced by Heed::ElElasticScatDataStruct::CS(), Garfield::ViewMedium::EvaluateFunction(), Heed::ElElasticScat::fill_hist_low_scat(), Garfield::Medium::GetElectronCollision(), Garfield::MediumMagboltz::GetElectronCollision(), Garfield::MediumSilicon::GetElectronCollision(), Garfield::Medium::GetElectronMomentum(), Garfield::MediumSilicon::GetElectronMomentum(), Heed::HeedDeltaElectronCS::HeedDeltaElectronCS(), Garfield::ComponentFieldMap::MapCoordinates(), Garfield::TrackBichsel::NewTrack(), Garfield::TrackElectron::NewTrack(), Garfield::TrackHeed::NewTrack(), Garfield::TrackPAI::NewTrack(), Garfield::TrackSimple::NewTrack(), Heed::HeedDeltaElectron::physics_after_new_speed(), vec::random_conic_vec(), vec::random_round_vec(), rnorm_double(), rnorm_float(), Garfield::ViewField::Rotate(), Garfield::SolidBox::SolidBox(), Garfield::SolidTube::SolidTube(), Garfield::TrackHeed::TransportDeltaElectron(), Garfield::TrackHeed::TransportPhoton(), vec::turn_new(), and Garfield::ComponentFieldMap::UnmapFields().

◆ exp()

◆ operator<<()

std::ostream & operator<< ( std::ostream &  file,
const DoubleAc f 
)

Definition at line 544 of file DoubleAc.cpp.

544 {
545 f.print(file, 1);
546 return file;
547}
void print(std::ostream &file, int l=1) const
Definition: DoubleAc.cpp:508

◆ pow() [1/2]

DoubleAc pow ( const DoubleAc ,
const DoubleAc  
)

Definition at line 536 of file DoubleAc.cpp.

536 {
537 mcerr << "ERROR in inline DoubleAc pow(const DoubleAc& f, const DoubleAc& "
538 "p):\n";
539 mcerr << "not implemented yet\n";
540 spexit(mcerr);
541 return 0.0;
542}

◆ pow() [2/2]

DoubleAc pow ( const DoubleAc f,
double  p 
)

Definition at line 336 of file DoubleAc.cpp.

336 {
337 if (p == 1) return f;
338 if (p == 0) return DoubleAc(1.0);
339 if (p > 0) {
340 double d = std::pow(f.get(), p);
341 double di = std::pow(f.left_limit(), p);
342 double da = std::pow(f.right_limit(), p);
343 if (f.left_limit() >= 0.0) {
344 return DoubleAc(d, di, da);
345 } else if (f.right_limit() >= 0.0) {
346 if (di < 0.0)
347 return DoubleAc(d, di, da);
348 else // the power is even
349 return DoubleAc(d, 0.0, find_max(di, da));
350 } else {
351 if (di < 0.0)
352 return DoubleAc(d, di, da);
353 else // the power is even
354 return DoubleAc(d, da, di);
355 }
356 } else {
357 double d = std::pow(f.get(), -p);
358 double di = std::pow(f.left_limit(), -p);
359 double da = std::pow(f.right_limit(), -p);
360 if (f.left_limit() >= 0.0) {
361 return 1.0 / DoubleAc(d, di, da);
362 } else if (f.right_limit() >= 0.0) {
363 if (di < 0.0)
364 return 1.0 / DoubleAc(d, di, da);
365 else // the power is even
366 return 1.0 / DoubleAc(d, 0.0, find_max(di, da));
367 } else {
368 if (di < 0.0)
369 return 1.0 / DoubleAc(d, di, da);
370 else // the power is even
371 return 1.0 / DoubleAc(d, da, di);
372 }
373 }
374}

Referenced by Garfield::Numerics::BesselI0S(), Garfield::Numerics::BesselI1S(), Garfield::Numerics::BesselK0L(), Garfield::Numerics::BesselK0S(), Garfield::Numerics::BesselK1L(), Garfield::Numerics::BesselK1S(), Heed::Bethe_Bloch_energy_loss(), Heed::Bethe_Bloch_energy_loss_gamma_1(), Heed::Bethe_Bloch_restricted_energy_loss_gamma_1(), Garfield::ComponentFieldMap::Coordinates4(), Heed::ElElasticScatDataStruct::CS(), Heed::e_cont_enloss(), Garfield::Medium::ElectronAttachment(), Garfield::Medium::ElectronDiffusion(), Garfield::Medium::ElectronTownsend(), Garfield::Medium::ElectronVelocity(), Garfield::MediumCdTe::ElectronVelocity(), Garfield::MediumGaAs::ElectronVelocity(), Garfield::MediumSilicon::ElectronVelocity(), Heed::ElElasticScat::ElElasticScat(), Heed::EnergyMesh::EnergyMesh(), Heed::EnTransfCS::EnTransfCS(), Heed::ExAtomPhotoAbsCS::ExAtomPhotoAbsCS(), Heed::ElElasticScat::fill_hist(), Heed::ElElasticScat::fill_hist_low_scat(), Cubic::find_zero(), Heed::HydrogenPhotoAbsCS::get_CS(), Heed::SimpleTablePhotoAbsCS::get_CS(), Heed::PhenoPhotoAbsCS::get_CS(), Heed::ElElasticScat::get_CS(), Heed::ElElasticScat::get_CS_Rutherford(), Heed::PairProd::get_eloss(), Heed::HydrogenPhotoAbsCS::get_integral_CS(), Heed::SimpleTablePhotoAbsCS::get_integral_CS(), Heed::PhenoPhotoAbsCS::get_integral_CS(), Garfield::ComponentAnsys121::GetAspectRatio(), Garfield::ComponentAnsys123::GetAspectRatio(), Garfield::ComponentElmer::GetAspectRatio(), Garfield::TrackElectron::GetCluster(), Garfield::MediumSilicon::GetConductionBandDensityOfStates(), Garfield::MediumMagboltz::GetElectronCollision(), Garfield::ComponentTcad2d::GetElement(), Garfield::ComponentTcad3d::GetElement(), Garfield::TrackElectron::GetStoppingPower(), Heed::HeedDeltaElectronCS::HeedDeltaElectronCS(), Garfield::Medium::HoleAttachment(), Garfield::Medium::HoleDiffusion(), Garfield::Medium::HoleTownsend(), Garfield::Medium::HoleVelocity(), Garfield::MediumCdTe::HoleVelocity(), Garfield::MediumGaAs::HoleVelocity(), Garfield::MediumSilicon::HoleVelocity(), Garfield::Medium::IonDiffusion(), Garfield::Medium::IonDissociation(), Garfield::Medium::IonVelocity(), Garfield::ComponentAnalyticField::IsInTrapRadius(), Garfield::ComponentAnalyticField::IsWireCrossed(), Heed::make_log_mesh(), Heed::make_log_mesh_ec(), Heed::mparticle::new_speed(), Heed::PhenoPhotoAbsCS::PhenoPhotoAbsCS(), Heed::HeedPhoton::physics_after_new_speed(), Garfield::ViewField::PlotProfile(), Heed::HeedMatterDef::print(), Garfield::RndmPolya(), Garfield::Medium::SetFieldGrid(), Heed::SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS(), Heed::straight::straight(), t_integ_power_2point(), t_value_power_2point(), and t_value_power_extended_2point().

◆ sin()

DoubleAc sin ( const DoubleAc f)

Definition at line 383 of file DoubleAc.cpp.

383 {
384 //mcout<<"DoubleAc sin is starting, f="; f.print(mcout, 3);
385 double d = std::sin(f.get());
386 double di = std::sin(f.left_limit());
387 double da = std::sin(f.right_limit());
388 //Iprintn(mcout, d);
389 //Iprintn(mcout, di);
390 //Iprintn(mcout, da);
391 long n = left_round(f.get() / M_PI + 0.5);
392 long ni = left_round(f.left_limit() / M_PI + 0.5);
393 long na = left_round(f.right_limit() / M_PI + 0.5);
394 //Iprintn(mcout, n);
395 //Iprintn(mcout, ni);
396 //Iprintn(mcout, na);
397 int seven = even_num(n);
398 //Iprintn(mcout, seven);
399 if (seven == 1) {
400 if (ni < n) {
401 di = -1.0;
402 da = find_max(di, da);
403 if (na > n) {
404 da = 1.0;
405 }
406 } else if (na > n) {
407 da = 1.0;
408 di = find_min(di, da);
409 }
410 } else {
411 double temp = di;
412 di = da;
413 da = temp;
414 if (ni < n) {
415 da = 1.0;
416 di = find_min(di, da);
417 if (na > n) {
418 di = -1.0;
419 }
420 } else if (na > n) {
421 di = -1.0;
422 da = find_max(di, da);
423 }
424 }
425 //Iprintn(mcout, d);
426 //Iprintn(mcout, di);
427 //Iprintn(mcout, da);
428 return DoubleAc(d, di, da);
429}

Referenced by Garfield::ViewMedium::EvaluateFunction(), Heed::ElElasticScat::fill_hist(), Heed::ElElasticScat::fill_hist_low_scat(), Heed::ElElasticScat::get_CS_Rutherford(), Garfield::Medium::GetElectronCollision(), Garfield::MediumMagboltz::GetElectronCollision(), Garfield::MediumSilicon::GetElectronCollision(), Garfield::Medium::GetElectronMomentum(), Garfield::MediumSilicon::GetElectronMomentum(), Heed::HeedDeltaElectronCS::HeedDeltaElectronCS(), Garfield::ComponentFieldMap::MapCoordinates(), Garfield::TrackBichsel::NewTrack(), Garfield::TrackElectron::NewTrack(), Garfield::TrackHeed::NewTrack(), Garfield::TrackPAI::NewTrack(), Garfield::TrackSimple::NewTrack(), Heed::HeedDeltaElectron::physics_after_new_speed(), vec::random_conic_vec(), vec::random_round_vec(), rnorm_double(), rnorm_float(), Garfield::ViewField::Rotate(), Garfield::SolidBox::SolidBox(), Garfield::SolidTube::SolidTube(), Heed::theta_two_part(), Garfield::TrackHeed::TransportDeltaElectron(), Garfield::TrackHeed::TransportPhoton(), vec::turn_new(), and Garfield::ComponentFieldMap::UnmapFields().

◆ sqrt()

DoubleAc sqrt ( const DoubleAc f)

Definition at line 313 of file DoubleAc.cpp.

313 {
314 if (f.get() < 0) {
315 mcerr << "error in DoubleAc sqrt(const DoubleAc& f): f.get() < 0, f.get()="
316 << f.get() << '\n';
317 spexit(mcerr);
318 }
319 return DoubleAc(std::sqrt(double(f.get())),
320 std::sqrt(double(find_max(f.get_left_limit(), 0.0))),
321 std::sqrt(double(f.get_right_limit())));
322}
double get_right_limit(void) const
Definition: DoubleAc.h:82
double get_left_limit(void) const
Definition: DoubleAc.h:78

Referenced by Garfield::Numerics::BesselK0L(), Garfield::Numerics::BesselK1L(), Garfield::ComponentFieldMap::Coordinates4(), Heed::cos_theta_two_part(), Heed::circumf::cross(), GarfieldPhysics::DoIt(), Heed::e_cont_enloss(), Garfield::Medium::ElectronAttachment(), Garfield::MediumCdTe::ElectronAttachment(), Garfield::MediumGaAs::ElectronAttachment(), Garfield::MediumSilicon::ElectronAttachment(), Garfield::Medium::ElectronDiffusion(), Garfield::Medium::ElectronTownsend(), Garfield::MediumSilicon::ElectronTownsend(), Garfield::Medium::ElectronVelocity(), Garfield::MediumCdTe::ElectronVelocity(), Garfield::MediumGaAs::ElectronVelocity(), Garfield::MediumSilicon::ElectronVelocity(), Heed::EnTransfCS::EnTransfCS(), Heed::EnTransfCS_BGM::EnTransfCS_BGM(), Garfield::ViewField::EvaluatePotential(), Garfield::ViewField::EvaluatePotentialProfile(), Garfield::ViewField::EvaluateWeightingField(), Heed::ElElasticScat::fill_hist_low_scat(), Parabol::find_zero(), Cubic::find_zero(), Garfield::DriftLineRKF::GetArrivalTimeSpread(), Garfield::ComponentAnsys121::GetAspectRatio(), Garfield::ComponentAnsys123::GetAspectRatio(), Garfield::ComponentElmer::GetAspectRatio(), Garfield::Track::GetBeta(), Garfield::Track::GetBetaGamma(), Garfield::SolidBox::GetBoundingBox(), Garfield::SolidTube::GetBoundingBox(), Garfield::TrackElectron::GetCluster(), Garfield::MediumSilicon::GetConductionBandDensityOfStates(), Garfield::Medium::GetElectronCollision(), Garfield::MediumMagboltz::GetElectronCollision(), Garfield::MediumSilicon::GetElectronCollision(), Garfield::MediumSilicon::GetElectronEnergy(), Garfield::Medium::GetElectronMomentum(), Garfield::MediumSilicon::GetElectronMomentum(), Garfield::ComponentTcad2d::GetElement(), Garfield::ComponentTcad3d::GetElement(), Garfield::DriftLineRKF::GetGain(), Garfield::Track::GetGamma(), Garfield::Track::GetMomentum(), Garfield::TrackElectron::GetStoppingPower(), Heed::HeedDeltaElectronCS::HeedDeltaElectronCS(), Garfield::Medium::HoleAttachment(), Garfield::MediumCdTe::HoleAttachment(), Garfield::MediumGaAs::HoleAttachment(), Garfield::MediumSilicon::HoleAttachment(), Garfield::Medium::HoleDiffusion(), Garfield::Medium::HoleTownsend(), Garfield::MediumSilicon::HoleTownsend(), Garfield::Medium::HoleVelocity(), Garfield::MediumCdTe::HoleVelocity(), Garfield::MediumGaAs::HoleVelocity(), Garfield::MediumSilicon::HoleVelocity(), Garfield::Medium::IonDiffusion(), Garfield::Medium::IonDissociation(), Garfield::Medium::IonVelocity(), Garfield::SolidSphere::IsInside(), Garfield::SolidTube::IsInside(), Garfield::ComponentAnalyticField::IsInTrapRadius(), Garfield::ComponentAnalyticField::IsWireCrossed(), Garfield::MediumGas::LoadGasFile(), Heed::lorbeta(), Heed::lorgamma_1(), Garfield::ComponentFieldMap::MapCoordinates(), Garfield::TrackBichsel::NewTrack(), Garfield::TrackElectron::NewTrack(), Garfield::TrackHeed::NewTrack(), Garfield::TrackPAI::NewTrack(), Garfield::TrackSimple::NewTrack(), norm_DynLinArr(), norm_DynLinArr_part(), Heed::PairProd::PairProd(), Heed::HeedParticle_BGM::physics(), Heed::HeedDeltaElectron::physics_after_new_speed(), Heed::HeedPhoton::physics_after_new_speed(), Garfield::ViewField::PlotProfile(), pois(), PointsRan::ran(), vec::random_sfer_vec(), Garfield::RndmGaussian(), Garfield::RndmPolya(), rnorm_double(), rnorm_float(), rnorm_improved(), Garfield::MediumMagboltz::RunMagboltz(), Garfield::MediumGas::ScaleDiffusion(), Garfield::Track::SetBeta(), Garfield::Track::SetBetaGamma(), Garfield::Track::SetMomentum(), Garfield::ViewFEMesh::SetPlane(), Garfield::ViewField::SetPlane(), Heed::SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS(), Garfield::SolidBox::SolidBox(), Garfield::SolidTube::SolidTube(), Heed::straight::straight(), Heed::theta_two_part(), Garfield::TrackHeed::TransportDeltaElectron(), Garfield::TrackHeed::TransportPhoton(), Garfield::ComponentFieldMap::UnmapFields(), and Garfield::MediumGas::WriteGasFile().

◆ square()

DoubleAc square ( const DoubleAc f)

Definition at line 324 of file DoubleAc.cpp.

324 {
325 if (f.left_limit() >= 0.0) {
326 return DoubleAc(f.get() * f.get(), f.left_limit() * f.left_limit(),
327 f.right_limit() * f.right_limit());
328 } else if (f.right_limit() >= 0.0) {
329 double t = find_max(-f.left_limit(), f.right_limit());
330 return DoubleAc(f.get() * f.get(), 0.0, t * t);
331 }
332 return DoubleAc(f.get() * f.get(), f.right_limit() * f.right_limit(),
333 f.left_limit() * f.left_limit());
334}

Referenced by norm_DynLinArr(), and normsq_DynLinArr().