- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/SVN-release/Ipopt-3.7.1/Ipopt/src/Algorithm/LinearSolvers/IpTripletToCSRConverter.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: IpTripletToCSRConverter.hpp 1370 2008-10-07 22:57:07Z andreasw $
    00006 //
    00007 // Authors:  Carl Laird, Andreas Waechter     IBM    2005-03-13
    00008
    00009 #ifndef __IPTRIPLETTOCSRCONVERTER_HPP__
    00010 #define __IPTRIPLETTOCSRCONVERTER_HPP__
    00011
    00012 #include "IpUtils.hpp"
    00013 #include "IpReferenced.hpp"
    00014 namespace Ipopt
    00015 {
    00016
    00023   class TripletToCSRConverter: public ReferencedObject
    00024   {
    00026     class TripletEntry
    00027     {
    00028     public:
    00032       TripletEntry()
    00033       {}
    00034
    00036       ~TripletEntry()
    00037       {}
    00038
    00040       TripletEntry(const TripletEntry& rhs)
    00041       {
    00042         i_row_ = rhs.i_row_;
    00043         j_col_ = rhs.j_col_;
    00044         i_pos_triplet_ = rhs.i_pos_triplet_;
    00045       }
    00046
    00048       TripletEntry& operator=(const TripletEntry& rhs)
    00049       {
    00050         if (this!=&rhs) {
    00051           i_row_ = rhs.i_row_;
    00052           j_col_ = rhs.j_col_;
    00053           i_pos_triplet_ = rhs.i_pos_triplet_;
    00054         }
    00055         return *this;
    00056       }
    00058
    00060       void Set(Index i_row, Index j_col, Index i_pos_triplet)
    00061       {
    00062         if (i_row>j_col) {
    00063           i_row_ = j_col;
    00064           j_col_ = i_row;
    00065         }
    00066         else {
    00067           i_row_ = i_row;
    00068           j_col_ = j_col;
    00069         }
    00070         i_pos_triplet_ = i_pos_triplet;
    00071       }
    00072
    00076       Index IRow() const
    00077       {
    00078         return i_row_;
    00079       }
    00081       Index JCol() const
    00082       {
    00083         return j_col_;
    00084       }
    00086       Index PosTriplet() const
    00087       {
    00088         return i_pos_triplet_;
    00089       }
    00091
    00093       bool operator< (const TripletEntry& Tentry) const
    00094       {
    00095         return ((i_row_ < Tentry.i_row_) ||
    00096                 (i_row_==Tentry.i_row_ && j_col_<Tentry.j_col_));
    00097       }
    00098
    00099     private:
    00109       //TripletEntry();
    00110
    00112       /*
    00113       TripletEntry(const TripletEntry&);
    00114       */
    00116
    00119       Index i_row_;
    00120       Index j_col_;
    00121       Index i_pos_triplet_;
    00123     };
    00124
    00125   public:
    00128     /* Constructor.  If offset is 0, then the counting of indices in
    00129        the compressed format starts a 0 (C-style numbering); if offset
    00130        is 1, then the counting starts at 1 (Fortran-type
    00131        numbering). */
    00132     TripletToCSRConverter(Index offset);
    00133
    00135     virtual ~TripletToCSRConverter();
    00137
    00148     Index InitializeConverter(Index dim, Index nonzeros,
    00149                               const Index* airn,
    00150                               const Index* ajcn);
    00151
    00155     const Index* IA() const
    00156     {
    00157       DBG_ASSERT(initialized_);
    00158       return ia_;
    00159     }
    00160
    00162     const Index* JA() const
    00163     {
    00164       DBG_ASSERT(initialized_);
    00165       return ja_;
    00166     }
    00167     const Index* iPosFirst() const
    00168     {
    00169       DBG_ASSERT(initialized_);
    00170       return ipos_first_;
    00171     }
    00173
    00179     void ConvertValues(Index nonzeros_triplet, const Number* a_triplet,
    00180                        Index nonzeros_compressed, Number* a_compressed);
    00181
    00182   private:
    00192     TripletToCSRConverter();
    00193
    00195     TripletToCSRConverter(const TripletToCSRConverter&);
    00196
    00198     void operator=(const TripletToCSRConverter&);
    00200
    00202     Index offset_;
    00203
    00205     Index* ia_;
    00206
    00208     Index* ja_;
    00209
    00211     Index dim_;
    00212
    00214     Index nonzeros_triplet_;
    00215
    00217     Index nonzeros_compressed_;
    00218
    00220     bool initialized_;
    00221
    00228     Index* ipos_first_;
    00234     Index* ipos_double_triplet_;
    00236     Index* ipos_double_compressed_;
    00238   };
    00239
    00240
    00241 } // namespace Ipopt
    00242
    00243 #endif