#ifndef MARS_MArrayF #define MARS_MArrayF #ifndef MARS_MArray #include "MArray.h" #endif #include class TArrayF; class MArrayF : public MArray { private: Float_t *fArray; //[fN] Array of fN chars public: MArrayF() { fN = 0; fArray = NULL; } MArrayF(UInt_t n) { fN = 0; fArray = NULL; Set(n); } MArrayF(UInt_t n, Float_t *array) { // Create TArrayC object and initialize it with values of array. fN = 0; fArray = NULL; Set(n, array); } MArrayF(const MArrayF &array) : MArray() { // Copy constructor. fArray = NULL; Set(array.fN, array.fArray); } MArrayF &operator=(const MArrayF &rhs) { // TArrayC assignment operator. if (this != &rhs) Set(rhs.fN, rhs.fArray); return *this; } virtual ~MArrayF() { // Delete TArrayC object. delete [] fArray; fArray = NULL; } void Adopt(UInt_t n, Float_t *array) { // Adopt array arr into TArrayC, i.e. don't copy arr but use it directly // in TArrayC. User may not delete arr, TArrayC dtor will do it. if (fArray) delete [] fArray; fN = n; fArray = array; } void AddAt(Float_t c, UInt_t i) { // Add char c at position i. Check for out of bounds. fArray[i] = c; } Float_t At(UInt_t i) const { return fArray[i]; } Float_t *GetArray() const { return fArray; } void Reset() { memset(fArray, 0, fN*sizeof(Float_t)); } void Reset(Float_t v) { for (Float_t *f=fArray; f void Add(T *src, Int_t n, Int_t p=0, Float_t m=1.) { // under these 3 conditions, we return immediately, because they either make no sense, // or result in an invariant array. if (p >= fN) { // maybe throw a warning, because p >= fN makes no sense at all return; } if ( n <= 0) { return; } if (m == 0.) { return; } if (src == NULL) { return; } Float_t *dest = fArray + p; Float_t *end = dest; if (n < fN-p) { end += n; } else { end += fN-p; } // we treat the case m==1. special, in order to speed up the code a bit // since when m==1. the multiplication can be omitted and this should be a bit faster then. if (m == 1.) { while (dest void AddClipped(Double_t th, T src, Int_t n, Int_t p=0) { Float_t *dest = fArray + p; Float_t *end = dest + n; while (dest