Logo ROOT  
Reference Guide
MnUserCovariance.h
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
2 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7  * *
8  **********************************************************************/
9 
10 #ifndef ROOT_Minuit2_MnUserCovariance
11 #define ROOT_Minuit2_MnUserCovariance
12 
13 #include "Minuit2/MnConfig.h"
14 #include <vector>
15 #include <cassert>
16 
17 namespace ROOT {
18 
19 namespace Minuit2 {
20 
21 /**
22  Class containing the covariance matrix data represented as a vector of
23  size n*(n+1)/2
24  Used to hide internal matrix representation to user
25  */
27 
28 public:
29  MnUserCovariance() : fData(std::vector<double>()), fNRow(0) {}
30 
31  // safe constructor using std::vector
32  MnUserCovariance(const std::vector<double> &data, unsigned int nrow) : fData(data), fNRow(nrow)
33  {
34  assert(data.size() == nrow * (nrow + 1) / 2);
35  }
36 
37  // unsafe constructor using just a pointer
38  MnUserCovariance(const double *data, unsigned int nrow)
39  : fData(std::vector<double>(data, data + nrow * (nrow + 1) / 2)), fNRow(nrow)
40  {
41  }
42 
43  MnUserCovariance(unsigned int n) : fData(std::vector<double>(n * (n + 1) / 2, 0.)), fNRow(n) {}
44 
46 
48 
50  {
51  if (this != &cov) {
52  fData = cov.fData;
53  fNRow = cov.fNRow;
54  }
55  return *this;
56  }
57 
58  double operator()(unsigned int row, unsigned int col) const
59  {
60  assert(row < fNRow && col < fNRow);
61  if (row > col)
62  return fData[col + row * (row + 1) / 2];
63  else
64  return fData[row + col * (col + 1) / 2];
65  }
66 
67  double &operator()(unsigned int row, unsigned int col)
68  {
69  assert(row < fNRow && col < fNRow);
70  if (row > col)
71  return fData[col + row * (row + 1) / 2];
72  else
73  return fData[row + col * (col + 1) / 2];
74  }
75 
76  void Scale(double f)
77  {
78  for (unsigned int i = 0; i < fData.size(); i++)
79  fData[i] *= f;
80  }
81 
82  const std::vector<double> &Data() const { return fData; }
83 
84  unsigned int Nrow() const { return fNRow; }
85 
86  // VC 7.1 warning: conversion from size_t to unsigned int
87  unsigned int size() const { return static_cast<unsigned int>(fData.size()); }
88 
89 private:
90  std::vector<double> fData;
91  unsigned int fNRow;
92 };
93 
94 } // namespace Minuit2
95 
96 } // namespace ROOT
97 
98 #endif // ROOT_Minuit2_MnUserCovariance
n
const Int_t n
Definition: legend1.C:16
f
#define f(i)
Definition: RSha256.hxx:104
ROOT::Minuit2::MnUserCovariance::Data
const std::vector< double > & Data() const
Definition: MnUserCovariance.h:82
ROOT::Minuit2::MnUserCovariance::operator=
MnUserCovariance & operator=(const MnUserCovariance &cov)
Definition: MnUserCovariance.h:49
ROOT::Minuit2::MnUserCovariance::MnUserCovariance
MnUserCovariance()
Definition: MnUserCovariance.h:29
ROOT::Minuit2::MnUserCovariance::MnUserCovariance
MnUserCovariance(const MnUserCovariance &cov)
Definition: MnUserCovariance.h:47
ROOT::Minuit2::MnUserCovariance
Class containing the covariance matrix data represented as a vector of size n*(n+1)/2 Used to hide in...
Definition: MnUserCovariance.h:26
ROOT::Minuit2::MnUserCovariance::Nrow
unsigned int Nrow() const
Definition: MnUserCovariance.h:84
ROOT::Minuit2::MnUserCovariance::fNRow
unsigned int fNRow
Definition: MnUserCovariance.h:91
ROOT::Minuit2::MnUserCovariance::MnUserCovariance
MnUserCovariance(const std::vector< double > &data, unsigned int nrow)
Definition: MnUserCovariance.h:32
ROOT::Minuit2::MnUserCovariance::operator()
double operator()(unsigned int row, unsigned int col) const
Definition: MnUserCovariance.h:58
ROOT::Minuit2::MnUserCovariance::MnUserCovariance
MnUserCovariance(const double *data, unsigned int nrow)
Definition: MnUserCovariance.h:38
double
double
Definition: Converters.cxx:939
ROOT::Minuit2::MnUserCovariance::size
unsigned int size() const
Definition: MnUserCovariance.h:87
ROOT::Minuit2::MnUserCovariance::MnUserCovariance
MnUserCovariance(unsigned int n)
Definition: MnUserCovariance.h:43
ROOT::Minuit2::MnUserCovariance::Scale
void Scale(double f)
Definition: MnUserCovariance.h:76
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: EExecutionPolicy.hxx:4
ROOT::Minuit2::MnUserCovariance::fData
std::vector< double > fData
Definition: MnUserCovariance.h:90
ROOT::Minuit2::MnUserCovariance::~MnUserCovariance
~MnUserCovariance()
Definition: MnUserCovariance.h:45
MnConfig.h
ROOT::Minuit2::MnUserCovariance::operator()
double & operator()(unsigned int row, unsigned int col)
Definition: MnUserCovariance.h:67