Ipopt  3.12.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpTripletToCSRConverter.hpp
Go to the documentation of this file.
1 // Copyright (C) 2005, 2008 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpTripletToCSRConverter.hpp 2488 2014-05-17 14:23:00Z stefan $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2005-03-13
8 
9 #ifndef __IPTRIPLETTOCSRCONVERTER_HPP__
10 #define __IPTRIPLETTOCSRCONVERTER_HPP__
11 
12 #include "IpUtils.hpp"
13 #include "IpReferenced.hpp"
14 namespace Ipopt
15 {
16 
24  {
27  {
28  public:
29 
31  void Set(Index i_row, Index j_col, Index i_pos_triplet)
32  {
33  if (i_row>j_col) {
34  i_row_ = j_col;
35  j_col_ = i_row;
36  }
37  else {
38  i_row_ = i_row;
39  j_col_ = j_col;
40  }
41  i_pos_triplet_ = i_pos_triplet;
42  }
43 
47  Index IRow() const
48  {
49  return i_row_;
50  }
52  Index JCol() const
53  {
54  return j_col_;
55  }
57  Index PosTriplet() const
58  {
59  return i_pos_triplet_;
60  }
62 
64  bool operator< (const TripletEntry& Tentry) const
65  {
66  return ((i_row_ < Tentry.i_row_) ||
67  (i_row_==Tentry.i_row_ && j_col_<Tentry.j_col_));
68  }
69 
70  private:
71 
78  };
79 
80  public:
82  enum ETriFull {
87  };
88 
91  /* Constructor. If offset is 0, then the counting of indices in
92  the compressed format starts a 0 (C-style numbering); if offset
93  is 1, then the counting starts at 1 (Fortran-type
94  numbering). */
96 
98  virtual ~TripletToCSRConverter();
100 
111  Index InitializeConverter(Index dim, Index nonzeros,
112  const Index* airn,
113  const Index* ajcn);
114 
118  const Index* IA() const
119  {
121  return ia_;
122  }
123 
125  const Index* JA() const
126  {
128  return ja_;
129  }
130  const Index* iPosFirst() const
131  {
133  return ipos_first_;
134  }
136 
142  void ConvertValues(Index nonzeros_triplet, const Number* a_triplet,
143  Index nonzeros_compressed, Number* a_compressed);
144 
145  private:
156 
159 
161  void operator=(const TripletToCSRConverter&);
163 
166 
169 
172 
175 
178 
181 
184 
187 
190 
207  };
208 
209 
210 } // namespace Ipopt
211 
212 #endif
Index * ipos_double_triplet_
Position of multiple elements in triplet matrix.
Class for one triplet position entry.
Lower (or Upper) triangular stored only.
TripletToCSRConverter()
Default Constructor.
void ConvertValues(Index nonzeros_triplet, const Number *a_triplet, Index nonzeros_compressed, Number *a_compressed)
Convert the values of the nonzero elements.
bool operator<(const TripletEntry &Tentry) const
Comparison operator.
Index offset_
Offset for CSR numbering.
Index InitializeConverter(Index dim, Index nonzeros, const Index *airn, const Index *ajcn)
Initialize the converter, given the fixed structure of the matrix.
double Number
Type of all numbers.
Definition: IpTypes.hpp:17
Class for converting symmetric matrices given in triplet format to matrices in compressed sparse row ...
void Set(Index i_row, Index j_col, Index i_pos_triplet)
Set the values of an entry.
Index * ipos_first_
First elements assignement.
Index PosTriplet() const
Index in original triplet matrix.
Index * ja_
Array storing the values for JA in the condensed format.
ReferencedObject class.
void operator=(const TripletToCSRConverter &)
Overloaded Equals Operator.
bool initialized_
Flag indicating if initialize method had been called.
ETriFull
Enum to specifiy half or full matrix storage.
Index * ia_
Array storing the values for IA in the condensed format.
const Index * IA() const
Return the IA array for the condensed format.
Index nonzeros_triplet_
Number of nonzeros in the triplet format.
Index dim_
Dimension of the matrix.
Index num_doubles_
Number of repeated entries.
ETriFull hf_
Indicator of half (ie lower only) or full (both upr and lwr) matrix.
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
Index nonzeros_compressed_
Number of nonzeros in the compressed format.
Index * ipos_double_compressed_
Position of multiple elements in compressed matrix.
virtual ~TripletToCSRConverter()
Destructor.
const Index * JA() const
Return the JA array for the condensed format.