Fixed Win64 build problems with help of Sameh Khamis
authorJoris Mooij <j.mooij@cs.ru.nl>
Thu, 2 Aug 2012 08:25:57 +0000 (10:25 +0200)
committerJoris Mooij <j.mooij@cs.ru.nl>
Thu, 2 Aug 2012 08:25:57 +0000 (10:25 +0200)
* Added VC10 build files, kindly provided by Sameh Khamis
* Fixed several Win64 related bugs (found by Sameh Khamis):
  - define NAN
  - add some necessary casts of size_t to BigInt
  - replaced occurrence of __PRETTY_FUNCTION__ with FUNCTION_NAME that was forgotten in a previous fix

19 files changed:
ChangeLog
README
include/dai/clustergraph.h
include/dai/doc.h
include/dai/exceptions.h
include/dai/factor.h
include/dai/index.h
include/dai/util.h
include/dai/varset.h
src/emalg.cpp
src/factor.cpp
src/jtree.cpp
vc10/compile_debug_win32.m [new file with mode: 0644]
vc10/compile_debug_x64.m [new file with mode: 0644]
vc10/compile_release_win32.m [new file with mode: 0644]
vc10/compile_release_x64.m [new file with mode: 0644]
vc10/libdai.sln [new file with mode: 0644]
vc10/libdai.vcxproj [new file with mode: 0644]
vc10/test_run.m [new file with mode: 0644]

index 0fddd79..6d2d675 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 git master
 ----------
+* Added VC10 build files, kindly provided by Sameh Khamis
+* Fixed several Win64 related bugs (found by Sameh Khamis): 
+  - define NAN
+  - add some necessary casts of size_t to BigInt
+  - replaced occurrence of __PRETTY_FUNCTION__ with FUNCTION_NAME that was forgotten in a previous fix
+  This means that libDAI now builds successfully also on 64-bit Windows systems.
 * Fixed bug (found by Andy Mueller): added GMP library invocations to swig Makefile
 * Fixed bug (found by Yan): replaced GNU extension __PRETTY_FUNCTION__ by __FUNCTION (Visual Studio) or __func__ (other compilers)
 * Fixed bug (found by cax): when building MatLab MEX files, GMP libraries were not linked
@@ -7,7 +13,7 @@ git master
 * Fixed bug in findMaximum (it only considered a single connected component of the factor graph)
 * [Benjamin Piwowarski] Renamed "foreach" macro into "bforeach" to avoid conflicts with newer Boost library versions
 * Optimized ClusterGraph( const FactorGraph&, bool) constructor
-* Fixed "typename" bug in src/alldai.cpp which resulted in FTBFS for older g++ compilers
+* Fixed "typename" bug in src/alldai.cpp which resulted in FTBFS with older g++ compilers
 * Fixed memory leak in alldai.cpp and removed the function builtinInfAlgs()
 * Fixed memory leak in CBP::run()
 * Fixed typo in Priya's name
diff --git a/README b/README
index 817a953..09f5263 100644 (file)
--- a/README
+++ b/README
@@ -2,8 +2,8 @@ libDAI  -  A free/open source C++ library for Discrete Approximate Inference
 
 -------------------------------------------------------------------------------
 
-Version:  0.3.0
-Date:     July 12, 2011
+Version:  git HEAD
+Date:     July 12, 2011 - or later
 See also: http://www.libdai.org
 
 -------------------------------------------------------------------------------
@@ -163,7 +163,8 @@ You need:
   * GNU make
   * recent boost C++ libraries (at least version 1.37; however, version 1.37
     shipped with Ubuntu 9.04 is known not to work)
-  * GMP library (or the Windows port called MPIR)
+  * GMP library (or the Windows port called MPIR, for 64 bits builds MPIR 2.5.0
+    or higher is needed)
   * doxygen (only for building the documentation)
   * graphviz (only for using some of the libDAI command line utilities)
   * CImg library (only for building the image segmentation example)
