Ipopt Documentation  
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 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6 
7 #ifndef __IPSUMMATRIX_HPP__
8 #define __IPSUMMATRIX_HPP__
9 
10 #include "IpUtils.hpp"
11 #include "IpMatrix.hpp"
12 
13 namespace Ipopt
14 {
15 
16 /* forward declarations */
17 class SumMatrixSpace;
18 
23 class SumMatrix: public Matrix
24 {
25 public:
28 
30  const SumMatrixSpace* owner_space
31  );
32 
34  virtual ~SumMatrix();
36 
38  void SetTerm(
39  Index iterm,
40  Number factor,
41  const Matrix& matrix
42  );
43 
48  void GetTerm(
49  Index iterm,
50  Number& factor,
52  ) const;
53 
55  Index NTerms() const;
56 
57 protected:
60  virtual void MultVectorImpl(
61  Number alpha,
62  const Vector& x,
63  Number beta,
64  Vector& y
65  ) const;
66 
67  virtual void TransMultVectorImpl(
68  Number alpha,
69  const Vector& x,
70  Number beta,
71  Vector& y
72  ) const;
73 
74  virtual bool HasValidNumbersImpl() const;
75 
76  virtual void ComputeRowAMaxImpl(
77  Vector& rows_norms,
78  bool init
79  ) const;
80 
81  virtual void ComputeColAMaxImpl(
82  Vector& cols_norms,
83  bool init
84  ) const;
85 
86  virtual void PrintImpl(
87  const Journalist& jnlst,
88  EJournalLevel level,
89  EJournalCategory category,
90  const std::string& name,
91  Index indent,
92  const std::string& prefix
93  ) const;
95 
96 private:
106 
108 
111  const SumMatrix&
112  );
113 
115  void operator=(
116  const SumMatrix&
117  );
119 
121  std::vector<Number> factors_;
122 
124  std::vector<SmartPtr<const Matrix> > matrices_;
125 
128 };
129 
132 {
133 public:
136 
140  Index nrows,
141  Index ncols,
142  Index nterms
143  )
144  : MatrixSpace(nrows, ncols),
145  nterms_(nterms)
146  { }
147 
149  virtual ~SumMatrixSpace()
150  { }
152 
154  Index NTerms() const
155  {
156  return nterms_;
157  }
158 
164  Index term_idx,
165  const MatrixSpace& mat_space
166  );
167 
170  Index term_idx
171  ) const;
172 
175 
176  virtual Matrix* MakeNew() const;
177 
178 private:
188 
190 
193  const SumMatrixSpace&
194  );
195 
198  const SumMatrixSpace&
199  );
201 
202  const Index nterms_;
203 
204  std::vector<SmartPtr<const MatrixSpace> > term_spaces_;
205 };
206 
207 } // namespace Ipopt
208 #endif
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
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
Class for matrix space for SumMatrix.
SmartPtr< const MatrixSpace > GetTermSpace(Index term_idx) const
Get the matrix space for a particular term.
virtual ~SumMatrixSpace()
Destructor.
void SetTermSpace(Index term_idx, const MatrixSpace &mat_space)
Set the appropriate matrix space for each term.
SumMatrix * MakeNewSumMatrix() const
Method for creating a new matrix of this specific type.
SumMatrixSpace(const SumMatrixSpace &)
Copy Constructor.
Index NTerms() const
Accessor functions to get the number of terms in the sum.
SumMatrixSpace(Index nrows, Index ncols, Index nterms)
Constructor, given the number of row and columns, as well as the number of terms in the sum.
SumMatrixSpace & operator=(const SumMatrixSpace &)
Default Assignment Operator.
std::vector< SmartPtr< const MatrixSpace > > term_spaces_
SumMatrixSpace()
Default constructor.
virtual Matrix * MakeNew() const
Pure virtual method for creating a new Matrix of the corresponding type.
Class for Matrices which are sum of matrices.
Definition: IpSumMatrix.hpp:24
virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix-vector multiply.
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 operator=(const SumMatrix &)
Default Assignment Operator.
SumMatrix(const SumMatrixSpace *owner_space)
Constructor, taking the owner_space.
Index NTerms() const
Return the number of terms.
SumMatrix()
Default Constructor.
const SumMatrixSpace * owner_space_
Copy of the owner_space as a SumMatrixSpace.
void GetTerm(Index iterm, Number &factor, SmartPtr< const Matrix > &matrix) const
Method for getting term iterm for the sum.
virtual void TransMultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix(transpose) vector multiply.
void SetTerm(Index iterm, Number factor, const Matrix &matrix)
Method for setting term iterm for the sum.
std::vector< Number > factors_
std::vector storing the factors for each term.
virtual ~SumMatrix()
Destructor.
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
std::vector< SmartPtr< const Matrix > > matrices_
std::vector storing the matrices for each term.
virtual void ComputeRowAMaxImpl(Vector &rows_norms, bool init) const
Compute the max-norm of the rows in the matrix.
SumMatrix(const SumMatrix &)
Copy Constructor.
virtual void ComputeColAMaxImpl(Vector &cols_norms, bool init) const
Compute the max-norm of the columns in the matrix.
Vector Base Class.
Definition: IpVector.hpp:48
This file contains a base class for all exceptions and a set of macros to help with exceptions.
EJournalCategory
Category Selection Enum.
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:17
EJournalLevel
Print Level Enum.
double Number
Type of all numbers.
Definition: IpTypes.hpp:15