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