[petsc-users] MatMult method
Matthew Knepley
knepley at gmail.com
Thu Mar 31 09:44:07 CDT 2022
On Thu, Mar 31, 2022 at 10:11 AM Medane TCHAKOROM <
medane.tchakorom at univ-fcomte.fr> wrote:
> Hello,
>
> I got one issue with MatMult method that I do not understand.
>
> Whenever I multiply Matrix A by vector b (as shown below), the printed
> result
>
> show a value with an exponent that is far away form the expected result.
> So I did the same
>
> Matrix-vector product in python and get the expected answer (shown below).
>
> Can someone please explain what is going on, cause I need the exact
> results in order to compute the norm.
>
I did the multiply by hand. Your Python results are wrong for rows 5 and 6,
but the PETSc results are correct.
Thanks,
Matt
> Thanks
>
>
> *Matrix A*
>
> Mat Object: 1 MPI processes
> type: seqaij
> row 0: (0, 4.) (1, -1.) (4, -1.)
> row 1: (0, -1.) (1, 4.) (2, -1.) (5, -1.)
> row 2: (1, -1.) (2, 4.) (3, -1.) (6, -1.)
> row 3: (2, -1.) (3, 4.) (7, -1.)
> row 4: (0, -1.) (4, 4.) (5, -1.) (8, -1.)
> row 5: (1, -1.) (4, -1.) (5, 4.) (6, -1.) (9, -1.)
> row 6: (2, -1.) (5, -1.) (6, 4.) (7, -1.) (10, -1.)
> row 7: (3, -1.) (6, -1.) (7, 4.) (11, -1.)
>
>
> *Vector b*
>
>
> Vec Object: 1 MPI processes
> type: seq
> 0.998617
> 0.997763
> 0.997763
> 0.998617
> 0.996705
> 0.994672
> 0.994672
> 0.996705
> 0.993529
> 0.989549
> 0.989549
> 0.993529
> 0.997285
> 0.995611
> 0.995611
> 0.997285
>
>
> *PETSc Results with : MatMult (A,x, some_vector_to_store_the_result)*
>
> Vec Object: 1 MPI processes
> type: seq
> 2.
> 1.
> 1.
> 2.
> 1.
> 0.
> *1.11022e-16*
> 1.
>
>
>
> *Python result:*
>
> [ 2. 0.999999 0.999999 2. 0.990577 -0.015165 -0.015165 0.990577]
>
>
>
>
>
>
>
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220331/bb820308/attachment.html>
More information about the petsc-users
mailing list