Changeset 1037 for XIOS/dev/branch_yushan/src/transformation/Functions
- Timestamp:
- 01/25/17 16:25:17 (8 years ago)
- Location:
- XIOS/dev/branch_yushan/src/transformation/Functions
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_yushan/src/transformation/Functions/average_reduction.cpp
r1018 r1037 3 3 \author Ha NGUYEN 4 4 \since 8 Sep 2016 5 \date 9 Jan 20175 \date 8 Sep 2016 6 6 7 7 \brief average reduction 8 8 */ 9 9 #include "average_reduction.hpp" 10 #include "utils.hpp"11 10 12 11 namespace xios { … … 30 29 const double* dataInput, 31 30 CArray<double,1>& dataOut, 32 std::vector<bool>& flagInitial, 33 const double& defaultValue) 31 std::vector<bool>& flagInitial) 34 32 { 35 33 if (resetWeight_) { weights_.resize(flagInitial.size()); weights_ = 1.0; resetWeight_ = false; } 36 bool hasMissingValue = NumTraits<double>::isnan(defaultValue);37 34 38 if (hasMissingValue) 35 int nbLocalIndex = localIndex.size(); 36 int currentlocalIndex = 0; 37 double currentWeight = 0.0; 38 for (int idx = 0; idx < nbLocalIndex; ++idx) 39 39 { 40 int nbLocalIndex = localIndex.size();41 int currentlocalIndex = 0;42 double currentWeight = 0.0; 43 for (int idx = 0; idx < nbLocalIndex; ++idx)40 currentlocalIndex = localIndex[idx].first; 41 currentWeight = localIndex[idx].second; 42 43 if (flagInitial[currentlocalIndex]) 44 44 { 45 currentlocalIndex = localIndex[idx].first; 46 currentWeight = localIndex[idx].second; 47 if (!NumTraits<double>::isnan(*(dataInput + idx))) 48 { 49 if (flagInitial[currentlocalIndex]) 50 { 51 dataOut(currentlocalIndex) = *(dataInput + idx); 52 flagInitial[currentlocalIndex] = false; 53 } 54 else 55 { 56 dataOut(currentlocalIndex) += *(dataInput + idx); 57 weights_(currentlocalIndex) += 1.0; 58 } 59 } 45 dataOut(currentlocalIndex) = *(dataInput + idx); 46 flagInitial[currentlocalIndex] = false; 60 47 } 61 } 62 else 63 { 64 int nbLocalIndex = localIndex.size(); 65 int currentlocalIndex = 0; 66 double currentWeight = 0.0; 67 for (int idx = 0; idx < nbLocalIndex; ++idx) 48 else 68 49 { 69 currentlocalIndex = localIndex[idx].first; 70 currentWeight = localIndex[idx].second; 71 72 if (flagInitial[currentlocalIndex]) 73 { 74 dataOut(currentlocalIndex) = *(dataInput + idx); 75 flagInitial[currentlocalIndex] = false; 76 } 77 else 78 { 79 dataOut(currentlocalIndex) += *(dataInput + idx); 80 weights_(currentlocalIndex) += 1.0; 81 } 50 dataOut(currentlocalIndex) += *(dataInput + idx); 51 weights_(currentlocalIndex) += 1.0; 82 52 } 83 53 } -
XIOS/dev/branch_yushan/src/transformation/Functions/average_reduction.hpp
r1018 r1037 26 26 const double* dataInput, 27 27 CArray<double,1>& dataOut, 28 std::vector<bool>& flagInitial, 29 const double& defaultValue); 28 std::vector<bool>& flagInitial); 30 29 31 30 virtual void updateData(CArray<double,1>& dataOut); -
XIOS/dev/branch_yushan/src/transformation/Functions/extract.cpp
r1018 r1037 29 29 const double* dataInput, 30 30 CArray<double,1>& dataOut, 31 std::vector<bool>& flagInitial, 32 const double& defaultValue) 31 std::vector<bool>& flagInitial) 33 32 { 34 33 int nbLocalIndex = localIndex.size(); -
XIOS/dev/branch_yushan/src/transformation/Functions/extract.hpp
r1018 r1037 26 26 const double* dataInput, 27 27 CArray<double,1>& dataOut, 28 std::vector<bool>& flagInitial, 29 const double& defaultValue); 28 std::vector<bool>& flagInitial); 30 29 31 30 virtual ~CExtractReductionAlgorithm() {} -
XIOS/dev/branch_yushan/src/transformation/Functions/max_reduction.cpp
r1018 r1037 8 8 */ 9 9 #include "max_reduction.hpp" 10 #include "utils.hpp"11 10 12 11 namespace xios { … … 30 29 const double* dataInput, 31 30 CArray<double,1>& dataOut, 32 std::vector<bool>& flagInitial, 33 const double& defaultValue) 31 std::vector<bool>& flagInitial) 34 32 { 35 bool hasMissingValue = NumTraits<double>::isnan(defaultValue); 36 37 if (hasMissingValue) 33 int nbLocalIndex = localIndex.size(); 34 int currentlocalIndex = 0; 35 double currentWeight = 0.0; 36 for (int idx = 0; idx < nbLocalIndex; ++idx) 38 37 { 39 int nbLocalIndex = localIndex.size();40 int currentlocalIndex = 0;41 for (int idx = 0; idx < nbLocalIndex; ++idx)38 currentlocalIndex = localIndex[idx].first; 39 currentWeight = localIndex[idx].second; 40 if (flagInitial[currentlocalIndex]) 42 41 { 43 currentlocalIndex = localIndex[idx].first; 44 if (!NumTraits<double>::isnan(*(dataInput + idx))) 45 { 46 if (flagInitial[currentlocalIndex]) 47 { 48 dataOut(currentlocalIndex) = *(dataInput + idx); 49 flagInitial[currentlocalIndex] = false; 50 } 51 else 52 { 53 dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex)); 54 } 55 } 42 dataOut(currentlocalIndex) = *(dataInput + idx); 43 flagInitial[currentlocalIndex] = false; 56 44 } 57 } 58 else 59 { 60 int nbLocalIndex = localIndex.size(); 61 int currentlocalIndex = 0; 62 for (int idx = 0; idx < nbLocalIndex; ++idx) 45 else 63 46 { 64 currentlocalIndex = localIndex[idx].first; 65 if (flagInitial[currentlocalIndex]) 66 { 67 dataOut(currentlocalIndex) = *(dataInput + idx); 68 flagInitial[currentlocalIndex] = false; 69 } 70 else 71 { 72 dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex)); 73 } 47 dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex)); 74 48 } 75 49 } -
XIOS/dev/branch_yushan/src/transformation/Functions/max_reduction.hpp
r1018 r1037 26 26 const double* dataInput, 27 27 CArray<double,1>& dataOut, 28 std::vector<bool>& flagInitial, 29 const double& defaultValue); 28 std::vector<bool>& flagInitial); 30 29 31 30 virtual ~CMaxReductionAlgorithm() {} -
XIOS/dev/branch_yushan/src/transformation/Functions/min_reduction.cpp
r1018 r1037 3 3 \author Ha NGUYEN 4 4 \since 27 June 2016 5 \date 9 Jan 20175 \date 27 June 2016 6 6 7 7 \brief min reduction 8 8 */ 9 9 #include "min_reduction.hpp" 10 #include "utils.hpp"11 10 12 11 namespace xios { … … 30 29 const double* dataInput, 31 30 CArray<double,1>& dataOut, 32 std::vector<bool>& flagInitial, 33 const double& defaultValue) 31 std::vector<bool>& flagInitial) 34 32 { 35 bool hasMissingValue = NumTraits<double>::isnan(defaultValue);36 37 if (hasMissingValue)33 int nbLocalIndex = localIndex.size(); 34 int currentlocalIndex = 0; 35 for (int idx = 0; idx < nbLocalIndex; ++idx) 38 36 { 39 int nbLocalIndex = localIndex.size(); 40 int currentlocalIndex = 0; 41 for (int idx = 0; idx < nbLocalIndex; ++idx) 37 currentlocalIndex = localIndex[idx].first; 38 if (flagInitial[currentlocalIndex]) 42 39 { 43 currentlocalIndex = localIndex[idx].first; 44 if (!NumTraits<double>::isnan(*(dataInput + idx))) 45 { 46 if (flagInitial[currentlocalIndex]) 47 { 48 dataOut(currentlocalIndex) = *(dataInput + idx); 49 flagInitial[currentlocalIndex] = false; 50 } 51 else 52 { 53 dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex)); 54 } 55 } 40 dataOut(currentlocalIndex) = *(dataInput + idx); 41 flagInitial[currentlocalIndex] = false; 56 42 } 57 } 58 else 59 { 60 int nbLocalIndex = localIndex.size(); 61 int currentlocalIndex = 0; 62 for (int idx = 0; idx < nbLocalIndex; ++idx) 43 else 63 44 { 64 currentlocalIndex = localIndex[idx].first; 65 if (flagInitial[currentlocalIndex]) 66 { 67 dataOut(currentlocalIndex) = *(dataInput + idx); 68 flagInitial[currentlocalIndex] = false; 69 } 70 else 71 { 72 dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex)); 73 } 45 dataOut(currentlocalIndex) = std::min(*(dataInput + idx), dataOut(currentlocalIndex)); 74 46 } 75 47 } -
XIOS/dev/branch_yushan/src/transformation/Functions/min_reduction.hpp
r1018 r1037 26 26 const double* dataInput, 27 27 CArray<double,1>& dataOut, 28 std::vector<bool>& flagInitial, 29 const double& defaultValue); 28 std::vector<bool>& flagInitial); 30 29 31 30 virtual ~CMinReductionAlgorithm() {} -
XIOS/dev/branch_yushan/src/transformation/Functions/reduction.hpp
r1018 r1037 45 45 const double* dataInput, 46 46 CArray<double,1>& dataOut, 47 std::vector<bool>& flagInitial, 48 const double& defaultValue) = 0; 47 std::vector<bool>& flagInitial) = 0; 49 48 /*! 50 49 Update local data -
XIOS/dev/branch_yushan/src/transformation/Functions/sum_reduction.cpp
r1018 r1037 3 3 \author Ha NGUYEN 4 4 \since 27 June 2016 5 \date 9 Jan 20175 \date 27 June 2016 6 6 7 7 \brief sum reduction 8 8 */ 9 9 #include "sum_reduction.hpp" 10 #include "utils.hpp"11 10 12 11 namespace xios { … … 30 29 const double* dataInput, 31 30 CArray<double,1>& dataOut, 32 std::vector<bool>& flagInitial, 33 const double& defaultValue) 31 std::vector<bool>& flagInitial) 34 32 { 35 bool hasMissingValue = NumTraits<double>::isnan(defaultValue); 36 if (hasMissingValue) 33 int nbLocalIndex = localIndex.size(); 34 int currentlocalIndex = 0; 35 double currentWeight = 0.0; 36 for (int idx = 0; idx < nbLocalIndex; ++idx) 37 37 { 38 int nbLocalIndex = localIndex.size();39 int currentlocalIndex = 0;40 for (int idx = 0; idx < nbLocalIndex; ++idx)38 currentlocalIndex = localIndex[idx].first; 39 currentWeight = localIndex[idx].second; 40 if (flagInitial[currentlocalIndex]) 41 41 { 42 currentlocalIndex = localIndex[idx].first; 43 if (!NumTraits<double>::isnan(*(dataInput + idx))) 44 { 45 if (flagInitial[currentlocalIndex]) 46 { 47 dataOut(currentlocalIndex) = *(dataInput + idx); 48 flagInitial[currentlocalIndex] = false; 49 } 50 else 51 { 52 dataOut(currentlocalIndex) += *(dataInput + idx); 53 } 54 } 55 } 56 } 57 else 58 { 59 int nbLocalIndex = localIndex.size(); 60 int currentlocalIndex = 0; 61 for (int idx = 0; idx < nbLocalIndex; ++idx) 42 dataOut(currentlocalIndex) = *(dataInput + idx); 43 flagInitial[currentlocalIndex] = false; 44 } 45 else 62 46 { 63 currentlocalIndex = localIndex[idx].first; 64 if (flagInitial[currentlocalIndex]) 65 { 66 dataOut(currentlocalIndex) = *(dataInput + idx); 67 flagInitial[currentlocalIndex] = false; 68 } 69 else 70 { 71 dataOut(currentlocalIndex) += *(dataInput + idx); 72 } 47 dataOut(currentlocalIndex) += *(dataInput + idx); 73 48 } 74 49 } -
XIOS/dev/branch_yushan/src/transformation/Functions/sum_reduction.hpp
r1018 r1037 26 26 const double* dataInput, 27 27 CArray<double,1>& dataOut, 28 std::vector<bool>& flagInitial, 29 const double& defaultValue); 28 std::vector<bool>& flagInitial); 30 29 31 30 virtual ~CSumReductionAlgorithm() {}
Note: See TracChangeset
for help on using the changeset viewer.