[petsc-dev] VECCUSP needs to be zeroed?

Lisandro Dalcin dalcinl at gmail.com
Wed Nov 9 09:57:10 CST 2011


On 8 November 2011 09:51, Matthew Knepley <knepley at gmail.com> wrote:
> On Tue, Nov 8, 2011 at 10:37 AM, Jose E. Roman <jroman at dsic.upv.es> wrote:
>>
>> The following code prints a vector of uninitialized entries.
>>
>>  ierr = VecCreate(comm,&v);CHKERRQ(ierr);
>>  ierr = VecSetSizes(v,n,n);CHKERRQ(ierr);
>>  ierr = VecSetType(v,VECSEQCUSP);CHKERRQ(ierr);
>>  ierr = VecView(v,PETSC_NULL);CHKERRQ(ierr);
>>
>> In contrast, if the type is VECSEQ the vector is initialized to zero. So
>> it seems that VecSet(v,0.0) must always be called. Is this the expected
>> behaviour?
>
> There is no guarantee of initialization for any Vec type.
>    Matt

Are you 100% sure about this? What's the point of wasting cycles by
explicitly calling Memzero in VecCreate_Seq? I bet may codes out there
(and even PETSc's testsuite) will break if you do not initialize all
entries to zero! For example, if you create a Vec or Mat and
immediately enter a loop using {Vec|Mat}SetValues(..., ADD_VALUES), I
think most people would expect this to work.


-- 
Lisandro Dalcin
---------------
CIMEC (INTEC/CONICET-UNL)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
3000 Santa Fe, Argentina
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169



More information about the petsc-dev mailing list