Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:56:49

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_TArrayF
0013 #define ROOT_TArrayF
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TArrayF                                                              //
0019 //                                                                      //
0020 // Array of floats (32 bits per element).                               //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TArray.h"
0025 
0026 
0027 class TArrayF : public TArray {
0028 
0029 public:
0030    Float_t    *fArray;       //[fN] Array of fN floats
0031 
0032    TArrayF();
0033    TArrayF(Int_t n);
0034    TArrayF(Int_t n, const Float_t *array);
0035    TArrayF(const TArrayF &array);
0036    TArrayF    &operator=(const TArrayF &rhs);
0037    virtual    ~TArrayF();
0038 
0039    void           Adopt(Int_t n, Float_t *array);
0040    void           AddAt(Float_t c, Int_t i);
0041    Float_t        At(Int_t i) const ;
0042    void           Copy(TArrayF &array) const {array.Set(fN,fArray);}
0043    const Float_t *GetArray() const { return fArray; }
0044    Float_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(Float_t));}
0048    void           Reset(Float_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 Float_t *array);
0051    void           SetAt(Double_t v, Int_t i) override { AddAt((Float_t)v, i); }
0052    Float_t       &operator[](Int_t i);
0053    Float_t        operator[](Int_t i) const;
0054 
0055    ClassDefOverride(TArrayF,1)  //Array of floats
0056 };
0057 
0058 #if defined R__TEMPLATE_OVERLOAD_BUG
0059 template <>
0060 #endif
0061 inline TBuffer &operator>>(TBuffer &buf, TArrayF *&obj)
0062 {
0063    // Read TArrayF object from buffer.
0064 
0065    obj = (TArrayF *) TArray::ReadArray(buf, TArrayF::Class());
0066    return buf;
0067 }
0068 
0069 #if defined R__TEMPLATE_OVERLOAD_BUG
0070 template <>
0071 #endif
0072 inline TBuffer &operator<<(TBuffer &buf, const TArrayF *obj)
0073 {
0074    // Write a TArrayF object into buffer
0075    return buf << (const TArray*)obj;
0076 }
0077 
0078 inline Float_t TArrayF::At(Int_t i) const
0079 {
0080    if (!BoundsOk("TArrayF::At", i)) return 0;
0081    return fArray[i];
0082 }
0083 
0084 inline Float_t &TArrayF::operator[](Int_t i)
0085 {
0086    if (!BoundsOk("TArrayF::operator[]", i))
0087       i = 0;
0088    return fArray[i];
0089 }
0090 
0091 inline Float_t TArrayF::operator[](Int_t i) const
0092 {
0093    if (!BoundsOk("TArrayF::operator[]", i)) return 0;
0094    return fArray[i];
0095 }
0096 
0097 #endif