Skip to content

Commit

Permalink
Extensions of pmmultrsym
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasvarga committed Nov 6, 2024
1 parent 50de5bd commit 465ebaa
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
8 changes: 8 additions & 0 deletions ext/FourierApproxExt/pmops_Fourier.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,11 @@ Base.isapprox(J::UniformScaling{<:Real}, A::FourierFunctionMatrix; kwargs...) =
function PeriodicMatrices.pmrand(::Type{PM}, n::Int, m::Int, period::Real = 2*pi; nh::Int = 1) where {PM <:FourierFunctionMatrix}
convert(PM,HarmonicArray(rand(n,m), [rand(n,m) for i in 1:nh], [rand(n,m) for i in 1:nh], period))
end
for PMF in (:pmmulsym, :pmtrmulsym, :pmmultrsym)
for PM in (:FourierFunctionMatrix,)
@eval begin
PeriodicMatrices.$PMF(B::$PM,C::$PM, β = true) = convert($PM,PeriodicMatrices.$PMF(convert(PeriodicFunctionMatrix,B), convert(PeriodicFunctionMatrix,C), β))
end
end
end

9 changes: 9 additions & 0 deletions src/pmops_sym.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,12 @@ function pmrand(::Type{PM}, n::Int, m::Int, period::Real = 2*pi; nh::Int = 1) wh
pmrand(PM{:c,Float64}, n, m, period; nh)
end

for PMF in (:pmmulsym, :pmtrmulsym, :pmmultrsym)
for PM in (:PeriodicSymbolicMatrix,)
@eval begin
$PMF(B::$PM,C::$PM, β = true) = convert($PM,$PMF(convert(PeriodicFunctionMatrix,B), convert(PeriodicFunctionMatrix,C), β))
end
end
end


18 changes: 16 additions & 2 deletions test/test_pmops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ At1=PeriodicFunctionMatrix(A11,2pi)
@test As*Xs+Xs*As'+Cs pmderiv(Xs) Xders
@test As'*Xs+Xs*As+Cds -pmderiv(Xs)
@test transpose(As) == As'
ac = rand(2,2)
ac = rand(2,2); Ac = PeriodicSymbolicMatrix(ac,2.)
@test As+ac ac+As
@test As-ac -(ac-As)
@test As-I == -(I-As)
Expand All @@ -363,6 +363,13 @@ ac = rand(2,2)
@test horzcat(As,ac)(1) == [As(1) ac] && horzcat(ac,As)(1) == [ac As(1)]
@test vertcat(As,ac)(1) == [As(1); ac] && vertcat(ac,As)(1) == [ac; As(1)]

Ast = transpose(As)
@test pmmulsym(As, Ast, 1) As*Ast
@test pmmulsym(Ac, Ac', 1) Ac*Ac'
@test pmtrmulsym(As, As, 1) Ast*As
@test pmmultrsym(As, As, 1) As*Ast



D = rand(2,2)
@test As+I == I+As && As*5 == 5*As && As*D -As*(-D) && iszero(As-As) && !iszero(As)
Expand Down Expand Up @@ -445,7 +452,7 @@ As = PeriodicSymbolicMatrix(A11,2*pi)
@test (As,PeriodicSymbolicMatrix(ffm2psm(Af,0:0)+ffm2psm(Af,1:1),As.period))
@test domain((Af+Af2).M).b 4pi && domain((Af*Af2).M).b 4pi

ac = rand(2,2)
ac = rand(2,2); Ac = FourierFunctionMatrix(ac,2)
@test Af+ac ac+Af
@test Af-ac -(ac-Af)
@test Af-I == -(I-Af)
Expand All @@ -462,6 +469,13 @@ ac = rand(2,2)
@test horzcat(Af,ac)(1) [Af(1) ac] && horzcat(ac,Af)(1) [ac Af(1)]
@test vertcat(Af,ac)(1) [Af(1); ac] && vertcat(ac,Af)(1) [ac; Af(1)]

Aft = transpose(Af)
@test pmmulsym(Af, Aft, 1) Af*Aft
@test pmmulsym(Ac, Ac', 1) Ac*Ac'
@test pmtrmulsym(Af, Af, 1) Aft*Af
@test pmmultrsym(Af, Af, 1) Af*Aft



@test issymmetric(Cf) && issymmetric(Cdf) && issymmetric(Xf) && issymmetric(Xderf)
@test Af*Xf+Xf*Af'+Cf pmderiv(Xf) Xderf
Expand Down

0 comments on commit 465ebaa

Please sign in to comment.