[petsc-users] MatMult a MatNest and a Vec

Matthew Knepley knepley at gmail.com
Sat Oct 1 07:59:25 CDT 2011


On Sat, Oct 1, 2011 at 3:04 AM, Hui Zhang <mike.hui.zhang at hotmail.com>wrote:

> Thank you, Jed!  I have more questions:
>
> if I do C=A*B with A(or B) of MatNest type and B(or A, resp.) of usual
> type,
> what type will C be of?
>

There is an understanding problem here. PETSc does not create C, you do. You
determine its type.


> And is there any function not supporting MatNest, for example, does LU
> decomposition
> supports MatNest?
>

No, you would have to convert it, or pull out the block that you want LU of.


> Does one sometimes need to convert MatNest to the usual type and how to do
> it?
>

MatConvert.

   Matt


> The MatNest is useful to me because my matrix is in the form [K1*K2
>  K3*K4].
> I think to construct it as MatNest is easier than setting up Aij.
>
> Best wishes,
> Hui
>
> On Sep 30, 2011, at 7:08 PM, Jed Brown wrote:
>
> On Fri, Sep 30, 2011 at 10:51, Hui Zhang <mike.hui.zhang at hotmail.com>wrote:
>
>> Do you know what type of the resulting vector y by MatMult of a MatNest A
>> and a Vec x, i.e. y = Ax?
>>
>
> MatMult does not change the types of vectors. This function works with any
> types.
>
> Note, however, that many Vec operations require all arguments to have the
> same type, so you can't freely mix native Vec with VecNest. I don't
> recommend using VecNest unless you have a very specific use case and can
> explain to me why you should use it. (I do recommend using MatNest, but
> generally with the MatGetLocalSubMatrix() so you don't depend on it---I
> always try to avoid depending on implementations.)
>
>
>> Because after that I want to modify a SubVec of the result y. If it is a
>> VectNest, I think
>> VecNestGetSubVec should be used but not VecGetSubVector.
>>
>
> This is why VecNest implements VecGetSubVector (see VecGetSubVector_Nest).
>
>
>


-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111001/d59612c3/attachment-0001.htm>


More information about the petsc-users mailing list