Ipopt  3.11.4
 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 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 
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