10 #ifndef EIGEN_SKYLINEMATRIX_H
11 #define EIGEN_SKYLINEMATRIX_H
34 template<
typename _Scalar,
int _Options>
50 template<
typename _Scalar,
int _Options>
58 using Base::IsRowMajor;
131 return &
m_data.upperProfile(0);
135 return &
m_data.upperProfile(0);
139 return &
m_data.lowerProfile(0);
143 return &
m_data.lowerProfile(0);
154 return this->m_data.
diag(outer);
159 const Index minOuterIndex = inner -
m_data.upperProfile(inner);
160 if (outer >= minOuterIndex)
167 const Index minInnerIndex = outer -
m_data.lowerProfile(outer);
168 if (inner >= minInnerIndex)
177 const Index maxOuterIndex = inner +
m_data.upperProfile(inner);
178 if (outer <= maxOuterIndex)
185 const Index maxInnerIndex = outer +
m_data.lowerProfile(outer);
187 if (inner <= maxInnerIndex)
203 return this->m_data.
diag(outer);
208 const Index minOuterIndex = inner -
m_data.upperProfile(inner);
209 eigen_assert(outer >= minOuterIndex &&
"You tried to access a coeff that does not exist in the storage");
214 const Index minInnerIndex = outer -
m_data.lowerProfile(outer);
215 eigen_assert(inner >= minInnerIndex &&
"You tried to access a coeff that does not exist in the storage");
221 const Index maxOuterIndex = inner +
m_data.upperProfile(inner);
222 eigen_assert(outer <= maxOuterIndex &&
"You tried to access a coeff that does not exist in the storage");
227 const Index maxInnerIndex = outer +
m_data.lowerProfile(outer);
228 eigen_assert(inner <= maxInnerIndex &&
"You tried to access a coeff that does not exist in the storage");
237 return this->m_data.
diag(idx);
249 const Index minInnerIndex = outer -
m_data.lowerProfile(outer);
250 if (inner >= minInnerIndex)
256 const Index maxInnerIndex = outer +
m_data.lowerProfile(outer);
257 if (inner <= maxInnerIndex)
273 const Index minOuterIndex = inner -
m_data.upperProfile(inner);
274 if (outer >= minOuterIndex)
279 const Index maxOuterIndex = inner +
m_data.upperProfile(inner);
280 if (outer <= maxOuterIndex)
290 return this->m_data.
diag(idx);
302 const Index minInnerIndex = outer -
m_data.lowerProfile(outer);
303 eigen_assert(inner >= minInnerIndex &&
"You tried to access a coeff that does not exist in the storage");
306 const Index maxInnerIndex = outer +
m_data.lowerProfile(outer);
307 eigen_assert(inner <= maxInnerIndex &&
"You tried to access a coeff that does not exist in the storage");
321 const Index minInnerIndex = outer -
m_data.lowerProfile(outer);
322 return inner >= minInnerIndex;
324 const Index maxInnerIndex = outer +
m_data.lowerProfile(outer);
325 return inner <= maxInnerIndex;
338 const Index minOuterIndex = inner -
m_data.upperProfile(inner);
339 eigen_assert(outer >= minOuterIndex &&
"You tried to access a coeff that does not exist in the storage");
342 const Index maxOuterIndex = inner +
m_data.upperProfile(inner);
343 eigen_assert(outer <= maxOuterIndex &&
"You tried to access a coeff that does not exist in the storage");
357 const Index minOuterIndex = inner -
m_data.upperProfile(inner);
358 return outer >= minOuterIndex;
360 const Index maxOuterIndex = inner +
m_data.upperProfile(inner);
361 return outer <= maxOuterIndex;
369 class InnerUpperIterator;
370 class InnerLowerIterator;
372 class OuterUpperIterator;
373 class OuterLowerIterator;
389 m_data.reserve(reserveSize, reserveUpperSize, reserveLowerSize);
413 Index minOuterIndex = 0;
414 minOuterIndex = inner -
m_data.upperProfile(inner);
416 if (outer < minOuterIndex)
418 const Index previousProfile =
m_data.upperProfile(inner);
420 m_data.upperProfile(inner) = inner - outer;
423 const Index bandIncrement =
m_data.upperProfile(inner) - previousProfile;
429 for (
Index innerIdx = stop; innerIdx >= start; innerIdx--) {
430 m_data.upper(innerIdx + bandIncrement) =
m_data.upper(innerIdx);
433 for (
Index innerIdx =
cols(); innerIdx > inner; innerIdx--) {
438 memset(this->
_upperPtr() + start, 0, (bandIncrement - 1) *
sizeof (
Scalar));
448 const Index minInnerIndex = outer -
m_data.lowerProfile(outer);
449 if (inner < minInnerIndex)
451 const Index previousProfile =
m_data.lowerProfile(outer);
452 m_data.lowerProfile(outer) = outer - inner;
454 const Index bandIncrement =
m_data.lowerProfile(outer) - previousProfile;
460 for (
Index innerIdx = stop; innerIdx >= start; innerIdx--) {
461 m_data.lower(innerIdx + bandIncrement) =
m_data.lower(innerIdx);
464 for (
Index innerIdx =
rows(); innerIdx > outer; innerIdx--) {
469 memset(this->
_lowerPtr() + start, 0, (bandIncrement - 1) *
sizeof (
Scalar));
478 const Index maxOuterIndex = inner +
m_data.upperProfile(inner);
479 if (outer > maxOuterIndex)
481 const Index previousProfile =
m_data.upperProfile(inner);
482 m_data.upperProfile(inner) = outer - inner;
484 const Index bandIncrement =
m_data.upperProfile(inner) - previousProfile;
489 for (
Index innerIdx = stop; innerIdx >= start; innerIdx--) {
490 m_data.upper(innerIdx + bandIncrement) =
m_data.upper(innerIdx);
493 for (
Index innerIdx = inner + 1; innerIdx <
outerSize() + 1; innerIdx++) {
496 memset(this->
_upperPtr() + m_rowStartIndex[inner] + previousProfile + 1, 0, (bandIncrement - 1) *
sizeof (
Scalar));
505 const Index maxInnerIndex = outer +
m_data.lowerProfile(outer);
506 if (inner > maxInnerIndex)
508 const Index previousProfile =
m_data.lowerProfile(outer);
509 m_data.lowerProfile(outer) = inner - outer;
511 const Index bandIncrement =
m_data.lowerProfile(outer) - previousProfile;
516 for (
Index innerIdx = stop; innerIdx >= start; innerIdx--) {
517 m_data.lower(innerIdx + bandIncrement) =
m_data.lower(innerIdx);
520 for (
Index innerIdx = outer + 1; innerIdx <
outerSize() + 1; innerIdx++) {
523 memset(this->
_lowerPtr() + m_colStartIndex[outer] + previousProfile + 1, 0, (bandIncrement - 1) *
sizeof (
Scalar));
596 const Index k = (diagSize - 1) / 2;
604 const Index k = diagSize / 2;
640 template<
typename OtherDerived>
643 *
this =
other.derived();
648 *
this =
other.derived();
661 std::cout <<
"SkylineMatrix& operator=(const SkylineMatrix& other)\n";
662 if (
other.isRValue()) {
673 template<
typename OtherDerived>
676 if (needToTranspose) {
688 std::cout <<
"upper elements : " << std::endl;
689 for (
Index i = 0;
i <
m.m_data.upperSize();
i++)
690 std::cout <<
m.m_data.upper(
i) <<
"\t";
691 std::cout << std::endl;
692 std::cout <<
"upper profile : " << std::endl;
694 std::cout <<
m.m_data.upperProfile(
i) <<
"\t";
695 std::cout << std::endl;
696 std::cout <<
"lower startIdx : " << std::endl;
698 std::cout << (
IsRowMajor ?
m.m_colStartIndex[
i] :
m.m_rowStartIndex[
i]) <<
"\t";
699 std::cout << std::endl;
702 std::cout <<
"lower elements : " << std::endl;
704 std::cout <<
m.m_data.lower(
i) <<
"\t";
705 std::cout << std::endl;
706 std::cout <<
"lower profile : " << std::endl;
708 std::cout <<
m.m_data.lowerProfile(
i) <<
"\t";
709 std::cout << std::endl;
710 std::cout <<
"lower startIdx : " << std::endl;
712 std::cout << (
IsRowMajor ?
m.m_rowStartIndex[
i] :
m.m_colStartIndex[
i]) <<
"\t";
713 std::cout << std::endl;
715 for (
Index rowIdx = 0; rowIdx <
m.rows(); rowIdx++) {
716 for (
Index colIdx = 0; colIdx <
m.cols(); colIdx++) {
717 s <<
m.coeff(rowIdx, colIdx) <<
"\t";
734 template<
typename Scalar,
int _Options>
739 : m_matrix(
mat), m_outer(outer),
756 return m_matrix.m_data.upper(m_id);
760 return const_cast<Scalar*
> (&(m_matrix.m_data.upper(m_id)));
764 return const_cast<Scalar&
> (m_matrix.m_data.upper(m_id));
768 return IsRowMajor ? m_outer - m_matrix.m_data.upperProfile(m_outer) + (m_id - m_start) :
769 m_outer + (m_id - m_start) + 1;
781 return m_matrix.m_data.upperProfile(m_outer);
784 inline operator bool()
const {
785 return (m_id < m_end) && (m_id >= m_start);
796 template<
typename Scalar,
int _Options>
819 return m_matrix.m_data.lower(m_id);
823 return const_cast<Scalar*
> (&(m_matrix.m_data.lower(m_id)));
827 return const_cast<Scalar&
> (m_matrix.m_data.lower(m_id));
831 return IsRowMajor ? m_outer - m_matrix.m_data.lowerProfile(m_outer) + (m_id - m_start) :
832 m_outer + (m_id - m_start) + 1;
845 return m_matrix.m_data.lowerProfile(m_outer);
848 inline operator bool()
const {
849 return (m_id < m_end) && (m_id >= m_start);
862 #endif // EIGEN_SKYLINEMATRIX_H