Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/metacling/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4433,6 +4433,11 @@ void TCling::CreateListOfBaseClasses(TClass *cl) const
if (cl->fBase) {
return;
}
// Ignore the base class (e.g. `std::_Complex_base` on Windows)
if (TClassEdit::GetComplexType(cl->GetName()) != TClassEdit::EComplexType::kNone) {
cl->fBase = new TList();
return;
}
TClingClassInfo *tci = (TClingClassInfo *)cl->GetClassInfo();
if (!tci) return;
TClingBaseClassInfo t(GetInterpreterImpl(), tci);
Expand Down
4 changes: 0 additions & 4 deletions roottest/root/io/complex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,22 @@ ROOTTEST_GENERATE_REFLEX_DICTIONARY(classWithComplex
ROOTTEST_ADD_TEST(writeClassWithComplex
MACRO execwriteClassWithComplex.C
OUTREF execwriteClassWithComplex.ref
${WILLFAIL_ON_WIN32}
FIXTURES_REQUIRED root-io-complex-dict-fixture
FIXTURES_SETUP root-io-complex-writeClassWithComplex-fixture)

ROOTTEST_ADD_TEST(readClassWithComplex
MACRO execreadClassWithComplex.C
OUTREF execreadClassWithComplex.ref
${WILLFAIL_ON_WIN32}
FIXTURES_REQUIRED root-io-complex-writeClassWithComplex-fixture)


ROOTTEST_ADD_TEST(writecomplex
MACRO execwritecomplex.C
${WILLFAIL_ON_WIN32}
OUTREF execwritecomplex.ref
FIXTURES_SETUP root-io-complex-writecomplex-fixture)

ROOTTEST_ADD_TEST(readcomplex
COPY_TO_BUILDDIR complexOfilekubuntuROOT5.root complexOfilekubuntuROOT6.root complexOfileslc6ROOT5.xml complexOfilekubuntuROOT5.xml complexOfilekubuntuROOT6.xml complexOfileslc6ROOT5.root
MACRO execreadcomplex.C
OUTREF execreadcomplex.ref
${WILLFAIL_ON_WIN32}
FIXTURES_REQUIRED root-io-complex-writecomplex-fixture)
49 changes: 29 additions & 20 deletions roottest/root/io/complex/execreadcomplex.C
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// This macro must be v5/v6 executable!

void compareValues(const char* filename,
complex<float> cFloat, complex<float> cFloatRef,
complex<double> cDouble, complex<double> cDoubleRef){
void compareValues(const char *filename, const char *where, complex<float> cFloat, complex<float> cFloatRef,
complex<double> cDouble, complex<double> cDoubleRef)
{
if (cFloatRef != cFloat) {
cout << "ERROR complex<float> on file " << filename << " numbers differ! Reference: " << cFloatRef << " on disk " << cFloat << endl;
cout << "ERROR complex<float> on file " << filename << " numbers differ for " << where
<< " ! Reference: " << cFloatRef << " on disk " << cFloat << endl;
}
if (cDoubleRef != cDouble) {
cout << "ERROR complex<double> on file " << filename << " numbers differ! Reference: " << cDoubleRef << " on disk " << cDouble << endl;
cout << "ERROR complex<double> on file " << filename << " numbers differ for " << where
<< " ! Reference: " << cDoubleRef << " on disk " << cDouble << endl;
}

}

void readcomplex(const std::string base)
Expand Down Expand Up @@ -46,8 +47,14 @@ void readcomplex(const std::string base)
for (int j = 0; j < nIters; ++j) {

// Re-generate values
std::complex<float> cFloatRef(rndm.Uniform(theMin, theMax), rndm.Uniform(theMin, theMax));
std::complex<double> cDoubleRef(rndm.Uniform(theMin, theMax), rndm.Uniform(theMin, theMax));
// Since the order of execution of function arguments are not guarantees by the standard,
// don't pass TRandom3 methods as function arguments, to avoid potential cross-platform differences
auto rnd1 = rndm.Uniform(theMin, theMax);
auto rnd2 = rndm.Uniform(theMin, theMax);
auto rnd3 = rndm.Uniform(theMin, theMax);
auto rnd4 = rndm.Uniform(theMin, theMax);
std::complex<float> cFloatRef(rnd1, rnd2);
std::complex<double> cDoubleRef(rnd3, rnd4);

// read them
TString cFloatName(TString::Format("cFloat_%i", j));
Expand All @@ -63,42 +70,44 @@ void readcomplex(const std::string base)
cout << "ERROR Cannot get " << cDoubleName << " from file " << ifilename << endl;
continue;
}

// compare them bit-by-bit
compareValues(ifilename, *cFloatPtr, cFloatRef, *cDoublePtr, cDoubleRef);

compareValues(ifilename, TString::Format("cFloat/cDouble #%i", j), *cFloatPtr, cFloatRef, *cDoublePtr,
cDoubleRef);
}

if (iFile != 1) {

// Now the tree
TTreeReader reader ("t",ifile);
TTreeReaderValue<complex<float>> cFloat_split(reader, "cFloat_split");
TTreeReaderValue<complex<float>> cFloat(reader, "cFloat");
TTreeReaderValue<complex<double>> cDouble_split(reader, "cDouble_split");
TTreeReaderValue<complex<double>> cDouble(reader, "cDouble");

int e = 0;
while (reader.Next()) {
std::complex<float> cFloatn(rndm.Uniform(theMin,theMax),rndm.Uniform(theMin,theMax));
std::complex<double> cDoublen(rndm.Uniform(theMin,theMax),rndm.Uniform(theMin,theMax));
compareValues(ifilename, *cFloat_split, cFloatn, *cDouble_split, cDoublen);
compareValues(ifilename, *cFloat, cFloatn, *cDouble, cDoublen);
auto rnd11 = rndm.Uniform(theMin, theMax);
auto rnd12 = rndm.Uniform(theMin, theMax);
auto rnd13 = rndm.Uniform(theMin, theMax);
auto rnd14 = rndm.Uniform(theMin, theMax);
std::complex<float> cFloatn(rnd11, rnd12);
std::complex<double> cDoublen(rnd13, rnd14);
compareValues(ifilename, TString::Format("Split branch entry #%i", e), *cFloat_split, cFloatn,
*cDouble_split, cDoublen);
compareValues(ifilename, TString::Format("Streamed branch entry #%i", e), *cFloat, cFloatn, *cDouble,
cDoublen);
++e;
}

}

}
}

