Ipopt 3.11.9
IpMultiVectorMatrix.hpp
Go to the documentation of this file.
1// Copyright (C) 2005, 2008 International Business Machines and others.
2// All Rights Reserved.
3// This code is published under the Eclipse Public License.
4//
5// $Id: IpMultiVectorMatrix.hpp 1861 2010-12-21 21:34:47Z andreasw $
6//
7// Authors: Andreas Waechter IBM 2005-12-24
8
9#ifndef __IPMULTIVECTORMATRIX_HPP__
10#define __IPMULTIVECTORMATRIX_HPP__
11
12#include "IpUtils.hpp"
13#include "IpMatrix.hpp"
14
15namespace Ipopt
16{
17
19 class MultiVectorMatrixSpace;
20
26 {
27 public:
28
31
35
39
42
48 void SetVector(Index i, const Vector& vec);
49 /* For the non-const version, keep in mind that operations that
50 * change this matrix also change the Vector that has been given
51 * here. */
54
57 {
58 return ConstVec(i);
59 }
60
65 {
67 return Vec(i);
68 }
69
72 void ScaleRows(const Vector& scal_vec);
73
76 void ScaleColumns(const Vector& scal_vec);
77
81 Number c);
82
88 const Matrix& C, Number b);
89
93
97 void LRMultVector(Number alpha, const Vector &x,
98 Number beta, Vector &y) const;
99
102
105
106 protected:
109 virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta,
110 Vector &y) const;
111
112 virtual void TransMultVectorImpl(Number alpha, const Vector& x,
113 Number beta, Vector& y) const;
114
117 virtual bool HasValidNumbersImpl() const;
118
119 virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const;
120
121 virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const;
122
123 virtual void PrintImpl(const Journalist& jnlst,
124 EJournalLevel level,
125 EJournalCategory category,
126 const std::string& name,
127 Index indent,
128 const std::string& prefix) const;
130
131
132 private:
143
146
150
152
154 std::vector<SmartPtr<const Vector> > const_vecs_;
155
157 std::vector<SmartPtr<Vector> > non_const_vecs_;
158
161 inline const Vector* ConstVec(Index i) const
162 {
163 DBG_ASSERT(i < NCols());
165 if (IsValid(non_const_vecs_[i])) {
166 return GetRawPtr(non_const_vecs_[i]);
167 }
168 else {
169 return GetRawPtr(const_vecs_[i]);
170 }
171 }
172
173 inline Vector* Vec(Index i)
174 {
175 DBG_ASSERT(i < NCols());
177 return GetRawPtr(non_const_vecs_[i]);
178 }
180 };
181
185 {
186 public:
193 const VectorSpace& vec_space);
194
197 {}
199
202 {
203 return new MultiVectorMatrix(this);
204 }
205
208 virtual Matrix* MakeNew() const
209 {
211 }
212
215 {
216 return vec_space_;
217 }
218
219 private:
221
222 };
223
224 inline
226 {}
227
228 inline
230 {
232 }
233
234 inline
236 {
238 }
239
240 inline
243 {
244 return owner_space_;
245 }
246
247} // namespace Ipopt
248#endif
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
Number * x
Input: Starting point Output: Optimal solution.
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
Index NCols() const
Number of columns.
Definition: IpMatrix.hpp:316
This is the matrix space for MultiVectorMatrix.
virtual Matrix * MakeNew() const
Overloaded MakeNew method for the MatrixSpace base class.
MultiVectorMatrix * MakeNewMultiVectorMatrix() const
Method for creating a new matrix of this specific type.
SmartPtr< const VectorSpace > ColVectorSpace() const
Accessor method for the VectorSpace for the columns.
MultiVectorMatrixSpace(Index ncols, const VectorSpace &vec_space)
Constructor, given the number of columns (i.e., Vectors to be stored) and given the VectorSpace for t...
SmartPtr< const VectorSpace > vec_space_
Class for Matrices with few columns that consists of Vectors.
virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix-vector multiply.
SmartPtr< Vector > GetVectorNonConst(Index i)
Get a Vector in a particular column as a non-const Vector.
virtual void ComputeRowAMaxImpl(Vector &rows_norms, bool init) const
Compute the max-norm of the rows in the matrix.
void ScaleRows(const Vector &scal_vec)
Method for scaling the rows of the matrix, using the ElementWiseMultiply method for each column vecto...
void AddOneMultiVectorMatrix(Number a, const MultiVectorMatrix &mv1, Number c)
Adding another MultiVectorMatrix, using the AddOneVector methods for the individual column vectors.
void AddRightMultMatrix(Number a, const MultiVectorMatrix &U, const Matrix &C, Number b)
Multiplying a Matrix C (for now assumed to be a DenseGenMatrix) from the right to a MultiVectorMatrix...
const Vector * ConstVec(Index i) const
Method for accessing the internal Vectors internally.
MultiVectorMatrix(const MultiVectorMatrix &)
Copy Constructor.
void operator=(const MultiVectorMatrix &)
Overloaded Equals Operator.
MultiVectorMatrix()
Default Constructor.
virtual void TransMultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix(transpose) vector multiply.
void FillWithNewVectors()
Method for initializing all Vectors with new (uninitialized) Vectors.
const MultiVectorMatrixSpace * owner_space_
SmartPtr< const MultiVectorMatrixSpace > MultiVectorMatrixOwnerSpace() const
Return the MultiVectorMatrixSpace.
void LRMultVector(Number alpha, const Vector &x, Number beta, Vector &y) const
Method for adding the low-rank update matrix corresponding to this matrix to a vector.
SmartPtr< const VectorSpace > ColVectorSpace() const
Vector space for the columns.
SmartPtr< const Vector > GetVector(Index i) const
Get a Vector in a particular column as a const Vector.
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
SmartPtr< MultiVectorMatrix > MakeNewMultiVectorMatrix() const
Create a new MultiVectorMatrix from same MatrixSpace.
std::vector< SmartPtr< const Vector > > const_vecs_
space for storing the const Vector's
virtual void ComputeColAMaxImpl(Vector &cols_norms, bool init) const
Compute the max-norm of the columns 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 SetVector(Index i, const Vector &vec)
Set a particular Vector at a given column position, replacing another vector if there has been one.
std::vector< SmartPtr< Vector > > non_const_vecs_
space for storing the non-const Vector's
void SetVectorNonConst(Index i, Vector &vec)
MultiVectorMatrix(const MultiVectorMatrixSpace *owner_space)
Constructor, taking the owner_space.
void ScaleColumns(const Vector &scal_vec)
Method for scaling the columns of the matrix, using the Scal method for each column vector.
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:183
void ObjectChanged()
Objects derived from TaggedObject MUST call this method every time their internal state changes to up...
VectorSpace base class, corresponding to the Vector base class.
Definition: IpVector.hpp:391
Vector Base Class.
Definition: IpVector.hpp:48
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