From 217bf7336cd0e49c824dc37f2bdd4b7cde4542ed Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 3 Jan 2024 15:40:56 +0530 Subject: [PATCH 1/5] Preserve types in triangular constructors --- Project.toml | 4 ++-- src/special.jl | 4 +--- test/runtests.jl | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index 2b94061..136e1e4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ToeplitzMatrices" uuid = "c751599d-da0a-543b-9d20-d0a503d91d24" -version = "0.8.3" +version = "0.9.0" [deps] AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c" @@ -25,7 +25,7 @@ LinearAlgebra = "<0.0.1, 1" Random = "<0.0.1, 1" StatsBase = "0.32, 0.33, 0.34" Test = "<0.0.1, 1" -julia = "1.0" +julia = "1.6" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" diff --git a/src/special.jl b/src/special.jl index 262c792..aa4ac06 100644 --- a/src/special.jl +++ b/src/special.jl @@ -192,11 +192,9 @@ function LowerTriangularToeplitz{T}(A::AbstractMatrix) where T checksquare(A) LowerTriangularToeplitz{T}(_vc(A)) end -_toeplitztype(s::Symbol) = Symbol(s,"Toeplitz") +_toeplitztype(s::Symbol) = Symbol(s, :Toeplitz) for TYPE in (:UpperTriangular, :LowerTriangular) @eval begin - $TYPE{T}(A::AbstractToeplitz) where T = $(_toeplitztype(TYPE)){T}(A) - $TYPE(A::AbstractToeplitz) = $TYPE{eltype(A)}(A) convert(::Type{TriangularToeplitz{T}},A::$(_toeplitztype(TYPE))) where T<:Number = convert($(_toeplitztype(TYPE)){T},A) end end diff --git a/test/runtests.jl b/test/runtests.jl index 38fae65..de67016 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -614,19 +614,19 @@ end A = randn(ComplexF64, 3, 3) T = Toeplitz(A) TU = UpperTriangular(T) - @test TU isa TriangularToeplitz + @test TU isa UpperTriangular @test istriu(TU) @test TU == Toeplitz(triu(A)) == triu(T) @test TU'ones(3) == Matrix(TU)'ones(3) @test transpose(TU)*ones(3) == transpose(Matrix(TU))*ones(3) - @test triu(TU, 1)::TriangularToeplitz == triu(Matrix(T), 1) == triu(T,1) + @test triu(TU, 1) == triu(Matrix(T), 1) == triu(T,1) TL = LowerTriangular(T) - @test TL isa TriangularToeplitz + @test TL isa LowerTriangular @test istril(TL) @test TL == Toeplitz(tril(A)) == tril(T) @test TL'ones(3) == Matrix(TL)'ones(3) @test transpose(TL)*ones(3) == transpose(Matrix(TL))*ones(3) - @test tril(TL, -1)::TriangularToeplitz == tril(Matrix(T), -1) == tril(T,-1) + @test tril(TL, -1) == tril(Matrix(T), -1) == tril(T,-1) for n in (65, 128) A = randn(n, n) TU = TriangularToeplitz(A, :U) From 73bc691c3cc113d1791bc33b622fe56b535d38aa Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 3 Jan 2024 16:14:11 +0530 Subject: [PATCH 2/5] Remove Symmetric constructor --- .github/workflows/CI.yml | 1 - src/special.jl | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index deff23e..deedb09 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -25,7 +25,6 @@ jobs: fail-fast: false matrix: version: - - '1.0' - '1.6' - '1' - 'nightly' diff --git a/src/special.jl b/src/special.jl index aa4ac06..5f96827 100644 --- a/src/special.jl +++ b/src/special.jl @@ -182,7 +182,6 @@ function SymmetricToeplitz{T}(A::AbstractMatrix, uplo::Symbol = :U) where T end end SymmetricToeplitz(A::AbstractMatrix, uplo::Symbol) = SymmetricToeplitz{eltype(A)}(A,uplo) -Symmetric(A::AbstractToeplitz, uplo::Symbol = :U) = SymmetricToeplitz(A,uplo) function UpperTriangularToeplitz{T}(A::AbstractMatrix) where T checksquare(A) From 4ed4561fb4838f0e044fecfa1cff3aead25c03c6 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 3 Jan 2024 20:12:12 +0530 Subject: [PATCH 3/5] Use isapprox in adj/trans matvec tests --- Project.toml | 12 ++++++------ test/runtests.jl | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Project.toml b/Project.toml index 136e1e4..c8b5c7f 100644 --- a/Project.toml +++ b/Project.toml @@ -9,12 +9,6 @@ FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -[weakdeps] -StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" - -[extensions] -ToeplitzMatricesStatsBaseExt = "StatsBase" - [compat] AbstractFFTs = "0.4, 0.5, 1" Aqua = "0.8" @@ -27,6 +21,9 @@ StatsBase = "0.32, 0.33, 0.34" Test = "<0.0.1, 1" julia = "1.6" +[extensions] +ToeplitzMatricesStatsBaseExt = "StatsBase" + [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" @@ -36,3 +33,6 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] test = ["Aqua", "FFTW", "Random", "StatsBase", "Test"] + +[weakdeps] +StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" diff --git a/test/runtests.jl b/test/runtests.jl index de67016..63c3600 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -617,15 +617,15 @@ end @test TU isa UpperTriangular @test istriu(TU) @test TU == Toeplitz(triu(A)) == triu(T) - @test TU'ones(3) == Matrix(TU)'ones(3) - @test transpose(TU)*ones(3) == transpose(Matrix(TU))*ones(3) + @test TU' * ones(3) ≈ Matrix(TU)' * ones(3) + @test transpose(TU)*ones(3) ≈ transpose(Matrix(TU))*ones(3) @test triu(TU, 1) == triu(Matrix(T), 1) == triu(T,1) TL = LowerTriangular(T) @test TL isa LowerTriangular @test istril(TL) @test TL == Toeplitz(tril(A)) == tril(T) - @test TL'ones(3) == Matrix(TL)'ones(3) - @test transpose(TL)*ones(3) == transpose(Matrix(TL))*ones(3) + @test TL' * ones(3) ≈ Matrix(TL)' * ones(3) + @test transpose(TL)*ones(3) ≈ transpose(Matrix(TL))*ones(3) @test tril(TL, -1) == tril(Matrix(T), -1) == tril(T,-1) for n in (65, 128) A = randn(n, n) From 5f38148eb2fa35b775a686cae3a7fa1508974ce8 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 3 Jan 2024 20:34:21 +0530 Subject: [PATCH 4/5] Import require_one_based_indexing directly from Base --- src/ToeplitzMatrices.jl | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/ToeplitzMatrices.jl b/src/ToeplitzMatrices.jl index 9a2a92c..52ce347 100644 --- a/src/ToeplitzMatrices.jl +++ b/src/ToeplitzMatrices.jl @@ -5,6 +5,7 @@ import Base: adjoint, convert, transpose, size, getindex, similar, copy, getprop import Base: parent import Base: ==, +, -, *, \ import Base: AbstractMatrix +import Base: require_one_based_indexing import LinearAlgebra: Cholesky, Factorization import LinearAlgebra: ldiv!, factorize, lmul!, pinv, eigvals, eigvecs, eigen, Eigen, det import LinearAlgebra: cholesky!, cholesky, tril!, triu!, checksquare, rmul!, dot, mul!, tril, triu, diag @@ -23,14 +24,6 @@ const HermOrSym{T,M} = Union{Hermitian{T,M}, Symmetric{T,M}} export AbstractToeplitz, Toeplitz, SymmetricToeplitz, Circulant, LowerTriangularToeplitz, UpperTriangularToeplitz, TriangularToeplitz, Hankel export durbin, trench, levinson -@static if isdefined(Base, :require_one_based_indexing) - const require_one_based_indexing = Base.require_one_based_indexing -else - function require_one_based_indexing(A...) - !Base.has_offset_axes(A...) || throw(ArgumentError("offset arrays are not supported but got an array with index other than 1")) - end -end - include("iterativeLinearSolvers.jl") # Abstract From edc734e342da762a7070f3ed34526a4cd2503084 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Fri, 29 Mar 2024 22:23:13 +0530 Subject: [PATCH 5/5] Restore Project.toml ordering --- Project.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index c8b5c7f..136e1e4 100644 --- a/Project.toml +++ b/Project.toml @@ -9,6 +9,12 @@ FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" +[weakdeps] +StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" + +[extensions] +ToeplitzMatricesStatsBaseExt = "StatsBase" + [compat] AbstractFFTs = "0.4, 0.5, 1" Aqua = "0.8" @@ -21,9 +27,6 @@ StatsBase = "0.32, 0.33, 0.34" Test = "<0.0.1, 1" julia = "1.6" -[extensions] -ToeplitzMatricesStatsBaseExt = "StatsBase" - [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" @@ -33,6 +36,3 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] test = ["Aqua", "FFTW", "Random", "StatsBase", "Test"] - -[weakdeps] -StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"