Ipopt Documentation  
 
Loading...
Searching...
No Matches
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// Authors: Andreas Waechter IBM 2005-12-24
6
7#ifndef __IPMULTIVECTORMATRIX_HPP__
8#define __IPMULTIVECTORMATRIX_HPP__
9
10#include "IpUtils.hpp"
11#include "IpMatrix.hpp"
12
13namespace Ipopt
14{
15
17class MultiVectorMatrixSpace;
18
25{
26public:
29
33 );
34
38
40 SmartPtr<MultiVectorMatrix> MakeNewMultiVectorMatrix() const;
41
49 Index i,
50 const Vector& vec
51 );
52
53 /* For the non-const version, keep in mind that operations that
54 * change this matrix also change the Vector that has been given
55 * here.
56 */
58 Index i,
59 Vector& vec
60 );
62
65 Index i
66 ) const
67 {
68 return ConstVec(i);
69 }
70
77 Index i
78 )
79 {
80 ObjectChanged();
81 return Vec(i);
82 }
83
88 const Vector& scal_vec
89 );
90
95 const Vector& scal_vec);
96
101 Number a,
102 const MultiVectorMatrix& mv1,
103 Number c
104 );
105
111 Number a,
112 const MultiVectorMatrix& U,
113 const Matrix& C,
114 Number b
115 );
116
119
128 const Vector& x,
129 Number beta,
130 Vector& y
131 ) const;
132
134 SmartPtr<const VectorSpace> ColVectorSpace() const;
135
137 SmartPtr<const MultiVectorMatrixSpace> MultiVectorMatrixOwnerSpace() const;
138
139protected:
142 virtual void MultVectorImpl(
144 const Vector& x,
145 Number beta,
146 Vector& y
147 ) const;
148
151 const Vector& x,
152 Number beta,
153 Vector& y
154 ) const;
155
156 virtual bool HasValidNumbersImpl() const;
157
158 virtual void ComputeRowAMaxImpl(
160 bool init
161 ) const;
162
163 virtual void ComputeColAMaxImpl(
165 bool init
166 ) const;
167
168 virtual void PrintImpl(
169 const Journalist& jnlst,
172 const std::string& name,
174 const std::string& prefix
175 ) const;
177
178private:
188
190
193 const MultiVectorMatrix&
194 );
195
198 const MultiVectorMatrix&
199 );
201
203
205 std::vector<SmartPtr<const Vector> > const_vecs_;
206
208 std::vector<SmartPtr<Vector> > non_const_vecs_;
209
212 inline const Vector* ConstVec(
213 Index i
214 ) const
215 {
216 DBG_ASSERT(i < NCols());
217 DBG_ASSERT(IsValid(const_vecs_[i]) || IsValid(non_const_vecs_[i]));
218 if( IsValid(non_const_vecs_[i]) )
219 {
220 return GetRawPtr(non_const_vecs_[i]);
221 }
222 else
223 {
224 return GetRawPtr(const_vecs_[i]);
225 }
226 }
227
228 inline Vector* Vec(
229 Index i
230 )
231 {
232 DBG_ASSERT(i < NCols());
233 DBG_ASSERT(IsValid(non_const_vecs_[i]));
234 return GetRawPtr(non_const_vecs_[i]);
235 }
237};
238
241{
242public:
245
249 Index ncols,
251 );
252
257
260 {
261 return new MultiVectorMatrix(this);
262 }
263
264 virtual Matrix* MakeNew() const
265 {
266 return MakeNewMultiVectorMatrix();
267 }
268
271 {
272 return vec_space_;
273 }
274
275private:
277
278};
279
282
284{
285 return owner_space_->MakeNewMultiVectorMatrix();
286}
287
289{
290 return owner_space_->ColVectorSpace();
291}
292
297
298} // namespace Ipopt
299#endif
#define DBG_ASSERT(test)
Definition IpDebug.hpp:27
Templated class which stores one entry for the CachedResult class.
Class responsible for all message output.
MatrixSpace base class, corresponding to the Matrix base class.
Definition IpMatrix.hpp:327
Matrix Base Class.
Definition IpMatrix.hpp:28
This is the matrix space for MultiVectorMatrix.
virtual Matrix * MakeNew() const
Pure virtual method for creating a new Matrix of the corresponding type.
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 &)
Default Assignment 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 Scale method for each column vector.
VectorSpace base class, corresponding to the Vector base class.
Definition IpVector.hpp:473
Vector Base Class.
Definition IpVector.hpp:48
#define IPOPTLIB_EXPORT
This file contains a base class for all exceptions and a set of macros to help with exceptions.
bool IsValid(const SmartPtr< U > &smart_ptr)
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
ipindex Index
Type of all indices of vectors, matrices etc.
Definition IpTypes.hpp:20
EJournalCategory
Category Selection Enum.
EJournalLevel
Print Level Enum.
ipnumber Number
Type of all numbers.
Definition IpTypes.hpp:17