BOSS 8.0.0
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 ) : _nElem( n ), _pointer( new DifNumber[n] ) {
30 zero( npar );
31}
32
33DifArray::DifArray( const HepVector& a, int npar )
34 : _nElem( a.num_row() ), _pointer( new DifNumber[nElem()] ) {
35 copy( a, npar );
36}
37
39 : _nElem( a.nElem() ), _pointer( new DifNumber[nElem()] ) {
40 copy( a );
41}
42
43DifArray::~DifArray() { delete[] _pointer; }
44
46 assert( i >= 0 );
47 assert( i < nElem() );
48 return _pointer[i];
49}
50
52 i = i - 1;
53 assert( i >= 0 );
54 assert( i < nElem() );
55 return _pointer[i];
56}
57
58DifNumber DifArray::fetch( int i ) const {
59 i = i - 1;
60 assert( i >= 0 );
61 assert( i < nElem() );
62 return _pointer[i];
63}
64
66 copy( rhs );
67 return *this;
68}
69
70HepMatrix DifArray::jacobian() const {
71 int npar = _pointer[0].nPar();
72 HepMatrix temp( nElem(), npar, 0 );
73 for ( int i = 1; i <= nElem(); i++ )
74 {
75 for ( int j = 1; j <= npar; j++ ) { temp( i, j ) = _pointer[i - 1].derivative( j ); }
76 } //(int i=1; i<=nElem(); i++)
77 return temp;
78}
79
80void DifArray::copy( const HepVector& a, int npar ) {
81 assert( nElem() == a.num_row() );
82 for ( int i = 0; i < nElem(); i++ )
83 {
84 _pointer[i].setNumber( a( i + 1 ) );
85 _pointer[i].setNPar( npar );
86 }
87}
88
89void DifArray::copy( const DifArray& a ) {
90 assert( nElem() == a.nElem() );
91 for ( int i = 0; i < nElem(); i++ ) { _pointer[i] = a._pointer[i]; }
92}
93
94void DifArray::zero( int npar ) {
95 for ( int i = 0; i < nElem(); i++ )
96 {
97 _pointer[i] = 0.0;
98 _pointer[i].setNPar( npar );
99 }
100}
101
102void DifArray::print( /*ostream& o*/ ) const {
103 cout << "nElem=" << nElem() << endl;
104 for ( int i = 1; i <= nElem(); i++ )
105 {
106 // SKIP cout << "element(" << i << ")=" << _pointer[i-1];
107 }
108}
const Int_t n
const DifNumber zero
DifArray & operator=(const DifArray &)
Definition DifArray.cxx:65
void print() const
Definition DifArray.cxx:102
DifArray(int n, int npar=0)
Definition DifArray.cxx:29
void zero(int npar=0)
Definition DifArray.cxx:94
DifNumber & operator[](int i)
Definition DifArray.cxx:45
DifNumber fetch(int i) const
Definition DifArray.cxx:58
HepMatrix jacobian() const
Definition DifArray.cxx:70
DifNumber & operator()(int i)
Definition DifArray.cxx:51