Skip to content

[julia] Julia Lang on FreeBSD

[julia] Julia Lang on FreeBSD

Julia is a high-level, high-performance, dynamic programming language, many of its features are well suited for numerical analysis and computational science.

Install julia on FreeBSD

1. Download julia

Go to julia download page: https://julialang.org/downloads

Find the julia for FreeBSD and download, (Generic FreeBSD on x86), 64-bit

Get the GPG file for verification download.

2. Extract julia to your system

mkdir -p ~/bin/apps
tar -xvf julia-1.6.0-freebsd-x86_64.tar.gz -C ~/bin/apps/
cd ~/bin/
ln -s apps/julia-1.6.0/bin/julia
cd

3. Start using julia!

-------- Start a julia REPL (shell):
$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.0 (2021-03-24)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia>
-------- Try our Julia Hello World!
julia> print("Hello, Julia!")
Hello, Julia!
julia> run(`uname -s`)
FreeBSD
Process(`uname -s`, ProcessExited(0))

Use julia!

Let's define a mathematical polynomial function:

julia> f(x) = 5x^3 - 3x^2 + 7x -9
f (generic function with 1 method)

julia> f(1/3)
-6.814814814814815

That's amazon, doesn't it?

Complex and exp:

julia> exp(3.2-1.5im)
1.7353625359719356 - 24.471075880329156im

Matrix and exp:

julia> a = [
           1 2 3
           2 1 3
           2 1 2
       ]
3×3 Matrix{Int64}:
 1  2  3
 2  1  3
 2  1  2

julia> exp(a)
3×3 Matrix{Float64}:
 84.0299  64.6916  125.493
 83.662   65.0595  125.493
 71.0151  54.478   106.89

Complex and matrix:

julia> a = [
           1 1 2
           2 2 1
           2 1 3
       ]
3×3 Matrix{Int64}:
 1  1  2
 2  2  1
 2  1  3

julia> x = 1.1 - 2.0im
1.1 - 2.0im

julia> x^a
3×3 Matrix{ComplexF64}:
 12.3949+13.4932im  8.76639+9.93455im  15.3679+16.9932im
  13.203+14.1173im  10.3369+9.04817im  17.4259+21.4382im
 17.5328+19.8691im  13.0962+15.6864im  23.4331+24.7346im

julia> a^x
3×3 Matrix{ComplexF64}:
  59.9685-150.231im  -13.2224+29.4762im  -34.3177+79.1619im
 -42.1906+99.3714im   7.38147-19.7069im   18.2693-51.362im
 -26.4447+58.9524im   2.52349-10.9429im   9.90496-30.6498im

Transpose a matrix:

(So amazingly, I never thought I can use a symbol ' to transpose a matrix in a programing language!)

julia> a
3×3 Matrix{Int64}:
 1  1  2
 2  2  1
 2  1  3

julia> a'
3×3 adjoint(::Matrix{Int64}) with eltype Int64:
 1  2  2
 1  2  1
 2  1  3

Inverse a matrix:

julia> a^-1
3×3 Matrix{Float64}:
 -1.66667    0.333333   1.0
  1.33333    0.333333  -1.0
  0.666667  -0.333333   0.0

Inverse a complex:

julia> x=2-7im
2 - 7im

julia> x^-1
0.03773584905660377 + 0.1320754716981132im

Julia Home: https://julialang.org

FreeBSD Julia: https://wiki.freebsd.org/Julia

 

 

 

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment


To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.

@freebsdgames.xyz