Ipopt 3.12.10

- Main Page
- Classes
- Files

- File List
- File Members

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
23 class TripletToCSRConverter: public ReferencedObject
24 {
26 class TripletEntry
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
74 Index i_row_;
75 Index j_col_;
76 Index i_pos_triplet_;
78 };
79
80 public:
82 enum ETriFull {
84 Triangular_Format,
86 Full_Format
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). */
95 TripletToCSRConverter(Index offset, ETriFull hf = Triangular_Format);
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 {
120 DBG_ASSERT(initialized_);
121 return ia_;
122 }
123
125 const Index* JA() const
126 {
127 DBG_ASSERT(initialized_);
128 return ja_;
129 }
130 const Index* iPosFirst() const
131 {
132 DBG_ASSERT(initialized_);
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:
155 TripletToCSRConverter();
156
158 TripletToCSRConverter(const TripletToCSRConverter&);
159
161 void operator=(const TripletToCSRConverter&);
163
165 Index offset_;
166
168 ETriFull hf_;
169
171 Index* ia_;
172
174 Index* ja_;
175
177 Index dim_;
178
180 Index nonzeros_triplet_;
181
183 Index nonzeros_compressed_;
184
186 Index num_doubles_;
187
189 bool initialized_;
190
197 Index* ipos_first_;
203 Index* ipos_double_triplet_;
205 Index* ipos_double_compressed_;
207 };
208
209
210 } // namespace Ipopt
211
212 #endif
Ipopt::TripletToCSRConverter::ipos_double_triplet_
Index * ipos_double_triplet_
Position of multiple elements in triplet matrix.
Definition: IpTripletToCSRConverter.hpp:203
Ipopt::TripletToCSRConverter::TripletEntry
Class for one triplet position entry.
Definition: IpTripletToCSRConverter.hpp:26
Ipopt::TripletToCSRConverter::Triangular_Format
Lower (or Upper) triangular stored only.
Definition: IpTripletToCSRConverter.hpp:84
IpUtils.hpp
Ipopt::TripletToCSRConverter::Full_Format
Store both lower and upper parts.
Definition: IpTripletToCSRConverter.hpp:86
Ipopt::TripletToCSRConverter::TripletToCSRConverter
TripletToCSRConverter()
Default Constructor.
Ipopt::TripletToCSRConverter::ConvertValues
void ConvertValues(Index nonzeros_triplet, const Number *a_triplet, Index nonzeros_compressed, Number *a_compressed)
Convert the values of the nonzero elements.
Ipopt::TripletToCSRConverter::TripletEntry::operator<
bool operator<(const TripletEntry &Tentry) const
Comparison operator.
Definition: IpTripletToCSRConverter.hpp:64
Ipopt::TripletToCSRConverter::offset_
Index offset_
Offset for CSR numbering.
Definition: IpTripletToCSRConverter.hpp:165
Ipopt::TripletToCSRConverter::InitializeConverter
Index InitializeConverter(Index dim, Index nonzeros, const Index *airn, const Index *ajcn)
Initialize the converter, given the fixed structure of the matrix.
Ipopt::Number
double Number
Type of all numbers.
Definition: IpTypes.hpp:17
Ipopt::TripletToCSRConverter
Class for converting symmetric matrices given in triplet format to matrices in compressed sparse row ...
Definition: IpTripletToCSRConverter.hpp:23
Ipopt::TripletToCSRConverter::TripletEntry::Set
void Set(Index i_row, Index j_col, Index i_pos_triplet)
Set the values of an entry.
Definition: IpTripletToCSRConverter.hpp:31
Ipopt::TripletToCSRConverter::ipos_first_
Index * ipos_first_
First elements assignement.
Definition: IpTripletToCSRConverter.hpp:197
Ipopt::TripletToCSRConverter::TripletEntry::i_row_
Index i_row_
Definition: IpTripletToCSRConverter.hpp:74
Ipopt::TripletToCSRConverter::TripletEntry::PosTriplet
Index PosTriplet() const
Index in original triplet matrix.
Definition: IpTripletToCSRConverter.hpp:57
Ipopt::TripletToCSRConverter::iPosFirst
const Index * iPosFirst() const
Definition: IpTripletToCSRConverter.hpp:130
Ipopt::TripletToCSRConverter::ja_
Index * ja_
Array storing the values for JA in the condensed format.
Definition: IpTripletToCSRConverter.hpp:174
Ipopt::ReferencedObject
ReferencedObject class.
Definition: IpReferenced.hpp:174
Ipopt::TripletToCSRConverter::operator=
void operator=(const TripletToCSRConverter &)
Overloaded Equals Operator.
Ipopt::TripletToCSRConverter::initialized_
bool initialized_
Flag indicating if initialize method had been called.
Definition: IpTripletToCSRConverter.hpp:189
Ipopt::TripletToCSRConverter::ETriFull
ETriFull
Enum to specifiy half or full matrix storage.
Definition: IpTripletToCSRConverter.hpp:82
Ipopt::TripletToCSRConverter::ia_
Index * ia_
Array storing the values for IA in the condensed format.
Definition: IpTripletToCSRConverter.hpp:171
Ipopt::TripletToCSRConverter::TripletEntry::IRow
Index IRow() const
Row position.
Definition: IpTripletToCSRConverter.hpp:47
Ipopt::TripletToCSRConverter::IA
const Index * IA() const
Return the IA array for the condensed format.
Definition: IpTripletToCSRConverter.hpp:118
Ipopt::TripletToCSRConverter::nonzeros_triplet_
Index nonzeros_triplet_
Number of nonzeros in the triplet format.
Definition: IpTripletToCSRConverter.hpp:180
Ipopt::TripletToCSRConverter::dim_
Index dim_
Dimension of the matrix.
Definition: IpTripletToCSRConverter.hpp:177
Ipopt::TripletToCSRConverter::num_doubles_
Index num_doubles_
Number of repeated entries.
Definition: IpTripletToCSRConverter.hpp:186
Ipopt::TripletToCSRConverter::hf_
ETriFull hf_
Indicator of half (ie lower only) or full (both upr and lwr) matrix.
Definition: IpTripletToCSRConverter.hpp:168
Ipopt::Index
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
IpReferenced.hpp
DBG_ASSERT
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
Ipopt::TripletToCSRConverter::nonzeros_compressed_
Index nonzeros_compressed_
Number of nonzeros in the compressed format.
Definition: IpTripletToCSRConverter.hpp:183
Ipopt::TripletToCSRConverter::TripletEntry::JCol
Index JCol() const
Column position.
Definition: IpTripletToCSRConverter.hpp:52
Ipopt::TripletToCSRConverter::TripletEntry::j_col_
Index j_col_
Definition: IpTripletToCSRConverter.hpp:75
Ipopt::TripletToCSRConverter::TripletEntry::i_pos_triplet_
Index i_pos_triplet_
Definition: IpTripletToCSRConverter.hpp:76
Ipopt::TripletToCSRConverter::ipos_double_compressed_
Index * ipos_double_compressed_
Position of multiple elements in compressed matrix.
Definition: IpTripletToCSRConverter.hpp:205
Ipopt::TripletToCSRConverter::~TripletToCSRConverter
virtual ~TripletToCSRConverter()
Destructor.
Ipopt::TripletToCSRConverter::JA
const Index * JA() const
Return the JA array for the condensed format.
Definition: IpTripletToCSRConverter.hpp:125