Commit bd582f7
authored
Accept axes in Base.checkdims_perm (#55403)
Since `checkdims_perm` only checks the axes of the arrays that are
passed to it, this PR adds a method that accepts the axes as arguments
instead of the arrays. This will avoid having to specialize on array
types.
An example of an improvement:
On master
```julia
julia> using LinearAlgebra
julia> D = Diagonal(zeros(1));
julia> Dv = Diagonal(view(zeros(1),:));
julia> @time @eval permutedims(D, (2,1));
0.016841 seconds (13.68 k allocations: 680.672 KiB, 51.37% compilation time)
julia> @time @eval permutedims(Dv, (2,1));
0.009303 seconds (11.24 k allocations: 564.203 KiB, 97.79% compilation time)
```
This PR
```julia
julia> @time @eval permutedims(D, (2,1));
0.016837 seconds (13.42 k allocations: 667.438 KiB, 51.05% compilation time)
julia> @time @eval permutedims(Dv, (2,1));
0.009076 seconds (6.59 k allocations: 321.156 KiB, 97.46% compilation time)
```
The allocations are lower in the second call.
I've retained the original method as well, as some packages seem to be
using it. This now forwards the axes to the new method.1 parent b43e247 commit bd582f7
File tree
5 files changed
+9
-10
lines changed- base
- stdlib/LinearAlgebra/src
5 files changed
+9
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1669 | 1669 | | |
1670 | 1670 | | |
1671 | 1671 | | |
1672 | | - | |
1673 | | - | |
1674 | | - | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
1675 | 1675 | | |
1676 | | - | |
1677 | 1676 | | |
1678 | 1677 | | |
1679 | 1678 | | |
| |||
1683 | 1682 | | |
1684 | 1683 | | |
1685 | 1684 | | |
1686 | | - | |
| 1685 | + | |
1687 | 1686 | | |
1688 | 1687 | | |
1689 | 1688 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | | - | |
| 285 | + | |
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
745 | 745 | | |
746 | 746 | | |
747 | 747 | | |
748 | | - | |
| 748 | + | |
749 | 749 | | |
750 | 750 | | |
751 | 751 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
642 | | - | |
| 642 | + | |
643 | 643 | | |
644 | 644 | | |
645 | 645 | | |
| |||
0 commit comments