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

Broadcast LinearOperators #196

Open
tmigot opened this issue Jul 17, 2021 · 5 comments
Open

Broadcast LinearOperators #196

tmigot opened this issue Jul 17, 2021 · 5 comments

Comments

@tmigot
Copy link
Member

tmigot commented Jul 17, 2021

What is the best way to broadcast LinearOperators? For instance,

Jx =  jac_op(nlp, x) # where nlp is an AbstractNLPModel, and x a vector

and then

Jx .= jac_op(nlp, y)
@dpo
Copy link
Member

dpo commented Jul 19, 2021

You can't do that (at least not in the current state of things). Maybe we could cook up jac_op!(J, nlp, x).

@abelsiqueira
Copy link
Member

I think that if you define Jx = jac_op(nlp, x), and change x afterward with .=, then Jx is changed automatically. At least for the default jac_op.

@dpo
Copy link
Member

dpo commented Jul 19, 2021

Is it? That wouldn't really be a desirable side effect.

@abelsiqueira
Copy link
Member

Perhaps we could store the x value inside the operator? Maybe creating a HessianLinearOperator?

@tmigot
Copy link
Member Author

tmigot commented Sep 1, 2022

Up this conversation following the discussion JuliaSmoothOptimizers/NLPModels.jl#416

What @abelsiqueira described

I think that if you define Jx = jac_op(nlp, x), and change x afterward with .=, then Jx is changed automatically. At least for the default jac_op.

is still true with LinearOperators v2.

Besides, I am not sure to see how we replace op.prod! because we cannot do

op.prod! = new_prod!

because of this

MethodError: Cannot `convert` an object of type NLPModels.var"#40#41"{Float64, SimpleNLPModel{Float64, Vector{Float64}}, Vector{Float64}, Vector{Float64}, typeof(*), typeof(+)} to an object of type NLPModels.var"#49#50"{Float64, SimpleNLPModel{Float64, Vector{Float64}}, Vector{Float64}, Vector{Float64}, typeof(*), typeof(+)}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants