[petsc-users] (no subject)

Jed Brown jedbrown at mcs.anl.gov
Fri Dec 28 17:02:47 CST 2012


On Fri, Dec 28, 2012 at 4:01 PM, Jelena Slivka <slivkaje at gmail.com> wrote:

> Hello!
> I have a few simple questions about PETSc about functions that I can't
> seem to find in the documentation:
> 1) Is there a way to automatically create a matrix in which all elements
> are the same scalar value a, e.g. something like ones(m,n) in Matlab?
>

That matrix (or any very low rank matrix) should not be stored explicitly
as a dense matrix.

2) Is there an equivalent to Matlab .* operator?
>

There is not a MatPointwiseMult(). It could be added, but I'm not aware of
a use for this operator outside of matrix misuse (using a Mat to represent
an array of numbers that are not an operator, thus should really be a Vec,
perhaps managed using DMDA).


> 3) Is there a function that can create matrix C by appending matrices A
> and B?
> Grateful in advance
>

Block matrices can be manipulated efficiently using MATNEST, but there is a
very high probability of misuse unless you really understand why that is an
appropriate data structure. Much more likely, you should create a matrix of
size C, then assemble the parts of A and B into it, perhaps using
MatGetLocalSubMatrix() so that the assembly "looks" like assembling A and B
separately.

Note that in parallel, you almost never want "concatenation" in the matrix
sense of [A B; C D]. Instead, you want that there is some row and column
permutation in which the operation would be concatenation, but in reality,
the matrices are actually interleaved with some granularity so that both
are well-distributed on the parallel machine.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121228/3bef7bdd/attachment.html>


More information about the petsc-users mailing list