10 #ifndef EIGEN_SKYLINEMATRIX_H
11 #define EIGEN_SKYLINEMATRIX_H
36 template<
typename Scalar_,
int Options_>
37 struct traits<SkylineMatrix<Scalar_, Options_> > {
38 typedef Scalar_ Scalar;
39 typedef Sparse StorageKind;
52 template<
typename Scalar_,
int Options_>
60 using Base::IsRowMajor;
133 return &
m_data.upperProfile(0);
137 return &
m_data.upperProfile(0);
141 return &
m_data.lowerProfile(0);
145 return &
m_data.lowerProfile(0);
156 return this->m_data.
diag(outer);
161 const Index minOuterIndex = inner -
m_data.upperProfile(inner);
162 if (outer >= minOuterIndex)
169 const Index minInnerIndex = outer -
m_data.lowerProfile(outer);
170 if (inner >= minInnerIndex)
179 const Index maxOuterIndex = inner +
m_data.upperProfile(inner);
180 if (outer <= maxOuterIndex)
187 const Index maxInnerIndex = outer +
m_data.lowerProfile(outer);
189 if (inner <= maxInnerIndex)
205 return this->m_data.
diag(outer);
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");
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");
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");
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");
239 return this->m_data.
diag(idx);
251 const Index minInnerIndex = outer -
m_data.lowerProfile(outer);
252 if (inner >= minInnerIndex)
258 const Index maxInnerIndex = outer +
m_data.lowerProfile(outer);
259 if (inner <= maxInnerIndex)
275 const Index minOuterIndex = inner -
m_data.upperProfile(inner);
276 if (outer >= minOuterIndex)
281 const Index maxOuterIndex = inner +
m_data.upperProfile(inner);
282 if (outer <= maxOuterIndex)
292 return this->m_data.
diag(idx);
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");
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");
323 const Index minInnerIndex = outer -
m_data.lowerProfile(outer);
324 return inner >= minInnerIndex;
326 const Index maxInnerIndex = outer +
m_data.lowerProfile(outer);
327 return inner <= maxInnerIndex;
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");
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");
359 const Index minOuterIndex = inner -
m_data.upperProfile(inner);
360 return outer >= minOuterIndex;
362 const Index maxOuterIndex = inner +
m_data.upperProfile(inner);
363 return outer <= maxOuterIndex;
371 class InnerUpperIterator;
372 class InnerLowerIterator;
374 class OuterUpperIterator;
375 class OuterLowerIterator;
391 m_data.reserve(reserveSize, reserveUpperSize, reserveLowerSize);
415 Index minOuterIndex = 0;
416 minOuterIndex = inner -
m_data.upperProfile(inner);
418 if (outer < minOuterIndex)
420 const Index previousProfile =
m_data.upperProfile(inner);
422 m_data.upperProfile(inner) = inner - outer;
425 const Index bandIncrement =
m_data.upperProfile(inner) - previousProfile;
431 for (
Index innerIdx = stop; innerIdx >= start; innerIdx--) {
432 m_data.upper(innerIdx + bandIncrement) =
m_data.upper(innerIdx);
435 for (
Index innerIdx =
cols(); innerIdx > inner; innerIdx--) {
450 const Index minInnerIndex = outer -
m_data.lowerProfile(outer);
451 if (inner < minInnerIndex)
453 const Index previousProfile =
m_data.lowerProfile(outer);
454 m_data.lowerProfile(outer) = outer - inner;
456 const Index bandIncrement =
m_data.lowerProfile(outer) - previousProfile;
462 for (
Index innerIdx = stop; innerIdx >= start; innerIdx--) {
463 m_data.lower(innerIdx + bandIncrement) =
m_data.lower(innerIdx);
466 for (
Index innerIdx =
rows(); innerIdx > outer; innerIdx--) {
480 const Index maxOuterIndex = inner +
m_data.upperProfile(inner);
481 if (outer > maxOuterIndex)
483 const Index previousProfile =
m_data.upperProfile(inner);
484 m_data.upperProfile(inner) = outer - inner;
486 const Index bandIncrement =
m_data.upperProfile(inner) - previousProfile;
491 for (
Index innerIdx = stop; innerIdx >= start; innerIdx--) {
492 m_data.upper(innerIdx + bandIncrement) =
m_data.upper(innerIdx);
495 for (
Index innerIdx = inner + 1; innerIdx <
outerSize() + 1; innerIdx++) {
498 std::fill_n(this->
_upperPtr() + m_rowStartIndex[inner] + previousProfile + 1, bandIncrement - 1,
Scalar(0));
507 const Index maxInnerIndex = outer +
m_data.lowerProfile(outer);
508 if (inner > maxInnerIndex)
510 const Index previousProfile =
m_data.lowerProfile(outer);
511 m_data.lowerProfile(outer) = inner - outer;
513 const Index bandIncrement =
m_data.lowerProfile(outer) - previousProfile;
518 for (
Index innerIdx = stop; innerIdx >= start; innerIdx--) {
519 m_data.lower(innerIdx + bandIncrement) =
m_data.lower(innerIdx);
522 for (
Index innerIdx = outer + 1; innerIdx <
outerSize() + 1; innerIdx++) {
525 std::fill_n(this->
_lowerPtr() + m_colStartIndex[outer] + previousProfile + 1, bandIncrement - 1,
Scalar(0));
584 void prune(
Scalar reference, RealScalar epsilon = dummy_precision<RealScalar > ()) {
598 const Index k = (diagSize - 1) / 2;
606 const Index k = diagSize / 2;
642 template<
typename OtherDerived>
663 std::cout <<
"SkylineMatrix& operator=(const SkylineMatrix& other)\n";
675 template<
typename OtherDerived>
678 if (needToTranspose) {
690 std::cout <<
"upper elements : " << std::endl;
691 for (
Index i = 0;
i <
m.m_data.upperSize();
i++)
692 std::cout <<
m.m_data.upper(
i) <<
"\t";
693 std::cout << std::endl;
694 std::cout <<
"upper profile : " << std::endl;
696 std::cout <<
m.m_data.upperProfile(
i) <<
"\t";
697 std::cout << std::endl;
698 std::cout <<
"lower startIdx : " << std::endl;
700 std::cout << (
IsRowMajor ?
m.m_colStartIndex[
i] :
m.m_rowStartIndex[
i]) <<
"\t";
701 std::cout << std::endl;
704 std::cout <<
"lower elements : " << std::endl;
706 std::cout <<
m.m_data.lower(
i) <<
"\t";
707 std::cout << std::endl;
708 std::cout <<
"lower profile : " << std::endl;
710 std::cout <<
m.m_data.lowerProfile(
i) <<
"\t";
711 std::cout << std::endl;
712 std::cout <<
"lower startIdx : " << std::endl;
714 std::cout << (
IsRowMajor ?
m.m_rowStartIndex[
i] :
m.m_colStartIndex[
i]) <<
"\t";
715 std::cout << std::endl;
717 for (
Index rowIdx = 0; rowIdx <
m.rows(); rowIdx++) {
718 for (
Index colIdx = 0; colIdx <
m.cols(); colIdx++) {
719 s <<
m.coeff(rowIdx, colIdx) <<
"\t";
736 template<
typename Scalar,
int Options_>
741 : m_matrix(
mat), m_outer(outer),
758 return m_matrix.m_data.upper(m_id);
762 return const_cast<Scalar*
> (&(m_matrix.m_data.upper(m_id)));
766 return const_cast<Scalar&
> (m_matrix.m_data.upper(m_id));
770 return IsRowMajor ? m_outer - m_matrix.m_data.upperProfile(m_outer) + (m_id - m_start) :
771 m_outer + (m_id - m_start) + 1;
783 return m_matrix.m_data.upperProfile(m_outer);
786 inline operator bool()
const {
787 return (m_id < m_end) && (m_id >= m_start);
798 template<
typename Scalar,
int Options_>
821 return m_matrix.m_data.lower(m_id);
825 return const_cast<Scalar*
> (&(m_matrix.m_data.lower(m_id)));
829 return const_cast<Scalar&
> (m_matrix.m_data.lower(m_id));
833 return IsRowMajor ? m_outer - m_matrix.m_data.lowerProfile(m_outer) + (m_id - m_start) :
834 m_outer + (m_id - m_start) + 1;
847 return m_matrix.m_data.lowerProfile(m_outer);
850 inline operator bool()
const {
851 return (m_id < m_end) && (m_id >= m_start);
RowXpr row(Index i) const
ColXpr col(Index i) const
#define EIGEN_DONT_INLINE
for(int i=0;i< 24;++i) array[i]
#define EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived)
#define EIGEN_DBG_SKYLINE(X)
#define EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op)
Base class of any skyline matrices or skyline expressions.
Derived & operator=(const Derived &other)
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
internal::index< StorageKind >::type Index
internal::traits< SkylineMatrix< Scalar_, Options_ > >::Scalar Scalar
InnerLowerIterator(const SkylineMatrix &mat, Index outer)
InnerLowerIterator & operator++()
InnerLowerIterator & operator+=(Index shift)
const SkylineMatrix & m_matrix
const SkylineMatrix & m_matrix
InnerUpperIterator(const SkylineMatrix &mat, Index outer)
InnerUpperIterator & operator++()
InnerUpperIterator & operator+=(Index shift)
The main skyline matrix class.
void resize(size_t rows, size_t cols)
Scalar coeffDiag(Index idx) const
void prune(Scalar reference, RealScalar epsilon=dummy_precision< RealScalar >())
SkylineMatrix(size_t rows, size_t cols)
SkylineMatrix(const SkylineMatrixBase< OtherDerived > &other)
bool coeffExistUpper(Index row, Index col)
friend std::ostream & operator<<(std::ostream &s, const SkylineMatrix &m)
SkylineMatrix< Scalar,(Flags &~RowMajorBit)|(IsRowMajor ? RowMajorBit :0) > TransposedSkylineMatrix
Scalar & coeffRefLower(Index row, Index col)
const Index * _lowerProfilePtr() const
Scalar coeff(Index row, Index col) const
const Scalar * _lowerPtr() const
Scalar & coeffRefDiag(Index idx)
Index * _upperProfilePtr()
Scalar coeffLower(Index row, Index col) const
Scalar coeffUpper(Index row, Index col) const
void resizeNonZeros(Index size)
SkylineStorage< Scalar > m_data
Index lowerNonZeros() const
SkylineMatrix & operator=(const SkylineMatrixBase< OtherDerived > &other)
void reserve(Index reserveSize, Index reserveUpperSize, Index reserveLowerSize)
Index upperNonZeros(Index j) const
bool coeffExistLower(Index row, Index col)
EIGEN_DONT_INLINE Scalar & insert(Index row, Index col)
SkylineMatrix & operator=(const SkylineMatrix &other)
Index lowerNonZeros(Index j) const
Index * _lowerProfilePtr()
const Scalar * _upperPtr() const
Scalar & coeffRefUpper(Index row, Index col)
Scalar & coeffRef(Index row, Index col)
void swap(SkylineMatrix &other)
Index upperNonZeros() const
SkylineMatrix(const SkylineMatrix &other)
const Index * _upperProfilePtr() const
const Scalar * _diagPtr() const
const unsigned int RowMajorBit
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
const unsigned int SkylineBit
Derived & const_cast_derived() const