TMath::Sort Not in root anymore?

Hi,

I was using the function TMath::Sort in ROOTv 5.34/30 then I tried to use range based loops to loop over the index (which is the thing that is sorted) but the gcc version in that ROOT version does not support range based loops. So I setup ROOTv 6.05/01 and I found out that TMath::Sort is not there anymore. Why was this function not implemented in ROOT6? Shouldn’t that make ROOT not backwards compatible?

Thanks.

Seems to me it is still there:

line 226 in:

root.cern.ch/gitweb?p=root.git; … 7897bc31ad

226 void Sort(Index n, const Element* a, Index* index, Bool_t down=kTRUE);

Hi,

I am using ROOTv 6.02/12 from CVMFS in both OSX 10.10.5 and ScientificLinux 6 and I cant get this function to appear, either when I type “TMath::S” and then do tab or when I use it. This is the list of functions that are working.

root [0] TMath::S

Sigma
SigmaUncertainty
Sign
Sign
Sign
Sign
Sign
Sign
SignalingNaN
Sin
SinH
Sqrt
Sqrt2
StruveH0
StruveH1
StruveL0
StruveL1
Student
StudentI
StudentQuantile

On the other hand in ROOTv 5.34/30

root [0] TMath::S

Sign
Sign
Sign
Sign
Sign
Sign
Sqrt2
Sigma
SigmaUncertainty
Sin
SinH
Sqrt
SignalingNaN
Student
StudentI
StudentQuantile
StruveH0
StruveH1
StruveL0
StruveL1
Sort
Sort
Sort
Sort
Sort
Sort
Sort
Sort
Sort
Sort
Sort
Sort

Im running the code below and in root 6 I get:

Processing test.cxx…
/Users/angelcampoverde/WORK/Test/./test.cxx:7:3: error: no matching function for
call to ‘Sort’
TMath::Sort(4, array, index);
^~~~~~~~~~~
/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64-MacOS/root/6.02.12-x86_64-mac1010-clang61-opt/include/TMath.h:925:57: note:
candidate template ignored: deduced conflicting types for parameter
’Index’ (‘int’ vs. ‘long long’)
template <typename Element, typename Index> void TMath::Sort(Index n, co…

in root5 it works.

[code]{
float array[4]={2, 1, 5, 4};
long long index[4];
long long size = 4;

TMath::Sort(4, array, index);

for (int ind = 0; ind < size ; ind++)
{
std::cout << "INDEX "<< index[ind] << std::endl;
}

}[/code]

Can you reproduce this?

Thanks.

Hi,

array and index are not good names. This macro works for me

{
   float a[4]={2, 1, 5, 4};
   long long size = 4;
   long long ind[4];
   TMath::Sort(size,a,ind);
   for (int i = 0; i < size; ++i) 
      std::cout << "INDEX   "<< ind[i] << std::endl;
}

Lorenzo

Hi,

Yes, it works. That is strange, those names work in ROOT5 but not in ROOT6 and the message does not seem to tell anything about the name of those arrays.

Thanks.

std::array is a new type part of C+±11. ROOT 5 by default is not compiled with C++11

Lorenzo