3
3
#
4
4
# ##########
5
5
6
- using BlockBandedMatrices, BandedMatrices, ArrayLayouts, FillArrays
6
+ using BlockBandedMatrices, BandedMatrices, ArrayLayouts, FillArrays, LazyBandedMatrices, LazyArrays
7
7
8
8
9
9
function finitedifference_2d (n)
@@ -58,14 +58,14 @@ n = 1000;
58
58
@time _gaussseidel (L,U, b, x, y, 20 ) # 0.4s
59
59
60
60
@time L̃ = sparse (BandedBlockBandedMatrix (L))
61
- @time Ũ = sparse (U)
61
+ @time Ũ = sparse (U)
62
62
x = copy (b)
63
63
y = copy (x)
64
- @time _gaussseidel2 (L̃,Ũ , b, x, y, 20 )
64
+ @time _gaussseidel2 (L̃,Ũ , b, x, y, 20 )
65
65
66
- Ã = sparse (A)
67
- @time qr (Ã );
68
- @time à \ b ;
66
+ Ã = sparse (A)
67
+ @time qr (Ã );
68
+ @time à \ b ;
69
69
70
70
A = randn (n,n)
71
71
@@ -82,98 +82,3 @@ n = 1000;
82
82
lu (A)
83
83
end
84
84
85
- 0.02 * n
86
-
87
- A* x - b
88
-
89
-
90
-
91
- x̃ = 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̃ .= L̃ \ ỹ
108
-
109
-
110
- x - x_bb
111
-
112
- x̃- 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̃ == L
125
- Ũ == U
126
-
127
- norm (A* x - b)
128
- @time
129
-
130
-
131
- @time copy (x)
132
- L̃ = 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 D² = 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