JuliaDiff / JuliaDiff/DiffResults.jl

`MVector` type yields `ImmutableDiffResult`

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

A pull request for this has already been merged.

  • #18 by @charleskawczynski — merged
Dominant language
Julia
Stars
37
Forks
9
PR merge metrics
No merged PRs in 30d

Description

Hello, I'm using this package through LsqFit.jl. I have a 3d parameter vector, and would like to speed up the code by leveraging StaticArrays.jl, which basically come for free by passing a StaticVector instead of a Vector. In order to support in-place operations, we can further pass an MVector, i.e. a modifiable statically sized array. However, as seen below, Static Arrays always lead to ImmutableDiffResults.

https://github.com/JuliaDiff/DiffResults.jl/blob/80f085ebddbe2cabd691a61cb56cc1fd7fccd309/src/DiffResults.jl#L31-L52

I've done the following overloads to make it work for my case:

DiffResult(value::MArray, derivs::Tuple{Vararg{MArray}}) = MutableDiffResult(value, derivs)
DiffResult(value::Union{Number, AbstractArray}, derivs::Tuple{Vararg{MVector}}) = MutableDiffResult(value, derivs)

I think this is a useful feature and currently can be considered a bug. If there's interest in merging this I can also open a PR.

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 with src/DiffResults.jl lines 31-52 and reproduce the reported behavior using an MVector or MArray, as described through LsqFit.jl and StaticArrays.jl. Check whether the existing merged pull request changed this dispatch, then verify that the reported mutable input produces a MutableDiffResult without affecting existing cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.