@@ -8,231 +8,231 @@ using Test
88 A = rand (5 , 5 )
99 L = MatrixOperator (A)
1010 L_copy = copy (L)
11-
11+
1212 # Modify original
1313 L. A[1 , 1 ] = 999.0
14-
14+
1515 # Check that copy is not affected
1616 @test L_copy. A[1 , 1 ] != 999.0
1717 @test L_copy. A != L. A
1818 end
19-
19+
2020 # Test DiagonalOperator (which is a MatrixOperator with Diagonal matrix)
2121 @testset " DiagonalOperator" begin
2222 d = rand (5 )
2323 L = DiagonalOperator (d)
2424 L_copy = copy (L)
25-
25+
2626 # Modify original
2727 L. A[1 , 1 ] = 999.0
28-
28+
2929 # Check that copy is not affected
3030 @test L_copy. A[1 , 1 ] != 999.0
3131 @test L_copy. A != L. A
3232 end
33-
33+
3434 # Test ScalarOperator
3535 @testset " ScalarOperator" begin
3636 L = ScalarOperator (2.0 )
3737 L_copy = copy (L)
38-
38+
3939 # Modify original
4040 L. val = 999.0
41-
41+
4242 # Check that copy is not affected
4343 @test L_copy. val == 2.0
4444 end
45-
45+
4646 # Test AffineOperator
4747 @testset " AffineOperator" begin
4848 A = MatrixOperator (rand (5 , 5 ))
4949 B = MatrixOperator (rand (5 , 5 ))
5050 b = rand (5 )
5151 L = AffineOperator (A, B, b)
5252 L_copy = copy (L)
53-
53+
5454 # Modify original
5555 L. b[1 ] = 999.0
5656 L. A. A[1 , 1 ] = 888.0
5757 L. B. A[1 , 1 ] = 777.0
58-
58+
5959 # Check that copy is not affected
6060 @test L_copy. b[1 ] != 999.0
6161 @test L_copy. A. A[1 , 1 ] != 888.0
6262 @test L_copy. B. A[1 , 1 ] != 777.0
6363 end
64-
64+
6565 # Test ComposedOperator
6666 @testset " ComposedOperator" begin
6767 A = MatrixOperator (rand (5 , 5 ))
6868 B = MatrixOperator (rand (5 , 5 ))
6969 L = A ∘ B
7070 L_copy = copy (L)
71-
71+
7272 # Modify original
7373 L. ops[1 ]. A[1 , 1 ] = 999.0
74-
74+
7575 # Check that copy is not affected
7676 @test L_copy. ops[1 ]. A[1 , 1 ] != 999.0
7777 end
78-
78+
7979 # Test InvertedOperator
8080 @testset " InvertedOperator" begin
8181 A = MatrixOperator (rand (5 , 5 ) + 5 I) # Make sure it's invertible
8282 L = inv (A)
8383 L_copy = copy (L)
84-
84+
8585 # Modify original
8686 L. L. A[1 , 1 ] = 999.0
87-
87+
8888 # Check that copy is not affected
8989 @test L_copy. L. A[1 , 1 ] != 999.0
9090 end
91-
91+
9292 # Test TensorProductOperator
9393 @testset " TensorProductOperator" begin
9494 A = MatrixOperator (rand (3 , 3 ))
9595 B = MatrixOperator (rand (2 , 2 ))
9696 L = kron (A, B) # Use kron instead of ⊗
9797 L_copy = copy (L)
98-
98+
9999 # Modify original
100100 L. ops[1 ]. A[1 , 1 ] = 999.0
101-
101+
102102 # Check that copy is not affected
103103 @test L_copy. ops[1 ]. A[1 , 1 ] != 999.0
104104 end
105-
105+
106106 # Test AdjointOperator
107107 @testset " AdjointOperator" begin
108108 A = MatrixOperator (rand (5 , 5 ))
109109 L = SciMLOperators. AdjointOperator (A) # Create AdjointOperator explicitly
110110 L_copy = copy (L)
111-
111+
112112 # Modify original
113113 L. L. A[1 , 1 ] = 999.0
114-
114+
115115 # Check that copy is not affected
116116 @test L_copy. L. A[1 , 1 ] != 999.0
117117 end
118-
118+
119119 # Test TransposedOperator
120120 @testset " TransposedOperator" begin
121121 A = MatrixOperator (rand (5 , 5 ))
122122 L = SciMLOperators. TransposedOperator (A) # Create TransposedOperator explicitly
123123 L_copy = copy (L)
124-
124+
125125 # Modify original
126126 L. L. A[1 , 1 ] = 999.0
127-
127+
128128 # Check that copy is not affected
129129 @test L_copy. L. A[1 , 1 ] != 999.0
130130 end
131-
131+
132132 # Test AddedScalarOperator
133133 @testset " AddedScalarOperator" begin
134134 α = ScalarOperator (2.0 )
135135 β = ScalarOperator (3.0 )
136136 L = α + β
137137 L_copy = copy (L)
138-
138+
139139 # Modify original
140140 L. ops[1 ]. val = 999.0
141-
141+
142142 # Check that copy is not affected
143143 @test L_copy. ops[1 ]. val == 2.0
144144 end
145-
145+
146146 # Test ComposedScalarOperator
147147 @testset " ComposedScalarOperator" begin
148148 α = ScalarOperator (2.0 )
149149 β = ScalarOperator (3.0 )
150150 L = α * β
151151 L_copy = copy (L)
152-
152+
153153 # Modify original
154154 L. ops[1 ]. val = 999.0
155-
155+
156156 # Check that copy is not affected
157157 @test L_copy. ops[1 ]. val == 2.0
158158 end
159-
159+
160160 # Test InvertedScalarOperator
161161 @testset " InvertedScalarOperator" begin
162162 α = ScalarOperator (2.0 )
163163 L = inv (α)
164164 L_copy = copy (L)
165-
165+
166166 # Modify original
167167 L. λ. val = 999.0
168-
168+
169169 # Check that copy is not affected
170170 @test L_copy. λ. val == 2.0
171171 end
172-
172+
173173 # Test IdentityOperator (should return self)
174174 @testset " IdentityOperator" begin
175175 L = IdentityOperator (5 )
176176 L_copy = copy (L)
177-
177+
178178 # Should be the same object since it's immutable
179179 @test L === L_copy
180180 end
181-
181+
182182 # Test NullOperator (should return self)
183183 @testset " NullOperator" begin
184184 L = NullOperator (5 )
185185 L_copy = copy (L)
186-
186+
187187 # Should be the same object since it's immutable
188188 @test L === L_copy
189189 end
190-
190+
191191 # Test InvertibleOperator
192192 @testset " InvertibleOperator" begin
193193 A = rand (5 , 5 ) + 5 I # Make sure it's invertible
194194 M = MatrixOperator (A)
195195 F = lu (A)
196196 L = InvertibleOperator (M, F)
197197 L_copy = copy (L)
198-
198+
199199 # Modify original
200200 L. L. A[1 , 1 ] = 999.0
201-
201+
202202 # Check that copy is not affected
203203 @test L_copy. L. A[1 , 1 ] != 999.0
204204 end
205-
205+
206206 # Test ScaledOperator
207207 @testset " ScaledOperator" begin
208208 α = ScalarOperator (2.0 )
209209 A = MatrixOperator (rand (5 , 5 ))
210210 L = α * A
211211 L_copy = copy (L)
212-
212+
213213 # Modify original
214214 L. λ. val = 999.0
215215 L. L. A[1 , 1 ] = 888.0
216-
216+
217217 # Check that copy is not affected
218218 @test L_copy. λ. val == 2.0
219219 @test L_copy. L. A[1 , 1 ] != 888.0
220220 end
221-
221+
222222 # Test AddedOperator
223223 @testset " AddedOperator" begin
224224 A = MatrixOperator (rand (5 , 5 ))
225225 B = MatrixOperator (rand (5 , 5 ))
226226 L = A + B
227227 L_copy = copy (L)
228-
228+
229229 # Modify original
230230 L. ops[1 ]. A[1 , 1 ] = 999.0
231-
231+
232232 # Check that copy is not affected
233233 @test L_copy. ops[1 ]. A[1 , 1 ] != 999.0
234234 end
235-
235+
236236 # Test that operators still work correctly after copying
237237 @testset " Functionality after copy" begin
238238 # MatrixOperator
@@ -241,22 +241,22 @@ using Test
241241 L_copy = copy (L)
242242 v = rand (5 )
243243 @test L * v ≈ L_copy * v
244-
244+
245245 # ScalarOperator
246246 α = ScalarOperator (2.0 )
247247 α_copy = copy (α)
248248 @test α * v ≈ α_copy * v
249-
249+
250250 # ComposedOperator
251251 B = MatrixOperator (rand (5 , 5 ))
252252 comp = L ∘ B
253253 comp_copy = copy (comp)
254254 @test comp * v ≈ comp_copy * v
255-
255+
256256 # AffineOperator
257257 b = rand (5 )
258258 aff = AffineOperator (L, B, b)
259259 aff_copy = copy (aff)
260260 @test aff * v ≈ aff_copy * v
261261 end
262- end
262+ end
0 commit comments