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 __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 inline 00031 SymMatrix(const SymMatrixSpace* owner_space); 00032 00034 virtual ~SymMatrix() 00035 {} 00037 00041 inline 00042 Index Dim() const; 00044 00045 inline 00046 SmartPtr<const SymMatrixSpace> OwnerSymMatrixSpace() const; 00047 00048 protected: 00056 virtual void TransMultVectorImpl(Number alpha, const Vector& x, Number beta, 00057 Vector& y) const 00058 { 00059 // Since this matrix is symetric, this is the same operation as 00060 // MultVector 00061 MultVector(alpha, x, beta, y); 00062 } 00065 virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const 00066 { 00067 ComputeRowAMaxImpl(cols_norms, init); 00068 } 00070 00071 private: 00075 const SymMatrixSpace* owner_space_; 00076 }; 00077 00078 00081 class SymMatrixSpace : public MatrixSpace 00082 { 00083 public: 00089 SymMatrixSpace(Index dim) 00090 : 00091 MatrixSpace(dim,dim) 00092 {} 00093 00095 virtual ~SymMatrixSpace() 00096 {} 00098 00101 virtual SymMatrix* MakeNewSymMatrix() const=0; 00102 00105 virtual Matrix* MakeNew() const 00106 { 00107 return MakeNewSymMatrix(); 00108 } 00109 00113 Index Dim() const 00114 { 00115 DBG_ASSERT(NRows() == NCols()); 00116 return NRows(); 00117 } 00118 00119 private: 00129 SymMatrixSpace(); 00130 00131 /* Copy constructor */ 00132 SymMatrixSpace(const SymMatrixSpace&); 00133 00135 SymMatrixSpace& operator=(const SymMatrixSpace&); 00137 00138 }; 00139 00140 /* inline methods */ 00141 inline 00142 SymMatrix::SymMatrix(const SymMatrixSpace* owner_space) 00143 : 00144 Matrix(owner_space), 00145 owner_space_(owner_space) 00146 {} 00147 00148 inline 00149 Index SymMatrix::Dim() const 00150 { 00151 return owner_space_->Dim(); 00152 } 00153 00154 inline 00155 SmartPtr<const SymMatrixSpace> SymMatrix::OwnerSymMatrixSpace() const 00156 { 00157 return owner_space_; 00158 } 00159 00160 } // namespace Ipopt 00161 00162 #endif