[petsc-users] MatScale returns different results depending on matrix size

Matthew Knepley knepley at gmail.com
Tue Jan 5 08:21:19 CST 2021


On Tue, Jan 5, 2021 at 7:57 AM Roland Richter <roland.richter at ntnu.no>
wrote:

> Hei,
>
> I would like to scale a given matrix with a fixed scalar value, and
> therefore would like to use MatScale(). Nevertheless, I observed an
> interesting behavior depending on the size of the matrix, and currently
> I am not sure why.
>
> When running the attached code, I intend to divide all elements in the
> matrix by a constant factor of 10. If I have three or fewer rows and
> 1024 columns, I get the expected result. If I have four or more rows
> (with the same number of columns), suddenly my scaling factor seems to
> be 0.01 instead of 0.1 for the PETSc-matrix. The armadillo-based matrix
> still behaves as expected.
>

1) It looks like you assume the storage in your armadillo matrix is row
major. I would be surprised if this was true.

2) I think it is unlikely that there is a problem with MatScale, so I would
guess either you have a memory overwrite
or are misinterpreting your output. If you send something I can run, I will
figure out which it is.

  Thanks,

     Matt


> I currently do not understand that behavior, but do not see any problems
> with the code either. Are there any possible explanations for that
> behavior?
>
> Thank you very much,
>
> regards,
>
> Roland Richter
>
>

-- 
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/20210105/19b6953d/attachment.html>


More information about the petsc-users mailing list