Skip to content

Add support for Hermitian Toeplitz matrices ?  #59

@BambOoxX

Description

@BambOoxX

Currently there seem to be no specific way to handle Hermitian Toeplitz matrices in Julia.

Using currently available constructors, I managed the small benchmark below

using LinearAlgebra, ToeplitzMatrices, BenchmarkTools
order = 100
col = rand(ComplexF64,order)
col[1] = real(col[1])
Toe = Toeplitz(col,conj(col))
Arr = Matrix(Toe)
Tri = TriangularToeplitz(col,:L)

HerToe = Hermitian(Toe)
HerTri = Hermitian(Tri,:L)
AvgTri = (Tri + Tri' - Diagonal(diag(Tri)))

(Arr == Toe) && (HerToe == Toe) && (HerTri == Toe) && (AvgTri == Toe)

v = rand(order)
@btime $Toe\$v;
@btime $Arr\$v;
@btime $HerToe\$v;
@btime $HerTri\$v;
@btime $AvgTri\$v;

On my system, I get surprisingly worse results using the Toeplitz matrix.

 18.133 ms (18835 allocations: 1.06 MiB)
  98.300 μs (4 allocations: 158.97 KiB)
  110.900 μs (4 allocations: 158.97 KiB)
  105.999 μs (4 allocations: 158.97 KiB)
  100.800 μs (4 allocations: 158.97 KiB)

In the same manner, the least time is spent while computing with the actual dense array.
While I am not sure where to start, I would have expected some improvements from the Toeplitz matrix, as well as reduced memory allocation.
The Hermitian + TriangularToeplitz combination seem to work quite well however, both in terms of allocations and time, and static memory usage.

In terms of storage, Toeplitz and others represent however an obvious gain as varinfo() returns

name                    size summary 
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
  Arr              156.289 KiB 100×100 Array{Complex{Float64},2}
  AvgTri         156.289 KiB 100×100 Array{Complex{Float64},2}
  HerToe            9.633 KiB 100×100 Hermitian{Complex{Float64},Toeplitz{Complex{Float64},Complex{Float64}}}
  HerTri              8.031 KiB 100×100 Hermitian{Complex{Float64},TriangularToeplitz{Complex{Float64},Complex{Float64}}}
  Toe                 9.617 KiB 100×100 Toeplitz{Complex{Float64},Complex{Float64}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions