Partial adoption of contributions by Giuseppe:
[libdai.git] / include / dai / x2x.h
1 /* Copyright (C) 2006-2008 Joris Mooij [j dot mooij at science dot ru dot nl]
2 Radboud University Nijmegen, The Netherlands
3
4 This file is part of libDAI.
5
6 libDAI is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 libDAI is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with libDAI; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21
22 #ifndef __defined_libdai_x2x_h
23 #define __defined_libdai_x2x_h
24
25
26 #include <cmath>
27 #include <cstring>
28
29
30 namespace x2x {
31
32 // Probability tables store -1 first, then +1
33
34 /// Convert moments to cumulants upto order k
35 void m2c (int N, double *x, int k);
36
37 /// Convert cumulants to moments upto order k
38 void c2m (int N, double *x, int k);
39
40 /// Convert (generalized) weights to log probability or energy
41 void w2logp (int N, double *x);
42
43 /// Convert log probability or energy to (generalized) weights
44 void logp2w (int N, double *x);
45
46 /// Convert probability to moments
47 void p2m (int N, double *x);
48
49 /// Convert moments to probability
50 void m2p (int N, double *x);
51
52 /// Convert log probability to probability
53 void logp2p (int N, double *x);
54
55 /// Convert probability to log probability
56 void p2logp (int N, double *x);
57
58 /// Normalize a log probability table
59 void logpnorm (int N, double *x);
60
61 /// Normalize a probability table, use logpnorm whenever possible
62 void pnorm (int N, double *x);
63
64 /// Fills table with v for all entries with more than k indices
65 /// used for example when cumulants or moments are converted upto some order
66 void fill (int N, double *x, int k, double v);
67
68 } // end of namespace x2x
69
70
71 #endif