Ipopt 3.12.10

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpGenTMatrix.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2009 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpGenTMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9 #ifndef __IPGENTMATRIX_HPP__
10 #define __IPGENTMATRIX_HPP__
11
12 #include "IpUtils.hpp"
13 #include "IpMatrix.hpp"
14
15 namespace Ipopt
16 {
17
18 /* forward declarations */
19 class GenTMatrixSpace;
20
36 class GenTMatrix : public Matrix
37 {
38 public:
39
42
45 GenTMatrix(const GenTMatrixSpace* owner_space);
46
48 ~GenTMatrix();
50
58 void SetValues(const Number* Values);
60
64 Index Nonzeros() const;
65
67 const Index* Irows() const;
68
70 const Index* Jcols() const;
71
73 const Number* Values() const
74 {
75 return values_;
76 }
77
82 Number* Values()
83 {
84 ObjectChanged();
85 initialized_ = true;
86 return values_;
87 }
89
90 protected:
93 virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta,
94 Vector &y) const;
95
96 virtual void TransMultVectorImpl(Number alpha, const Vector& x, Number beta,
97 Vector& y) const;
98
101 virtual bool HasValidNumbersImpl() const;
102
103 virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const;
104
105 virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const;
106
107 virtual void PrintImpl(const Journalist& jnlst,
108 EJournalLevel level,
109 EJournalCategory category,
110 const std::string& name,
111 Index indent,
112 const std::string& prefix) const
113 {
114 PrintImplOffset(jnlst, level, category, name, indent, prefix, 0);
115 }
117
118 void PrintImplOffset(const Journalist& jnlst,
119 EJournalLevel level,
120 EJournalCategory category,
121 const std::string& name,
122 Index indent,
123 const std::string& prefix,
124 Index offset) const;
125
126 friend class ParGenMatrix;
127
128 private:
138 GenTMatrix();
139
141 GenTMatrix(const GenTMatrix&);
142
144 void operator=(const GenTMatrix&);
146
150 const GenTMatrixSpace* owner_space_;
151
153 Number* values_;
154
156 bool initialized_;
157
158 };
159
164 class GenTMatrixSpace : public MatrixSpace
165 {
166 public:
176 GenTMatrixSpace(Index nRows, Index nCols,
177 Index nonZeros,
178 const Index* iRows, const Index* jCols);
179
181 ~GenTMatrixSpace()
182 {
183 delete [] iRows_;
184 delete [] jCols_;
185 }
187
189 GenTMatrix* MakeNewGenTMatrix() const
190 {
191 return new GenTMatrix(this);
192 }
193
196 virtual Matrix* MakeNew() const
197 {
198 return MakeNewGenTMatrix();
199 }
200
204 Index Nonzeros() const
205 {
206 return nonZeros_;
207 }
208
210 const Index* Irows() const
211 {
212 return iRows_;
213 }
214
216 const Index* Jcols() const
217 {
218 return jCols_;
219 }
221
222 private:
227 const Index nonZeros_;
228 Index* jCols_;
229 Index* iRows_;
231
234 Number* AllocateInternalStorage() const;
235
238 void FreeInternalStorage(Number* values) const;
239
240 friend class GenTMatrix;
241 };
242
243 /* inline methods */
244 inline
245 Index GenTMatrix::Nonzeros() const
246 {
247 return owner_space_->Nonzeros();
248 }
249
250 inline
251 const Index* GenTMatrix::Irows() const
252 {
253 return owner_space_->Irows();
254 }
255
256 inline
257 const Index* GenTMatrix::Jcols() const
258 {
259 return owner_space_->Jcols();
260 }
261
262
263 } // namespace Ipopt
264 #endif
Ipopt::GenTMatrixSpace::FreeInternalStorage
void FreeInternalStorage(Number *values) const
This method is only for the GenTMatrix to call in order to de-allocate internal storage.
x
Number * x
Input: Starting point Output: Optimal solution.
Definition: IpStdCInterface.h:238
Ipopt::GenTMatrix::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.
Definition: IpGenTMatrix.hpp:107
IpUtils.hpp
Ipopt::GenTMatrixSpace
This is the matrix space for a GenTMatrix with fixed sparsity structure.
Definition: IpGenTMatrix.hpp:164
Ipopt::GenTMatrix::operator=
void operator=(const GenTMatrix &)
Overloaded Equals Operator.
Ipopt::GenTMatrix::GenTMatrix
GenTMatrix()
Default Constructor.
Ipopt::GenTMatrixSpace::Irows
const Index * Irows() const
Row index of each non-zero element (counting starts at 1)
Definition: IpGenTMatrix.hpp:210
Ipopt::Number
double Number
Type of all numbers.
Definition: IpTypes.hpp:17
Ipopt::TaggedObject::ObjectChanged
void ObjectChanged()
Objects derived from TaggedObject MUST call this method every time their internal state changes to up...
Definition: IpTaggedObject.hpp:117
Ipopt::Vector
Vector Base Class.
Definition: IpVector.hpp:47
Ipopt::GenTMatrixSpace::jCols_
Index * jCols_
Definition: IpGenTMatrix.hpp:228
Ipopt::GenTMatrixSpace::AllocateInternalStorage
Number * AllocateInternalStorage() const
This method is only for the GenTMatrix to call in order to allocate internal storage.
Ipopt::GenTMatrix::ComputeRowAMaxImpl
virtual void ComputeRowAMaxImpl(Vector &rows_norms, bool init) const
Compute the max-norm of the rows in the matrix.
IpMatrix.hpp
Ipopt::EJournalLevel
EJournalLevel
Print Level Enum.
Definition: IpJournalist.hpp:51
Ipopt::GenTMatrixSpace::MakeNew
virtual Matrix * MakeNew() const
Overloaded MakeNew method for the MatrixSpace base class.
Definition: IpGenTMatrix.hpp:196
Ipopt::GenTMatrix::Values
const Number * Values() const
Array with nonzero values (const version).
Definition: IpGenTMatrix.hpp:73
Ipopt::GenTMatrix::TransMultVectorImpl
virtual void TransMultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix(transpose) vector multiply.
Ipopt::GenTMatrixSpace::Nonzeros
Index Nonzeros() const
Number of non-zeros in the sparse matrix.
Definition: IpGenTMatrix.hpp:204
Ipopt::GenTMatrix::~GenTMatrix
~GenTMatrix()
Destructor.
Ipopt::GenTMatrix::Jcols
const Index * Jcols() const
Array with Column indices (counting starts at 1)
Definition: IpGenTMatrix.hpp:257
Ipopt::GenTMatrixSpace::iRows_
Index * iRows_
Definition: IpGenTMatrix.hpp:229
Ipopt::Matrix
Matrix Base Class.
Definition: IpMatrix.hpp:27
Ipopt::GenTMatrix::initialized_
bool initialized_
Flag for Initialization.
Definition: IpGenTMatrix.hpp:156
Ipopt::GenTMatrixSpace::GenTMatrixSpace
GenTMatrixSpace(Index nRows, Index nCols, Index nonZeros, const Index *iRows, const Index *jCols)
Constructor, given the number of rows and columns, as well as the number of nonzeros and the position...
Ipopt::GenTMatrixSpace::Jcols
const Index * Jcols() const
Column index of each non-zero element (counting starts at 1)
Definition: IpGenTMatrix.hpp:216
Ipopt::MatrixSpace
MatrixSpace base class, corresponding to the Matrix base class.
Definition: IpMatrix.hpp:239
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
Ipopt::GenTMatrixSpace::GenTMatrix
friend class GenTMatrix
Definition: IpGenTMatrix.hpp:240
Ipopt::GenTMatrix::Irows
const Index * Irows() const
Array with Row indices (counting starts at 1)
Definition: IpGenTMatrix.hpp:251
Ipopt::GenTMatrix::owner_space_
const GenTMatrixSpace * owner_space_
Copy of the owner space as a GenTMatrixSpace instead of a MatrixSpace.
Definition: IpGenTMatrix.hpp:150
Ipopt::GenTMatrix
Class for general matrices stored in triplet format.
Definition: IpGenTMatrix.hpp:36
Ipopt::GenTMatrixSpace::nonZeros_
const Index nonZeros_
Definition: IpGenTMatrix.hpp:227
Ipopt::Journalist
Class responsible for all message output.
Definition: IpJournalist.hpp:134
Ipopt::GenTMatrixSpace::~GenTMatrixSpace
~GenTMatrixSpace()
Destructor.
Definition: IpGenTMatrix.hpp:181
Ipopt::GenTMatrix::Nonzeros
Index Nonzeros() const
Number of nonzero entries.
Definition: IpGenTMatrix.hpp:245
Ipopt::GenTMatrix::values_
Number * values_
Values of nonzeros.
Definition: IpGenTMatrix.hpp:153
Ipopt::GenTMatrix::HasValidNumbersImpl
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Ipopt::GenTMatrix::MultVectorImpl
virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix-vector multiply.
Ipopt::GenTMatrix::Values
Number * Values()
Array with the nonzero values of this matrix (non-const version).
Definition: IpGenTMatrix.hpp:82
Ipopt::GenTMatrixSpace::MakeNewGenTMatrix
GenTMatrix * MakeNewGenTMatrix() const
Method for creating a new matrix of this specific type.
Definition: IpGenTMatrix.hpp:189
Ipopt::GenTMatrix::ComputeColAMaxImpl
virtual void ComputeColAMaxImpl(Vector &cols_norms, bool init) const
Compute the max-norm of the columns in the matrix.
Ipopt::EJournalCategory
EJournalCategory
Category Selection Enum.
Definition: IpJournalist.hpp:70
Ipopt::GenTMatrix::ParGenMatrix
friend class ParGenMatrix
Definition: IpGenTMatrix.hpp:126
Ipopt::GenTMatrix::SetValues
void SetValues(const Number *Values)
Set values of nonzero elements.
Ipopt::GenTMatrix::PrintImplOffset
void PrintImplOffset(const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent, const std::string &prefix, Index offset) const