FLOPC++
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
FlopCpp
src
MP_index.cpp
Go to the documentation of this file.
1
// ******************** FlopCpp **********************************************
2
// File: MP_index.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 "
MP_index.hpp
"
10
#include "
MP_domain.hpp
"
11
#include "
MP_set.hpp
"
12
#include "
MP_model.hpp
"
13
14
namespace
flopc {
15
// Initialization of static member data
16
MP_index
&
MP_index::Empty
= *
new
MP_index
();
17
MP_index
&
MP_index::Any_index
= *
new
MP_index
();
18
MP_index_exp
MP_index_exp::Empty
= *
new
MP_index_exp
(
Constant
(0.0));
19
20
MP_index
&
MP_index::getEmpty
() {
21
return
Empty
;
22
}
23
MP_index
&
MP_index::Any
() {
24
return
Any_index
;
25
}
26
const
MP_index_exp
&
MP_index_exp::getEmpty
() {
27
return
Empty
;
28
}
29
30
class
MP_index_constant
:
public
MP_index_base
{
31
friend
class
MP_index_exp
;
32
public
:
33
private
:
34
MP_index_constant
(
const
Constant
& c) :
C
(c) {}
35
int
evaluate
()
const
{
36
return
int(
C
->evaluate());
37
}
38
MP_index
*
getIndex
()
const
{
39
return
0;
40
}
41
virtual
MP_domain
getDomain
(
MP_set
* s)
const
{
42
return
MP_domain::getEmpty
();
43
}
44
Constant
C
;
45
};
46
47
class
MP_index_subsetRef
:
public
MP_index_base
{
48
friend
class
MP_index_exp
;
49
private
:
50
MP_index_subsetRef
(
const
SUBSETREF
& s) :
S
(&s) {}
51
int
evaluate
()
const
{
52
return
int(
S
->
evaluate
());
53
}
54
MP_index
*
getIndex
()
const
{
55
return
S
->
getIndex
();
56
}
57
virtual
MP_domain
getDomain
(
MP_set
* s)
const
{
58
return
MP_domain
(
S
->
getDomain
(s));
59
}
60
const
SUBSETREF
*
S
;
61
};
62
63
MP_index_exp
operator+
(
MP_index
& i,
const
Constant
& j) {
64
return
new
MP_index_sum
(i,j);
65
}
66
67
MP_index_exp
operator+
(
MP_index
& i,
const
int
& j) {
68
return
new
MP_index_sum
(i,
Constant
(j));
69
}
70
71
MP_index_exp
operator-
(
MP_index
& i,
const
Constant
& j) {
72
return
new
MP_index_dif
(i,j);
73
}
74
75
MP_index_exp
operator-
(
MP_index
& i,
const
int
& j) {
76
return
new
MP_index_dif
(i,
Constant
(j));
77
}
78
79
MP_index_exp
operator*
(
MP_index
& i,
const
Constant
& j) {
80
return
new
MP_index_mult
(i,j);
81
}
82
83
84
}
// End of namespace flopc
85
86
using namespace
flopc;
87
88
89
MP_domain
MP_index::getDomain
(
MP_set
* s)
const
{
90
return
new
MP_domain_set
(s,const_cast<MP_index*>(
this
)) ;
91
}
92
93
MP_domain
MP_index_mult::getDomain
(
MP_set
* s)
const
{
94
return
left
->getDomain(s);
95
}
96
97
MP_domain
MP_index_sum::getDomain
(
MP_set
* s)
const
{
98
return
left
->getDomain(s);
99
}
100
101
MP_domain
MP_index_dif::getDomain
(
MP_set
* s)
const
{
102
return
left
->getDomain(s);
103
}
104
105
MP_index_exp::MP_index_exp
(
int
i) :
106
Handle
<
MP_index_base
*>(new
MP_index_constant
(
Constant
(i))) {}
107
108
MP_index_exp::MP_index_exp
(
const
SUBSETREF
& s) :
109
Handle
<
MP_index_base
*>(new
MP_index_subsetRef
(s)) {}
110
111
MP_index_exp::MP_index_exp
(
const
Constant
& c) :
112
Handle
<
MP_index_base
*>(new
MP_index_constant
(c)) {}
113
114
MP_index_exp::MP_index_exp
(
MP_index
& i) :
115
Handle
<
MP_index_base
*>(&i) {
operator->
()->
count
++; }
116
117
MP_index_exp::MP_index_exp
(
const
MP_index_exp
&other):
118
Handle
<
MP_index_base
*>((const
Handle
<
MP_index_base
*> &)other) {}
119
Generated on Sat Nov 1 2014 02:49:56 for FLOPC++ by
1.8.1.2