Hi,

I think that there is a bug in the MatMultAdd_Shell function when entries y and z are the same Vec. It is not possible to call

VecWAXPY(z,1.0,shell->right_add_work,y);

if z and y are the same Vec.

I have attached a patch.

Best,
Loic

--
Loic Gouarin
Laboratoire de Mathématiques
Université Paris-Sud
Bâtiment 425
91405 Orsay Cedex
France
Tel: (+33) 1 69 15 60 14
Fax: (+33) 1 69 15 67 18

>From 34c4a17d78ea5ef4856b55d0a3ec29fd409ee54b Mon Sep 17 00:00:00 2001
From: gouarin <[email protected]>
Date: Sun, 29 Mar 2015 15:53:29 +0200
Subject: [PATCH] fix a bug in matmultadd_shell when y and z are the same Vec

---
 src/mat/impls/shell/shell.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mat/impls/shell/shell.c b/src/mat/impls/shell/shell.c
index 221ec69..ef5b0be 100644
--- a/src/mat/impls/shell/shell.c
+++ b/src/mat/impls/shell/shell.c
@@ -256,7 +256,7 @@ PetscErrorCode MatMultAdd_Shell(Mat A,Vec x,Vec y,Vec z)
   if (y == z) {
     if (!shell->right_add_work) {ierr = VecDuplicate(z,&shell->right_add_work);CHKERRQ(ierr);}
     ierr = MatMult(A,x,shell->right_add_work);CHKERRQ(ierr);
-    ierr = VecWAXPY(z,1.0,shell->right_add_work,y);CHKERRQ(ierr);
+    ierr = VecAXPY(z,1.0,shell->right_add_work);CHKERRQ(ierr);
   } else {
     ierr = MatMult(A,x,z);CHKERRQ(ierr);
     ierr = VecAXPY(z,1.0,y);CHKERRQ(ierr);
-- 
2.1.0

Reply via email to