Main Page
Namespaces
Classes
Files
File List
File Members
tmp
buildd
coinor-ipopt-3.10.2
Ipopt
src
Algorithm
LinearSolvers
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 1861 2010-12-21 21:34:47Z andreasw $
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
:
32
TripletEntry
()
33
{}
34
36
~TripletEntry
()
37
{}
38
40
TripletEntry
(
const
TripletEntry
& rhs)
41
{
42
i_row_
= rhs.
i_row_
;
43
j_col_
= rhs.
j_col_
;
44
i_pos_triplet_
= rhs.
i_pos_triplet_
;
45
}
46
48
TripletEntry
&
operator=
(
const
TripletEntry
& rhs)
49
{
50
if
(
this
!=&rhs) {
51
i_row_
= rhs.
i_row_
;
52
j_col_
= rhs.
j_col_
;
53
i_pos_triplet_
= rhs.
i_pos_triplet_
;
54
}
55
return
*
this
;
56
}
58
60
void
Set
(
Index
i_row,
Index
j_col,
Index
i_pos_triplet)
61
{
62
if
(i_row>j_col) {
63
i_row_
= j_col;
64
j_col_
= i_row;
65
}
66
else
{
67
i_row_
= i_row;
68
j_col_
= j_col;
69
}
70
i_pos_triplet_
= i_pos_triplet;
71
}
72
76
Index
IRow
()
const
77
{
78
return
i_row_
;
79
}
81
Index
JCol
()
const
82
{
83
return
j_col_
;
84
}
86
Index
PosTriplet
()
const
87
{
88
return
i_pos_triplet_
;
89
}
91
93
bool
operator<
(
const
TripletEntry
& Tentry)
const
94
{
95
return
((
i_row_
< Tentry.
i_row_
) ||
96
(
i_row_
==Tentry.
i_row_
&&
j_col_
<Tentry.
j_col_
));
97
}
98
99
private
:
109
//TripletEntry();
110
112
/*
113
TripletEntry(const TripletEntry&);
114
*/
116
119
Index
i_row_
;
120
Index
j_col_
;
121
Index
i_pos_triplet_
;
123
};
124
125
public
:
127
enum
ETriFull
{
129
Triangular_Format
,
131
Full_Format
132
};
133
136
/* Constructor. If offset is 0, then the counting of indices in
137
the compressed format starts a 0 (C-style numbering); if offset
138
is 1, then the counting starts at 1 (Fortran-type
139
numbering). */
140
TripletToCSRConverter
(
Index
offset,
ETriFull
hf =
Triangular_Format
);
141
143
virtual
~TripletToCSRConverter
();
145
156
Index
InitializeConverter
(
Index
dim,
Index
nonzeros,
157
const
Index
* airn,
158
const
Index
* ajcn);
159
163
const
Index
*
IA
()
const
164
{
165
DBG_ASSERT
(
initialized_
);
166
return
ia_
;
167
}
168
170
const
Index
*
JA
()
const
171
{
172
DBG_ASSERT
(
initialized_
);
173
return
ja_
;
174
}
175
const
Index
*
iPosFirst
()
const
176
{
177
DBG_ASSERT
(
initialized_
);
178
return
ipos_first_
;
179
}
181
187
void
ConvertValues
(
Index
nonzeros_triplet,
const
Number
* a_triplet,
188
Index
nonzeros_compressed,
Number
* a_compressed);
189
190
private
:
200
TripletToCSRConverter
();
201
203
TripletToCSRConverter
(
const
TripletToCSRConverter
&);
204
206
void
operator=
(
const
TripletToCSRConverter
&);
208
210
Index
offset_
;
211
213
ETriFull
hf_
;
214
216
Index
*
ia_
;
217
219
Index
*
ja_
;
220
222
Index
dim_
;
223
225
Index
nonzeros_triplet_
;
226
228
Index
nonzeros_compressed_
;
229
231
bool
initialized_
;
232
239
Index
*
ipos_first_
;
245
Index
*
ipos_double_triplet_
;
247
Index
*
ipos_double_compressed_
;
249
};
250
251
252
}
// namespace Ipopt
253
254
#endif
Generated on Tue Jun 26 2012 17:01:43 by
1.8.1.1