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
IpSymScaledMatrix.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: IpSymScaledMatrix.hpp 1861 2010-12-21 21:34:47Z andreasw $
6
//
7
// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9
#ifndef __IPSYMSCALEDMATRIX_HPP__
10
#define __IPSYMSCALEDMATRIX_HPP__
11
12
#include "
IpUtils.hpp
"
13
#include "
IpSymMatrix.hpp
"
14
15
namespace
Ipopt
16
{
17
18
/* forward declarations */
19
class
SymScaledMatrixSpace;
20
26
class
SymScaledMatrix
:
public
SymMatrix
27
{
28
public
:
29
32
35
SymScaledMatrix
(
const
SymScaledMatrixSpace
* owner_space);
36
38
~SymScaledMatrix
();
40
42
void
SetUnscaledMatrix
(
const
SmartPtr<const SymMatrix>
unscaled_matrix);
43
45
void
SetUnscaledMatrixNonConst
(
const
SmartPtr<SymMatrix>
& unscaled_matrix);
46
48
SmartPtr<const SymMatrix>
GetUnscaledMatrix
()
const
;
49
51
SmartPtr<SymMatrix>
GetUnscaledMatrixNonConst
();
52
54
SmartPtr<const Vector>
RowColScaling
()
const
;
55
56
protected
:
59
virtual
void
MultVectorImpl
(
Number
alpha,
const
Vector
&
x
,
60
Number
beta,
Vector
& y)
const
;
61
65
virtual
bool
HasValidNumbersImpl
()
const
;
66
67
virtual
void
ComputeRowAMaxImpl
(
Vector
& rows_norms,
bool
init)
const
;
68
69
virtual
void
PrintImpl
(
const
Journalist
& jnlst,
70
EJournalLevel
level,
71
EJournalCategory
category,
72
const
std::string& name,
73
Index
indent,
74
const
std::string& prefix)
const
;
76
77
private
:
87
SymScaledMatrix
();
88
90
SymScaledMatrix
(
const
SymScaledMatrix
&);
91
93
void
operator=
(
const
SymScaledMatrix
&);
95
97
SmartPtr<const SymMatrix>
matrix_
;
99
SmartPtr<SymMatrix>
nonconst_matrix_
;
100
102
SmartPtr<const SymScaledMatrixSpace>
owner_space_
;
103
};
104
107
class
SymScaledMatrixSpace
:
public
SymMatrixSpace
108
{
109
public
:
115
SymScaledMatrixSpace
(
const
SmartPtr<const Vector>
& row_col_scaling,
116
bool
row_col_scaling_reciprocal,
117
const
SmartPtr<const SymMatrixSpace>
& unscaled_matrix_space)
118
:
119
SymMatrixSpace
(unscaled_matrix_space->
Dim
()),
120
unscaled_matrix_space_
(unscaled_matrix_space)
121
{
122
scaling_
= row_col_scaling->MakeNewCopy();
123
if
(row_col_scaling_reciprocal) {
124
scaling_
->ElementWiseReciprocal();
125
}
126
}
127
129
~SymScaledMatrixSpace
()
130
{}
132
134
SymScaledMatrix
*
MakeNewSymScaledMatrix
(
bool
allocate_unscaled_matrix =
false
)
const
135
{
136
SymScaledMatrix
* ret =
new
SymScaledMatrix
(
this
);
137
if
(allocate_unscaled_matrix) {
138
SmartPtr<SymMatrix>
unscaled_matrix =
unscaled_matrix_space_
->MakeNewSymMatrix();
139
ret->
SetUnscaledMatrixNonConst
(unscaled_matrix);
140
}
141
return
ret;
142
}
143
145
virtual
SymMatrix
*
MakeNewSymMatrix
()
const
146
{
147
return
MakeNewSymScaledMatrix
();
148
}
151
virtual
Matrix
*
MakeNew
()
const
152
{
153
return
MakeNewSymScaledMatrix
();
154
}
155
157
SmartPtr<const Vector>
RowColScaling
()
const
158
{
159
return
ConstPtr
(
scaling_
);
160
}
161
163
SmartPtr<const SymMatrixSpace>
UnscaledMatrixSpace
()
const
164
{
165
return
unscaled_matrix_space_
;
166
}
167
168
private
:
178
SymScaledMatrixSpace
();
179
181
SymScaledMatrixSpace
(
const
SymScaledMatrixSpace
&);
182
184
SymScaledMatrixSpace
&
operator=
(
const
SymScaledMatrixSpace
&);
186
188
SmartPtr<Vector>
scaling_
;
190
SmartPtr<const SymMatrixSpace>
unscaled_matrix_space_
;
191
};
192
193
inline
194
void
SymScaledMatrix::SetUnscaledMatrix
(
const
SmartPtr<const SymMatrix>
unscaled_matrix)
195
{
196
matrix_
= unscaled_matrix;
197
nonconst_matrix_
= NULL;
198
ObjectChanged
();
199
}
200
201
inline
202
void
SymScaledMatrix::SetUnscaledMatrixNonConst
(
const
SmartPtr<SymMatrix>
& unscaled_matrix)
203
{
204
nonconst_matrix_
= unscaled_matrix;
205
matrix_
=
GetRawPtr
(unscaled_matrix);
206
ObjectChanged
();
207
}
208
209
inline
210
SmartPtr<const SymMatrix>
SymScaledMatrix::GetUnscaledMatrix
()
const
211
{
212
return
matrix_
;
213
}
214
215
inline
216
SmartPtr<SymMatrix>
SymScaledMatrix::GetUnscaledMatrixNonConst
()
217
{
218
DBG_ASSERT
(
IsValid
(
nonconst_matrix_
));
219
ObjectChanged
();
220
return
nonconst_matrix_
;
221
}
222
223
inline
SmartPtr<const Vector>
SymScaledMatrix::RowColScaling
()
const
224
{
225
return
ConstPtr
(
owner_space_
->RowColScaling());
226
}
227
228
}
// namespace Ipopt
229
230
#endif
Generated on Mon Oct 21 2013 19:08:15 for Ipopt by
1.8.4