Ipopt  3.11.9
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:
84 
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 
137 
140  virtual Matrix* MakeNew() const;
141 
142  private:
153 
156 
160 
161  const Index nterms_;
162 
163  std::vector< SmartPtr<const MatrixSpace> > term_spaces_;
164  };
165 
166 } // namespace Ipopt
167 #endif
Number * x
Input: Starting point Output: Optimal solution.
Class responsible for all message output.
MatrixSpace base class, corresponding to the Matrix base class.
Definition: IpMatrix.hpp:240
Matrix Base Class.
Definition: IpMatrix.hpp:28
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:183
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.
std::vector< SmartPtr< const MatrixSpace > > term_spaces_
SumMatrixSpace & operator=(const SumMatrixSpace &)
Overloaded Equals Operator.
SumMatrixSpace()
Default constructor.
virtual Matrix * MakeNew() const
Overloaded MakeNew method for the MatrixSpace base class.
Class for Matrices which are sum of matrices.
Definition: IpSumMatrix.hpp:25
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 &)
Overloaded Equals 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.
Definition: IpSumMatrix.hpp:99
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.
Definition: IpSumMatrix.hpp:93
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.
Definition: IpSumMatrix.hpp:96
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
EJournalCategory
Category Selection Enum.
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
EJournalLevel
Print Level Enum.
double Number
Type of all numbers.
Definition: IpTypes.hpp:17