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

Mark SubArrays as invalid outputs for IDAIntegrator(out, t) #434

Merged
merged 6 commits into from
Dec 10, 2023

Commits on Nov 18, 2023

  1. Mark SubArrays as invalid outputs for IDAIntegrator(out, t)

    Let's imagine we have a matrix that we are filling out, column by column with
    `integrator(t)`, but we realize we want to use the non-allocating version.
    We try to use `integrator(out[:, idx], t)`, and then realize that of course we
    need to make that a view because otherwise slicing just creates a copy.
    Imagine our surprise when the view doesn't work either.  Indeed:
    
    ```julia
    julia> out = zeros(3)
           outv = @view(out[:])
           nv = convert(Sundials.NVector, outv)
           nv[1] = 1.0
           out
    3-element Vector{Float64}:
     0.0
     0.0
     0.0
    ```
    
    The issue, as it turns out, is due to the `convert(NVector, x)` overload
    automatically making a copy of non-plain `Vector` types.  I understand
    the reasoning behind this, as the backing memory store needs to be
    contiguous memory.  It may be possible to write a correct dispatch for
    `SubArray`s that are contiguous vectors, but I'm not sure how to do
    that, and so have opted instead to just make this an error rather than
    silently return untouched memory.
    staticfloat committed Nov 18, 2023
    Configuration menu
    Copy the full SHA
    05af793 View commit details
    Browse the repository at this point in the history
  2. Add test

    staticfloat committed Nov 18, 2023
    Configuration menu
    Copy the full SHA
    fb04aeb View commit details
    Browse the repository at this point in the history
  3. Update callbacks.jl

    staticfloat committed Nov 18, 2023
    Configuration menu
    Copy the full SHA
    4df72ab View commit details
    Browse the repository at this point in the history

Commits on Dec 10, 2023

  1. Configuration menu
    Copy the full SHA
    e71b24d View commit details
    Browse the repository at this point in the history
  2. Update Project.toml

    ChrisRackauckas committed Dec 10, 2023
    Configuration menu
    Copy the full SHA
    23d7738 View commit details
    Browse the repository at this point in the history
  3. Update CI.yml

    ChrisRackauckas committed Dec 10, 2023
    Configuration menu
    Copy the full SHA
    7da7201 View commit details
    Browse the repository at this point in the history