Ipopt 3.11.9
Loading...
Searching...
No Matches
IpCompoundSymMatrix.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: IpCompoundSymMatrix.hpp 1861 2010-12-21 21:34:47Z andreasw $
6//
7// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9#ifndef __IPCOMPOUNDSYMMATRIX_HPP__
10#define __IPCOMPOUNDSYMMATRIX_HPP__
11
12#include "IpUtils.hpp"
13#include "IpSymMatrix.hpp"
14
15namespace Ipopt
16{
17
18 /* forward declarations */
19 class CompoundSymMatrixSpace;
20
25 {
26 public:
27
30
37
41
46 void SetComp(Index irow, Index jcol, const Matrix& matrix);
47
49 void SetCompNonConst(Index irow, Index jcol, Matrix& matrix);
50
55 {
56 return ConstComp(irow,jcol);
57 }
58
63 {
65 return Comp(irow,jcol);
66 }
67
70
71 // The following don't seem to be necessary
72 /* Number of block rows of this compound matrix. */
73 // Index NComps_NRows() const { return NComps_Dim(); }
74
75 /* Number of block colmuns of this compound matrix. */
76 // Index NComps_NCols() const { return NComps_Dim(); }
77
80
81 protected:
84 virtual void MultVectorImpl(Number alpha, const Vector& x,
85 Number beta, Vector& y) const;
86
89 virtual bool HasValidNumbersImpl() const;
90
91 virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const;
92
93 virtual void PrintImpl(const Journalist& jnlst,
94 EJournalLevel level,
95 EJournalCategory category,
96 const std::string& name,
97 Index indent,
98 const std::string& prefix) const;
100
101 private:
112
115
119
121 std::vector<std::vector<SmartPtr<Matrix> > > comps_;
122
124 std::vector<std::vector<SmartPtr<const Matrix> > > const_comps_;
125
128
130 mutable bool matrices_valid_;
131
133 bool MatricesValid() const;
134
136 const Matrix* ConstComp(Index irow, Index jcol) const
137 {
138 DBG_ASSERT(irow < NComps_Dim());
139 DBG_ASSERT(jcol <= irow);
140 if (IsValid(comps_[irow][jcol])) {
141 return GetRawPtr(comps_[irow][jcol]);
142 }
143 else if (IsValid(const_comps_[irow][jcol])) {
144 return GetRawPtr(const_comps_[irow][jcol]);
145 }
146
147 return NULL;
148 }
149
151 Matrix* Comp(Index irow, Index jcol)
152 {
153 DBG_ASSERT(irow < NComps_Dim());
154 DBG_ASSERT(jcol <= irow);
155 // We shouldn't be asking for a non-const if this entry holds a
156 // const one...
157 DBG_ASSERT(IsNull(const_comps_[irow][jcol]));
158 if (IsValid(comps_[irow][jcol])) {
159 return GetRawPtr(comps_[irow][jcol]);
160 }
161
162 return NULL;
163 }
164 };
165
172 {
173 public:
179 CompoundSymMatrixSpace(Index ncomp_spaces, Index total_dim);
180
185
189 void SetBlockDim(Index irow_jcol, Index dim);
190
192 Index GetBlockDim(Index irow_jcol) const;
193
200 void SetCompSpace(Index irow, Index jcol,
201 const MatrixSpace& mat_space,
202 bool auto_allocate = false);
204
209 {
211 DBG_ASSERT(jcol<=irow);
212 return comp_spaces_[irow][jcol];
213 }
214
218 {
219 return ncomp_spaces_;
220 }
222
225
229 {
231 }
232
233 private:
244
247
251
254
259 std::vector<Index> block_dim_;
260
263 std::vector<std::vector<SmartPtr<const MatrixSpace> > > comp_spaces_;
264
267 std::vector<std::vector< bool > > allocate_block_;
268
270 mutable bool dimensions_set_;
271
273 bool DimensionsSet() const;
274 };
275
276 inline
281
282} // namespace Ipopt
283#endif
#define DBG_ASSERT(test)
Definition IpDebug.hpp:38
Number * x
Input: Starting point Output: Optimal solution.
This is the matrix space for CompoundSymMatrix.
std::vector< std::vector< bool > > allocate_block_
2-dim std::vector of booleans deciding whether to allocate a new matrix for the blocks automagically
CompoundSymMatrixSpace(const CompoundSymMatrix &)
Copy Constructor.
CompoundSymMatrixSpace()
Default constructor.
Index ncomp_spaces_
Number of components per row and column.
void SetBlockDim(Index irow_jcol, Index dim)
Set the dimension dim for block row (or column) irow_jcol.
SmartPtr< const MatrixSpace > GetCompSpace(Index irow, Index jcol) const
Obtain the component MatrixSpace in block row irow and block column jcol.
virtual SymMatrix * MakeNewSymMatrix() const
Overloaded MakeNew method for the SymMatrixSpace base class.
bool dimensions_set_
boolean indicating if the compound matrix space is in a "valid" state
CompoundSymMatrixSpace(Index ncomp_spaces, Index total_dim)
Constructor, given the number of blocks (same for rows and columns), as well as the total dimension o...
void SetCompSpace(Index irow, Index jcol, const MatrixSpace &mat_space, bool auto_allocate=false)
Set the component SymMatrixSpace.
Index GetBlockDim(Index irow_jcol) const
Get the dimension dim for block row (or column) irow_jcol.
CompoundSymMatrix * MakeNewCompoundSymMatrix() const
Method for creating a new matrix of this specific type.
std::vector< std::vector< SmartPtr< const MatrixSpace > > > comp_spaces_
2-dim std::vector of matrix spaces for the components.
std::vector< Index > block_dim_
Vector of the number of rows in each comp column, Since this is symmetric, this is also the number of...
bool DimensionsSet() const
Method to check whether or not the spaces are valid.
CompoundSymMatrixSpace & operator=(const CompoundSymMatrixSpace &)
Overloaded Equals Operator.
Class for symmetric matrices consisting of other matrices.
SmartPtr< CompoundSymMatrix > MakeNewCompoundSymMatrix() const
Method for creating a new matrix of this specific type.
void SetCompNonConst(Index irow, Index jcol, Matrix &matrix)
Non const version of the same method.
Index NComps_Dim() const
Number of block rows and columns.
virtual void ComputeRowAMaxImpl(Vector &rows_norms, bool init) const
Compute the max-norm of the rows in the matrix.
SmartPtr< Matrix > GetCompNonConst(Index irow, Index jcol)
Non const version of GetComp.
std::vector< std::vector< SmartPtr< const Matrix > > > const_comps_
Vector of vectors containing the const components.
CompoundSymMatrix()
Default Constructor.
virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix-vector multiply.
void SetComp(Index irow, Index jcol, const Matrix &matrix)
Method for setting an individual component at position (irow, icol) in the compound matrix.
void operator=(const CompoundSymMatrix &)
Overloaded Equals Operator.
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.
std::vector< std::vector< SmartPtr< Matrix > > > comps_
Vector of vectors containing the components.
const CompoundSymMatrixSpace * owner_space_
Copy of the owner_space ptr as a CompoundSymMatrixSpace.
Matrix * Comp(Index irow, Index jcol)
Internal method to return a non-const pointer to one of the comps.
const Matrix * ConstComp(Index irow, Index jcol) const
Internal method to return a const pointer to one of the comps.
SmartPtr< const Matrix > GetComp(Index irow, Index jcol) const
Method for retrieving one block from the compound matrix.
CompoundSymMatrix(const CompoundSymMatrixSpace *owner_space)
Constructor, taking only the number for block components into the row and column direction.
CompoundSymMatrix(const CompoundSymMatrix &)
Copy Constructor.
bool MatricesValid() const
method to check wether or not the matrices are valid
~CompoundSymMatrix()
Destructor.
bool matrices_valid_
boolean indicating if the compound matrix is in a "valid" state
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Class responsible for all message output.
MatrixSpace base class, corresponding to the Matrix base class.
Definition IpMatrix.hpp:240
Matrix Base Class.
Definition IpMatrix.hpp:28
Template class for Smart Pointers.
SymMatrixSpace base class, corresponding to the SymMatrix base class.
This is the base class for all derived symmetric matrix types.
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
bool IsValid(const SmartPtr< U > &smart_ptr)
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
EJournalCategory
Category Selection Enum.
int Index
Type of all indices of vectors, matrices etc.
Definition IpTypes.hpp:19
EJournalLevel
Print Level Enum.
bool IsNull(const SmartPtr< U > &smart_ptr)
double Number
Type of all numbers.
Definition IpTypes.hpp:17