Commit ea8e858
authored
Test Diagonal functions against non-dense matrices (#1316)
In the `Diagonal` tests, we often compare results of function
evaluations with that for the corresponding dense matrix. E.g., with `D
= Diagonal(::Vector)` and `DM = Matrix(D)`,
```julia
@test log(Diagonal(abs.(D.diag))) ≈ log(abs.(DM)) atol=n^3*eps(relty)
```
The problem with this is that, in the dense method `log(::Matrix)`, we
check if the matrix is diagonal, and dispatch to the `Diagonal` methods
for performance. This makes this test useless, as we are comparing
identical methods.
In this PR, I've changed the type of `DM` to be `Hermitian` for real
matrices, and `UpperTriangular` for complex ones. Both of these types
have special methods for `log`, at least. The `Hermitian` matrices have
special methods for all the trigonometric functions, and for the complex
matrices, we wrap these in a custom wrapper `NotDiagonal` that avoids
the `isdiag` paths. This wrapper lies about the structure, but it should
be ok for the testing purposes as we ensure that we are comparing
different paths.1 parent 2d35f07 commit ea8e858
1 file changed
+23
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
30 | 41 | | |
31 | 42 | | |
32 | 43 | | |
| |||
37 | 48 | | |
38 | 49 | | |
39 | 50 | | |
40 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
41 | 57 | | |
42 | 58 | | |
43 | 59 | | |
44 | | - | |
| 60 | + | |
45 | 61 | | |
46 | | - | |
| 62 | + | |
47 | 63 | | |
48 | 64 | | |
49 | 65 | | |
| |||
83 | 99 | | |
84 | 100 | | |
85 | 101 | | |
86 | | - | |
87 | | - | |
88 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
89 | 105 | | |
90 | 106 | | |
91 | 107 | | |
| |||
227 | 243 | | |
228 | 244 | | |
229 | 245 | | |
230 | | - | |
| 246 | + | |
231 | 247 | | |
232 | 248 | | |
233 | 249 | | |
| |||
0 commit comments