Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RotationGenerator and its subtypes #203

Merged
merged 29 commits into from
Jan 13, 2022
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
034e2f6
add infinitesimal rotations
hyrodium Nov 20, 2021
0c52741
update log with InfinitesimalRotation
hyrodium Nov 14, 2021
498cb1c
rename log.jl to logexp.jl, and fix tests
hyrodium Nov 20, 2021
b3d2268
update infinitesimal
hyrodium Nov 20, 2021
20a53e0
add tests for infinitesimal rotations
hyrodium Nov 20, 2021
bda9f38
update tests for infinitesimal
hyrodium Nov 20, 2021
f19e191
update src for infinitesimal
hyrodium Nov 20, 2021
6106e07
fix typo
hyrodium Nov 20, 2021
6e0e149
add tests for error
hyrodium Nov 20, 2021
fa141fb
update Base.:-
hyrodium Nov 20, 2021
2c22177
add tests for type promotion
hyrodium Nov 20, 2021
c6bd658
update tests
hyrodium Nov 20, 2021
95bcb18
update Base.ones
hyrodium Nov 20, 2021
500a2d9
update tests
hyrodium Nov 20, 2021
b3aa8c0
update comments
hyrodium Nov 20, 2021
faa2b8a
update export
hyrodium Nov 20, 2021
377294d
fix type parameter in test
hyrodium Nov 20, 2021
173c282
update tests
hyrodium Nov 20, 2021
71de499
add Base.:/(r::InfinitesimalRotation, t::Number)
hyrodium Nov 20, 2021
a859beb
update comments
hyrodium Nov 20, 2021
c6ce5cb
update 2d infinitesimal rotation
hyrodium Nov 20, 2021
af3f7b2
update tests
hyrodium Nov 20, 2021
4faa473
update tests
hyrodium Nov 20, 2021
50e98b3
rename InfinitesimalRotation to RotationGenerator
hyrodium Nov 22, 2021
77b10f1
rename files
hyrodium Nov 22, 2021
aaf529d
add test fot exp(::RotMatrixGenerator)::RotMatrix
hyrodium Nov 22, 2021
c133d83
fix for exp(::RotMatrixGenerator)::RotMatrix
hyrodium Nov 22, 2021
89d6a39
update tests to remove rand method
hyrodium Nov 22, 2021
b55c9ee
remove unnecessary Base.promote_op method
hyrodium Nov 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update tests
  • Loading branch information
hyrodium committed Nov 20, 2021
commit 173c282f733724569e2e0cc1fd2cb0b1c727f944
65 changes: 65 additions & 0 deletions test/infinitesimal.jl
Original file line number Diff line number Diff line change
@@ -4,12 +4,23 @@
types_2d = (InfinitesimalRotMatrix{2}, InfinitesimalAngle2d)
types_3d = (InfinitesimalRotMatrix{3}, InfinitesimalRotationVec)

@testset "constructor" begin
m = rand(3,3)
s1 = InfinitesimalRotMatrix{3}(m - m')
s2 = InfinitesimalRotMatrix{3, BigFloat}(m - m')
@test s1 isa InfinitesimalRotMatrix{3, Float64}
@test s2 isa InfinitesimalRotMatrix{3, BigFloat}
end

@testset "zero" begin
for T in all_types
r = zero(T)
@test r isa InfinitesimalRotation
@test r === zero(r)
@test zeros(T,2,3) == [zero(T) for i in 1:2, j in 1:3]
@test zeros(T{BigFloat},2,3) == [zero(T{BigFloat}) for i in 1:2, j in 1:3]
@test zeros(T,(2,3)) == [zero(T) for i in 1:2, j in 1:3]
@test zeros(T{BigFloat},(2,3)) == [zero(T{BigFloat}) for i in 1:2, j in 1:3]
end
end

@@ -19,6 +30,19 @@
@test r isa SMatrix
@test r == one(r)
@test ones(T,2,3) == [one(T) for i in 1:2, j in 1:3]
@test ones(T{BigFloat},2,3) == [one(T{BigFloat}) for i in 1:2, j in 1:3]
@test ones(T,(2,3)) == [one(T) for i in 1:2, j in 1:3]
@test ones(T{BigFloat},(2,3)) == [one(T{BigFloat}) for i in 1:2, j in 1:3]
end

for T in types_2d
r = one(T{BigFloat})
@test r isa SMatrix{2,2,BigFloat}
end

for T in types_3d
r = one(T{BigFloat})
@test r isa SMatrix{3,3,BigFloat}
end
end

@@ -54,6 +78,30 @@
end
end

@testset "division" begin
for T in all_types
r = T(log(rand(typeof(exp(zero(T))))))
a = 4.2
@test r isa T
@test r/1 isa T
@test r/a isa T

@test r/1 == r
@test r/2 + r/2 ≈ r
@test r/a == SMatrix(r)/a
end
end

@testset "matrix multiplication" begin
for T in all_types
r = T(log(rand(typeof(exp(zero(T))))))
@test r isa T
@test r*r isa SMatrix
@test r/r isa SMatrix
@test r^2 isa SMatrix
end
end

@testset "error case" begin
for T in types_2d
@test_throws BoundsError zero(InfinitesimalAngle2d)[5]
@@ -96,4 +144,21 @@
@test 1.2 * zero(T{Int}) isa T{Float64}
end
end

@testset "Testing show" begin
io = IOBuffer()
r = zero(InfinitesimalRotMatrix{2})
show(io, MIME("text/plain"), r)
str = String(take!(io))
if VERSION ≥ v"1.6"
@test startswith(str, "2×2 InfinitesimalRotMatrix2{Float64}")
else
@test startswith(str, "2×2 InfinitesimalRotMatrix{2,Float64,4}")
end

rvec = InfinitesimalRotationVec(1.0, 2.0, 3.0)
show(io, MIME("text/plain"), rvec)
str = String(take!(io))
@test startswith(str, "3×3 InfinitesimalRotationVec{Float64}") && occursin("(1.0, 2.0, 3.0):", str)
end
end