I am trying to understand how to use a transposed matrix view along the lines of Numpy ( https://github.com/ParRes/Kernels/blob/master/PYTHON/transpose-numpy.py#L99 ).
https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateTranspose.html says "Creates a new matrix object that behaves like A'" But later it seems to suggest that this is only true when performance a matrix-vector product: "Rather the new matrix object performs the matrix-vector product by using the MatMultTranspose() on the original matrix" I got the idea to use this view concept from https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatTranspose.html, which says: "Consider using MatCreateTranspose() instead if you only need a matrix that behaves like the transpose, but don't need the storage to be changed." When I try to use the transpose view in MatAXPY using this code: Mat AT; ierr = MatCreateTranspose(A, &AT); // create transpose view of A ierr = MatAXPY(B, one, AT, SAME_NONZERO_PATTERN); I get an error suggesting that I am doing something bad: [0]PETSC ERROR: --------------------- Error Message -------------------------------------------------------------- [0]PETSC ERROR: Object is in wrong state [0]PETSC ERROR: Not for unassembled matrix (Y) [0]PETSC ERROR: See https://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting. [0]PETSC ERROR: Petsc Release Version 3.13.1, unknown [0]PETSC ERROR: ./transpose-petsc on a named jrhammon-nuc by jrhammon Mon Jun 1 15:38:20 2020 [0]PETSC ERROR: Configure options --prefix=/home/jrhammon/PRK/deps/petsc --with-blaslapack-dir=/opt/intel/inteloneapi/mkl/2021.1-beta06 --with-mpi-dir=/opt/intel/inteloneapi/mpi/2021.1-beta06 --with-cxx=0 --with-fc=0 [0]PETSC ERROR: #1 MatAXPY() line 74 in /home/jrhammon/PRK/deps/petsc-src/src/mat/utils/axpy.c [0]PETSC ERROR: #2 main() line 170 in transpose-petsc.c [0]PETSC ERROR: PETSc Option Table entries: [0]PETSC ERROR: -i 10 [0]PETSC ERROR: -n 100 [0]PETSC ERROR: ----------------End of Error Message -------send entire error message to [email protected] What do I need to do to use a transpose view properly outside of M*V? Thanks, Jeff -- Jeff Hammond [email protected] http://jeffhammond.github.io/
