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

Change definition #85

Open
putianyi889 opened this issue Mar 31, 2023 · 1 comment
Open

Change definition #85

putianyi889 opened this issue Mar 31, 2023 · 1 comment

Comments

@putianyi889
Copy link
Contributor

putianyi889 commented Mar 31, 2023

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.
    _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.
@dlfivefifty
Copy link
Member

@andreasnoack what was the motivation for having the diagonal repeated twice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants