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 Eclipse Public License.
00004 //
00005 // $Id: IpTripletToCSRConverter.hpp 2490 2014-05-26 16:40:51Z stefan $
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:
00029 
00031       void Set(Index i_row, Index j_col, Index i_pos_triplet)
00032       {
00033         if (i_row>j_col) {
00034           i_row_ = j_col;
00035           j_col_ = i_row;
00036         }
00037         else {
00038           i_row_ = i_row;
00039           j_col_ = j_col;
00040         }
00041         i_pos_triplet_ = i_pos_triplet;
00042       }
00043 
00047       Index IRow() const
00048       {
00049         return i_row_;
00050       }
00052       Index JCol() const
00053       {
00054         return j_col_;
00055       }
00057       Index PosTriplet() const
00058       {
00059         return i_pos_triplet_;
00060       }
00062 
00064       bool operator< (const TripletEntry& Tentry) const
00065       {
00066         return ((i_row_ < Tentry.i_row_) ||
00067                 (i_row_==Tentry.i_row_ && j_col_<Tentry.j_col_));
00068       }
00069 
00070     private:
00071 
00074       Index i_row_;
00075       Index j_col_;
00076       Index i_pos_triplet_;
00078     };
00079 
00080   public:
00082     enum ETriFull {
00084       Triangular_Format,
00086       Full_Format
00087     };
00088 
00091     /* Constructor.  If offset is 0, then the counting of indices in
00092        the compressed format starts a 0 (C-style numbering); if offset
00093        is 1, then the counting starts at 1 (Fortran-type
00094        numbering). */
00095     TripletToCSRConverter(Index offset, ETriFull hf = Triangular_Format);
00096 
00098     virtual ~TripletToCSRConverter();
00100 
00111     Index InitializeConverter(Index dim, Index nonzeros,
00112                               const Index* airn,
00113                               const Index* ajcn);
00114 
00118     const Index* IA() const
00119     {
00120       DBG_ASSERT(initialized_);
00121       return ia_;
00122     }
00123 
00125     const Index* JA() const
00126     {
00127       DBG_ASSERT(initialized_);
00128       return ja_;
00129     }
00130     const Index* iPosFirst() const
00131     {
00132       DBG_ASSERT(initialized_);
00133       return ipos_first_;
00134     }
00136 
00142     void ConvertValues(Index nonzeros_triplet, const Number* a_triplet,
00143                        Index nonzeros_compressed, Number* a_compressed);
00144 
00145   private:
00155     TripletToCSRConverter();
00156 
00158     TripletToCSRConverter(const TripletToCSRConverter&);
00159 
00161     void operator=(const TripletToCSRConverter&);
00163 
00165     Index offset_;
00166 
00168     ETriFull hf_;
00169 
00171     Index* ia_;
00172 
00174     Index* ja_;
00175 
00177     Index dim_;
00178 
00180     Index nonzeros_triplet_;
00181 
00183     Index nonzeros_compressed_;
00184 
00186     Index num_doubles_;
00187 
00189     bool initialized_;
00190 
00197     Index* ipos_first_;
00203     Index* ipos_double_triplet_;
00205     Index* ipos_double_compressed_;
00207   };
00208 
00209 
00210 } // namespace Ipopt
00211 
00212 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 17 Aug 2014 for Ipopt by  doxygen 1.6.1