-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgenerate_lse_table.m
65 lines (51 loc) · 1.44 KB
/
generate_lse_table.m
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
%{
liblrhsmm
===
Copyright (c) 2016 Kanru Hua. All rights reserved.
This file is part of liblrhsmm.
liblrhsmm is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
liblrhsmm is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with liblrhsmm. If not, see <http://www.gnu.org/licenses/>.
%}
printf("#include \"math-funcs.h\"\n\n");
printf("FP_TYPE lrh_lse_table[lrh_lse_table_size] = {\n ");
tbsize = 7000;
tbstep = 0.001;
x = -(0:tbsize - 1) * tbstep;
y = log(1.0 + exp(x));
for n = 1:tbsize
if(mod(n, 5) == 0)
if(n == tbsize)
printf("%2.7e\n};\n", y(n));
else
printf("%2.7e,\n ", y(n));
end
else
printf("%2.7e, ", y(n));
end
end
printf("\n");
tbsize = 7000;
tbstep = 0.002;
x = -(0:tbsize - 1) * tbstep;
y = exp(x);
printf("FP_TYPE lrh_exp_table[lrh_exp_table_size] = {\n ");
for n = 1:tbsize
if(mod(n, 5) == 0)
if(n == tbsize)
printf("%2.7e\n};\n", y(n));
else
printf("%2.7e,\n ", y(n));
end
else
printf("%2.7e, ", y(n));
end
end
printf("\n");