versor  3.0
C++11 library for Geometric algebra
vsr_map.h
1 /*
2  * =====================================================================================
3  *
4  * Filename: vsr_map.h
5  *
6  * Description: map a function over a set see also topo
7  *
8  * Version: 1.0
9  * Created: 03/02/2015 18:20:30
10  * Revision: none
11  * Compiler: gcc
12  *
13  * Author: Pablo Colapinto (), gmail -> wolftype
14  * Organization:
15  *
16  * =====================================================================================
17  */
18 
19 
20 #ifndef vsr_map_INC
21 #define vsr_map_INC
22 
23 #include "detail/vsr_generic_op.h"
24 
25 namespace vsr {
26 
27  namespace functor {
28 
29 
33  template<class T, class S, class Lambda>
34  vector<T> eval(const vector<S>& in, Lambda func, int iter, float range=1.0){
35  vector<T> out;
36  for(auto& c : in){
37  for (int j=0;j<iter;++j){
38  float t = range*(float)j/iter;
39  out.push_back( func(c,t) );
40  }
41  }
42  return out;
43  }
44 
48  template<class T, class Lambda, class S, class ... Args>
49  vector<T> fmap(Lambda func, const vector<S>& in, Args ... args){
50  vector<T> out;
51  for(auto& c : in){
52  out.push_back( func(c,args...) );
53  }
54  return out;
55  }
56 
57 
58  } //functor::
59 
60 }//vsr::
61 #endif /* ----- #ifndef vsr_map_INC ----- */
core namespaced operations that are metric-agnostic
the versor library namespace
Definition: vsr_algebra.h:29