Skip to content

Commit e4d00a4

Browse files
committed
FillArraysExt
1 parent 74c5cfd commit e4d00a4

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ version = "0.3.1"
55

66
[weakdeps]
77
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
8+
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
89
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
910

1011
[extensions]
1112
FunctionImplementationsBlockArraysExt = "BlockArrays"
13+
FunctionImplementationsFillArraysExt = "FillArrays"
1214
FunctionImplementationsLinearAlgebraExt = "LinearAlgebra"
1315

1416
[compat]
1517
BlockArrays = "1.4"
18+
FillArrays = "1.15"
1619
LinearAlgebra = "1.10"
1720
julia = "1.10"
1821

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module FunctionImplementationsFillArraysExt
2+
3+
using FillArrays: RectDiagonal
4+
using FunctionImplementations: FunctionImplementations
5+
6+
function FunctionImplementations.permuteddims(a::RectDiagonal, perm)
7+
(ndims(a) == length(perm) && isperm(perm)) ||
8+
throw(ArgumentError("no valid permutation of dimensions"))
9+
return RectDiagonal(parent(a), ntuple(d -> axes(a)[perm[d]], ndims(a)))
10+
end
11+
12+
end

test/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
33
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
44
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
5+
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
56
FunctionImplementations = "7c7cc465-9c6a-495f-bdd1-f42428e86d0c"
67
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
78
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -16,6 +17,7 @@ FunctionImplementations = {path = ".."}
1617
Adapt = "4"
1718
Aqua = "0.8"
1819
BlockArrays = "1.4"
20+
FillArrays = "1.15"
1921
FunctionImplementations = "0.3"
2022
JLArrays = "0.3"
2123
LinearAlgebra = "1.10"

test/test_permuteddims.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import FillArrays as FA
12
import FunctionImplementations as FI
23
import LinearAlgebra as LA
34
using Test: @test, @testset
@@ -10,9 +11,15 @@ using Test: @test, @testset
1011
@test size(b) == (3, 2)
1112
@test b == permutedims(a, (2, 1))
1213
end
13-
@testset "Diagonal" begin
14+
@testset "LinearAlgebra.Diagonal" begin
1415
a = LA.Diagonal(randn(3))
1516
b = FI.permuteddims(a, (2, 1))
1617
@test b a
1718
end
19+
20+
@testset "FillArrays.RectDiagonal" begin
21+
a = FA.RectDiagonal(randn(3), (3, 4))
22+
@test FI.permuteddims(a, (1, 2)) a
23+
@test FI.permuteddims(a, (2, 1)) FA.RectDiagonal(parent(a), (4, 3))
24+
end
1825
end

0 commit comments

Comments
 (0)