投稿

9月, 2018の投稿を表示しています

julia1.0 の Stats の Unsatisfiable requirements

julia 1.0 のパッケージのアップデートで、エラーが出ました。Stats.jl の要求する version が宜しくないようです。 rm Stats で、一旦、アンインストールして、後日、入れ直しということになりそうです。 julia 1.0 は思ったよりも不安定かもしれません。 (v1.0) pkg> up Updating registry at `~/.julia/registries/General` Updating git-repo `https://github.com/JuliaRegistries/General.git` Resolving package versions... ERROR: Unsatisfiable requirements detected for package Stats [072d6d2a]: Stats [072d6d2a] log: ├─possible versions are: [0.0.1, 0.1.0] or uninstalled ├─restricted to versions * by an explicit requirement, leaving only versions [0.0.1, 0.1.0] └─restricted by julia compatibility requirements to versions: uninstalled — no versions left (v1.0) pkg> rm Stats Updating `~/.julia/environments/v1.0/Project.toml` [072d6d2a] - Stats v0.1.0 Updating `~/.julia/environments/v1.0/Manifest.toml` [072d6d2a] - Stats v0.1.0 (v1.0) pkg> up Updating registry at `~/.julia/registries/General` Updating git-repo `https://github.com/JuliaRegistries/General.git` Resolv...

そろそろ julia 0.6 から julia 1.0 に移行できるかな? でも変更点多数ですね。

RCall と PyCall が動いたので julia 0.6 から julia 1.0 に移行できるかもしれません。 でも、なぜか .juliarc を読んでくれていないようです。 他にも、戸惑うこと多数です。0.6 のコピー&ペーストは、まず動きません。 きっと短めのプログラムから、少しずつ、自分の方が、適応していかないといけないのでしょう。 日付を扱う Base.Dates が、Dates になっているようです _ _ _ _(_)_ | Documentation: https://docs.julialang.org (_) | (_) (_) | _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 1.0.0 (2018-08-08) _/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release |__/ | julia> Date(2018) ERROR: UndefVarError: Date not defined Stacktrace: [1] top-level scope at none:0 julia> using Base.Dates ERROR: UndefVarError: Dates not defined julia> using Dates julia> Date(2018) 2018-01-01 パスの指定時のエスケープシークエンスの使い方が代わっているようです julia> cd("./Google\ ドライブ/") ERROR: syntax: invalid escape sequence julia> cd("./Google ドライブ/") missi...

julia で内積を計算する入力方法, NumPy の行列かけ算との違い

julia で内積を計算する入力方法は2つあります。dot() と演算記号の「⋅」を使う方法です。 まず、julia 1.0.x 以上では、おまじないが必要です。 julia> using LinearAlgebra dot() は入力には困りませんが、演算記号の「⋅」はどうやって入力しましょう? MacOS X では、alt+8 で「•」 という記号が入力できます。しかし、これでは計算してくれません。 演算記号の「⋅」は、TeXの \cdot に続いて タブを押す方法で入力できます。 \alpha などもタブで「α」に変換してくれます。 julia> a=[1,2,3] 3-element Array{Int64,1}: 1 2 3 julia> b=[4,5,6] 3-element Array{Int64,1}: 4 5 6 julia> a*b ERROR: DimensionMismatch("Cannot multiply two vectors") Stacktrace: [1] *(::Array{Int64,1}, ::Array{Int64,1}) at ./linalg/rowvector.jl:184 julia> a.*b 3-element Array{Int64,1}: 4 10 18 julia> a\cdot a⋅b 32 julia> dot(a,b) 32 PyCall で NumPy を呼び出して同じ演算をしてみしょう。 julia> using PyCall julia> @pyimport numpy as np julia> np.dot(a,b) 32 1×n のベクトルでは、numpy の numpy.dot() と julia の dot() は同じです。 しかし、n×m になると異なるので注意が必要です。 julia> A = [1 2 ; 3 4] 2×2 Array{Int64,2}: 1 2 3 4 julia> B = [5 6 ; 7 8] 2×2 Array{Int64,2}: 5 6 ...