From 1010e0a02d0b7dbf3354f80957ccb18dd948b3de Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Fri, 3 Jul 2026 17:40:04 +0200 Subject: [PATCH] remove unnecessary `similar_type` methods These "invalidate" and only do what the default already does --- src/core_types.jl | 6 ------ src/rotation_generator.jl | 6 ------ 2 files changed, 12 deletions(-) diff --git a/src/core_types.jl b/src/core_types.jl index 952a7a3..05d663c 100644 --- a/src/core_types.jl +++ b/src/core_types.jl @@ -32,12 +32,6 @@ rotation_axis(r::Rotation{3}) = rotation_axis(AngleAxis(r)) Base.convert(::Type{R}, rot::R) where {N,R<:Rotation{N}} = rot Base.convert(::Type{R}, rot::Rotation{N}) where {N,R<:Rotation{N}} = R(rot) -# Rotation matrices should be orthoginal/unitary. Only the operations we define, -# like multiplication, will stay as Rotations, otherwise users will get an -# SMatrix{3,3} (e.g. rot1 + rot2 -> SMatrix) -Base.@pure StaticArrays.similar_type(::Union{R,Type{R}}) where {R <: Rotation} = SMatrix{size(R)..., eltype(R), prod(size(R))} -Base.@pure StaticArrays.similar_type(::Union{R,Type{R}}, ::Type{T}) where {R <: Rotation, T} = SMatrix{size(R)..., T, prod(size(R))} - @inline function Base.:/(r1::Rotation, r2::Rotation) r1 * inv(r2) end diff --git a/src/rotation_generator.jl b/src/rotation_generator.jl index 9d13b97..091744d 100644 --- a/src/rotation_generator.jl +++ b/src/rotation_generator.jl @@ -30,12 +30,6 @@ Base.:-(r1::RotationGenerator, r2::RotationGenerator) = r1 + (-r2) # `convert` goes through the constructors, similar to e.g. `Number` Base.convert(::Type{R}, rot::RotationGenerator{N}) where {N,R<:RotationGenerator{N}} = R(rot) -# RotationGenerator matrices should be skew-symmetric. Only the operations we define, -# like addition, will stay as RotationGenerators, otherwise users will get an -# SMatrix{3,3} (e.g. rot1 * rot2 -> SMatrix) -Base.@pure StaticArrays.similar_type(::Union{R,Type{R}}) where {R <: RotationGenerator} = SMatrix{size(R)..., eltype(R), prod(size(R))} -Base.@pure StaticArrays.similar_type(::Union{R,Type{R}}, ::Type{T}) where {R <: RotationGenerator, T} = SMatrix{size(R)..., T, prod(size(R))} - ################################################################################ ################################################################################ """