Skip to content

Commit

Permalink
Update helpers.h
Browse files Browse the repository at this point in the history
  • Loading branch information
ManosPapadakis95 committed Dec 4, 2023
1 parent 8af14f4 commit b46a7c6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions inst/include/internal/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <RcppArmadillo.h>
using namespace arma;

typedef double (*Unary_Function)(double); // unary function

template <class RET, class... Args>
using Mfunction = RET (*)(Args...);

Expand Down Expand Up @@ -52,4 +54,11 @@ colvec elems(colvec x, colvec y)
inline bool check_if_is_finite(double x)
{
return x > 0 and !R_IsNA(x);
}

template<Unary_Function F,typename T1,typename T2>
void fill_with(T1 start,T1 end,T2 startf){
for(;start!=end;++start,++startf){
*startf=F(*start);
}
}

0 comments on commit b46a7c6

Please sign in to comment.