@@ -10,12 +10,9 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
10
10
n0, n1, n2 = rand (), rand (), rand ()
11
11
x0, x1, x2 = rand (k), rand (k, k), rand (k, k, k)
12
12
s0, s1, s2 = SVector {k} (rand (k)), SMatrix {k,k} (rand (k, k)), SArray {Tuple{k,k,k}} (rand (k, k, k))
13
- m0, m1, m2 = MVector {k} (rand (k)), MMatrix {k,k} (rand (k, k)), MArray {Tuple{k,k,k}} (rand (k, k, k))
14
-
15
13
rn = DiffResult (n0, n1, n2)
16
14
rx = DiffResult (x0, x1, x2)
17
15
rs = DiffResult (s0, s1, s2)
18
- rm = DiffResult (m0, m1, m2)
19
16
rsmix = DiffResult (n0, s0, s1)
20
17
21
18
issimilar (x, y) = typeof (x) == typeof (y) && size (x) == size (y)
@@ -25,7 +22,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
25
22
@test rn === DiffResult (n0, n1, n2)
26
23
@test rx == DiffResult (x0, x1, x2)
27
24
@test rs === DiffResult (s0, s1, s2)
28
- @test rm == DiffResult (m0, m1, m2)
29
25
@test rsmix === DiffResult (n0, s0, s1)
30
26
31
27
@test issimilar (GradientResult (x0), DiffResult (first (x0), x0))
@@ -38,15 +34,9 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
38
34
@test JacobianResult (SVector {k+1} (vcat (s0, 0.0 )), s0) === DiffResult (SVector {k+1} (vcat (s0, 0.0 )), zeros (SMatrix{k+ 1 ,k,Float64}))
39
35
@test HessianResult (s0) === DiffResult (first (s0), s0, zeros (SMatrix{k,k,Float64}))
40
36
41
- @test issimilar (GradientResult (m0), DiffResult (first (m0), m0))
42
- @test issimilar (JacobianResult (m0), DiffResult (m0, zeros (MMatrix{k,k,Float64})))
43
- @test issimilar (JacobianResult (MVector {k + 1} (vcat (m0, 0.0 )), m0), DiffResult (MVector {k + 1} (vcat (m0, 0.0 )), zeros (MMatrix{k + 1 ,k,Float64})))
44
- @test issimilar (HessianResult (m0), DiffResult (first (m0), m0, zeros (MMatrix{k,k,Float64})))
45
-
46
37
@test eltype (rn) === typeof (n0)
47
38
@test eltype (rx) === eltype (x0)
48
39
@test eltype (rs) === eltype (s0)
49
- @test eltype (rm) === eltype (m0)
50
40
51
41
rn_copy = copy (rn)
52
42
@test rn == rn_copy
@@ -60,10 +50,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
60
50
@test rs == rs_copy
61
51
@test rs === rs_copy
62
52
63
- rm_copy = copy (rm)
64
- @test rm == rm_copy
65
- @test rm != = rm_copy
66
-
67
53
rsmix_copy = copy (rsmix)
68
54
@test rsmix == rsmix_copy
69
55
@test rsmix === rsmix_copy
@@ -73,7 +59,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
73
59
@test value (rn) === n0
74
60
@test value (rx) === x0
75
61
@test value (rs) === s0
76
- @test value (rm) === m0
77
62
@test value (rsmix) === n0
78
63
79
64
rn = value! (rn, n1)
@@ -91,11 +76,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
91
76
@test typeof (value (rs)) === typeof (s0)
92
77
rs = value! (rs, s0)
93
78
94
- m0_new, m0_copy = rand (k), copy (m0)
95
- rm = value! (rm, m0_new)
96
- @test value (rm) === m0 == m0_new
97
- rm = value! (rm, m0_copy)
98
-
99
79
rsmix = value! (rsmix, n1)
100
80
@test value (rsmix) === n1
101
81
rsmix = value! (rsmix, n0)
@@ -115,11 +95,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
115
95
@test typeof (value (rs)) === typeof (s0)
116
96
rs = value! (rs, s0)
117
97
118
- m0_new, m0_copy = rand (k), copy (m0)
119
- rm = value! (exp, rm, m0_new)
120
- @test value (rm) === m0 == exp .(m0_new)
121
- rm = value! (rm, m0_copy)
122
-
123
98
rsmix = value! (exp, rsmix, n1)
124
99
@test value (rsmix) === exp (n1)
125
100
rsmix = value! (rsmix, n0)
@@ -141,9 +116,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
141
116
@test derivative (rs) === s1
142
117
@test derivative (rs, Val{2 }) === s2
143
118
144
- @test derivative (rm) === m1
145
- @test derivative (rm, Val{2 }) === m2
146
-
147
119
@test derivative (rsmix) === s0
148
120
@test derivative (rsmix, Val{2 }) === s1
149
121
@@ -168,11 +140,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
168
140
@test typeof (derivative (rsmix)) === typeof (s0)
169
141
rsmix = derivative! (rsmix, s0)
170
142
171
- m1_new, m1_copy = rand (k, k), copy (m1)
172
- rm = derivative! (rm, m1_new)
173
- @test derivative (rm) === m1 == m1_new
174
- rm = derivative! (rm, m1_copy)
175
-
176
143
rn = derivative! (rn, n1, Val{2 })
177
144
@test derivative (rn, Val{2 }) === n1
178
145
rn = derivative! (rn, n2, Val{2 })
@@ -194,11 +161,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
194
161
@test typeof (derivative (rsmix, Val{2 })) === typeof (s1)
195
162
rsmix = derivative! (rsmix, s1, Val{2 })
196
163
197
- m2_new, m2_copy = rand (k, k, k), copy (m2)
198
- rm = derivative! (rm, m2_new, Val{2 })
199
- @test derivative (rm, Val{2 }) === m2 == m2_new
200
- rm = derivative! (rm, m2_copy, Val{2 })
201
-
202
164
rn = derivative! (exp, rn, n0)
203
165
@test derivative (rn) === exp (n0)
204
166
rn = derivative! (rn, n1)
@@ -220,11 +182,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
220
182
@test typeof (derivative (rsmix)) === typeof (s0)
221
183
rsmix = derivative! (exp, rsmix, s0)
222
184
223
- m1_new, m1_copy = rand (k, k), copy (m1)
224
- rm = derivative! (exp, rm, m1_new)
225
- @test derivative (rm) === m1 == exp .(m1_new)
226
- rm = derivative! (exp, rm, m1_copy)
227
-
228
185
rn = derivative! (exp, rn, n1, Val{2 })
229
186
@test derivative (rn, Val{2 }) === exp (n1)
230
187
rn = derivative! (rn, n2, Val{2 })
@@ -245,11 +202,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
245
202
@test derivative (rsmix, Val{2 }) == exp .(s1_new)
246
203
@test typeof (derivative (rsmix, Val{2 })) === typeof (s1)
247
204
rsmix = derivative! (exp, rsmix, s1, Val{2 })
248
-
249
- m2_new, m2_copy = rand (k, k, k), copy (m2)
250
- rm = derivative! (exp, rm, m2_new, Val{2 })
251
- @test derivative (rm, Val{2 }) === m2 == exp .(m2_new)
252
- rm = derivative! (exp, rm, m2_copy, Val{2 })
253
205
end
254
206
255
207
@testset " gradient/gradient!" begin
@@ -265,11 +217,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
265
217
@test typeof (gradient (rs)) === typeof (s1)
266
218
rs = gradient! (rs, s1)
267
219
268
- m1_new, m1_copy = rand (k, k), copy (m1)
269
- rm = gradient! (rm, m1_new)
270
- @test gradient (rm) === m1 == m1_new
271
- rm = gradient! (rm, m1_copy)
272
-
273
220
x1_new, x1_copy = rand (k, k), copy (x1)
274
221
rx = gradient! (exp, rx, x1_new)
275
222
@test gradient (rx) === x1 == exp .(x1_new)
@@ -281,11 +228,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
281
228
@test typeof (gradient (rsmix)) === typeof (s0)
282
229
rsmix = gradient! (exp, rsmix, s0)
283
230
284
- m1_new, m1_copy = rand (k, k), copy (m1)
285
- rm = gradient! (exp, rm, m1_new)
286
- @test gradient (rm) === m1 == exp .(m1_new)
287
- rm = gradient! (exp, rm, m1_copy)
288
-
289
231
T = typeof (SVector {k*k} (rand (k* k)))
290
232
rs_new = gradient! (rs, convert (T, gradient (rs)))
291
233
@test rs_new === rs
@@ -304,11 +246,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
304
246
@test typeof (jacobian (rs)) === typeof (s1)
305
247
rs = jacobian! (rs, s1)
306
248
307
- m1_new, m1_copy = rand (k, k), copy (m1)
308
- rm = jacobian! (rm, m1_new)
309
- @test jacobian (rm) === m1 == m1_new
310
- rm = jacobian! (rm, m1_copy)
311
-
312
249
x1_new, x1_copy = rand (k, k), copy (x1)
313
250
rx = jacobian! (exp, rx, x1_new)
314
251
@test jacobian (rx) === x1 == exp .(x1_new)
@@ -320,11 +257,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
320
257
@test typeof (jacobian (rsmix)) === typeof (s0)
321
258
rsmix = jacobian! (exp, rsmix, s0)
322
259
323
- m1_new, m1_copy = rand (k, k), copy (m1)
324
- rm = jacobian! (exp, rm, m1_new)
325
- @test jacobian (rm) === m1 == exp .(m1_new)
326
- rm = jacobian! (exp, rm, m1_copy)
327
-
328
260
T = typeof (SVector {k*k} (rand (k* k)))
329
261
rs_new = jacobian! (rs, convert (T, jacobian (rs)))
330
262
@test rs_new === rs
@@ -343,11 +275,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
343
275
@test typeof (hessian (rs)) === typeof (s2)
344
276
rs = hessian! (rs, s2)
345
277
346
- m2_new, m2_copy = rand (k, k, k), copy (m2)
347
- rm = hessian! (rm, m2_new)
348
- @test hessian (rm) === m2 == m2_new
349
- rm = hessian! (rm, m2_copy)
350
-
351
278
x2_new, x2_copy = rand (k, k, k), copy (x2)
352
279
rx = hessian! (exp, rx, x2_new)
353
280
@test hessian (rx) === x2 == exp .(x2_new)
@@ -359,11 +286,6 @@ using DiffResults: DiffResult, GradientResult, JacobianResult, HessianResult,
359
286
@test typeof (hessian (rsmix)) === typeof (s1)
360
287
rsmix = hessian! (exp, rsmix, s1)
361
288
362
- m2_new, m2_copy = rand (k, k, k), copy (m2)
363
- rm = hessian! (exp, rm, m2_new)
364
- @test hessian (rm) === m2 == exp .(m2_new)
365
- rm = hessian! (exp, rm, m2_copy)
366
-
367
289
T = typeof (SVector {k*k*k} (rand (k* k* k)))
368
290
rs_new = hessian! (rs, convert (T, hessian (rs)))
369
291
@test rs_new === rs
0 commit comments