Ipopt
trunk
|
00001 // Copyright (C) 2004, 2008 International Business Machines and others. 00002 // All Rights Reserved. 00003 // This code is published under the Eclipse Public License. 00004 // 00005 // $Id$ 00006 // 00007 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 00008 00009 #ifndef __IPDIAGMATRIX_HPP__ 00010 #define __IPDIAGMATRIX_HPP__ 00011 00012 #include "IpUtils.hpp" 00013 #include "IpSymMatrix.hpp" 00014 00015 namespace Ipopt 00016 { 00017 00020 class DiagMatrix : public SymMatrix 00021 { 00022 public: 00023 00026 00028 DiagMatrix(const SymMatrixSpace* owner_space); 00029 00031 ~DiagMatrix(); 00033 00035 void SetDiag(const Vector& diag) 00036 { 00037 diag_ = &diag; 00038 } 00039 00041 SmartPtr<const Vector> GetDiag() const 00042 { 00043 return diag_; 00044 } 00045 00046 protected: 00049 virtual void MultVectorImpl(Number alpha, const Vector& x, 00050 Number beta, Vector& y) const; 00051 00054 virtual bool HasValidNumbersImpl() const; 00055 00056 virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const; 00057 00058 virtual void PrintImpl(const Journalist& jnlst, 00059 EJournalLevel level, 00060 EJournalCategory category, 00061 const std::string& name, 00062 Index indent, 00063 const std::string& prefix) const; 00065 00066 private: 00076 DiagMatrix(); 00077 00079 DiagMatrix(const DiagMatrix&); 00080 00082 void operator=(const DiagMatrix&); 00084 00086 SmartPtr<const Vector> diag_; 00087 }; 00088 00090 class DiagMatrixSpace : public SymMatrixSpace 00091 { 00092 public: 00096 DiagMatrixSpace(Index dim) 00097 : 00098 SymMatrixSpace(dim) 00099 {} 00100 00102 virtual ~DiagMatrixSpace() 00103 {} 00105 00108 virtual SymMatrix* MakeNewSymMatrix() const 00109 { 00110 return MakeNewDiagMatrix(); 00111 } 00112 00114 DiagMatrix* MakeNewDiagMatrix() const 00115 { 00116 return new DiagMatrix(this); 00117 } 00118 00119 private: 00129 DiagMatrixSpace(); 00130 00132 DiagMatrixSpace(const DiagMatrixSpace&); 00133 00135 void operator=(const DiagMatrixSpace&); 00137 00138 }; 00139 00140 } // namespace Ipopt 00141 #endif