void execreadcomplex()
{

// Files produced on this very platform
readcomplex("complexOfileROOT6");

// A collection of files coming for elsewhere
readcomplex("complexOfilekubuntuROOT5");
readcomplex("complexOfilekubuntuROOT6");
readcomplex("complexOfileslc6ROOT5");

}
59 changes: 35 additions & 24 deletions roottest/root/io/complex/execwritecomplex.C
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// This macro must be v5/v6 executable!

void writecomplex(const std::string base){

void writecomplex(const std::string base)
{
const int nentries = 1000;

const double theMax = 1000.;
const double theMin = -theMax;

// The two formats
std::string rVersion = "ROOT6";
if (gROOT->GetVersionInt()<60000)
if (gROOT->GetVersionInt() < 60000)
rVersion = "ROOT5";

std::vector<string> ofileNames;
ofileNames.push_back(base+rVersion+".xml");
ofileNames.push_back(base+rVersion+".root");
ofileNames.push_back(base + rVersion + ".xml");
ofileNames.push_back(base + rVersion + ".root");

for (int iFile=0;iFile<ofileNames.size();++iFile){
for (int iFile = 0; iFile < ofileNames.size(); ++iFile) {

const char* ofileName = ofileNames[iFile].c_str();

Expand All @@ -27,36 +27,47 @@ void writecomplex(const std::string base){
TRandom3 rndm(1);

// Write nentries random complex per type
for (int j=0;j<nentries;++j){
std::complex<float> cFloatrw(rndm.Uniform(theMin,theMax),rndm.Uniform(theMin,theMax));
std::complex<double> cDoublerw(rndm.Uniform(theMin,theMax),rndm.Uniform(theMin,theMax));
for (int j = 0; j < nentries; ++j) {
// Since the order of execution of function arguments are not guarantees by the standard,
// don't pass TRandom3 methods as function arguments, to avoid potential cross-platform differences
auto rnd1 = rndm.Uniform(theMin, theMax);
auto rnd2 = rndm.Uniform(theMin, theMax);
auto rnd3 = rndm.Uniform(theMin, theMax);
auto rnd4 = rndm.Uniform(theMin, theMax);
std::complex<float> cFloatrw(rnd1, rnd2);
std::complex<double> cDoublerw(rnd3, rnd4);

ofile->WriteObjectAny(&cFloatrw,"complex<float>",TString::Format("cFloat_%i",j));
ofile->WriteObjectAny(&cDoublerw,"complex<double>",TString::Format("cDouble_%i",j));
ofile->WriteObjectAny(&cFloatrw, "complex<float>", TString::Format("cFloat_%i", j));
ofile->WriteObjectAny(&cDoublerw, "complex<double>", TString::Format("cDouble_%i", j));
}

if (iFile != 0) { // tree not supported on xml

// Now write a tree with nentries events with one branch per type, split and unsplit
std::complex<float>* cFloat = new std::complex<float>(0.f,0.f);
std::complex<double>* cDouble = new std::complex<double>(0.,0.);
TTree t("t","Test Tree");
t.Branch("cFloat_split", &cFloat,16000,99);
t.Branch("cFloat", &cFloat,16000,0);
t.Branch("cDouble_split", &cDouble,16000,99);
t.Branch("cDouble", &cDouble,16000,0);
for (int j=0;j<nentries;++j){
std::complex<float> cFloatVol(rndm.Uniform(theMin,theMax),rndm.Uniform(theMin,theMax));
std::complex<double> cDoubleVol(rndm.Uniform(theMin,theMax),rndm.Uniform(theMin,theMax));
*cFloat=cFloatVol;
*cDouble=cDoubleVol;
std::complex<float> *cFloat = new std::complex<float>(0.f, 0.f);
std::complex<double> *cDouble = new std::complex<double>(0., 0.);
TTree t("t", "Test Tree");
t.Branch("cFloat_split", &cFloat, 16000, 99);
t.Branch("cFloat", &cFloat, 16000, 0);
t.Branch("cDouble_split", &cDouble, 16000, 99);
t.Branch("cDouble", &cDouble, 16000, 0);
for (int j = 0; j < nentries; ++j) {
auto rnd11 = rndm.Uniform(theMin, theMax);
auto rnd12 = rndm.Uniform(theMin, theMax);
auto rnd13 = rndm.Uniform(theMin, theMax);
auto rnd14 = rndm.Uniform(theMin, theMax);
std::complex<float> cFloatVol(rnd11, rnd12);
std::complex<double> cDoubleVol(rnd13, rnd14);
*cFloat = cFloatVol;
*cDouble = cDoubleVol;
t.Fill();
}
t.Write();
}
}
}

void execwritecomplex(){
void execwritecomplex()
{
writecomplex("complexOfile");
}
2 changes: 1 addition & 1 deletion roottest/root/io/newstl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ endif()
ROOTTEST_ADD_TEST(ComplexTest
MACRO runComplexTest.C
ROOTEXE_OPTS ${_complextest_load}
OUTREF ComplexTest${ref_suffix}
OUTREF ComplexTest.ref
FIXTURES_REQUIRED root-io-newstl-ComplexTest_h-fixture)

ROOTTEST_ADD_TEST(SampleFile
Expand Down
5 changes: 0 additions & 5 deletions roottest/root/io/newstl/ComplexTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,4 @@ class Test: public TObject
ClassDefOverride(Test, 1);
};

#ifdef __ROOTCLING__
#pragma link C++ class std::complex<double>+;
#pragma link C++ class Test+;
#endif

#endif /* Test_hh */
Loading