memory allocation

Barry Smith bsmith at
Fri Mar 6 12:58:50 CST 2009

On Mar 6, 2009, at 12:05 PM, Yixun Liu wrote:

> Hi,
> To allocate space for matrix I can specify the exact number of non- 
> zero
> elements for diagonal and off diagonal or just specify a maximal  
> number
> for each row. Do they have the same performance?

    If you specifiy the exact counts for each row then there will me  
no additional memory allocations and no wasted space.
If you provide an upper bound then then will be no additional memory  
allocations and some space (depending on the structure of your
matrix will be unused).

    Asside from memory usage both approaches will take the same amount  
of time.


> Thanks.
> Yixun

More information about the petsc-users mailing list