Eigen::SkylineMatrix< Scalar_, Options_ > Class Template Reference

The main skyline matrix class. More...

+ Inheritance diagram for Eigen::SkylineMatrix< Scalar_, Options_ >:

Classes

class  InnerLowerIterator
 
class  InnerUpperIterator
 

Public Member Functions

Scalar_diagPtr ()
 
const Scalar_diagPtr () const
 
Index_lowerProfilePtr ()
 
const Index_lowerProfilePtr () const
 
Scalar_lowerPtr ()
 
const Scalar_lowerPtr () const
 
Index_upperProfilePtr ()
 
const Index_upperProfilePtr () const
 
Scalar_upperPtr ()
 
const Scalar_upperPtr () const
 
Scalar coeff (Index row, Index col) const
 
Scalar coeffDiag (Index idx) const
 
bool coeffExistLower (Index row, Index col)
 
bool coeffExistUpper (Index row, Index col)
 
Scalar coeffLower (Index row, Index col) const
 
ScalarcoeffRef (Index row, Index col)
 
ScalarcoeffRefDiag (Index idx)
 
ScalarcoeffRefLower (Index row, Index col)
 
ScalarcoeffRefUpper (Index row, Index col)
 
Scalar coeffUpper (Index row, Index col) const
 
Index cols () const
 
void finalize ()
 
Index innerSize () const
 
EIGEN_DONT_INLINE Scalarinsert (Index row, Index col)
 
Index lowerNonZeros () const
 
Index lowerNonZeros (Index j) const
 
Index nonZeros () const
 
SkylineMatrixoperator= (const SkylineMatrix &other)
 
template<typename OtherDerived >
SkylineMatrixoperator= (const SkylineMatrixBase< OtherDerived > &other)
 
Index outerSize () const
 
void prune (Scalar reference, RealScalar epsilon=dummy_precision< RealScalar >())
 
void reserve (Index reserveSize, Index reserveUpperSize, Index reserveLowerSize)
 
void resize (size_t rows, size_t cols)
 
void resizeNonZeros (Index size)
 
Index rows () const
 
void setZero ()
 
 SkylineMatrix ()
 
 SkylineMatrix (const SkylineMatrix &other)
 
template<typename OtherDerived >
 SkylineMatrix (const SkylineMatrixBase< OtherDerived > &other)
 
 SkylineMatrix (size_t rows, size_t cols)
 
void squeeze ()
 
Scalar sum () const
 
void swap (SkylineMatrix &other)
 
Index upperNonZeros () const
 
Index upperNonZeros (Index j) const
 
 ~SkylineMatrix ()
 
- Public Member Functions inherited from Eigen::SkylineMatrixBase< SkylineMatrix< Scalar_, Options_ > >
void assignGeneric (const OtherDerived &other)
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
const internal::eval< SkylineMatrix< Scalar_, Options_ >, IsSkyline >::type eval () const
 
void evalTo (MatrixBase< DenseDerived > &dst) const
 
Index innerSize () const
 
bool isRValue () const
 
SkylineMatrix< Scalar_, Options_ > & markAsRValue ()
 
Index nonZeros () const
 
const SkylineProductReturnType< SkylineMatrix< Scalar_, Options_ >, OtherDerived >::Type operator* (const MatrixBase< OtherDerived > &other) const
 
SkylineMatrix< Scalar_, Options_ > & operator= (const SkylineMatrix< Scalar_, Options_ > &other)
 
SkylineMatrix< Scalar_, Options_ > & operator= (const SkylineMatrixBase< OtherDerived > &other)
 
SkylineMatrix< Scalar_, Options_ > & operator= (const SkylineProduct< Lhs, Rhs, SkylineTimeSkylineProduct > &product)
 
Index outerSize () const
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index size () const EIGEN_NOEXCEPT
 
 SkylineMatrixBase ()
 
Matrix< Scalar, RowsAtCompileTime, ColsAtCompileTimetoDense () const
 
- Public Member Functions inherited from Eigen::EigenBase< class >
void addTo (Dest &dst) const
 
void applyThisOnTheLeft (Dest &dst) const
 
void applyThisOnTheRight (Dest &dst) const
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
Derived & const_cast_derived () const
 
const Derived & const_derived () const
 
Derived & derived ()
 
const Derived & derived () const
 
void evalTo (Dest &dst) const
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index size () const EIGEN_NOEXCEPT
 
void subTo (Dest &dst) const
 

Public Attributes

Indexm_colStartIndex
 
SkylineStorage< Scalarm_data
 
Indexm_rowStartIndex
 

Protected Types

typedef SkylineMatrix< Scalar,(Flags &~RowMajorBit)|(IsRowMajor ? RowMajorBit :0) > TransposedSkylineMatrix
 

Protected Attributes

Index m_innerSize
 
Index m_outerSize
 
- Protected Attributes inherited from Eigen::SkylineMatrixBase< SkylineMatrix< Scalar_, Options_ > >
bool m_isRValue
 

Additional Inherited Members

- Public Types inherited from Eigen::SkylineMatrixBase< SkylineMatrix< Scalar_, Options_ > >
enum  
 
typedef internal::index< StorageKind >::type Index
 
typedef internal::traits< SkylineMatrix< Scalar_, Options_ > >::Scalar Scalar
 
