SoPlex Doxygen Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
vector_exact.h
Go to the documentation of this file.
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2
/* */
3
/* This file is part of the class library */
4
/* SoPlex --- the Sequential object-oriented simPlex. */
5
/* */
6
/* Copyright (C) 1996 Roland Wunderling */
7
/* 1996-2012 Konrad-Zuse-Zentrum */
8
/* fuer Informationstechnik Berlin */
9
/* */
10
/* SoPlex is distributed under the terms of the ZIB Academic Licence. */
11
/* */
12
/* You should have received a copy of the ZIB Academic License */
13
/* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
14
/* */
15
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16
17
/**@file vector_exact.h
18
* @brief Dense vector of MpqReal.
19
*/
20
#ifndef _VECTOR_EXACT_H_
21
#define _VECTOR_EXACT_H_
22
23
#include <assert.h>
24
#include <string.h>
25
#include <math.h>
26
#include <iostream>
27
28
#include "
mpqreal.h
"
29
30
namespace
soplex
31
{
32
class
Vector;
33
class
SVector;
34
class
SSVector;
35
36
/**@brief Dense vector of MpqReal.
37
* @ingroup Algebra
38
*
39
* Class Vector_exact is a copy of class Vector replacing the floating point type Real with the exact MpqReal.
40
*/
41
class
Vector_exact
42
{
43
protected
:
44
45
//------------------------------------
46
/**@name Data */
47
//@{
48
/// dimension of vector
49
int
dimen
;
50
/// values of a vector
51
/** The memory block pointed to by val must at least have size
52
* dimen * sizeof(Real)
53
*/
54
MpqReal
*
val
;
55
//@}
56
57
public
:
58
59
//------------------------------------
60
/**@name Construction and assignment */
61
//@{
62
/// construction
63
/** There is no default constructor since the storage for a
64
* Vector must be provided externally.
65
* Storage must be passed as a memory block val at construction. It
66
* must be large enough to fit at least dimen Real values.
67
*/
68
Vector_exact
(
int
p_dimen,
MpqReal
*p_val)
69
:
dimen
(p_dimen)
70
,
val
(p_val)
71
{
72
assert(
dimen
>= 0);
73
assert(
isConsistent
());
74
}
75
/// Assignment operator.
76
Vector_exact
&
operator=
(
const
Vector_exact
& vec);
77
78
/// Assignment operator.
79
Vector_exact
&
operator=
(
const
Vector
& vec);
80
81
/// Assignment operator.
82
/** Assigning a SVector to a Vector using operator=()
83
* will set all values to 0 except the nonzeros of \p vec.
84
* This is diffent in method assign().
85
*/
86
Vector_exact
&
operator=
(
const
SVector
& vec);
87
//@}
88
89
//------------------------------------
90
/**@name Access */
91
//@{
92
/// dimension of vector
93
inline
int
dim
()
const
94
{
95
return
dimen
;
96
}
97
/// return \p n 'th value by reference
98
MpqReal
&
operator[]
(
int
n)
99
{
100
assert(n >= 0 && n <
dimen
);
101
return
val
[n];
102
}
103
104
/// return \p n 'th value
105
MpqReal
operator[]
(
int
n)
const
106
{
107
assert(n >= 0 && n <
dimen
);
108
return
val
[n];
109
}
110
111
/// equality operator
112
friend
bool
operator==
(
const
Vector_exact
& vec1,
const
Vector_exact
& vec2);
113
//@}
114
115
//------------------------------------
116
/**@name Algebraic methods */
117
//@{
118
/// vector addition
119
Vector_exact
&
operator+=
(
const
Vector_exact
& vec);
120
/// vector addition
121
Vector_exact
&
operator+=
(
const
Vector
& vec);
122
/// vector addition
123
Vector_exact
&
operator+=
(
const
SVector
& vec);
124
125
/// vector difference
126
Vector_exact
&
operator-=
(
const
Vector_exact
& vec);
127
/// vector difference
128
Vector_exact
&
operator-=
(
const
Vector
& vec);
129
/// vector difference
130
Vector_exact
&
operator-=
(
const
SVector
& vec);
131
132
/// scaling
133
Vector_exact
&
operator*=
(
MpqReal
x);
134
135
/// absolute biggest element (infinity norm).
136
MpqReal
maxAbs
()
const
;
137
/// absolute smallest element.
138
MpqReal
minAbs
()
const
;
139
140
/// addition of scaled vector
141
Vector_exact
&
multAdd
(
MpqReal
x,
const
Vector_exact
& vec);
142
/// addition of scaled vector
143
Vector_exact
&
multAdd
(
MpqReal
x,
const
Vector
& vec);
144
/// addition of scaled vector
145
Vector_exact
&
multAdd
(
MpqReal
x,
const
SVector
& vec);
146
//@}
147
148
//------------------------------------
149
/**@name Utilities */
150
//@{
151
/// Conversion to C-style pointer.
152
/** This function serves for using a Vector in an C-style
153
* function. It returns a pointer to the first value of the array.
154
*
155
* @todo check whether this non-const c-style acces should indeed be public
156
*/
157
MpqReal
*
get_ptr
()
158
{
159
return
val
;
160
}
161
/// Conversion to C-style pointer.
162
/** This function serves for using a Vector in an C-style
163
* function. It returns a pointer to the first value of the array.
164
*/
165
const
MpqReal
*
get_const_ptr
()
const
166
{
167
return
val
;
168
}
169
/// output operator.
170
friend
std::ostream&
operator<<
(std::ostream& s,
const
Vector_exact
& vec);
171
172
/// consistency check.
173
bool
isConsistent
()
const
;
174
175
/// set vector to 0.
176
void
clear
()
177
{
178
if
(
dimen
> 0 )
179
{
180
for
(
int
i = 0; i <
dimen
; i++ )
181
val
[i] = 0;
182
}
183
}
184
//@}
185
186
private
:
187
188
//------------------------------------
189
/**@name Blocked */
190
//@{
191
/// we have no default constructor.
192
Vector_exact
();
193
//@}
194
};
195
}
// namespace soplex
196
#endif // _VECTOR_EXACT_H_
197
198
//-----------------------------------------------------------------------------
199
//Emacs Local Variables:
200
//Emacs mode:c++
201
//Emacs c-basic-offset:3
202
//Emacs tab-width:8
203
//Emacs indent-tabs-mode:nil
204
//Emacs End:
205
//-----------------------------------------------------------------------------
© 2003-2013 by Zuse Institute Berlin (ZIB),
Imprint
Generated on Wed Jan 9 2013 for SoPlex by
doxygen