Adopted contributions by Christian.
[libdai.git] / 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 #include <cmath>
23 #include <cstring>
24
25
26 namespace x2x {
27
28 // Probability tables store -1 first, then +1
29
30 /// Convert moments to cumulants upto order k
31 void m2c (int N, double *x, int k);
32
33 /// Convert cumulants to moments upto order k
34 void c2m (int N, double *x, int k);
35
36 /// Convert (generalized) weights to log probability or energy
37 void w2logp (int N, double *x);
38
39 /// Convert log probability or energy to (generalized) weights
40 void logp2w (int N, double *x);
41
42 /// Convert probability to moments
43 void p2m (int N, double *x);
44
45 /// Convert moments to probability
46 void m2p (int N, double *x);
47
48 /// Convert log probability to probability
49 void logp2p (int N, double *x);
50
51 /// Convert probability to log probability
52 void p2logp (int N, double *x);
53
54 /// Normalize a log probability table
55 void logpnorm (int N, double *x);
56
57 /// Normalize a probability table, use logpnorm whenever possible
58 void pnorm (int N, double *x);
59
60 /// Fills table with v for all entries with more than k indices
61 /// used for example when cumulants or moments are converted upto some order
62 void fill (int N, double *x, int k, double v);
63 }