- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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

Go to the documentation of this file.

    00001 // Copyright (C) 2004, 2008 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Common Public License.
    00004 //
    00005 // $Id: IpGenTMatrix.hpp 1290 2008-08-25 15:48: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 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;
    00114
    00115
    00116   private:
    00126     GenTMatrix();
    00127
    00129     GenTMatrix(const GenTMatrix&);
    00130
    00132     void operator=(const GenTMatrix&);
    00134
    00138     const GenTMatrixSpace* owner_space_;
    00139
    00141     Number* values_;
    00142
    00144     bool initialized_;
    00145
    00146   };
    00147
    00152   class GenTMatrixSpace : public MatrixSpace
    00153   {
    00154   public:
    00164     GenTMatrixSpace(Index nRows, Index nCols,
    00165                     Index nonZeros,
    00166                     const Index* iRows, const Index* jCols);
    00167
    00169     ~GenTMatrixSpace()
    00170     {
    00171       delete [] iRows_;
    00172       delete [] jCols_;
    00173     }
    00175
    00177     GenTMatrix* MakeNewGenTMatrix() const
    00178     {
    00179       return new GenTMatrix(this);
    00180     }
    00181
    00184     virtual Matrix* MakeNew() const
    00185     {
    00186       return MakeNewGenTMatrix();
    00187     }
    00188
    00192     Index Nonzeros() const
    00193     {
    00194       return nonZeros_;
    00195     }
    00196
    00198     const Index* Irows() const
    00199     {
    00200       return iRows_;
    00201     }
    00202
    00204     const Index* Jcols() const
    00205     {
    00206       return jCols_;
    00207     }
    00209
    00210   private:
    00215     const Index nonZeros_;
    00216     Index* jCols_;
    00217     Index* iRows_;
    00219
    00222     Number* AllocateInternalStorage() const;
    00223
    00226     void FreeInternalStorage(Number* values) const;
    00227
    00228     friend class GenTMatrix;
    00229   };
    00230
    00231   /* inline methods */
    00232   inline
    00233   Index GenTMatrix::Nonzeros() const
    00234   {
    00235     return owner_space_->Nonzeros();
    00236   }
    00237
    00238   inline
    00239   const Index* GenTMatrix::Irows() const
    00240   {
    00241     return owner_space_->Irows();
    00242   }
    00243
    00244   inline
    00245   const Index* GenTMatrix::Jcols() const
    00246   {
    00247     return owner_space_->Jcols();
    00248   }
    00249
    00250
    00251 } // namespace Ipopt
    00252 #endif