Skip to content

Commit d4f74a8

Browse files
committed
Add some tests
1 parent 8ec022f commit d4f74a8

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

test/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[deps]
22
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3+
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
34
KroneckerArrays = "05d0b138-81bc-4ff7-84be-08becefb1ccc"
45
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
56
MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4"
@@ -9,6 +10,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
910

1011
[compat]
1112
Aqua = "0.8"
13+
FillArrays = "1"
1214
KroneckerArrays = "0.1"
1315
LinearAlgebra = "1.10"
1416
MatrixAlgebraKit = "0.2"

test/test_matrixalgebrakit.jl

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
using FillArrays: Eye
12
using KroneckerArrays:
2-
using LinearAlgebra: Hermitian, I, diag, norm
3+
using LinearAlgebra: Hermitian, I, diag, hermitianpart, norm
34
using MatrixAlgebraKit:
45
eig_full,
56
eig_trunc,
@@ -23,28 +24,35 @@ using MatrixAlgebraKit:
2324
svd_vals
2425
using Test: @test, @test_throws, @testset
2526

27+
herm(a) = hermitianpart(a).data
28+
2629
@testset "MatrixAlgebraKit" begin
2730
elt = Float32
2831

2932
a = randn(elt, 2, 2) randn(elt, 3, 3)
3033
d, v = eig_full(a)
3134
@test a * v v * d
3235

36+
a = randn(elt, 2, 2) Eye(3)
37+
d, v = eig_full(a)
38+
@test d.b == v.b == Eye(3)
39+
@test a * v v * d
40+
3341
a = randn(elt, 2, 2) randn(elt, 3, 3)
3442
@test_throws MethodError eig_trunc(a)
3543

3644
a = randn(elt, 2, 2) randn(elt, 3, 3)
3745
d = eig_vals(a)
3846
@test d diag(eig_full(a)[1])
3947

40-
a = Hermitian(randn(elt, 2, 2)) Hermitian(randn(elt, 3, 3))
48+
a = herm(randn(elt, 2, 2)) herm(randn(elt, 3, 3))
4149
d, v = eigh_full(a)
4250
@test a * v v * d
4351

44-
a = Hermitian(randn(elt, 2, 2)) Hermitian(randn(elt, 3, 3))
52+
a = herm(randn(elt, 2, 2)) herm(randn(elt, 3, 3))
4553
@test_throws MethodError eigh_trunc(a)
4654

47-
a = Hermitian(randn(elt, 2, 2)) Hermitian(randn(elt, 3, 3))
55+
a = herm(randn(elt, 2, 2)) herm(randn(elt, 3, 3))
4856
d = eigh_vals(a)
4957
@test d diag(eigh_full(a)[1])
5058

@@ -102,6 +110,11 @@ using Test: @test, @test_throws, @testset
102110
@test collect(u'u) I
103111
@test collect(v * v') I
104112

113+
a = randn(elt, 2, 2) Eye(3)
114+
u, s, v = svd_compact(a)
115+
@test u * s * v a
116+
@test u.b == s.b == v.b == Eye(3)
117+
105118
a = randn(elt, 2, 2) randn(elt, 3, 3)
106119
u, s, v = svd_full(a)
107120
@test u * s * v a

0 commit comments

Comments
 (0)