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   	#ifndef ROOT_TArray
25   	#include "TArray.h"
26   	#endif
27   	
28   	
29   	class TArrayD : public TArray {
30   	
31   	public:
32   	   Double_t    *fArray;       //[fN] Array of fN doubles
33   	
34   	   TArrayD();
35   	   TArrayD(Int_t n);
36   	   TArrayD(Int_t n, const Double_t *array);
37   	   TArrayD(const TArrayD &array);
38   	   TArrayD    &operator=(const TArrayD &rhs);
39   	   virtual    ~TArrayD();
40   	
41   	   void            Adopt(Int_t n, Double_t *array);
42   	   void            AddAt(Double_t c, Int_t i);
43   	   Double_t        At(Int_t i) const ;
44   	   void            Copy(TArrayD &array) const {array.Set(fN,fArray);}
45   	   const Double_t *GetArray() const { return fArray; }
46   	   Double_t       *GetArray() { return fArray; }
47   	   Double_t        GetAt(Int_t i) const { return At(i); }
48   	   Stat_t          GetSum() const {Stat_t sum=0; for (Int_t i=0;i<fN;i++) sum+=fArray[i]; return sum;}
49   	   void            Reset()             {memset(fArray, 0, fN*sizeof(Double_t));}
50   	   void            Reset(Double_t val) {for (Int_t i=0;i<fN;i++) fArray[i] = val;}
51   	   void            Set(Int_t n);
52   	   void            Set(Int_t n, const Double_t *array);
53   	   void            SetAt(Double_t v, Int_t i) { AddAt(v, i); }
54   	   Double_t       &operator[](Int_t i);
55   	   Double_t        operator[](Int_t i) const;
56   	
57   	   ClassDef(TArrayD,1)  //Array of doubles
58   	};
59   	
60   	
61   	#if defined R__TEMPLATE_OVERLOAD_BUG
62   	template <>
63   	#endif
64   	inline TBuffer &operator>>(TBuffer &buf, TArrayD *&obj)
65   	{
66   	   // Read TArrayD object from buffer.
67   	
68   	   obj = (TArrayD *) TArray::ReadArray(buf, TArrayD::Class());
69   	   return buf;
70   	}
71   	
72   	#if defined R__TEMPLATE_OVERLOAD_BUG
73   	template <>
74   	#endif
75   	inline TBuffer &operator<<(TBuffer &buf, const TArrayD *obj)
76   	{
77   	   // Write a TArrayD object into buffer
78   	   return buf << (const TArray*)obj;
79   	}
80   	
81   	inline Double_t TArrayD::At(Int_t i) const
82   	{
83   	   if (!BoundsOk("TArrayD::At", i)) return 0;
84   	   return fArray[i];
85   	}
86   	
87   	inline Double_t &TArrayD::operator[](Int_t i)
88   	{
89   	   if (!BoundsOk("TArrayD::operator[]", i))
90   	      i = 0;
91   	   return fArray[i];
92   	}
93   	
94   	inline Double_t TArrayD::operator[](Int_t i) const
95   	{
96   	   if (!BoundsOk("TArrayD::operator[]", i)) return 0;
97   	   return fArray[i];
98   	}
99   	
100  	#endif
101