BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
DifArray.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: DifArray.cxx,v 1.3 2009/12/23 02:59:56 zhangy Exp $
4//
5// Description:
6// Class Implementation for |DifArray|
7// What do i do ?
8// Environment:
9// Software developed for the BaBar Detector at the SLAC B-Factory.
10//
11// Author List:
12// A. Snyder
13//
14// Copyright Information:
15// Copyright (C) 1996 SLAC
16//
17// History:
18// Migration for BESIII MDC
19//
20//------------------------------------------------------------------------
21
22#include "MdcRecoUtil/DifArray.h"
23#include "MdcRecoUtil/DifNumber.h"
24#include <iostream>
25using std::endl;
26//CHAGNE using std::ostream;
27using std::cout;
28
29DifArray::DifArray(int n,int npar):
30 _nElem(n),
31 _pointer(new DifNumber[n])
32{zero(npar);}
33
34DifArray::DifArray(const HepVector & a,int npar):
35 _nElem(a.num_row()),
36 _pointer(new DifNumber[nElem()])
37{copy(a,npar);}
38
39
41 _nElem(a.nElem()),
42 _pointer(new DifNumber[nElem()])
43{copy(a);}
44
45DifArray::~DifArray() {delete[] _pointer;}
46
48 assert(i>=0);
49 assert(i<nElem());
50 return _pointer[i];
51}
52
54 i=i-1;
55 assert(i>=0);
56 assert(i<nElem());
57 return _pointer[i];
58}
59
61 i=i-1;
62 assert(i>=0);
63 assert(i<nElem());
64 return _pointer[i];
65}
66
68 copy(rhs);
69 return *this;
70}
71
72HepMatrix DifArray::jacobian()const {
73 int npar=_pointer[0].nPar();
74 HepMatrix temp(nElem(),npar,0);
75 for(int i=1; i<=nElem(); i++){
76 for(int j=1; j<=npar; j++) {
77 temp(i,j)=_pointer[i-1].derivative(j);
78 }
79 } //(int i=1; i<=nElem(); i++)
80 return temp;
81}
82
83void DifArray::copy(const HepVector& a,int npar){
84 assert(nElem()==a.num_row());
85 for(int i=0; i<nElem(); i++)
86 {
87 _pointer[i].setNumber(a(i+1));
88 _pointer[i].setNPar(npar);
89 }
90}
91
92void DifArray::copy(const DifArray& a){
93 assert(nElem()==a.nElem());
94 for(int i=0; i<nElem(); i++) {_pointer[i]=a._pointer[i];}
95}
96
97void DifArray::zero(int npar){
98 for(int i=0; i<nElem(); i++) {
99 _pointer[i]=0.0;
100 _pointer[i].setNPar(npar);
101 }
102}
103
104void DifArray::print(/*ostream& o*/)const{
105 cout << "nElem=" << nElem() << endl;
106 for(int i=1; i<=nElem(); i++){
107 //SKIP cout << "element(" << i << ")=" << _pointer[i-1];
108 }
109
110}
const Int_t n
const DifNumber zero
DifArray & operator=(const DifArray &)
Definition: DifArray.cxx:67
void print() const
Definition: DifArray.cxx:104
~DifArray()
Definition: DifArray.cxx:45
DifArray(int n, int npar=0)
Definition: DifArray.cxx:29
void zero(int npar=0)
Definition: DifArray.cxx:97
DifNumber & operator[](int i)
Definition: DifArray.cxx:47
DifNumber fetch(int i) const
Definition: DifArray.cxx:60
HepMatrix jacobian() const
Definition: DifArray.cxx:72
DifNumber & operator()(int i)
Definition: DifArray.cxx:53