source: XIOS/trunk/src/functor/accumulate.cpp @ 443

Last change on this file since 443 was 443, checked in by ymipsl, 11 years ago

Add new temporal operation : accumulate

YM

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1#include "accumulate.hpp"
2#include "array_new.hpp"
3
4namespace xios
5{
6   namespace func
7   {
8      /// ////////////////////// Définitions ////////////////////// ///
9
10      CAccumulate::CAccumulate(CArray<double,1>& doutput)
11         : SuperClass(StdString("average"), doutput)
12      { /* Ne rien faire de plus */ }
13
14      CAccumulate::~CAccumulate(void)
15      { /* Ne rien faire de plus */ }
16
17      //---------------------------------------------------------------
18
19      void CAccumulate::apply(const CArray<double,1>& _dinput,
20                                 CArray<double,1>& _doutput)
21      {
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 ;
32     
33      }
34     
35      void CAccumulate::final(void)
36      {
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;
43        this->nbcall = 0; 
44      }
45   } // namespace func
46} // namespace xmlioserver
Note: See TracBrowser for help on using the repository browser.