Ipopt
3.11.4
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
src
LinAlg
IpScaledMatrix.hpp
Go to the documentation of this file.
1
// Copyright (C) 2004, 2008 International Business Machines and others.
2
// All Rights Reserved.
3
// This code is published under the Eclipse Public License.
4
//
5
// $Id: IpScaledMatrix.hpp 1861 2010-12-21 21:34:47Z andreasw $
6
//
7
// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9
#ifndef __IPSCALEDMATRIX_HPP__
10
#define __IPSCALEDMATRIX_HPP__
11
12
#include "
IpUtils.hpp
"
13
#include "
IpMatrix.hpp
"
14
15
namespace
Ipopt
16
{
17
18
/* forward declarations */
19
class
ScaledMatrixSpace;
20
26
class
ScaledMatrix
:
public
Matrix
27
{
28
public
:
29
32
35
ScaledMatrix
(
const
ScaledMatrixSpace
* owner_space);
36
38
~ScaledMatrix
();
40
42
void
SetUnscaledMatrix
(
const
SmartPtr<const Matrix>
unscaled_matrix);
43
45
void
SetUnscaledMatrixNonConst
(
const
SmartPtr<Matrix>
& unscaled_matrix);
46
48
SmartPtr<const Matrix>
GetUnscaledMatrix
()
const
;
49
51
SmartPtr<Matrix>
GetUnscaledMatrixNonConst
();
52
54
SmartPtr<const Vector>
RowScaling
()
const
;
55
57
SmartPtr<const Vector>
ColumnScaling
()
const
;
58
59
protected
:
62
virtual
void
MultVectorImpl
(
Number
alpha,
const
Vector
&
x
,
63
Number
beta,
Vector
& y)
const
;
64
65
virtual
void
TransMultVectorImpl
(
Number
alpha,
const
Vector
& x,
66
Number
beta,
Vector
& y)
const
;
67
71
virtual
bool
HasValidNumbersImpl
()
const
;
72
73
virtual
void
ComputeRowAMaxImpl
(
Vector
& rows_norms,
bool
init)
const
;
74
75
virtual
void
ComputeColAMaxImpl
(
Vector
& cols_norms,
bool
init)
const
;
76
77
virtual
void
PrintImpl
(
const
Journalist
& jnlst,
78
EJournalLevel
level,
79
EJournalCategory
category,
80
const
std::string& name,
81
Index
indent,
82
const
std::string& prefix)
const
;
83
87
virtual
void
AddMSinvZImpl
(
Number
alpha,
const
Vector
& S,
const
Vector
& Z,
88
Vector
& X)
const
;
89
93
virtual
void
SinvBlrmZMTdBrImpl
(
Number
alpha,
const
Vector
& S,
94
const
Vector
& R,
const
Vector
& Z,
95
const
Vector
& D,
Vector
& X)
const
;
97
98
private
:
108
ScaledMatrix
();
109
111
ScaledMatrix
(
const
ScaledMatrix
&);
112
114
void
operator=
(
const
ScaledMatrix
&);
116
118
SmartPtr<const Matrix>
matrix_
;
120
SmartPtr<Matrix>
nonconst_matrix_
;
121
123
SmartPtr<const ScaledMatrixSpace>
owner_space_
;
124
};
125
128
class
ScaledMatrixSpace
:
public
MatrixSpace
129
{
130
public
:
136
ScaledMatrixSpace
(
const
SmartPtr<const Vector>
& row_scaling,
137
bool
row_scaling_reciprocal,
138
const
SmartPtr<const MatrixSpace>
& unscaled_matrix_space,
139
const
SmartPtr<const Vector>
& column_scaling,
140
bool
column_scaling_reciprocal);
141
143
~ScaledMatrixSpace
()
144
{}
146
148
ScaledMatrix
*
MakeNewScaledMatrix
(
bool
allocate_unscaled_matrix =
false
)
const
149
{
150
ScaledMatrix
* ret =
new
ScaledMatrix
(
this
);
151
if
(allocate_unscaled_matrix) {
152
SmartPtr<Matrix>
unscaled_matrix =
unscaled_matrix_space_
->MakeNew();
153
ret->
SetUnscaledMatrixNonConst
(unscaled_matrix);
154
}
155
return
ret;
156
}
157
160
virtual
Matrix
*
MakeNew
()
const
161
{
162
return
MakeNewScaledMatrix
();
163
}
164
166
SmartPtr<const Vector>
RowScaling
()
const
167
{
168
return
ConstPtr
(
row_scaling_
);
169
}
170
172
SmartPtr<const MatrixSpace>
UnscaledMatrixSpace
()
const
173
{
174
return
unscaled_matrix_space_
;
175
}
176
178
SmartPtr<const Vector>
ColumnScaling
()
const
179
{
180
return
ConstPtr
(
column_scaling_
);
181
}
182
183
private
:
193
ScaledMatrixSpace
();
194
196
ScaledMatrixSpace
(
const
ScaledMatrixSpace
&);
197
199
ScaledMatrixSpace
&
operator=
(
const
ScaledMatrixSpace
&);
201
203
SmartPtr<Vector>
row_scaling_
;
205
SmartPtr<const MatrixSpace>
unscaled_matrix_space_
;
207
SmartPtr<Vector>
column_scaling_
;
208
};
209
210
inline
211
void
ScaledMatrix::SetUnscaledMatrix
(
const
SmartPtr<const Matrix>
unscaled_matrix)
212
{
213
matrix_
= unscaled_matrix;
214
nonconst_matrix_
= NULL;
215
ObjectChanged
();
216
}
217
218
inline
219
void
ScaledMatrix::SetUnscaledMatrixNonConst
(
const
SmartPtr<Matrix>
& unscaled_matrix)
220
{
221
nonconst_matrix_
= unscaled_matrix;
222
matrix_
=
GetRawPtr
(unscaled_matrix);
223
ObjectChanged
();
224
}
225
226
inline
227
SmartPtr<const Matrix>
ScaledMatrix::GetUnscaledMatrix
()
const
228
{
229
return
matrix_
;
230
}
231
232
inline
233
SmartPtr<Matrix>
ScaledMatrix::GetUnscaledMatrixNonConst
()
234
{
235
DBG_ASSERT
(
IsValid
(
nonconst_matrix_
));
236
ObjectChanged
();
237
return
nonconst_matrix_
;
238
}
239
240
inline
241
SmartPtr<const Vector>
ScaledMatrix::RowScaling
()
const
242
{
243
return
ConstPtr
(
owner_space_
->RowScaling());
244
}
245
246
inline
247
SmartPtr<const Vector>
ScaledMatrix::ColumnScaling
()
const
248
{
249
return
ConstPtr
(
owner_space_
->ColumnScaling());
250
}
251
252
}
// namespace Ipopt
253
254
#endif
Generated on Mon Oct 21 2013 19:08:15 for Ipopt by
1.8.4