Logo ROOT  
Reference Guide
TArrayD.h
Go to the documentation of this file.
1 // @(#)root/cont:$Id$
2 // Author: Rene Brun 06/03/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TArrayD
13 #define ROOT_TArrayD
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TArrayD //
19 // //
20 // Array of doubles (64 bits per element). //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TArray.h"
25 
26 
27 class TArrayD : public TArray {
28 
29 public:
30  Double_t *fArray; //[fN] Array of fN doubles
31 
32  TArrayD();
33  TArrayD(Int_t n);
34  TArrayD(Int_t n, const Double_t *array);
35  TArrayD(const TArrayD &array);
36  TArrayD &operator=(const TArrayD &rhs);
37  virtual ~TArrayD();
38 
39  void Adopt(Int_t n, Double_t *array);
40  void AddAt(Double_t c, Int_t i);
41  Double_t At(Int_t i) const ;
42  void Copy(TArrayD &array) const {array.Set(fN,fArray);}
43  const Double_t *GetArray() const { return fArray; }
44  Double_t *GetArray() { return fArray; }
45  Double_t GetAt(Int_t i) const { return At(i); }
46  Stat_t GetSum() const {Stat_t sum=0; for (Int_t i=0;i<fN;i++) sum+=fArray[i]; return sum;}
47  void Reset() {memset(fArray, 0, fN*sizeof(Double_t));}
48  void Reset(Double_t val) {for (Int_t i=0;i<fN;i++) fArray[i] = val;}
49  void Set(Int_t n);
50  void Set(Int_t n, const Double_t *array);
51  void SetAt(Double_t v, Int_t i) { AddAt(v, i); }
54 
55  ClassDef(TArrayD,1) //Array of doubles
56 };
57 
58 
59 #if defined R__TEMPLATE_OVERLOAD_BUG
60 template <>
61 #endif
62 inline TBuffer &operator>>(TBuffer &buf, TArrayD *&obj)
63 {
64  // Read TArrayD object from buffer.
65 
66  obj = (TArrayD *) TArray::ReadArray(buf, TArrayD::Class());
67  return buf;
68 }
69 
70 #if defined R__TEMPLATE_OVERLOAD_BUG
71 template <>
72 #endif
73 inline TBuffer &operator<<(TBuffer &buf, const TArrayD *obj)
74 {
75  // Write a TArrayD object into buffer
76  return buf << (const TArray*)obj;
77 }
78 
79 inline Double_t TArrayD::At(Int_t i) const
80 {
81  if (!BoundsOk("TArrayD::At", i)) return 0;
82  return fArray[i];
83 }
84 
86 {
87  if (!BoundsOk("TArrayD::operator[]", i))
88  i = 0;
89  return fArray[i];
90 }
91 
93 {
94  if (!BoundsOk("TArrayD::operator[]", i)) return 0;
95  return fArray[i];
96 }
97 
98 #endif
c
#define c(i)
Definition: RSha256.hxx:119
n
const Int_t n
Definition: legend1.C:16
TArrayD::GetSum
Stat_t GetSum() const
Definition: TArrayD.h:52
TArrayD::At
Double_t At(Int_t i) const
Definition: TArrayD.h:79
Int_t
int Int_t
Definition: RtypesCore.h:45
operator>>
TBuffer & operator>>(TBuffer &buf, TArrayD *&obj)
Definition: TArrayD.h:62
TArrayD::TArrayD
TArrayD()
Default TArrayD ctor.
Definition: TArrayD.cxx:26
TBuffer
Definition: TBuffer.h:43
TArray::fN
Int_t fN
Definition: TArray.h:38
v
@ v
Definition: rootcling_impl.cxx:3635
TArrayD::SetAt
void SetAt(Double_t v, Int_t i)
Definition: TArrayD.h:57
TArrayD::AddAt
void AddAt(Double_t c, Int_t i)
Set the double c value at position i in the array.
Definition: TArrayD.cxx:94
TArrayD::GetArray
const Double_t * GetArray() const
Definition: TArrayD.h:49
TArrayD::GetAt
Double_t GetAt(Int_t i) const
Definition: TArrayD.h:51
TArrayD::operator[]
Double_t & operator[](Int_t i)
Definition: TArrayD.h:85
TArrayD::Set
void Set(Int_t n)
Set size of this array to n doubles.
Definition: TArrayD.cxx:106
TArrayD::Copy
void Copy(TArrayD &array) const
Definition: TArrayD.h:48
TArrayD::~TArrayD
virtual ~TArrayD()
Delete TArrayD object.
Definition: TArrayD.cxx:71
TArrayD::Reset
void Reset()
Definition: TArrayD.h:53
TArrayD::fArray
Double_t * fArray
Definition: TArrayD.h:36
TArray::ReadArray
static TArray * ReadArray(TBuffer &b, const TClass *clReq)
Read TArray object from buffer.
Definition: TArray.cxx:41
sum
static long int sum(long int i)
Definition: Factory.cxx:2272
Double_t
double Double_t
Definition: RtypesCore.h:59
TArray
Definition: TArray.h:31
TArray::BoundsOk
Bool_t BoundsOk(const char *where, Int_t at) const
Definition: TArray.h:77
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TArray.h
TArrayD::Adopt
void Adopt(Int_t n, Double_t *array)
Adopt array arr into TArrayD, i.e.
Definition: TArrayD.cxx:81
Stat_t
double Stat_t
Definition: RtypesCore.h:77
TArrayD
Definition: TArrayD.h:27
Class
void Class()
Definition: Class.C:29
TArrayD::operator=
TArrayD & operator=(const TArrayD &rhs)
TArrayD assignment operator.
Definition: TArrayD.cxx:61
int
operator<<
TBuffer & operator<<(TBuffer &buf, const TArrayD *obj)
Definition: TArrayD.h:73