Ipopt  3.11.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 
40 
42  void SetUnscaledMatrix(const SmartPtr<const SymMatrix> unscaled_matrix);
43 
45  void SetUnscaledMatrixNonConst(const SmartPtr<SymMatrix>& unscaled_matrix);
46 
49 
52 
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:
88 
91 
93  void operator=(const SymScaledMatrix&);
95 
100 
103  };
104 
108  {
109  public:
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 
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 
158  {
159  return ConstPtr(scaling_);
160  }
161 
164  {
165  return unscaled_matrix_space_;
166  }
167 
168  private:
179 
182 
186 
191  };
192 
193  inline
195  {
196  matrix_ = unscaled_matrix;
197  nonconst_matrix_ = NULL;
198  ObjectChanged();
199  }
200 
201  inline
203  {
204  nonconst_matrix_ = unscaled_matrix;
205  matrix_ = GetRawPtr(unscaled_matrix);
206  ObjectChanged();
207  }
208 
209  inline
211  {
212  return matrix_;
213  }
214 
215  inline
217  {
219  ObjectChanged();
220  return nonconst_matrix_;
221  }
222 
224  {
225  return ConstPtr(owner_space_->RowColScaling());
226  }
227 
228 } // namespace Ipopt
229 
230 #endif