Changeset 9219 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 01/14/09 12:31:37 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MMath.cc
r9195 r9219 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.4 2 2008-12-21 18:09:49tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.43 2009-01-14 12:31:36 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 324 324 Double_t MMath::MedianDev(Long64_t n, const Long64_t *a) { Double_t med; return MedianDevImp(n, a, med); } 325 325 326 // ------------------------------------------------------------------------ 327 // 328 // Re-sort an array. Intsead of returning an index (like TMath::Sort) 329 // the array contents are sorted. 330 // 331 template <class Size, class Element> void MMath::ReSortImp(Size n, Element *a, Bool_t down) 332 { 333 Element *cpy = new Element[n]; 334 Int_t *pos = new Int_t[n]; 335 336 memcpy(cpy, a, n*sizeof(Element)); 337 338 TMath::Sort(n, a, pos, down); 339 340 Int_t *idx = pos; 341 342 for (Element *ptr=a; ptr<a+n; ptr++) 343 *ptr = cpy[*idx++]; 344 345 delete cpy; 346 delete pos; 347 } 348 349 void MMath::ReSort(Long64_t n, Short_t *a, Bool_t down) { ReSortImp(n, a, down); } 350 void MMath::ReSort(Long64_t n, Int_t *a, Bool_t down) { ReSortImp(n, a, down); } 351 void MMath::ReSort(Long64_t n, Float_t *a, Bool_t down) { ReSortImp(n, a, down); } 352 void MMath::ReSort(Long64_t n, Double_t *a, Bool_t down) { ReSortImp(n, a, down); } 353 326 354 // -------------------------------------------------------------------------- 327 355 // -
trunk/MagicSoft/Mars/mbase/MMath.h
r8989 r9219 17 17 { 18 18 Double_t GaussProb(Double_t x, Double_t sigma=1, Double_t mean=0); 19 20 template <class Size, class Element> void ReSortImp(Size n, Element *a, Bool_t down=kFALSE); 21 void ReSort(Long64_t n, Short_t *a, Bool_t down=kFALSE); 22 void ReSort(Long64_t n, Int_t *a, Bool_t down=kFALSE); 23 void ReSort(Long64_t n, Float_t *a, Bool_t down=kFALSE); 24 void ReSort(Long64_t n, Double_t *a, Bool_t down=kFALSE); 19 25 20 26 template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a) { Double_t med; return MedianDevImp(n, a, med); }
Note:
See TracChangeset
for help on using the changeset viewer.