samer@0
|
1 *** Prolog Matlab interface
|
samer@0
|
2 ***
|
samer@0
|
3 *** Authors:
|
samer@0
|
4 *** Samer Abdallah
|
samer@0
|
5 *** Centre for Digital Music,
|
samer@0
|
6 *** Queen Mary, University of London
|
samer@0
|
7 ***
|
samer@0
|
8 *** Christophe Rhodes
|
samer@0
|
9 *** Centre for Computational Creativity
|
samer@0
|
10 *** Goldsmiths College, University of London
|
samer@0
|
11 ***
|
samer@19
|
12 *** 2004--2012
|
samer@0
|
13
|
samer@0
|
14
|
samer@0
|
15 -------------------------------------------------------------------------
|
samer@0
|
16 BUILDING/INSTALLATION
|
samer@0
|
17
|
samer@0
|
18
|
samer@0
|
19 Before you start, you need a working SWI Prolog installation and
|
samer@8
|
20 a Matlab installation. The compilation is done using the swipl-ld utility
|
samer@0
|
21 that comes with SWI. This only has a hope of working on Unix systems,
|
samer@0
|
22 and I've only tried with Mac OS X and Linux.
|
samer@0
|
23
|
samer@9
|
24 You also need the plcore package, which contains the required Prolog
|
samer@9
|
25 libraries utils.pl, dcgu.pl and ops.pl.
|
samer@9
|
26
|
samer@0
|
27
|
samer@0
|
28 *** Binary and Prolog code ***
|
samer@0
|
29
|
samer@8
|
30 There is a template makefile in Makefile.templ
|
samer@8
|
31 Copy it to Makefile and adjust the configuration variables at
|
samer@8
|
32 the top to suit your system.
|
samer@0
|
33
|
samer@0
|
34 Then run
|
samer@0
|
35 $ make
|
samer@0
|
36 $ make install
|
samer@0
|
37
|
samer@0
|
38 This should copy the binary object and Prolog libraries to the target
|
samer@0
|
39 installation directory. SWI Prolog needs to be able to find them,
|
samer@8
|
40 eg, with INSTALL_PL_TO=~/lib/prolog and INSTALL_LIB_TO=~/lib/prolog/x86_64
|
samer@8
|
41 I put
|
samer@0
|
42
|
samer@8
|
43 file_search_path(foreign,'/Users/samer/lib/prolog/x86_64').
|
samer@0
|
44
|
samer@0
|
45 into my ~/.plrc
|
samer@0
|
46 Since ~/lib/prolog is automatically in the file_search_path(library,_),
|
samer@0
|
47 nothing else needs to be done. If you install the libraries somewhere
|
samer@0
|
48 else, you will need to add a file_search_path(library,PathToLibraries)
|
samer@0
|
49 clause.
|
samer@0
|
50
|
samer@0
|
51
|
samer@0
|
52
|
samer@0
|
53 ** Matlab code **
|
samer@0
|
54
|
samer@0
|
55 The subdirectories of the matlab directory need to be in your matlab
|
samer@0
|
56 path, or the contents copied to somewhere already in you Matlab search
|
samer@0
|
57 path.
|
samer@0
|
58
|
samer@0
|
59
|
samer@0
|
60
|
samer@0
|
61
|
samer@0
|
62 -------------------------------------------------------------------------
|
samer@0
|
63 SANITY CHECK
|
samer@0
|
64
|
samer@19
|
65 NB: you need to make sure the required Matlab dynamic libraries are
|
samer@19
|
66 on your dyld search path before starting SWI Prolog. The bash script
|
samer@19
|
67 swiplml shows how you can do this by setting the DYLD_FALLBACK_LIBRARY_PATH
|
samer@19
|
68 environment variable before calling swipl, but be aware that there
|
samer@19
|
69 are several environment variables that can affect dynamic library loading
|
samer@19
|
70 and that they can have weird effects on your system if you have conflicting
|
samer@19
|
71 libraries is different places. See the dyld man page ('man dyld').
|
samer@0
|
72
|
samer@19
|
73 If the installation is ok, then the following should work (using the
|
samer@19
|
74 included swiplml script):
|
samer@19
|
75
|
samer@19
|
76 $ swiplml
|
samer@0
|
77 ?- use_module(library(plml)).
|
samer@0
|
78 ...
|
samer@0
|
79 Yes.
|
samer@0
|
80
|
samer@0
|
81 ?- ml_open(ml). % ml is the name assigned to the Matlab engine instance
|
samer@0
|
82 Matlab engine (ml) open.
|
samer@0
|
83
|
samer@0
|
84 Yes
|
samer@0
|
85
|
samer@0
|
86 ?- float(A)===2*pi.
|
samer@0
|
87 A = 6.28319
|
samer@0
|
88
|
samer@19
|
89 ?- A:float===2*pi.
|
samer@19
|
90 A = 6.28319
|
samer@0
|
91
|