FLOPC++
MP_data.cpp
Go to the documentation of this file.
1 // ******************** FlopCpp **********************************************
2 // File: MP_data.cpp
3 // $Id$
4 // Author: Tim Helge Hultberg (thh@mat.ua.pt)
5 // Copyright (C) 2003 Tim Helge Hultberg
6 // All Rights Reserved.
7 //****************************************************************************
8 
9 #include <iostream>
10 
11 #include "MP_data.hpp"
12 #include "MP_domain.hpp"
13 #include "MP_index.hpp"
14 #include "MP_set.hpp"
15 #include "MP_constant.hpp"
16 #include "MP_expression.hpp"
17 
18 using namespace flopc;
19 using namespace std;
20 
21 double MP_data::outOfBoundData = 0;
22 
24  C = c;
25  ((D->S1(I1)*D->S2(I2)*D->S3(I3)*D->S4(I4)*D->S5(I5)).such_that(B)).Forall(this);
26  return *this;;
27 }
28 
29 const DataRef& DataRef::operator=(const DataRef& r) {
30  return operator=(Constant(const_cast<DataRef*>(&r)));
31 }
32 
33 void DataRef::operator()() const {
34  evaluate_lhs(C->evaluate());
35 }
36 
38  B = b;
39  return *this;
40 }
41 
42 
43 double DataRef::evaluate() const {
44  int i1 = D->S1.check(I1->evaluate());
45  int i2 = D->S2.check(I2->evaluate());
46  int i3 = D->S3.check(I3->evaluate());
47  int i4 = D->S4.check(I4->evaluate());
48  int i5 = D->S5.check(I5->evaluate());
49 
50  int i = D->f(i1,i2,i3,i4,i5);
51  if ( i == outOfBound ) {
52  return 0;
53  } else {
54  return D->v[i];
55  }
56 }
57 
58 
59 
60 int DataRef::getStage() const {
61  int i1 = D->S1.checkStage(I1->evaluate());
62  int i2 = D->S2.checkStage(I2->evaluate());
63  int i3 = D->S3.checkStage(I3->evaluate());
64  int i4 = D->S4.checkStage(I4->evaluate());
65  int i5 = D->S5.checkStage(I5->evaluate());
66 
67  int stage = 0;
68  if (i1>stage) stage = i1;
69  if (i2>stage) stage = i2;
70  if (i3>stage) stage = i3;
71  if (i4>stage) stage = i4;
72  if (i5>stage) stage = i5;
73 
74  // might need to add outofbound check here
75  return stage+stochastic;
76 }
77 
78 
79 void DataRef::evaluate_lhs(double v) const {
80  int i1 = D->S1.check(I1->evaluate());
81  int i2 = D->S2.check(I2->evaluate());
82  int i3 = D->S3.check(I3->evaluate());
83  int i4 = D->S4.check(I4->evaluate());
84  int i5 = D->S5.check(I5->evaluate());
85 
86  int i = D->f(i1,i2,i3,i4,i5);
87  if (i != outOfBound) {
88  D->v[i] = v;
89  }
90 }
91 
92 void MP_data::operator()() const {
93  if (&S1!=&MP_set::getEmpty()) cout << i1.evaluate() << " ";
94  if (&S2!=&MP_set::getEmpty()) cout << i2.evaluate() << " ";
95  if (&S3!=&MP_set::getEmpty()) cout << i3.evaluate() << " ";
96  if (&S4!=&MP_set::getEmpty()) cout << i4.evaluate() << " ";
97  if (&S5!=&MP_set::getEmpty()) cout << i5.evaluate() << " ";
98  cout<<" "<<v[f(i1.evaluate(),i2.evaluate(),i3.evaluate(),
99  i4.evaluate(),i5.evaluate())] << endl;
100 }
101 
102 void MP_data::display(string s) {
103  cout<<s<<endl;
104  ((S1)(i1)*(S2)(i2)*(S3)(i3)*(S4)(i4)*(S5)(i5)).Forall(this);
105 }
void evaluate_lhs(double v) const
Definition: MP_data.cpp:79
int getStage() const
Definition: MP_data.cpp:60
static MP_set & getEmpty()
gets the distinct &#39;empty&#39; MP_set.
Definition: MP_set.cpp:17
const DataRef & operator=(const DataRef &r)
Definition: MP_data.cpp:29
static double outOfBoundData
Definition: MP_data.hpp:178
double evaluate() const
Definition: MP_data.cpp:43
const int outOfBound
Distinct return value on conditions where an index goes out of bounds.
Reference to a set of data.
Definition: MP_data.hpp:29
Reference counted class for all &quot;boolean&quot; types of data.This contains counters to ConstantBase pointe...
Definition: MP_boolean.hpp:45
DataRef & such_that(const MP_boolean &b)
Definition: MP_data.cpp:37
Reference counted class for all &quot;constant&quot; types of data.
Definition: MP_constant.hpp:48
void display(std::string s="")
For displaying data in a human readable format.
Definition: MP_data.cpp:102
void operator()() const
Definition: MP_data.cpp:33
void operator()() const
Definition: MP_data.cpp:92