-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathindex.html
400 lines (380 loc) · 33.9 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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Seamless Integration Between R and 'Julia' • JuliaCall</title>
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/cerulean/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- sticky kit --><script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script><!-- pkgdown --><link href="pkgdown.css" rel="stylesheet">
<script src="pkgdown.js"></script><meta property="og:title" content="Seamless Integration Between R and 'Julia'">
<meta property="og:description" content="Provides an R interface to 'Julia',
which is a high-level, high-performance dynamic programming language
for numerical computing, see <https://julialang.org/> for more information.
It provides a high-level interface as well as a low-level interface.
Using the high level interface, you could call any 'Julia' function just like
any R function with automatic type conversion. Using the low level interface,
you could deal with C-level SEXP directly while enjoying the convenience of
using a high-level programming language like 'Julia'.">
<meta name="twitter:card" content="summary">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-article">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">JuliaCall</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.16.6</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.html">
<span class="fa fa-home fa-lg"></span>
</a>
</li>
<li>
<a href="reference/index.html">Reference</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Articles
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="articles/JuliaCall_in_Jupyter_R_Notebook.html">JuliaCall in Jupyter R Notebook</a>
</li>
<li>
<a href="articles/Julia_in_RMarkdown.html">Julia in RMarkdown</a>
</li>
<li>
<a href="articles/mandelbrot.html">Improve R's Performance using JuliaCall with Mandelbrot Set Example</a>
</li>
</ul>
</li>
<li>
<a href="news/index.html">Changelog</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/Non-Contradiction/JuliaCall">
<span class="fa fa-github fa-lg"></span>
</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container -->
</div>
<!--/.navbar -->
</header><div class="row">
<div class="col-md-9 contents">
<!-- README.md is generated from README.Rmd. Please edit that file -->
<div id="juliacall-for-seamless-integration-of-r-and-julia" class="section level1">
<div class="page-header"><h1 class="hasAnchor">
<a href="#juliacall-for-seamless-integration-of-r-and-julia" class="anchor"></a>JuliaCall for Seamless Integration of R and Julia</h1></div>
<p><strong>[Table of Contents]</strong> <!-- Table of contents generated generated by http://tableofcontent.eu --></p>
<ul>
<li>
<a href="#juliacall-for-seamless-integration-of-r-and-julia">JuliaCall for Seamless Integration of R and Julia</a>
<ul>
<li><a href="#installation">Installation</a></li>
<li><a href="#basic-usage">Basic Usage</a></li>
<li><a href="#troubleshooting-and-ways-to-get-help">Troubleshooting and Ways to Get Help</a></li>
<li><a href="#juliacall-for-r-package-developers">JuliaCall for R Package Developers</a></li>
<li><a href="#suggestion-issue-reporting-and-contributing">Suggestion, Issue Reporting, and Contributing</a></li>
<li><a href="#other-interfaces-between-r-and-julia">Other Interfaces Between R and Julia</a></li>
</ul>
</li>
</ul>
<p>Package <code>JuliaCall</code> is an R interface to <code>Julia</code>, which is a high-level, high-performance dynamic programming language for numerical computing, see <a href="https://julialang.org/" class="uri">https://julialang.org/</a> for more information. Below is an image for <a href="https://en.wikipedia.org/wiki/Mandelbrot_set">Mandelbrot set</a>. JuliaCall brings <strong>more than 100 times speedup</strong> of the calculation! See <a href="https://github.com/Non-Contradiction/JuliaCall/tree/master/example/mandelbrot" class="uri">https://github.com/Non-Contradiction/JuliaCall/tree/master/example/mandelbrot</a> for more information.</p>
<p><img src="https://non-contradiction.github.io/JuliaCall/articles/mandelbrot.png"></p>
<div id="installation" class="section level2">
<h2 class="hasAnchor">
<a href="#installation" class="anchor"></a>Installation</h2>
<p>To use package <code>JuliaCall</code>, you first have to install <a href="https://julialang.org/"><code>Julia</code></a> on your computer. You can download a generic binary from <a href="https://julialang.org/downloads/" class="uri">https://julialang.org/downloads/</a> and add it to your path, and then you can install <code>JuliaCall</code> just like any other R packages by</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/install.packages">install.packages</a></span>(<span class="st">"JuliaCall"</span>)</a></code></pre></div>
<p>Currently <code>Julia v0.6.x</code>, <code>Julia v1.0.x</code>, and <code>Julia v1.1</code> are all supported by <code>JuliaCall</code>.</p>
<p>You can get the development version of <code>JuliaCall</code> by</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" data-line-number="1">devtools<span class="op">::</span><span class="kw"><a href="https://www.rdocumentation.org/packages/devtools/topics/reexports">install_github</a></span>(<span class="st">"Non-Contradiction/JuliaCall"</span>)</a></code></pre></div>
</div>
<div id="basic-usage" class="section level2">
<h2 class="hasAnchor">
<a href="#basic-usage" class="anchor"></a>Basic Usage</h2>
<p>Before using <code>JuliaCall</code>, you need to do initial setup by function <code><a href="reference/julia_setup.html">julia_setup()</a></code> for automatic type conversion, Julia display systems, etc. It is necessary for every new R session to use the package. If not carried out manually, it will be invoked automatically before other <code>julia_xxx</code> functions. Solutions to some common error in <code><a href="reference/julia_setup.html">julia_setup()</a></code> are documented in the <a href="#troubleshooting-and-way-to-get-help">troubleshooting section</a>.</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(JuliaCall)</a>
<a class="sourceLine" id="cb3-2" data-line-number="2">julia <-<span class="st"> </span><span class="kw"><a href="reference/julia_setup.html">julia_setup</a></span>()</a>
<a class="sourceLine" id="cb3-3" data-line-number="3"><span class="co">#> Julia version 1.0.3 at location /Applications/Julia-1.0.app/Contents/Resources/julia/bin will be used.</span></a>
<a class="sourceLine" id="cb3-4" data-line-number="4"><span class="co">#> Loading setup script for JuliaCall...</span></a>
<a class="sourceLine" id="cb3-5" data-line-number="5"><span class="co">#> Finish loading setup script for JuliaCall.</span></a>
<a class="sourceLine" id="cb3-6" data-line-number="6"></a>
<a class="sourceLine" id="cb3-7" data-line-number="7"><span class="co">## If you want to use `Julia` at a specific location, you could do the following:</span></a>
<a class="sourceLine" id="cb3-8" data-line-number="8"><span class="co">## julia_setup(JULIA_HOME = "the folder that contains Julia binary").</span></a>
<a class="sourceLine" id="cb3-9" data-line-number="9"><span class="co">## You can also set JULIA_HOME in command line environment or use `options(...)`.</span></a>
<a class="sourceLine" id="cb3-10" data-line-number="10"></a>
<a class="sourceLine" id="cb3-11" data-line-number="11"><span class="co">## Different ways of using Julia to calculate sqrt(2)</span></a>
<a class="sourceLine" id="cb3-12" data-line-number="12"></a>
<a class="sourceLine" id="cb3-13" data-line-number="13"><span class="co"># julia$command("a = sqrt(2);"); julia$eval("a")</span></a>
<a class="sourceLine" id="cb3-14" data-line-number="14"><span class="kw"><a href="reference/julia_command.html">julia_command</a></span>(<span class="st">"a = sqrt(2);"</span>); <span class="kw"><a href="reference/julia_eval.html">julia_eval</a></span>(<span class="st">"a"</span>)</a>
<a class="sourceLine" id="cb3-15" data-line-number="15"><span class="co">#> [1] 1.414214</span></a>
<a class="sourceLine" id="cb3-16" data-line-number="16"><span class="kw"><a href="reference/julia_eval.html">julia_eval</a></span>(<span class="st">"sqrt(2)"</span>)</a>
<a class="sourceLine" id="cb3-17" data-line-number="17"><span class="co">#> [1] 1.414214</span></a>
<a class="sourceLine" id="cb3-18" data-line-number="18"><span class="kw"><a href="reference/call.html">julia_call</a></span>(<span class="st">"sqrt"</span>, <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb3-19" data-line-number="19"><span class="co">#> [1] 1.414214</span></a>
<a class="sourceLine" id="cb3-20" data-line-number="20"><span class="kw"><a href="reference/julia_eval.html">julia_eval</a></span>(<span class="st">"sqrt"</span>)(<span class="dv">2</span>)</a>
<a class="sourceLine" id="cb3-21" data-line-number="21"><span class="co">#> [1] 1.414214</span></a>
<a class="sourceLine" id="cb3-22" data-line-number="22"><span class="kw"><a href="reference/julia_assign.html">julia_assign</a></span>(<span class="st">"x"</span>, <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/MathFun">sqrt</a></span>(<span class="dv">2</span>)); <span class="kw"><a href="reference/julia_eval.html">julia_eval</a></span>(<span class="st">"x"</span>)</a>
<a class="sourceLine" id="cb3-23" data-line-number="23"><span class="co">#> [1] 1.414214</span></a>
<a class="sourceLine" id="cb3-24" data-line-number="24"><span class="kw"><a href="reference/julia_assign.html">julia_assign</a></span>(<span class="st">"rsqrt"</span>, sqrt); <span class="kw"><a href="reference/call.html">julia_call</a></span>(<span class="st">"rsqrt"</span>, <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb3-25" data-line-number="25"><span class="co">#> [1] 1.414214</span></a>
<a class="sourceLine" id="cb3-26" data-line-number="26"><span class="dv">2</span> <span class="op">%>J%</span><span class="st"> </span>sqrt</a>
<a class="sourceLine" id="cb3-27" data-line-number="27"><span class="co">#> [1] 1.414214</span></a>
<a class="sourceLine" id="cb3-28" data-line-number="28"></a>
<a class="sourceLine" id="cb3-29" data-line-number="29"><span class="co">## You can use `julia$exists` as `exists` in R to test</span></a>
<a class="sourceLine" id="cb3-30" data-line-number="30"><span class="co">## whether a function or name exists in Julia or not</span></a>
<a class="sourceLine" id="cb3-31" data-line-number="31"></a>
<a class="sourceLine" id="cb3-32" data-line-number="32"><span class="kw"><a href="reference/julia_exists.html">julia_exists</a></span>(<span class="st">"sqrt"</span>)</a>
<a class="sourceLine" id="cb3-33" data-line-number="33"><span class="co">#> [1] TRUE</span></a>
<a class="sourceLine" id="cb3-34" data-line-number="34"><span class="kw"><a href="reference/julia_exists.html">julia_exists</a></span>(<span class="st">"c"</span>)</a>
<a class="sourceLine" id="cb3-35" data-line-number="35"><span class="co">#> [1] FALSE</span></a>
<a class="sourceLine" id="cb3-36" data-line-number="36"></a>
<a class="sourceLine" id="cb3-37" data-line-number="37"><span class="co">## Functions related to installing and using Julia packages</span></a>
<a class="sourceLine" id="cb3-38" data-line-number="38"></a>
<a class="sourceLine" id="cb3-39" data-line-number="39"><span class="kw"><a href="reference/julia_package.html">julia_install_package_if_needed</a></span>(<span class="st">"Optim"</span>)</a>
<a class="sourceLine" id="cb3-40" data-line-number="40"><span class="kw"><a href="reference/julia_package.html">julia_installed_package</a></span>(<span class="st">"Optim"</span>)</a>
<a class="sourceLine" id="cb3-41" data-line-number="41"><span class="co">#> [1] "0.18.1"</span></a>
<a class="sourceLine" id="cb3-42" data-line-number="42"><span class="kw"><a href="reference/julia_package.html">julia_library</a></span>(<span class="st">"Optim"</span>)</a></code></pre></div>
</div>
<div id="troubleshooting-and-ways-to-get-help" class="section level2">
<h2 class="hasAnchor">
<a href="#troubleshooting-and-ways-to-get-help" class="anchor"></a>Troubleshooting and Ways to Get Help</h2>
<div id="julia-is-not-found" class="section level3">
<h3 class="hasAnchor">
<a href="#julia-is-not-found" class="anchor"></a>Julia is not found</h3>
<p>Make sure the <code>Julia</code> installation is correct. <code>JuliaCall</code> can find <code>Julia</code> on PATH, and there are three ways for <code>JuliaCall</code> to find <code>Julia</code> not on PATH.</p>
<ul>
<li>Use <code><a href="reference/julia_setup.html">julia_setup(JULIA_HOME = "the folder that contains julia binary")</a></code>
</li>
<li>Use <code><a href="https://www.rdocumentation.org/packages/base/topics/options">options(JULIA_HOME = "the folder that contains julia binary")</a></code>
</li>
<li>Set <code>JULIA_HOME</code> in command line environment.</li>
</ul>
</div>
<div id="libstdc-so-6-version-glibcxx_3-4-xx-not-found" class="section level3">
<h3 class="hasAnchor">
<a href="#libstdc-so-6-version-glibcxx_3-4-xx-not-found" class="anchor"></a>libstdc++.so.6: version `GLIBCXX_3.4.xx’ not found</h3>
<p>Such problems are usually on Linux machines. The cause for the problem is that R cannot find the libstdc++ version needed by <code>Julia</code>. To deal with the problem, users can export “TheFolderContainsJulia/lib/julia” to R_LD_LIBRARY_PATH.</p>
</div>
<div id="rcall-not-properly-installed" class="section level3">
<h3 class="hasAnchor">
<a href="#rcall-not-properly-installed" class="anchor"></a>RCall not properly installed</h3>
<p>The issue is usually caused by updates in R, and it can be typically solved by setting <code>rebuild</code> argument to <code>TRUE</code> in <code><a href="reference/julia_setup.html">julia_setup()</a></code> as follows.</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1">JuliaCall<span class="op">::</span><span class="kw"><a href="https://www.rdocumentation.org/packages/JuliaCall/topics/julia_setup">julia_setup</a></span>(<span class="dt">rebuild =</span> <span class="ot">TRUE</span>)</a></code></pre></div>
</div>
<div id="how-to-get-help" class="section level3">
<h3 class="hasAnchor">
<a href="#how-to-get-help" class="anchor"></a>How to Get Help</h3>
<ul>
<li>One way to get help for Julia functions is just using <code>julia$help</code> as the following example:</li>
</ul>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="kw"><a href="reference/julia_help.html">julia_help</a></span>(<span class="st">"sqrt"</span>)</a>
<a class="sourceLine" id="cb5-2" data-line-number="2"><span class="co">#> ```</span></a>
<a class="sourceLine" id="cb5-3" data-line-number="3"><span class="co">#> sqrt(x)</span></a>
<a class="sourceLine" id="cb5-4" data-line-number="4"><span class="co">#> ```</span></a>
<a class="sourceLine" id="cb5-5" data-line-number="5"><span class="co">#> </span></a>
<a class="sourceLine" id="cb5-6" data-line-number="6"><span class="co">#> Return $\sqrt{x}$. Throws [`DomainError`](@ref) for negative [`Real`](@ref) arguments. Use complex negative arguments instead. The prefix operator `√` is equivalent to `sqrt`.</span></a>
<a class="sourceLine" id="cb5-7" data-line-number="7"><span class="co">#> </span></a>
<a class="sourceLine" id="cb5-8" data-line-number="8"><span class="co">#> # Examples</span></a>
<a class="sourceLine" id="cb5-9" data-line-number="9"><span class="co">#> </span></a>
<a class="sourceLine" id="cb5-10" data-line-number="10"><span class="co">#> ```jldoctest; filter = r"Stacktrace:(\n \[[0-9]+\].*)*"</span></a>
<a class="sourceLine" id="cb5-11" data-line-number="11"><span class="co">#> julia> sqrt(big(81))</span></a>
<a class="sourceLine" id="cb5-12" data-line-number="12"><span class="co">#> 9.0</span></a>
<a class="sourceLine" id="cb5-13" data-line-number="13"><span class="co">#> </span></a>
<a class="sourceLine" id="cb5-14" data-line-number="14"><span class="co">#> julia> sqrt(big(-81))</span></a>
<a class="sourceLine" id="cb5-15" data-line-number="15"><span class="co">#> ERROR: DomainError with -8.1e+01:</span></a>
<a class="sourceLine" id="cb5-16" data-line-number="16"><span class="co">#> NaN result for non-NaN input.</span></a>
<a class="sourceLine" id="cb5-17" data-line-number="17"><span class="co">#> Stacktrace:</span></a>
<a class="sourceLine" id="cb5-18" data-line-number="18"><span class="co">#> [1] sqrt(::BigFloat) at ./mpfr.jl:501</span></a>
<a class="sourceLine" id="cb5-19" data-line-number="19"><span class="co">#> [...]</span></a>
<a class="sourceLine" id="cb5-20" data-line-number="20"><span class="co">#> </span></a>
<a class="sourceLine" id="cb5-21" data-line-number="21"><span class="co">#> julia> sqrt(big(complex(-81)))</span></a>
<a class="sourceLine" id="cb5-22" data-line-number="22"><span class="co">#> 0.0 + 9.0im</span></a>
<a class="sourceLine" id="cb5-23" data-line-number="23"><span class="co">#> ```</span></a>
<a class="sourceLine" id="cb5-24" data-line-number="24"><span class="co">#> </span></a>
<a class="sourceLine" id="cb5-25" data-line-number="25"><span class="co">#> ```</span></a>
<a class="sourceLine" id="cb5-26" data-line-number="26"><span class="co">#> sqrt(A::AbstractMatrix)</span></a>
<a class="sourceLine" id="cb5-27" data-line-number="27"><span class="co">#> ```</span></a>
<a class="sourceLine" id="cb5-28" data-line-number="28"><span class="co">#> </span></a>
<a class="sourceLine" id="cb5-29" data-line-number="29"><span class="co">#> If `A` has no negative real eigenvalues, compute the principal matrix square root of `A`, that is the unique matrix $X$ with eigenvalues having positive real part such that $X^2 = A$. Otherwise, a nonprincipal square root is returned.</span></a>
<a class="sourceLine" id="cb5-30" data-line-number="30"><span class="co">#> </span></a>
<a class="sourceLine" id="cb5-31" data-line-number="31"><span class="co">#> If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](@ref)) is used to compute the square root. Otherwise, the square root is determined by means of the Björck-Hammarling method [^BH83], which computes the complex Schur form ([`schur`](@ref)) and then the complex square root of the triangular factor.</span></a>
<a class="sourceLine" id="cb5-32" data-line-number="32"><span class="co">#> </span></a>
<a class="sourceLine" id="cb5-33" data-line-number="33"><span class="co">#> [^BH83]: Åke Björck and Sven Hammarling, "A Schur method for the square root of a matrix", Linear Algebra and its Applications, 52-53, 1983, 127-140. [doi:10.1016/0024-3795(83)80010-X](https://doi.org/10.1016/0024-3795(83)80010-X)</span></a>
<a class="sourceLine" id="cb5-34" data-line-number="34"><span class="co">#> </span></a>
<a class="sourceLine" id="cb5-35" data-line-number="35"><span class="co">#> # Examples</span></a>
<a class="sourceLine" id="cb5-36" data-line-number="36"><span class="co">#> </span></a>
<a class="sourceLine" id="cb5-37" data-line-number="37"><span class="co">#> ```jldoctest</span></a>
<a class="sourceLine" id="cb5-38" data-line-number="38"><span class="co">#> julia> A = [4 0; 0 4]</span></a>
<a class="sourceLine" id="cb5-39" data-line-number="39"><span class="co">#> 2×2 Array{Int64,2}:</span></a>
<a class="sourceLine" id="cb5-40" data-line-number="40"><span class="co">#> 4 0</span></a>
<a class="sourceLine" id="cb5-41" data-line-number="41"><span class="co">#> 0 4</span></a>
<a class="sourceLine" id="cb5-42" data-line-number="42"><span class="co">#> </span></a>
<a class="sourceLine" id="cb5-43" data-line-number="43"><span class="co">#> julia> sqrt(A)</span></a>
<a class="sourceLine" id="cb5-44" data-line-number="44"><span class="co">#> 2×2 Array{Float64,2}:</span></a>
<a class="sourceLine" id="cb5-45" data-line-number="45"><span class="co">#> 2.0 0.0</span></a>
<a class="sourceLine" id="cb5-46" data-line-number="46"><span class="co">#> 0.0 2.0</span></a>
<a class="sourceLine" id="cb5-47" data-line-number="47"><span class="co">#> ```</span></a></code></pre></div>
<ul>
<li><p>The GitHub Pages for this repository host the documentation for the development version of <code>JuliaCall</code>: <a href="https://non-contradiction.github.io/JuliaCall/" class="uri">https://non-contradiction.github.io/JuliaCall/</a>.</p></li>
<li><p>Also, you are more than welcome to contact me about <code>JuliaCall</code> at <a href="mailto:lch34677@gmail.com" class="email">lch34677@gmail.com</a> or <a href="mailto:cxl508@psu.edu" class="email">cxl508@psu.edu</a>.</p></li>
</ul>
</div>
</div>
<div id="juliacall-for-r-package-developers" class="section level2">
<h2 class="hasAnchor">
<a href="#juliacall-for-r-package-developers" class="anchor"></a>JuliaCall for R Package Developers</h2>
<p>If you are interested in developing an <code>R</code> package which is an interface for a <code>Julia</code> package, <code>JuliaCall</code> is an ideal choice. You only need to find the <code>Julia</code> function or <code>Julia</code> module you want to have in <code>R</code>, <code>using</code> the module, and <code>julia_call</code> the function. There are some examples:</p>
<ul>
<li>
<a href="https://github.com/JuliaDiffEq/diffeqr"><code>diffeqr</code></a> is a package for solving differential equations in <code>R</code>. It utilizes <a href="http://docs.juliadiffeq.org/latest/">DifferentialEquations.jl</a> for its core routines to give high performance solving of ordinary differential equations (ODEs), stochastic differential equations (SDEs), delay differential equations (DDEs), and differential-algebraic equations (DAEs) directly in <code>R</code>.</li>
<li>
<a href="https://github.com/Non-Contradiction/convexjlr"><code>convexjlr</code></a> is an <code>R</code> package for Disciplined Convex Programming (DCP) by providing a high level wrapper for <code>Julia</code> package <a href="https://github.com/JuliaOpt/Convex.jl"><code>Convex.jl</code></a>. <code>convexjlr</code> can solve linear programs, second order cone programs, semidefinite programs, exponential cone programs, mixed-integer linear programs, and some other DCP-compliant convex programs through <code>Convex.jl</code>.</li>
<li>
<a href="https://github.com/Non-Contradiction/ipoptjlr"><code>ipoptjlr</code></a> provides an <code>R</code> interface to the <code>Ipopt</code> nonlinear optimization solver. It provides a simple high-level wrapper for <code>Julia</code> package [<code>Ipopt.jl</code>] (<a href="https://github.com/JuliaOpt/Ipopt.jl" class="uri">https://github.com/JuliaOpt/Ipopt.jl</a>).</li>
<li>
<a href="https://github.com/eloualiche/FixedEffectjlr"><code>FixedEffectjlr</code></a> uses the <code>Julia</code> package <a href="https://github.com/matthieugomez/FixedEffectModels.jl"><code>FixedEffectModels.jl</code></a> to estimate large fixed effects models in <code>R</code>.</li>
<li>
<a href="http://rpubs.com/dmbates/377897">Julia MixedModels from R</a> illustrates how to use <code>JuliaCall</code> and <code>Julia</code> package <a href="https://github.com/dmbates/MixedModels.jl"><code>MixedModels.jl</code></a> to build mixed models in <code>R</code>.</li>
<li>
<a href="https://github.com/Non-Contradiction/autodiffr"><code>autodiffr</code></a> provides automatic differentiation to native <code>R</code> functions by wrapping <code>Julia</code> packages <a href="https://github.com/JuliaDiff/ForwardDiff.jl"><code>ForwardDiff.jl</code></a> and <a href="https://github.com/JuliaDiff/ReverseDiff.jl"><code>ReverseDiff.jl</code></a> through <code>JuliaCall</code>, which is a work in progress.</li>
</ul>
<p>If you have any issues in developing an <code>R</code> package using <code>JuliaCall</code>, you may report it using the link: <a href="https://github.com/Non-Contradiction/JuliaCall/issues/new" class="uri">https://github.com/Non-Contradiction/JuliaCall/issues/new</a>, or email me at <a href="mailto:lch34677@gmail.com" class="email">lch34677@gmail.com</a> or <a href="mailto:cxl508@psu.edu" class="email">cxl508@psu.edu</a>.</p>
</div>
<div id="suggestion-issue-reporting-and-contributing" class="section level2">
<h2 class="hasAnchor">
<a href="#suggestion-issue-reporting-and-contributing" class="anchor"></a>Suggestion, Issue Reporting, and Contributing</h2>
<p><code>JuliaCall</code> is under active development now. Any suggestion or issue reporting is welcome! You may report it using the link: <a href="https://github.com/Non-Contradiction/JuliaCall/issues/new" class="uri">https://github.com/Non-Contradiction/JuliaCall/issues/new</a>, or email me at <a href="mailto:lch34677@gmail.com" class="email">lch34677@gmail.com</a> or <a href="mailto:cxl508@psu.edu" class="email">cxl508@psu.edu</a>. You are welcome to use the <a href="https://github.com/Non-Contradiction/JuliaCall/blob/master/.github/ISSUE_TEMPLATE/bug_report.md">issue template</a> and the <a href="https://github.com/Non-Contradiction/JuliaCall/blob/master/.github/pull_request_template.md">pull request template</a>. The <a href="https://github.com/Non-Contradiction/JuliaCall/blob/master/.github/CONTRIBUTING.md">contributing guide</a> provides some guidance for making contributions.</p>
<div id="checking-juliacall-package" class="section level3">
<h3 class="hasAnchor">
<a href="#checking-juliacall-package" class="anchor"></a>Checking <code>JuliaCall</code> Package</h3>
<p>To check and test the <code>JuliaCall</code> package, you need to have the source package. You can</p>
<ul>
<li>download the source of <code>JuliaCall</code> from Github,</li>
<li>open <code>JuliaCall.Rproj</code> in your RStudio or open <code>R</code> from the downloaded directory,</li>
<li>run <code><a href="https://www.rdocumentation.org/packages/devtools/topics/test">devtools::test()</a></code> to see the result of the test suite.</li>
<li>run <code><a href="https://www.rdocumentation.org/packages/devtools/topics/check">devtools::check()</a></code> or click the <code>Check</code> button in the RStudio Build panel in the upper right to see the result of <code>R CMD check</code>.</li>
</ul>
</div>
</div>
<div id="other-interfaces-between-r-and-julia" class="section level2">
<h2 class="hasAnchor">
<a href="#other-interfaces-between-r-and-julia" class="anchor"></a>Other Interfaces Between R and Julia</h2>
<ul>
<li>
<a href="https://github.com/JuliaInterop/RCall.jl"><code>RCall.jl</code></a> is a <code>Julia</code> package which embeds <code>R</code> in <code>Julia</code>. <code>JuliaCall</code> is inspired by <code>RCall.jl</code> and depends on <code>RCall.jl</code> for many functionalities like type conversion between <code>R</code> and <code>Julia</code>.</li>
<li>
<a href="https://github.com/johnmchambers/XRJulia"><code>XRJulia</code></a> is an <code>R</code> package based on John Chambers’ <code>XR</code> package and allows for structured integration of <code>R</code> with <code>Julia</code>. It connects to <code>Julia</code> and uses JSON to transfer data between <code>Julia</code> and <code>R</code>. A simple performance comparison between <code>XRJulia</code> and <code>Julia</code> can be found in <a href="https://doi.org/10.21105/joss.01284"><code>JuliaCall</code> JOSS paper</a>.</li>
<li>
<a href="https://github.com/armgong/rjulia"><code>RJulia</code></a> is an <code>R</code> package which embeds <code>Julia</code> in <code>R</code> as well as <code>JuliaCall</code>. It is not on CRAN yet, and I haven’t tested it.</li>
</ul>
</div>
<div id="license" class="section level2">
<h2 class="hasAnchor">
<a href="#license" class="anchor"></a>License</h2>
<p><code>JuliaCall</code> is licensed under <a href="https://cran.r-project.org/web/licenses/MIT">MIT</a>.</p>
</div>
<div id="code-of-conduct" class="section level2">
<h2 class="hasAnchor">
<a href="#code-of-conduct" class="anchor"></a>Code of Conduct</h2>
<p>Please note that the <code>JuliaCall</code> project is released with a <a href="https://github.com/Non-Contradiction/JuliaCall/blob/master/CODE_OF_CONDUCT.md">Contributor Code of Conduct</a>. By contributing to this project, you agree to abide by its terms.</p>
</div>
<div id="citing" class="section level2">
<h2 class="hasAnchor">
<a href="#citing" class="anchor"></a>Citing</h2>
<p>If you use <code>JuliaCall</code> in research that resulted in publications, then please cite the <code>JuliaCall</code> paper using the following BibTeX entry:</p>
<pre><code>@Article{JuliaCall,
author = {Changcheng Li},
title = {{JuliaCall}: an {R} package for seamless integration between {R} and {Julia}},
journal = {The Journal of Open Source Software},
publisher = {The Open Journal},
year = {2019},
volume = {4},
number = {35},
pages = {1284},
doi = {10.21105/joss.01284},
}</code></pre>
</div>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<div class="links">
<h2>Links</h2>
<ul class="list-unstyled">
<li>Download from CRAN at <br><a href="https://cloud.r-project.org/package=JuliaCall">https://cloud.r-project.org/package=JuliaCall</a>
</li>
<li>Browse source code at <br><a href="https://github.com/Non-Contradiction/JuliaCall">https://github.com/Non-Contradiction/JuliaCall</a>
</li>
<li>Report a bug at <br><a href="https://github.com/Non-Contradiction/JuliaCall/issues">https://github.com/Non-Contradiction/JuliaCall/issues</a>
</li>
</ul>
</div>
<div class="license">
<h2>License</h2>
<ul class="list-unstyled">
<li><a href="LICENSE.html">Full license</a></li>
<li><small><a href="https://opensource.org/licenses/mit-license.php">MIT</a> + file <a href="LICENSE-text.html">LICENSE</a></small></li>
</ul>
</div>
<div class="citation">
<h2>Citation</h2>
<ul class="list-unstyled">
<li><a href="authors.html">Citing JuliaCall</a></li>
</ul>
</div>
<div class="developers">
<h2>Developers</h2>
<ul class="list-unstyled">
<li>Changcheng Li <br><small class="roles"> Author, maintainer </small> </li>
<li><a href="authors.html">All authors...</a></li>
</ul>
</div>
<div class="dev-status">
<h2>Dev status</h2>
<ul class="list-unstyled">
<li><a href="https://travis-ci.org/Non-Contradiction/JuliaCall"><img src="https://travis-ci.org/Non-Contradiction/JuliaCall.svg?branch=master" alt="Travis-CI Build Status"></a></li>
<li><a href="https://ci.appveyor.com/project/Non-Contradiction/JuliaCall"><img src="https://ci.appveyor.com/api/projects/status/github/Non-Contradiction/JuliaCall?branch=master&svg=true" alt="AppVeyor Build Status"></a></li>
<li><a href="https://cran.r-project.org/package=JuliaCall"><img src="https://www.r-pkg.org/badges/version/JuliaCall" alt="CRAN_Status_Badge"></a></li>
<li><a href="https://cran.r-project.org/package=JuliaCall"><img src="https://cranlogs.r-pkg.org/badges/JuliaCall"></a></li>
<li><a href="https://cran.r-project.org/package=JuliaCall"><img src="https://cranlogs.r-pkg.org/badges/grand-total/JuliaCall"></a></li>
<li><a href="https://doi.org/10.21105/joss.01284"><img src="http://joss.theoj.org/papers/10.21105/joss.01284/status.svg" alt="DOI"></a></li>
</ul>
</div>
</div>
</div>
<footer><div class="copyright">
<p>Developed by Changcheng Li.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>
</body>
</html>