-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.html
302 lines (294 loc) · 12.8 KB
/
index.html
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<html>
<head>
<meta name="description" content="Convenient online tool automatically translates MATLAB source code into Julia, so you can move on to the more interesting task of parallelizing your code." />
<meta name="keywords" content="matlab,julia,convert,translate,translator,online,translate matlab to julia,convert matlab to julia,translate matlab julia,convert matlab julia,matlab to julia,matlab julia,julia matlab,try julia" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-30110053-1', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
<script>
/**
* Function that tracks a click on an outbound link in Analytics.
* This function takes a valid URL string as an argument, and uses that URL string
* as the event label. Setting the transport method to 'beacon' lets the hit be sent
* using 'navigator.sendBeacon' in browser that support it.
*/
var trackOutboundLink = function(url) {
ga('send', 'event', 'outbound', 'click', url, {
'transport': 'beacon',
'hitCallback': function(){document.location = url;}
});
}
var trackTranslatorEvent = function(label) {
ga('send', 'event', 'translator', 'click', label);
}
var trackSocialEvent = function(label) {
ga('send', 'event', 'social', 'click', label);
}
var trackOtherEvent = function(label) {
ga('send', 'event', 'other', 'click', label);
}
</script>
<link rel="icon" href="../me/mooncow.jpg">
<style type="text/css"></style>
</head>
<body><a name="top"> </a>
<title>
MATLAB to Julia translator | MATLAB to Julia converter
</title>
<style type="text/css">
.link{color:#006633; text-decoration:underline;}
.link:hover{text-decoration:none;}
.deadlink{color:#999999; text-decoration:none;}
.spooky{color:#BBBBBB; text-decoration:none;}
ul{list-style:none;margin-left:0;padding-left:0;}
li{padding-left:1.5em;text-indent:0em;}
li:before{content:"";padding-right:0px;}
indent{display:inline-block;margin-left:2.5em;}
</style>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.9";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<br>
<table border="0">
<tr>
<td width="200"></td>
<td width="355"></td>
<td width="20"></td>
<td width="125"></td>
<td width="250"></td>
<td width="100"></td>
</tr>
<tr>
<td></td>
<td colspan="5">
<p>
</p>
<span style="line-height:1em">
<h1 style="font-family:Tahoma; color:#999999; font-size:150%; letter-spacing:4px">
matlab-to-julia
</h1>
<h1 style="font-family:Tahoma; color:#999999; font-size:100%; letter-spacing:2px">
Translates MATLAB source code into Julia.
</h1>
</span>
</td>
</tr>
<tr>
<td></td>
<td colspan="3" width="500">
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<p>
<br>
Some of the fields that could most benefit from parallelization primarily
use programming languages that were not designed with parallel computing
in mind. This MATLAB-to-Julia translator begins to approach the problem
starting with MATLAB, which is syntactically close to Julia. The translator
aims to do much of the tedious work of converting source code from MATLAB
to Julia, in hopes that a MATLAB user who is curious about Julia could
then spend most of their first moments with the language exploring its
capacity to improve their existing programs rather than wrangling with
bugs or a new syntax.
</p>
<p>
This translator is not comprehensive, but it should accurately translate
enough of the most common statements that most of the tedious work of
translating the code by hand is eliminated. The hope is that you can
then review the translated Julia code and perhaps make minor corrections
(<a href="https://docs.julialang.org/en/latest/manual/noteworthy-differences/#Noteworthy-differences-from-MATLAB-1" class="link" onclick="trackOutboundLink('https://docs.julialang.org/en/latest/manual/noteworthy-differences/#Noteworthy-differences-from-MATLAB-1'); return false;">list of differences between MATLAB and Julia</a>,
<a href="https://cheatsheets.quantecon.org/" class="link" onclick="trackOutboundLink('https://cheatsheets.quantecon.org/'); return false;">cheatsheet</a>),
but be able to quickly move on to the more interesting task of parallelizing
your code.
</p>
<p>
<a class="link" onclick="insertDemoCode(); trackTranslatorEvent('inserted demo code');">Click here</a>
for a demo translation.
<a class="link" href="https://github.com/lakras/matlab-to-julia/blob/master/matlab_to_julia_translator.js" onclick="trackOutboundLink('https://github.com/lakras/matlab-to-julia/blob/master/matlab_to_julia_translator.js'); return false;">Click here</a>
to view the source code.
</p>
<p>
Happy coding!
</p>
<p>
</p>
</span>
</td>
</tr>
<tr>
<td width="200"></td>
<td colspan="2" width="375">
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<p>
MATLAB
</p>
</span>
</td>
<td colspan="2" width="375">
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<p>
Julia
</p>
</span>
</td>
</tr>
<tr>
<td width="200"></td>
<td colspan="2" width="375">
<script type="text/javascript" src="matlab_to_julia_translator.js"></script>
<script type="text/javascript" src="web_page_functions.js"></script>
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<p>
<textarea rows="35" style="width: 100%; resize: none;" id="inputField" type="text" onfocus="clearInputField();enableTranslateButton();" onclick="trackTranslatorEvent('clicked MATLAB field');">Enter MATLAB code here.</textarea>
</p>
</span>
</td>
<td colspan="2" width="375">
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<p>
<textarea rows="35" style="width: 100%; resize: none;" id="outputField" width="375" type="text" disabled="true" onclick="trackTranslatorEvent('clicked Julia field');">Translated code will appear here.</textarea>
</p>
</span>
</td>
</tr>
<tr>
<td width="200"></td>
<td colspan="4" width="750">
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<p align="center">
<button id="translateButton" onclick="runTranslator(); trackTranslatorEvent('translated');">translate!</button>
</p>
<p align="center">
<button id="copyToClipboardButton" onclick="copyToClipboard(); trackTranslatorEvent('copied to clipboard');">copy to clipboard</button>
</p>
</span>
</td>
</tr>
<tr>
<td colspan="5">
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<p>
</p>
</span>
</td>
</tr>
<tr>
<td width="200"></td>
<td width="355" valign="top">
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<p>
You can <a href="https://github.com/lakras/matlab-to-julia/issues/" class="link" onclick="trackOutboundLink('https://github.com/lakras/matlab-to-julia/issues/'); return false;">file an issue on GitHub</a>
to report translation bugs or to suggest features or translations you would like to see added.
If you prefer, you can also
<a href="https://docs.google.com/forms/d/e/1FAIpQLScvH5sN-TLk69V5hipx9Afk54Srn8muBrhJuoV59KkLEeza-Q/viewform?usp=sf_link" class="link" onclick="trackOutboundLink('https://docs.google.com/forms/d/e/1FAIpQLScvH5sN-TLk69V5hipx9Afk54Srn8muBrhJuoV59KkLEeza-Q/viewform?usp=sf_link'); return false;">fill out this Google form</a>.
</p>
<p>
If this translator was helpful, please spread the word and consider <a href="https://github.com/lakras/matlab-to-julia/" class="link" onclick="trackOutboundLink('https://github.com/lakras/matlab-to-julia/'); return false;">contributing to the codebase</a>.
</p>
<p>
<a href="https://twitter.com/share" class="twitter-share-button" onclick="trackSocialEvent('twitter-share-button');" data-text="Translate #MATLAB source code into #Julia." data-url="https://lakras.github.io/matlab-to-julia/" data-via="lakrasil" data-related="lakrasil" data-show-count="false">Tweet</a><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</p>
<p>
<div align="center" class="fb-like" onclick="trackSocialEvent('fb-like');" data-href="https://lakras.github.io/matlab-to-julia/" data-layout="button" data-action="recommend" data-size="small" data-show-faces="false" data-share="true"></div>
</p>
<p>
<script type="text/javascript" src="//www.redditstatic.com/button/button1.js"></script>
</p>
<p>
<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script><script type="IN/Share" data-url="https://lakras.github.io/matlab-to-julia/"></script>
</p>
<p>
</p>
<p>
<a href="https://github.com/lakras/matlab-to-julia" class="link" onclick="trackOutboundLink('https://github.com/lakras/matlab-to-julia'); return false;"><img src="http://sciencecow.mit.edu/me/tippedcow.jpg" width="200"></a>
</p>
<p>
</p>
<p></p>
</span>
</td>
<td width="20"></td>
<td colspan="3" width="375" valign="top">
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<p>
<ul>
<a id="advancedOptionsLabel" onclick="hideOrExposeOptions();trackTranslatorEvent('hid or exposed advanced options');">▼ <u>Advanced options:</u></a>
<li>
<label id="optionsLabel1">correct/guide translation of function calls</label>
<table border = "0">
<tr>
<td>
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<ul>
<li>
<label id="optionsLabel2">interpret as functions:</label>
</li>
<li>
<label id="optionsLabel3">do not interpret as functions:</label>
</li>
</ul>
</span>
</td>
<td width="2"></td>
<td>
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<input type="text" size="35" id="functionNamesField" onclick="clearFunctionNamesField();clearNotFunctionNamesField();trackTranslatorEvent('clicked function names field');" value="functionName1, functionName2, etc.">
<br><input type="text" size="35" id="notFunctionNamesField" onclick="clearFunctionNamesField();clearNotFunctionNamesField();trackTranslatorEvent('clicked not function names field');" value="matrixName, variableName, etc.">
</span>
</td>
</tr>
</table>
</li>
<li>
<table border = "0">
<tr>
<td>
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<label id="optionsLabel4">translate anonymous MATLAB functions</label>
<ul>
<li>
<label id="optionsLabel5"><input type="radio" id="anonymousOneLinersButton" name="anonymousFunctionsRadioButton" onclick="trackTranslatorEvent('clicked for anonymous Julia functions');" value="value" checked> to anonymous Julia functions</label>
</li>
<li>
<label id="optionsLabel6"><input type="radio" id="nonanonymousOneLinersButton" name="anonymousFunctionsRadioButton" onclick="trackTranslatorEvent('clicked for one-line Julia functions');" value="value"> to compact (one-line) Julia functions</label>
</li>
</ul>
</span>
</td>
<td width="10"></td>
<td>
<span style="font-family:verdana; font-size:75%; line-height:1.5em">
<label id="optionsLabel7"><span class="spooky">h = @(x, y) x*y</span></label>
<br><label id="optionsLabel8" for="anonymousOneLinersButton"><span class="spooky">h = (x, y) -> x*y</span></label>
<br><label id="optionsLabel9" for="nonanonymousOneLinersButton"><span class="spooky">h(x, y) = x*y</span></label>
</span>
</td>
</tr>
</table>
</li>
<li>
<label id="optionsLabel10"><input type="checkbox" id="removeSemicolonsCheckbox" onclick="trackTranslatorEvent('clicked remove semicolons checkbox');" value="value" checked> remove semicolons at ends of lines</label>
</li>
</ul>
</p>
</span>
</td>
</tr>
</table>
</body></html>