- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/SVN-release/Ipopt-3.7.1/Ipopt/src/LinAlg/IpMultiVectorMatrix.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2005, 2008 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Common Public License.
    00004 //
    00005 // $Id: IpMultiVectorMatrix.hpp 1324 2008-09-16 14:19:26Z 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 ComputeRowAMaxImpl(Vector& rows_norms, bool init) const;
    00120
    00121     virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const;
    00122
    00123     virtual void PrintImpl(const Journalist& jnlst,
    00124                            EJournalLevel level,
    00125                            EJournalCategory category,
    00126                            const std::string& name,
    00127                            Index indent,
    00128                            const std::string& prefix) const;
    00130
    00131
    00132   private:
    00142     MultiVectorMatrix();
    00143
    00145     MultiVectorMatrix(const MultiVectorMatrix&);
    00146
    00148     void operator=(const MultiVectorMatrix&);
    00150
    00151     const MultiVectorMatrixSpace* owner_space_;
    00152
    00154     std::vector<SmartPtr<const Vector> > const_vecs_;
    00155
    00157     std::vector<SmartPtr<Vector> > non_const_vecs_;
    00158
    00161     inline const Vector* ConstVec(Index i) const
    00162     {
    00163       DBG_ASSERT(i < NCols());
    00164       DBG_ASSERT(IsValid(const_vecs_[i]) || IsValid(non_const_vecs_[i]));
    00165       if (IsValid(non_const_vecs_[i])) {
    00166         return GetRawPtr(non_const_vecs_[i]);
    00167       }
    00168       else {
    00169         return GetRawPtr(const_vecs_[i]);
    00170       }
    00171     }
    00172
    00173     inline Vector* Vec(Index i)
    00174     {
    00175       DBG_ASSERT(i < NCols());
    00176       DBG_ASSERT(IsValid(non_const_vecs_[i]));
    00177       return GetRawPtr(non_const_vecs_[i]);
    00178     }
    00180   };
    00181
    00184   class MultiVectorMatrixSpace : public MatrixSpace
    00185   {
    00186   public:
    00192     MultiVectorMatrixSpace(Index ncols,
    00193                            const VectorSpace& vec_space);
    00194
    00196     ~MultiVectorMatrixSpace()
    00197     {}
    00199
    00201     MultiVectorMatrix* MakeNewMultiVectorMatrix() const
    00202     {
    00203       return new MultiVectorMatrix(this);
    00204     }
    00205
    00208     virtual Matrix* MakeNew() const
    00209     {
    00210       return MakeNewMultiVectorMatrix();
    00211     }
    00212
    00214     SmartPtr<const VectorSpace> ColVectorSpace() const
    00215     {
    00216       return vec_space_;
    00217     }
    00218
    00219   private:
    00220     SmartPtr<const VectorSpace> vec_space_;
    00221
    00222   };
    00223
    00224   inline
    00225   MultiVectorMatrix::~MultiVectorMatrix()
    00226   {}
    00227
    00228   inline
    00229   SmartPtr<MultiVectorMatrix> MultiVectorMatrix::MakeNewMultiVectorMatrix() const
    00230   {
    00231     return owner_space_->MakeNewMultiVectorMatrix();
    00232   }
    00233
    00234   inline
    00235   SmartPtr<const VectorSpace> MultiVectorMatrix::ColVectorSpace() const
    00236   {
    00237     return owner_space_->ColVectorSpace();
    00238   }
    00239
    00240   inline
    00241   SmartPtr<const MultiVectorMatrixSpace>
    00242   MultiVectorMatrix::MultiVectorMatrixOwnerSpace() const
    00243   {
    00244     return owner_space_;
    00245   }
    00246
    00247 } // namespace Ipopt
    00248 #endif