-
Notifications
You must be signed in to change notification settings - Fork 84
/
notes_on_using_libermate.txt
121 lines (81 loc) · 2.96 KB
/
notes_on_using_libermate.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
Install clips from source
==============
try
chkinputdatatype(x,p);
catch ME
throwAsCaller(ME);
end
Not parseable, gives:
File "/home/sam/workspace/libermate-0.4/translate_new.py", line 190, in do_try
b=self.write_node(node.children[1], "")
IndexError: list index out of range
Solution: Comment it out, throwAsCaller is what fails here.
Later on change the function behaviour to throw a python error as desired.
==============
if any( w(:)<0 ) && realFlag
Not parseable, gives:
File "./libermate.py", line 236, in bop
if(python_priority[ptoken]>python_priority[op]):
KeyError: 'np.any((w.flatten(1)<0.))'
Solution: Comment it out, && realFlag fails here because in MATLAB is bool
and in the translation becomes a float (1.0) which can't be '&&'-ed.
Later on correct that flag to a bool value by hand.
==============
if any( (w>pi) | (w<0) ) && realFlag
Not parseable, gives:
File "./libermate.py", line 236, in bop
if(python_priority[ptoken]>python_priority[op]):
KeyError: 'np.any(np.logical_or(w > np.pi, w<0.))'
Solution: Comment it out, && realFlag fails because the evaluation of
realFlag as it's parsed as a float in python and it's originally intended
to be a boolean. Later correct by hand this value to a boolean.
=============
a = [1; -H2\h1].';
Not parseable, gives:
File "./libermate.py", line 251, in preop
if(python_priority[ptoken]>python_priority[op]):
KeyError: ', '
Solution: Make H2 negative before, i.e.:
H2_minus = -H2
a = [1; H2_minus\h1].';
Then it will work.
=============
c = T(:,2:p+q+2)\(T_minus(:,1));
Not parseable, gives:
File "/home/sam/workspace/libermate-0.4/translate_new.py", line 265, in do_BACKDIV
b=self.write_node(node.children[1], ", ")
IndexError: list index out of range
Solution: This is too complicated for the parser, try to divide it in parts, i.e.:
T_minus = -T;
T_left = T(:,2:p+q+2);
T_right = (T_minus(:,1));
c = T_left \ T_right;
============
File "/home/sam/workspace/libermate-0.4/translate_new.py", line 271, in do_COLON
sstr=self.colonop(ptoken, cc)
File "./libermate.py", line 269, in colonop
a=cc[0]
IndexError: list index out of range
==========
After work:
1) Correct identations of ifs
2) Correct the matcompat.max found in the code, you can safely change them to just max
3) Correct other import issues:
linalg.solve -> from scipy.linalg import solve
toeplitz not found
from scipy.linalg import toeplitz
etc... I google them to know where they are in scipy
4) matdiv not found
change it to a division "/"
5) some np.zeros(1,K) should be np.zeros(K)
6) length -> len can be safely changed usually
7) Indices are floats sometimes, change them to ints (remove the "." from "1.")
8) Indices are wrong lots of times
Info about libermate
https://groups.google.com/forum/#!topic/scipy-user/6tx6ORxOr_I
Official website:
http://libermate.sourceforge.net/
Useful info:
http://wiki.scipy.org/NumPy_for_Matlab_Users
Alternatives:
https://github.com/ocefpaf/python-mlabwrap