Skip to content

tril  #203

@ArnoStrouwen

Description

@ArnoStrouwen

the symmetry of the hessian is exploited for extra compression (casadi also does this):
https://github.com/JuliaDiff/SparseDiffTools.jl/blob/master/test/test_sparse_hessian.jl#L12
But I don't immediately see how that extra compression is then later recovered:
https://github.com/JuliaDiff/SparseDiffTools.jl/blob/master/src/differentiation/compute_hessian_ad.jl#L142

using Pkg; Pkg.activate(".")
using SparsityDetection
using SparseDiffTools
function f(x)
    y = zero(eltype(x))
    for i in firstindex(x):lastindex(x)-1
        y += x[i]*x[i+1]
    end
    return y
end
f(rand(10))

x = randn(5)
sparsity = hessian_sparsity(f, x)

colors = matrix_colors(tril(sparsity))
colors2 = matrix_colors(sparsity)

ncolors = maximum(colors)
ncolors2 = maximum(colors2)

hescache = ForwardAutoColorHesCache(f, x, colors, sparsity)
hescache2 = ForwardAutoColorHesCache(f, x, colors2, sparsity)

H = SparseDiffTools.autoauto_color_hessian(f, x, hescache)
H2 = SparseDiffTools.autoauto_color_hessian(f, x, hescache2)
H3 = SparseDiffTools.autoauto_color_hessian(f, x)

Also, H3 is not really sparse.

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