JuliaArrays / JuliaArrays/StructArrays.jl

push! is type unstable

Open
#328 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
402
Forks
49
PR merge metrics
No merged PRs in 30d

Description

Hi,

I use SA in BifurcationKit but I recently noticed that the push! is type unstable. If I remove StructArray in here in ContResult, the TI disappear. Am I wrongly using your package?

using Revise
using BifurcationKit

function Fsl!(out, X, p)
    (;μ, c ) = p
    x, y = X
    ua = x^2 + y^2
    out[1] = μ * x - y - x * ua * c
    out[2] = x + μ * y - y * ua * c
    out
end

function JFsl!(J, X, p)
    (;μ, c) = p
    x, y = X
    ua = x^2 + y^2

    J[1, 1] = μ - c * (ua + 2x^2)
    J[1, 2] = -1 - 2c * x * y
    J[2, 1] = 1 - 2c * x * y
    J[2, 2] = μ - c * (ua + 2y^2)

    J
end
JFsl(x,p) = JFsl!(zeros(2,2),x,p)
prob = BifurcationProblem(Fsl!, zeros(2), (μ=0-.1, c=1.), (@optic _.μ); J! = JFsl!, J = JFsl)

opts = ContinuationPar(p_max = 2., detect_bifurcation = 0, detect_fold=false)
br = @time continuation(prob, PALC(), opts)

@profview (for _=1:10000; continuation(prob, PALC(), ContinuationPar(p_max = 2., detect_bifurcation = 0, detect_fold=false)); end 

gives

Image Image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the type-instability report with the Julia example and compare the StructArray and non-StructArray paths in BifurcationKit's src/Results.jl around line 81. Inspect the push! entry point and use the reported continuation workload to identify the instability; done means the affected path is type-stable without breaking the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.