-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Currently vr
and vc
can be modified so that their first entries are different:
julia> T=Toeplitz(rand(3,3))
3×3 Toeplitz{Float64, Vector{Float64}, Vector{Float64}}:
0.410444 0.893844 0.0538559
0.477895 0.410444 0.893844
0.853433 0.477895 0.410444
julia> T.vr[1]=0;
julia> T
3×3 Toeplitz{Float64, Vector{Float64}, Vector{Float64}}:
0.410444 0.893844 0.0538559
0.477895 0.410444 0.893844
0.853433 0.477895 0.410444
julia> Toeplitz(T)
ERROR: First element of the vectors must be the same
It's difficult to keep track of this constraint. How about defining Toeplitz as something like
struct Toeplitz
first # [1,1]
vc # [2:end,1]
vr # [1,2:end]
end
Pros:
- It's easier to convert between types. For example, the following methods could be removed.
ToeplitzMatrices.jl/src/special.jl
Lines 98 to 99 in c3ac898
_circulate(v::AbstractVector) = vcat(v[1],v[end:-1:2]) _firstnonzero(v::AbstractVector) = vcat(v[1],zero(view(v,2:lastindex(v)))) - It ensures that the top-left entry is inambiguous.
- It's easier to implement some methods, like
isone
,istriu
, etc.
Cons:
- Getting the full first row/column needs concatenation and is therefore slower. This doesn't affect conversions since they wouldn't need the full row/column.
- A lot of codes need to be rewritten.
mutable
is needed in order to change the first entry.
Metadata
Metadata
Assignees
Labels
No labels