typedef internal::traits< SkylineMatrix< Scalar_, Options_ > >::StorageKind StorageKind
 
- Public Types inherited from Eigen::EigenBase< class >
typedef Eigen::Index Index
 
typedef internal::traits< Derived >::StorageKind StorageKind
 

Detailed Description

template<typename Scalar_, int Options_>
class Eigen::SkylineMatrix< Scalar_, Options_ >

The main skyline matrix class.

This class implements a skyline matrix using the very uncommon storage scheme.

Parameters
Scalar_the scalar type, i.e. the type of the coefficients
Options_Union of bit flags controlling the storage scheme. Currently the only possibility is RowMajor. The default is 0 which means column-major.

Definition at line 53 of file SkylineMatrix.h.

Member Typedef Documentation

◆ TransposedSkylineMatrix

template<typename Scalar_ , int Options_>
typedef SkylineMatrix<Scalar, (Flags&~RowMajorBit) | (IsRowMajor ? RowMajorBit : 0) > Eigen::SkylineMatrix< Scalar_, Options_ >::TransposedSkylineMatrix
protected

Definition at line 64 of file SkylineMatrix.h.

Constructor & Destructor Documentation

◆ SkylineMatrix() [1/4]

template<typename Scalar_ , int Options_>
Eigen::SkylineMatrix< Scalar_, Options_ >::SkylineMatrix ( )
inline

Definition at line 632 of file SkylineMatrix.h.

634  resize(0, 0);
635  }
void resize(size_t rows, size_t cols)

◆ SkylineMatrix() [2/4]

template<typename Scalar_ , int Options_>
Eigen::SkylineMatrix< Scalar_, Options_ >::SkylineMatrix ( size_t  rows,
size_t  cols 
)
inline

Definition at line 637 of file SkylineMatrix.h.

639  resize(rows, cols);
640  }
Index cols() const
Definition: SkylineMatrix.h:80
Index rows() const
Definition: SkylineMatrix.h:76

◆ SkylineMatrix() [3/4]

template<typename Scalar_ , int Options_>
template<typename OtherDerived >
Eigen::SkylineMatrix< Scalar_, Options_ >::SkylineMatrix ( const SkylineMatrixBase< OtherDerived > &  other)
inline

Definition at line 643 of file SkylineMatrix.h.

645  *this = other.derived();
646  }

◆ SkylineMatrix() [4/4]

template<typename Scalar_ , int Options_>
Eigen::SkylineMatrix< Scalar_, Options_ >::SkylineMatrix ( const SkylineMatrix< Scalar_, Options_ > &  other)
inline

Definition at line 648 of file SkylineMatrix.h.

649  : Base(), m_outerSize(0), m_innerSize(0), m_colStartIndex(0), m_rowStartIndex(0) {
650  *this = other.derived();
651  }

◆ ~SkylineMatrix()

template<typename Scalar_ , int Options_>
Eigen::SkylineMatrix< Scalar_, Options_ >::~SkylineMatrix ( )
inline

Destructor

Definition at line 727 of file SkylineMatrix.h.

727  {
728  delete[] m_colStartIndex;
729  delete[] m_rowStartIndex;
730  }

Member Function Documentation

◆ _diagPtr() [1/2]

template<typename Scalar_ , int Options_>
Scalar* Eigen::SkylineMatrix< Scalar_, Options_ >::_diagPtr ( )
inline

Definition at line 112 of file SkylineMatrix.h.

112  {
113  return &m_data.diag(0);
114  }
SkylineStorage< Scalar > m_data
Definition: SkylineMatrix.h:72

◆ _diagPtr() [2/2]

template<typename Scalar_ , int Options_>
const Scalar* Eigen::SkylineMatrix< Scalar_, Options_ >::_diagPtr ( ) const
inline

Definition at line 108 of file SkylineMatrix.h.

108  {
109  return &m_data.diag(0);
110  }

◆ _lowerProfilePtr() [1/2]

template<typename Scalar_ , int Options_>
Index* Eigen::SkylineMatrix< Scalar_, Options_ >::_lowerProfilePtr ( )
inline

Definition at line 144 of file SkylineMatrix.h.

144  {
145  return &m_data.lowerProfile(0);
146  }

◆ _lowerProfilePtr() [2/2]

template<typename Scalar_ , int Options_>
const Index* Eigen::SkylineMatrix< Scalar_, Options_ >::_lowerProfilePtr ( ) const
inline

Definition at line 140 of file SkylineMatrix.h.

140  {
141  return &m_data.lowerProfile(0);
142  }

◆ _lowerPtr() [1/2]

template<typename Scalar_ , int Options_>
Scalar* Eigen::SkylineMatrix< Scalar_, Options_ >::_lowerPtr ( )
inline

Definition at line 128 of file SkylineMatrix.h.

128  {
129  return &m_data.lower(0);
130  }

◆ _lowerPtr() [2/2]

template<typename Scalar_ , int Options_>
const Scalar* Eigen::SkylineMatrix< Scalar_, Options_ >::_lowerPtr ( ) const
inline

Definition at line 124 of file SkylineMatrix.h.

124  {
125  return &m_data.lower(0);
126  }

◆ _upperProfilePtr() [1/2]

