Dear co-rooters,
I am facing this rather strange issue. When defining a sparse TMatrixF
and try to fill it using SetMatrixArray()
I get the following error (the full report is at the end of the post)
Fatal: row[irowmin] >= this->fRowLwb && row[irowmax] <= this->fRowLwb+this->fNrows-1 violated at line 1176 of `/builddir/build/BUILD/root-5.34.36/math/matrix/src/TMatrixTSparse.cxx'
aborting
Any idea on what might be the issue?
My code is as follows
#include <iostream>
#include <fstream>
#include <vector>
#include <iomanip>
#include "TROOT.h"
#include "TGraph.h"
#include "TH1.h"
#include "TMath.h"
#include "TMatrixF.h"
#include "TMatrixFSym.h"
#include "TMatrixFSparse.h"
#include "TMatrixTSym.h"
#include "TString.h"
#include "TRandom.h"
#include "covariance_lib.cc"
using namespace std;
int covariance_parasitic_factor(TString filename_EVAL, TString filename_FLUX, int E_MIN, int E_MAX, int N_BPDEC, float En_PAR, int energies_EXP){
// (1) Free-Up memory
gROOT->Reset();
// (2) Define the isolethargic binning - MeV
//int E_MAX = 0, E_MIN = -9, N_BPDEC = 1000;
int ndec = E_MAX - E_MIN;
int nbins = (int) ndec*N_BPDEC;
float step = (float) ndec / nbins;
float* En_USER = new float[nbins];
for(int i=0; i <= nbins; i++) {
En_USER[i] = (float) pow(10., step * (float) i + E_MIN);
}
// (3) Read the evaluation and interpolate
int nbins_EVAL = count_lines(filename_EVAL);
float* xs_USER = new float[nbins];
float* En_EVAL = new float[nbins_EVAL];
float* xs_EVAL = new float[nbins_EVAL];
int* idx = new int[nbins];
input_ascii(filename_EVAL, En_EVAL, xs_EVAL);
linear_interpolation(nbins, nbins_EVAL, En_USER, xs_USER, En_EVAL, xs_EVAL, idx);
// () Find the index of the Parasitic Energy (Energy in MeV)
int idx_PAR;
for (int i=0; i<nbins; ++i){
if (En_USER[i]<En_PAR && En_PAR<En_USER[i+1]) idx_PAR = i;
}
delete[] En_EVAL;
delete[] En_USER;
delete[] xs_EVAL;
delete[] idx;
// () Read the flux file - Flux:Relative Uncertainty
int nbins_FLUX = count_lines(filename_FLUX);
float* flux = new float[nbins_FLUX];
float* relative_Uncert_FLUX = new float[nbins_FLUX];
float* absolute_Uncert_FLUX = new float[nbins_FLUX];
input_ascii(filename_FLUX, flux, relative_Uncert_FLUX);
// () Calculate the Absolute Uncertainty in the flux
for (int i=0; i<nbins_FLUX; ++i){
if (flux[i] == 0.) absolute_Uncert_FLUX[i] = 0.;
else absolute_Uncert_FLUX[i] = relative_Uncert_FLUX [i]*flux[i];
}
delete[] relative_Uncert_FLUX;
// () Calculate the parameter A = Sum_Epar/(Sum_total)^2 Flux*XS
float* A = new float[energies_EXP];
float sum_PAR = 0.;
float sum_TOT = 0.;
for (int j=0; j<energies_EXP; ++j){
for (int i=0; i<nbins; ++i){
if (i<=idx_PAR) sum_PAR += xs_USER[i] * flux[j*nbins+i];
sum_TOT += xs_USER[i] * flux[j*nbins+i];
}
A[j] = sum_PAR/pow(sum_TOT, 2);
}
// () Calculate the non-zero values of the sensitivity matrix
// () Calculate the non-zero values of the sensitivity matrix
TMatrixFSparse G(5,5);
//TMatrixF B(5,2);
int col[3] = {1, 1, 2};
int row[3] = {2, 5, 2};
float data[3] = {10., 5., 1.2};
//G.Use(1, 1, 1, 3, a);
//G.Print();
G.SetMatrixArray(3, row, col, data);
G.Print();
// () Define TMatrices
//TMatrixFSym COV_Parasitic(energies_EXP);
//TMatrixFSym COV_FLUX(energies_EXP*nbins);
return 0;
}
The two input files that will be used can be found here
https://cernbox.cern.ch/index.php/s/xtKIUHx3dEEa7L8
https://cernbox.cern.ch/index.php/s/453g4MOrHUudT8l
The function can be run as
covariance_parasitic_factor("ENDF_B-VII_1.dat", "flux_Lif.dat", -9, 0, 1000, 4.3853e-1, 3)
The full error report, follows up next
root [5] covariance_parasitic_factor("ENDF_B-VII_1.dat", "flux_Lif.dat", -9, 0, 1000, 4.3853e-1, 3)
Fatal: row[irowmin] >= this->fRowLwb && row[irowmax] <= this->fRowLwb+this->fNrows-1 violated at line 1176 of `/builddir/build/BUILD/root-5.34.36/math/matrix/src/TMatrixTSparse.cxx'
aborting
#0 0x00007f9c555e482e in waitpid () from /lib64/libc.so.6
#1 0x00007f9c55576479 in do_system () from /lib64/libc.so.6
#2 0x00007f9c56287b04 in TUnixSystem::StackTrace() () from /usr/lib64/root/libCore.so.5.34
#3 0x00007f9c561c4af4 in DefaultErrorHandler(int, bool, char const*, char const*) () from /usr/lib64/root/libCore.so.5.34
#4 0x00007f9c561c41ff in ErrorHandler () from /usr/lib64/root/libCore.so.5.34
#5 0x00007f9c561c4313 in Fatal(char const*, char const*, ...) () from /usr/lib64/root/libCore.so.5.34
#6 0x00007f9c51903264 in TMatrixTSparse<float>::SetMatrixArray(int, int*, int*, float*) () from /usr/lib64/root/libMatrix.so
#7 0x00007f9c4deca6f5 in covariance_parasitic_factor (filename_EVAL=<incomplete type>, filename_FLUX=<incomplete type>, E_MIN=<value optimized out>, E_MAX=<value optimized out>, N_BPDEC=<value optimized out>, En_PAR=1.77041079e-37, energies_EXP=3) at /eos/user/a/astamato/covariance/code/./covariance_parasitic_factor.C:83
#8 0x00007f9c4decab55 in G__covariance_parasitic_factor_C_ACLiC_dict__0_2358 (result7=0x7fffce414880, funcname=<value optimized out>, libp=<value optimized out>, hash=<value optimized out>) at /eos/user/a/astamato/covariance/code/covariance_parasitic_factor_C_ACLiC_dict.cxx:86
#9 0x00007f9c54c05ba9 in Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) () from /usr/lib64/root/libCint.so.5.34
#10 0x00007f9c54caded1 in G__execute_call () from /usr/lib64/root/libCint.so.5.34
#11 0x00007f9c54caed22 in G__call_cppfunc () from /usr/lib64/root/libCint.so.5.34
#12 0x00007f9c54c8da05 in G__interpret_func () from /usr/lib64/root/libCint.so.5.34
#13 0x00007f9c54c7c918 in G__getfunction () from /usr/lib64/root/libCint.so.5.34
#14 0x00007f9c54c5b12e in G__getitem () from /usr/lib64/root/libCint.so.5.34
#15 0x00007f9c54c5fcb8 in G__getexpr () from /usr/lib64/root/libCint.so.5.34
#16 0x00007f9c54cdabe7 in G__exec_statement () from /usr/lib64/root/libCint.so.5.34
#17 0x00007f9c54c472d1 in ?? () from /usr/lib64/root/libCint.so.5.34
#18 0x00007f9c54c475de in G__exec_tempfile_fp () from /usr/lib64/root/libCint.so.5.34
#19 0x00007f9c54ce6645 in G__process_cmd () from /usr/lib64/root/libCint.so.5.34
#20 0x00007f9c56247c46 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /usr/lib64/root/libCore.so.5.34
#21 0x00007f9c561ab0e0 in TApplication::ProcessLine(char const*, bool, int*) () from /usr/lib64/root/libCore.so.5.34
#22 0x00007f9c55dfa05b in TRint::HandleTermInput() () from /usr/lib64/root/libRint.so.5.34
#23 0x00007f9c56284f8e in TUnixSystem::CheckDescriptors() () from /usr/lib64/root/libCore.so.5.34
#24 0x00007f9c56285273 in TUnixSystem::DispatchOneEvent(bool) () from /usr/lib64/root/libCore.so.5.34
#25 0x00007f9c56205bd6 in TSystem::InnerLoop() () from /usr/lib64/root/libCore.so.5.34
#26 0x00007f9c5620770b in TSystem::Run() () from /usr/lib64/root/libCore.so.5.34
#27 0x00007f9c561a82df in TApplication::Run(bool) () from /usr/lib64/root/libCore.so.5.34
#28 0x00007f9c55dfb5b4 in TRint::Run(bool) () from /usr/lib64/root/libRint.so.5.34
#29 0x000000000040103c in main ()