@@ -10,6 +10,10 @@ Base.getindex(m::RotMat2, i::Int) = getindex(m.elements, i)
1010# Rotation matrices must be unitary so `similar_type` has to return an SMatrix.
1111StaticArrays. similar_type (:: Union{RotMat2,Type{RotMat2}} ) = SMatrix{2 ,2 ,Float64,4 }
1212
13+ Base. @kwdef mutable struct KPS4{S, T, P}
14+ v_apparent:: T = zeros (S, 3 )
15+ end
16+
1317@testset " Linear algebra" begin
1418
1519 @testset " SArray as a (mathematical) vector space" begin
@@ -313,6 +317,25 @@ StaticArrays.similar_type(::Union{RotMat2,Type{RotMat2}}) = SMatrix{2,2,Float64,
313317 @test norm (SVector {0,Float64} ()) isa Float64
314318 @test norm (SA[SVector {0,Int} (),SVector {0,Int} ()]) isa float (Int)
315319 @test norm (SA[SVector {0,Int} (),SVector {0,Int} ()]) == norm ([Int[], Int[]])
320+
321+ # no allocation for MArray -- issue #1126
322+
323+ @inline function calc_particle_forces! (s, pos1, pos2)
324+ segment = pos1 - pos2
325+ norm1 = norm (segment)
326+ unit_vector = segment / norm1
327+
328+ v_app_perp = s. v_apparent - s. v_apparent ⋅ unit_vector * unit_vector
329+ half_drag_force = norm (v_app_perp)
330+ nothing
331+ end
332+ kps4 = KPS4 {Float64, MVector{3, Float64}, 6+4+1} ()
333+
334+ pos1 = MVector {3, Float64} (1.0 , 2.0 , 3.0 )
335+ pos2 = MVector {3, Float64} (2.0 , 3.0 , 4.0 )
336+ calc_particle_forces! (kps4, pos1, pos2)
337+ calc_particle_forces! (kps4, pos1, pos2)
338+ @test (@allocated calc_particle_forces! (kps4, pos1, pos2)) == 0
316339 end
317340
318341 @testset " trace" begin
0 commit comments