Ipopt Documentation  
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 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6 
7 #ifndef __IPSYMSCALEDMATRIX_HPP__
8 #define __IPSYMSCALEDMATRIX_HPP__
9 
10 #include "IpUtils.hpp"
11 #include "IpSymMatrix.hpp"
12 
13 namespace Ipopt
14 {
15 
16 /* forward declarations */
17 class SymScaledMatrixSpace;
18 
27 {
28 public:
30 
34  const SymScaledMatrixSpace* owner_space
35  );
36 
38  ~SymScaledMatrix();
40 
42  void SetUnscaledMatrix(
43  const SmartPtr<const SymMatrix> unscaled_matrix
44  );
45 
47  void SetUnscaledMatrixNonConst(
48  const SmartPtr<SymMatrix>& unscaled_matrix
49  );
50 
52  SmartPtr<const SymMatrix> GetUnscaledMatrix() const;
53 
55  SmartPtr<SymMatrix> GetUnscaledMatrixNonConst();
56 
58  SmartPtr<const Vector> RowColScaling() const;
59 
60 protected:
62  virtual void MultVectorImpl(
64  Number alpha,
65  const Vector& x,
66  Number beta,
67  Vector& y
68  ) const;
69 
70  virtual bool HasValidNumbersImpl() const;
71 
72  virtual void ComputeRowAMaxImpl(
73  Vector& rows_norms,
74  bool init
75  ) const;
76 
77  virtual void PrintImpl(
78  const Journalist& jnlst,
79  EJournalLevel level,
80  EJournalCategory category,
81  const std::string& name,
82  Index indent,
83  const std::string& prefix
84  ) const;
86 
87 private:
96 
99 
102  const SymScaledMatrix&
103  );
104 
106  void operator=(
107  const SymScaledMatrix&
108  );
110 
113 
116 
119 };
120 
124 {
125 public:
127 
132  const SmartPtr<const Vector>& row_col_scaling,
133  bool row_col_scaling_reciprocal,
134  const SmartPtr<const SymMatrixSpace>& unscaled_matrix_space
135  )
136  : SymMatrixSpace(unscaled_matrix_space->Dim()),
137  scaling_(row_col_scaling->MakeNewCopy()),
138  unscaled_matrix_space_(unscaled_matrix_space)
139  {
140  if( row_col_scaling_reciprocal )
141  {
142  scaling_->ElementWiseReciprocal();
143  }
144  }
145 
148  { }
150 
153  bool allocate_unscaled_matrix = false
154  ) const
155  {
156  SymScaledMatrix* ret = new SymScaledMatrix(this);
157  if( allocate_unscaled_matrix )
158  {
159  SmartPtr<SymMatrix> unscaled_matrix = unscaled_matrix_space_->MakeNewSymMatrix();
160  ret->SetUnscaledMatrixNonConst(unscaled_matrix);
161  }
162  return ret;
163  }
164 
165  virtual SymMatrix* MakeNewSymMatrix() const
166  {
167  return MakeNewSymScaledMatrix();
168  }
169 
170  virtual Matrix* MakeNew() const
171  {
172  return MakeNewSymScaledMatrix();
173  }
174 
177  {
178  return ConstPtr(scaling_);
179  }
180 
183  {
184  return unscaled_matrix_space_;
185  }
186 
187 private:
196 
199 
202  const SymScaledMatrixSpace&
203  );
204 
206  SymScaledMatrixSpace& operator=(
207  const SymScaledMatrixSpace&
208  );
210 
213 
216 };
217 
219  const SmartPtr<const SymMatrix> unscaled_matrix
220 )
221 {
222  matrix_ = unscaled_matrix;
223  nonconst_matrix_ = NULL;
224  ObjectChanged();
225 }
226 
228  const SmartPtr<SymMatrix>& unscaled_matrix
229 )
230 {
231  nonconst_matrix_ = unscaled_matrix;
232  matrix_ = GetRawPtr(unscaled_matrix);
233  ObjectChanged();
234 }
235 
237 {
238  return matrix_;
239 }
240 
242 {
244  ObjectChanged();
245  return nonconst_matrix_;
246 }
247 
249 {
250  return ConstPtr(owner_space_->RowColScaling());
251 }
252 
253 } // namespace Ipopt
254 
255 #endif
SymScaledMatrix * MakeNewSymScaledMatrix(bool allocate_unscaled_matrix=false) const
Method for creating a new matrix of this specific type.
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:672
SmartPtr< SymMatrix > nonconst_matrix_
non-const version of the unscaled matrix
#define IPOPTLIB_EXPORT
Definition: config.h:94
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
Class for a Matrix in conjunction with its scaling factors for row and column scaling.
EJournalLevel
Print Level Enum.
void SetUnscaledMatrix(const SmartPtr< const SymMatrix > unscaled_matrix)
Set the unscaled matrix.
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...
This is the base class for all derived symmetric matrix types.
Definition: IpSymMatrix.hpp:20
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:164
SmartPtr< Vector > scaling_
Row scaling vector.
SmartPtr< const Vector > RowColScaling() const
return the vector for the row and column scaling
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:649
Matrix Base Class.
Definition: IpMatrix.hpp:27
SymScaledMatrixSpace(const SmartPtr< const Vector > &row_col_scaling, bool row_col_scaling_reciprocal, const SmartPtr< const SymMatrixSpace > &unscaled_matrix_space)
Constructor, given the number of row and columns blocks, as well as the total number of rows and colu...
ipnumber Number
Type of all numbers.
Definition: IpTypes.hpp:17
SmartPtr< const SymMatrix > matrix_
const version of the unscaled matrix
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:27
This is the matrix space for SymScaledMatrix.
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:663
SymMatrixSpace base class, corresponding to the SymMatrix base class.
Definition: IpSymMatrix.hpp:85
SmartPtr< const SymMatrixSpace > UnscaledMatrixSpace() const
return the matrix space for the unscaled matrix
Class responsible for all message output.
virtual SymMatrix * MakeNewSymMatrix() const
Pure virtual method for creating a new matrix of this specific type.
SmartPtr< SymMatrix > GetUnscaledMatrixNonConst()
Return the unscaled matrix in non-const form.
SmartPtr< const SymMatrix > GetUnscaledMatrix() const
Return the unscaled matrix in const form.
SmartPtr< const Vector > RowColScaling() const
return the vector for the row and column scaling
SmartPtr< const SymMatrixSpace > unscaled_matrix_space_
unscaled matrix space
EJournalCategory
Category Selection Enum.
virtual Matrix * MakeNew() const
Pure virtual method for creating a new Matrix of the corresponding type.
SmartPtr< const SymScaledMatrixSpace > owner_space_
Matrix space stored as a SymScaledMatrixSpace.
void SetUnscaledMatrixNonConst(const SmartPtr< SymMatrix > &unscaled_matrix)
Set the unscaled matrix in a non-const version.