Ipopt Documentation  
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 
13 namespace Ipopt
14 {
15 
17 class MultiVectorMatrixSpace;
18 
25 {
26 public:
28 
32  const MultiVectorMatrixSpace* owner_space
33  );
34 
38 
40  SmartPtr<MultiVectorMatrix> MakeNewMultiVectorMatrix() const;
41 
47  void SetVector(
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  */
57  void SetVectorNonConst(
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 
87  void ScaleRows(
88  const Vector& scal_vec
89  );
90 
94  void ScaleColumns(
95  const Vector& scal_vec);
96 
100  void AddOneMultiVectorMatrix(
101  Number a,
102  const MultiVectorMatrix& mv1,
103  Number c
104  );
105 
110  void AddRightMultMatrix(
111  Number a,
112  const MultiVectorMatrix& U,
113  const Matrix& C,
114  Number b
115  );
116 
118  void FillWithNewVectors();
119 
126  void LRMultVector(
127  Number alpha,
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 
139 protected:
141  virtual void MultVectorImpl(
143  Number alpha,
144  const Vector& x,
145  Number beta,
146  Vector& y
147  ) const;
148 
149  virtual void TransMultVectorImpl(
150  Number alpha,
151  const Vector& x,
152  Number beta,
153  Vector& y
154  ) const;
155 
156  virtual bool HasValidNumbersImpl() const;
157 
158  virtual void ComputeRowAMaxImpl(
159  Vector& rows_norms,
160  bool init
161  ) const;
162 
163  virtual void ComputeColAMaxImpl(
164  Vector& cols_norms,
165  bool init
166  ) const;
167 
168  virtual void PrintImpl(
169  const Journalist& jnlst,
170  EJournalLevel level,
171  EJournalCategory category,
172  const std::string& name,
173  Index indent,
174  const std::string& prefix
175  ) const;
177 
178 private:
187 
190 
193  const MultiVectorMatrix&
194  );
195 
197  void operator=(
198  const MultiVectorMatrix&
199  );
201 
203 
205  std::vector<SmartPtr<const Vector> > const_vecs_;
206 
208  std::vector<SmartPtr<Vector> > non_const_vecs_;
209 
211  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 {
242 public:
244 
249  Index ncols,
250  const VectorSpace& vec_space
251  );
252 
255  { }
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 
275 private:
277 
278 };
279 
281 { }
282 
284 {
286 }
287 
289 {
290  return owner_space_->ColVectorSpace();
291 }
292 
294 {
295  return owner_space_;
296 }
297 
298 } // namespace Ipopt
299 #endif
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.
bool IsValid(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:674
virtual Matrix * MakeNew() const
Pure virtual method for creating a new Matrix of the corresponding type.
double Number
Type of all numbers.
Definition: IpTypes.hpp:15
Vector Base Class.
Definition: IpVector.hpp:47
EJournalLevel
Print Level Enum.
std::vector< SmartPtr< const Vector > > const_vecs_
space for storing the const Vector&#39;s
This file contains a base class for all exceptions and a set of macros to help with exceptions...
SmartPtr< const MultiVectorMatrixSpace > MultiVectorMatrixOwnerSpace() const
Return the MultiVectorMatrixSpace.
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:171
VectorSpace base class, corresponding to the Vector base class.
Definition: IpVector.hpp:458
SmartPtr< const Vector > GetVector(Index i) const
Get a Vector in a particular column as a const Vector.
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Definition: IpSmartPtr.hpp:651
SmartPtr< const VectorSpace > ColVectorSpace() const
Vector space for the columns.
Matrix Base Class.
Definition: IpMatrix.hpp:27
const MultiVectorMatrixSpace * owner_space_
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:326
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:27
#define IPOPTLIB_EXPORT
Class responsible for all message output.
std::vector< SmartPtr< Vector > > non_const_vecs_
space for storing the non-const Vector&#39;s
This is the matrix space for MultiVectorMatrix.
SmartPtr< MultiVectorMatrix > MakeNewMultiVectorMatrix() const
Create a new MultiVectorMatrix from same MatrixSpace.
EJournalCategory
Category Selection Enum.
SmartPtr< Vector > GetVectorNonConst(Index i)
Get a Vector in a particular column as a non-const Vector.