@@ -192,7 +193,7 @@ Building boost under Cygwin
   * Download the latest boost libraries from http://www.boost.org
   * Build the required boost libraries using:
 
-        ./bootstrap.sh --with-libraries=program_options,math,graph,test --prefix=/boost_root/
+        ./bootstrap.sh –with-libraries=program_options,math,graph,test –prefix=/boost_root/
         ./bjam
 
   * In order to use dynamic linking, the boost .dll's should be somewhere in
@@ -221,7 +222,7 @@ If the build is successful, you can test the example program:
 
 or the more extensive test program:
 
-  tests/testdai --aliases tests/aliases.conf --filename tests/alarm.fg --methods JTREE_HUGIN BP_SEQMAX
+  tests/testdai –aliases tests/aliases.conf –filename tests/alarm.fg –methods JTREE_HUGIN BP_SEQMAX
 
 -------------------------------------------------------------------------------
 
@@ -233,7 +234,7 @@ You need:
 
   * A recent version of MicroSoft Visual Studio (2008 is known to work)
   * recent boost C++ libraries (version 1.37 or higher)
-  * GMP or MPIR library
+  * GMP or MPIR library (for 64-bits builds, MPIR 2.5.0 or higher is needed)
   * GNU make (can be obtained from http://gnuwin32.sourceforge.net)
   * CImg library (only for building the image segmentation example)
 
@@ -260,13 +261,13 @@ Because building boost under Windows is tricky, I provide some guidance here.
   * The following command builds the boost libraries that are relevant for
     libDAI:
 
-        bjam --with-graph --with-math --with-program_options --with-test link=static runtime-link=shared
+        bjam –with-graph –with-math –with-program_options –with-test link=static runtime-link=shared
 
 Building GMP or MPIR under Windows
 
 Information about how to build GPR or MPIR under Windows can be found on the
 internet. The user has to update Makefile.WINDOWS in order to link with the GPR
-/MPIR libraries.
+/MPIR libraries. Note that for 64-bit builds, MPIR 2.5.0 or higher is needed.
 
 Building libDAI
 
@@ -284,7 +285,7 @@ If the build is successful, you can test the example program:
 
 or the more extensive test program:
 
-  tests\testdai --aliases tests\aliases.conf --filename tests\alarm.fg --methods JTREE_HUGIN BP_SEQMAX
+  tests\testdai –aliases tests\aliases.conf –filename tests\alarm.fg –methods JTREE_HUGIN BP_SEQMAX
 
 -------------------------------------------------------------------------------
 
index 594fae0..75ab339 100644 (file)
@@ -241,7 +241,7 @@ namespace dai {
                     result.insert( Di );
                     if( maxStates ) {
                         totalStates += Di.nrStates();
-                        if( totalStates > maxStates )
+                        if( totalStates > (BigInt)maxStates )
                             DAI_THROW(OUT_OF_MEMORY);
                     }
                     varindices.erase( i );
index f1a3d89..93af3ef 100644 (file)
  *    - GNU make
  *    - recent boost C++ libraries (at least version 1.37; however,
  *      version 1.37 shipped with Ubuntu 9.04 is known not to work)
- *    - GMP library (or the Windows port called MPIR)
+ *    - GMP library (or the Windows port called MPIR, for 64 bits builds MPIR 2.5.0 or higher is needed)
  *    - doxygen (only for building the documentation)
  *    - graphviz (only for using some of the libDAI command line utilities)
  *    - CImg library (only for building the image segmentation example)
  *  You need:
  *  - A recent version of MicroSoft Visual Studio (2008 is known to work)
  *  - recent boost C++ libraries (version 1.37 or higher)
- *  - GMP or MPIR library
+ *  - GMP or MPIR library (for 64-bits builds, MPIR 2.5.0 or higher is needed)
  *  - GNU make (can be obtained from http://gnuwin32.sourceforge.net)
  *  - CImg library (only for building the image segmentation example)
  *
  *  
  *  Information about how to build GPR or MPIR under Windows can be found on the internet.
  *  The user has to update Makefile.WINDOWS in order to link with the GPR/MPIR libraries.
+ *  Note that for 64-bit builds, MPIR 2.5.0 or higher is needed.
  *
  *  \subsection build-windows-libdai Building libDAI
  *
index fbe3ef4..7cf5025 100644 (file)
@@ -54,7 +54,7 @@
  *  DAI_THROWE(NOT_IMPLEMENTED,"Detailed error message");
  *  \endcode
  */
-#define DAI_THROWE(cod,msg) throw dai::Exception(dai::Exception::cod, __FILE__, __PRETTY_FUNCTION__, DAI_TOSTRING(__LINE__), msg)
+#define DAI_THROWE(cod,msg) throw dai::Exception(dai::Exception::cod, __FILE__, FUNCTION_NAME, DAI_TOSTRING(__LINE__), msg)
 
 /// Assertion mechanism, similar to the standard assert() macro. It is always active, even if NDEBUG is defined
 #define DAI_ASSERT(condition) ((condition) ? ((void)0) : DAI_THROWE(ASSERTION_FAILED, std::string("Assertion \"" #condition "\" failed")))
index f4d713e..b157586 100644 (file)
@@ -85,7 +85,7 @@ class TFactor {
          */
         template<typename S>
         TFactor( const VarSet& vars, const std::vector<S> &x ) : _vs(vars), _p() {
-            DAI_ASSERT( x.size() == vars.nrStates() );
+            DAI_ASSERT( (BigInt)x.size() == vars.nrStates() );
             _p = TProb<T>( x.begin(), x.end(), x.size() );
         }
 
@@ -100,7 +100,7 @@ class TFactor {
 
         /// Constructs factor depending on variables in \a vars, copying the values from \a p
         TFactor( const VarSet& vars, const TProb<T> &p ) : _vs(vars), _p(p) {
-            DAI_ASSERT( _vs.nrStates() == _p.size() );
+            DAI_ASSERT( _vs.nrStates() == (BigInt)_p.size() );
         }
 
         /// Constructs factor depending on variables in \a vars, permuting the values given in \a p accordingly
index 911a03d..2d59be1 100644 (file)
@@ -371,8 +371,8 @@ class State {
                     states[*v] = 0;
             else {
                 for( VarSet::const_iterator v = vs.begin(); v != vs.end(); v++ ) {
-                    states[*v] = BigInt_size_t( linearState % v->states() );
-                    linearState /= v->states();
+                    states[*v] = BigInt_size_t( linearState % (BigInt)v->states() );
+                    linearState /= (BigInt)v->states();
                 }
                 DAI_ASSERT( linearState == 0 );
             }
@@ -431,8 +431,8 @@ class State {
             for( VarSet::const_iterator v = vs.begin(); v != vs.end(); v++ ) {
                 states_type::const_iterator entry = states.find( *v );
                 if( entry != states.end() )
-                    vs_state += entry->second * prod;
-                prod *= v->states();
+                    vs_state += (BigInt)entry->second * prod;
+                prod *= (BigInt)v->states();
             }
             return vs_state;
         }
index 18a9eb8..dadfead 100644 (file)
 #include <boost/lexical_cast.hpp>
 #include <algorithm>
 #include <cerrno>
+
+#if defined(WINDOWS)
+#include <cstdint> // only defined in C++11 and higher, but needed for Win64 builds in order to enable conditional code in MPIR library
+#endif
 #include <gmpxx.h>
 
 #include <dai/exceptions.h>
@@ -71,6 +75,9 @@
 
     /// Define INFINITY
     #define INFINITY (std::numeric_limits<Real>::infinity())
+
+    /// Define NAN
+    #define NAN (std::numeric_limits<Real>::quiet_NaN())
 #endif
 
 
@@ -85,7 +92,7 @@ typedef mpz_class BigInt;
 
 /// Safe down-cast of big integer to size_t
 inline size_t BigInt_size_t( const BigInt &N ) {
-    DAI_ASSERT( N <= std::numeric_limits<std::size_t>::max() );
+    DAI_ASSERT( N <= (BigInt)std::numeric_limits<std::size_t>::max() );
     return N.get_ui();
 }
 
index d1a76ae..d32b1e4 100644 (file)
@@ -130,7 +130,7 @@ class VarSet : public SmallSet<Var> {
         BigInt nrStates() const {
             BigInt states = 1;
             for( VarSet::const_iterator n = begin(); n != end(); n++ )
-                states *= n->states();
+                states *= (BigInt)n->states();
             return states;
         }
     //@}
index 3b99236..e8958c2 100644 (file)
@@ -93,7 +93,7 @@ void SharedParameters::setPermsAndVarSetsFromVarOrders() {
         VarSet vs;
         _perms[foi->first] = calculatePermutation( foi->second, vs );
         _varsets[foi->first] = vs;
-        DAI_ASSERT( _estimation->probSize() == vs.nrStates() );
+        DAI_ASSERT( (BigInt)_estimation->probSize() == vs.nrStates() );
     }
 }
 
index 6421049..c419de3 100644 (file)
@@ -62,7 +62,7 @@ Factor createFactorDelta( const Var &v, size_t state ) {
 
 Factor createFactorDelta( const VarSet& vs, size_t state ) {
     Factor fac( vs, 0.0 );
-    DAI_ASSERT( state < vs.nrStates() );
+    DAI_ASSERT( (BigInt)state < vs.nrStates() );
     fac.set( state, 1.0 );
     return fac;
 }
index 18a0982..9a38e7a 100644 (file)
@@ -99,7 +99,7 @@ JTree::JTree( const FactorGraph &fg, const PropertySet &opts, bool automatic ) :
         BigInt memneeded = 0;
         bforeach( const VarSet& cl, ElimVec )
             memneeded += cl.nrStates();
-        memneeded *= sizeof(Real) * fudge;
+        memneeded *= (BigInt)sizeof(Real) * (BigInt)fudge;
         if( props.verbose >= 1 ) {
             cerr << "Estimate of needed memory: " << memneeded / 1024 << "kB" << endl;
             cerr << "Maximum memory: ";
@@ -108,7 +108,7 @@ JTree::JTree( const FactorGraph &fg, const PropertySet &opts, bool automatic ) :
             else
                cerr << "unlimited" << endl;
         }
-        if( props.maxmem && memneeded > props.maxmem )
+        if( props.maxmem && memneeded > (BigInt)props.maxmem )
             DAI_THROW(OUT_OF_MEMORY);
 
         // Generate the junction tree corresponding to the elimination sequence
diff --git a/vc10/compile_debug_win32.m b/vc10/compile_debug_win32.m
new file mode 100644 (file)
index 0000000..eaa6af6
--- /dev/null
@@ -0,0 +1,39 @@
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/Win32/debug ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -LWin32\debug ...\r
+    -Lc:/mpir-2.5.1/lib/Win32/debug ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -g -largeArrayDims -D_DEBUG -c ../src/matlab/matlab.cpp\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/Win32/debug ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -LWin32\debug ...\r
+    -Lc:/mpir-2.5.1/lib/Win32/debug ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -g -largeArrayDims -D_DEBUG -DWINDOWS ../src/matlab/dai.cpp ../matlab\matlab.obj\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/Win32/debug ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -LWin32\debug ...\r
+    -Lc:/mpir-2.5.1/lib/Win32/debug ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -g -largeArrayDims -D_DEBUG -DWINDOWS ../src/matlab/dai_potstrength.cpp ../matlab\matlab.obj\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/Win32/debug ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -LWin32\debug ...\r
+    -Lc:/mpir-2.5.1/lib/Win32/debug ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -g -largeArrayDims -D_DEBUG ../src/matlab/dai_readfg.cpp ../matlab\matlab.obj\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/Win32/debug ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -LWin32\debug ...\r
+    -Lc:/mpir-2.5.1/lib/Win32/debug ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -g -largeArrayDims -D_DEBUG ../src/matlab/dai_writefg.cpp ../matlab\matlab.obj\r
diff --git a/vc10/compile_debug_x64.m b/vc10/compile_debug_x64.m
new file mode 100644 (file)
index 0000000..a309132
--- /dev/null
@@ -0,0 +1,39 @@
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/x64/debug ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -Lx64\debug ...\r
+    -Lc:/mpir-2.5.1/lib/x64/debug ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -g -largeArrayDims -D_DEBUG -c ../src/matlab/matlab.cpp\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/x64/debug ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -Lx64\debug ...\r
+    -Lc:/mpir-2.5.1/lib/x64/debug ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -g -largeArrayDims -D_DEBUG -DWINDOWS ../src/matlab/dai.cpp ../matlab\matlab.obj\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/x64/debug ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -Lx64\debug ...\r
+    -Lc:/mpir-2.5.1/lib/x64/debug ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -g -largeArrayDims -D_DEBUG -DWINDOWS ../src/matlab/dai_potstrength.cpp ../matlab\matlab.obj\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/x64/debug ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -Lx64\debug ...\r
+    -Lc:/mpir-2.5.1/lib/x64/debug ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -g -largeArrayDims -D_DEBUG ../src/matlab/dai_readfg.cpp ../matlab\matlab.obj\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/x64/debug ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -Lx64\debug ...\r
+    -Lc:/mpir-2.5.1/lib/x64/debug ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -g -largeArrayDims -D_DEBUG ../src/matlab/dai_writefg.cpp ../matlab\matlab.obj\r
diff --git a/vc10/compile_release_win32.m b/vc10/compile_release_win32.m
new file mode 100644 (file)
index 0000000..b63bcd3
--- /dev/null
@@ -0,0 +1,39 @@
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/Win32/Release ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -LWin32\Release ...\r
+    -Lc:/mpir-2.5.1/lib/Win32/Release ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -O -largeArrayDims -c ../src/matlab/matlab.cpp\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/Win32/Release ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -LWin32\Release ...\r
+    -Lc:/mpir-2.5.1/lib/Win32/Release ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -O -largeArrayDims -DWINDOWS ../src/matlab/dai.cpp ../matlab\matlab.obj\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/Win32/Release ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -LWin32\Release ...\r
+    -Lc:/mpir-2.5.1/lib/Win32/Release ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -O -largeArrayDims -DWINDOWS ../src/matlab/dai_potstrength.cpp ../matlab\matlab.obj\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/Win32/Release ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -LWin32\Release ...\r
+    -Lc:/mpir-2.5.1/lib/Win32/Release ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -O -largeArrayDims ../src/matlab/dai_readfg.cpp ../matlab\matlab.obj\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/Win32/Release ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -LWin32\Release ...\r
+    -Lc:/mpir-2.5.1/lib/Win32/Release ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -O -largeArrayDims ../src/matlab/dai_writefg.cpp ../matlab\matlab.obj\r
diff --git a/vc10/compile_release_x64.m b/vc10/compile_release_x64.m
new file mode 100644 (file)
index 0000000..2a679f8
--- /dev/null
@@ -0,0 +1,39 @@
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/x64/Release ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -Lx64\Release ...\r
+    -Lc:/mpir-2.5.1/lib/x64/Release ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -O -largeArrayDims -c ../src/matlab/matlab.cpp\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/x64/Release ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -Lx64\Release ...\r
+    -Lc:/mpir-2.5.1/lib/x64/Release ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -O -largeArrayDims -DWINDOWS ../src/matlab/dai.cpp ../matlab\matlab.obj\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/x64/Release ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -Lx64\Release ...\r
+    -Lc:/mpir-2.5.1/lib/x64/Release ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -O -largeArrayDims -DWINDOWS ../src/matlab/dai_potstrength.cpp ../matlab\matlab.obj\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/x64/Release ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -Lx64\Release ...\r
+    -Lc:/mpir-2.5.1/lib/x64/Release ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -O -largeArrayDims ../src/matlab/dai_readfg.cpp ../matlab\matlab.obj\r
+\r
+mex -I../include -Ic:/boost_1_50_0 -Ic:/boost_1_50_0/boost/tr1 ...\r
+    -Ic:/mpir-2.5.1/lib/x64/Release ...\r
+    -I"C:/Program Files/MATLAB/R2011b/extern/include" ...\r
+    -Lc:/boost_1_50_0/stage/lib -Lx64\Release ...\r
+    -Lc:/mpir-2.5.1/lib/x64/Release ...\r
+    -llibdai -lmpirxx -lmpir -outdir ../matlab ...\r
+    -O -largeArrayDims ../src/matlab/dai_writefg.cpp ../matlab\matlab.obj\r
diff --git a/vc10/libdai.sln b/vc10/libdai.sln
new file mode 100644 (file)
index 0000000..02425f3
--- /dev/null
@@ -0,0 +1,26 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 11.00\r
+# Visual Studio 2010\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libdai", "libdai.vcxproj", "{16F46426-A6F0-4819-8D30-4C79E7FE38B2}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Debug|x64 = Debug|x64\r
+               Release|Win32 = Release|Win32\r
+               Release|x64 = Release|x64\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {16F46426-A6F0-4819-8D30-4C79E7FE38B2}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {16F46426-A6F0-4819-8D30-4C79E7FE38B2}.Debug|Win32.Build.0 = Debug|Win32\r
+               {16F46426-A6F0-4819-8D30-4C79E7FE38B2}.Debug|x64.ActiveCfg = Debug|x64\r
+               {16F46426-A6F0-4819-8D30-4C79E7FE38B2}.Debug|x64.Build.0 = Debug|x64\r
+               {16F46426-A6F0-4819-8D30-4C79E7FE38B2}.Release|Win32.ActiveCfg = Release|Win32\r
+               {16F46426-A6F0-4819-8D30-4C79E7FE38B2}.Release|Win32.Build.0 = Release|Win32\r
+               {16F46426-A6F0-4819-8D30-4C79E7FE38B2}.Release|x64.ActiveCfg = Release|x64\r
+               {16F46426-A6F0-4819-8D30-4C79E7FE38B2}.Release|x64.Build.0 = Release|x64\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/vc10/libdai.vcxproj b/vc10/libdai.vcxproj
new file mode 100644 (file)
index 0000000..799baa1
--- /dev/null
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Debug|x64">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|x64">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{16F46426-A6F0-4819-8D30-4C79E7FE38B2}</ProjectGuid>\r
+    <RootNamespace>libdai</RootNamespace>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>StaticLibrary</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
+    <ConfigurationType>StaticLibrary</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>StaticLibrary</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
+    <ConfigurationType>StaticLibrary</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <IncludePath>../include;C:\boost_1_50_0;C:\boost_1_50_0\boost\tr1;C:\mpir-2.5.1\lib\Win32\Debug;$(IncludePath)</IncludePath>\r
+    <LibraryPath>C:\mpir-2.5.1\lib\Win32\Debug;$(LibraryPath)</LibraryPath>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <IncludePath>../include;C:\boost_1_50_0;C:\boost_1_50_0\boost\tr1;C:\mpir-2.5.1\lib\x64\Debug;$(IncludePath)</IncludePath>\r
+    <LibraryPath>C:\mpir-2.5.1\lib\x64\Debug;$(LibraryPath)</LibraryPath>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <IncludePath>../include;C:\boost_1_50_0;C:\boost_1_50_0\boost\tr1;C:\mpir-2.5.1\lib\Win32\Release;$(IncludePath)</IncludePath>\r
+    <LibraryPath>C:\mpir-2.5.1\lib\Win32\Release;$(LibraryPath)</LibraryPath>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <IncludePath>../include;C:\boost_1_50_0;C:\boost_1_50_0\boost\tr1;C:\mpir-2.5.1\lib\x64\Release;$(IncludePath)</IncludePath>\r
+    <LibraryPath>C:\mpir-2.5.1\lib\x64\Release;$(LibraryPath)</LibraryPath>\r
+  </PropertyGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;WINDOWS;DAI_WITH_DECMAP;DAI_WITH_CBP;DAI_WITH_GIBBS;DAI_WITH_MR;DAI_WITH_JTREE;DAI_WITH_TREEEP;DAI_WITH_LC;DAI_WITH_HAK;DAI_WITH_MF;DAI_WITH_TRWBP;DAI_WITH_FBP;DAI_WITH_BP;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;WINDOWS;DAI_WITH_DECMAP;DAI_WITH_CBP;DAI_WITH_GIBBS;DAI_WITH_MR;DAI_WITH_JTREE;DAI_WITH_TREEEP;DAI_WITH_LC;DAI_WITH_HAK;DAI_WITH_MF;DAI_WITH_TRWBP;DAI_WITH_FBP;DAI_WITH_BP;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;WINDOWS;DAI_WITH_DECMAP;DAI_WITH_CBP;DAI_WITH_GIBBS;DAI_WITH_MR;DAI_WITH_JTREE;DAI_WITH_TREEEP;DAI_WITH_LC;DAI_WITH_HAK;DAI_WITH_MF;DAI_WITH_TRWBP;DAI_WITH_FBP;DAI_WITH_BP;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;WINDOWS;DAI_WITH_DECMAP;DAI_WITH_CBP;DAI_WITH_GIBBS;DAI_WITH_MR;DAI_WITH_JTREE;DAI_WITH_TREEEP;DAI_WITH_LC;DAI_WITH_HAK;DAI_WITH_MF;DAI_WITH_TRWBP;DAI_WITH_FBP;DAI_WITH_BP;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+    </ClCompile>\r
+    <Link>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="..\include\dai\alldai.h" />\r
+    <ClInclude Include="..\include\dai\bbp.h" />\r
+    <ClInclude Include="..\include\dai\bipgraph.h" />\r
+    <ClInclude Include="..\include\dai\bp.h" />\r
+    <ClInclude Include="..\include\dai\bp_dual.h" />\r
+    <ClInclude Include="..\include\dai\cbp.h" />\r
+    <ClInclude Include="..\include\dai\clustergraph.h" />\r
+    <ClInclude Include="..\include\dai\dag.h" />\r
+    <ClInclude Include="..\include\dai\daialg.h" />\r
+    <ClInclude Include="..\include\dai\decmap.h" />\r
+    <ClInclude Include="..\include\dai\doc.h" />\r
+    <ClInclude Include="..\include\dai\emalg.h" />\r
+    <ClInclude Include="..\include\dai\enum.h" />\r
+    <ClInclude Include="..\include\dai\evidence.h" />\r
+    <ClInclude Include="..\include\dai\exactinf.h" />\r
+    <ClInclude Include="..\include\dai\exceptions.h" />\r
+    <ClInclude Include="..\include\dai\factor.h" />\r
+    <ClInclude Include="..\include\dai\factorgraph.h" />\r
+    <ClInclude Include="..\include\dai\fbp.h" />\r
+    <ClInclude Include="..\include\dai\gibbs.h" />\r
+    <ClInclude Include="..\include\dai\graph.h" />\r
+    <ClInclude Include="..\include\dai\hak.h" />\r
+    <ClInclude Include="..\include\dai\index.h" />\r
+    <ClInclude Include="..\include\dai\io.h" />\r
+    <ClInclude Include="..\include\dai\jtree.h" />\r
+    <ClInclude Include="..\include\dai\lc.h" />\r
+    <ClInclude Include="..\include\dai\mf.h" />\r
+    <ClInclude Include="..\include\dai\mr.h" />\r
+    <ClInclude Include="..\include\dai\prob.h" />\r
+    <ClInclude Include="..\include\dai\properties.h" />\r
+    <ClInclude Include="..\include\dai\regiongraph.h" />\r
+    <ClInclude Include="..\include\dai\smallset.h" />\r
+    <ClInclude Include="..\include\dai\treeep.h" />\r
+    <ClInclude Include="..\include\dai\trwbp.h" />\r
+    <ClInclude Include="..\include\dai\util.h" />\r
+    <ClInclude Include="..\include\dai\var.h" />\r
+    <ClInclude Include="..\include\dai\varset.h" />\r
+    <ClInclude Include="..\include\dai\weightedgraph.h" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\src\alldai.cpp" />\r
+    <ClCompile Include="..\src\bbp.cpp" />\r
+    <ClCompile Include="..\src\bipgraph.cpp" />\r
+    <ClCompile Include="..\src\bp.cpp" />\r
+    <ClCompile Include="..\src\bp_dual.cpp" />\r
+    <ClCompile Include="..\src\cbp.cpp" />\r
+    <ClCompile Include="..\src\clustergraph.cpp" />\r
+    <ClCompile Include="..\src\dag.cpp" />\r
+    <ClCompile Include="..\src\daialg.cpp" />\r
+    <ClCompile Include="..\src\decmap.cpp" />\r
+    <ClCompile Include="..\src\emalg.cpp" />\r
+    <ClCompile Include="..\src\evidence.cpp" />\r
+    <ClCompile Include="..\src\exactinf.cpp" />\r
+    <ClCompile Include="..\src\exceptions.cpp" />\r
+    <ClCompile Include="..\src\factor.cpp" />\r
+    <ClCompile Include="..\src\factorgraph.cpp" />\r
+    <ClCompile Include="..\src\fbp.cpp" />\r
+    <ClCompile Include="..\src\gibbs.cpp" />\r
+    <ClCompile Include="..\src\graph.cpp" />\r
+    <ClCompile Include="..\src\hak.cpp" />\r
+    <ClCompile Include="..\src\io.cpp" />\r
+    <ClCompile Include="..\src\jtree.cpp" />\r
+    <ClCompile Include="..\src\lc.cpp" />\r
+    <ClCompile Include="..\src\mf.cpp" />\r
+    <ClCompile Include="..\src\mr.cpp" />\r
+    <ClCompile Include="..\src\properties.cpp" />\r
+    <ClCompile Include="..\src\regiongraph.cpp" />\r
+    <ClCompile Include="..\src\treeep.cpp" />\r
+    <ClCompile Include="..\src\trwbp.cpp" />\r
+    <ClCompile Include="..\src\util.cpp" />\r
+    <ClCompile Include="..\src\varset.cpp" />\r
+    <ClCompile Include="..\src\weightedgraph.cpp" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>
\ No newline at end of file
diff --git a/vc10/test_run.m b/vc10/test_run.m
new file mode 100644 (file)
index 0000000..e08f7aa
--- /dev/null
@@ -0,0 +1,2 @@
+fg = dai_readfg('../tests/alarm.fg');\r
+[logz, q, md, qv, qf, qmap] = dai(fg, 'BP', '[inference=SUMPROD,updates=SEQMAX,tol=1e-6,maxiter=100,logdomain=0]');\r