SkylineStorage.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2009 Guillaume Saupin <guillaume.saupin@cea.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_SKYLINE_STORAGE_H
11 #define EIGEN_SKYLINE_STORAGE_H
12 
13 namespace Eigen {
14 
21 template<typename Scalar>
24  typedef SparseIndex Index;
25 public:
26 
28  : m_diag(0),
29  m_lower(0),
30  m_upper(0),
31  m_lowerProfile(0),
32  m_upperProfile(0),
33  m_diagSize(0),
34  m_upperSize(0),
35  m_lowerSize(0),
38  m_allocatedSize(0) {
39  }
40 
42  : m_diag(0),
43  m_lower(0),
44  m_upper(0),
45  m_lowerProfile(0),
46  m_upperProfile(0),
47  m_diagSize(0),
48  m_upperSize(0),
49  m_lowerSize(0),
52  m_allocatedSize(0) {
53  *this = other;
54  }
55 
57  resize(other.diagSize(), other.m_upperProfileSize, other.m_lowerProfileSize, other.upperSize(), other.lowerSize());
58  memcpy(m_diag, other.m_diag, m_diagSize * sizeof (Scalar));
59  memcpy(m_upper, other.m_upper, other.upperSize() * sizeof (Scalar));
60  memcpy(m_lower, other.m_lower, other.lowerSize() * sizeof (Scalar));
61  memcpy(m_upperProfile, other.m_upperProfile, m_upperProfileSize * sizeof (Index));
62  memcpy(m_lowerProfile, other.m_lowerProfile, m_lowerProfileSize * sizeof (Index));
63  return *this;
64  }
65 
67  std::swap(m_diag, other.m_diag);
68  std::swap(m_upper, other.m_upper);
69  std::swap(m_lower, other.m_lower);
70  std::swap(m_upperProfile, other.m_upperProfile);
71  std::swap(m_lowerProfile, other.m_lowerProfile);
72  std::swap(m_diagSize, other.m_diagSize);
73  std::swap(m_upperSize, other.m_upperSize);
74  std::swap(m_lowerSize, other.m_lowerSize);
75  std::swap(m_allocatedSize, other.m_allocatedSize);
76  }
77 
79  delete[] m_diag;
80  delete[] m_upper;
81  if (m_upper != m_lower)
82  delete[] m_lower;
83  delete[] m_upperProfile;
84  delete[] m_lowerProfile;
85  }
86 
88  Index newAllocatedSize = size + upperSize + lowerSize;
89  if (newAllocatedSize > m_allocatedSize)
91  }
92 
93  void squeeze() {
96  }
97 
100  reallocate(diagSize, upperProfileSize, lowerProfileSize, upperSize + Index(reserveSizeFactor * upperSize), lowerSize + Index(reserveSizeFactor * lowerSize));
106  }
107 
108  inline Index diagSize() const {
109  return m_diagSize;
110  }
111 
112  inline Index upperSize() const {
113  return m_upperSize;
114  }
115 
116  inline Index lowerSize() const {
117  return m_lowerSize;
118  }
119 
120  inline Index upperProfileSize() const {
121  return m_upperProfileSize;
122  }
123 
124  inline Index lowerProfileSize() const {
125  return m_lowerProfileSize;
126  }
127 
128  inline Index allocatedSize() const {
129  return m_allocatedSize;
130  }
131 
132  inline void clear() {
133  m_diagSize = 0;
134  }
135 
136  inline Scalar& diag(Index i) {
137  return m_diag[i];
138  }
139 
140  inline const Scalar& diag(Index i) const {
141  return m_diag[i];
142  }
143 
144  inline Scalar& upper(Index i) {
145  return m_upper[i];
146  }
147 
148  inline const Scalar& upper(Index i) const {
149  return m_upper[i];
150  }
151 
152  inline Scalar& lower(Index i) {
153  return m_lower[i];
154  }
155 
156  inline const Scalar& lower(Index i) const {
157  return m_lower[i];
158  }
159 
161  return m_upperProfile[i];
162  }
163 
164  inline const Index& upperProfile(Index i) const {
165  return m_upperProfile[i];
166  }
167 
169  return m_lowerProfile[i];
170  }
171 
172  inline const Index& lowerProfile(Index i) const {
173  return m_lowerProfile[i];
174  }
175 
178  res.m_upperProfile = upperProfile;
179  res.m_lowerProfile = lowerProfile;
180  res.m_diag = diag;
181  res.m_upper = upper;
182  res.m_lower = lower;
183  res.m_allocatedSize = res.m_diagSize = size;
184  res.m_upperSize = upperSize;
185  res.m_lowerSize = lowerSize;
186  return res;
187  }
188 
189  inline void reset() {
190  memset(m_diag, 0, m_diagSize * sizeof (Scalar));
191  memset(m_upper, 0, m_upperSize * sizeof (Scalar));
192  memset(m_lower, 0, m_lowerSize * sizeof (Scalar));
193  memset(m_upperProfile, 0, m_diagSize * sizeof (Index));
194  memset(m_lowerProfile, 0, m_diagSize * sizeof (Index));
195  }
196 
197  void prune(Scalar reference, RealScalar epsilon = dummy_precision<RealScalar>()) {
198  //TODO
199  }
200 
201 protected:
202 
204 
205  Scalar* diag = new Scalar[diagSize];
206  Scalar* upper = new Scalar[upperSize];
207  Scalar* lower = new Scalar[lowerSize];
210 
211  Index copyDiagSize = (std::min)(diagSize, m_diagSize);
212  Index copyUpperSize = (std::min)(upperSize, m_upperSize);
213  Index copyLowerSize = (std::min)(lowerSize, m_lowerSize);
214  Index copyUpperProfileSize = (std::min)(upperProfileSize, m_upperProfileSize);
215  Index copyLowerProfileSize = (std::min)(lowerProfileSize, m_lowerProfileSize);
216 
217  // copy
218  memcpy(diag, m_diag, copyDiagSize * sizeof (Scalar));
219  memcpy(upper, m_upper, copyUpperSize * sizeof (Scalar));
220  memcpy(lower, m_lower, copyLowerSize * sizeof (Scalar));
221  memcpy(upperProfile, m_upperProfile, copyUpperProfileSize * sizeof (Index));
222  memcpy(lowerProfile, m_lowerProfile, copyLowerProfileSize * sizeof (Index));
223 
224 
225 
226  // delete old stuff
227  delete[] m_diag;
228  delete[] m_upper;
229  delete[] m_lower;
230  delete[] m_upperProfile;
231  delete[] m_lowerProfile;
232  m_diag = diag;
233  m_upper = upper;
234  m_lower = lower;
240  }
241 
242 public:
254 
255 };
256 
257 } // end namespace Eigen
258 
259 #endif // EIGEN_SKYLINE_STORAGE_H
Eigen::SkylineStorage::operator=
SkylineStorage & operator=(const SkylineStorage &other)
Definition: SkylineStorage.h:56
Eigen::SkylineStorage::reallocate
void reallocate(Index diagSize, Index upperProfileSize, Index lowerProfileSize, Index upperSize, Index lowerSize)
Definition: SkylineStorage.h:203
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::SkylineStorage::m_diag
Scalar * m_diag
Definition: SkylineStorage.h:243
Eigen::SkylineStorage::~SkylineStorage
~SkylineStorage()
Definition: SkylineStorage.h:78
Eigen::SkylineStorage::clear
void clear()
Definition: SkylineStorage.h:132
Eigen::SkylineStorage::lower
const Scalar & lower(Index i) const
Definition: SkylineStorage.h:156
Eigen::SkylineStorage::SkylineStorage
SkylineStorage()
Definition: SkylineStorage.h:27
Eigen::SkylineStorage::m_allocatedSize
Index m_allocatedSize
Definition: SkylineStorage.h:253
Eigen::SkylineStorage::upperProfile
Index & upperProfile(Index i)
Definition: SkylineStorage.h:160
Eigen::SkylineStorage::squeeze
void squeeze()
Definition: SkylineStorage.h:93
Eigen::SkylineStorage::reset
void reset()
Definition: SkylineStorage.h:189
Eigen::SkylineStorage::diagSize
Index diagSize() const
Definition: SkylineStorage.h:108
res
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
Eigen::SkylineStorage::m_lowerProfileSize
Index m_lowerProfileSize
Definition: SkylineStorage.h:252
Eigen::SkylineStorage::m_upperSize
Index m_upperSize
Definition: SkylineStorage.h:249
Eigen::SkylineStorage::lower
Scalar & lower(Index i)
Definition: SkylineStorage.h:152
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Eigen::SkylineStorage::allocatedSize
Index allocatedSize() const
Definition: SkylineStorage.h:128
Eigen::SkylineStorage::m_upperProfile
Index * m_upperProfile
Definition: SkylineStorage.h:246
epsilon
static double epsilon
Definition: testRot3.cpp:37
Eigen::SkylineStorage::upperProfileSize
Index upperProfileSize() const
Definition: SkylineStorage.h:120
Eigen::SkylineStorage::lowerSize
Index lowerSize() const
Definition: SkylineStorage.h:116
Eigen::SkylineStorage
Definition: SkylineStorage.h:22
Eigen::SkylineStorage::RealScalar
NumTraits< Scalar >::Real RealScalar
Definition: SkylineStorage.h:23
Eigen::SkylineStorage::Index
SparseIndex Index
Definition: SkylineStorage.h:24
Eigen::SkylineStorage::m_lower
Scalar * m_lower
Definition: SkylineStorage.h:245
std::swap
void swap(GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &a, GeographicLib::NearestNeighbor< dist_t, pos_t, distfun_t > &b)
Definition: NearestNeighbor.hpp:827
Eigen::SkylineStorage::m_diagSize
Index m_diagSize
Definition: SkylineStorage.h:248
Eigen::SkylineStorage::upperProfile
const Index & upperProfile(Index i) const
Definition: SkylineStorage.h:164
Eigen::SkylineStorage::m_upper
Scalar * m_upper
Definition: SkylineStorage.h:244
Eigen::SkylineStorage::diag
Scalar & diag(Index i)
Definition: SkylineStorage.h:136
Eigen::SkylineStorage::lowerProfileSize
Index lowerProfileSize() const
Definition: SkylineStorage.h:124
Eigen::SkylineStorage::reserve
void reserve(Index size, Index upperProfileSize, Index lowerProfileSize, Index upperSize, Index lowerSize)
Definition: SkylineStorage.h:87
Eigen::SkylineStorage::lowerProfile
const Index & lowerProfile(Index i) const
Definition: SkylineStorage.h:172
Eigen::SkylineStorage::lowerProfile
Index & lowerProfile(Index i)
Definition: SkylineStorage.h:168
Eigen::SkylineStorage::m_upperProfileSize
Index m_upperProfileSize
Definition: SkylineStorage.h:251
Eigen::SkylineStorage::Map
static SkylineStorage Map(Index *upperProfile, Index *lowerProfile, Scalar *diag, Scalar *upper, Scalar *lower, Index size, Index upperSize, Index lowerSize)
Definition: SkylineStorage.h:176
Eigen::SkylineStorage::upper
Scalar & upper(Index i)
Definition: SkylineStorage.h:144
Eigen::SkylineStorage::m_lowerSize
Index m_lowerSize
Definition: SkylineStorage.h:250
Eigen::SkylineStorage::diag
const Scalar & diag(Index i) const
Definition: SkylineStorage.h:140
min
#define min(a, b)
Definition: datatypes.h:19
Eigen::SkylineStorage::upperSize
Index upperSize() const
Definition: SkylineStorage.h:112
Eigen::SkylineStorage::swap
void swap(SkylineStorage &other)
Definition: SkylineStorage.h:66
Eigen::SkylineStorage::resize
void resize(Index diagSize, Index upperProfileSize, Index lowerProfileSize, Index upperSize, Index lowerSize, float reserveSizeFactor=0)
Definition: SkylineStorage.h:98
Eigen::SkylineStorage::SkylineStorage
SkylineStorage(const SkylineStorage &other)
Definition: SkylineStorage.h:41
Eigen::SkylineStorage::prune
void prune(Scalar reference, RealScalar epsilon=dummy_precision< RealScalar >())
Definition: SkylineStorage.h:197
Eigen::NumTraits
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:232
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
Eigen::SkylineStorage::upper
const Scalar & upper(Index i) const
Definition: SkylineStorage.h:148
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Eigen::SkylineStorage::m_lowerProfile
Index * m_lowerProfile
Definition: SkylineStorage.h:247


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:35:28