-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cc
51 lines (36 loc) · 951 Bytes
/
test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "lazylookup.hh"
#include <cmath>
#include <stdlib.h>
double frobnicate(int x)
{
double sum = 1;
for (int i = 0; i < 100000000; i++)
{
sum += sin(sum*x);
}
return sum;
}
double ufrobnicate(std::size_t x)
{
return frobnicate(x);
}
double gridfn(const std::array<double,2> & X)
{
return X[0] *X[1];
}
int main(int nargs, char ** args)
{
lazylookup::dict<int,double> test_dict(frobnicate);
lazylookup::vec<double> test_vec(ufrobnicate);
lazylookup::grid_interpolator<2> test_grid(gridfn, {100,100},{0,0},{10,10});
for (int i = 0; i < 100; i++)
{
int input = (i%10);
printf("dict: %g %d\n", test_dict[input], test_dict.get_n_filled());
printf("vec: %g %d\n", test_vec[input], test_vec.get_n_filled());
std::array<double,2> grid_input = { sqrt(i), sqrt(i) };
printf("grid: %g %g\n", gridfn(grid_input), test_grid[grid_input]);
}
//test_grid.dump();
return 0;
}