Skip to content

Commit 6af032b

Browse files
committed
Package updates
1 parent 6661752 commit 6af032b

File tree

2 files changed

+423
-317
lines changed

2 files changed

+423
-317
lines changed

src/06_Direct_methods.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,30 +1070,30 @@ function factorise_lu_pivot(A)
10701070
L = zeros(n, n)
10711071
U = zeros(n, n)
10721072
p = fill(0, n)
1073-
Aᵏ = float(copy(A)) # Make a copy of A and ensure that all entries
1073+
Ak = float(copy(A)) # Make a copy of A and ensure that all entries
10741074
# are converted to floating-point numbers
10751075

10761076
for k in 1:n-1 # Algorithm steps
1077-
p[k] = argmax(abs.(Aᵏ[:, k])) # Find row with maximal pivot
1077+
p[k] = argmax(abs.(Ak[:, k])) # Find row with maximal pivot
10781078

1079-
U[k, :] = Aᵏ[p[k], :] # Copy pivot row to U, use U now instead of Aᵏ,
1079+
U[k, :] = Ak[p[k], :] # Copy pivot row to U, use U now instead of Ak,
10801080
# which is again updated in-place
10811081
for i in 1:n # Row loop: Note the full range as any row may
10821082
# be non-zero
1083-
L[i, k] = Aᵏ[i, k] / U[k, k]
1083+
L[i, k] = Ak[i, k] / U[k, k]
10841084
for j = 1:n # Column loop: Again full range
1085-
Aᵏ[i, j] = Aᵏ[i, j] - L[i, k] * U[k, j]
1085+
Ak[i, j] = Ak[i, j] - L[i, k] * U[k, j]
10861086
end
10871087
end
10881088
end
1089-
p[n] = argmax(abs.(Aᵏ[:, n]))
1090-
U[n, n] = Aᵏ[p[n], n]
1091-
L[:, n] = Aᵏ[:, n] / U[n, n]
1089+
p[n] = argmax(abs.(Ak[:, n]))
1090+
U[n, n] = Ak[p[n], n]
1091+
L[:, n] = Ak[:, n] / U[n, n]
10921092

10931093
# To simplify assembling L we so far kept the rows in the same order
10941094
# as in A. To make the matrix upper triangular we also apply the column
10951095
# permutation p before returning the results.
1096-
LowerTriangular(L[p, :]), UpperTriangular(U), p
1096+
(; L=LowerTriangular(L[p, :]), U=UpperTriangular(U), p=p)
10971097
end
10981098

10991099
# ╔═╡ 24df3f6a-8ac3-492b-b4e7-80029af6918d
@@ -1120,13 +1120,13 @@ fac.p
11201120
md"In contrast we obtain:"
11211121

11221122
# ╔═╡ 8f06e886-6ebb-4a16-a1c5-8123e09ef723
1123-
factorise_lu_pivot(D)[1] # L
1123+
factorise_lu_pivot(D).L
11241124

11251125
# ╔═╡ 88000701-f480-4efd-93b8-50b60c9d5d95
1126-
factorise_lu_pivot(D)[2] # U
1126+
factorise_lu_pivot(D).U
11271127

11281128
# ╔═╡ f79f92bc-e50b-4e5c-a82e-555269fa80b5
1129-
factorise_lu_pivot(D)[3] # p
1129+
factorise_lu_pivot(D).p
11301130

11311131
# ╔═╡ 3e110a7e-1272-4c50-80f6-290f61844952
11321132
md"""
@@ -2094,9 +2094,9 @@ uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
20942094
version = "3.1.0"
20952095
20962096
[[deps.MIMEs]]
2097-
git-tree-sha1 = "1833212fd6f580c20d4291da9c1b4e8a655b128e"
2097+
git-tree-sha1 = "c64d943587f7187e751162b3b84445bbbd79f691"
20982098
uuid = "6c6e2e6c-3030-632d-7369-2d6c69616d65"
2099-
version = "1.0.0"
2099+
version = "1.1.0"
21002100
21012101
[[deps.MacroTools]]
21022102
git-tree-sha1 = "72aebe0b5051e5143a079a4685a46da330a40472"

0 commit comments

Comments
 (0)