On Wed, Mar 20, 2013 at 4:22 PM, Barry Smith <bsmith at mcs.anl.gov> wrote: > > Why not just use one file, if Matlab is going to read them, it saves you > typing both when saving the matrices and when reading them in Matlab?
Because I didn't realize I could store multiple matrices in one file. Is this true for binary as well? > > If the matrices are not tiny you likely also want to use the binary viewer, > it will be much faster and work in parallel. I am using the binary viewer. Matlab is there for debugging. -Nachiket > > Barry > > On Mar 20, 2013, at 1:28 PM, Nachiket Gokhale <gokhalen at gmail.com> wrote: > >> I have this in my code: >> >> ierr = PetscViewerCreate(PETSC_COMM_WORLD,&RightViewer);CHKERRQ(ierr); >> ierr = PetscViewerSetType(RightViewer,PETSCVIEWERASCII);CHKERRQ(ierr); >> ierr = PetscViewerFileSetMode(RightViewer,FILE_MODE_WRITE);CHKERRQ(ierr); >> ierr = >> PetscViewerSetFormat(RightViewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); >> >> ierr = PetscViewerCreate(PETSC_COMM_WORLD,&LeftViewer);CHKERRQ(ierr); >> ierr = PetscViewerSetType(LeftViewer,PETSCVIEWERASCII);CHKERRQ(ierr); >> ierr = PetscViewerFileSetMode(LeftViewer,FILE_MODE_WRITE);CHKERRQ(ierr); >> ierr = >> PetscViewerSetFormat(LeftViewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); >> >> It would have been nice to create the LeftViewer from the RightViewer. >> That is what I am trying to do. >> >> At other places I use only one viewer to output left and right matrices: >> >> // projection matrices in ascii >> ierr = PetscViewerCreate(PETSC_COMM_WORLD,&ProjMatViewer);CHKERRQ(ierr); >> ierr = PetscViewerSetType(ProjMatViewer,PETSCVIEWERASCII);CHKERRQ(ierr); >> ierr = PetscViewerFileSetMode(ProjMatViewer,FILE_MODE_WRITE);CHKERRQ(ierr); >> ierr = >> PetscViewerSetFormat(ProjMatViewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); >> // right >> ierr = >> PetscViewerFileSetName(ProjMatViewer,projfileasciiright);CHKERRQ(ierr); >> ierr = MatView(ProjMatRight,ProjMatViewer);CHKERRQ(ierr); >> // left >> ierr = >> PetscViewerFileSetName(ProjMatViewer,projfileasciileft);CHKERRQ(ierr); >> ierr = MatView(ProjMatLeft,ProjMatViewer);CHKERRQ(ierr); >> // destroy >> ierr = PetscViewerDestroy(&ProjMatViewer);CHKERRQ(ierr); >> >> But I think switching the filename is inconvenient - I'd rather create >> a separate viewer Left and Right Matrices and have it copy the same >> parameters from an already created viewer. >> >> -Nachiket >> >> On Wed, Mar 20, 2013 at 2:16 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote: >>> What would it mean to duplicate a viewer? What are you actually trying to >>> do? >>> >>> On Mar 20, 2013 12:59 PM, "Nachiket Gokhale" <gokhalen at gmail.com> wrote: >>>> >>>> Not a show stopper, but would it be possible to add a >>>> PetscViewerDuplicate function? I don't see such a function here - >>>> >>>> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/index.html >>>> >>>> Cheers, -Nachiket >
