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

Go to the documentation of this file.
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: IpGenTMatrix.hpp 798 2006-10-13 19:58:22Z andreasw $
00006 //
00007 // Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
00008 
00009 #ifndef __IPGENTMATRIX_HPP__
00010 #define __IPGENTMATRIX_HPP__
00011 
00012 #include "IpUtils.hpp"
00013 #include "IpMatrix.hpp"
00014 
00015 namespace Ipopt
00016 {
00017 
00018   /* forward declarations */
00019   class GenTMatrixSpace;
00020 
00036   class GenTMatrix : public Matrix
00037   {
00038   public:
00039 
00042 
00045     GenTMatrix(const GenTMatrixSpace* owner_space);
00046 
00048     ~GenTMatrix();
00050 
00058     void SetValues(const Number* Values);
00060 
00064     Index Nonzeros() const;
00065 
00067     const Index* Irows() const;
00068 
00070     const Index* Jcols() const;
00071 
00073     const Number* Values() const
00074     {
00075       return values_;
00076     }
00077 
00082     Number* Values()
00083     {
00084       ObjectChanged();
00085       initialized_ = true;
00086       return values_;
00087     }
00089 
00090   protected:
00093     virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta,
00094                                 Vector &y) const;
00095 
00096     virtual void TransMultVectorImpl(Number alpha, const Vector& x, Number beta,
00097                                      Vector& y) const;
00098 
00101     virtual bool HasValidNumbersImpl() const;
00102 
00103     virtual void PrintImpl(const Journalist& jnlst,
00104                            EJournalLevel level,
00105                            EJournalCategory category,
00106                            const std::string& name,
00107                            Index indent,
00108                            const std::string& prefix) const;
00110 
00111 
00112   private:
00122     GenTMatrix();
00123 
00125     GenTMatrix(const GenTMatrix&);
00126 
00128     void operator=(const GenTMatrix&);
00130 
00134     const GenTMatrixSpace* owner_space_;
00135 
00137     Number* values_;
00138 
00140     bool initialized_;
00141 
00142   };
00143 
00148   class GenTMatrixSpace : public MatrixSpace
00149   {
00150   public:
00160     GenTMatrixSpace(Index nRows, Index nCols,
00161                     Index nonZeros,
00162                     const Index* iRows, const Index* jCols);
00163 
00165     ~GenTMatrixSpace()
00166     {
00167       delete [] iRows_;
00168       delete [] jCols_;
00169     }
00171 
00173     GenTMatrix* MakeNewGenTMatrix() const
00174     {
00175       return new GenTMatrix(this);
00176     }
00177 
00180     virtual Matrix* MakeNew() const
00181     {
00182       return MakeNewGenTMatrix();
00183     }
00184 
00188     Index Nonzeros() const
00189     {
00190       return nonZeros_;
00191     }
00192 
00194     const Index* Irows() const
00195     {
00196       return iRows_;
00197     }
00198 
00200     const Index* Jcols() const
00201     {
00202       return jCols_;
00203     }
00205 
00206   private:
00211     const Index nonZeros_;
00212     Index* jCols_;
00213     Index* iRows_;
00215 
00218     Number* AllocateInternalStorage() const;
00219 
00222     void FreeInternalStorage(Number* values) const;
00223 
00224     friend class GenTMatrix;
00225   };
00226 
00227   /* inline methods */
00228   inline
00229   Index GenTMatrix::Nonzeros() const
00230   {
00231     return owner_space_->Nonzeros();
00232   }
00233 
00234   inline
00235   const Index* GenTMatrix::Irows() const
00236   {
00237     return owner_space_->Irows();
00238   }
00239 
00240   inline
00241   const Index* GenTMatrix::Jcols() const
00242   {
00243     return owner_space_->Jcols();
00244   }
00245 
00246 
00247 } // namespace Ipopt
00248 #endif

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