template<typename Scalar_ , int Options_>
Index* Eigen::SkylineMatrix< Scalar_, Options_ >::_upperProfilePtr ( )
inline

Definition at line 136 of file SkylineMatrix.h.

136  {
137  return &m_data.upperProfile(0);
138  }

◆ _upperProfilePtr() [2/2]

template<typename Scalar_ , int Options_>
const Index* Eigen::SkylineMatrix< Scalar_, Options_ >::_upperProfilePtr ( ) const
inline

Definition at line 132 of file SkylineMatrix.h.

132  {
133  return &m_data.upperProfile(0);
134  }

◆ _upperPtr() [1/2]

template<typename Scalar_ , int Options_>
Scalar* Eigen::SkylineMatrix< Scalar_, Options_ >::_upperPtr ( )
inline

Definition at line 120 of file SkylineMatrix.h.

120  {
121  return &m_data.upper(0);
122  }

◆ _upperPtr() [2/2]

template<typename Scalar_ , int Options_>
const Scalar* Eigen::SkylineMatrix< Scalar_, Options_ >::_upperPtr ( ) const
inline

Definition at line 116 of file SkylineMatrix.h.

116  {
117  return &m_data.upper(0);
118  }

◆ coeff()

template<typename Scalar_ , int Options_>
Scalar Eigen::SkylineMatrix< Scalar_, Options_ >::coeff ( Index  row,
Index  col 
) const
inline

Definition at line 148 of file SkylineMatrix.h.

148  {
149  const Index outer = IsRowMajor ? row : col;
150  const Index inner = IsRowMajor ? col : row;
151 
152  eigen_assert(outer < outerSize());
153  eigen_assert(inner < innerSize());
154 
155  if (outer == inner)
156  return this->m_data.diag(outer);
157 
158  if (IsRowMajor) {
159  if (inner > outer) //upper matrix
160  {
161  const Index minOuterIndex = inner - m_data.upperProfile(inner);
162  if (outer >= minOuterIndex)
163  return this->m_data.upper(m_colStartIndex[inner] + outer - (inner - m_data.upperProfile(inner)));
164  else
165  return Scalar(0);
166  }
167  if (inner < outer) //lower matrix
168  {
169  const Index minInnerIndex = outer - m_data.lowerProfile(outer);
170  if (inner >= minInnerIndex)
171  return this->m_data.lower(m_rowStartIndex[outer] + inner - (outer - m_data.lowerProfile(outer)));
172  else
173  return Scalar(0);
174  }
175  return m_data.upper(m_colStartIndex[inner] + outer - inner);
176  } else {
177  if (outer > inner) //upper matrix
178  {
179  const Index maxOuterIndex = inner + m_data.upperProfile(inner);
180  if (outer <= maxOuterIndex)
181  return this->m_data.upper(m_colStartIndex[inner] + (outer - inner));
182  else
183  return Scalar(0);
184  }
185  if (outer < inner) //lower matrix
186  {
187  const Index maxInnerIndex = outer + m_data.lowerProfile(outer);
188 
189  if (inner <= maxInnerIndex)
190  return this->m_data.lower(m_rowStartIndex[outer] + (inner - outer));
191  else
192  return Scalar(0);
193  }
194  }
195  }
RowXpr row(Index i) const
ColXpr col(Index i) const
#define eigen_assert(x)
internal::traits< SkylineMatrix< Scalar_, Options_ > >::Scalar Scalar
Index outerSize() const
Definition: SkylineMatrix.h:88
Index innerSize() const
Definition: SkylineMatrix.h:84
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index

◆ coeffDiag()

template<typename Scalar_ , int Options_>
Scalar Eigen::SkylineMatrix< Scalar_, Options_ >::coeffDiag ( Index  idx) const
inline

Definition at line 236 of file SkylineMatrix.h.

236  {
237  eigen_assert(idx < outerSize());
238  eigen_assert(idx < innerSize());
239  return this->m_data.diag(idx);
240  }

◆ coeffExistLower()

template<typename Scalar_ , int Options_>
bool Eigen::SkylineMatrix< Scalar_, Options_ >::coeffExistLower ( Index  row,
Index  col 
)
inline

Definition at line 314 of file SkylineMatrix.h.

314  {
315  const Index outer = IsRowMajor ? row : col;
316  const Index inner = IsRowMajor ? col : row;
317 
318  eigen_assert(outer < outerSize());
319  eigen_assert(inner < innerSize());
320  eigen_assert(inner != outer);
321 
322  if (IsRowMajor) {
323  const Index minInnerIndex = outer - m_data.lowerProfile(outer);
324  return inner >= minInnerIndex;
325  } else {
326  const Index maxInnerIndex = outer + m_data.lowerProfile(outer);
327  return inner <= maxInnerIndex;
328  }
329  }

◆ coeffExistUpper()

template<typename Scalar_ , int Options_>
bool Eigen::SkylineMatrix< Scalar_, Options_ >::coeffExistUpper ( Index  row,
Index  col 
)
inline

Definition at line 350 of file SkylineMatrix.h.

