Split global .gitignore file into per-directory files
[libav.git] / libavutil / tests / lls.c
1 /*
2 * This file is part of Libav.
3 *
4 * Libav is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * Libav is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with Libav; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <limits.h>
20 #include <stdio.h>
21
22 #include "libavutil/internal.h"
23 #include "libavutil/lfg.h"
24 #include "libavutil/lls.h"
25
26 int main(void)
27 {
28 LLSModel m;
29 int i, order;
30 AVLFG lfg;
31
32 av_lfg_init(&lfg, 1);
33 avpriv_init_lls(&m, 3);
34
35 for (i = 0; i < 100; i++) {
36 LOCAL_ALIGNED(32, double, var, [4]);
37 double eval;
38
39 var[0] = (av_lfg_get(&lfg) / (double) UINT_MAX - 0.5) * 2;
40 var[1] = var[0] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
41 var[2] = var[1] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
42 var[3] = var[2] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
43 m.update_lls(&m, var);
44 avpriv_solve_lls(&m, 0.001, 0);
45 for (order = 0; order < 3; order++) {
46 eval = m.evaluate_lls(&m, var + 1, order);
47 printf("real:%9f order:%d pred:%9f var:%f coeffs:%f %9f %9f\n",
48 var[0], order, eval, sqrt(m.variance[order] / (i + 1)),
49 m.coeff[order][0], m.coeff[order][1],
50 m.coeff[order][2]);
51 }
52 }
53 return 0;
54 }