10 #ifndef ROOT_Minuit2_MnUserCovariance
11 #define ROOT_Minuit2_MnUserCovariance
27 class MnUserCovariance {
31 MnUserCovariance() : fData(std::vector<double>()), fNRow(0) {}
34 MnUserCovariance(
const std::vector<double>& data,
unsigned int nrow) :
35 fData(data), fNRow(nrow) {
36 assert(data.size() == nrow*(nrow+1)/2);
40 MnUserCovariance(
const double * data,
unsigned int nrow) :
41 fData(std::vector<double>(data,data+nrow*(nrow+1)/2)),
45 MnUserCovariance(
unsigned int n) :
46 fData(std::vector<double>(n*(n+1)/2, 0.)), fNRow(n) {}
48 ~MnUserCovariance() {}
50 MnUserCovariance(
const MnUserCovariance& cov) : fData(cov.fData), fNRow(cov.fNRow) {}
52 MnUserCovariance& operator=(
const MnUserCovariance& cov) {
60 double operator()(
unsigned int row,
unsigned int col)
const {
61 assert(row < fNRow && col < fNRow);
63 return fData[col+row*(row+1)/2];
65 return fData[row+col*(col+1)/2];
68 double& operator()(
unsigned int row,
unsigned int col) {
69 assert(row < fNRow && col < fNRow);
71 return fData[col+row*(row+1)/2];
73 return fData[row+col*(col+1)/2];
76 void Scale(
double f) {
77 for(
unsigned int i = 0; i < fData.size(); i++) fData[i] *= f;
80 const std::vector<double>& Data()
const {
return fData;}
82 unsigned int Nrow()
const {
return fNRow;}
85 unsigned int size()
const
86 {
return static_cast <
unsigned int > ( fData.size() );
91 std::vector<double> fData;
99 #endif // ROOT_Minuit2_MnUserCovariance