Prolo-Klimper
Ein bisschen Vorbereitung für die nächste Session (wahrscheinlich heute) mit einer neu besaiteten Gitarre. Diesmal noch mal M3T, demnächst folgt eine weitere NST-Session.
prolo-01
prolo-02
Ich bleibe am Ball. Am liebsten überall.¹¹
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
julia> table = collect(r*c for r in 1:5, c in 1:5)
5×5 Array{Int64,2}:
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
julia> circshift(table, (0, 11))
5×5 Array{Int64,2}:
5 1 2 3 4
10 2 4 6 8
15 3 6 9 12
20 4 8 12 16
25 5 10 15 20
julia> circshift(table, (0, 11))
5×5 Array{Int64,2}:
5 1 2 3 4
10 2 4 6 8
15 3 6 9 12
20 4 8 12 16
25 5 10 15 20
julia> circshift(table, (0, 2))
5×5 Array{Int64,2}:
4 5 1 2 3
8 10 2 4 6
12 15 3 6 9
16 20 4 8 12
20 25 5 10 15
julia> rotr90(table)
5×5 Array{Int64,2}:
5 4 3 2 1
10 8 6 4 2
15 12 9 6 3
20 16 12 8 4
25 20 15 10 5
julia> table
5×5 Array{Int64,2}:
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
julia> a = collect(1:10);
julia> a[9] = -111
-111
julia> a
10-element Array{Int64,1}:
1
2
3
4
5
6
7
8
-111
10
julia> print(a)
[1, 2, 3, 4, 5, 6, 7, 8, -111, 10]
julia> A = reshape(1:12, 3, 4)
3×4 reshape(::UnitRange{Int64}, 3, 4) with eltype Int64:
1 4 7 10
2 5 8 11
3 6 9 12
julia> b = ones(3,4)
3×4 Array{Float64,2}:
1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0
julia> a + b
ERROR: DimensionMismatch("dimensions must match")
Stacktrace:
[1] promote_shape at ./indices.jl:154 [inlined]
[2] promote_shape at ./indices.jl:150 [inlined]
[3] promote_shape at ./indices.jl:145 [inlined]
[4] +(::Array{Int64,1}, ::Array{Float64,2}) at ./arraymath.jl:45
[5] top-level scope at REPL[124]:1
julia> A + B
ERROR: UndefVarError: B not defined
Stacktrace:
[1] top-level scope at REPL[125]:1
julia> A + b
3×4 Array{Float64,2}:
2.0 5.0 8.0 11.0
3.0 6.0 9.0 12.0
4.0 7.0 10.0 13.0
julia> A - b
3×4 Array{Float64,2}:
0.0 3.0 6.0 9.0
1.0 4.0 7.0 10.0
2.0 5.0 8.0 11.0
julia> A = [1 2 ; 3 4]
2×2 Array{Int64,2}:
1 2
3 4
julia> B = [10 11 ; 12 13]
2×2 Array{Int64,2}:
10 11
12 13
julia> A .* B
2×2 Array{Int64,2}:
10 22
36 52
julia> A x B
ERROR: syntax: extra token "x" after end of expression
Stacktrace:
[1] top-level scope at REPL[130]:0
julia> A * B
2×2 Array{Int64,2}:
34 37
78 85
julia> A - B
2×2 Array{Int64,2}:
-9 -9
-9 -9
julia> A / B
2×2 Array{Float64,2}:
5.5 -4.5
4.5 -3.5
julia> B / A
2×2 Array{Float64,2}:
-3.5 4.5
-4.5 5.5
julia> A \ B
2×2 Array{Float64,2}:
-8.0 -9.0
9.0 10.0
julia> A * 11
2×2 Array{Int64,2}:
11 22
33 44
julia> A .* 11
2×2 Array{Int64,2}:
11 22
33 44
julia> A // 11
2×2 Array{Rational{Int64},2}:
1//11 2//11
3//11 4//11
julia> C = A // 11
2×2 Array{Rational{Int64},2}:
1//11 2//11
3//11 4//11
julia> C
2×2 Array{Rational{Int64},2}:
1//11 2//11
3//11 4//11
julia> A .> 6
2×2 BitArray{2}:
0 0
0 0
julia> A .< 6
2×2 BitArray{2}:
1 1
1 1
julia> A = [1 2 3
4 5 6
7 8 9]
3×3 Array{Int64,2}:
1 2 3
4 5 6
7 8 9
julia> rot180(A)
3×3 Array{Int64,2}:
9 8 7
6 5 4
3 2 1
julia> reverse(A, dims=(1))
3×3 Array{Int64,2}:
7 8 9
4 5 6
1 2 3
julia> reverse(A, dims=(2))
3×3 Array{Int64,2}:
3 2 1
6 5 4
9 8 7
ndims(A)
2
julia> a = reshape(rand(1:20, 20), 4, 5)
4×5 Array{Int64,2}:
2 15 10 4 20
17 11 7 6 8
4 15 3 1 10
7 17 7 14 18
julia> sort(a, dims=(1))
4×5 Array{Int64,2}:
2 11 3 1 8
4 15 7 4 10
7 15 7 6 18
17 17 10 14 20
julia> r = rand(100:110, 10)
10-element Array{Int64,1}:
105
100
106
110
106
103
104
105
107
105
julia> sortperm(r)
10-element Array{Int64,1}:
2
6
7
1
8
10
3
5
9
4
julia> r[sortperm(r)]
10-element Array{Int64,1}:
100
103
104
105
105
105
106
106
107
110
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
¹¹ Leider aber ist das nicht der Fall.²²
²² Macht ja nix, dafür hab' ich wenigstens 'nen Knall.³³
³³ Wie auch immer das fim iwi in ieinen Zusammenhang jetzt bringen wall.
prolo-01
prolo-02
Ich bleibe am Ball. Am liebsten überall.¹¹
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
julia> table = collect(r*c for r in 1:5, c in 1:5)
5×5 Array{Int64,2}:
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
julia> circshift(table, (0, 11))
5×5 Array{Int64,2}:
5 1 2 3 4
10 2 4 6 8
15 3 6 9 12
20 4 8 12 16
25 5 10 15 20
julia> circshift(table, (0, 11))
5×5 Array{Int64,2}:
5 1 2 3 4
10 2 4 6 8
15 3 6 9 12
20 4 8 12 16
25 5 10 15 20
julia> circshift(table, (0, 2))
5×5 Array{Int64,2}:
4 5 1 2 3
8 10 2 4 6
12 15 3 6 9
16 20 4 8 12
20 25 5 10 15
julia> rotr90(table)
5×5 Array{Int64,2}:
5 4 3 2 1
10 8 6 4 2
15 12 9 6 3
20 16 12 8 4
25 20 15 10 5
julia> table
5×5 Array{Int64,2}:
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
julia> a = collect(1:10);
julia> a[9] = -111
-111
julia> a
10-element Array{Int64,1}:
1
2
3
4
5
6
7
8
-111
10
julia> print(a)
[1, 2, 3, 4, 5, 6, 7, 8, -111, 10]
julia> A = reshape(1:12, 3, 4)
3×4 reshape(::UnitRange{Int64}, 3, 4) with eltype Int64:
1 4 7 10
2 5 8 11
3 6 9 12
julia> b = ones(3,4)
3×4 Array{Float64,2}:
1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0
julia> a + b
ERROR: DimensionMismatch("dimensions must match")
Stacktrace:
[1] promote_shape at ./indices.jl:154 [inlined]
[2] promote_shape at ./indices.jl:150 [inlined]
[3] promote_shape at ./indices.jl:145 [inlined]
[4] +(::Array{Int64,1}, ::Array{Float64,2}) at ./arraymath.jl:45
[5] top-level scope at REPL[124]:1
julia> A + B
ERROR: UndefVarError: B not defined
Stacktrace:
[1] top-level scope at REPL[125]:1
julia> A + b
3×4 Array{Float64,2}:
2.0 5.0 8.0 11.0
3.0 6.0 9.0 12.0
4.0 7.0 10.0 13.0
julia> A - b
3×4 Array{Float64,2}:
0.0 3.0 6.0 9.0
1.0 4.0 7.0 10.0
2.0 5.0 8.0 11.0
julia> A = [1 2 ; 3 4]
2×2 Array{Int64,2}:
1 2
3 4
julia> B = [10 11 ; 12 13]
2×2 Array{Int64,2}:
10 11
12 13
julia> A .* B
2×2 Array{Int64,2}:
10 22
36 52
julia> A x B
ERROR: syntax: extra token "x" after end of expression
Stacktrace:
[1] top-level scope at REPL[130]:0
julia> A * B
2×2 Array{Int64,2}:
34 37
78 85
julia> A - B
2×2 Array{Int64,2}:
-9 -9
-9 -9
julia> A / B
2×2 Array{Float64,2}:
5.5 -4.5
4.5 -3.5
julia> B / A
2×2 Array{Float64,2}:
-3.5 4.5
-4.5 5.5
julia> A \ B
2×2 Array{Float64,2}:
-8.0 -9.0
9.0 10.0
julia> A * 11
2×2 Array{Int64,2}:
11 22
33 44
julia> A .* 11
2×2 Array{Int64,2}:
11 22
33 44
julia> A // 11
2×2 Array{Rational{Int64},2}:
1//11 2//11
3//11 4//11
julia> C = A // 11
2×2 Array{Rational{Int64},2}:
1//11 2//11
3//11 4//11
julia> C
2×2 Array{Rational{Int64},2}:
1//11 2//11
3//11 4//11
julia> A .> 6
2×2 BitArray{2}:
0 0
0 0
julia> A .< 6
2×2 BitArray{2}:
1 1
1 1
julia> A = [1 2 3
4 5 6
7 8 9]
3×3 Array{Int64,2}:
1 2 3
4 5 6
7 8 9
julia> rot180(A)
3×3 Array{Int64,2}:
9 8 7
6 5 4
3 2 1
julia> reverse(A, dims=(1))
3×3 Array{Int64,2}:
7 8 9
4 5 6
1 2 3
julia> reverse(A, dims=(2))
3×3 Array{Int64,2}:
3 2 1
6 5 4
9 8 7
ndims(A)
2
julia> a = reshape(rand(1:20, 20), 4, 5)
4×5 Array{Int64,2}:
2 15 10 4 20
17 11 7 6 8
4 15 3 1 10
7 17 7 14 18
julia> sort(a, dims=(1))
4×5 Array{Int64,2}:
2 11 3 1 8
4 15 7 4 10
7 15 7 6 18
17 17 10 14 20
julia> r = rand(100:110, 10)
10-element Array{Int64,1}:
105
100
106
110
106
103
104
105
107
105
julia> sortperm(r)
10-element Array{Int64,1}:
2
6
7
1
8
10
3
5
9
4
julia> r[sortperm(r)]
10-element Array{Int64,1}:
100
103
104
105
105
105
106
106
107
110
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
¹¹ Leider aber ist das nicht der Fall.²²
²² Macht ja nix, dafür hab' ich wenigstens 'nen Knall.³³
³³ Wie auch immer das fim iwi in ieinen Zusammenhang jetzt bringen wall.
Kommentare
Kommentar veröffentlichen