@@ -9,13 +9,22 @@ import Base: AbstractMatrix
99import LinearAlgebra: Cholesky, Factorization
1010import LinearAlgebra: ldiv!, factorize, lmul!, pinv, eigvals, eigvecs, eigen, Eigen, det
1111import LinearAlgebra: cholesky!, cholesky, tril!, triu!, checksquare, rmul!, dot, mul!, tril, triu
12+ import LinearAlgebra: istriu, istril, isdiag
1213import LinearAlgebra: UpperTriangular, LowerTriangular, Symmetric, Adjoint
1314import AbstractFFTs: Plan, plan_fft!
1415import StatsBase
1516
1617export AbstractToeplitz, Toeplitz, SymmetricToeplitz, Circulant, LowerTriangularToeplitz, UpperTriangularToeplitz, TriangularToeplitz, Hankel
1718export durbin, trench, levinson
1819
20+ @static if isdefined (Base, :require_one_based_indexing )
21+ const require_one_based_indexing = Base. require_one_based_indexing
22+ else
23+ function require_one_based_indexing (A... )
24+ ! Base. has_offset_axes (A... ) || throw (ArgumentError (" offset arrays are not supported but got an array with index other than 1" ))
25+ end
26+ end
27+
1928include (" iterativeLinearSolvers.jl" )
2029
2130# Abstract
@@ -33,6 +42,21 @@ convert(::Type{AbstractToeplitz{T}}, A::AbstractToeplitz) where T = AbstractToep
3342isconcrete (A:: AbstractToeplitz ) = isconcretetype (typeof (A. vc)) && isconcretetype (typeof (A. vr))
3443iszero (A:: AbstractToeplitz ) = iszero (A. vc) && iszero (A. vr)
3544
45+ function istril (A:: AbstractToeplitz , k:: Integer = 0 )
46+ vr, vc = _vr (A), _vc (A)
47+ all (iszero, @view vr[max (1 , k+ 2 ): end ]) && all (iszero, @view vc[2 : min (- k,end )])
48+ end
49+
50+ function istriu (A:: AbstractToeplitz , k:: Integer = 0 )
51+ vr, vc = _vr (A), _vc (A)
52+ all (iszero, @view vc[max (1 , - k+ 2 ): end ]) && all (iszero, @view vr[2 : min (k,end )])
53+ end
54+
55+ function isdiag (A:: AbstractToeplitz )
56+ vr, vc = _vr (A), _vc (A)
57+ all (iszero, @view vr[2 : end ]) && all (iszero, @view vc[2 : end ])
58+ end
59+
3660"""
3761 ToeplitzFactorization
3862
0 commit comments