SEP Solver Library
1.0
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Macros
base
Space.h
Go to the documentation of this file.
1
#ifndef Space_H
2
#define Space_H 1
3
#include "
dataContainer.h
"
4
#include "
handleIO.h
"
5
#include "
except.h
"
6
#include <boost/smart_ptr/shared_ptr.hpp>
7
#include <boost/smart_ptr/make_shared.hpp>
8
namespace
SEP {
9
10
11
class
Space
:
public
Writeable
{
12
private
:
13
boost::shared_ptr<int> key;
14
public
:
15
Space
() {
16
key = boost::make_shared<int>(1);
17
}
// default constructor
18
virtual
~Space
() {};
// destructor
19
20
virtual
dataContainer
*
buildDataContainer
()
const
{
21
return
0;
// must return something
22
}
23
// build a data container for a vector in the spaces
24
25
boost::shared_ptr<int>
get_key
()
const
{
return
this->key;}
26
27
virtual
void
set_key
(
const
boost::shared_ptr<int> & k){
28
this->key = k;
29
}
30
31
virtual
long
long
get_n123
() = 0;
32
// specific instances of space have dimensions
33
34
virtual
bool
isCompatible
(
dataContainer
* otherContainer)
const
= 0;
35
// check compatibility of a vector with this space
36
37
virtual
bool
isCompatible
(
Space
* otherSpace,
bool
makeSame=
false
)
const
= 0;
38
// Check if spaces are compatible. By default, do not give them the
39
// same key if they are compatible, but if makeSame = true, compatible
40
// spaces are given the same key.
41
42
virtual
void
zeroElement
(
dataContainer
* x)
const
= 0;
43
44
45
virtual
void
random
(
dataContainer
* x)
const
= 0;
46
// zero element of the space
47
48
virtual
bool
operator ==
(
const
Space
& otherSpace)
const
49
{
50
if
(
this
== &otherSpace){
51
return
true
;
52
}
else
if
(this->key == otherSpace.
get_key
()){
53
return
true
;
54
}
55
return
false
;
56
}
57
// check if two vector MultiSpace are equal
58
59
virtual
void
linearCombo
(
float
a,
dataContainer
* x,
float
b,
dataContainer
* y)
const
= 0;
60
// do a linear combination x = ax + by
61
62
virtual
double
innerProd
(
dataContainer
* x,
dataContainer
* y)
const
= 0;
63
// take the inner product of x and y
64
65
//Put back later *************************
66
//virtual void norm(int p, dataContainer * x) const = 0;
67
// calculate the p-norm of a vector (p=2 Euclidean)
68
69
virtual
void
addInv
(
dataContainer
* x)
const
= 0;
70
// get the additive inverse of x (multiply by -1)
71
// and overwrite x
72
73
virtual
void
addInv
(
dataContainer
* x,
dataContainer
* xNeg)
const
= 0;
74
// xNeg = -1*x but leave x alone
75
76
virtual
void
scale
(
float
a,
dataContainer
* x)
const
=0;
77
// multiply vector x by scalar a and overwrite x
78
79
virtual
void
print_it
(){ std::cout<<
"i am default"
<<std::endl;}
80
81
virtual
void
scale
(
float
a,
dataContainer
* x,
dataContainer
* ax)
const
= 0;
82
// multiply vector x by scalar a and write it in ax
83
84
};
85
86
class
MultiSpace
:
public
Space
{
87
public
:
88
Space
*
sp1
,*
sp2
;
89
90
MultiSpace
():
sp1
(0),
sp2
(0) {}
// default constructor
91
MultiSpace
(
Space
*s1,
Space
*s2);
92
virtual
~MultiSpace
() {}
// destructor
93
Space
*
getSpace1
()
const
{
return
sp1
;}
94
Space
*
getSpace2
()
const
{
return
sp2
;}
95
96
virtual
MultiDataContainer
*
buildDataContainer
()
const
;
97
98
// virtual MultiSpace clone_space() const;
99
100
virtual
long
long
get_n123
();
101
102
virtual
void
zeroElement
(
dataContainer
* x)
const
;
103
104
virtual
void
linearCombo
(
float
a,
dataContainer
* x,
float
b,
dataContainer
* y)
const
;
105
106
virtual
double
innerProd
(
dataContainer
* x,
dataContainer
* y)
const
;
107
108
//hide virtual float norm(int p, dataContainer * x) const ;
109
110
virtual
void
addInv
(
dataContainer
* x)
const
;
111
112
virtual
void
addInv
(
dataContainer
* x,
dataContainer
* xNeg)
const
;
113
114
virtual
void
scale
(
float
a,
dataContainer
* x)
const
;
115
116
virtual
void
scale
(
float
a,
dataContainer
* x,
dataContainer
* ax)
const
;
117
virtual
bool
isCompatible
(
Space
* otherSpace,
bool
makeSame=
false
)
const
;
118
virtual
bool
isCompatible
(
dataContainer
* otherContainer)
const
;
119
virtual
void
random
(
dataContainer
* x)
const
;
120
// zero element of the space
121
122
};
123
124
125
126
}
127
#endif
Generated by
1.8.4