SciML / SciMLOperators.jl

SciMLOperators.jl: Matrix-Free Operators for the SciML Scientific Machine Learning Common Interface in Julia
https://docs.sciml.ai/SciMLOperators/stable
MIT License
44 stars 10 forks source link

allow functionoperator (batch = false) to accept/return vec'd arrays #210

Closed vpuri3 closed 1 year ago

vpuri3 commented 1 year ago

@ChrisRackauckas

with this branch,

julia> f(u, p, t) = 2u; f(v, u, p, t) = mul!(v, 2, u);                                                                                                               [30/1927]

julia> F = FunctionOperator(f, ones(4, 4));

julia> F * ones(4, 4)
4×4 Matrix{Float64}:
 2.0  2.0  2.0  2.0
 2.0  2.0  2.0  2.0
 2.0  2.0  2.0  2.0
 2.0  2.0  2.0  2.0                        

julia> F * vec(ones(4, 4))
16-element Vector{Float64}:
 2.0
 2.0
 2.0
 2.0
 2.0
...
julia> mul!(zeros(16), F, ones(16))
16-element Vector{Float64}:
 2.0
 2.0
 2.0
 2.0
 2.0
...
codecov[bot] commented 1 year ago

Codecov Report

Merging #210 (734205b) into master (f169b36) will increase coverage by 0.80%. The diff coverage is 73.41%.

@@            Coverage Diff             @@
##           master     #210      +/-   ##
==========================================
+ Coverage   70.31%   71.12%   +0.80%     
==========================================
  Files          10       10              
  Lines        1533     1562      +29     
==========================================
+ Hits         1078     1111      +33     
+ Misses        455      451       -4     
Impacted Files Coverage Δ
src/func.jl 84.55% <73.41%> (+3.48%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

ChrisRackauckas commented 1 year ago

Should we just remove the vec in that spot of OrdinaryDiffEq if it's hitting an operator?

vpuri3 commented 1 year ago

We will remove the entire WOperator object evenetually.

The idea behind this PR is that we should support vec'd arrays anyway because one or the other downstream packages would use it. I've added warnings, docs etc all over the place as well. So after this PR, I believe we will be hitting all use cases and this package will be as versatile as it gets.

vpuri3 commented 1 year ago

We should also move preconditioner tests to interfaceII in ODE.jl

vpuri3 commented 1 year ago

BTW the failing test in preconditioner.jl is passing now