Skip to content

Commit

Permalink
Cleaning to avoid hcat/vcat/hvcat type piracy in Julia 1.6 and 1.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasvarga committed Mar 8, 2022
1 parent 8d9e872 commit c16b741
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MatrixPencils"
uuid = "48965c70-4690-11ea-1f13-43a2532b2fa8"
authors = ["Andreas Varga <varga.andreas@gmail.com>"]
version = "1.7.1"
version = "1.7.2"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## Version 1.7.2

This patch version eliminates possible hcat/vcat/hvcat type piracies in Julia 1.6 and 1.7.

## Version 1.7.1

This patch version adjusts the dependencies of BLAS+LAPACK and Polynomials.
Expand Down
10 changes: 5 additions & 5 deletions src/gsfstab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function saloc(A::AbstractMatrix, B::AbstractMatrix; disc::Bool = false,
ng = n-nb
fnrmtol = 1000*nrmA/nrmB
fnrmtol == 0 && (fnrmtol = 1000/nrmB)

nu = 0; na = 0
nc = n
F = zeros(T,m,n);
Expand Down Expand Up @@ -484,7 +484,7 @@ function saloc(A::AbstractMatrix, E::Union{AbstractMatrix,UniformScaling{Bool}},
if E == I
F, S, blkdims = saloc(A, B, evals = evals, sdeg = sdeg, atol1 = atol1, atol2 = atol3, rtol = rtol)
TS = eltype(F)
return F, GeneralizedSchur(S.T, Matrix{TS}(I,n,n), S.values, ones(TS,n), S.Z, S.Z), [0; blkdims]
return F, GeneralizedSchur(S.T, Matrix{TS}(I,n,n), S.values, ones(TS,n), S.Z, S.Z), [[0]; blkdims]
end

LinearAlgebra.checksquare(E) == n || throw(DimensionMismatch("E must be a $n x $n matrix"))
Expand Down Expand Up @@ -635,7 +635,7 @@ function saloc(A::AbstractMatrix, E::Union{AbstractMatrix,UniformScaling{Bool}},

nfg = n-nb-ninf
fnrmtol = 1000*max(nrmA,1)/nrmB

nfu = 0; nfa = 0
nc = n
F = zeros(T,m,n);
Expand Down Expand Up @@ -1156,7 +1156,7 @@ function saloc2(A::AbstractMatrix{T},B::AbstractMatrix{T},evc::AbstractVector{T1
sp = real(evc[1]+evc[2]); pp = real(evc[1]*evc[2]);
k11 = (sc-sp)/s1;
k12 = at[2,2]/at[2,1]*k11+(pp-at[1,1]*at[2,2]+at[1,2]*at[2,1])/at[2,1]/s1;
F = v1*[-k11 -k12; zeros(m-1,2)]*U';
F = v1*[[-k11 -k12]; zeros(m-1,2)]*U';
if rankB == 2 && norm(F) > norm(ftry)
# choose the lower norm feedback
F = ftry;
Expand Down Expand Up @@ -1225,7 +1225,7 @@ function saloc2(A::AbstractMatrix{T},E::AbstractMatrix{T},B::AbstractMatrix{T},e
sp = real(evc[1]+evc[2]); pp = real(evc[1]*evc[2]);
k11 = (sc-sp)/s1;
k12 = at[2,2]/at[2,1]*k11+(pp-at[1,1]*at[2,2]+at[1,2]*at[2,1])/at[2,1]/s1;
F = v1*[-k11 -k12; zeros(m-1,2)]*U'; V = Matrix{eltype(B)}(I,m,m)
F = v1*[[-k11 -k12]; zeros(T,m-1,2)]*U'; V = Matrix{eltype(B)}(I,m,m)
if rankB == 2 && norm(F) > norm(ftry)
# choose the lower norm feedback
F = ftry;
Expand Down
4 changes: 2 additions & 2 deletions src/pmtools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,8 @@ function lps2pm(A::AbstractMatrix, E::AbstractMatrix,B::AbstractMatrix, F::Abstr
M1 = [A1 B1/W1; V1'\C1 V1'\D1/W1]
N1 = [E1 F1/W1; V1'\G1 V1'\H1/W1]
n = size(A1,1)
indi = [1:n;1]
indj = [1:n;1]
indi = [1:n;[1]]
indj = [1:n;[1]]
n1 = n+1
for i = 1:p
indi[n1] = n+i
Expand Down
4 changes: 2 additions & 2 deletions src/rmtools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,8 @@ function lps2rm(A::AbstractMatrix, E::AbstractMatrix, B::AbstractMatrix, F::Abst
NUM[i,j,1:length(cz)] = compl ? cz*(Rval[i,j]/zval) : real(cz*(Rval[i,j]/zval))
else
n1 = size(A1,1)
M1 = [A1 zeros(T,n1,2); zeros(T,1,n1+1) one(T); zeros(T,1,n1) one(T) zero(T)]
N1 = [E1 F1 zeros(T,n1,1); G1 H1 zero(T); zeros(T,1,n1+2)]
M1 = [A1 zeros(T,n1,2); zeros(T,1,n1+1) [one(T)]; zeros(T,1,n1) [one(T) zero(T)]]
N1 = [E1 F1 zeros(T,n1,1); G1 H1 [zero(T)]; zeros(T,1,n1+2)]
pol, ip, _ = pzeros(M1,N1; fast = fast, atol1 = atol1, atol2 = atol2, rtol = rtol)
cp, pval = polcoeffval(pol[1:(length(pol)-sum(ip))],val)
NUM[i,j,1:length(cz)] = compl ? cz*(Rval[i,j]*pval/zval) : real(cz*(Rval[i,j]*pval/zval))
Expand Down
2 changes: 2 additions & 0 deletions test/test_gsfstab.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ end

@testset "Spectrum allocation functions" begin

println("saloc for standard pair (A,B)")
@testset "saloc for standard pair (A,B)" begin


Expand Down Expand Up @@ -298,6 +299,7 @@ end # Ty loop

end #begin

println("saloc for generalized pair (A-λE,B)")
@testset "saloc for generalized pair (A-λE,B)" begin

## simple cases: B = [];
Expand Down
16 changes: 9 additions & 7 deletions test/test_klf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Random.seed!(2351);

@testset "Matrix Pencils Utilities" begin

println("klf_rlsplit")
@testset "klf_rlsplit" begin

fast = true
Expand Down Expand Up @@ -200,8 +201,8 @@ atol1 = 1.e-7; atol2 = 1.e-7; rtol = 1.e-7;
@time M1, N1, Q1, Z1, νr, μr, νi, nfe, νl, μl = klf(M, N, finite_infinite=true,fast = true, atol1 = 0*atol1, atol2 = 0*atol2, rtol = rtol)
@test norm(Q1'*M2*Z1-M1) < atol1 &&
norm(Q1'*N2*Z1-N1) < atol2 &&
νr == [ones(Int,mr); 0] && μr == ones(Int,nr) &&
νi == ones(Int,ni) && νl == ones(Int,ml) && μl == [0; ones(Int,nl)] && nfe == nf
νr == [ones(Int,mr); [0]] && μr == ones(Int,nr) &&
νi == ones(Int,ni) && νl == ones(Int,ml) && μl == [[0]; ones(Int,nl)] && nfe == nf

M = copy(M2); N = copy(N2);

Expand All @@ -222,6 +223,7 @@ end
end

@testset "klf_left and klf_right" begin
println("klf_left and klf_right")

fast = true
for fast in (false,true)
Expand Down Expand Up @@ -629,7 +631,7 @@ end
end

@testset "klf" begin

println("klf")
fast = true
for fast in (false,true)

Expand Down Expand Up @@ -977,16 +979,16 @@ atol1 = 1.e-6; atol2 = 1.e-7; rtol = 1.e-7;
@time M1, N1, Q1, Z1, νr, μr, νi, nfe, νl, μl = klf(M, N, finite_infinite=true,fast = fast, atol1 = atol1, atol2 = 0*atol2, rtol = rtol)
@test norm(Q1'*M2*Z1-M1) < atol1 &&
norm(Q1'*N2*Z1-N1) < atol2 &&
νr == [ones(Int,mr); 0] && μr == ones(Int,nr) &&
νi == ones(Int,ni) && νl == ones(Int,ml) && μl == [0; ones(Int,nl)] && nfe == nf
νr == [ones(Int,mr); [0]] && μr == ones(Int,nr) &&
νi == ones(Int,ni) && νl == ones(Int,ml) && μl == [[0]; ones(Int,nl)] && nfe == nf

M = copy(M2); N = copy(N2);
atol1 = 1.e-6; atol2 = 1.e-7; rtol = 1.e-7;
@time M1, N1, Q1, Z1, νr, μr, νi, nfe, νl, μl = klf(M, N, finite_infinite=false,fast = fast, atol1 = atol1, atol2 = 0*atol2, rtol = rtol)
@test norm(Q1'*M2*Z1-M1) < atol1 &&
norm(Q1'*N2*Z1-N1) < atol2 &&
νr == [ones(Int,mr); 0] && μr == ones(Int,nr) &&
νi == ones(Int,ni) && νl == ones(Int,ml) && μl == [0; ones(Int,nl)] && nfe == nf
νr == [ones(Int,mr); [0]] && μr == ones(Int,nr) &&
νi == ones(Int,ni) && νl == ones(Int,ml) && μl == [[0]; ones(Int,nl)] && nfe == nf

end
end
Expand Down
1 change: 0 additions & 1 deletion test/test_pmtools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ using MatrixPencils
using Polynomials
using Test


@testset "Polynomial Matrix Tools" begin

@testset "Conversions" begin
Expand Down
1 change: 0 additions & 1 deletion test/test_rmtools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ using MatrixPencils
using Polynomials
using Test


@testset "Rational Matrix Tools" begin


Expand Down

2 comments on commit c16b741

@andreasvarga
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/56212

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.7.2 -m "<description of version>" c16b7415bd2765b452f29b6977bcc4f0566003a9
git push origin v1.7.2

Please sign in to comment.