Hi,

I am having trouble with using the function MatMult in PETSc. The result of MatMult(A, x, Ax) (using multiprocessors) is not equal to the result of A*x computed in Matlab.
The format of the matrix A is AIJ and is obtained by function SNESDefaultComputeJacobian.
I compute A*x in Matlab with the following A and x and compare it with Ax.

        .......................
        ierr = MatMult(*A, x, Ax);CHKERRQ(ierr);

        sprintf(filename,"x.m");
        ierr = PetscViewerASCIIOpen(PETSC_COMM_WORLD,filename,&view->viewer);CHKERRQ(ierr);
        ierr = PetscViewerSetFormat(view->viewer, PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr);
        ierr = VecView(x, view->viewer);CHKERRQ(ierr);

        sprintf(filename,"Ax.m");
        ierr = PetscViewerASCIIOpen(PETSC_COMM_WORLD,filename,&view->viewer);CHKERRQ(ierr);
        ierr = PetscViewerSetFormat(view->viewer, PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr);
        ierr = VecView(Ax, view->viewer);CHKERRQ(ierr); 
        .....................

What kind of bug can cause this problem?

Thanks.

Best,

Rongliang