Julia 简介

             

  • 本词条处于草稿阶段.

   许多语法和 Matlab 很像,另一些和 C/C++ 很像,如果你两种语言都已经会了,那么 Julia 是十分简单的.

   安装方法

sudo snap install Julia --classic

   另外 Jupyter Notebook 也支持 Julia.

命令行

println("hello world")

计算器

变量

矩阵

   SubArray 的结构

struct SubArray{T,N,P,I,L} <: AbstractArray{T,N}
    parent::P
    indices::I
    offset1::Int  # for linear indexing and pointer, only valid when L==true
    stride1::Int  # used only for linear indexing
    ...
end

   随机矩阵

rand(ComplexF64, Nr1, Nr2, Npw)

脚本

画图

   第三方画图包 Plots,无需安装!

using Plots
x = 1:10; y = rand(10); # These are the plotting data
plot(x,y)

常用函数

   函数定义

function sphere_vol(r)
    return 4/3*pi*r^3
end

   hash(把结果的 hash 输出可以保证计算过程不被优化掉)

hash(矩阵)

   当前时间 time()

         

© 小时科技 保留一切权利