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 using std::cout;
11 using std::endl;
12 
13 #include "MP_data.hpp"
14 #include "MP_domain.hpp"
15 #include "MP_index.hpp"
16 #include "MP_set.hpp"
17 #include "MP_constant.hpp"
18 #include "MP_expression.hpp"
19 
20 using namespace flopc;
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 }