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: IpSymMatrix.hpp 843 2007-02-27 22:10:18Z andreasw $ 00006 // 00007 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 00008 00009 #ifndef __IPSYMMATRIX_HPP__ 00010 #define __IPSYMMATRIX_HPP__ 00011 00012 #include "IpUtils.hpp" 00013 #include "IpMatrix.hpp" 00014 00015 namespace Ipopt 00016 { 00017 00018 /* forward declarations */ 00019 class SymMatrixSpace; 00020 00023 class SymMatrix : public Matrix 00024 { 00025 public: 00030 SymMatrix(const SymMatrixSpace* owner_space); 00031 00033 virtual ~SymMatrix() 00034 {} 00036 00040 Index Dim() const; 00042 00043 SmartPtr<const SymMatrixSpace> OwnerSymMatrixSpace() const; 00044 00045 protected: 00053 virtual void TransMultVectorImpl(Number alpha, const Vector& x, Number beta, 00054 Vector& y) const; 00056 00057 private: 00061 const SymMatrixSpace* owner_space_; 00062 }; 00063 00064 00067 class SymMatrixSpace : public MatrixSpace 00068 { 00069 public: 00075 SymMatrixSpace(Index dim) 00076 : 00077 MatrixSpace(dim,dim) 00078 {} 00079 00081 virtual ~SymMatrixSpace() 00082 {} 00084 00087 virtual SymMatrix* MakeNewSymMatrix() const=0; 00088 00091 virtual Matrix* MakeNew() const 00092 { 00093 return MakeNewSymMatrix(); 00094 } 00095 00099 Index Dim() const 00100 { 00101 DBG_ASSERT(NRows() == NCols()); 00102 return NRows(); 00103 } 00104 00105 private: 00115 SymMatrixSpace(); 00116 00117 /* Copy constructor */ 00118 SymMatrixSpace(const SymMatrixSpace&); 00119 00121 SymMatrixSpace& operator=(const SymMatrixSpace&); 00123 00124 }; 00125 00126 /* inline methods */ 00127 inline 00128 SymMatrix::SymMatrix(const SymMatrixSpace* owner_space) 00129 : 00130 Matrix(owner_space), 00131 owner_space_(owner_space) 00132 {} 00133 00134 inline 00135 Index SymMatrix::Dim() const 00136 { 00137 return owner_space_->Dim(); 00138 } 00139 00140 inline 00141 SmartPtr<const SymMatrixSpace> SymMatrix::OwnerSymMatrixSpace() const 00142 { 00143 return owner_space_; 00144 } 00145 00146 } // namespace Ipopt 00147 00148 #endif