[petsc-users] Matricize a vector

Matthew Knepley knepley at gmail.com
Tue Sep 6 06:02:48 CDT 2011


On Tue, Sep 6, 2011 at 5:52 AM, <elam at cs.toronto.edu> wrote:

> Hello,
>
> Is it possible to reshape a vector into a matrix in PETSc?  I need to do
> this to compute a matrix vector multiplication (Ax) where the matrix A can
> be decomposed into Kronecker tensor format.  For example, A = A1 kron A2
> kron A3, where A1, A2, A3 are smaller sparse matrices.
>
> Essentially, I need to matricize the vector x and perform a series of
> matrix matrix multiplications to compute Ax.  In Matlab the function to
> perform the matricization is reshape.  Is there a similar function in
> PETSc?
>

1) This function only makes sense for dense matrices. That is not a huge
deal.


> I could implement the (tensor product) matrix vector multiplication by
> creating temporary matrices to store each of the intermediate matrix
> matrix multiplication results.  But this seems inefficient.  I was
> wondering if there is a more efficient way to implement this in PETSc?
> Can I simply reset the size of a matrix (as long as the number of elements
> remain the same) to reshape it?  Any suggestions would be appreciated.
>

2) However, it only makes sense in a very limited way in parallel. From your
     description above, I suspect what you need are calls to VecScatter() to
     select the part of the vector you need, do a local multiplication which
can
     easily wrap your vector as a dense matrix, and VecScatter back. This is
     essentially how SpMV is implemented.

Thus, I am saying that you will have to implement a MatMult() for your new
KroneckerProduct matrix class. You can set MATSHELL and set the mult
operation.

  Thanks,

     Matt


> Thank you for your help.
>
> Best regards,
>
> Elizabeth
>
>
>
>


-- 
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/20110906/b6a06677/attachment.htm>


More information about the petsc-users mailing list