/home/coin/SVN-release/CoinAll-1.1.0/Ipopt/src/LinAlg/IpMultiVectorMatrix.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2005, 2006 International Business Machines and others.
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // $Id: IpMultiVectorMatrix.hpp 737 2006-06-08 16:37:12Z andreasw $
00006 //
00007 // Authors:  Andreas Waechter             IBM    2005-12-24
00008 
00009 #ifndef __IPMULTIVECTORMATRIX_HPP__
00010 #define __IPMULTIVECTORMATRIX_HPP__
00011 
00012 #include "IpUtils.hpp"
00013 #include "IpMatrix.hpp"
00014 
00015 namespace Ipopt
00016 {
00017 
00019   class MultiVectorMatrixSpace;
00020 
00025   class MultiVectorMatrix : public Matrix
00026   {
00027   public:
00028 
00031 
00034     MultiVectorMatrix(const MultiVectorMatrixSpace* owner_space);
00035 
00037     ~MultiVectorMatrix();
00039 
00041     SmartPtr<MultiVectorMatrix> MakeNewMultiVectorMatrix() const;
00042 
00048     void SetVector(Index i, const Vector& vec);
00049     /* For the non-const version, keep in mind that operations that
00050      * change this matrix also change the Vector that has been given
00051      * here. */
00052     void SetVectorNonConst(Index i, Vector& vec);
00054 
00056     inline SmartPtr<const Vector> GetVector(Index i) const
00057     {
00058       return ConstVec(i);
00059     }
00060 
00064     inline SmartPtr<Vector> GetVectorNonConst(Index i)
00065     {
00066       ObjectChanged();
00067       return Vec(i);
00068     }
00069 
00072     void ScaleRows(const Vector& scal_vec);
00073 
00076     void ScaleColumns(const Vector& scal_vec);
00077 
00080     void AddOneMultiVectorMatrix(Number a, const MultiVectorMatrix& mv1,
00081                                  Number c);
00082 
00087     void AddRightMultMatrix(Number a, const MultiVectorMatrix& U,
00088                             const Matrix& C, Number b);
00089 
00092     void FillWithNewVectors();
00093 
00097     void LRMultVector(Number alpha, const Vector &x,
00098                       Number beta, Vector &y) const;
00099 
00101     SmartPtr<const VectorSpace> ColVectorSpace() const;
00102 
00104     SmartPtr<const MultiVectorMatrixSpace> MultiVectorMatrixOwnerSpace() const;
00105 
00106   protected:
00109     virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta,
00110                                 Vector &y) const;
00111 
00112     virtual void TransMultVectorImpl(Number alpha, const Vector& x,
00113                                      Number beta, Vector& y) const;
00114 
00117     virtual bool HasValidNumbersImpl() const;
00118 
00119     virtual void PrintImpl(const Journalist& jnlst,
00120                            EJournalLevel level,
00121                            EJournalCategory category,
00122                            const std::string& name,
00123                            Index indent,
00124                            const std::string& prefix) const;
00126 
00127 
00128   private:
00138     MultiVectorMatrix();
00139 
00141     MultiVectorMatrix(const MultiVectorMatrix&);
00142 
00144     void operator=(const MultiVectorMatrix&);
00146 
00147     const MultiVectorMatrixSpace* owner_space_;
00148 
00150     std::vector<SmartPtr<const Vector> > const_vecs_;
00151 
00153     std::vector<SmartPtr<Vector> > non_const_vecs_;
00154 
00157     inline const Vector* ConstVec(Index i) const
00158     {
00159       DBG_ASSERT(i < NCols());
00160       DBG_ASSERT(IsValid(const_vecs_[i]) || IsValid(non_const_vecs_[i]));
00161       if (IsValid(non_const_vecs_[i])) {
00162         return GetRawPtr(non_const_vecs_[i]);
00163       }
00164       else {
00165         return GetRawPtr(const_vecs_[i]);
00166       }
00167     }
00168 
00169     inline Vector* Vec(Index i)
00170     {
00171       DBG_ASSERT(i < NCols());
00172       DBG_ASSERT(IsValid(non_const_vecs_[i]));
00173       return GetRawPtr(non_const_vecs_[i]);
00174     }
00176   };
00177 
00180   class MultiVectorMatrixSpace : public MatrixSpace
00181   {
00182   public:
00188     MultiVectorMatrixSpace(Index ncols,
00189                            const VectorSpace& vec_space);
00190 
00192     ~MultiVectorMatrixSpace()
00193     {}
00195 
00197     MultiVectorMatrix* MakeNewMultiVectorMatrix() const
00198     {
00199       return new MultiVectorMatrix(this);
00200     }
00201 
00204     virtual Matrix* MakeNew() const
00205     {
00206       return MakeNewMultiVectorMatrix();
00207     }
00208 
00210     SmartPtr<const VectorSpace> ColVectorSpace() const
00211     {
00212       return vec_space_;
00213     }
00214 
00215   private:
00216     SmartPtr<const VectorSpace> vec_space_;
00217 
00218   };
00219 
00220   inline
00221   MultiVectorMatrix::~MultiVectorMatrix()
00222   {}
00223 
00224   inline
00225   SmartPtr<MultiVectorMatrix> MultiVectorMatrix::MakeNewMultiVectorMatrix() const
00226   {
00227     return owner_space_->MakeNewMultiVectorMatrix();
00228   }
00229 
00230   inline
00231   SmartPtr<const VectorSpace> MultiVectorMatrix::ColVectorSpace() const
00232   {
00233     return owner_space_->ColVectorSpace();
00234   }
00235 
00236   inline
00237   SmartPtr<const MultiVectorMatrixSpace>
00238   MultiVectorMatrix::MultiVectorMatrixOwnerSpace() const
00239   {
00240     return owner_space_;
00241   }
00242 
00243 } // namespace Ipopt
00244 #endif

Generated on Sun Nov 14 14:06:36 2010 for Coin-All by  doxygen 1.4.7