6 #ifndef DISMEC_FAST_SPARSE_ITER_H
7 #define DISMEC_FAST_SPARSE_ITER_H
22 using Scalar = SparseFeatures::Scalar;
23 using Index = SparseFeatures::Index;
28 m_id = mat.outerIndexPtr()[
row];
40 [[nodiscard]]
inline int col()
const {
return index(); }
42 inline explicit operator bool()
const {
return (
m_id <
m_end); }
54 template<
typename Scalar,
int Options,
typename StorageIndex,
typename OtherDerived>
55 auto fast_dot(
const Eigen::SparseMatrix<Scalar, Options, StorageIndex>& first,
int row,
const Eigen::MatrixBase<OtherDerived>& other) -> Scalar {
56 auto values = first.valuePtr();
57 auto indices = first.innerIndexPtr();
58 auto id = first.outerIndexPtr()[row];
59 auto end = first.outerIndexPtr()[row + 1];
65 for (;
id < end - 4;
id += 4) {
66 a += values[id] * other.coeff(indices[
id]);
67 b += values[
id + 1] * other.coeff(indices[
id + 1]);
68 c += values[
id + 2] * other.coeff(indices[
id + 2]);
69 d += values[
id + 3] * other.coeff(indices[
id + 3]);
71 Scalar res = (a + b) + (c + d);
73 res += values[id] * other.coeff(indices[
id]);
This is an almost verbatim copy of the SparseFeatures::InnerIterator provided by Eigen.
FastSparseRowIter & operator++()
SparseFeatures::Scalar Scalar
const StorageIndex * m_indices
FastSparseRowIter(const SparseFeatures &mat, Index row)
const Scalar & value() const
SparseFeatures::StorageIndex StorageIndex
SparseFeatures::Index Index
Main namespace in which all types, classes, and functions are defined.
auto fast_dot(const Eigen::SparseMatrix< Scalar, Options, StorageIndex > &first, int row, const Eigen::MatrixBase< OtherDerived > &other) -> Scalar
types::SparseRowMajor< real_t > SparseFeatures
Sparse Feature Matrix in Row Major format.