source: XIOS/dev/branch_yushan/src/transformation/Functions/min_reduction.cpp @ 1037

Last change on this file since 1037 was 1037, checked in by yushan, 8 years ago

initialize the branch

File size: 1.2 KB
RevLine 
[888]1/*!
2   \file min.cpp
3   \author Ha NGUYEN
4   \since 27 June 2016
[1037]5   \date 27 June 2016
[888]6
7   \brief min reduction
8 */
[979]9#include "min_reduction.hpp"
[888]10
11namespace xios {
12
13CMinReductionAlgorithm::CMinReductionAlgorithm()
14  : CReductionAlgorithm()
15{
16}
17
18CReductionAlgorithm* CMinReductionAlgorithm::create()
19{
20  return (new CMinReductionAlgorithm());
21}
22
23bool CMinReductionAlgorithm::registerTrans()
24{
25  return registerOperation(TRANS_REDUCE_MIN, CMinReductionAlgorithm::create);
26}
27
28void CMinReductionAlgorithm::apply(const std::vector<std::pair<int,double> >& localIndex,
29                                   const double* dataInput,
30                                   CArray<double,1>& dataOut,
[1037]31                                   std::vector<bool>& flagInitial)
[888]32{
[1037]33  int nbLocalIndex = localIndex.size();
34  int currentlocalIndex = 0;
35  for (int idx = 0; idx < nbLocalIndex; ++idx)
[888]36  {
[1037]37    currentlocalIndex = localIndex[idx].first;
38    if (flagInitial[currentlocalIndex])
[888]39    {
[1037]40      dataOut(currentlocalIndex) = *(dataInput + idx);
41      flagInitial[currentlocalIndex] = false;
[888]42    }
[1037]43    else
[888]44    {
[1037]45      dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex));
[888]46    }
47  }
48}
49
50}
Note: See TracBrowser for help on using the repository browser.