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:
34  const ScaledMatrixSpace* owner_space
35  );
36 
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:
66  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 
105  virtual void AddMSinvZImpl(
106  Number alpha,
107  const Vector& S,
108  const Vector& Z,
109  Vector& X
110  ) const;
111 
116  virtual void SinvBlrmZMTdBrImpl(
117  Number alpha,
118  const Vector& S,
119  const Vector& R,
120  const Vector& Z,
121  const Vector& D,
122  Vector& X
123  ) const;
125 
126 private:
138 
141  const ScaledMatrix&
142  );
143 
145  void operator=(
146  const ScaledMatrix&
147  );
149 
152 
155 
158 };
159 
162 {
163 public:
170  const SmartPtr<const Vector>& row_scaling,
171  bool row_scaling_reciprocal,
172  const SmartPtr<const MatrixSpace>& unscaled_matrix_space,
173  const SmartPtr<const Vector>& column_scaling,
174  bool column_scaling_reciprocal
175  );
176 
179  { }
181 
184  bool allocate_unscaled_matrix = false
185  ) const
186  {
187  ScaledMatrix* ret = new ScaledMatrix(this);
188  if( allocate_unscaled_matrix )
189  {
190  SmartPtr<Matrix> unscaled_matrix = unscaled_matrix_space_->MakeNew();
191  ret->SetUnscaledMatrixNonConst(unscaled_matrix);
192  }
193  return ret;
194  }
195 
196  virtual Matrix* MakeNew() const
197  {
198  return MakeNewScaledMatrix();
199  }
200 
203  {
204  return ConstPtr(row_scaling_);
205  }
206 
209  {
210  return unscaled_matrix_space_;
211  }
212 
215  {
216  return ConstPtr(column_scaling_);
217  }
218 
219 private:
231 
234  const ScaledMatrixSpace&
235  );
236 
239  const ScaledMatrixSpace&
240  );
242 
245 
248 
251 };
252 
254  const SmartPtr<const Matrix> unscaled_matrix
255 )
256 {
257  matrix_ = unscaled_matrix;
258  nonconst_matrix_ = NULL;
259  ObjectChanged();
260 }
261 
263  const SmartPtr<Matrix>& unscaled_matrix
264 )
265 {
266  nonconst_matrix_ = unscaled_matrix;
267  matrix_ = GetRawPtr(unscaled_matrix);
268  ObjectChanged();
269 }
270 
272 {
273  return matrix_;
274 }
275 
277 {
279  ObjectChanged();
280  return nonconst_matrix_;
281 }
282 
284 {
285  return ConstPtr(owner_space_->RowScaling());
286 }
287 
289 {
290  return ConstPtr(owner_space_->ColumnScaling());
291 }
292 
293 } // namespace Ipopt
294 
295 #endif
Ipopt::ScaledMatrixSpace::MakeNew
virtual Matrix * MakeNew() const
Pure virtual method for creating a new Matrix of the corresponding type.
Definition: IpScaledMatrix.hpp:196
Ipopt::ScaledMatrixSpace::MakeNewScaledMatrix
ScaledMatrix * MakeNewScaledMatrix(bool allocate_unscaled_matrix=false) const
Method for creating a new matrix of this specific type.
Definition: IpScaledMatrix.hpp:183
IpUtils.hpp
Ipopt::ScaledMatrixSpace::UnscaledMatrixSpace
SmartPtr< const MatrixSpace > UnscaledMatrixSpace() const
return the matrix space for the unscaled matrix
Definition: IpScaledMatrix.hpp:208
Ipopt::MatrixSpace
MatrixSpace base class, corresponding to the Matrix base class.
Definition: IpMatrix.hpp:327
Ipopt::ScaledMatrixSpace::ScaledMatrixSpace
ScaledMatrixSpace(const SmartPtr< const Vector > &row_scaling, bool row_scaling_reciprocal, const SmartPtr< const MatrixSpace > &unscaled_matrix_space, const SmartPtr< const Vector > &column_scaling, bool column_scaling_reciprocal)
Constructor, given the number of row and columns blocks, as well as the totel number of rows and colu...
Ipopt::ScaledMatrix
Class for a Matrix in conjunction with its scaling factors for row and column scaling.
Definition: IpScaledMatrix.hpp:27
Ipopt::ScaledMatrixSpace::ColumnScaling
SmartPtr< const Vector > ColumnScaling() const
return the vector for the column scaling
Definition: IpScaledMatrix.hpp:214
Ipopt::ScaledMatrix::operator=
void operator=(const ScaledMatrix &)
Default Assignment Operator.
Ipopt::ScaledMatrixSpace::unscaled_matrix_space_
SmartPtr< const MatrixSpace > unscaled_matrix_space_
unscaled matrix space
Definition: IpScaledMatrix.hpp:247
Ipopt::ScaledMatrix::ComputeRowAMaxImpl
virtual void ComputeRowAMaxImpl(Vector &rows_norms, bool init) const
Compute the max-norm of the rows in the matrix.
Ipopt::ScaledMatrix::PrintImpl
virtual void PrintImpl(const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent, const std::string &prefix) const
Print detailed information about the matrix.
Ipopt::ScaledMatrix::matrix_
SmartPtr< const Matrix > matrix_
const version of the unscaled matrix
Definition: IpScaledMatrix.hpp:151
Ipopt::ScaledMatrixSpace::row_scaling_
SmartPtr< Vector > row_scaling_
Row scaling vector.
Definition: IpScaledMatrix.hpp:244
Ipopt
This file contains a base class for all exceptions and a set of macros to help with exceptions.
Definition: IpInexactAlgBuilder.hpp:14
Ipopt::Number
double Number
Type of all numbers.
Definition: IpTypes.hpp:15
Ipopt::Matrix
Matrix Base Class.
Definition: IpMatrix.hpp:28
Ipopt::ScaledMatrix::ScaledMatrix
ScaledMatrix(const ScaledMatrix &)
Copy Constructor.
Ipopt::ScaledMatrix::ComputeColAMaxImpl
virtual void ComputeColAMaxImpl(Vector &cols_norms, bool init) const
Compute the max-norm of the columns in the matrix.
Ipopt::ScaledMatrix::SetUnscaledMatrixNonConst
void SetUnscaledMatrixNonConst(const SmartPtr< Matrix > &unscaled_matrix)
Set the unscaled matrix in a non-const version.
Definition: IpScaledMatrix.hpp:262
Ipopt::TaggedObject::ObjectChanged
void ObjectChanged()
Objects derived from TaggedObject MUST call this method every time their internal state changes to up...
Ipopt::ScaledMatrix::nonconst_matrix_
SmartPtr< Matrix > nonconst_matrix_
non-const version of the unscaled matrix
Definition: IpScaledMatrix.hpp:154
Ipopt::EJournalLevel
EJournalLevel
Print Level Enum.
Definition: IpJournalist.hpp:32
Ipopt::ScaledMatrix::ScaledMatrix
ScaledMatrix(const ScaledMatrixSpace *owner_space)
Constructor, taking the owner_space.
Ipopt::ScaledMatrix::SetUnscaledMatrix
void SetUnscaledMatrix(const SmartPtr< const Matrix > unscaled_matrix)
Set the unscaled matrix.
Definition: IpScaledMatrix.hpp:253
IPOPTLIB_EXPORT
#define IPOPTLIB_EXPORT
Definition: config_default.h:16
Ipopt::ScaledMatrix::GetUnscaledMatrixNonConst
SmartPtr< Matrix > GetUnscaledMatrixNonConst()
Return the unscaled matrix in non-const form.
Definition: IpScaledMatrix.hpp:276
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
Ipopt::GetRawPtr
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:651
Ipopt::SmartPtr
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
Ipopt::ScaledMatrix::ColumnScaling
SmartPtr< const Vector > ColumnScaling() const
return the vector for the column scaling
Definition: IpScaledMatrix.hpp:288
Ipopt::ScaledMatrix::AddMSinvZImpl
virtual void AddMSinvZImpl(Number alpha, const Vector &S, const Vector &Z, Vector &X) const
X = beta*X + alpha*(Matrix S^{-1} Z).
Ipopt::EJournalCategory
EJournalCategory
Category Selection Enum.
Definition: IpJournalist.hpp:52
Ipopt::ScaledMatrix::HasValidNumbersImpl
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Ipopt::ScaledMatrix::TransMultVectorImpl
virtual void TransMultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix(transpose) vector multiply.
Ipopt::ScaledMatrixSpace::RowScaling
SmartPtr< const Vector > RowScaling() const
return the vector for the row scaling
Definition: IpScaledMatrix.hpp:202
Ipopt::ScaledMatrix::MultVectorImpl
virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix-vector multiply.
Ipopt::ScaledMatrixSpace::ScaledMatrixSpace
ScaledMatrixSpace()
Default constructor.
Ipopt::ScaledMatrix::ScaledMatrix
ScaledMatrix()
Default Constructor.
Ipopt::ConstPtr
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:665
Ipopt::ScaledMatrix::SinvBlrmZMTdBrImpl
virtual void SinvBlrmZMTdBrImpl(Number alpha, const Vector &S, const Vector &R, const Vector &Z, const Vector &D, Vector &X) const
X = S^{-1} (r + alpha*Z*M^Td).
Ipopt::Journalist
Class responsible for all message output.
Definition: IpJournalist.hpp:117
Ipopt::ScaledMatrixSpace
This is the matrix space for ScaledMatrix.
Definition: IpScaledMatrix.hpp:162
Ipopt::ScaledMatrixSpace::~ScaledMatrixSpace
~ScaledMatrixSpace()
Destructor.
Definition: IpScaledMatrix.hpp:178
Ipopt::ScaledMatrix::~ScaledMatrix
~ScaledMatrix()
Destructor.
Ipopt::ScaledMatrixSpace::operator=
ScaledMatrixSpace & operator=(const ScaledMatrixSpace &)
Default Assignment Operator.
Ipopt::ScaledMatrixSpace::ScaledMatrixSpace
ScaledMatrixSpace(const ScaledMatrixSpace &)
Copy Constructor.
Ipopt::ScaledMatrix::owner_space_
SmartPtr< const ScaledMatrixSpace > owner_space_
Matrix space stored as a ScaledMatrixSpace.
Definition: IpScaledMatrix.hpp:157
IpMatrix.hpp
Ipopt::IsValid
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:674
DBG_ASSERT
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:28
Ipopt::ScaledMatrixSpace::column_scaling_
SmartPtr< Vector > column_scaling_
column scaling vector
Definition: IpScaledMatrix.hpp:250
Ipopt::ScaledMatrix::GetUnscaledMatrix
SmartPtr< const Matrix > GetUnscaledMatrix() const
Return the unscaled matrix in const form.
Definition: IpScaledMatrix.hpp:271
Ipopt::ScaledMatrix::RowScaling
SmartPtr< const Vector > RowScaling() const
return the vector for the row scaling
Definition: IpScaledMatrix.hpp:283
Ipopt::Vector
Vector Base Class.
Definition: IpVector.hpp:48