350  {
351  const Index outer = IsRowMajor ? row : col;
352  const Index inner = IsRowMajor ? col : row;
353 
354  eigen_assert(outer < outerSize());
355  eigen_assert(inner < innerSize());
356  eigen_assert(inner != outer);
357 
358  if (IsRowMajor) {
359  const Index minOuterIndex = inner - m_data.upperProfile(inner);
360  return outer >= minOuterIndex;
361  } else {
362  const Index maxOuterIndex = inner + m_data.upperProfile(inner);
363  return outer <= maxOuterIndex;
364  }
365  }

◆ coeffLower()

template<typename Scalar_ , int Options_>
Scalar Eigen::SkylineMatrix< Scalar_, Options_ >::coeffLower ( Index  row,
Index  col 
) const
inline

Definition at line 242 of file SkylineMatrix.h.

242  {
243  const Index outer = IsRowMajor ? row : col;
244  const Index inner = IsRowMajor ? col : row;
245 
246  eigen_assert(outer < outerSize());
247  eigen_assert(inner < innerSize());
248  eigen_assert(inner != outer);
249 
250  if (IsRowMajor) {
251  const Index minInnerIndex = outer - m_data.lowerProfile(outer);
252  if (inner >= minInnerIndex)
253  return this->m_data.lower(m_rowStartIndex[outer] + inner - (outer - m_data.lowerProfile(outer)));
254  else
255  return Scalar(0);
256 
257  } else {
258  const Index maxInnerIndex = outer + m_data.lowerProfile(outer);
259  if (inner <= maxInnerIndex)
260  return this->m_data.lower(m_rowStartIndex[outer] + (inner - outer));
261  else
262  return Scalar(0);
263  }
264  }

◆ coeffRef()

template<typename Scalar_ , int Options_>
Scalar& Eigen::SkylineMatrix< Scalar_, Options_ >::coeffRef ( Index  row,
Index  col 
)
inline

Definition at line 197 of file SkylineMatrix.h.

197  {
198  const Index outer = IsRowMajor ? row : col;
199  const Index inner = IsRowMajor ? col : row;
200 
201  eigen_assert(outer < outerSize());
202  eigen_assert(inner < innerSize());
203 
204  if (outer == inner)
205  return this->m_data.diag(outer);
206 
207  if (IsRowMajor) {
208  if (col > row) //upper matrix
209  {
210  const Index minOuterIndex = inner - m_data.upperProfile(inner);
211  eigen_assert(outer >= minOuterIndex && "You tried to access a coeff that does not exist in the storage");
212  return this->m_data.upper(m_colStartIndex[inner] + outer - (inner - m_data.upperProfile(inner)));
213  }
214  if (col < row) //lower matrix
215  {
216  const Index minInnerIndex = outer - m_data.lowerProfile(outer);
217  eigen_assert(inner >= minInnerIndex && "You tried to access a coeff that does not exist in the storage");
218  return this->m_data.lower(m_rowStartIndex[outer] + inner - (outer - m_data.lowerProfile(outer)));
219  }
220  } else {
221  if (outer > inner) //upper matrix
222  {
223  const Index maxOuterIndex = inner + m_data.upperProfile(inner);
224  eigen_assert(outer <= maxOuterIndex && "You tried to access a coeff that does not exist in the storage");
225  return this->m_data.upper(m_colStartIndex[inner] + (outer - inner));
226  }
227  if (outer < inner) //lower matrix
228  {
229  const Index maxInnerIndex = outer + m_data.lowerProfile(outer);
230  eigen_assert(inner <= maxInnerIndex && "You tried to access a coeff that does not exist in the storage");
231  return this->m_data.lower(m_rowStartIndex[outer] + (inner - outer));
232  }
233  }
234  }

◆ coeffRefDiag()

template<typename Scalar_ , int Options_>
Scalar& Eigen::SkylineMatrix< Scalar_, Options_ >::coeffRefDiag ( Index  idx)
inline

Definition at line 289 of file SkylineMatrix.h.

289  {
290  eigen_assert(idx < outerSize());
291  eigen_assert(idx < innerSize());
292  return this->m_data.diag(idx);
293  }

◆ coeffRefLower()

template<typename Scalar_ , int Options_>
Scalar& Eigen::SkylineMatrix< Scalar_, Options_ >::coeffRefLower ( Index  row,
Index  col 
)
inline

Definition at line 295 of file SkylineMatrix.h.

295  {
296  const Index outer = IsRowMajor ? row : col;
297  const Index inner = IsRowMajor ? col : row;
298 
299  eigen_assert(outer < outerSize());
300  eigen_assert(inner < innerSize());
301  eigen_assert(inner != outer);
302 
303  if (IsRowMajor) {
304  const Index minInnerIndex = outer - m_data.lowerProfile(outer);
305  eigen_assert(inner >= minInnerIndex && "You tried to access a coeff that does not exist in the storage");
306  return this->m_data.lower(m_rowStartIndex[outer] + inner - (outer - m_data.lowerProfile(outer)));
307  } else {
308  const Index maxInnerIndex = outer + m_data.lowerProfile(outer);
309  eigen_assert(inner <= maxInnerIndex && "You tried to access a coeff that does not exist in the storage");
310  return this->m_data.lower(m_rowStartIndex[outer] + (inner - outer));
311  }
312  }

◆ coeffRefUpper()

