My ROOT version is 6.30/04. I am running OSX 14.4.1 with XCode 15.3 on an M1 driven MacBook Pro.
I found that if you provide the TPrincipal class with too many entries, it fails. Here is my test code.
#include <stdio.h>
void test_tprinc(Long_t num)
{
TRandom r;
TPrincipal covar(3);
Double_t triplet[3];
Long_t i;
for (i=0; i<num; i++) {
triplet[0]=r.Gaus(0.,1.);
triplet[1]=4*triplet[0]+r.Gaus(0.,1.);
triplet[2]=-3*triplet[1]+r.Gaus(0.,1.);
covar.AddRow(triplet);
}
TMatrixD Mcovar = TMatrixD(3,3);;
Mcovar = * covar.GetCovarianceMatrix();
cout << "Covariance Matrix" << endl;
cout << setw(12) << Mcovar(0,0) << setw(12) << Mcovar(0,1) << setw(12) << Mcovar(0,2) << endl;
cout << setw(12) << Mcovar(1,0) << setw(12) << Mcovar(1,1) << setw(12) << Mcovar(1,2) << endl;
cout << setw(12) << Mcovar(2,0) << setw(12) << Mcovar(2,1) << setw(12) << Mcovar(2,2) << endl;
}
And here is the output for various values of the argument “num” which determines the number of entries.
root [0] .L tprinc_test.cpp
root [1] test_tprinc(100)
Covariance Matrix
0.925195 0 0
3.6724 15.327 0
-10.9756 -45.7341 137.481
root [2] test_tprinc(100000)
Covariance Matrix
0.998668 0 0
3.99162 16.9557 0
-11.9761 -50.8703 153.622
root [3] test_tprinc(100000000)
Covariance Matrix
0.99999 0 0
3.99987 16.999 0
-11.9997 -50.9972 153.993
root [4] test_tprinc(10000000000)
Error in <TVectorT<double>::Allocate>: nrows=-1382938632
*** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libHist.so] TPrincipal::AddRow(double const*) (no debug info)
[<unknown binary>] (no debug info)
[<unknown binary>] (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libCling.so] cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libCling.so] cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libCling.so] cling::Interpreter::EvaluateInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libCling.so] cling::Interpreter::process(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, cling::Value*, cling::Transaction**, bool) (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libCling.so] cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libCling.so] HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libCling.so] TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libRint.so] TRint::ProcessLineNr(char const*, char const*, int*) (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libRint.so] TRint::HandleTermInput() (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libCore.so] TUnixSystem::CheckDescriptors() (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libCore.so] TMacOSXSystem::DispatchOneEvent(bool) (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libCore.so] TSystem::InnerLoop() (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libCore.so] TSystem::Run() (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libCore.so] TApplication::Run(bool) (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/lib/root/libRint.so] TRint::Run(bool) (no debug info)
[/opt/homebrew/Cellar/root/6.30.04/bin/root.exe] main (no debug info)
[/usr/lib/dyld] start (no debug info)
Root >
Evidently the number of rows is stored in a 32-bit integer. Or something similar to that.
[I would also remark that only the lower diagonal of the covariance matrix is computed by the class. This is not a “bug” (the matrix is symmetric) but probably a “user interface flaw”. If the user doesn’t know this detail, it will generate troubles.]