Ipopt  3.12.11
 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 2269 2013-05-05 11:32:40Z stefan $
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
void SetTerm(Index iterm, Number factor, const Matrix &matrix)
Method for setting term iterm for the sum.
Number * x
Input: Starting point Output: Optimal solution.
SumMatrixSpace & operator=(const SumMatrixSpace &)
Overloaded Equals Operator.
virtual void ComputeColAMaxImpl(Vector &cols_norms, bool init) const
Compute the max-norm of the columns in the matrix.
virtual Matrix * MakeNew() const
Overloaded MakeNew method for the MatrixSpace base class.
Index NTerms() const
Return the number of terms.
SumMatrix()
Default Constructor.
SumMatrixSpace()
Default constructor.
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_
double Number
Type of all numbers.
Definition: IpTypes.hpp:17
Vector Base Class.
Definition: IpVector.hpp:47
virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix-vector multiply.
virtual bool HasValidNumbersImpl() const
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Class for matrix space for SumMatrix.
EJournalLevel
Print Level Enum.
virtual ~SumMatrixSpace()
Destructor.
std::vector< SmartPtr< const Matrix > > matrices_
std::vector storing the matrices for each term.
Definition: IpSumMatrix.hpp:96
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
virtual void ComputeRowAMaxImpl(Vector &rows_norms, bool init) const
Compute the max-norm of the rows in the matrix.
Matrix Base Class.
Definition: IpMatrix.hpp:27
SumMatrix * MakeNewSumMatrix() const
Method for creating a new matrix of this specific type.
virtual void TransMultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const
Matrix(transpose) vector multiply.
MatrixSpace base class, corresponding to the Matrix base class.
Definition: IpMatrix.hpp:239
virtual ~SumMatrix()
Destructor.
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
SmartPtr< const MatrixSpace > GetTermSpace(Index term_idx) const
Get the matrix space for a particular term.
void SetTermSpace(Index term_idx, const MatrixSpace &mat_space)
Set the appropriate matrix space for each term.
std::vector< Number > factors_
std::vector storing the factors for each term.
Definition: IpSumMatrix.hpp:93
Index NTerms() const
Accessor functions to get the number of terms in the sum.
void operator=(const SumMatrix &)
Overloaded Equals Operator.
Class responsible for all message output.
void GetTerm(Index iterm, Number &factor, SmartPtr< const Matrix > &matrix) const
Method for getting term iterm for the sum.
Class for Matrices which are sum of matrices.
Definition: IpSumMatrix.hpp:24
const SumMatrixSpace * owner_space_
Copy of the owner_space as a SumMatrixSpace.
Definition: IpSumMatrix.hpp:99
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.
EJournalCategory
Category Selection Enum.