Changeset 17682 for trunk/Mars/mbase
- Timestamp:
- 04/23/14 13:53:35 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mbase/MArrayF.h
r9211 r17682 170 170 171 171 template<class T> 172 void Add(T *src, Int_t n, Int_t p=0) 172 void Add(T *src, Int_t n, Int_t p=0, Float_t m=1.) 173 { 174 // under these 3 conditions, we return immediately, because they either make no sense, 175 // or result in an invariant array. 176 if (p >= fN) 177 { 178 // maybe throw a warning, because p >= fN makes no sense at all 179 return; 180 } 181 if ( n <= 0) 182 { 183 return; 184 } 185 if (m == 0.) 186 { 187 return; 188 } 189 if (src == NULL) 190 { 191 return; 192 } 193 194 Float_t *dest = fArray + p; 195 Float_t *end = dest; 196 if (n < fN-p) 197 { 198 end += n; 199 } 200 else 201 { 202 end += fN-p; 203 } 204 205 // we treat the case m==1. special, in order to speed up the code a bit 206 // since when m==1. the multiplication can be omitted and this should be a bit faster then. 207 if (m == 1.) 208 { 209 while (dest<end) 210 *dest++ += *src++; 211 } 212 else 213 { 214 while (dest<end) 215 *dest++ += (*src++) * m; 216 } 217 } 218 219 template<class T> 220 void AddClipped(Double_t th, T src, Int_t n, Int_t p=0) 173 221 { 174 222 Float_t *dest = fArray + p; … … 176 224 177 225 while (dest<end) 178 *dest++ += *src++;179 }180 181 template<class T>182 void AddClipped(Double_t th, T src, Int_t n, Int_t p=0)183 {184 Float_t *dest = fArray + p;185 Float_t *end = dest + n;186 187 while (dest<end)188 226 *dest++ += TMath::Min(*src++, th); 189 227 }
Note:
See TracChangeset
for help on using the changeset viewer.