many-to-many multi-modal routing aggregator
1#pragma once
2
3#include <math.h> // isnan
4
5#include <Rcpp.h>
6// [[Rcpp::plugins(cpp11)]]
7// [[Rcpp::depends(RcppParallel)]]
8#include <RcppParallel.h>
9
10constexpr int INFINITE_INT = std::numeric_limits <int>::max ();
11constexpr double INFINITE_DBL = std::numeric_limits <double>::max ();
12
13// https://stackoverflow.com/a/35890119
14template <typename T>
15struct NaNAwareLess
16{
17 bool operator () (T a, T b) const
18 {
19 if (std::isnan (b))
20 {
21 return false; // Assume NaN is less than *any* non-NaN value.
22 }
23 if (std::isnan (a))
24 {
25 return true; // Assume *any* non-NaN value is greater than NaN.
26 }
27 return (a < b);
28 }
29};
30
31const double rcpp_matrix_max (Rcpp::NumericMatrix dmat);