Log of /trunk/math/mathcore/src/TMath.cxx
Parent Directory
Revision
44507 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Mon Jun 4 12:30:41 2012 UTC (2 years, 7 months ago) by
axel
File length: 106769 byte(s)
Diff to
previous 44433
Remove
using namespace std;
from Riostream.h, which has huge consequences for all of ROOT.
Riostream.h is now a simple wrapper for fstream, iostream, iomanip for backward compatibility; Riosfwd.h simply wraps iosfwd.
Because of templates and their inline functions, Riostream.h needed to be included in headers, too (e.g. TParameter.h), which violated the assumption that Riostream.h is not exposing its using namespace std to headers.
ROOT now requires R__ANSISTREAM, R__SSTREAM, which does not change the set of supported compilers.
Without "using namespace std", several identifiers are now prefixed by std::; e.g. roofit/* source files now have a using namespace std to keep their coding style.
TFile::MakeProject() now generates "using namespace std" to convert the CINT-style class names into C++ ones.
Revision
36584 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Wed Nov 10 10:44:31 2010 UTC (4 years, 2 months ago) by
moneta
File length: 106636 byte(s)
Diff to
previous 36293
fix in TMath::KolmogorovTest the case when the two vectors are identical
- clean up and simplify also the code
in the case of ties the results have been checked manually with R ks.test function
Revision
30749 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Thu Oct 15 16:33:04 2009 UTC (5 years, 3 months ago) by
brun
File length: 106899 byte(s)
Diff to
previous 29770
From Matthew Strait:
This patch fixes the spelling of "function" in the root source code
and documentation, which is misspelled (sometimes as part of larger
"function"-based words) at least 152 times:
* "funciton" 48 times
* "funcion" 36 times
* "funtion" 23 times
* "fucntion" 17 times
* "functionn" 6 times
* "fuction" 6 times
* "fuunction" 4 times
* "functioin" 3 times
* "fonction" 3 times
* "funstion" twice
* "fnuction" once
* "functiom" once
* "functio" once
* "funcition" once
Revision
24832 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Tue Jul 15 13:10:27 2008 UTC (6 years, 6 months ago) by
moneta
File length: 106980 byte(s)
Diff to
previous 23655
- improve documentation for Landau distribution
- also fix landau_pdf to return normalized distribution when scale is different than 1
Revision
23655 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Tue May 6 07:58:46 2008 UTC (6 years, 8 months ago) by
moneta
File length: 106674 byte(s)
Diff to
previous 22885
- merge changes with development branch (up to rev 23650).
Main changes are:
TMath:
from David: The following methods now have additional interface working with Iterators as well:
MinElement
MaxElement
LocMin
LocMax
Mean
GeomMean
RMS
BinarySearch
Sort -> (changed to SortItr)
- use now std in binary search algorithm. Old algorithm failed some tests and it is found to be a
little bit slower
- do not use std instead in LocMin and LocMax since generic std algorithm is slower on 64 bit arch.
- TMath::PoissonI
fix a problem for large values, by using directly the TMath::Poisson implementation
- TMath::Landau and TMath::Landau
remove duplications by using directly ROOT::Math::landau_pdf and ROOT::Math::landau_cdf
- TMath::Prob
use ROOT::Math::chisquared_cdf_c (gives also less rounding errors for small values)
- TMath::GammaDist
use ROOT::Math::gamma_pdf , implementation now returns correct value, 0, for large values of
shape parameter instead of nan
- TMath::LogNormal:
use ROOT::Math::lognormal_pdf
- compile TMath dictionary with -O2
- fix a warning in -Wshadow
- TMath.h is now reordered by functionality and alphabetical order
test:
various improvement from David, see http://root.cern.ch/viewcvs?rev=22880&root=root&view=rev
- add dictionary for the enumeration used in the Integration class
- from David: some clean up of Minimizer class (remove typedef definitions)
Revision
22518 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Mar 7 15:40:22 2008 UTC (6 years, 10 months ago) by
moneta
Original Path:
trunk/math/src/TMath.cxx
File length: 112255 byte(s)
Diff to
previous 22168
Syncronize with the Math develoment branch:
- merge classes from math (TMath, TComplex and TRandom) in libMathCore
- change various functions of TMath (work from David ):
- make a single template functions for all the various types (like Sort or Binart Search)
- use std implementations for Sort, BinarySearch, LocMin
- use mathcore special functions for Gamma and Beta functions
- remove genvector from mathcore
- add classes for integration, derivation and root findings using the algorithms of TF1
- use the plug-in manager to instantiates different implementations of the same classes in MathMore
Revision
21041 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Mon Nov 26 13:19:02 2007 UTC (7 years, 1 month ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 172826 byte(s)
Diff to
previous 21031
From Axel and Silvia Arcelli:
* implement rebinning, add, multiply, divide (incl. binomial)
* fix error calculation, now similar to TH1 etc
* allow for non-equal bin sizes: call constructor without bin edges,
call SetBinEdges() afterwards
Revision
21031 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Sat Nov 24 09:56:30 2007 UTC (7 years, 2 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 172827 byte(s)
Diff to
previous 20975
Improve TMath::KolmogorovTest (Jason Detwiler)
//
// Method Improvement by Jason A Detwiler (JADetwiler@lbl.gov)
// -----------------------------------------------------------
// The nuts-and-bolts of the TMath::KolmogorovTest() algorithm is a for-loop
// over the two sorted arrays a and b representing empirical distribution
// functions. The for-loop handles 3 cases: when the next points to be
// evaluated satisfy a>b, a<b, or a=b:
//
// for (Int_t i=0;i<na+nb;i++) {
// if (a[ia-1] < b[ib-1]) {
// rdiff -= sa;
// ia++;
// if (ia > na) {ok = kTRUE; break;}
// } else if (a[ia-1] > b[ib-1]) {
// rdiff += sb;
// ib++;
// if (ib > nb) {ok = kTRUE; break;}
// } else {
// rdiff += sb - sa;
// ia++;
// ib++;
// if (ia > na) {ok = kTRUE; break;}
// if (ib > nb) {ok = kTRUE; break;}
// }
// rdmax = TMath::Max(rdmax,TMath::Abs(rdiff));
// }
//
// For the last case, a=b, the algorithm advances each array by one index in an
// attempt to move through the equality. However, this is incorrect when one or
// the other of a or b (or both) have a repeated value, call it x. For the KS
// statistic to be computed properly, rdiff needs to be calculated after all of
// the a and b at x have been tallied (this is due to the definition of the
// empirical distribution function; another way to convince yourself that the
// old CERNLIB method is wrong is that it implies that the function defined as the
// difference between a and b is multi-valued at x -- besides being ugly, this
// would invalidate Kolmogorov's theorem).
//
// The solution is to just add while-loops into the equality-case handling to
// perform the tally:
//
// } else {
// double x = a[ia-1];
// while(a[ia-1] == x && ia <= na) {
// rdiff -= sa;
// ia++;
// }
// while(b[ib-1] == x && ib <= nb) {
// rdiff += sb;
// ib++;
// }
// if (ia > na) {ok = kTRUE; break;}
// if (ib > nb) {ok = kTRUE; break;}
// }
Revision
17776 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Thu Feb 8 09:07:50 2007 UTC (7 years, 11 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 170405 byte(s)
Diff to
previous 17653
-Move function NextPrime from TMath to TMathBase. This function is used
by a few Core classes. This moves make base, cont and meta independent of TMath.h.
-TMath::NextPrime implementation is in TObject.cxx (we do not have TMathBase.cxx).
Revision
17399 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Jan 19 07:21:23 2007 UTC (8 years ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 170890 byte(s)
Diff to
previous 17284
From Jason Det:
TMath::BinomialI(p, n, k) is meant to return the probability of observing k
or more events of probability p in n trials. The function simply wraps
TMath::BetaIncomplete(x, a, b) because of the simple relationship between the
functions. However, BetaIncomplete is ill-defined for a=0, which corresponds
to k=0 in BinomialI. But Binomial(p, n, 0) should always give 1.0, since the
probability of getting 0 or more events is always 100%. So this bug can be
quickly fixed by adding the following if() statement in the body of
BinomialI() before the call to BetaIncomplete():
if(k <= 0) return 1.0;
Although the same problem does not occur for k = n, I would still recommend
adding also the following if() statements before the call to BetaIncomplete()
to cut down on computation time:
if(k > n) return 0.0;
if(k == n) return TMath::Power(p, n);
Revision
17146 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Mon Dec 11 10:44:21 2006 UTC (8 years, 1 month ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 178166 byte(s)
Diff to
previous 15763
From Lorenzo:
Replace declarations like
const Double_t array[892];
by
static Double_t array[892];
This makes a huge performance improvement with most compilers (factor 20 !!).
With the const qualifier, the compiler allocates the array at each call !!
Revision
13963 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Tue Jan 31 17:08:29 2006 UTC (8 years, 11 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 178073 byte(s)
Diff to
previous 13300
Improvement of TMath::RootsCubic by Francois-Xavier Gentit
If you call TMath::RootsCubic with the following coefficients:
coef[3] = 1, coef[2] = -2, coef[1] = 1, coef[0] = -2
the polynomial should have the following roots:
2 | +i | -i
and the result given by RootsCubic is:
a b c : 0.666667 2 0.666667 ??????
It is also strange that RootsCubic does not distinguish the 2 cases
(1) - 3 real roots
(2) - 1 real root and 2 complex conjugates ones
The 2 cases could be distinguished for instance by returning a boolean?
I join to this mail a possible replacement for RootsCubic correcting these 2
problems.
Revision
12473 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Mon Aug 15 08:42:46 2005 UTC (9 years, 5 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 172134 byte(s)
Diff to
previous 12419
-Add more comments in TH1::KolmogorovTest
-Implement new function
Double_t TMath::KolmogorovTest(Int_t na, const Double_t *a, Int_t nb, const Double_t *b, Option_t *option)
{
// Statistical test whether two one-dimensional sets of points are compatible
// with coming from the same parent distribution, using the Kolmogorov test.
// That is, it is used to compare two experimental distributions of unbinned data.
//
// Input:
// a,b: One-dimensional arrays of length na, nb, respectively.
// The elements of a and b must be given in ascending order.
// option is a character string to specify options
// "D" Put out a line of "Debug" printout
// "M" Return the Maximum Kolmogorov distance instead of prob
Revision
12027 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Mon Jun 13 13:21:04 2005 UTC (9 years, 7 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 168402 byte(s)
Diff to
previous 11819
From Anna Kreshuk:
Implementation of a new function recently requested a few times:
Double_t TMath::ChisquareQuantile(Double_t p, Double_t ndf)
// Evaluate the quantiles of the chi-squared probability distribution function.
// Algorithm AS 91 Appl. Statist. (1975) Vol.24, P.35
// Incorporates the suggested changes in AS R85 (vol.40(1), pp.233-5, 1991)
// Parameters:
// p - the probability value, at which the quantile is computed
// ndf - number of degrees of freedom
Revision
11819 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Thu May 19 08:26:01 2005 UTC (9 years, 8 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 165340 byte(s)
Diff to
previous 11694
Add two new functions to TMath:
inline Int_t CeilNint(Double_t x);
inline Int_t FloorNint(Double_t x);
make const several arguments in the following functions;
Float_t *Cross(const Float_t v1[3],const Float_t v2[3],Float_t out[3]);
Double_t *Cross(const Double_t v1[3],const Double_t v2[3],Double_t out[3]);
Float_t NormCross(const Float_t v1[3],const Float_t v2[3],Float_t out[3]);
Double_t NormCross(const Double_t v1[3],const Double_t v2[3],Double_t out[3]);
Float_t *Normal2Plane(const Float_t v1[3],const Float_t v2[3],const Float_t v3[3], Float_t normal[3]);
Double_t *Normal2Plane(const Double_t v1[3],const Double_t v2[3],const Double_t v3[3], Double_t normal[3]);
void RootsCubic(const Double_t coef[4],Double_t &a, Double_t &b, Double_t &c);
Revision
11536 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Apr 8 16:45:51 2005 UTC (9 years, 9 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 165435 byte(s)
Diff to
previous 11495
From Anna Kreshuk
Add the new following functions in TMath:
Double_t TMath::Vavilov(Double_t x, Double_t kappa, Double_t beta2)
//Returns the value of the Vavilov density function
//Parameters: 1st - the point were the density function is evaluated
// 2nd - value of kappa (distribution parameter)
// 3rd - value of beta2 (distribution parameter)
//The algorithm was taken from the CernLib function vavden(G115)
//Reference: A.Rotondi and P.Montagna, Fast Calculation of Vavilov distribution
//Nucl.Instr. and Meth. B47(1990), 215-224
//Accuracy: quote from the reference above:
//"The resuls of our code have been compared with the values of the Vavilov
//density function computed numerically in an accurate way: our approximation
//shows a difference of less than 3% around the peak of the density function, slowly
//increasing going towards the extreme tails to the right and to the left"
Double_t TMath::VavilovI(Double_t x, Double_t kappa, Double_t beta2)
//Returns the value of the Vavilov distribution function
//Parameters: 1st - the point were the density function is evaluated
// 2nd - value of kappa (distribution parameter)
// 3rd - value of beta2 (distribution parameter)
//The algorithm was taken from the CernLib function vavden(G115)
//Reference: A.Rotondi and P.Montagna, Fast Calculation of Vavilov distribution
//Nucl.Instr. and Meth. B47(1990), 215-224
//Accuracy: quote from the reference above:
//"The resuls of our code have been compared with the values of the Vavilov
//density function computed numerically in an accurate way: our approximation
//shows a difference of less than 3% around the peak of the density function, slowly
//increasing going towards the extreme tails to the right and to the left"
Double_t TMath::LandauI(Double_t x)
//Returns the value of the Landau distribution function at point x.
//The algorithm was taken from the Cernlib function dislan(G110)
//Reference: K.S.Kolbig and B.Schorr, "A program package for the Landau
//distribution", Computer Phys.Comm., 31(1984), 97-111
Revision
10164 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Sep 24 18:14:08 2004 UTC (10 years, 4 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 133532 byte(s)
Diff to
previous 10067
Modify TMath::MedianImp when computing the medium of an array
with n elements where n>1000 and is an odd number.
The new algorithm gives exactly the same result as other known algorithms, but
it is slower in case n>1000 and even.
Revision
9755 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Aug 13 16:41:16 2004 UTC (10 years, 5 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 133505 byte(s)
Diff to
previous 9739
From Philippe:
This patch re-enables the generation of the Html documentation
for TMath (and any other namespace) on sgi kcc.
NamespaceImp is still not useable on alpha and solaris.
On solaris this is due to a bug/problen in the compiler/linker
in the handling of inline function (there are __always__ local
symbol (instead of weak symbols)).
Revision
9723 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Wed Aug 11 09:39:16 2004 UTC (10 years, 5 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 133386 byte(s)
Diff to
previous 9652
New functions in TMath: Original code by Anna Kreshuk
Double_t TMath::CauchyDist(Double_t x, Double_t t, Double_t s)
//computes the density of Cauchy distribution at point x
//by default, standard Cauchy distribution is used (t=0, s=1)
//t is the location parameter
//s is the scale parameter
//The Cauchy distribution, also called Lorentzian distribution,
//is a continuous distribution describing resonance behavior
//The mean and standard deviation of the Cauchy distribution are undefined.
//The practical meaning of this is that collecting 1,000 data points gives
//no more accurate an estimate of the mean and standard deviation than does a single point.
//the formula was taken from "Engineering Statistics Handbook" on site
//http://www.itl.nist.gov/div898/handbook/eda/section3/eda3663.htm
Double_t TMath::GammaDist(Double_t x, Double_t gamma, Double_t mu, Double_t beta)
//computes the density function of Gamma distribution at point x
//gamma - shape parameter
//mu - location parameter
//beta - scale parameter
//the formula was taken from "Engineering Statistics Handbook" on site
//http://www.itl.nist.gov/div898/handbook/eda/section3/eda366b.htm
// --implementation by Anna Kreshuk
Double_t TMath::LogNormal(Double_t x, Double_t sigma, Double_t theta, Double_t m)
//computes the density of LogNormal distribution at point x
//variable X has lognormal distribution if Y=Ln(X) has normal distribution
//sigma is the shape parameter
//theta is the location parameter
//m is the scale parameter
//the formula was taken from "Engineering Statistics Handbook" on site
//http://www.itl.nist.gov/div898/handbook/eda/section3/eda3669.htm
Examples of these functions are shown in the new tutorial mathGammaNormal.C
Revision
9644 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Jul 30 23:46:34 2004 UTC (10 years, 5 months ago) by
rdm
Original Path:
trunk/math/src/TMath.cxx
File length: 122905 byte(s)
Diff to
previous 9636
From Philippe:
This patch should work around the problem on alpha by
disabling the external call to TMath::ROOT::GenerateInitInstance
but this disable the ability to generate the doc on Alpha (for
TMath).
This patch also resolves several problem with nesting of
namespace and classes.
Note: To register an implementation file for a namespace do
NamespaceImp(namespaceName)
To do so for nested namespace, do not use a fully qualified
name but use the proper nesting:
namespace reallyout { namespace outer { NamespaceImp(inner) } }
In rootcint, this patch also prevent the (re)definition of the
compilers specific macros (like __GNUC) when we are using the
compiler's preprocessor.
Revision
9636 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Jul 30 19:09:52 2004 UTC (10 years, 5 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 122821 byte(s)
Diff to
previous 9591
From Philippe:
This patch change TMath from a class to a namespace.
This patch also updates rootcint to that it force the
creation of a TClass for namepaces. The TClass for
namespace is needed to allow THtml and the command
completion mechanism to properly work.
This patch also add the new macro
NamespaceImp(namespacename)
which register an implementation file for the namespace.
This patch also update THtml to clean up the output for namespaces.
Revision
9581 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Jul 23 14:29:15 2004 UTC (10 years, 6 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 122451 byte(s)
Diff to
previous 9485
New version of TMath with several emhancements and new functions.
Most functions accept now a Long64_t instead of Int_t for the
length of the arrays.
The Median functions have been improved in speed (thanks Anna Kreshuk).
The following functions are either new or have a new prototype
that should be back compatible.
// Min, Max of an array
static Short_t MinElement(Long64_t n, const Short_t *a);
static Int_t MinElement(Long64_t n, const Int_t *a);
static Float_t MinElement(Long64_t n, const Float_t *a);
static Double_t MinElement(Long64_t n, const Double_t *a);
static Long64_t MinElement(Long64_t n, const Long64_t *a);
static Short_t MaxElement(Long64_t n, const Short_t *a);
static Int_t MaxElement(Long64_t n, const Int_t *a);
static Float_t MaxElement(Long64_t n, const Float_t *a);
static Double_t MaxElement(Long64_t n, const Double_t *a);
static Long64_t MaxElement(Long64_t n, const Long64_t *a);
// Locate Min, Max element number in an array
static Long64_t LocMin(Long64_t n, const Short_t *a);
static Long64_t LocMin(Long64_t n, const Int_t *a);
static Long64_t LocMin(Long64_t n, const Float_t *a);
static Long64_t LocMin(Long64_t n, const Double_t *a);
static Long64_t LocMin(Long64_t n, const Long64_t *a);
static Long64_t LocMax(Long64_t n, const Short_t *a);
static Long64_t LocMax(Long64_t n, const Int_t *a);
static Long64_t LocMax(Long64_t n, const Float_t *a);
static Long64_t LocMax(Long64_t n, const Double_t *a);
static Long64_t LocMax(Long64_t n, const Long64_t *a);
//Mean, Geometric Mean, Median, RMS
static Double_t Mean(Long64_t n, const Short_t *a, const Double_t *w=0);
static Double_t Mean(Long64_t n, const Int_t *a, const Double_t *w=0);
static Double_t Mean(Long64_t n, const Float_t *a, const Double_t *w=0);
static Double_t Mean(Long64_t n, const Double_t *a,const Double_t *w=0);
static Double_t Mean(Long64_t n, const Long64_t *a,const Double_t *w=0);
static Double_t GeomMean(Long64_t n, const Short_t *a);
static Double_t GeomMean(Long64_t n, const Int_t *a);
static Double_t GeomMean(Long64_t n, const Float_t *a);
static Double_t GeomMean(Long64_t n, const Double_t *a);
static Double_t GeomMean(Long64_t n, const Long64_t *a);
static Double_t RMS(Long64_t n, const Short_t *a);
static Double_t RMS(Long64_t n, const Int_t *a);
static Double_t RMS(Long64_t n, const Float_t *a);
static Double_t RMS(Long64_t n, const Double_t *a);
static Double_t RMS(Long64_t n, const Long64_t *a);
static Double_t Median(Long64_t n, const Short_t *a, const Double_t *w=0, Long64_t *work=0);
static Double_t Median(Long64_t n, const Int_t *a, const Double_t *w=0, Long64_t *work=0);
static Double_t Median(Long64_t n, const Float_t *a, const Double_t *w=0, Long64_t *work=0);
static Double_t Median(Long64_t n, const Double_t *a, const Double_t *w=0, Long64_t *work=0);
static Double_t Median(Long64_t n, const Long64_t *a, const Double_t *w=0, Long64_t *work=0);
static Short_t KOrdStat(Long64_t n, const Short_t *a, Long64_t k, Long64_t *work=0);
static Int_t KOrdStat(Long64_t n, const Int_t *a, Long64_t k, Long64_t *work=0);
static Float_t KOrdStat(Long64_t n, const Float_t *a, Long64_t k, Long64_t *work=0);
static Double_t KOrdStat(Long64_t n, const Double_t *a, Long64_t k, Long64_t *work=0);
static Long64_t KOrdStat(Long64_t n, const Long64_t *a, Long64_t k, Long64_t *work=0);
// Binary search
static Long64_t BinarySearch(Long64_t n, const Short_t *array, Short_t value);
static Long64_t BinarySearch(Long64_t n, const Short_t **array, Short_t value);
static Long64_t BinarySearch(Long64_t n, const Int_t *array, Int_t value);
static Long64_t BinarySearch(Long64_t n, const Int_t **array, Int_t value);
static Long64_t BinarySearch(Long64_t n, const Float_t *array, Float_t value);
static Long64_t BinarySearch(Long64_t n, const Float_t **array, Float_t value);
static Long64_t BinarySearch(Long64_t n, const Double_t *array, Double_t value);
static Long64_t BinarySearch(Long64_t n, const Double_t **array, Double_t value);
static Long64_t BinarySearch(Long64_t n, const Long64_t *array, Long64_t value);
static Long64_t BinarySearch(Long64_t n, const Long64_t **array, Long64_t value);
// Sorting
static void Sort(Int_t n, const Short_t *a, Int_t *index, Bool_t down=kTRUE);
static void Sort(Int_t n, const Int_t *a, Int_t *index, Bool_t down=kTRUE);
static void Sort(Int_t n, const Float_t *a, Int_t *index, Bool_t down=kTRUE);
static void Sort(Int_t n, const Double_t *a, Int_t *index, Bool_t down=kTRUE);
static void Sort(Int_t n, const Long64_t *a, Int_t *index, Bool_t down=kTRUE);
static void Sort(Long64_t n, const Short_t *a, Long64_t *index, Bool_t down=kTRUE);
static void Sort(Long64_t n, const Int_t *a, Long64_t *index, Bool_t down=kTRUE);
static void Sort(Long64_t n, const Float_t *a, Long64_t *index, Bool_t down=kTRUE);
static void Sort(Long64_t n, const Double_t *a, Long64_t *index, Bool_t down=kTRUE);
static void Sort(Long64_t n, const Long64_t *a, Long64_t *index, Bool_t down=kTRUE);
Revision
9394 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Mon Jul 5 17:51:12 2004 UTC (10 years, 6 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 113279 byte(s)
Diff to
previous 9262
Add new prototype for TMath::Sort.
static void Sort(Long64_t n, const Long64_t *a, Long64_t *index, Bool_t down=kTRUE);
This new prototype will be used by the new TTreeIndex class.
Add new functions
static Double_t ErfInverse(Double_t x);
static Double_t ErfcInverse(Double_t x) {return TMath::ErfInverse(1-x);}
TMath::Erf computes the inverse of the error function
Revision
9262 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Sat Jun 19 13:38:56 2004 UTC (10 years, 7 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 110453 byte(s)
Diff to
previous 9256
Add new functions to TMath:
//Mean, Median, RMS
static Double_t Mean(Int_t n, const Short_t *a);
static Double_t Mean(Int_t n, const Int_t *a);
static Double_t Mean(Int_t n, const Float_t *a);
static Double_t Mean(Int_t n, const Double_t *a);
static Double_t Mean(Int_t n, const Long_t *a);
static Double_t Mean(Int_t n, const Long64_t *a);
static Short_t Median(Int_t n, const Short_t *a);
static Int_t Median(Int_t n, const Int_t *a);
static Float_t Median(Int_t n, const Float_t *a);
static Double_t Median(Int_t n, const Double_t *a);
static Long_t Median(Int_t n, const Long_t *a);
static Long64_t Median(Int_t n, const Long64_t *a);
static Double_t MedianSorted(Int_t n, Double_t *a);
static Double_t RMS(Int_t n, const Short_t *a);
static Double_t RMS(Int_t n, const Int_t *a);
static Double_t RMS(Int_t n, const Float_t *a);
static Double_t RMS(Int_t n, const Double_t *a);
static Double_t RMS(Int_t n, const Long_t *a);
static Double_t RMS(Int_t n, const Long64_t *a);
// Statistics
static Double_t Beta(Double_t p, Double_t q);
static Double_t BetaCf(Double_t x, Double_t a, Double_t b);
static Double_t BetaIncomplete(Double_t x, Double_t a, Double_t b);
static Double_t BinomialI(Double_t p, Int_t n, Int_t k);
static Double_t FDist(Double_t F, Double_t N, Double_t M);
static Double_t FDistI(Double_t F, Double_t N, Double_t M);
static Double_t Student(Double_t T, Double_t ndf);
static Double_t StudentI(Double_t T, Double_t ndf);
Revision
8717 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Wed Apr 28 08:06:08 2004 UTC (10 years, 8 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 93937 byte(s)
Diff to
previous 8686
Implement suggestions (and code) from Kevin Lynch <krlynch@bu.edu>
in the TMath functions "hypot", "ASinH","ACosH", "Normalize", "Poisson".
... the functions I've "fixed" are those
that are not internally protected against numerical overflow in
intermediate calculations, but whose final results should be
representable.
... I have tested all this suggested code, although not extensively.
In the regions where the current TMath functions are safe, these
replacements behave similarly; they also work in regions where the
current functions fail, including the region where Ken Bloom reported
the problem, for instance:
root [2] TMath::Poisson(170,70)
Error: Symbol inf is not defined in current scope FILE: LINE:0
(Double_t)inf
*** Interpreter error recovered ***
root [3] TMathnew::Poisson(170,70)
(Double_t)2.54255920378495108e-24
root [4] TMath::Poisson(10,5)
(Double_t)1.81327887078059496e-02
root [5] TMathnew::Poisson(10,5)
(Double_t)1.81327887078059427e-02
Revision
8050 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Tue Jan 27 16:28:53 2004 UTC (10 years, 11 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 87953 byte(s)
Diff to
previous 7742
Implement support for Long64 and ULong64_t types with the new functions:
static Long64_t Abs(Long64_t d);
static Long64_t Sign(Long64_t a, Long64_t b);
static Long64_t Min(Long64_t a, Long64_t b);
static ULong64_t Min(ULong64_t a, ULong64_t b);
static Long64_t Max(Long64_t a, Long64_t b);
static ULong64_t Max(ULong64_t a, ULong64_t b);
static Int_t LocMin(Int_t n, const Long64_t *a);
static Int_t LocMax(Int_t n, const Long64_t *a);
static Int_t BinarySearch(Int_t n, const Long64_t *array, Long64_t value);
static Int_t BinarySearch(Int_t n, const Long64_t **array, Long64_t value);
static void Sort(Int_t n, const Long64_t *a, Int_t *index, Bool_t down=kTRUE);
Revision
6719 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Jun 13 15:57:46 2003 UTC (11 years, 7 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 82592 byte(s)
Diff to
previous 6568
Implement a suggestion from Sylwester Radomski in TMath::Poisson
The function TMath::Poisson(x, par) do not return correct value
for x = 0.
In the code of TMath it is: if (x<=0) return 0;
For x=0 the function shall return exp(-par).
Revision
6322 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Tue Mar 18 15:49:25 2003 UTC (11 years, 10 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 82499 byte(s)
Diff to
previous 6066
Split the function previously called TMath::Struve(Int_t n, Double_t x)
into two functions with names following the mathematical nomenclature for Struve/Bessel
functions and add two new functions (thanks to Kirill Filimonov)
to compute the modified Struve functions.
The new functions are:
static Double_t StruveH0(Double_t x);
static Double_t StruveH1(Double_t x);
static Double_t StruveL0(Double_t x);
static Double_t StruveL1(Double_t x);
Revision
5412 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Thu Oct 10 17:08:52 2002 UTC (12 years, 3 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 80778 byte(s)
Diff to
previous 5142
Add new functions Inside
Bool_t TMath::IsInside(Double_t xp, Double_t yp, Int_t np, Double_t *x, Double_t *y)
// Function which returns kTRUE if point xp,yp lies inside the
// polygon defined by the np points in arrays x and y, kFALSE otherwise
Bool_t TMath::IsInside(Float_t xp, Float_t yp, Int_t np, Float_t *x, Float_t *y)
Bool_t TMath::IsInside(Int_t xp, Int_t yp, Int_t np, Int_t *x, Int_t *y)
Revision
5130 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Aug 16 13:43:10 2002 UTC (12 years, 5 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 78307 byte(s)
Diff to
previous 4805
Add a new function
Double_t TMath::Voigt(Double_t x, Double_t sigma, Double_t lg, Int_t R)
// Computation of Voigt function (normalised).
// Voigt is a convolution of
// gauss(x) = 1/(sqrt(2*pi)*sigma) * exp(x*x/(2*sigma*sigma)
// and
// lorentz(x) = (1/pi) * (lg/2) / (x*x + g*g/4)
// functions.
// The Voigt function is known to be the real part of Faddeeva function also
// called complex error function [2].
// The algoritm was developed by J. Humlicek [1].
// This code is based on fortran code presented by R. J. Wells [2].
// Translated and adapted by Miha D. Puc
// To calculate the Faddeeva function with relative error less than 10^(-R).
// R can be set by the the user subject to the constraints 2 <= R <= 5.
// [1] J. Humlicek, JQSRT, 21, 437 (1982).
// [2] R. J. Wells, Rapid Approximation to the Voigt/Faddeeva Function and
// it's Derivatives.
From original mail by miha.puc@marvin.fmf.uni-lj.si
Voigt function is very common in optical spectrometry (astronomy, ..) and
also in X-ray spectrometry. I found it's quite difficult to get a
good and fast approximation algorthm and I think having voigt in TMath
would be of great value to many. For this reason and since I already have
the code I'm sending it to you to consider.
Revision
3878 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Tue Feb 5 22:51:52 2002 UTC (12 years, 11 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 68273 byte(s)
Diff to
previous 3743
Add new Bessel functions and also the Struve function:
static Double_t BesselJ0(Double_t x); // Bessel function J0(x) for any real x
static Double_t BesselJ1(Double_t x); // Bessel function J1(x) for any real x
static Double_t BesselY0(Double_t x); // Bessel function Y0(x) for positive x
static Double_t BesselY1(Double_t x); // Bessel function Y1(x) for positive x
static Double_t Struve(Int_t n, Double_t x); // Struve functions of order 0 and 1
Revision
1760 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Wed Mar 7 16:49:17 2001 UTC (13 years, 10 months ago) by
rdm
Original Path:
trunk/math/src/TMath.cxx
File length: 51766 byte(s)
Diff to
previous 1096
new Hash function by V.Perev. It has the following qualities:
Based on precalculated table of 256 specially selected numbers.
These numbers are selected in such a way, that for string
length == 4 (integer number) the hash is unambigous, i.e.
from hash value we can recalculate input (no degeneration).
The quality of hash method is good enough, that
"random" numbers made as R = Hash(1), Hash(2), ...Hash(N)
tested by <R>, <R*R>, <Ri*Ri+1> gives the same result
as for libc rand().
Revision
302 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Fri Jun 30 07:24:54 2000 UTC (14 years, 6 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 47021 byte(s)
Diff to
previous 301
Fix a bug in TMath::NextPrime reported by David Faden
TMath::NextPrime(Long_t) doesn't return the next prime when its argument
happens to be prime (excluding two) - instead it returns its argument. As well,
TMath::NextPrime(x) returns three for x less than two and TMath::NextPrime(3)
doesn't check for the prime number following three but returns three directly.
Revision
292 -
(
view)
(
download)
(
as text)
(
annotate)
-
[select for diffs]
Modified
Wed Jun 28 14:32:54 2000 UTC (14 years, 6 months ago) by
brun
Original Path:
trunk/math/src/TMath.cxx
File length: 46155 byte(s)
Diff to
previous 3
Add a new function KolmogorovProb in TMath.
Double_t TMath::KolmogorovProb(Double_t z)
{
// Calculates the probability of exceeding the value z=dn*N**2
// for the Kolmogorov test, where dn=maximum distance between
// cumulative distribution function and N experimental values.
// Function holds only for large N, but is accurate to 10**-11
// Theta function inversion formula is used for Z <= 1
This form allows you to request diffs between any two revisions of this file.
For each of the two "sides" of the diff,
enter a numeric revision.