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