From 135d562578551a3d81a820d4ef15301298864bb7 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 24 Jan 2024 11:26:16 +0530 Subject: [PATCH] Size for ToeplitzFactorization (#128) * Size for ToeplitzFactorization * Add size(::ToeplitzFactorization, i) * Reorganize code * Add specific tests --- Project.toml | 2 +- src/ToeplitzMatrices.jl | 2 ++ test/runtests.jl | 11 +++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 2b94061..feef0cc 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.8.4" [deps] AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c" diff --git a/src/ToeplitzMatrices.jl b/src/ToeplitzMatrices.jl index 9a2a92c..2447b8c 100644 --- a/src/ToeplitzMatrices.jl +++ b/src/ToeplitzMatrices.jl @@ -99,6 +99,8 @@ struct ToeplitzFactorization{T,A<:AbstractToeplitz{T},S<:Number,P<:Plan{S}} <: F tmp::Vector{S} dft::P end +Base.size(T::ToeplitzFactorization) = (s = size(T.dft,1); (s, s)) +Base.size(T::ToeplitzFactorization, i::Integer) = size(T)[i] include("toeplitz.jl") include("special.jl") diff --git a/test/runtests.jl b/test/runtests.jl index 1a7e3d9..25efde2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -770,3 +770,14 @@ end end end end + +@testset "ldiv! for ToeplitzFactorization (#73)" begin + b = rand(6) + x = zero(b) + P = Circulant([1., 0., 0., 0., 0., 0.]) + Pfac = factorize(P) + @test size(Pfac) == size(P) + @test size(Pfac, 1) == size(P, 1) + ldiv!(x, Pfac, b) + @test x ≈ Pfac \ b +end