Skip to content

Commit 43e16bb

Browse files
authored
Update finitedifference_2d.jl
1 parent f7491bf commit 43e16bb

File tree

1 file changed

+6
-101
lines changed

1 file changed

+6
-101
lines changed

examples/finitedifference_2d.jl

Lines changed: 6 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
###########
55

6-
using BlockBandedMatrices, BandedMatrices, ArrayLayouts, FillArrays
6+
using BlockBandedMatrices, BandedMatrices, ArrayLayouts, FillArrays, LazyBandedMatrices, LazyArrays
77

88

99
function finitedifference_2d(n)
@@ -58,14 +58,14 @@ n = 1000;
5858
@time _gaussseidel(L,U, b, x, y, 20) # 0.4s
5959

6060
@time= sparse(BandedBlockBandedMatrix(L))
61-
@time = sparse(U)
61+
@time Ũ = sparse(U)
6262
x = copy(b)
6363
y = copy(x)
64-
@time _gaussseidel2(L̃,, b, x, y, 20)
64+
@time _gaussseidel2(L̃,Ũ, b, x, y, 20)
6565

66-
= sparse(A)
67-
@time qr();
68-
@time \b ;
66+
à = sparse(A)
67+
@time qr(Ã);
68+
@time à \b ;
6969

7070
A = randn(n,n)
7171

@@ -82,98 +82,3 @@ n = 1000;
8282
lu(A)
8383
end
8484

85-
0.02*n
86-
87-
A*x - b
88-
89-
90-
91-
= copy(x)
92-
= copy(y)
93-
94-
@view(y[1:end-1]) .= Mul(U , @view(x[2:end]))
95-
96-
mul!(@view(ỹ[1:end-1]) , Ũ , @view(x̃[2:end]))
97-
y[end] = 0
98-
ỹ[end] = 0
99-
x = copy(b)
100-
y = copy(x)
101-
_gaussseidel(L,U, b, x, y, 1) - x_bb
102-
103-
x .= b .- y
104-
ỹ .= b .-
105-
x .= Ldiv(L, x)
106-
107-
x̃ .=\
108-
109-
110-
x - x_bb
111-
112-
-x
113-
114-
115-
116-
(L̃ \ x) - (L \ x)
117-
118-
- y |> norm
119-
x - x_bb
120-
121-
A*x - b
122-
123-
124-
== L
125-
== U
126-
127-
norm(A*x - b)
128-
@time
129-
130-
131-
@time copy(x)
132-
= sparse(L)
133-
= sparse(U)
134-
135-
136-
137-
138-
y = x[1:end-1]
139-
z = similar(y)
140-
@time z .= Mul(U,y)
141-
y = similar(x)
142-
@time (@view(y[1:end-1]) .= Mul(U , @view(x[2:end])))
143-
y[end] = 0
144-
@time x .= b .- y
145-
@time x .= Ldiv(L, x)
146-
A = randn(9,40_000);
147-
@time A*x;
148-
149-
A
150-
S = sparse(A);
151-
152-
400^2
153-
154-
@time L\x
155-
156-
157-
h = 1/n
158-
@time= BandedMatrix(0 => Fill(-2,n), 1 => Fill(1,n-1), -1 => Fill(1,n-1))/h^2
159-
@time D_xx = BandedBlockBandedMatrix(Kron(D², Eye(n)))
160-
@time D_yy = BandedBlockBandedMatrix(Kron(Eye(n), D²))
161-
@time D_xx .+ D_yy
162-
4
163-
164-
165-
166-
using Profile
167-
dest = Δ;
168-
@time BlockBandedMatrices.blockbanded_copyto!(dest, D_yy)
169-
view(dest, Block(1,1)) .= view(dest, Block(1,1)) .+ view(D_yy, Block(1,1))
170-
D_yy
171-
@time copyto!(dest, Broadcast.broadcasted(+, D_xx , D_yy))
172-
173-
174-
175-
176-
using FFTW
177-
A = randn(400, 400);
178-
@time fft(A);
179-
dest[Block(1,1)]

0 commit comments

Comments
 (0)