IpTripletToCSRConverter.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2005, 2006 International Business Machines and others.
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // $Id: IpTripletToCSRConverter.hpp 759 2006-07-07 03:07:08Z 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 
00043       TripletEntry(const TripletEntry&)
00044       {}
00046 
00048       void Set(Index i_row, Index j_col, Index i_pos_triplet)
00049       {
00050         if (i_row>j_col) {
00051           i_row_ = j_col;
00052           j_col_ = i_row;
00053         }
00054         else {
00055           i_row_ = i_row;
00056           j_col_ = j_col;
00057         }
00058         i_pos_triplet_ = i_pos_triplet;
00059       }
00060 
00064       Index IRow() const
00065       {
00066         return i_row_;
00067       }
00069       Index JCol() const
00070       {
00071         return j_col_;
00072       }
00074       Index PosTriplet() const
00075       {
00076         return i_pos_triplet_;
00077       }
00079 
00081       bool operator< (const TripletEntry& Tentry) const
00082       {
00083         return ((i_row_ < Tentry.i_row_) ||
00084                 (i_row_==Tentry.i_row_ && j_col_<Tentry.j_col_));
00085       }
00086 
00087     private:
00097       //TripletEntry();
00098 
00100       /*
00101       TripletEntry(const TripletEntry&);
00102       */
00103 
00105       void operator=(const TripletEntry&);
00107 
00110       Index i_row_;
00111       Index j_col_;
00112       Index i_pos_triplet_;
00114     };
00115 
00116   public:
00119     /* Constructor.  If offset is 0, then the counting of indices in
00120        the compressed format starts a 0 (C-style numbering); if offset
00121        is 1, then the counting starts at 1 (Fortran-type
00122        numbering). */
00123     TripletToCSRConverter(Index offset);
00124 
00126     virtual ~TripletToCSRConverter();
00128 
00139     Index InitializeConverter(Index dim, Index nonzeros,
00140                               const Index* airn,
00141                               const Index* ajcn);
00142 
00144     const Index* IA() const
00145     {
00146       DBG_ASSERT(initialized_);
00147       return ia_;
00148     }
00149 
00151     const Index* JA() const
00152     {
00153       DBG_ASSERT(initialized_);
00154       return ja_;
00155     }
00156 
00162     void ConvertValues(Index nonzeros_triplet, const Number* a_triplet,
00163                        Index nonzeros_compressed, Number* a_compressed);
00164 
00165   private:
00175     TripletToCSRConverter();
00176 
00178     TripletToCSRConverter(const TripletToCSRConverter&);
00179 
00181     void operator=(const TripletToCSRConverter&);
00183 
00185     Index offset_;
00186 
00188     Index* ia_;
00189 
00191     Index* ja_;
00192 
00194     Index dim_;
00195 
00197     Index nonzeros_triplet_;
00198 
00200     Index nonzeros_compressed_;
00201 
00203     bool initialized_;
00204 
00211     Index* ipos_first_;
00217     Index* ipos_double_triplet_;
00219     Index* ipos_double_compressed_;
00221   };
00222 
00223 
00224 } // namespace Ipopt
00225 
00226 #endif

Generated on Fri Sep 26 07:44:13 2008 for SimTKcore by  doxygen 1.5.6