Ipopt Documentation  
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 // Authors: Carl Laird, Andreas Waechter IBM 2005-03-13
6 
7 #ifndef __IPTRIPLETTOCSRCONVERTER_HPP__
8 #define __IPTRIPLETTOCSRCONVERTER_HPP__
9 
10 #include "IpUtils.hpp"
11 #include "IpReferenced.hpp"
12 namespace Ipopt
13 {
14 
23 {
26  {
27  public:
28 
30  void Set(
31  Index i_row,
32  Index j_col,
33  Index i_pos_triplet
34  )
35  {
36  if( i_row > j_col )
37  {
38  i_row_ = j_col;
39  j_col_ = i_row;
40  }
41  else
42  {
43  i_row_ = i_row;
44  j_col_ = j_col;
45  }
46  i_pos_triplet_ = i_pos_triplet;
47  }
48 
50 
52  Index IRow() const
53  {
54  return i_row_;
55  }
56 
58  Index JCol() const
59  {
60  return j_col_;
61  }
62 
64  Index PosTriplet() const
65  {
66  return i_pos_triplet_;
67  }
69 
74  bool operator<(
75  const TripletEntry& Tentry
76  ) const
77  {
78  return ((i_row_ < Tentry.i_row_) || (i_row_ == Tentry.i_row_ && j_col_ < Tentry.j_col_));
79  }
80 
81  private:
83  Index i_row_;
88  };
89 
90 public:
92  enum ETriFull
93  {
98  };
99 
101  /* Constructor.
103  *
104  * If offset is 0, then the counting of indices in the compressed
105  * format starts a 0 (C-style numbering); if offset is 1, then the
106  * counting starts at 1 (Fortran-type numbering).
107  */
109  Index offset,
111  );
112 
114  virtual ~TripletToCSRConverter();
116 
131  Index dim,
132  Index nonzeros,
133  const Index* airn,
134  const Index* ajcn
135  );
136 
138 
140  const Index* IA() const
141  {
143  return ia_;
144  }
145 
147  const Index* JA() const
148  {
150  return ja_;
151  }
152 
153  const Index* iPosFirst() const
154  {
156  return ipos_first_;
157  }
159 
167  void ConvertValues(
168  Index nonzeros_triplet,
169  const Number* a_triplet,
170  Index nonzeros_compressed,
171  Number* a_compressed
172  );
173 
174 private:
182 
185 
188  const TripletToCSRConverter&
189  );
190 
192  void operator=(
193  const TripletToCSRConverter&
194  );
196 
199 
202 
205 
208 
211 
214 
217 
220 
223 
225 
233 
240 
244 };
245 
246 } // namespace Ipopt
247 
248 #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.
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:15
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.
bool operator<(const TripletEntry &Tentry) const
Comparison operator.
Index * ipos_first_
First elements assignment.
const Index * JA() const
Return the JA array for the condensed format.
This file contains a base class for all exceptions and a set of macros to help with exceptions...
Index * ja_
Array storing the values for JA in the condensed format.
Storing the reference count of all the smart pointers that currently reference it.
void operator=(const TripletToCSRConverter &)
Default Assignment Operator.
bool initialized_
Flag indicating if initialize method had been called.
ETriFull
Enum to specify 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:17
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:27
Index nonzeros_compressed_
Number of nonzeros in the compressed format.
Index PosTriplet() const
Index in original triplet matrix.
Index * ipos_double_compressed_
Position of multiple elements in compressed matrix.
virtual ~TripletToCSRConverter()
Destructor.