Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
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
17namespace ROOT {
18
19namespace 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
28public:
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
89private:
90 std::vector<double> fData;
91 unsigned int fNRow;
92};
93
94} // namespace Minuit2
95
96} // namespace ROOT
97
98#endif // ROOT_Minuit2_MnUserCovariance
#define f(i)
Definition RSha256.hxx:104
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Class containing the covariance matrix data represented as a vector of size n*(n+1)/2 Used to hide in...
const std::vector< double > & Data() const
double & operator()(unsigned int row, unsigned int col)
MnUserCovariance(const MnUserCovariance &cov)
MnUserCovariance(const double *data, unsigned int nrow)
double operator()(unsigned int row, unsigned int col) const
MnUserCovariance & operator=(const MnUserCovariance &cov)
MnUserCovariance(const std::vector< double > &data, unsigned int nrow)
const Int_t n
Definition legend1.C:16
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.