Repository navigation
Add copy, dot, axpy! and arithmetic for Vec and Mat - #322
Merged
Merged
Conversation
PetscVec gets copy, dot, axpy!, axpby!, rmul!, lmul! and the operators x + y, x - y, -x, α * x and x / α; an assembled PetscMat gets copy, A + B, A - B, -A and α * A. They call the PETSc routines (VecDot, VecAXPY, VecWAXPY, MatAXPY, MatScale, ...), so they are collective and work on distributed objects, and dot conjugates its first argument as it does for Julia arrays. The docs index now lists Base and LinearAlgebra methods under their own names. Purely additive
filoferra
force-pushed
the
vec-mat-algebra
branch
from
October 28, 2026 17:08
f9499df to
f2d5f44
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PetscVecgetscopy,dot,axpy!,axpby!,rmul!,lmul!andx + y,x - y,-x,α * x,x / α. An assembledPetscMatgetscopy,A + B,A - B,-Aandα * A.VecDot,VecAXPY,VecAXPBY,VecScale,VecWAXPY,MatDuplicate,MatAXPY,MatScale), so they're collective and work on distributed objects.dot(x, y)conjugatesx, as for Julia arrays (PETSc'sVecDot(x, y)is yᴴx, so the call swaps the arguments).x / αdivides each entry, so it matchesxs ./ αexactly instead of scaling by 1/α.A ± Bworks when A and B have different nonzero patterns; the result has the union of the two.copyand the operators return a new object. Like a constructor's result, it has a finalizer only on one rank, so on more ranks calldestroy!on it.LinearAlgebra.normasPETSc.LinearAlgebra).