@@ -101,57 +101,58 @@ def test_NormalEquationsInversion(par):
101101 )
102102 y = Gop * x
103103
104- # normal equations with regularization
105- xinv = normal_equations_inversion (
106- Gop ,
107- y ,
108- [Reg ],
109- epsI = 1e-5 ,
110- epsRs = [1e-8 ],
111- x0 = x0 ,
112- engine = "pylops" ,
113- ** dict (niter = 200 , tol = 1e-10 )
114- )[0 ]
115- assert_array_almost_equal (x , xinv , decimal = 3 )
116- # normal equations with weight
117- xinv = normal_equations_inversion (
118- Gop ,
119- y ,
120- None ,
121- Weight = Weigth ,
122- epsI = 1e-5 ,
123- x0 = x0 ,
124- engine = "pylops" ,
125- ** dict (niter = 200 , tol = 1e-10 )
126- )[0 ]
127- assert_array_almost_equal (x , xinv , decimal = 3 )
128- # normal equations with weight and small regularization
129- xinv = normal_equations_inversion (
130- Gop ,
131- y ,
132- [Reg ],
133- Weight = Weigth ,
134- epsI = 1e-5 ,
135- epsRs = [1e-8 ],
136- x0 = x0 ,
137- engine = "pylops" ,
138- ** dict (niter = 200 , tol = 1e-10 )
139- )[0 ]
140- assert_array_almost_equal (x , xinv , decimal = 3 )
141- # normal equations with weight and small normal regularization
142- xinv = normal_equations_inversion (
143- Gop ,
144- y ,
145- [],
146- NRegs = [NReg ],
147- Weight = Weigth ,
148- epsI = 1e-5 ,
149- epsNRs = [1e-8 ],
150- x0 = x0 ,
151- engine = "pylops" ,
152- ** dict (niter = 200 , tol = 1e-10 )
153- )[0 ]
154- assert_array_almost_equal (x , xinv , decimal = 3 )
104+ for preallocate in [False , True ]:
105+ # normal equations with regularization
106+ xinv = normal_equations_inversion (
107+ Gop ,
108+ y ,
109+ [Reg ],
110+ epsI = 1e-5 ,
111+ epsRs = [1e-8 ],
112+ x0 = x0 ,
113+ engine = "pylops" ,
114+ ** dict (niter = 200 , tol = 1e-10 , preallocate = preallocate )
115+ )[0 ]
116+ assert_array_almost_equal (x , xinv , decimal = 3 )
117+ # normal equations with weight
118+ xinv = normal_equations_inversion (
119+ Gop ,
120+ y ,
121+ None ,
122+ Weight = Weigth ,
123+ epsI = 1e-5 ,
124+ x0 = x0 ,
125+ engine = "pylops" ,
126+ ** dict (niter = 200 , tol = 1e-10 , preallocate = preallocate )
127+ )[0 ]
128+ assert_array_almost_equal (x , xinv , decimal = 3 )
129+ # normal equations with weight and small regularization
130+ xinv = normal_equations_inversion (
131+ Gop ,
132+ y ,
133+ [Reg ],
134+ Weight = Weigth ,
135+ epsI = 1e-5 ,
136+ epsRs = [1e-8 ],
137+ x0 = x0 ,
138+ engine = "pylops" ,
139+ ** dict (niter = 200 , tol = 1e-10 , preallocate = preallocate )
140+ )[0 ]
141+ assert_array_almost_equal (x , xinv , decimal = 3 )
142+ # normal equations with weight and small normal regularization
143+ xinv = normal_equations_inversion (
144+ Gop ,
145+ y ,
146+ [],
147+ NRegs = [NReg ],
148+ Weight = Weigth ,
149+ epsI = 1e-5 ,
150+ epsNRs = [1e-8 ],
151+ x0 = x0 ,
152+ engine = "pylops" ,
153+ ** dict (niter = 200 , tol = 1e-10 , preallocate = preallocate )
154+ )[0 ]
155+ assert_array_almost_equal (x , xinv , decimal = 3 )
155156
156157
157158@pytest .mark .parametrize (
@@ -175,40 +176,41 @@ def test_RegularizedInversion(par):
175176 )
176177 y = Gop * x
177178
178- # regularized inversion with regularization
179- xinv = regularized_inversion (
180- Gop ,
181- y ,
182- [Reg ],
183- epsRs = [1e-8 ],
184- x0 = x0 ,
185- engine = "pylops" ,
186- ** dict (damp = 0 , niter = 200 , show = 0 )
187- )[0 ]
188- assert_array_almost_equal (x , xinv , decimal = 3 )
189- # regularized inversion with weight
190- xinv = regularized_inversion (
191- Gop ,
192- y ,
193- None ,
194- Weight = Weigth ,
195- x0 = x0 ,
196- engine = "pylops" ,
197- ** dict (damp = 0 , niter = 200 , show = 0 )
198- )[0 ]
199- assert_array_almost_equal (x , xinv , decimal = 3 )
200- # regularized inversion with regularization
201- xinv = regularized_inversion (
202- Gop ,
203- y ,
204- [Reg ],
205- Weight = Weigth ,
206- epsRs = [1e-8 ],
207- x0 = x0 ,
208- engine = "pylops" ,
209- ** dict (damp = 0 , niter = 200 , show = 0 )
210- )[0 ]
211- assert_array_almost_equal (x , xinv , decimal = 3 )
179+ for preallocate in [False , True ]:
180+ # regularized inversion with regularization
181+ xinv = regularized_inversion (
182+ Gop ,
183+ y ,
184+ [Reg ],
185+ epsRs = [1e-8 ],
186+ x0 = x0 ,
187+ engine = "pylops" ,
188+ ** dict (damp = 0 , niter = 200 , preallocate = preallocate )
189+ )[0 ]
190+ assert_array_almost_equal (x , xinv , decimal = 3 )
191+ # regularized inversion with weight
192+ xinv = regularized_inversion (
193+ Gop ,
194+ y ,
195+ None ,
196+ Weight = Weigth ,
197+ x0 = x0 ,
198+ engine = "pylops" ,
199+ ** dict (damp = 0 , niter = 200 , preallocate = preallocate )
200+ )[0 ]
201+ assert_array_almost_equal (x , xinv , decimal = 3 )
202+ # regularized inversion with regularization
203+ xinv = regularized_inversion (
204+ Gop ,
205+ y ,
206+ [Reg ],
207+ Weight = Weigth ,
208+ epsRs = [1e-8 ],
209+ x0 = x0 ,
210+ engine = "pylops" ,
211+ ** dict (damp = 0 , niter = 200 , preallocate = preallocate )
212+ )[0 ]
213+ assert_array_almost_equal (x , xinv , decimal = 3 )
212214
213215
214216@pytest .mark .parametrize (
@@ -230,13 +232,24 @@ def test_WeightedInversion(par):
230232 x = np .ones (par ["nx" ]) + par ["imag" ] * np .ones (par ["nx" ])
231233 y = Gop * x
232234
233- xne = normal_equations_inversion (
234- Gop , y , None , Weight = Weigth , engine = "pylops" , ** dict (niter = 5 , tol = 1e-10 )
235- )[0 ]
236- xreg = regularized_inversion (
237- Gop , y , None , Weight = Weigth1 , engine = "pylops" , ** dict (damp = 0 , niter = 5 , show = 0 )
238- )[0 ]
239- assert_array_almost_equal (xne , xreg , decimal = 3 )
235+ for preallocate in [False , True ]:
236+ xne = normal_equations_inversion (
237+ Gop ,
238+ y ,
239+ None ,
240+ Weight = Weigth ,
241+ engine = "pylops" ,
242+ ** dict (niter = 5 , tol = 1e-10 , preallocate = preallocate )
243+ )[0 ]
244+ xreg = regularized_inversion (
245+ Gop ,
246+ y ,
247+ None ,
248+ Weight = Weigth1 ,
249+ engine = "pylops" ,
250+ ** dict (damp = 0 , niter = 5 , preallocate = preallocate )
251+ )[0 ]
252+ assert_array_almost_equal (xne , xreg , decimal = 3 )
240253
241254
242255@pytest .mark .parametrize (
@@ -260,10 +273,17 @@ def test_PreconditionedInversion(par):
260273 else None
261274 )
262275 y = Gop * x
263- xinv = preconditioned_inversion (
264- Gop , y , Pre , x0 = x0 , engine = "pylops" , ** dict (damp = 0 , niter = 800 , show = 0 )
265- )[0 ]
266- assert_array_almost_equal (x , xinv , decimal = 2 )
276+
277+ for preallocate in [False , True ]:
278+ xinv = preconditioned_inversion (
279+ Gop ,
280+ y ,
281+ Pre ,
282+ x0 = x0 ,
283+ engine = "pylops" ,
284+ ** dict (damp = 0 , niter = 800 , preallocate = preallocate )
285+ )[0 ]
286+ assert_array_almost_equal (x , xinv , decimal = 2 )
267287
268288
269289@pytest .mark .parametrize ("par" , [(par1 )])
@@ -279,8 +299,23 @@ def test_skinnyregularization(par):
279299 x = np .arange (par ["nx" ] - 1 )
280300 y = Dop * x
281301
282- xinv = normal_equations_inversion (Dop , y , [Regop ], epsRs = [1e-4 ], engine = "pylops" )[0 ]
283- assert_array_almost_equal (x , xinv , decimal = 2 )
302+ for preallocate in [False , True ]:
303+ xinv = normal_equations_inversion (
304+ Dop ,
305+ y ,
306+ [Regop ],
307+ epsRs = [1e-4 ],
308+ engine = "pylops" ,
309+ ** dict (preallocate = preallocate )
310+ )[0 ]
311+ assert_array_almost_equal (x , xinv , decimal = 2 )
284312
285- xinv = regularized_inversion (Dop , y , [Regop ], epsRs = [1e-4 ], engine = "pylops" )[0 ]
286- assert_array_almost_equal (x , xinv , decimal = 2 )
313+ xinv = regularized_inversion (
314+ Dop ,
315+ y ,
316+ [Regop ],
317+ epsRs = [1e-4 ],
318+ engine = "pylops" ,
319+ ** dict (preallocate = preallocate )
320+ )[0 ]
321+ assert_array_almost_equal (x , xinv , decimal = 2 )
0 commit comments