Changeset 470 for XIOS/trunk/src/functor/average.cpp
- Timestamp:
- 01/30/14 15:55:42 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/functor/average.cpp
r380 r470 12 12 { /* Ne rien faire de plus */ } 13 13 14 CAverage::CAverage(CArray<double,1>& doutput, double missingValue) 15 : SuperClass(StdString("average"), doutput, missingValue) 16 { /* Ne rien faire de plus */ } 17 14 18 CAverage::~CAverage(void) 15 19 { /* Ne rien faire de plus */ } … … 20 24 CArray<double,1>& _doutput) 21 25 { 22 /* 23 const double * it1 = _dinput->data(), 24 * end1 = _dinput->data() + _dinput->num_elements(); 25 double * it = _doutput->data(); 26 if (this->nbcall == 1) 27 for (; it1 != end1; it1++, it++) *it = *it1; 28 else for (; it1 != end1; it1++, it++) *it += *it1; 29 */ 30 if (this->nbcall == 1) _doutput=_dinput ; 31 else _doutput+=_dinput ; 26 if (hasMissingValue) 27 { 28 if (nbcalls.numElements()==0) 29 { 30 nbcalls.resize(_dinput.numElements()) ; 31 nbcalls=0 ; 32 } 33 } 34 35 if (this->nbcall == 1) 36 { 37 _doutput=_dinput ; 38 if (hasMissingValue) 39 { 40 int i, n =_dinput.numElements() ; 41 const double * in=_dinput.dataFirst() ; 42 int* nc=nbcalls.dataFirst() ; 43 for (i=0; i<n; ++i,++nc) 44 if (*in!=missingValue) (*nc) ++; 45 } 46 } 47 else 48 { 49 if (hasMissingValue) 50 { 51 int i, n =_dinput.numElements() ; 52 const double * in=_dinput.dataFirst() ; 53 double* out=_doutput.dataFirst(); 54 int* nc=nbcalls.dataFirst() ; 55 for (i=0; i<n; ++i,++in,++out,++nc) 56 if (*in!=missingValue) 57 { 58 if (*nc != 0) (*out) += *in; 59 else *out = *in ; 60 (*nc) ++; 61 } 62 } 63 else _doutput+=_dinput ; 64 } 32 65 33 66 } … … 35 68 void CAverage::final(void) 36 69 { 37 /* double * it1 = this->getDataOutput()->data(), 38 * end1 = this->getDataOutput()->data() + this->getDataOutput()->num_elements(); 39 for (; it1 != end1; it1++) *it1 /= this->nbcall; 40 this->nbcall = 0; 41 */ 42 doutput/=this->nbcall; 70 if (hasMissingValue) 71 { 72 int i, n = nbcalls.numElements() ; 73 double* out= doutput.dataFirst(); 74 int* nc=nbcalls.dataFirst() ; 75 for (i=0; i<n; ++i, ++out,++nc) 76 if (*nc!=0) 77 { 78 *out /= *nc; 79 *nc = 0 ; 80 } 81 82 } 83 else doutput/=this->nbcall; 43 84 this->nbcall = 0; 85 44 86 } 45 87 } // namespace func
Note: See TracChangeset
for help on using the changeset viewer.