// Example macro describing how to use the special mathematical functions // taking full advantage of the precision and speed of the C99 compliant // environments. To execute the macro type in: // // root[0]: .x mathcoreSpecFunc.C // // It will create two canvases: // // a) one with the representation of the tgamma, lgamma, erf and erfc functions // b) one with the relative difference between the old ROOT versions and the // C99 implementation (on obsolete platform+compiler combinations which are // not C99 compliant it will call the original ROOT implementations, hence // the difference will be 0) // // The naming and numbering of the functions is taken from // <A HREF="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1687.pdf"> // Matt Austern, // (Draft) Technical Report on Standard Library Extensions, // N1687=04-0127, September 10, 2004</A> // // Author: Andras Zsenei #include "TF1.h" #include "TSystem.h" #include "TCanvas.h" void mathcoreSpecFunc() { gSystem->Load("libMathCore"); TF1 *f1a = new TF1("f1a","ROOT::Math::tgamma(x)",0,20); TF1 *f1b = new TF1("f1b","abs((ROOT::Math::tgamma(x)-TMath::Gamma(x))/ROOT::Math::tgamma(x))",0,20); TF1 *f2a = new TF1("f2a","ROOT::Math::lgamma(x)",0,100); TF1 *f2b = new TF1("f2b","abs((ROOT::Math::lgamma(x)-TMath::LnGamma(x))/ROOT::Math::lgamma(x))",0,100); TF1 *f3a = new TF1("f3a","ROOT::Math::erf(x)",0,5); TF1 *f3b = new TF1("f3b","abs((ROOT::Math::erf(x)-TMath::Erf(x))/ROOT::Math::erf(x))",0,5); TF1 *f4a = new TF1("f4a","ROOT::Math::erfc(x)",0,5); TF1 *f4b = new TF1("f4b","abs((ROOT::Math::erfc(x)-TMath::Erfc(x))/ROOT::Math::erfc(x))",0,5); TCanvas *c1 = new TCanvas("c1","c1",1000,750); c1->SetFillColor(kYellow-10); f1a->SetLineColor(kBlue); f1b->SetLineColor(kBlue); f2a->SetLineColor(kBlue); f2b->SetLineColor(kBlue); f3a->SetLineColor(kBlue); f3b->SetLineColor(kBlue); f4a->SetLineColor(kBlue); f4b->SetLineColor(kBlue); c1->Divide(2,2); c1->cd(1); f1a->Draw(); c1->cd(2); f2a->Draw(); c1->cd(3); f3a->Draw(); c1->cd(4); f4a->Draw(); TCanvas *c2 = new TCanvas("c2","c2",1000,750); c2->SetFillColor(kYellow-10); c2->Divide(2,2); c2->cd(1); f1b->Draw(); c2->cd(2); f2b->Draw(); c2->cd(3); f3b->Draw(); c2->cd(4); f4b->Draw(); } mathcoreSpecFunc.C:1 mathcoreSpecFunc.C:2 mathcoreSpecFunc.C:3 mathcoreSpecFunc.C:4 mathcoreSpecFunc.C:5 mathcoreSpecFunc.C:6 mathcoreSpecFunc.C:7 mathcoreSpecFunc.C:8 mathcoreSpecFunc.C:9 mathcoreSpecFunc.C:10 mathcoreSpecFunc.C:11 mathcoreSpecFunc.C:12 mathcoreSpecFunc.C:13 mathcoreSpecFunc.C:14 mathcoreSpecFunc.C:15 mathcoreSpecFunc.C:16 mathcoreSpecFunc.C:17 mathcoreSpecFunc.C:18 mathcoreSpecFunc.C:19 mathcoreSpecFunc.C:20 mathcoreSpecFunc.C:21 mathcoreSpecFunc.C:22 mathcoreSpecFunc.C:23 mathcoreSpecFunc.C:24 mathcoreSpecFunc.C:25 mathcoreSpecFunc.C:26 mathcoreSpecFunc.C:27 mathcoreSpecFunc.C:28 mathcoreSpecFunc.C:29 mathcoreSpecFunc.C:30 mathcoreSpecFunc.C:31 mathcoreSpecFunc.C:32 mathcoreSpecFunc.C:33 mathcoreSpecFunc.C:34 mathcoreSpecFunc.C:35 mathcoreSpecFunc.C:36 mathcoreSpecFunc.C:37 mathcoreSpecFunc.C:38 mathcoreSpecFunc.C:39 mathcoreSpecFunc.C:40 mathcoreSpecFunc.C:41 mathcoreSpecFunc.C:42 mathcoreSpecFunc.C:43 mathcoreSpecFunc.C:44 mathcoreSpecFunc.C:45 mathcoreSpecFunc.C:46 mathcoreSpecFunc.C:47 mathcoreSpecFunc.C:48 mathcoreSpecFunc.C:49 mathcoreSpecFunc.C:50 mathcoreSpecFunc.C:51 mathcoreSpecFunc.C:52 mathcoreSpecFunc.C:53 mathcoreSpecFunc.C:54 mathcoreSpecFunc.C:55 mathcoreSpecFunc.C:56 mathcoreSpecFunc.C:57 mathcoreSpecFunc.C:58 mathcoreSpecFunc.C:59 mathcoreSpecFunc.C:60 mathcoreSpecFunc.C:61 mathcoreSpecFunc.C:62 mathcoreSpecFunc.C:63 mathcoreSpecFunc.C:64 mathcoreSpecFunc.C:65 mathcoreSpecFunc.C:66 mathcoreSpecFunc.C:67 mathcoreSpecFunc.C:68 mathcoreSpecFunc.C:69 mathcoreSpecFunc.C:70 mathcoreSpecFunc.C:71 mathcoreSpecFunc.C:72 mathcoreSpecFunc.C:73 mathcoreSpecFunc.C:74 mathcoreSpecFunc.C:75 mathcoreSpecFunc.C:76 mathcoreSpecFunc.C:77 mathcoreSpecFunc.C:78 mathcoreSpecFunc.C:79 mathcoreSpecFunc.C:80 mathcoreSpecFunc.C:81 mathcoreSpecFunc.C:82 mathcoreSpecFunc.C:83 mathcoreSpecFunc.C:84 mathcoreSpecFunc.C:85 |
|