Commit 47d02b7
Specialize norm-related functions for Diagonal (#1457)
For banded matrices such as `Diagonal`, we may skip the non-stored
elements in computing the norm, as the contribution of these would be
zero.
This improves performance.
On master
```julia
julia> D1 = Diagonal(rand(1000));
julia> D2 = Diagonal(rand(1000));
julia> @Btime norm($D1);
2.668 ms (0 allocations: 0 bytes)
julia> @Btime isapprox($D1, $D2);
8.007 ms (3 allocations: 7.88 KiB)
```
vs this PR
```julia
julia> @Btime norm($D1);
247.196 ns (0 allocations: 0 bytes)
julia> @Btime isapprox($D1, $D2);
1.696 μs (0 allocations: 0 bytes)
```
---------
Co-authored-by: Steven G. Johnson <[email protected]>1 parent e367ff1 commit 47d02b7
2 files changed
+36
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1111 | 1111 | | |
1112 | 1112 | | |
1113 | 1113 | | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
1114 | 1131 | | |
1115 | 1132 | | |
1116 | 1133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1576 | 1576 | | |
1577 | 1577 | | |
1578 | 1578 | | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
1579 | 1598 | | |
0 commit comments