10 #ifndef EIGEN_SPARSEMATRIX_H
11 #define EIGEN_SPARSEMATRIX_H
50 template <
typename Scalar_,
int Options_,
typename StorageIndex_>
67 template <
typename Scalar_,
int Options_,
typename StorageIndex_,
int DiagIndex>
80 ColsAtCompileTime = 1,
82 MaxColsAtCompileTime = 1,
87 template <
typename Scalar_,
int Options_,
typename StorageIndex_,
int DiagIndex>
89 :
public traits<Diagonal<SparseMatrix<Scalar_, Options_, StorageIndex_>, DiagIndex>> {
93 template <
typename StorageIndex>
98 m_end = begin + range;
102 template <
typename IndexType>
113 template <
typename Scalar>
120 template <
typename Scalar_,
int Options_,
typename StorageIndex_>
125 template <
typename,
typename,
typename,
typename,
typename>
132 using Base::operator+=;
133 using Base::operator-=;
246 if (inserted !=
nullptr) {
254 if (inserted !=
nullptr) {
259 if (inserted !=
nullptr) {
320 #ifdef EIGEN_PARSED_BY_DOXYGEN
333 template <
class SizesType>
334 inline void reserve(
const SizesType& reserveSizes);
336 template <
class SizesType>
337 inline void reserve(
const SizesType& reserveSizes,
338 const typename SizesType::value_type& enableif =
typename SizesType::value_type()) {
344 template <
class SizesType>
347 Index totalReserveSize = 0;
348 for (
Index j = 0; j < m_outerSize; ++j) totalReserveSize += internal::convert_index<Index>(reserveSizes[
j]);
351 if (totalReserveSize == 0)
return;
361 newOuterIndex[
j] = internal::convert_index<StorageIndex>(count);
362 Index reserveSize = internal::convert_index<Index>(reserveSizes[
j]);
381 internal::convert_index<StorageIndex>(reserveSizes[
m_outerSize - 1]);
389 newOuterIndex[
j] = internal::convert_index<StorageIndex>(count);
390 Index alreadyReserved =
392 Index reserveSize = internal::convert_index<Index>(reserveSizes[
j]);
396 newOuterIndex[
m_outerSize] = internal::convert_index<StorageIndex>(count);
407 internal::conditional_aligned_delete_auto<StorageIndex, true>(newOuterIndex,
m_outerSize + 1);
433 "Invalid ordered insertion (invalid inner index)");
453 "You must call startVec for each inner vector sequentially");
482 const Index begin =
j + num;
518 const Index target =
j + num;
535 template <
typename InputIterators>
538 template <
typename InputIterators,
typename DupFunctor>
541 template <
typename Derived,
typename DupFunctor>
544 template <
typename InputIterators>
547 template <
typename InputIterators,
typename DupFunctor>
550 template <
typename InputIterators>
553 template <
typename InputIterators,
typename DupFunctor>
556 template <
typename InputIterators>
559 template <
typename InputIterators,
typename DupFunctor>
583 "you cannot insert an element that already exists, you must call coeffRef to this end");
607 copyStart = nextStart;
608 copyTarget += chunkSize;
645 template <
typename KeepFunc>
646 void prune(
const KeepFunc& keep = KeepFunc()) {
691 if (outerChange != 0) {
699 if (outerChange > 0) {
709 if (innerChange < 0) {
774 template <
typename OtherDerived>
779 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
784 #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN
792 template <
typename OtherDerived,
unsigned int UpLo>
801 template <
typename OtherDerived>
803 *
this = other.
derived().markAsRValue();
813 template <
typename OtherDerived>
821 template <
typename OtherDerived>
858 }
else if (
this != &other) {
859 #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN
878 #ifndef EIGEN_PARSED_BY_DOXYGEN
879 template <
typename OtherDerived>
884 template <
typename Lhs,
typename Rhs>
888 template <
typename OtherDerived>
891 template <
typename OtherDerived>
893 *
this = other.
derived().markAsRValue();
900 s <<
"Nonzero entries:\n";
if (
m.isCompressed()) {
901 for (Index i = 0; i < m.nonZeros(); ++i) s <<
"(" << m.m_data.value(i) <<
"," << m.m_data.index(i) <<
") ";
903 for (Index i = 0; i < m.outerSize(); ++i) {
904 Index p = m.m_outerIndex[i];
905 Index pe = m.m_outerIndex[i] + m.m_innerNonZeros[i];
907 for (; k < pe; ++k) {
908 s <<
"(" << m.m_data.value(k) <<
"," << m.m_data.index(k) <<
") ";
910 for (; k < m.m_outerIndex[i + 1]; ++k) {
915 s << std::endl;
s <<
"Outer pointers:\n";
916 for (
Index i = 0;
i <
m.outerSize(); ++
i) {
s <<
m.m_outerIndex[
i] <<
" "; }
s <<
" $" << std::endl;
917 if (!
m.isCompressed()) {
918 s <<
"Inner non zeros:\n";
919 for (Index i = 0; i < m.outerSize(); ++i) {
920 s << m.m_innerNonZeros[i] <<
" ";
922 s <<
" $" << std::endl;
925 s << static_cast<const SparseMatrixBase<SparseMatrix>&>(
m);
932 internal::conditional_aligned_delete_auto<StorageIndex, true>(m_outerIndex, m_outerSize + 1);
933 internal::conditional_aligned_delete_auto<StorageIndex, true>(m_innerNonZeros, m_outerSize);
939 #ifdef EIGEN_SPARSEMATRIX_PLUGIN
940 #include EIGEN_SPARSEMATRIX_PLUGIN
944 template <
typename Other>
946 resize(other.rows(), other.cols());
947 internal::conditional_aligned_delete_auto<StorageIndex, true>(m_innerNonZeros, m_outerSize);
980 eigen_assert(m_innerNonZeros[outer] <= (m_outerIndex[outer + 1] - m_outerIndex[outer]));
982 Index p = m_outerIndex[outer] + m_innerNonZeros[outer]++;
1004 template <
typename DiagXpr,
typename Func>
1009 Index n = diagXpr.size();
1013 if ((m_outerSize !=
n) || (m_innerSize !=
n))
resize(
n,
n);
1016 if (m_data.
size() == 0 || overwrite) {
1017 internal::conditional_aligned_delete_auto<StorageIndex, true>(m_innerNonZeros, m_outerSize);
1018 m_innerNonZeros = 0;
1020 ValueMap valueMap(valuePtr(),
n);
1021 std::iota(m_outerIndex, m_outerIndex +
n + 1,
StorageIndex(0));
1022 std::iota(innerIndexPtr(), innerIndexPtr() +
n,
StorageIndex(0));
1030 insertionLocations.setConstant(kEmptyIndexVal);
1032 Index deferredInsertions = 0;
1036 Index begin = m_outerIndex[
j];
1037 Index end = isCompressed() ? m_outerIndex[
j + 1] : begin + m_innerNonZeros[
j];
1038 Index capacity = m_outerIndex[
j + 1] -
end;
1042 assignFunc.assignCoeff(m_data.
value(dst), diaEval.coeff(
j));
1044 else if (dst ==
end && capacity > 0)
1045 assignFunc.assignCoeff(insertBackUncompressed(
j,
j), diaEval.coeff(
j));
1049 deferredInsertions++;
1051 if (capacity == 0) shift++;
1055 if (deferredInsertions > 0) {
1057 Index copyEnd = isCompressed() ? m_outerIndex[m_outerSize]
1058 : m_outerIndex[m_outerSize - 1] + m_innerNonZeros[m_outerSize - 1];
1059 for (
Index j = m_outerSize - 1; deferredInsertions > 0;
j--) {
1060 Index begin = m_outerIndex[
j];
1061 Index end = isCompressed() ? m_outerIndex[
j + 1] : begin + m_innerNonZeros[
j];
1062 Index capacity = m_outerIndex[
j + 1] -
end;
1064 bool doInsertion = insertionLocations(
j) >= 0;
1065 bool breakUpCopy = doInsertion && (capacity > 0);
1071 Index copyBegin = m_outerIndex[
j + 1];
1072 Index to = copyBegin + shift;
1073 Index chunkSize = copyEnd - copyBegin;
1074 m_data.
moveChunk(copyBegin, to, chunkSize);
1078 m_outerIndex[
j + 1] += shift;
1082 if (capacity > 0) shift++;
1083 Index copyBegin = insertionLocations(
j);
1084 Index to = copyBegin + shift;
1085 Index chunkSize = copyEnd - copyBegin;
1086 m_data.
moveChunk(copyBegin, to, chunkSize);
1090 assignFunc.assignCoeff(m_data.
value(dst), diaEval.coeff(
j));
1091 if (!isCompressed()) m_innerNonZeros[
j]++;
1093 deferredInsertions--;
1094 copyEnd = copyBegin;
1098 eigen_assert((shift == 0) && (deferredInsertions == 0));
1112 struct default_prunning_func {
1126 template <
typename InputIterator,
typename SparseMatrixType,
typename DupFunctor>
1128 DupFunctor dup_func) {
1129 constexpr
bool IsRowMajor = SparseMatrixType::IsRowMajor;
1130 using StorageIndex =
typename SparseMatrixType::StorageIndex;
1132 using TransposedSparseMatrix =
1135 if (begin ==
end)
return;
1145 for (InputIterator it(begin); it !=
end; ++it) {
1147 StorageIndex
j = convert_index<StorageIndex>(IsRowMajor ? it->col() : it->row());
1149 trmat.outerIndexPtr()[
j + 1]++;
1153 std::partial_sum(trmat.outerIndexPtr(), trmat.outerIndexPtr() + trmat.outerSize() + 1, trmat.outerIndexPtr());
1154 eigen_assert(nonZeros == trmat.outerIndexPtr()[trmat.outerSize()]);
1155 trmat.resizeNonZeros(nonZeros);
1159 smart_copy(trmat.outerIndexPtr(), trmat.outerIndexPtr() + trmat.outerSize(),
tmp);
1162 for (InputIterator it(begin); it !=
end; ++it) {
1163 StorageIndex
j = convert_index<StorageIndex>(IsRowMajor ? it->col() : it->row());
1164 StorageIndex
i = convert_index<StorageIndex>(IsRowMajor ? it->row() : it->col());
1165 StorageIndex
k =
tmp[
j];
1166 trmat.
data().index(
k) =
i;
1167 trmat.data().value(
k) = it->value();
1171 IndexMap wi(
tmp, trmat.innerSize());
1172 trmat.collapseDuplicates(wi, dup_func);
1178 template <
typename InputIterator,
typename SparseMatrixType,
typename DupFunctor>
1180 DupFunctor dup_func) {
1181 constexpr
bool IsRowMajor = SparseMatrixType::IsRowMajor;
1182 using StorageIndex =
typename SparseMatrixType::StorageIndex;
1184 if (begin ==
end)
return;
1186 constexpr StorageIndex kEmptyIndexValue(-1);
1190 StorageIndex previous_j = kEmptyIndexValue;
1191 StorageIndex previous_i = kEmptyIndexValue;
1194 for (InputIterator it(begin); it !=
end; ++it) {
1196 StorageIndex
j = convert_index<StorageIndex>(IsRowMajor ? it->row() : it->col());
1197 StorageIndex
i = convert_index<StorageIndex>(IsRowMajor ? it->col() : it->row());
1200 bool duplicate = (previous_j ==
j) && (previous_i ==
i);
1215 previous_i = kEmptyIndexValue;
1216 previous_j = kEmptyIndexValue;
1218 for (InputIterator it(begin); it !=
end; ++it) {
1219 StorageIndex
j = convert_index<StorageIndex>(IsRowMajor ? it->row() : it->col());
1220 StorageIndex
i = convert_index<StorageIndex>(IsRowMajor ? it->col() : it->row());
1221 bool duplicate = (previous_j ==
j) && (previous_i ==
i);
1239 template <
typename DupFunctor,
typename LhsScalar,
typename RhsScalar = LhsScalar>
1244 return m_functor(
a,
b);
1250 template <
typename DupFunctor,
typename LhsScalar,
typename RhsScalar>
1254 template <
typename InputIterator,
typename SparseMatrixType,
typename DupFunctor>
1256 DupFunctor dup_func) {
1267 assign_sparse_to_sparse<SparseMatrixType, SrcXprType>(
mat, src);
1271 template <
typename InputIterator,
typename SparseMatrixType,
typename DupFunctor>
1273 DupFunctor dup_func) {
1284 assign_sparse_to_sparse<SparseMatrixType, SrcXprType>(
mat, src);
1326 template <
typename Scalar,
int Options_,
typename StorageIndex_>
1327 template <
typename InputIterators>
1329 const InputIterators&
end) {
1330 internal::set_from_triplets<InputIterators, SparseMatrix<Scalar, Options_, StorageIndex_>>(
1343 template <
typename Scalar,
int Options_,
typename StorageIndex_>
1344 template <
typename InputIterators,
typename DupFunctor>
1346 const InputIterators&
end, DupFunctor dup_func) {
1347 internal::set_from_triplets<InputIterators, SparseMatrix<Scalar, Options_, StorageIndex_>, DupFunctor>(
1348 begin,
end, *
this, dup_func);
1355 template <
typename Scalar,
int Options_,
typename StorageIndex_>
1356 template <
typename InputIterators>
1358 const InputIterators&
end) {
1359 internal::set_from_triplets_sorted<InputIterators, SparseMatrix<Scalar, Options_, StorageIndex_>>(
1372 template <
typename Scalar,
int Options_,
typename StorageIndex_>
1373 template <
typename InputIterators,
typename DupFunctor>
1375 const InputIterators&
end,
1376 DupFunctor dup_func) {
1377 internal::set_from_triplets_sorted<InputIterators, SparseMatrix<Scalar, Options_, StorageIndex_>, DupFunctor>(
1378 begin,
end, *
this, dup_func);
1419 template <
typename Scalar,
int Options_,
typename StorageIndex_>
1420 template <
typename InputIterators>
1422 const InputIterators&
end) {
1423 internal::insert_from_triplets<InputIterators, SparseMatrix<Scalar, Options_, StorageIndex_>>(
1436 template <
typename Scalar,
int Options_,
typename StorageIndex_>
1437 template <
typename InputIterators,
typename DupFunctor>
1439 const InputIterators&
end, DupFunctor dup_func) {
1440 internal::insert_from_triplets<InputIterators, SparseMatrix<Scalar, Options_, StorageIndex_>, DupFunctor>(
1441 begin,
end, *
this, dup_func);
1448 template <
typename Scalar,
int Options_,
typename StorageIndex_>
1449 template <
typename InputIterators>
1451 const InputIterators&
end) {
1452 internal::insert_from_triplets_sorted<InputIterators, SparseMatrix<Scalar, Options_, StorageIndex_>>(
1465 template <
typename Scalar,
int Options_,
typename StorageIndex_>
1466 template <
typename InputIterators,
typename DupFunctor>
1468 const InputIterators&
end,
1469 DupFunctor dup_func) {
1470 internal::insert_from_triplets_sorted<InputIterators, SparseMatrix<Scalar, Options_, StorageIndex_>, DupFunctor>(
1471 begin,
end, *
this, dup_func);
1475 template <
typename Scalar_,
int Options_,
typename StorageIndex_>
1476 template <
typename Derived,
typename DupFunctor>
1485 const bool is_compressed = isCompressed();
1487 for (
Index j = 0;
j < m_outerSize; ++
j) {
1489 const StorageIndex end = is_compressed ? m_outerIndex[
j + 1] : m_outerIndex[
j] + m_innerNonZeros[
j];
1492 if (wi(
i) >= newBegin) {
1505 m_outerIndex[
j] = newBegin;
1507 m_outerIndex[m_outerSize] = count;
1511 internal::conditional_aligned_delete_auto<StorageIndex, true>(m_innerNonZeros, m_outerSize);
1512 m_innerNonZeros = 0;
1516 template <
typename Scalar,
int Options_,
typename StorageIndex_>
1517 template <
typename OtherDerived>
1522 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
1524 #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN
1529 if (needToTranspose) {
1530 #ifdef EIGEN_SPARSE_TRANSPOSED_COPY_PLUGIN
1542 OtherCopy otherCopy(other.
derived());
1543 OtherCopyEval otherCopyEval(otherCopy);
1550 for (
Index j = 0;
j < otherCopy.outerSize(); ++
j)
1551 for (
typename OtherCopyEval::InnerIterator it(otherCopyEval,
j); it; ++it) ++dest.
m_outerIndex[it.index()];
1559 positions[
j] = count;
1567 for (
typename OtherCopyEval::InnerIterator it(otherCopyEval,
j); it; ++it) {
1568 Index pos = positions[it.index()]++;
1577 initAssignment(other.
derived());
1580 return Base::operator=(other.
derived());
1584 template <
typename Scalar_,
int Options_,
typename StorageIndex_>
1587 return insertByOuterInner(IsRowMajor ?
row :
col, IsRowMajor ?
col :
row);
1590 template <
typename Scalar_,
int Options_,
typename StorageIndex_>
1595 return insertUncompressedAtByOuterInner(outer, inner, dst);
1598 template <
typename Scalar_,
int Options_,
typename StorageIndex_>
1608 Index capacity = m_outerIndex[outer + 1] -
end;
1611 m_innerNonZeros[outer]++;
1618 "you cannot insert an element that already exists, you must call coeffRef to this end");
1619 return insertUncompressedAtByOuterInner(outer, inner, dst);
1622 template <
typename Scalar_,
int Options_,
typename StorageIndex_>
1629 Index end = m_outerIndex[outer + 1];
1632 "you cannot insert an element that already exists, you must call coeffRef to this end");
1633 return insertCompressedAtByOuterInner(outer, inner, dst);
1636 template <
typename Scalar_,
int Options_,
typename StorageIndex_>
1645 Index minReserve = 32;
1650 Index chunkSize = m_outerIndex[m_outerSize] - dst;
1652 m_data.
moveChunk(dst, dst + 1, chunkSize);
1655 for (
Index j = outer;
j < m_outerSize;
j++) m_outerIndex[
j + 1]++;
1660 return m_data.
value(dst);
1663 template <
typename Scalar_,
int Options_,
typename StorageIndex_>
1668 for (
Index leftTarget = outer - 1, rightTarget = outer; (leftTarget >= 0) || (rightTarget < m_outerSize);) {
1669 if (rightTarget < m_outerSize) {
1672 Index nextStart = m_outerIndex[rightTarget + 1];
1677 if (chunkSize > 0) m_data.
moveChunk(dst, dst + 1, chunkSize);
1678 m_innerNonZeros[outer]++;
1679 for (
Index j = outer;
j < rightTarget;
j++) m_outerIndex[
j + 1]++;
1682 return m_data.
value(dst);
1686 if (leftTarget >= 0) {
1689 Index nextStart = m_outerIndex[leftTarget + 1];
1694 Index chunkSize = dst - nextStart;
1695 if (chunkSize > 0) m_data.
moveChunk(nextStart, nextStart - 1, chunkSize);
1696 m_innerNonZeros[outer]++;
1697 for (
Index j = leftTarget;
j < outer;
j++) m_outerIndex[
j + 1]--;
1700 return m_data.
value(dst - 1);
1709 Index dst_offset = dst - m_outerIndex[outer];
1713 m_data.
resize(m_outerSize);
1714 std::iota(m_outerIndex, m_outerIndex + m_outerSize + 1,
StorageIndex(0));
1719 if (m_outerSize <= maxReserveSize) {
1721 reserveInnerVectors(IndexVector::Constant(m_outerSize, 1));
1727 ReserveSizesXpr reserveSizesXpr(m_outerSize, 1, ReserveSizesOp(outer, m_outerSize, maxReserveSize));
1728 reserveInnerVectors(reserveSizesXpr);
1736 if (chunkSize > 0) m_data.
moveChunk(new_dst, new_dst + 1, chunkSize);
1737 m_innerNonZeros[outer]++;
1740 return m_data.
value(new_dst);
1745 template <
typename Scalar_,
int Options_,
typename StorageIndex_>
1747 :
evaluator<SparseCompressedBase<SparseMatrix<Scalar_, Options_, StorageIndex_>>> {
1759 template <
typename Scalar,
int Options,
typename StorageIndex>
1774 std::size_t num_storage_indices =
value.isCompressed() ? 0 :
value.outerSize();
1776 num_storage_indices +=
value.outerSize() + 1;
1778 const StorageIndex inner_buffer_size =
value.outerIndexPtr()[
value.outerSize()];
1779 num_storage_indices += inner_buffer_size;
1781 std::size_t num_values = inner_buffer_size;
1782 return sizeof(Header) +
sizeof(
Scalar) * num_values +
sizeof(StorageIndex) * num_storage_indices;
1789 const size_t header_bytes =
sizeof(Header);
1793 memcpy(dest, &header, header_bytes);
1794 dest += header_bytes;
1797 if (!header.compressed) {
1798 std::size_t data_bytes =
sizeof(StorageIndex) * header.outer_size;
1799 memcpy(dest,
value.innerNonZeroPtr(), data_bytes);
1804 std::size_t data_bytes =
sizeof(StorageIndex) * (header.outer_size + 1);
1805 memcpy(dest,
value.outerIndexPtr(), data_bytes);
1809 data_bytes =
sizeof(StorageIndex) * header.inner_buffer_size;
1810 memcpy(dest,
value.innerIndexPtr(), data_bytes);
1814 data_bytes =
sizeof(
Scalar) * header.inner_buffer_size;
1815 memcpy(dest,
value.valuePtr(), data_bytes);
1825 const size_t header_bytes =
sizeof(Header);
1828 memcpy(&header, src, header_bytes);
1829 src += header_bytes;
1832 value.resize(header.rows, header.cols);
1833 if (header.compressed) {
1834 value.makeCompressed();
1840 value.data().resize(header.inner_buffer_size);
1843 if (!header.compressed) {
1845 std::size_t data_bytes =
sizeof(StorageIndex) * header.outer_size;
1847 memcpy(
value.innerNonZeroPtr(), src, data_bytes);
1852 std::size_t data_bytes =
sizeof(StorageIndex) * (header.outer_size + 1);
1854 memcpy(
value.outerIndexPtr(), src, data_bytes);
1858 data_bytes =
sizeof(StorageIndex) * header.inner_buffer_size;
1860 memcpy(
value.innerIndexPtr(), src, data_bytes);
1864 data_bytes =
sizeof(
Scalar) * header.inner_buffer_size;
1866 memcpy(
value.valuePtr(), src, data_bytes);
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
#define EIGEN_DEPRECATED
Definition: Macros.h:931
#define EIGEN_USING_STD(FUNC)
Definition: Macros.h:1090
#define eigen_internal_assert(x)
Definition: Macros.h:916
#define EIGEN_PREDICT_FALSE(x)
Definition: Macros.h:1179
#define EIGEN_UNUSED_VARIABLE(var)
Definition: Macros.h:966
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_DONT_INLINE
Definition: Macros.h:853
#define eigen_assert(x)
Definition: Macros.h:910
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
Definition: Memory.h:806
#define EIGEN_DBG_SPARSE(X)
Definition: SparseUtil.h:21
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
Definition: SparseUtil.h:39
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
float * p
Definition: Tutorial_Map_using.cpp:9
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
Scalar * b
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:79
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:64
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:44
EIGEN_DEVICE_FUNC Derived & setConstant(const Scalar &value)
Definition: CwiseNullaryOp.h:349
Base class for diagonal matrices and expressions.
Definition: DiagonalMatrix.h:33
EIGEN_DEVICE_FUNC const Derived & derived() const
Definition: DiagonalMatrix.h:57
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Definition: Diagonal.h:68
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
constexpr EIGEN_DEVICE_FUNC const Scalar * data() const
Definition: PlainObjectBase.h:273
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:202
Definition: ReturnByValue.h:50
EIGEN_DEVICE_FUNC void evalTo(Dest &dst) const
Definition: ReturnByValue.h:58
EIGEN_DEVICE_FUNC size_t size(const SparseMat &value) const
Definition: SparseMatrix.h:1772
SparseMatrix< Scalar, Options, StorageIndex > SparseMat
Definition: SparseMatrix.h:1762
EIGEN_DEVICE_FUNC const uint8_t * deserialize(const uint8_t *src, const uint8_t *end, SparseMat &value) const
Definition: SparseMatrix.h:1821
EIGEN_DEVICE_FUNC uint8_t * serialize(uint8_t *dest, uint8_t *end, const SparseMat &value)
Definition: SparseMatrix.h:1785
Definition: Serializer.h:27
Definition: SparseCompressedBase.h:207
Definition: SparseCompressedBase.h:292
Common base class for sparse [compressed]-{row|column}-storage format.
Definition: SparseCompressedBase.h:43
Index nonZeros() const
Definition: SparseCompressedBase.h:64
bool isCompressed() const
Definition: SparseCompressedBase.h:114
@ IsRowMajor
Definition: SparseMatrixBase.h:99
Derived & operator=(const Derived &other)
Definition: SparseAssign.h:43
Base class of any sparse matrices or sparse expressions.
Definition: SparseMatrixBase.h:30
internal::traits< SparseMatrix< Scalar_, Options_, StorageIndex_ > >::StorageIndex StorageIndex
Definition: SparseMatrixBase.h:44
Index size() const
Definition: SparseMatrixBase.h:187
Index rows() const
Definition: SparseMatrixBase.h:182
bool isRValue() const
Definition: SparseMatrixBase.h:200
Derived & const_cast_derived() const
Definition: SparseMatrixBase.h:146
internal::traits< SparseMatrix< Scalar_, Options_, StorageIndex_ > >::Scalar Scalar
Definition: SparseMatrixBase.h:32
const Derived & derived() const
Definition: SparseMatrixBase.h:144
NumTraits< Scalar >::Real RealScalar
Definition: SparseMatrixBase.h:128
Index cols() const
Definition: SparseMatrixBase.h:184
static StorageIndex convert_index(const Index idx)
Definition: SparseMatrixBase.h:391
Definition: SparseMatrix.h:957
StorageIndex m_value
Definition: SparseMatrix.h:959
StorageIndex m_index
Definition: SparseMatrix.h:958
StorageIndex value_type
Definition: SparseMatrix.h:962
StorageIndex operator[](Index i) const
Definition: SparseMatrix.h:965
SingletonVector(Index i, Index v)
Definition: SparseMatrix.h:963
A versatible sparse matrix representation.
Definition: SparseMatrix.h:121
EIGEN_DEPRECATED EIGEN_DONT_INLINE Scalar & insertCompressed(Index row, Index col)
Definition: SparseMatrix.h:1624
Base::IndexVector IndexVector
Definition: SparseMatrix.h:145
Scalar coeff(Index row, Index col) const
Definition: SparseMatrix.h:211
Scalar & insertCompressedAtByOuterInner(Index outer, Index inner, Index dst)
Definition: SparseMatrix.h:1638
SparseMatrix & operator=(SparseCompressedBase< OtherDerived > &&other)
Definition: SparseMatrix.h:892
StorageIndex * innerIndexPtr()
Definition: SparseMatrix.h:184
StorageIndex * innerNonZeroPtr()
Definition: SparseMatrix.h:202
void collapseDuplicates(DenseBase< Derived > &wi, DupFunctor dup_func=DupFunctor())
Definition: SparseMatrix.h:1477
Storage m_data
Definition: SparseMatrix.h:155
SparseMatrix(SparseCompressedBase< OtherDerived > &&other)
Definition: SparseMatrix.h:802
EIGEN_DEPRECATED EIGEN_DONT_INLINE Scalar & insertUncompressed(Index row, Index col)
Definition: SparseMatrix.h:1600
EIGEN_DONT_INLINE SparseMatrix & operator=(const SparseMatrixBase< OtherDerived > &other)
const ConstDiagonalReturnType diagonal() const
Definition: SparseMatrix.h:757
void swap(SparseMatrix &other)
Definition: SparseMatrix.h:829
Scalar & insertUncompressedAtByOuterInner(Index outer, Index inner, Index dst)
Definition: SparseMatrix.h:1665
void insertFromSortedTriplets(const InputIterators &begin, const InputIterators &end, DupFunctor dup_func)
Definition: SparseMatrix.h:1467
void assignDiagonal(const DiagXpr diagXpr, const Func &assignFunc)
Definition: SparseMatrix.h:1005
void setZero()
Definition: SparseMatrix.h:303
Index cols() const
Definition: SparseMatrix.h:161
SparseMatrix(const ReturnByValue< OtherDerived > &other)
Copy constructor with in-place evaluation.
Definition: SparseMatrix.h:814
void setFromSortedTriplets(const InputIterators &begin, const InputIterators &end)
Definition: SparseMatrix.h:1357
SparseMatrix & operator=(SparseMatrix &&other)
Definition: SparseMatrix.h:873
void setFromTriplets(const InputIterators &begin, const InputIterators &end, DupFunctor dup_func)
Definition: SparseMatrix.h:1345
void startVec(Index outer)
Definition: SparseMatrix.h:451
EIGEN_STRONG_INLINE Scalar & insertBackUncompressed(Index row, Index col)
Definition: SparseMatrix.h:975
SparseMatrix & operator=(const EigenBase< OtherDerived > &other)
Definition: SparseMatrix.h:880
Index outerSize() const
Definition: SparseMatrix.h:166
StorageIndex * m_outerIndex
Definition: SparseMatrix.h:153
Scalar & insertBackByOuterInner(Index outer, Index inner)
Definition: SparseMatrix.h:430
SparseMatrix()
Definition: SparseMatrix.h:766
void uncompress()
Definition: SparseMatrix.h:622
void insertEmptyOuterVectors(Index j, Index num=1)
Definition: SparseMatrix.h:509
void insertFromSortedTriplets(const InputIterators &begin, const InputIterators &end)
Definition: SparseMatrix.h:1450
Scalar * valuePtr()
Definition: SparseMatrix.h:175
void finalize()
Definition: SparseMatrix.h:461
void reserveInnerVectors(const SizesType &reserveSizes)
Definition: SparseMatrix.h:345
SparseMatrix< Scalar, IsRowMajor ? ColMajor :RowMajor, StorageIndex > TransposedSparseMatrix
Definition: SparseMatrix.h:149
const StorageIndex * innerNonZeroPtr() const
Definition: SparseMatrix.h:198
void makeCompressed()
Definition: SparseMatrix.h:589
Index m_outerSize
Definition: SparseMatrix.h:151
Scalar & insertByOuterInner(Index j, Index i)
Definition: SparseMatrix.h:566
StorageIndex * outerIndexPtr()
Definition: SparseMatrix.h:193
Scalar & coeffRef(Index row, Index col)
Definition: SparseMatrix.h:275
friend EIGEN_DEVICE_FUNC void swap(SparseMatrix &a, SparseMatrix &b)
Definition: SparseMatrix.h:838
const Scalar * valuePtr() const
Definition: SparseMatrix.h:171
void initAssignment(const Other &other)
Definition: SparseMatrix.h:945
Eigen::Map< SparseMatrix< Scalar, Options_, StorageIndex > > Map
Definition: SparseMatrix.h:135
void setFromSortedTriplets(const InputIterators &begin, const InputIterators &end, DupFunctor dup_func)
Definition: SparseMatrix.h:1374
EIGEN_STATIC_ASSERT((Options &(ColMajor|RowMajor))==Options, INVALID_MATRIX_TEMPLATE_PARAMETERS) struct default_prunning_func
Definition: SparseMatrix.h:1110
SparseMatrix(const SparseSelfAdjointView< OtherDerived, UpLo > &other)
Definition: SparseMatrix.h:793
void resize(Index rows, Index cols)
Definition: SparseMatrix.h:734
bool isCompressed() const
Definition: SparseCompressedBase.h:114
Index rows() const
Definition: SparseMatrix.h:159
SparseMatrix(const SparseMatrix &other)
Definition: SparseMatrix.h:807
StorageIndex * m_innerNonZeros
Definition: SparseMatrix.h:154
void setFromTriplets(const InputIterators &begin, const InputIterators &end)
Definition: SparseMatrix.h:1328
SparseMatrix(const DiagonalBase< OtherDerived > &other)
Copy constructor with in-place evaluation.
Definition: SparseMatrix.h:822
constexpr const Storage & data() const
Definition: SparseMatrix.h:207
void setIdentity()
Definition: SparseMatrix.h:842
Index innerSize() const
Definition: SparseMatrix.h:164
SparseMatrix(Index rows, Index cols)
Definition: SparseMatrix.h:769
void conservativeResize(Index rows, Index cols)
Definition: SparseMatrix.h:681
void insertFromTriplets(const InputIterators &begin, const InputIterators &end, DupFunctor dup_func)
Definition: SparseMatrix.h:1438
void prune(const Scalar &reference, const RealScalar &epsilon=NumTraits< RealScalar >::dummy_precision())
Definition: SparseMatrix.h:634
void resizeNonZeros(Index size)
Definition: SparseMatrix.h:754
Diagonal< SparseMatrix > DiagonalReturnType
Definition: SparseMatrix.h:136
SparseMatrix & operator=(const Product< Lhs, Rhs, AliasFreeProduct > &other)
SparseMatrix(const SparseMatrixBase< OtherDerived > &other)
Definition: SparseMatrix.h:775
Base::InnerIterator InnerIterator
Definition: SparseMatrix.h:138
Diagonal< const SparseMatrix > ConstDiagonalReturnType
Definition: SparseMatrix.h:137
~SparseMatrix()
Definition: SparseMatrix.h:931
void reserve(const SizesType &reserveSizes, const typename SizesType::value_type &enableif=typename SizesType::value_type())
Definition: SparseMatrix.h:337
SparseCompressedBase< SparseMatrix > Base
Definition: SparseMatrix.h:122
void prune(const KeepFunc &keep=KeepFunc())
Definition: SparseMatrix.h:646
SparseMatrix & operator=(const SparseMatrix &other)
Definition: SparseMatrix.h:855
@ Options
Definition: SparseMatrix.h:143
void removeOuterVectors(Index j, Index num=1)
Definition: SparseMatrix.h:476
const StorageIndex * outerIndexPtr() const
Definition: SparseMatrix.h:189
Scalar & insertBack(Index row, Index col)
Definition: SparseMatrix.h:424
Scalar & findOrInsertCoeff(Index row, Index col, bool *inserted)
Definition: SparseMatrix.h:231
void reserve(Index reserveSize)
Definition: SparseMatrix.h:315
@ IsRowMajor
Definition: SparseMatrixBase.h:99
const StorageIndex * innerIndexPtr() const
Definition: SparseMatrix.h:180
Scalar & insert(Index row, Index col)
Definition: SparseMatrix.h:1586
DiagonalReturnType diagonal()
Definition: SparseMatrix.h:763
friend std::ostream & operator<<(std::ostream &s, const SparseMatrix &m)
Definition: SparseMatrix.h:898
Scalar & insertBackByOuterInnerUnordered(Index outer, Index inner)
Definition: SparseMatrix.h:442
Base::ScalarVector ScalarVector
Definition: SparseMatrix.h:146
Index m_innerSize
Definition: SparseMatrix.h:152
constexpr Storage & data()
Definition: SparseMatrix.h:205
Base::ReverseInnerIterator ReverseInnerIterator
Definition: SparseMatrix.h:139
void insertFromTriplets(const InputIterators &begin, const InputIterators &end)
Definition: SparseMatrix.h:1421
internal::CompressedStorage< Scalar, StorageIndex > Storage
Definition: SparseMatrix.h:142
SparseMatrix(SparseMatrix &&other)
Definition: SparseMatrix.h:799
EIGEN_STRONG_INLINE Scalar & insertAtByOuterInner(Index outer, Index inner, Index dst)
Definition: SparseMatrix.h:1592
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
Definition: SparseSelfAdjointView.h:52
a sparse vector class
Definition: SparseVector.h:62
void squeeze()
Definition: CompressedStorage.h:68
Scalar & value(Index i)
Definition: CompressedStorage.h:103
StorageIndex & index(Index i)
Definition: CompressedStorage.h:112
const StorageIndex * indexPtr() const
Definition: CompressedStorage.h:100
void swap(CompressedStorage &other)
Definition: CompressedStorage.h:51
void append(const Scalar &v, Index i)
Definition: CompressedStorage.h:87
const Scalar * valuePtr() const
Definition: CompressedStorage.h:98
Scalar atInRange(Index start, Index end, Index key, const Scalar &defaultValue=Scalar(0)) const
Definition: CompressedStorage.h:143
Index searchLowerIndex(Index key) const
Definition: CompressedStorage.h:122
void reserve(Index size)
Definition: CompressedStorage.h:63
void moveChunk(Index from, Index to, Index chunkSize)
Definition: CompressedStorage.h:178
void clear()
Definition: CompressedStorage.h:96
Index allocatedSize() const
Definition: CompressedStorage.h:95
Index size() const
Definition: CompressedStorage.h:94
void resize(Index size, double reserveSizeFactor=0)
Definition: CompressedStorage.h:72
static constexpr lastp1_t end
Definition: IndexedViewHelper.h:79
@ ColMajor
Definition: Constants.h:318
@ RowMajor
Definition: Constants.h:320
const unsigned int LvalueBit
Definition: Constants.h:148
const unsigned int RowMajorBit
Definition: Constants.h:70
const unsigned int CompressedAccessBit
Definition: Constants.h:195
RealScalar s
Definition: level1_cplx_impl.h:130
EIGEN_BLAS_FUNC() swap(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
Definition: level1_impl.h:117
const Scalar * a
Definition: level2_cplx_impl.h:32
int * m
Definition: level2_cplx_impl.h:294
if(UPLO(*uplo)==INVALID) info
Definition: level3_impl.h:428
char char char int int * k
Definition: level2_impl.h:374
char char * op
Definition: level2_impl.h:374
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
double eps
Definition: crbond_bessel.cc:24
EIGEN_DEVICE_FUNC IndexDest convert_index(const IndexSrc &idx)
Definition: XprHelper.h:63
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
Definition: AssignEvaluator.h:812
EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Definition: MathFunctions.h:1916
typename remove_all< T >::type remove_all_t
Definition: Meta.h:142
EIGEN_DEVICE_FUNC void throw_std_bad_alloc()
Definition: Memory.h:110
void insert_from_triplets(const InputIterator &begin, const InputIterator &end, SparseMatrixType &mat, DupFunctor dup_func)
Definition: SparseMatrix.h:1255
EIGEN_DEVICE_FUNC void smart_copy(const T *start, const T *end, T *target)
Definition: Memory.h:569
void insert_from_triplets_sorted(const InputIterator &begin, const InputIterator &end, SparseMatrixType &mat, DupFunctor dup_func)
Definition: SparseMatrix.h:1272
void smart_memmove(const T *start, const T *end, T *target)
Definition: Memory.h:594
void set_from_triplets_sorted(const InputIterator &begin, const InputIterator &end, SparseMatrixType &mat, DupFunctor dup_func)
Definition: SparseMatrix.h:1179
void set_from_triplets(const InputIterator &begin, const InputIterator &end, SparseMatrixType &mat, DupFunctor dup_func)
Definition: SparseMatrix.h:1127
std::uint8_t uint8_t
Definition: Meta.h:36
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
Definition: MathFunctions.h:926
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
Definition: MathFunctions.h:920
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
squared absolute value
Definition: GlobalFunctions.h:87
const unsigned int NestByRefBit
Definition: Constants.h:173
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
const int InnerRandomAccessPattern
Definition: SparseUtil.h:42
const int Dynamic
Definition: Constants.h:25
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56
type
Definition: compute_granudrum_aor.py:141
Definition: Eigen_Colamd.h:49
void start(const unsigned &i)
(Re-)start i-th timer
Definition: oomph_utilities.cc:243
double epsilon
Definition: osc_ring_sarah_asymptotics.h:43
#define EIGEN_SPARSE_TRANSPOSED_COPY_PLUGIN
Definition: sparse_permutations.cpp:11
#define EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN
Definition: sparse_permutations.cpp:22
Definition: Constants.h:519
Definition: EigenBase.h:33
constexpr EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:49
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:43
Definition: Constants.h:534
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: SparseMatrix.h:989
Index p
Definition: SparseMatrix.h:992
Index i
Definition: SparseMatrix.h:991
IndexPosPair(Index a_i, Index a_p)
Definition: SparseMatrix.h:990
Definition: Constants.h:522
Definition: AssignEvaluator.h:773
SparseMatrix< Scalar_, Options_, StorageIndex_ > SparseMatrixType
Definition: SparseMatrix.h:1749
evaluator()
Definition: SparseMatrix.h:1750
evaluator< SparseCompressedBase< SparseMatrix< Scalar_, Options_, StorageIndex_ > > > Base
Definition: SparseMatrix.h:1748
evaluator(const SparseMatrixType &mat)
Definition: SparseMatrix.h:1751
Definition: CoreEvaluators.h:104
Definition: XprHelper.h:205
@ PacketAccess
Definition: XprHelper.h:206
@ Cost
Definition: XprHelper.h:206
@ IsRepeatable
Definition: XprHelper.h:206
Definition: XprHelper.h:533
Definition: XprHelper.h:506
Definition: SparseMatrix.h:1240
const DupFunctor & m_functor
Definition: SparseMatrix.h:1247
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const DupFunctor & functor() const
Definition: SparseMatrix.h:1246
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator()(const LhsScalar &a, const RhsScalar &b) const
Definition: SparseMatrix.h:1243
typename result_of< DupFunctor(LhsScalar, RhsScalar)>::type result_type
Definition: SparseMatrix.h:1241
scalar_disjunction_op(const DupFunctor &op)
Definition: SparseMatrix.h:1242
Template functor to compute the sum of two scalars.
Definition: BinaryFunctors.h:34
Definition: SparseMatrix.h:94
StorageIndex m_remainder
Definition: SparseMatrix.h:109
Index m_end
Definition: SparseMatrix.h:110
EIGEN_DEVICE_FUNC sparse_reserve_op(Index begin, Index end, Index size)
Definition: SparseMatrix.h:95
StorageIndex m_val
Definition: SparseMatrix.h:109
Index m_begin
Definition: SparseMatrix.h:110
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE StorageIndex operator()(IndexType i) const
Definition: SparseMatrix.h:103
StorageIndex_ StorageIndex
Definition: SparseMatrix.h:75
MatrixXpr XprKind
Definition: SparseMatrix.h:76
ref_selector< MatrixType >::type MatrixTypeNested
Definition: SparseMatrix.h:70
Scalar_ Scalar
Definition: SparseMatrix.h:73
std::remove_reference_t< MatrixTypeNested > MatrixTypeNested_
Definition: SparseMatrix.h:71
SparseMatrix< Scalar_, Options_, StorageIndex_ > MatrixType
Definition: SparseMatrix.h:69
Dense StorageKind
Definition: SparseMatrix.h:74
MatrixXpr XprKind
Definition: SparseMatrix.h:55
Sparse StorageKind
Definition: SparseMatrix.h:54
Scalar_ Scalar
Definition: SparseMatrix.h:52
StorageIndex_ StorageIndex
Definition: SparseMatrix.h:53
Definition: ForwardDeclarations.h:21
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2