With CodeGeneration[Julia], you can translate expressions to code fragments:
>
|
|
>
|
|
cg = sqrt(a ^ 2 + b ^ 2 + c ^ 2)
| |
You can also translate procedures and larger programs.
>
|
|
function cg0(m)
r = 0
for i = 1:m
r = r + i
return(r)
end
| |
CodeGeneration[Julia] translates many Maple data structures and functions, including many routines for linear algebra and special functions, to equivalents in Julia.
>
|
|
cg2 = -v ^ 3 + 3 * v + 1 ? v < 1 : 2 * v ^ 3 - 9 * v ^ 2 + 12 * v - 2 ? v < 2 : -v ^ 3 + 9 * v ^ 2 - 24 * v + 22
| |
>
|
|
cg3(M,n) = M - x * eye(n)
| |
>
|
|
cg4 = _C1 * besselj(nu, x) + _C2 * bessely(nu, x)
| |
Code Generation for Julia in Maple can also translate some key commands from Statistics:
>
|
|
>
|
|
cg6 = median([5,2,1,4,3])
| |
>
|
|
When possible, Maple attempts to return an equivalent command to commands dealing with many distributions. In this example, the evaluated probability density function is translated.
>
|
|
cg9 = 0 ? x < 0 : 1 / x * sqrt(2) * pi ^ (-1//2) * exp(-log(x) ^ 2 / 2) / 2
| |