SciML / SciML/RecursiveArrayTools.jl

`Matrix(sol)` can return other types than `Matrix`

Open
#270 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
233
Forks
76
Avg merge
2h 17m
Merged PRs (30d)
9

Description

Calling Matrix(sol) on an *DE solution returns a CuMatrix when the states are CuVectors.

This is because Matrix(sol) is implemented using a generic hcat (see snippet below). This is a very obvious and useful thing to do, but would it make more sense as an implementation of convert(AbstractMatrix, sol) rather than Matrix(sol)?

I know constructors are not guaranteed to return the invoked type, but it's confusing that you have to call Matrix(Matrix(sol)) to actually get a Matrix.

https://github.com/SciML/RecursiveArrayTools.jl/blob/d06ecb856f43bc5e37cbaf50e5f63c578bf3f1bd/src/vector_of_array.jl#L90-L95

Contributor guide

Open the contributing guide

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/vector_of_array.jl around lines 90-95 and reproduce Matrix(sol) for a DE solution whose states are CuVectors. Compare the resulting type with Matrix(Matrix(sol)), then inspect nearby array-construction behavior. Done means the intended Matrix conversion behavior is settled and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.