Last change
on this file since 888 was
888,
checked in by mhnguyen, 7 years ago
|
Adding new transformation for scalar: Reducing an axis to a scalar
+) Add new xml node for new transformation
+) Add new algorithms for axis reduction
+) Make change in some place to make sure everything work fine
Test
+) On Curie
+) Tests pass and are correct
|
File size:
1.2 KB
|
Line | |
---|
1 | /*! |
---|
2 | \file max.cpp |
---|
3 | \author Ha NGUYEN |
---|
4 | \since 27 June 2016 |
---|
5 | \date 27 June 2016 |
---|
6 | |
---|
7 | \brief max reduction |
---|
8 | */ |
---|
9 | #include "max.hpp" |
---|
10 | |
---|
11 | namespace xios { |
---|
12 | |
---|
13 | CMaxReductionAlgorithm::CMaxReductionAlgorithm() |
---|
14 | : CReductionAlgorithm() |
---|
15 | { |
---|
16 | } |
---|
17 | |
---|
18 | CReductionAlgorithm* CMaxReductionAlgorithm::create() |
---|
19 | { |
---|
20 | return (new CMaxReductionAlgorithm()); |
---|
21 | } |
---|
22 | |
---|
23 | bool CMaxReductionAlgorithm::registerTrans() |
---|
24 | { |
---|
25 | return registerOperation(TRANS_REDUCE_MAX, CMaxReductionAlgorithm::create); |
---|
26 | } |
---|
27 | |
---|
28 | void CMaxReductionAlgorithm::apply(const std::vector<std::pair<int,double> >& localIndex, |
---|
29 | const double* dataInput, |
---|
30 | CArray<double,1>& dataOut, |
---|
31 | std::vector<bool>& flagInitial) |
---|
32 | { |
---|
33 | int nbLocalIndex = localIndex.size(); |
---|
34 | int currentlocalIndex = 0; |
---|
35 | double currentWeight = 0.0; |
---|
36 | for (int idx = 0; idx < nbLocalIndex; ++idx) |
---|
37 | { |
---|
38 | currentlocalIndex = localIndex[idx].first; |
---|
39 | currentWeight = localIndex[idx].second; |
---|
40 | if (flagInitial[currentlocalIndex]) |
---|
41 | { |
---|
42 | dataOut(currentlocalIndex) = *(dataInput + idx); |
---|
43 | flagInitial[currentlocalIndex] = false; |
---|
44 | } |
---|
45 | else |
---|
46 | { |
---|
47 | dataOut(currentlocalIndex) = std::max(*(dataInput + idx), dataOut(currentlocalIndex)); |
---|
48 | } |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.