Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TArrayD.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/cont:$Id$
0002 // Author: Rene Brun   06/03/95
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TArrayD
0013 #define ROOT_TArrayD
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TArrayD                                                              //
0019 //                                                                      //
0020 // Array of doubles (64 bits per element).                              //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TArray.h"
0025 
0026 
0027 class TArrayD : public TArray {
0028 
0029 public:
0030    Double_t    *fArray;       //[fN] Array of fN doubles
0031 
0032    TArrayD();
0033    TArrayD(Int_t n);
0034    TArrayD(Int_t n, const Double_t *array);
0035    TArrayD(const TArrayD &array);
0036    TArrayD    &operator=(const TArrayD &rhs);
0037    virtual    ~TArrayD();
0038 
0039    void            Adopt(Int_t n, Double_t *array);
0040    void            AddAt(Double_t c, Int_t i);
0041    Double_t        At(Int_t i) const ;
0042    void            Copy(TArrayD &array) const {array.Set(fN,fArray);}
0043    const Double_t *GetArray() const { return fArray; }
0044    Double_t       *GetArray() { return fArray; }
0045    Double_t        GetAt(Int_t i) const override { return At(i); }
0046    Stat_t          GetSum() const {Stat_t sum=0; for (Int_t i=0;i<fN;i++) sum+=fArray[i]; return sum;}
0047    void            Reset()             {memset(fArray, 0, fN*sizeof(Double_t));}
0048    void            Reset(Double_t val) {for (Int_t i=0;i<fN;i++) fArray[i] = val;}
0049    void            Set(Int_t n) override;
0050    void            Set(Int_t n, const Double_t *array);
0051    void            SetAt(Double_t v, Int_t i) override { AddAt(v, i); }
0052    Double_t       &operator[](Int_t i);
0053    Double_t        operator[](Int_t i) const;
0054 
0055    ClassDefOverride(TArrayD,1)  //Array of doubles
0056 };
0057 
0058 
0059 #if defined R__TEMPLATE_OVERLOAD_BUG
0060 template <>
0061 #endif
0062 inline TBuffer &operator>>(TBuffer &buf, TArrayD *&obj)
0063 {
0064    // Read TArrayD object from buffer.
0065 
0066    obj = (TArrayD *) TArray::ReadArray(buf, TArrayD::Class());
0067    return buf;
0068 }
0069 
0070 #if defined R__TEMPLATE_OVERLOAD_BUG
0071 template <>
0072 #endif
0073 inline TBuffer &operator<<(TBuffer &buf, const TArrayD *obj)
0074 {
0075    // Write a TArrayD object into buffer
0076    return buf << (const TArray*)obj;
0077 }
0078 
0079 inline Double_t TArrayD::At(Int_t i) const
0080 {
0081    if (!BoundsOk("TArrayD::At", i)) return 0;
0082    return fArray[i];
0083 }
0084 
0085 inline Double_t &TArrayD::operator[](Int_t i)
0086 {
0087    if (!BoundsOk("TArrayD::operator[]", i))
0088       i = 0;
0089    return fArray[i];
0090 }
0091 
0092 inline Double_t TArrayD::operator[](Int_t i) const
0093 {
0094    if (!BoundsOk("TArrayD::operator[]", i)) return 0;
0095    return fArray[i];
0096 }
0097 
0098 #endif