Giter Site home page Giter Site logo

Comments (7)

lopezm94 avatar lopezm94 commented on May 23, 2024

Do you mean when b is a matrix? For me the program stops because of KrylovSubspace (not dot), which would require some change in the internals.

julia> x = rand(20,20); A = rand(20,20); b = rand(20,20);

julia> cg(A,b)
ERROR: DimensionMismatch("dimensions must match")
 in promote_shape at ./operators.jl:211

julia> cg!(x,A,b)
ERROR: MethodError: `init!` has no method matching init!(::IterativeSolvers.KrylovSubspace{Float64,Array{Float64,2}}, ::Array{Float64,2})
Closest candidates are:
  init!{T}(::IterativeSolvers.KrylovSubspace{T,OpT}, ::Array{T,1})

from differentialequations.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 23, 2024

Yes, that's the error which stops it from working. Either cg needs to be changed in IterativeSolvers, or an alternative version needs to be implemented just for this.

from differentialequations.jl.

lopezm94 avatar lopezm94 commented on May 23, 2024

I don't really know what the future plan for KrylovSubspace should be for handling matrices.

@jiahao

from differentialequations.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 23, 2024

Now that I think about, if I'm not mistaken, this can just be done with a comprehension over the iterative solvers. For example, when solving AX=B with X a matrix, the values of X[i,:] only depend on B[i,:] (think about the way it multiplies). So actually this is just shorthand for n independent Ax=b problems, where the A happens to be the same each time. So a comprehension or loop over the columns with cg calls solves it.

(Would there be any efficiency gains by handling it somewhat similarly inside the cg loop? I can't see a reason why there would be)

Should there be type annotation on the b and x in cg then to clarify that it's for vectors? And would this wrapper for matrices be welcomed in IterativeSolvers.jl itself, or should I make it and keep it here?

from differentialequations.jl.

lopezm94 avatar lopezm94 commented on May 23, 2024

Does the stopping criteria change for matrices? Yeah what you are saying could be done easily in a patch, but at the moment the pull request are merging slowly (might take some time).

from differentialequations.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 23, 2024

I think the stopping criteria can be done either way. Theoretically there is none so it's just what's practical. In practice, by doing a loop over cg it will go until the tolerance is satisfied for each, whereas if it was implemented in the loop it could check the convergence of the whole B-AX in some suitable norm. By the Triangle Inequality the second form would be a weaker condition, though one could always adjust the tolerances to account for it.

However, in the case of PDEs it may be more practical to allow the different columns to have the errors/tolerances applied separately because they may differ vastly in their values (one case where this may come up is a PDE where the components are kept in the columns of X, but some substances have much higher values, and thus would dominate the norm allowing for a lot of error in the other values. This could be terrible in cases where relative tolerance dominates).

from differentialequations.jl.

ChrisRackauckas avatar ChrisRackauckas commented on May 23, 2024

It works. However, I wasn't able to use views, so it has some extra allocations. Noted in #33

from differentialequations.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.