Assembling a matrix
Douglas Arnold
arnold at umn.edu
Fri Dec 18 17:59:59 CST 2009
Anirban Chatterjee asked how to assemble an (n+1)x(n+1) sparse matrix
B = [A v;
v^T c]
from an nxn sparse matrix A, a vector v, and a scalar c. Matt
Knepley and Barry Smith advised against it.
I have pretty much the same problem and I want to make sure I
understand the situation. In my case, the matrix A comes to me
from another application that I would rather not fiddle with.
The rank of A is n-1 and v is a vector in its nullspace, c=0. I would
like to solve a system with the matrix B by a direct solver, and
so I think I need to assemble it. Do I understand correctly that
there is no efficient way to do this in PETSc? Even in a sequential
computation?
-- Doug
> Where will the "new" row live? On the last process, why that one?
>
> Does the matrix A have to be completely assembled before the v is
> computed? Or can the entries of A be computed at the same time as the v?
>
> PETSc doesn't have code to efficiently dynamically change the size
> of a matrix. Thus generating a new matrix from a given sparse matrix
> plus a new row requires a complete copy of the starting matrix into
> the new matrix data structure. If you assemble the entire matrix
> together without first generating the smaller matrix A then it is
> easy; just generate the preallocation structure of A with the one
> additional row/column information and call MatSetValues() to put in
> the parts of A and the parts of v.
>
> Barry
>
> On Dec 8, 2009, at 4:05 PM, Anirban Chatterjee wrote:
>
>> Hi,
>>
>> I have an nxn matrix A, a column vector v and a scalar c. I want to
>> assemble a matrix B as follows,
>> B = [A v;
>> v^T c]
>> Can someone tell me the easiest and most efficient way to do this.
>>
>> --Anirban
More information about the petsc-users
mailing list