Ipopt 3.11.9
Loading...
Searching...
No Matches
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 2490 2014-05-26 16:40:51Z 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"
14namespace 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 }
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:
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
100
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
163
166
169
172
175
178
181
184
187
190
207 };
208
209
210} // namespace Ipopt
211
212#endif
#define DBG_ASSERT(test)
Definition IpDebug.hpp:38
ReferencedObject class.
Class for one triplet position entry.
void Set(Index i_row, Index j_col, Index i_pos_triplet)
Set the values of an entry.
Index PosTriplet() const
Index in original triplet matrix.
bool operator<(const TripletEntry &Tentry) const
Comparison operator.
Class for converting symmetric matrices given in triplet format to matrices in compressed sparse row ...
TripletToCSRConverter(const TripletToCSRConverter &)
Copy Constructor.
Index offset_
Offset for CSR numbering.
const Index * JA() const
Return the JA array for the condensed format.
void ConvertValues(Index nonzeros_triplet, const Number *a_triplet, Index nonzeros_compressed, Number *a_compressed)
Convert the values of the nonzero elements.
const Index * IA() const
Return the IA array for the condensed format.
Index * ipos_double_compressed_
Position of multiple elements in compressed matrix.
Index * ipos_double_triplet_
Position of multiple elements in triplet matrix.
Index nonzeros_triplet_
Number of nonzeros in the triplet format.
Index nonzeros_compressed_
Number of nonzeros in the compressed format.
Index * ja_
Array storing the values for JA in the condensed format.
virtual ~TripletToCSRConverter()
Destructor.
bool initialized_
Flag indicating if initialize method had been called.
Index num_doubles_
Number of repeated entries.
Index * ia_
Array storing the values for IA in the condensed format.
Index dim_
Dimension of the matrix.
TripletToCSRConverter(Index offset, ETriFull hf=Triangular_Format)
TripletToCSRConverter()
Default Constructor.
void operator=(const TripletToCSRConverter &)
Overloaded Equals Operator.
ETriFull hf_
Indicator of half (ie lower only) or full (both upr and lwr) matrix.
Index InitializeConverter(Index dim, Index nonzeros, const Index *airn, const Index *ajcn)
Initialize the converter, given the fixed structure of the matrix.
Index * ipos_first_
First elements assignement.
ETriFull
Enum to specifiy half or full matrix storage.
@ Full_Format
Store both lower and upper parts.
@ Triangular_Format
Lower (or Upper) triangular stored only.
int Index
Type of all indices of vectors, matrices etc.
Definition IpTypes.hpp:19
double Number
Type of all numbers.
Definition IpTypes.hpp:17