template<typename Scalar_ , int Options_>
Scalar& Eigen::SkylineMatrix< Scalar_, Options_ >::coeffRefUpper ( Index  row,
Index  col 
)
inline

Definition at line 331 of file SkylineMatrix.h.

331  {
332  const Index outer = IsRowMajor ? row : col;
333  const Index inner = IsRowMajor ? col : row;
334 
335  eigen_assert(outer < outerSize());
336  eigen_assert(inner < innerSize());
337  eigen_assert(inner != outer);
338 
339  if (IsRowMajor) {
340  const Index minOuterIndex = inner - m_data.upperProfile(inner);
341  eigen_assert(outer >= minOuterIndex && "You tried to access a coeff that does not exist in the storage");
342  return this->m_data.upper(m_colStartIndex[inner] + outer - (inner - m_data.upperProfile(inner)));
343  } else {
344  const Index maxOuterIndex = inner + m_data.upperProfile(inner);
345  eigen_assert(outer <= maxOuterIndex && "You tried to access a coeff that does not exist in the storage");
346  return this->m_data.upper(m_colStartIndex[inner] + (outer - inner));
347  }
348  }

◆ coeffUpper()

template<typename Scalar_ , int Options_>
Scalar Eigen::SkylineMatrix< Scalar_, Options_ >::coeffUpper ( Index  row,
Index  col 
) const
inline

Definition at line 266 of file SkylineMatrix.h.

266  {
267  const Index outer = IsRowMajor ? row : col;
268  const Index inner = IsRowMajor ? col : row;
269 
270  eigen_assert(outer < outerSize());
271  eigen_assert(inner < innerSize());
272  eigen_assert(inner != outer);
273 
274  if (IsRowMajor) {
275  const Index minOuterIndex = inner - m_data.upperProfile(inner);
276  if (outer >= minOuterIndex)
277  return this->m_data.upper(m_colStartIndex[inner] + outer - (inner - m_data.upperProfile(inner)));
278  else
279  return Scalar(0);
280  } else {
281  const Index maxOuterIndex = inner + m_data.upperProfile(inner);
282  if (outer <= maxOuterIndex)
283  return this->m_data.upper(m_colStartIndex[inner] + (outer - inner));
284  else
285  return Scalar(0);
286  }
287  }

◆ cols()

template<typename Scalar_ , int Options_>
Index Eigen::SkylineMatrix< Scalar_, Options_ >::cols ( void  ) const
inline

Definition at line 80 of file SkylineMatrix.h.

80  {
82  }

◆ finalize()

template<typename Scalar_ , int Options_>
void Eigen::SkylineMatrix< Scalar_, Options_ >::finalize ( )
inline

Must be called after inserting a set of non zero entries.

Definition at line 536 of file SkylineMatrix.h.

536  {
537  if (IsRowMajor) {
538  if (rows() > cols())
539  m_data.resize(cols(), cols(), rows(), m_colStartIndex[cols()] + 1, m_rowStartIndex[rows()] + 1);
540  else
541  m_data.resize(rows(), cols(), rows(), m_colStartIndex[cols()] + 1, m_rowStartIndex[rows()] + 1);
542 
543  // eigen_assert(rows() == cols() && "memory reorganisatrion only works with suare matrix");
544  //
545  // Scalar* newArray = new Scalar[m_colStartIndex[cols()] + 1 + m_rowStartIndex[rows()] + 1];
546  // Index dataIdx = 0;
547  // for (Index row = 0; row < rows(); row++) {
548  //
549  // const Index nbLowerElts = m_rowStartIndex[row + 1] - m_rowStartIndex[row];
550  // // std::cout << "nbLowerElts" << nbLowerElts << std::endl;
551  // memcpy(newArray + dataIdx, m_data.m_lower + m_rowStartIndex[row], nbLowerElts * sizeof (Scalar));
552  // m_rowStartIndex[row] = dataIdx;
553  // dataIdx += nbLowerElts;
554  //
555  // const Index nbUpperElts = m_colStartIndex[row + 1] - m_colStartIndex[row];
556  // memcpy(newArray + dataIdx, m_data.m_upper + m_colStartIndex[row], nbUpperElts * sizeof (Scalar));
557  // m_colStartIndex[row] = dataIdx;
558  // dataIdx += nbUpperElts;
559  //
560  //
561  // }
562  // //todo : don't access m_data profile directly : add an accessor from SkylineMatrix
563  // m_rowStartIndex[rows()] = m_rowStartIndex[rows()-1] + m_data.lowerProfile(rows()-1);
564  // m_colStartIndex[cols()] = m_colStartIndex[cols()-1] + m_data.upperProfile(cols()-1);
565  //
566  // delete[] m_data.m_lower;
567  // delete[] m_data.m_upper;
568  //
569  // m_data.m_lower = newArray;
570  // m_data.m_upper = newArray;
571  } else {
572  if (rows() > cols())
573  m_data.resize(cols(), rows(), cols(), m_rowStartIndex[cols()] + 1, m_colStartIndex[cols()] + 1);
574  else
575  m_data.resize(rows(), rows(), cols(), m_rowStartIndex[rows()] + 1, m_colStartIndex[rows()] + 1);
576  }
577  }

◆ innerSize()

