OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
SymmetricDifference.cpp
Go to the documentation of this file.
2
3#include <boost/regex.hpp>
4
5namespace mslang {
6 void SymmetricDifference::print(int indentwidth) {
7 std::string indent(' ', indentwidth);
8 std::cout << indent << "Symmetric division\n"
9 << indent << " first operand\n";
10 firstOperand_m->print(indentwidth + 8);
11
12 std::cout << indent << " second operand\n";
13 secondOperand_m->print(indentwidth + 8);
14 }
15
16 void SymmetricDifference::apply(std::vector<std::shared_ptr<Base> > &bfuncs) {
17 std::vector<std::shared_ptr<Base> > first, second;
18
19 firstOperand_m->apply(first);
20 secondOperand_m->apply(second);
21 for (auto item: first) {
22 item->divideBy(second);
23 bfuncs.emplace_back(item->clone());
24 }
25
26 for (auto item: first)
27 item.reset();
28
29 first.clear();
30
31 firstOperand_m->apply(first);
32 for (auto item: second) {
33 item->divideBy(first);
34 bfuncs.emplace_back(item->clone());
35 }
36
37 for (auto item: first)
38 item.reset();
39 for (auto item: second)
40 item.reset();
41 }
42
44 SymmetricDifference *dif = static_cast<SymmetricDifference*>(fun);
45 if (!parse(it, end, dif->firstOperand_m)) return false;
46
47 boost::regex argumentList("(,[a-z]+\\(.*)");
48 boost::regex endParenthesis("\\)(.*)");
49 boost::smatch what;
50
51 std::string str(it, end);
52 if (!boost::regex_match(str, what, argumentList)) return false;
53
54 iterator it2 = it + 1;
55 if (!parse(it2, end, dif->secondOperand_m)) return false;
56
57 it = it2;
58 str = std::string(it, end);
59 if (!boost::regex_match(str, what, endParenthesis)) return false;
60
61 std::string fullMatch = what[0];
62 std::string rest = what[1];
63
64 it += (fullMatch.size() - rest.size());
65
66 return true;
67 }
68}
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
std::string::iterator iterator
Definition: MSLang.h:16
virtual void apply(std::vector< std::shared_ptr< Base > > &bfuncs)=0
static bool parse(iterator &it, const iterator &end, Function *&fun)
Definition: MSLang.cpp:48
virtual void print(int indent)=0
virtual void print(int indentwidth)
virtual void apply(std::vector< std::shared_ptr< Base > > &bfuncs)
static bool parse_detail(iterator &it, const iterator &end, Function *&fun)