Ipopt 3.11.9
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
15namespace Ipopt
16{
17
18 /* forward declarations */
19 class SymScaledMatrixSpace;
20
27 {
28 public:
29
32
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
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
146 {
147 return MakeNewSymScaledMatrix();
148 }
151 virtual Matrix* MakeNew() const
152 {
153 return MakeNewSymScaledMatrix();
154 }
155
158 {
159 return ConstPtr(scaling_);
160 }
161
164 {
166 }
167
168 private:
179
182
186
191 };
192
193 inline
195 {
196 matrix_ = unscaled_matrix;
197 nonconst_matrix_ = NULL;
199 }
200
201 inline
203 {
204 nonconst_matrix_ = unscaled_matrix;
205 matrix_ = GetRawPtr(unscaled_matrix);
207 }
208
209 inline
211 {
212 return matrix_;
213 }
214
215 inline
217 {
220 return nonconst_matrix_;
221 }
222
224 {
225 return ConstPtr(owner_space_->RowColScaling());
226 }
227
228} // namespace Ipopt
229
230#endif
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
Number * x
Input: Starting point Output: Optimal solution.
Class responsible for all message output.
Matrix Base Class.
Definition: IpMatrix.hpp:28
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:183
SymMatrixSpace base class, corresponding to the SymMatrix base class.
Definition: IpSymMatrix.hpp:82
Index Dim() const
Accessor method for the dimension of the matrices in this matrix space.
This is the base class for all derived symmetric matrix types.
Definition: IpSymMatrix.hpp:24
This is the matrix space for SymScaledMatrix.
virtual SymMatrix * MakeNewSymMatrix() const
Overloaded method from SymMatrixSpace.
SmartPtr< const Vector > RowColScaling() const
return the vector for the row and column scaling
SmartPtr< const SymMatrixSpace > UnscaledMatrixSpace() const
return the matrix space for the unscaled matrix
virtual Matrix * MakeNew() const
Overloaded MakeNew method for the MatrixSpace base class.
SymScaledMatrix * MakeNewSymScaledMatrix(bool allocate_unscaled_matrix=false) const
Method for creating a new matrix of this specific type.
SymScaledMatrixSpace & operator=(const SymScaledMatrixSpace &)
Overloaded Equals Operator.
SymScaledMatrixSpace()
Default constructor.
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 totel number of rows and colu...
SmartPtr< const SymMatrixSpace > unscaled_matrix_space_
unscaled matrix space
SmartPtr< Vector > scaling_
Row scaling vector.
SymScaledMatrixSpace(const SymScaledMatrixSpace &)
Copy Constructor.
Class for a Matrix in conjunction with its scaling factors for row and column scaling.
SmartPtr< const Vector > RowColScaling() const
return the vector for the row and column scaling
SymScaledMatrix(const SymScaledMatrix &)
Copy Constructor.
SmartPtr< const SymMatrix > GetUnscaledMatrix() const
Return the unscaled matrix in const form.
void operator=(const SymScaledMatrix &)
Overloaded Equals Operator.
virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix-vector multiply.
void SetUnscaledMatrix(const SmartPtr< const SymMatrix > unscaled_matrix)
Set the unscaled matrix.
SmartPtr< const SymScaledMatrixSpace > owner_space_
Matrix space stored as a SymScaledMatrixSpace.
SymScaledMatrix()
Default Constructor.
virtual void ComputeRowAMaxImpl(Vector &rows_norms, bool init) const
Compute the max-norm of the rows in the matrix.
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.
void SetUnscaledMatrixNonConst(const SmartPtr< SymMatrix > &unscaled_matrix)
Set the unscaled matrix in a non-const version.
SymScaledMatrix(const SymScaledMatrixSpace *owner_space)
Constructor, taking the owner_space.
SmartPtr< const SymMatrix > matrix_
const version of the unscaled matrix
SmartPtr< SymMatrix > GetUnscaledMatrixNonConst()
Return the unscaled matrix in non-const form.
~SymScaledMatrix()
Destructor.
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
SmartPtr< SymMatrix > nonconst_matrix_
non-const version of the unscaled matrix
void ObjectChanged()
Objects derived from TaggedObject MUST call this method every time their internal state changes to up...
Vector Base Class.
Definition: IpVector.hpp:48
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:582
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:589
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:570
EJournalCategory
Category Selection Enum.
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
EJournalLevel
Print Level Enum.
double Number
Type of all numbers.
Definition: IpTypes.hpp:17