template<typename Scalar_ , int Options_>
Index Eigen::SkylineMatrix< Scalar_, Options_ >::innerSize ( ) const
inline

Definition at line 84 of file SkylineMatrix.h.

84  {
85  return m_innerSize;
86  }

◆ insert()

template<typename Scalar_ , int Options_>
EIGEN_DONT_INLINE Scalar& Eigen::SkylineMatrix< Scalar_, Options_ >::insert ( Index  row,
Index  col 
)
inline
Returns
a reference to a novel non zero coefficient with coordinates row x col.
Warning
This function can be extremely slow if the non zero coefficients are not inserted in a coherent order.

After an insertion session, you should call the finalize() function.

Definition at line 402 of file SkylineMatrix.h.

402  {
403  const Index outer = IsRowMajor ? row : col;
404  const Index inner = IsRowMajor ? col : row;
405 
406  eigen_assert(outer < outerSize());
407  eigen_assert(inner < innerSize());
408 
409  if (outer == inner)
410  return m_data.diag(col);
411 
412  if (IsRowMajor) {
413  if (outer < inner) //upper matrix
414  {
415  Index minOuterIndex = 0;
416  minOuterIndex = inner - m_data.upperProfile(inner);
417 
418  if (outer < minOuterIndex) //The value does not yet exist
419  {
420  const Index previousProfile = m_data.upperProfile(inner);
421 
422  m_data.upperProfile(inner) = inner - outer;
423 
424 
425  const Index bandIncrement = m_data.upperProfile(inner) - previousProfile;
426  //shift data stored after this new one
427  const Index stop = m_colStartIndex[cols()];
428  const Index start = m_colStartIndex[inner];
429 
430 
431  for (Index innerIdx = stop; innerIdx >= start; innerIdx--) {
432  m_data.upper(innerIdx + bandIncrement) = m_data.upper(innerIdx);
433  }
434 
435  for (Index innerIdx = cols(); innerIdx > inner; innerIdx--) {
436  m_colStartIndex[innerIdx] += bandIncrement;
437  }
438 
439  //zeros new data
440  std::fill_n(this->_upperPtr() + start, bandIncrement - 1, Scalar(0));
441 
442  return m_data.upper(m_colStartIndex[inner]);
443  } else {
444  return m_data.upper(m_colStartIndex[inner] + outer - (inner - m_data.upperProfile(inner)));
445  }
446  }
447 
448  if (outer > inner) //lower matrix
449  {
450  const Index minInnerIndex = outer - m_data.lowerProfile(outer);
451  if (inner < minInnerIndex) //The value does not yet exist
452  {
453  const Index previousProfile = m_data.lowerProfile(outer);
454  m_data.lowerProfile(outer) = outer - inner;
455 
456  const Index bandIncrement = m_data.lowerProfile(outer) - previousProfile;
457  //shift data stored after this new one
458  const Index stop = m_rowStartIndex[rows()];
459  const Index start = m_rowStartIndex[outer];
460 
461 
462  for (Index innerIdx = stop; innerIdx >= start; innerIdx--) {
463  m_data.lower(innerIdx + bandIncrement) = m_data.lower(innerIdx);
464  }
465 
466  for (Index innerIdx = rows(); innerIdx > outer; innerIdx--) {
467  m_rowStartIndex[innerIdx] += bandIncrement;
468  }
469 
470  //zeros new data
471  std::fill_n(this->_lowerPtr() + start, bandIncrement - 1, Scalar(0));
472  return m_data.lower(m_rowStartIndex[outer]);
473  } else {
474  return m_data.lower(m_rowStartIndex[outer] + inner - (outer - m_data.lowerProfile(outer)));
475  }
476  }
477  } else {
478  if (outer > inner) //upper matrix
479  {
480  const Index maxOuterIndex = inner + m_data.upperProfile(inner);
481  if (outer > maxOuterIndex) //The value does not yet exist
482  {
483  const Index previousProfile = m_data.upperProfile(inner);
484  m_data.upperProfile(inner) = outer - inner;
485 
486  const Index bandIncrement = m_data.upperProfile(inner) - previousProfile;
487  //shift data stored after this new one
488  const Index stop = m_rowStartIndex[rows()];
489  const Index start = m_rowStartIndex[inner + 1];
490 
491  for (Index innerIdx = stop; innerIdx >= start; innerIdx--) {
492  m_data.upper(innerIdx + bandIncrement) = m_data.upper(innerIdx);
493  }
494 
495  for (Index innerIdx = inner + 1; innerIdx < outerSize() + 1; innerIdx++) {
496  m_rowStartIndex[innerIdx] += bandIncrement;
497  }
498  std::fill_n(this->_upperPtr() + m_rowStartIndex[inner] + previousProfile + 1, bandIncrement - 1, Scalar(0));
499  return m_data.upper(m_rowStartIndex[inner] + m_data.upperProfile(inner));
500  } else {
501  return m_data.upper(m_rowStartIndex[inner] + (outer - inner));
502  }
503  }
504 
505  if (outer < inner) //lower matrix
506  {
507  const Index maxInnerIndex = outer + m_data.lowerProfile(outer);
508  if (inner > maxInnerIndex) //The value does not yet exist
509  {
510  const Index previousProfile = m_data.lowerProfile(outer);
511  m_data.lowerProfile(outer) = inner - outer;
512 
513  const Index bandIncrement = m_data.lowerProfile(outer) - previousProfile;
514  //shift data stored after this new one
515  const Index stop = m_colStartIndex[cols()];
516  const Index start = m_colStartIndex[outer + 1];
517 
518  for (Index innerIdx = stop; innerIdx >= start; innerIdx--) {
519  m_data.lower(innerIdx + bandIncrement) = m_data.lower(innerIdx);
520  }
521 
522  for (Index innerIdx = outer + 1; innerIdx < outerSize() + 1; innerIdx++) {
523  m_colStartIndex[innerIdx] += bandIncrement;
524  }
525  std::fill_n(this->_lowerPtr() + m_colStartIndex[outer] + previousProfile + 1, bandIncrement - 1, Scalar(0));
526  return m_data.lower(m_colStartIndex[outer] + m_data.lowerProfile(outer));
527  } else {
528  return m_data.lower(m_colStartIndex[outer] + (inner - outer));
529  }
530  }
531  }
532  }
const Scalar * _lowerPtr() const
const Scalar * _upperPtr() const

