Ipopt Documentation  
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 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6 
7 #ifndef __IPSCALEDMATRIX_HPP__
8 #define __IPSCALEDMATRIX_HPP__
9 
10 #include "IpUtils.hpp"
11 #include "IpMatrix.hpp"
12 
13 namespace Ipopt
14 {
15 
16 /* forward declarations */
17 class ScaledMatrixSpace;
18 
27 {
28 public:
30 
34  const ScaledMatrixSpace* owner_space
35  );
36 
38  ~ScaledMatrix();
40 
42  void SetUnscaledMatrix(
43  const SmartPtr<const Matrix> unscaled_matrix
44  );
45 
47  void SetUnscaledMatrixNonConst(
48  const SmartPtr<Matrix>& unscaled_matrix
49  );
50 
52  SmartPtr<const Matrix> GetUnscaledMatrix() const;
53 
55  SmartPtr<Matrix> GetUnscaledMatrixNonConst();
56 
58  SmartPtr<const Vector> RowScaling() const;
59 
61  SmartPtr<const Vector> ColumnScaling() const;
62 
63 protected:
65  virtual void MultVectorImpl(
67  Number alpha,
68  const Vector& x,
69  Number beta,
70  Vector& y
71  ) const;
72 
73  virtual void TransMultVectorImpl(
74  Number alpha,
75  const Vector& x,
76  Number beta,
77  Vector& y
78  ) const;
79 
80  virtual bool HasValidNumbersImpl() const;
81 
82  virtual void ComputeRowAMaxImpl(
83  Vector& rows_norms,
84  bool init
85  ) const;
86 
87  virtual void ComputeColAMaxImpl(
88  Vector& cols_norms,
89  bool init
90  ) const;
91 
92  virtual void PrintImpl(
93  const Journalist& jnlst,
94  EJournalLevel level,
95  EJournalCategory category,
96  const std::string& name,
97  Index indent,
98  const std::string& prefix
99  ) const;
100 
102  // ToDo Specialized implementation missing so far!
103  virtual void AddMSinvZImpl(
104  Number alpha,
105  const Vector& S,
106  const Vector& Z,
107  Vector& X
108  ) const;
109 
111  // ToDo Specialized implementation missing so far!
112  virtual void SinvBlrmZMTdBrImpl(
113  Number alpha,
114  const Vector& S,
115  const Vector& R,
116  const Vector& Z,
117  const Vector& D,
118  Vector& X
119  ) const;
121 
122 private:
131 
133  ScaledMatrix();
134 
136  ScaledMatrix(
137  const ScaledMatrix&
138  );
139 
141  void operator=(
142  const ScaledMatrix&
143  );
145 
148 
151 
154 };
155 
158 {
159 public:
161 
166  const SmartPtr<const Vector>& row_scaling,
167  bool row_scaling_reciprocal,
168  const SmartPtr<const MatrixSpace>& unscaled_matrix_space,
169  const SmartPtr<const Vector>& column_scaling,
170  bool column_scaling_reciprocal
171  );
172 
175  { }
177 
180  bool allocate_unscaled_matrix = false
181  ) const
182  {
183  ScaledMatrix* ret = new ScaledMatrix(this);
184  if( allocate_unscaled_matrix )
185  {
186  SmartPtr<Matrix> unscaled_matrix = unscaled_matrix_space_->MakeNew();
187  ret->SetUnscaledMatrixNonConst(unscaled_matrix);
188  }
189  return ret;
190  }
191 
192  virtual Matrix* MakeNew() const
193  {
194  return MakeNewScaledMatrix();
195  }
196 
199  {
200  return ConstPtr(row_scaling_);
201  }
202 
205  {
206  return unscaled_matrix_space_;
207  }
208 
211  {
212  return ConstPtr(column_scaling_);
213  }
214 
215 private:
224 
227 
230  const ScaledMatrixSpace&
231  );
232 
234  ScaledMatrixSpace& operator=(
235  const ScaledMatrixSpace&
236  );
238 
241 
244 
247 };
248 
250  const SmartPtr<const Matrix> unscaled_matrix
251 )
252 {
253  matrix_ = unscaled_matrix;
254  nonconst_matrix_ = NULL;
255  ObjectChanged();
256 }
257 
259  const SmartPtr<Matrix>& unscaled_matrix
260 )
261 {
262  nonconst_matrix_ = unscaled_matrix;
263  matrix_ = GetRawPtr(unscaled_matrix);
264  ObjectChanged();
265 }
266 
268 {
269  return matrix_;
270 }
271 
273 {
275  ObjectChanged();
276  return nonconst_matrix_;
277 }
278 
280 {
281  return ConstPtr(owner_space_->RowScaling());
282 }
283 
285 {
286  return ConstPtr(owner_space_->ColumnScaling());
287 }
288 
289 } // namespace Ipopt
290 
291 #endif
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:672
SmartPtr< const ScaledMatrixSpace > owner_space_
Matrix space stored as a ScaledMatrixSpace.
ScaledMatrix * MakeNewScaledMatrix(bool allocate_unscaled_matrix=false) const
Method for creating a new matrix of this specific type.
#define IPOPTLIB_EXPORT
Definition: config.h:94
Class for a Matrix in conjunction with its scaling factors for row and column scaling.
SmartPtr< Vector > row_scaling_
Row scaling vector.
void ObjectChanged()
Objects derived from TaggedObject MUST call this method every time their internal state changes to up...
Vector Base Class.
Definition: IpVector.hpp:47
SmartPtr< const Vector > ColumnScaling() const
return the vector for the column scaling
EJournalLevel
Print Level Enum.
ipindex Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:20
This file contains a base class for all exceptions and a set of macros to help with exceptions...
~ScaledMatrixSpace()
Destructor.
This is the matrix space for ScaledMatrix.
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:164
SmartPtr< const Vector > ColumnScaling() const
return the vector for the column scaling
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:649
void SetUnscaledMatrixNonConst(const SmartPtr< Matrix > &unscaled_matrix)
Set the unscaled matrix in a non-const version.
Matrix Base Class.
Definition: IpMatrix.hpp:27
SmartPtr< Matrix > GetUnscaledMatrixNonConst()
Return the unscaled matrix in non-const form.
SmartPtr< const Vector > RowScaling() const
return the vector for the row scaling
MatrixSpace base class, corresponding to the Matrix base class.
Definition: IpMatrix.hpp:326
SmartPtr< const MatrixSpace > UnscaledMatrixSpace() const
return the matrix space for the unscaled matrix
ipnumber Number
Type of all numbers.
Definition: IpTypes.hpp:17
SmartPtr< const Vector > RowScaling() const
return the vector for the row scaling
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:27
SmartPtr< const MatrixSpace > unscaled_matrix_space_
unscaled matrix space
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:663
Class responsible for all message output.
SmartPtr< Matrix > nonconst_matrix_
non-const version of the unscaled matrix
SmartPtr< const Matrix > GetUnscaledMatrix() const
Return the unscaled matrix in const form.
void SetUnscaledMatrix(const SmartPtr< const Matrix > unscaled_matrix)
Set the unscaled matrix.
SmartPtr< const Matrix > matrix_
const version of the unscaled matrix
EJournalCategory
Category Selection Enum.
SmartPtr< Vector > column_scaling_
column scaling vector
virtual Matrix * MakeNew() const
Pure virtual method for creating a new Matrix of the corresponding type.