Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve types in triangular constructors #126

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
fail-fast: false
matrix:
version:
- '1.0'
- '1.6'
- '1'
- 'nightly'
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ToeplitzMatrices"
uuid = "c751599d-da0a-543b-9d20-d0a503d91d24"
version = "0.8.4"
version = "0.9.0"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand All @@ -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"
Expand Down
9 changes: 1 addition & 8 deletions src/ToeplitzMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/special.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@
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)
Expand All @@ -192,11 +191,9 @@
checksquare(A)
LowerTriangularToeplitz{T}(_vc(A))
end
_toeplitztype(s::Symbol) = Symbol(s,"Toeplitz")
_toeplitztype(s::Symbol) = Symbol(s, :Toeplitz)

Check warning on line 194 in src/special.jl

View check run for this annotation

Codecov / codecov/patch

src/special.jl#L194

Added line #L194 was not covered by tests
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
Expand Down
16 changes: 8 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -620,19 +620,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 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 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 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)
TU = TriangularToeplitz(A, :U)
Expand Down
Loading