- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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

Go to the documentation of this file.

    00001 // Copyright (C) 2004, 2009 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Common Public License.
    00004 //
    00005 // $Id: IpGenTMatrix.hpp 1492 2009-07-07 02:11:04Z 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 ComputeRowAMaxImpl(Vector& rows_norms, bool init) const;
    00104
    00105     virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const;
    00106
    00107     virtual void PrintImpl(const Journalist& jnlst,
    00108                            EJournalLevel level,
    00109                            EJournalCategory category,
    00110                            const std::string& name,
    00111                            Index indent,
    00112                            const std::string& prefix) const
    00113     {
    00114       PrintImplOffset(jnlst, level, category, name, indent, prefix, 0);
    00115     }
    00117
    00118     void PrintImplOffset(const Journalist& jnlst,
    00119                          EJournalLevel level,
    00120                          EJournalCategory category,
    00121                          const std::string& name,
    00122                          Index indent,
    00123                          const std::string& prefix,
    00124                          Index offset) const;
    00125
    00126     friend class ParGenMatrix;
    00127
    00128   private:
    00138     GenTMatrix();
    00139
    00141     GenTMatrix(const GenTMatrix&);
    00142
    00144     void operator=(const GenTMatrix&);
    00146
    00150     const GenTMatrixSpace* owner_space_;
    00151
    00153     Number* values_;
    00154
    00156     bool initialized_;
    00157
    00158   };
    00159
    00164   class GenTMatrixSpace : public MatrixSpace
    00165   {
    00166   public:
    00176     GenTMatrixSpace(Index nRows, Index nCols,
    00177                     Index nonZeros,
    00178                     const Index* iRows, const Index* jCols);
    00179
    00181     ~GenTMatrixSpace()
    00182     {
    00183       delete [] iRows_;
    00184       delete [] jCols_;
    00185     }
    00187
    00189     GenTMatrix* MakeNewGenTMatrix() const
    00190     {
    00191       return new GenTMatrix(this);
    00192     }
    00193
    00196     virtual Matrix* MakeNew() const
    00197     {
    00198       return MakeNewGenTMatrix();
    00199     }
    00200
    00204     Index Nonzeros() const
    00205     {
    00206       return nonZeros_;
    00207     }
    00208
    00210     const Index* Irows() const
    00211     {
    00212       return iRows_;
    00213     }
    00214
    00216     const Index* Jcols() const
    00217     {
    00218       return jCols_;
    00219     }
    00221
    00222   private:
    00227     const Index nonZeros_;
    00228     Index* jCols_;
    00229     Index* iRows_;
    00231
    00234     Number* AllocateInternalStorage() const;
    00235
    00238     void FreeInternalStorage(Number* values) const;
    00239
    00240     friend class GenTMatrix;
    00241   };
    00242
    00243   /* inline methods */
    00244   inline
    00245   Index GenTMatrix::Nonzeros() const
    00246   {
    00247     return owner_space_->Nonzeros();
    00248   }
    00249
    00250   inline
    00251   const Index* GenTMatrix::Irows() const
    00252   {
    00253     return owner_space_->Irows();
    00254   }
    00255
    00256   inline
    00257   const Index* GenTMatrix::Jcols() const
    00258   {
    00259     return owner_space_->Jcols();
    00260   }
    00261
    00262
    00263 } // namespace Ipopt
    00264 #endif