OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
ATable.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: ATable.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.3 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: ATable
10 // Expression class. Generates a list of values from a TABLE() function.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2002/01/22 15:16:02 $
15 // $Author: jsberg $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Expressions/ATable.h"
20 
21 #include <iostream>
22 
23 using namespace std;
24 
25 // Class ATable
26 // ------------------------------------------------------------------------
27 
28 namespace Expressions {
29 
30  ATable::ATable(const ATable &rhs):
31  OArray<double>(rhs), itsExpr(rhs.itsExpr),
32  itsBegin(rhs.itsBegin), itsEnd(rhs.itsEnd), itsStep(rhs.itsEnd)
33  {}
34 
35 
36  ATable::ATable(int n1, int n2, int n3):
37  OArray<double>(), itsExpr(), itsBegin(n1), itsEnd(n2), itsStep(n3)
38  {}
39 
40 
42  {}
43 
44 
46  return new ATable(*this);
47  }
48 
49 
51  itsExpr = expr;
52  }
53 
54 
55  std::vector<double> ATable::evaluate() const {
56  std::vector<double> result(itsEnd, 0.0);
57 
58  for(itsHash = itsBegin; itsHash <= itsEnd; itsHash += itsStep) {
59  result[itsHash-1] = itsExpr->evaluate();
60  }
61 
62  return result;
63  }
64 
65 
66  double ATable::getHash() const {
67  return itsHash;
68  }
69 
70 
71  void ATable::print(std::ostream &os, int) const {
72  os << "TABLE(" << itsBegin << ':' << itsEnd << ':' << itsStep << ',';
73  itsExpr->print(os);
74  os << ')';
75  return;
76  }
77 
78 }
An array expression generated from a TABLE() function.
Definition: ATable.h:38
virtual OArray< double > * clone() const
Make clone.
Definition: ATable.cpp:45
PtrToScalar< double > itsExpr
Definition: ATable.h:73
void defineExpression(PtrToScalar< double >)
Store the generating expression.
Definition: ATable.cpp:50
virtual std::vector< double > evaluate() const
Evaluate.
Definition: ATable.cpp:55
virtual void print(std::ostream &os, int precedence=99) const
Print expression.
Definition: ATable.cpp:71
double getHash() const
Return the current value of &#39;#&#39;.
Definition: ATable.cpp:66
An array expression.
Definition: Expressions.h:149