8 #include <boost/call_traits.hpp>
9 #include <boost/numeric/ublas/matrix.hpp>
12 # define UNLIKELY(E) __builtin_expect(E, 0)
14 # define UNLIKELY(E) (E)
17 struct key_error :
public std::runtime_error
19 key_error(
const std::string& s) :
std::runtime_error(s) {}
24 bool find(
const M& map,
25 typename boost::call_traits<typename M::key_type>::param_type key,
26 typename M::mapped_type& result)
28 typename M::const_iterator it = map.find(key);
29 if(it==map.end())
return false;
42 typedef typename I::iterator_category iterator_category;
43 typedef typename I::value_type::second_type value_type;
44 typedef std::ptrdiff_t difference_type;
45 typedef value_type* pointer;
46 typedef value_type& reference;
52 reference operator*()
const {
return orig->second; }
53 pointer operator->()
const {
return &orig->second; }
54 reference operator[](
size_t i)
const {
return orig[i]->second; }
73 typedef boost::numeric::ublas::matrix<double,
74 boost::numeric::ublas::row_major
77 typedef std::map<std::string, size_t> colnames_t;
82 void read(std::istream&);
85 class numeric_table_cache {
87 std::auto_ptr<Pvt> pvt;
89 numeric_table_cache();
90 ~numeric_table_cache();
92 typedef boost::shared_ptr<const numeric_table> table_pointer;
94 table_pointer fetch(
const std::string& path);
98 static numeric_table_cache*
get();
102 std::ostringstream strm;
104 operator std::string()
const {
return strm.str(); }
106 SB& operator<<(T i) { strm<<i;
return *
this; }
110 template<
unsigned MAX>
114 size_t index[MAX], limit[MAX];
116 std::fill(index, index+MAX, 0u);
117 std::copy(lim, lim+nd, limit);
121 for(
unsigned nd=0; nd<ndim; nd++) {
123 if(index[nd]<limit[nd]) {
136 #define FLAME_UNUSED __attribute__((unused))
141 #if __cplusplus<201103L && !defined(static_assert)
142 #define STATIC_JOIN(x, y) STATIC_JOIN2(x, y)
143 #define STATIC_JOIN2(x, y) x ## y
144 #define static_assert(expr, msg) \
145 typedef int STATIC_JOIN(static_assert_failed_at_line_, __LINE__) \
146 [ (expr) ? 1 : -1 ] FLAME_UNUSED
Helper to step through the indicies of an Nd array.