00001 // Copyright (C) 2004, 2006 International Business Machines and others. 00002 // All Rights Reserved. 00003 // This code is published under the Common Public License. 00004 // 00005 // $Id: IpDiagMatrix.hpp 759 2006-07-07 03:07:08Z andreasw $ 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 PrintImpl(const Journalist& jnlst, 00057 EJournalLevel level, 00058 EJournalCategory category, 00059 const std::string& name, 00060 Index indent, 00061 const std::string& prefix) const; 00063 00064 private: 00074 DiagMatrix(); 00075 00077 DiagMatrix(const DiagMatrix&); 00078 00080 void operator=(const DiagMatrix&); 00082 00084 SmartPtr<const Vector> diag_; 00085 }; 00086 00088 class DiagMatrixSpace : public SymMatrixSpace 00089 { 00090 public: 00094 DiagMatrixSpace(Index dim) 00095 : 00096 SymMatrixSpace(dim) 00097 {} 00098 00100 virtual ~DiagMatrixSpace() 00101 {} 00103 00106 virtual SymMatrix* MakeNewSymMatrix() const 00107 { 00108 return MakeNewDiagMatrix(); 00109 } 00110 00112 DiagMatrix* MakeNewDiagMatrix() const 00113 { 00114 return new DiagMatrix(this); 00115 } 00116 00117 private: 00127 DiagMatrixSpace(); 00128 00130 DiagMatrixSpace(const DiagMatrixSpace&); 00131 00133 void operator=(const DiagMatrixSpace&); 00135 00136 }; 00137 00138 } // namespace Ipopt 00139 #endif