[petsc-users] Reshaping a vector into a matrix

Barry Smith bsmith at mcs.anl.gov
Thu Jan 6 14:37:25 CST 2011


On Jan 6, 2011, at 11:48 AM, S V N Vishwanathan wrote:

> On Thu, 2011-01-06 at 08:40 -0800, Jed Brown wrote:
>> On Wed, Jan 5, 2011 at 22:02, S V N Vishwanathan
>> <vishy at stat.purdue.edu> wrote:
>>        I mean a two dimensional array. Basically my parameter vector
>>        is of the
>>        form
>> 
>>        vec = (vec1^t, vec2^t, vec3^t,...veck^t)^t
>> 
>>        which I represent as a Petsc Vector. In my objective function
>>        calculation I am given a matrix X and need to compute
>> 
>>        fx = (X.vec1, X.vec2, ..., X.veck)^t
>> 
>> 1. How big is "k"?
> 
> My k is typically of the order of 10 to a 100 (max).
> 
>> 2. Since each vec1,vec2,... is the same size, this is likely to
>> produce poor memory performance.  If you care about speed, I suggest
>> interlacing the values in vec1,...,veck.  In that case, you can create
>> an MAIJ matrix that acts on this "multi-vector".
> 
> I do not want to repeat X since it is a large sparse matrix (typically 1
> million x 50 thousand) with around 4 -5% non-zero entries. However this
> varies a lot from problem to problem. In some cases a dense matrix is
> the most appropriate representation for X (in this case the dimensions
> are typically 50thousand x 200). 
> 
> I am trying to use the block matrices and vectors provided by PetscExt
> to see if they can solve my problem.

   You most definitely want to use the MAIJ.  MAIJ does not "repeat" X, it uses the original matrix passed in but does efficient multiple matrix-vector products at the same time.

   Barry

> 
> vishy
> 
> 



More information about the petsc-users mailing list