Ipopt Documentation  
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 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6 
7 #ifndef __IPGENTMATRIX_HPP__
8 #define __IPGENTMATRIX_HPP__
9 
10 #include "IpUtils.hpp"
11 #include "IpMatrix.hpp"
12 
13 namespace Ipopt
14 {
15 
16 /* forward declarations */
17 class GenTMatrixSpace;
18 
35 {
36 public:
41  const GenTMatrixSpace* owner_space
42  );
43 
47 
58  void SetValues(
59  const Number* Values
60  );
62 
66  Index Nonzeros() const;
67 
69  const Index* Irows() const;
70 
72  const Index* Jcols() const;
73 
75  const Number* Values() const
76  {
77  return values_;
78  }
79 
86  {
87  ObjectChanged();
88  initialized_ = true;
89  return values_;
90  }
92 
93 protected:
96  virtual void MultVectorImpl(
97  Number alpha,
98  const Vector& x,
99  Number beta,
100  Vector& y
101  ) const;
102 
103  virtual void TransMultVectorImpl(
104  Number alpha,
105  const Vector& x,
106  Number beta,
107  Vector& y
108  ) const;
109 
110  virtual bool HasValidNumbersImpl() const;
111 
112  virtual void ComputeRowAMaxImpl(
113  Vector& rows_norms,
114  bool init
115  ) const;
116 
117  virtual void ComputeColAMaxImpl(
118  Vector& cols_norms,
119  bool init
120  ) const;
121 
122  virtual void PrintImpl(
123  const Journalist& jnlst,
124  EJournalLevel level,
125  EJournalCategory category,
126  const std::string& name,
127  Index indent,
128  const std::string& prefix
129  ) const
130  {
131  PrintImplOffset(jnlst, level, category, name, indent, prefix, 0);
132  }
134 
136  const Journalist& jnlst,
137  EJournalLevel level,
138  EJournalCategory category,
139  const std::string& name,
140  Index indent,
141  const std::string& prefix,
142  Index offset
143  ) const;
144 
145  friend class ParGenMatrix;
146 
147 private:
159 
162  const GenTMatrix&
163  );
164 
166  void operator=(
167  const GenTMatrix&
168  );
170 
175 
178 
181 
182 };
183 
189 {
190 public:
203  Index nRows,
204  Index nCols,
205  Index nonZeros,
206  const Index* iRows,
207  const Index* jCols
208  );
209 
212  {
213  delete[] iRows_;
214  delete[] jCols_;
215  }
217 
220  {
221  return new GenTMatrix(this);
222  }
223 
224  virtual Matrix* MakeNew() const
225  {
226  return MakeNewGenTMatrix();
227  }
228 
232  Index Nonzeros() const
233  {
234  return nonZeros_;
235  }
236 
238  const Index* Irows() const
239  {
240  return iRows_;
241  }
242 
244  const Index* Jcols() const
245  {
246  return jCols_;
247  }
249 
250 private:
257 
262 
267  Number* values
268  ) const;
269 
270  friend class GenTMatrix;
271 };
272 
273 /* inline methods */
275 {
276  return owner_space_->Nonzeros();
277 }
278 
279 inline const Index* GenTMatrix::Irows() const
280 {
281  return owner_space_->Irows();
282 }
283 
284 inline const Index* GenTMatrix::Jcols() const
285 {
286  return owner_space_->Jcols();
287 }
288 
289 } // namespace Ipopt
290 #endif
IpUtils.hpp
Ipopt::MatrixSpace
MatrixSpace base class, corresponding to the Matrix base class.
Definition: IpMatrix.hpp:327
Ipopt::GenTMatrix::operator=
void operator=(const GenTMatrix &)
Default Assignment Operator.
Ipopt::GenTMatrix::TransMultVectorImpl
virtual void TransMultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix(transpose) vector multiply.
Ipopt::GenTMatrix::initialized_
bool initialized_
Flag for Initialization.
Definition: IpGenTMatrix.hpp:180
Ipopt::GenTMatrix::Irows
const Index * Irows() const
Array with Row indices (counting starts at 1)
Definition: IpGenTMatrix.hpp:279
Ipopt::GenTMatrix::GenTMatrix
GenTMatrix(const GenTMatrixSpace *owner_space)
Constructor, taking the owner_space.
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::GenTMatrixSpace::AllocateInternalStorage
Number * AllocateInternalStorage() const
This method is only for the GenTMatrix to call in order to allocate internal storage.
Ipopt::GenTMatrixSpace::MakeNew
virtual Matrix * MakeNew() const
Pure virtual method for creating a new Matrix of the corresponding type.
Definition: IpGenTMatrix.hpp:224
Ipopt::GenTMatrixSpace::Nonzeros
Index Nonzeros() const
Number of non-zeros in the sparse matrix.
Definition: IpGenTMatrix.hpp:232
Ipopt::EJournalLevel
EJournalLevel
Print Level Enum.
Definition: IpJournalist.hpp:32
Ipopt::GenTMatrix::ComputeColAMaxImpl
virtual void ComputeColAMaxImpl(Vector &cols_norms, bool init) const
Compute the max-norm of the columns in the matrix.
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
This is the matrix space for a GenTMatrix with fixed sparsity structure.
Definition: IpGenTMatrix.hpp:189
Ipopt::GenTMatrix::MultVectorImpl
virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix-vector multiply.
IPOPTLIB_EXPORT
#define IPOPTLIB_EXPORT
Definition: config_default.h:16
Ipopt::GenTMatrix::~GenTMatrix
~GenTMatrix()
Destructor.
Ipopt::GenTMatrixSpace::Jcols
const Index * Jcols() const
Column index of each non-zero element (counting starts at 1)
Definition: IpGenTMatrix.hpp:244
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
Ipopt::GenTMatrix::GenTMatrix
GenTMatrix(const GenTMatrix &)
Copy Constructor.
Ipopt::GenTMatrix::owner_space_
const GenTMatrixSpace * owner_space_
Copy of the owner space as a GenTMatrixSpace instead of a MatrixSpace.
Definition: IpGenTMatrix.hpp:174
Ipopt::GenTMatrixSpace::MakeNewGenTMatrix
GenTMatrix * MakeNewGenTMatrix() const
Method for creating a new matrix of this specific type.
Definition: IpGenTMatrix.hpp:219
Ipopt::GenTMatrixSpace::jCols_
Index * jCols_
Definition: IpGenTMatrix.hpp:254
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:122
Ipopt::EJournalCategory
EJournalCategory
Category Selection Enum.
Definition: IpJournalist.hpp:52
Ipopt::GenTMatrixSpace::nonZeros_
const Index nonZeros_
Definition: IpGenTMatrix.hpp:253
Ipopt::GenTMatrixSpace::FreeInternalStorage
void FreeInternalStorage(Number *values) const
This method is only for the GenTMatrix to call in order to de-allocate internal storage.
Ipopt::GenTMatrix::SetValues
void SetValues(const Number *Values)
Set values of nonzero elements.
Ipopt::GenTMatrix::Nonzeros
Index Nonzeros() const
Number of nonzero entries.
Definition: IpGenTMatrix.hpp:274
Ipopt::GenTMatrix
Class for general matrices stored in triplet format.
Definition: IpGenTMatrix.hpp:35
Ipopt::Journalist
Class responsible for all message output.
Definition: IpJournalist.hpp:117
Ipopt::GenTMatrix::Jcols
const Index * Jcols() const
Array with Column indices (counting starts at 1)
Definition: IpGenTMatrix.hpp:284
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
Ipopt::GenTMatrix::Values
const Number * Values() const
Array with nonzero values (const version).
Definition: IpGenTMatrix.hpp:75
IpMatrix.hpp
Ipopt::GenTMatrix::GenTMatrix
GenTMatrix()
Default Constructor.
Ipopt::GenTMatrix::HasValidNumbersImpl
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Ipopt::GenTMatrixSpace::Irows
const Index * Irows() const
Row index of each non-zero element (counting starts at 1)
Definition: IpGenTMatrix.hpp:238
Ipopt::GenTMatrix::ComputeRowAMaxImpl
virtual void ComputeRowAMaxImpl(Vector &rows_norms, bool init) const
Compute the max-norm of the rows in the matrix.
Ipopt::GenTMatrix::Values
Number * Values()
Array with the nonzero values of this matrix (non-const version).
Definition: IpGenTMatrix.hpp:85
Ipopt::GenTMatrix::values_
Number * values_
Values of nonzeros.
Definition: IpGenTMatrix.hpp:177
Ipopt::GenTMatrixSpace::~GenTMatrixSpace
~GenTMatrixSpace()
Destructor.
Definition: IpGenTMatrix.hpp:211
Ipopt::GenTMatrixSpace::iRows_
Index * iRows_
Definition: IpGenTMatrix.hpp:255
Ipopt::Vector
Vector Base Class.
Definition: IpVector.hpp:48