So it turns out my fix broke something else (I should have done more 
testing). I've attached the patch to the patch I provided for you. Apply this 
after the you apply the patch I previously sent you

Attachment: fix-fix-matview-matlab-name.patch
Description: Binary data

  Or better start using the copy of the PETSc in the repository: 
http://www.mcs.anl.gov/petsc/developers/index.html  the branch maint 
corresponds to the last release plus some additional fixes. The branch master 
corresponds to the development copy that we are currently adding features to.

   Barry

> On Jan 17, 2015, at 3:46 PM, Barry Smith <[email protected]> wrote:
> 
> 
>  Michael,
> 
>    Thanks for reporting this. I have fixed it in out maint and master branch 
> and it will be fixed in our next patch update. I've also attached a patch 
> file that you can use to update your copy of PETSc.  
> <fix-matview-matlab-name.patch>
> 
> Note 1:  The reason for the zzz = zeros(3,3); is that for large matrices in 
> Matlab it is (was?) much better to allocate a array of the correct final size 
> before actually providing the entries in the matrix, otherwise Matlab would 
> slowly dynamically keep increasing the size of the matrix as it found more 
> entries in the matrix you provided. This is why we have this line.
> 
> zzz = zeros(3,3);
> zzz = [
> 1 1  1.0000000000000000e+00
> 2 2  1.0000000000000000e+00
> 3 3  1.0000000000000000e+00
> ];
> A = spconvert(zzz);
> 
> Note: 2 If the matrix is large at all you do not want to save as an ASII 
> matlab file. Instead save using the binary viewer and use the PETSc Matlab 
> script PetscBinaryRead() to read it into Matlab. This will be much much 
> faster for large matrices. For tiny matrices using the ASCII viewer is fine.
> 
>   Thanks
>   Barry
> 
> 
> 
>> On Jan 17, 2015, at 2:29 PM, Michael Souza <[email protected]> wrote:
>> 
>> The name of variable created by MatView using PETSC_VIEWER_ASCII_MATLAB is 
>> not the expected one. More clearly, the name of variable is "zzz" no matter 
>> what you set by calling PetscObjectSetName. 
>> 
>> The code below reproduces the unexpected behaviour. There, I create a 
>> diagonal MATMPIAIJ matrix and I set its name to "A", but the name of created 
>> variable in MATLAB's script is "zzz".
>> 
>> I also would like to point that there is no need to print the line "zzz = [m 
>> n];" once its value will not be used and it will produce an warning at 
>> Matlab's editor. So I think it could be removed.
>> 
>> Note: This strange behaviour doesn't occur with MATSEQAIJ matrices.
>> 
>> Cheers,
>> Michael Souza
>> ----------------------------------------------------------
>> int main(int argc, char **args) {
>>    PetscErrorCode ierr;
>>    Mat A;
>>    PetscInt i, N = 3;
>> 
>>    ierr = PetscInitialize(&argc, &args, (char *) 0, help);CHKERRQ(ierr);
>> 
>>    // matrix creation and setup
>>    ierr = MatCreate(PETSC_COMM_WORLD, &A);CHKERRQ(ierr);
>>    ierr = MatSetType(A, MATMPIAIJ);CHKERRQ(ierr);
>>    ierr = MatSetSizes(A, PETSC_DECIDE, PETSC_DECIDE, N, N);CHKERRQ(ierr);
>>    ierr = MatSetUp(A);CHKERRQ(ierr);
>>    for (i = 0; i < N; i++) {
>>        ierr = MatSetValue(A, i, i, 1.0, INSERT_VALUES);CHKERRQ(ierr);
>>    }
>>    ierr = MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
>>    ierr = MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
>> 
>>    // matlab viewer
>>    ierr = PetscViewerSetFormat(PETSC_VIEWER_STDOUT_WORLD, 
>> PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr);
>>    ierr = PetscObjectSetName((PetscObject) A, "A");CHKERRQ(ierr);
>>    ierr = MatView(A, PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
>> 
>>    // free memory
>>    ierr = MatDestroy(&A);CHKERRQ(ierr);
>> 
>>    ierr = PetscFinalize();CHKERRQ(ierr);
>> 
>>    return EXIT_SUCCESSSS;
>> }
>> ----------------------------------------------------------
>> 
> 

Reply via email to