◆ lowerNonZeros() [1/2]

template<typename Scalar_ , int Options_>
Index Eigen::SkylineMatrix< Scalar_, Options_ >::lowerNonZeros ( ) const
inline

Definition at line 96 of file SkylineMatrix.h.

96  {
97  return m_data.lowerSize();
98  }

◆ lowerNonZeros() [2/2]

template<typename Scalar_ , int Options_>
Index Eigen::SkylineMatrix< Scalar_, Options_ >::lowerNonZeros ( Index  j) const
inline

Definition at line 104 of file SkylineMatrix.h.

104  {
105  return m_rowStartIndex[j + 1] - m_rowStartIndex[j];
106  }
std::ptrdiff_t j

◆ nonZeros()

template<typename Scalar_ , int Options_>
Index Eigen::SkylineMatrix< Scalar_, Options_ >::nonZeros ( ) const
inline
Returns
the number of non zero coefficients

Definition at line 385 of file SkylineMatrix.h.

385  {
386  return m_data.diagSize() + m_data.upperSize() + m_data.lowerSize();
387  }

◆ operator=() [1/2]

template<typename Scalar_ , int Options_>
SkylineMatrix& Eigen::SkylineMatrix< Scalar_, Options_ >::operator= ( const SkylineMatrix< Scalar_, Options_ > &  other)
inline

Definition at line 662 of file SkylineMatrix.h.

662  {
663  std::cout << "SkylineMatrix& operator=(const SkylineMatrix& other)\n";
664  if (other.isRValue()) {
665  swap(other.const_cast_derived());
666  } else {
667  resize(other.rows(), other.cols());
668  memcpy(m_colStartIndex, other.m_colStartIndex, (m_outerSize + 1) * sizeof (Index));
669  memcpy(m_rowStartIndex, other.m_rowStartIndex, (m_outerSize + 1) * sizeof (Index));
670  m_data = other.m_data;
671  }
672  return *this;
673  }
void swap(SkylineMatrix &other)

◆ operator=() [2/2]

template<typename Scalar_ , int Options_>
template<typename OtherDerived >
SkylineMatrix& Eigen::SkylineMatrix< Scalar_, Options_ >::operator= ( const SkylineMatrixBase< OtherDerived > &  other)
inline

Definition at line 676 of file SkylineMatrix.h.

676  {
677  const bool needToTranspose = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit);
678  if (needToTranspose) {
679  // TODO
680  // return *this;
681  } else {
682  // there is no special optimization
683  return SkylineMatrixBase<SkylineMatrix>::operator=(other.derived());
684  }
685  }
Derived & operator=(const Derived &other)
const unsigned int RowMajorBit

◆ outerSize()

template<typename Scalar_ , int Options_>
Index Eigen::SkylineMatrix< Scalar_, Options_ >::outerSize ( ) const
inline

Definition at line 88 of file SkylineMatrix.h.

88  {
89  return m_outerSize;
90  }

◆ prune()

template<typename Scalar_ , int Options_>
void Eigen::SkylineMatrix< Scalar_, Options_ >::prune ( Scalar  reference,
RealScalar  epsilon = dummy_precision<RealScalar > () 
)
inline

Definition at line 584 of file SkylineMatrix.h.

584  {
585  //TODO
586  }

◆ reserve()

template<typename Scalar_ , int Options_>
void Eigen::SkylineMatrix< Scalar_, Options_ >::reserve ( Index  reserveSize,
Index  reserveUpperSize,
Index  reserveLowerSize 
)
inline

Preallocates reserveSize non zeros

Definition at line 390 of file SkylineMatrix.h.

390  {
391  m_data.reserve(reserveSize, reserveUpperSize, reserveLowerSize);
392  }

◆ resize()

template<typename Scalar_ , int Options_>
void Eigen::SkylineMatrix< Scalar_, Options_ >::resize ( size_t  rows,
size_t  cols 
)
inline

Resizes the matrix to a rows x cols matrix and initializes it to zero

See also
resizeNonZeros(Index), reserve(), setZero()

Definition at line 591 of file SkylineMatrix.h.

