Ipopt
trunk
|
00001 // Copyright (C) 2004, 2009 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 __IPEXPANSIONMATRIX_HPP__ 00010 #define __IPEXPANSIONMATRIX_HPP__ 00011 00012 #include "IpUtils.hpp" 00013 #include "IpMatrix.hpp" 00014 00015 namespace Ipopt 00016 { 00017 00019 class ExpansionMatrixSpace; 00020 00027 class ExpansionMatrix : public Matrix 00028 { 00029 public: 00030 00033 00036 ExpansionMatrix(const ExpansionMatrixSpace* owner_space); 00037 00039 ~ExpansionMatrix(); 00041 00049 const Index* ExpandedPosIndices() const; 00050 00059 const Index* CompressedPosIndices() const; 00060 00061 protected: 00064 virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, 00065 Vector &y) const; 00066 00067 virtual void TransMultVectorImpl(Number alpha, const Vector& x, 00068 Number beta, Vector& y) const; 00069 00072 virtual void AddMSinvZImpl(Number alpha, const Vector& S, const Vector& Z, 00073 Vector& X) const; 00074 00077 virtual void SinvBlrmZMTdBrImpl(Number alpha, const Vector& S, 00078 const Vector& R, const Vector& Z, 00079 const Vector& D, Vector& X) const; 00080 00081 virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const; 00082 00083 virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const; 00084 00085 virtual void PrintImpl(const Journalist& jnlst, 00086 EJournalLevel level, 00087 EJournalCategory category, 00088 const std::string& name, 00089 Index indent, 00090 const std::string& prefix) const 00091 { 00092 PrintImplOffset(jnlst, level, category, name, indent, prefix, 1, 1); 00093 } 00095 00096 void PrintImplOffset(const Journalist& jnlst, 00097 EJournalLevel level, 00098 EJournalCategory category, 00099 const std::string& name, 00100 Index indent, 00101 const std::string& prefix, 00102 Index row_offset, 00103 Index col_offset) const; 00104 00105 friend class ParExpansionMatrix; 00106 00107 private: 00117 ExpansionMatrix(); 00118 00120 ExpansionMatrix(const ExpansionMatrix&); 00121 00123 void operator=(const ExpansionMatrix&); 00125 00126 const ExpansionMatrixSpace* owner_space_; 00127 00128 }; 00129 00132 class ExpansionMatrixSpace : public MatrixSpace 00133 { 00134 public: 00144 ExpansionMatrixSpace(Index NLargeVec, 00145 Index NSmallVec, 00146 const Index *ExpPos, 00147 const int offset = 0); 00148 00150 ~ExpansionMatrixSpace() 00151 { 00152 delete [] compressed_pos_; 00153 delete [] expanded_pos_; 00154 } 00156 00158 ExpansionMatrix* MakeNewExpansionMatrix() const 00159 { 00160 return new ExpansionMatrix(this); 00161 } 00162 00165 virtual Matrix* MakeNew() const 00166 { 00167 return MakeNewExpansionMatrix(); 00168 } 00169 00176 const Index* ExpandedPosIndices() const 00177 { 00178 return expanded_pos_; 00179 } 00180 00188 const Index* CompressedPosIndices() const 00189 { 00190 return compressed_pos_; 00191 } 00192 00193 private: 00194 Index *expanded_pos_; 00195 Index *compressed_pos_; 00196 }; 00197 00198 /* inline methods */ 00199 inline 00200 const Index* ExpansionMatrix::ExpandedPosIndices() const 00201 { 00202 return owner_space_->ExpandedPosIndices(); 00203 } 00204 00205 inline 00206 const Index* ExpansionMatrix::CompressedPosIndices() const 00207 { 00208 return owner_space_->CompressedPosIndices(); 00209 } 00210 00211 } // namespace Ipopt 00212 #endif