OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
Repeat.cpp
Go to the documentation of this file.
4 
5 namespace mslang {
6  void Repeat::print(int indentwidth) {
7  std::string indent(indentwidth, ' ');
8  std::string indent2(indentwidth + 8, ' ');
9  std::cout << indent << "repeat, " << std::endl;
10  func_m->print(indentwidth + 8);
11  std::cout << ",\n"
12  << indent2 << "N: " << N_m << ", \n"
13  << indent2 << "dx: " << shiftx_m << ", \n"
14  << indent2 << "dy: " << shifty_m;
15  }
16 
17  void Repeat::apply(std::vector<std::shared_ptr<Base> > &bfuncs) {
20 
21  func_m->apply(bfuncs);
22  const unsigned int size = bfuncs.size();
23 
24  AffineTransformation current_trafo = trafo;
25  for (unsigned int i = 0; i < N_m; ++ i) {
26  for (unsigned int j = 0; j < size; ++ j) {
27  std::shared_ptr<Base> obj(bfuncs[j]->clone());
28  obj->trafo_m = obj->trafo_m.mult(current_trafo);
29  bfuncs.emplace_back(std::move(obj));
30  }
31 
32  current_trafo = current_trafo.mult(trafo);
33  }
34  }
35 
37  Repeat *rep = static_cast<Repeat*>(fun);
38  if (!parse(it, end, rep->func_m)) return false;
39 
40  int numRepetitions = 0;
41  ArgumentExtractor arguments(std::string(++ it, end));
42  try {
43  if (arguments.getNumArguments() == 3) {
44  numRepetitions = parseMathExpression(arguments.get(0));
45  rep->shiftx_m = parseMathExpression(arguments.get(1));
46  rep->shifty_m = parseMathExpression(arguments.get(2));
47  rep->rot_m = 0.0;
48 
49  } else if (arguments.getNumArguments() == 2) {
50  numRepetitions = parseMathExpression(arguments.get(0));
51  rep->shiftx_m = 0.0;
52  rep->shifty_m = 0.0;
53  rep->rot_m = parseMathExpression(arguments.get(1));
54  } else {
55  std::cout << "Repeat: number of arguments not supported" << std::endl;
56  return false;
57  }
58  } catch (std::runtime_error &e) {
59  std::cout << e.what() << std::endl;
60  return false;
61  }
62 
63  if (numRepetitions < 0) {
64  std::cout << "Repeat: a negative number of repetitions provided '"
65  << arguments.get(0) << " = " << rep->N_m << "'"
66  << std::endl;
67  return false;
68  }
69 
70  rep->N_m = numRepetitions;
71 
72  it += (arguments.getLengthConsumed() + 1);
73 
74  return true;
75  }
76 }
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of it
Definition: LICENSE:43
double rot_m
Definition: Repeat.h:12
double parseMathExpression(const std::string &str)
Definition: matheval.cpp:4
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6
virtual void print(int indentwidth)
Definition: Repeat.cpp:6
virtual void print(int indent)=0
AffineTransformation mult(const AffineTransformation &B)
unsigned int N_m
Definition: Repeat.h:9
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
static bool parse(iterator &it, const iterator &end, Function *&fun)
Definition: MSLang.cpp:48
std::string::iterator iterator
Definition: MSLang.h:15
unsigned int getNumArguments() const
double shiftx_m
Definition: Repeat.h:10
unsigned int getLengthConsumed() const
Tps< T > cos(const Tps< T > &x)
Cosine.
Definition: TpsMath.h:129
std::string get(unsigned int i) const
static bool parse_detail(iterator &it, const iterator &end, Function *&fun)
Definition: Repeat.cpp:36
constexpr double e
The value of .
Definition: Physics.h:39
Tps< T > sin(const Tps< T > &x)
Sine.
Definition: TpsMath.h:111
Function * func_m
Definition: Repeat.h:8
virtual void apply(std::vector< std::shared_ptr< Base > > &bfuncs)
Definition: Repeat.cpp:17
virtual void apply(std::vector< std::shared_ptr< Base >> &bfuncs)=0
end
Definition: multipole_t.tex:9
double shifty_m
Definition: Repeat.h:11