591  {
592  const Index diagSize = rows > cols ? cols : rows;
594 
595  eigen_assert(rows == cols && "Skyline matrix must be square matrix");
596 
597  if (diagSize % 2) { // diagSize is odd
598  const Index k = (diagSize - 1) / 2;
599 
600  m_data.resize(diagSize, IsRowMajor ? cols : rows, IsRowMajor ? rows : cols,
601  2 * k * k + k + 1,
602  2 * k * k + k + 1);
603 
604  } else // diagSize is even
605  {
606  const Index k = diagSize / 2;
607  m_data.resize(diagSize, IsRowMajor ? cols : rows, IsRowMajor ? rows : cols,
608  2 * k * k - k + 1,
609  2 * k * k - k + 1);
610  }
611 
613  delete[] m_colStartIndex;
614  delete[] m_rowStartIndex;
615  }
616  m_colStartIndex = new Index [cols + 1];
617  m_rowStartIndex = new Index [rows + 1];
618  m_outerSize = diagSize;
619 
620  m_data.reset();
621  m_data.clear();
622 
623  m_outerSize = diagSize;
624  std::fill_n(m_colStartIndex, cols + 1, Index(0));
625  std::fill_n(m_rowStartIndex, rows + 1, Index(0));
626  }

◆ resizeNonZeros()

template<typename Scalar_ , int Options_>
void Eigen::SkylineMatrix< Scalar_, Options_ >::resizeNonZeros ( Index  size)
inline

Definition at line 628 of file SkylineMatrix.h.

628  {
629  m_data.resize(size);
630  }
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT

◆ rows()

template<typename Scalar_ , int Options_>
Index Eigen::SkylineMatrix< Scalar_, Options_ >::rows ( void  ) const
inline

Definition at line 76 of file SkylineMatrix.h.

76  {
78  }

◆ setZero()

template<typename Scalar_ , int Options_>
void Eigen::SkylineMatrix< Scalar_, Options_ >::setZero ( )
inline

Removes all non zeros

Definition at line 378 of file SkylineMatrix.h.

378  {
379  m_data.clear();
380  std::fill_n(m_colStartIndex, m_outerSize + 1, Index(0));
381  std::fill_n(m_rowStartIndex, m_outerSize + 1, Index(0));
382  }

◆ squeeze()

template<typename Scalar_ , int Options_>
void Eigen::SkylineMatrix< Scalar_, Options_ >::squeeze ( )
inline

Definition at line 579 of file SkylineMatrix.h.

579  {
580  finalize();
581  m_data.squeeze();
582  }

◆ sum()

template<typename Scalar_ , int Options_>
Scalar Eigen::SkylineMatrix< Scalar_, Options_ >::sum ( ) const

Overloaded for performance

◆ swap()

template<typename Scalar_ , int Options_>
void Eigen::SkylineMatrix< Scalar_, Options_ >::swap ( SkylineMatrix< Scalar_, Options_ > &  other)
inline

Definition at line 653 of file SkylineMatrix.h.

653  {
654  //EIGEN_DBG_SKYLINE(std::cout << "SkylineMatrix:: swap\n");
655  std::swap(m_colStartIndex, other.m_colStartIndex);
656  std::swap(m_rowStartIndex, other.m_rowStartIndex);
657  std::swap(m_innerSize, other.m_innerSize);
658  std::swap(m_outerSize, other.m_outerSize);
659  m_data.swap(other.m_data);
660  }

◆ upperNonZeros() [1/2]

template<typename Scalar_ , int Options_>
Index Eigen::SkylineMatrix< Scalar_, Options_ >::upperNonZeros ( ) const
inline

Definition at line 92 of file SkylineMatrix.h.

92  {
93  return m_data.upperSize();
94  }

◆ upperNonZeros() [2/2]

template<typename Scalar_ , int Options_>
Index Eigen::SkylineMatrix< Scalar_, Options_ >::upperNonZeros ( Index  j) const
inline

Definition at line 100 of file SkylineMatrix.h.

100  {
101  return m_colStartIndex[j + 1] - m_colStartIndex[j];
102  }

Member Data Documentation

◆ m_colStartIndex

template<typename Scalar_ , int Options_>
Index* Eigen::SkylineMatrix< Scalar_, Options_ >::m_colStartIndex

Definition at line 70 of file SkylineMatrix.h.

◆ m_data

template<typename Scalar_ , int Options_>
SkylineStorage<Scalar> Eigen::SkylineMatrix< Scalar_, Options_ >::m_data

Definition at line 72 of file SkylineMatrix.h.

◆ m_innerSize

template<typename Scalar_ , int Options_>
Index Eigen::SkylineMatrix< Scalar_, Options_ >::m_innerSize
protected

Definition at line 67 of file SkylineMatrix.h.

◆ m_outerSize

template<typename Scalar_ , int Options_>
Index Eigen::SkylineMatrix< Scalar_, Options_ >::m_outerSize
protected

Definition at line 66 of file SkylineMatrix.h.

◆ m_rowStartIndex

template<typename Scalar_ , int Options_>
Index* Eigen::SkylineMatrix< Scalar_, Options_ >::m_rowStartIndex

Definition at line 71 of file SkylineMatrix.h.


The documentation for this class was generated from the following file: