Sleipnir C++ API
Loading...
Searching...
No Matches
all_finite.hpp
1// Copyright (c) Sleipnir contributors
2
3#pragma once
4
5#include <cmath>
6
7#include <Eigen/SparseCore>
8
13template <typename Derived>
14bool all_finite(const Eigen::SparseCompressedBase<Derived>& mat) {
15 using std::isfinite;
16
17 for (int k = 0; k < mat.outerSize(); ++k) {
18 for (typename Derived::InnerIterator it{mat, k}; it; ++it) {
19 if (!isfinite(it.value())) {
20 return false;
21 }
22 }
23 }
24
25 return true;
26}