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

clean up affine operator #21

Merged
merged 11 commits into from
Jun 4, 2022
Merged

clean up affine operator #21

merged 11 commits into from
Jun 4, 2022

Conversation

vpuri3
Copy link
Member

@vpuri3 vpuri3 commented Jun 3, 2022

  • define traits
  • add tests
  • mul!, *

@vpuri3 vpuri3 changed the title clean up affine operator [WIP] clean up affine operator Jun 3, 2022
@codecov
Copy link

codecov bot commented Jun 3, 2022

Codecov Report

Merging #21 (36047b2) into master (aa02552) will not change coverage.
The diff coverage is 0.00%.

@@          Coverage Diff           @@
##           master     #21   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files           4       4           
  Lines         459     498   +39     
======================================
- Misses        459     498   +39     
Impacted Files Coverage Δ
src/sciml.jl 0.00% <0.00%> (ø)
src/basic.jl 0.00% <0.00%> (ø)
src/interface.jl 0.00% <0.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@vpuri3
Copy link
Member Author

vpuri3 commented Jun 3, 2022

what is the matrix representation of

L = AffineOperator(A, b)
L(u) = A*u + b

we would also need a new name. affine is too vague. something that signifies that it is adding a vector, like vecsumoperator or muladdoperator or something

@vpuri3
Copy link
Member Author

vpuri3 commented Jun 3, 2022

im going with MuladdOperator for now

@vpuri3
Copy link
Member Author

vpuri3 commented Jun 3, 2022

thoughts @ChrisRackauckas ?

@ChrisRackauckas
Copy link
Member

what is the matrix representation of

You can dig up some of the old conversations in DiffEqOperators.jl about this question (SciML/DifferentialEquations.jl#260 (comment), SciML/DiffEqOperators.jl#53). There is no matrix representation of it, since if there was it would be a linear operator instead of an affine operator. You can only represent an affine operator as a linear operator in a dimension of one larger. Basically, the operation is: [A b] * [u;1], so it requires something modified to the input as well.

While it this seems like it might doom the idea of using matrix-free affine operators, it turns out that it's okay because of an obscure fact that iterative linear solvers are actually compatible with affine operators. Everyone talks about and proves them for linear solvers, but that's actually over-restrictive.

You can show some nice properties of affine operators, like that the definition given of * will make Qx=b in an iterative solver converge to Qax = b-Qb (so if we actually define a type that does this in Julia, it will work with iterative solvers without a fuss. Just the same thing idea as writing in residual form).

I forget where I wrote the proof of that, some PDE solvers roadmap. But it's rather straightforward to prove. If Q is the affine operator Q(x) = Ax + c, then solving Qx = b is equivalent to solving Ax + c = b or Ax = b-c. You do the same thing of plugging the affine operator into the GMRES/CG/etc. proof, just move the affine part to the rhs residual, and show it converges to solving Ax = b-c, and so GMRES/CG/etc. solves Q(x) = c for an affine operator properly. That same trick then can be used pretty much anywhere you would've had a linear operator to extend the proof to affine operators, so then exp(A*t)*v operations via Krylov methods work for A being affine as well, and all sorts of things. So affine operators have no matrix representation but they are still compatible with pretty much any iterative or Krylov method.

And many boundary conditions give not linear operators but affine operators, hence the existence of all of this.

@vpuri3 vpuri3 changed the title [WIP] clean up affine operator clean up affine operator Jun 3, 2022
test/sciml.jl Outdated Show resolved Hide resolved
test/sciml.jl Outdated Show resolved Hide resolved
@ChrisRackauckas ChrisRackauckas merged commit e9b7add into SciML:master Jun 4, 2022
@vpuri3 vpuri3 deleted the affine branch June 4, 2022 00:40
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

Successfully merging this pull request may close these issues.

None yet

2 participants