Skip to content

Commit 92adef9

Browse files
committed
Add a rudimentary precompile workload
1 parent a1d5464 commit 92adef9

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ authors = ["Jutho Haegeman <jutho.haegeman@ugent.be>, Lukas Devos, Katharine Hya
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
8+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
89

910
[weakdeps]
1011
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
@@ -35,6 +36,7 @@ EnzymeTestUtils = "0.2.5"
3536
GenericLinearAlgebra = "0.3.19, 0.4"
3637
GenericSchur = "0.5.6"
3738
LinearAlgebra = "1"
39+
PrecompileTools = "1"
3840
Mooncake = "0.5.27"
3941
ParallelTestRunner = "2"
4042
Random = "1"

src/MatrixAlgebraKit.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,6 @@ include("pullbacks/eigh.jl")
129129
include("pullbacks/svd.jl")
130130
include("pullbacks/polar.jl")
131131

132+
include("precompile.jl")
133+
132134
end

src/precompile.jl

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using PrecompileTools: @compile_workload
2+
3+
@compile_workload begin
4+
truncation_strategies = [
5+
truncrank(2), trunctol(; atol = 1.0e-2), truncrank(2) & trunctol(; atol = 1.0e-2), truncerror(; atol = 1.0e-2) | truncfilter(x -> abs(x) < 1.0e-2),
6+
]
7+
for T in (Float32, Float64, ComplexF32, ComplexF64)
8+
A = diagm(ones(T, 4)) # 4×4 Matrix{T}, Hermitian, nonsingular
9+
Atall = rand(T, 4, 2)
10+
Awide = rand(T, 2, 4)
11+
12+
# decompositions
13+
# --------------
14+
qr_compact(A)
15+
qr_full(Atall)
16+
qr_null(Atall)
17+
18+
lq_compact(A)
19+
lq_full(Awide)
20+
lq_null(Awide)
21+
22+
svd_compact(A)
23+
svd_full(A)
24+
svd_vals(A)
25+
26+
schur_full(A)
27+
schur_vals(A)
28+
29+
eigh_full(A)
30+
eigh_vals(A)
31+
32+
eig_full(A)
33+
eig_vals(A)
34+
35+
gen_eig_full(A, A)
36+
gen_eig_vals(A, A)
37+
38+
left_polar(A)
39+
right_polar(A)
40+
41+
# derived decompositions
42+
left_orth(A)
43+
left_null(A)
44+
right_orth(A)
45+
right_null(A)
46+
47+
# truncated decompositions
48+
for trunc in truncation_strategies
49+
svd_trunc(A; trunc)
50+
eigh_trunc(A; trunc)
51+
eig_trunc(A; trunc)
52+
end
53+
left_orth(A; trunc = truncrank(2))
54+
right_orth(A; trunc = truncrank(2))
55+
56+
# projections
57+
project_hermitian(A)
58+
project_antihermitian(A)
59+
project_isometric(A)
60+
61+
# properties
62+
isisometric(A)
63+
isunitary(A)
64+
ishermitian(A)
65+
isantihermitian(A)
66+
end
67+
end

0 commit comments

Comments
 (0)