XLPack API: Julia example programs

How to call XLPack from Julia

The XLPack Lite Julia interface program is included in SDK, so that the calling program can easily call XLPack Lite like built-in functions by declaring “using XLPack”.
Float64 is used for floating point variables and Int32 is used for integer variables. Either two dimensional or one dimensional array can be used for both coefficient matrix a and right hand matrix b.

Julia example program (Example (1))

using XLPack

function TestDgesv()
    n = 3
    a = [ 0.2 -0.11 -0.93;
         -0.32 0.81 0.37;
         -0.8 -0.92 -0.29 ]
    b = [ -0.3727, 0.4319, -1.4247 ]
    ipiv = Vector{Cint}(undef, n)
    info = dgesv(n, a, ipiv, b)
    println("x = ", b, ", info = ", info)
end

TestDgesv()

Result

x = [0.8600000000000002, 0.64, 0.5099999999999999], info = 0

Julia example program (Example (2))

In Example (2), the integral of f(x) is computed using qk15. qk15 requires the external function defining f(x). It can be coded in Julia and qk15 will call it when necessary.

using XLPack

function TestQk15()
    f(x) = 1/(1 + x^2)
    a = 0
    b = 4
    s, abserr = qk15(f, a, b)
    println(s, " ", abserr)
end

TestQk15()

Result

1.3258176613637855 0.0014827239412162237