Ipopt  3.12.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 2269 2013-05-05 11:32:40Z stefan $
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 
15 namespace Ipopt
16 {
17 
19  class MultiVectorMatrixSpace;
20 
25  class MultiVectorMatrix : public Matrix
26  {
27  public:
28 
31 
34  MultiVectorMatrix(const MultiVectorMatrixSpace* owner_space);
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. */
52  void SetVectorNonConst(Index i, Vector& vec);
54 
57  {
58  return ConstVec(i);
59  }
60 
65  {
66  ObjectChanged();
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 
92  void FillWithNewVectors();
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 
148  void operator=(const MultiVectorMatrix&);
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  {
210  return MakeNewMultiVectorMatrix();
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  {
237  return owner_space_->ColVectorSpace();
238  }
239 
240  inline
243  {
244  return owner_space_;
245  }
246 
247 } // namespace Ipopt
248 #endif
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:579
Number * x
Input: Starting point Output: Optimal solution.
virtual void ComputeRowAMaxImpl(Vector &rows_norms, bool init) const
Compute the max-norm of the rows in the matrix.
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.
virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix-vector multiply.
virtual void ComputeColAMaxImpl(Vector &cols_norms, bool init) const
Compute the max-norm of the columns in the matrix.
void ScaleColumns(const Vector &scal_vec)
Method for scaling the columns of the matrix, using the Scal method for each column vector...
void SetVector(Index i, const Vector &vec)
Set a particular Vector at a given column position, replacing another vector if there has been one...
double Number
Type of all numbers.
Definition: IpTypes.hpp:17
void ObjectChanged()
Objects derived from TaggedObject MUST call this method every time their internal state changes to up...
Vector Base Class.
Definition: IpVector.hpp:47
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
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.
EJournalLevel
Print Level Enum.
std::vector< SmartPtr< const Vector > > const_vecs_
space for storing the const Vector&#39;s
void ScaleRows(const Vector &scal_vec)
Method for scaling the rows of the matrix, using the ElementWiseMultiply method for each column vecto...
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...
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
VectorSpace base class, corresponding to the Vector base class.
Definition: IpVector.hpp:390
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:560
SmartPtr< const Vector > GetVector(Index i) const
Get a Vector in a particular column as a const Vector.
Matrix Base Class.
Definition: IpMatrix.hpp:27
const MultiVectorMatrixSpace * owner_space_
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...
SmartPtr< const VectorSpace > vec_space_
Class for Matrices with few columns that consists of Vectors.
MatrixSpace base class, corresponding to the Matrix base class.
Definition: IpMatrix.hpp:239
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.
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
const Vector * ConstVec(Index i) const
Method for accessing the internal Vectors internally.
void AddOneMultiVectorMatrix(Number a, const MultiVectorMatrix &mv1, Number c)
Adding another MultiVectorMatrix, using the AddOneVector methods for the individual column vectors...
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
SmartPtr< const VectorSpace > ColVectorSpace() const
Accessor method for the VectorSpace for the columns.
Index NCols() const
Number of columns.
Definition: IpMatrix.hpp:316
SmartPtr< const MultiVectorMatrixSpace > MultiVectorMatrixOwnerSpace() const
Return the MultiVectorMatrixSpace.
void SetVectorNonConst(Index i, Vector &vec)
Class responsible for all message output.
virtual void TransMultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix(transpose) vector multiply.
std::vector< SmartPtr< Vector > > non_const_vecs_
space for storing the non-const Vector&#39;s
This is the matrix space for MultiVectorMatrix.
MultiVectorMatrix()
Default Constructor.
SmartPtr< const VectorSpace > ColVectorSpace() const
Vector space for the columns.
void FillWithNewVectors()
Method for initializing all Vectors with new (uninitialized) Vectors.
SmartPtr< MultiVectorMatrix > MakeNewMultiVectorMatrix() const
Create a new MultiVectorMatrix from same MatrixSpace.
void operator=(const MultiVectorMatrix &)
Overloaded Equals Operator.
EJournalCategory
Category Selection Enum.
SmartPtr< Vector > GetVectorNonConst(Index i)
Get a Vector in a particular column as a non-const Vector.