Ipopt  3.11.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpSumMatrix.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2008 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpSumMatrix.hpp 1861 2010-12-21 21:34:47Z andreasw $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8 
9 #ifndef __IPSUMMATRIX_HPP__
10 #define __IPSUMMATRIX_HPP__
11 
12 #include "IpUtils.hpp"
13 #include "IpMatrix.hpp"
14 
15 namespace Ipopt
16 {
17 
18  /* forward declarations */
19  class SumMatrixSpace;
20 
24  class SumMatrix : public Matrix
25  {
26  public:
27 
32  SumMatrix(const SumMatrixSpace* owner_space);
33 
35  virtual ~SumMatrix();
37 
39  void SetTerm(Index iterm, Number factor, const Matrix& matrix);
40 
43  void GetTerm(Index iterm, Number& factor, SmartPtr<const Matrix>& matrix) const;
44 
46  Index NTerms() const;
47 
48  protected:
51  virtual void MultVectorImpl(Number alpha, const Vector& x,
52  Number beta, Vector& y) const;
53 
54  virtual void TransMultVectorImpl(Number alpha, const Vector& x,
55  Number beta, Vector& y) const;
56 
59  virtual bool HasValidNumbersImpl() const;
60 
61  virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const;
62 
63  virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const;
64 
65  virtual void PrintImpl(const Journalist& jnlst,
66  EJournalLevel level,
67  EJournalCategory category,
68  const std::string& name,
69  Index indent,
70  const std::string& prefix) const;
72 
73  private:
83  SumMatrix();
84 
86  SumMatrix(const SumMatrix&);
87 
89  void operator=(const SumMatrix&);
91 
93  std::vector<Number> factors_;
94 
96  std::vector<SmartPtr<const Matrix> > matrices_;
97 
100  };
101 
104  {
105  public:
111  SumMatrixSpace(Index nrows, Index ncols, Index nterms)
112  :
113  MatrixSpace(nrows, ncols),
114  nterms_(nterms)
115  {}
116 
118  virtual ~SumMatrixSpace()
119  {}
121 
123  Index NTerms() const
124  {
125  return nterms_;
126  }
127 
130  void SetTermSpace(Index term_idx, const MatrixSpace& mat_space);
131 
134 
136  SumMatrix* MakeNewSumMatrix() const;
137 
140  virtual Matrix* MakeNew() const;
141 
142  private:
152  SumMatrixSpace();
153 
156 
160 
161  const Index nterms_;
162 
163  std::vector< SmartPtr<const MatrixSpace> > term_spaces_;
164  };
165 
166 } // namespace Ipopt
167 #endif