Code Generation
The CodeGeneration package offers new support for translating Maple code to the Julia programming language.
Julia
With CodeGeneration[Julia], you can translate expressions to code fragments:
withCodeGeneration:
Juliaa2+b2+c2
cg = sqrt(a ^ 2 + b ^ 2 + c ^ 2)
You can also translate procedures and larger programs.
Juliam→addi,i=1..m
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.
Julia1234
cg1 = [1 2; 3 4]
Julia({−v3+3⁢v+1v<12⁢v3−9⁢v2+12⁢v−2v<2−v3+9⁢v2−24⁢v+22otherwise)
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
JuliaM,n→M − x LinearAlgebra:-IdentityMatrixn
cg3(M,n) = M - x * eye(n)
Julia_C1⁢BesselJ⁡ν,x+_C2⁢BesselYν,x
cg4 = _C1 * besselj(nu, x) + _C2 * bessely(nu, x)
Code Generation for Julia in Maple can also translate some key commands from Statistics:
Julia'Statistics:-Mean5,2,1,4,3'
cg5 = mean([5,2,1,4,3])
Julia'Statistics:-Median5,2,1,4,3'
cg6 = median([5,2,1,4,3])
Julia'Statistics:-StandardDeviation5,2,1,4,3'
cg7 = std([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.
JuliaStatistics:-PDFLogNormal0,1,x
cg9 = 0 ? x < 0 : 1 / x * sqrt(2) * pi ^ (-1//2) * exp(-log(x) ^ 2 / 2) / 2
Download Help Document