[petsc-users] About MatTransposeMatMult

Joon Hee Choi choi240 at purdue.edu
Thu Sep 26 03:31:41 CDT 2013

Hello all,

I am trying to calculate M = X^T * B. X is a seqaij and B is a seqdense matrix.
However, I used MatTransposeMatMult() but I got an error. Can someone why I got the error and how I should modify my code? I am attaching my simple code, error message, and result. Thank you very much.


PetscInt m1, m2, n1, n2;
MatType t1, t2;
ierr = MatGetType(X, &t1); CHKERRQ(ierr);
ierr = MatGetType(B, &t2); CHKERRQ(ierr);
ierr = MatGetSize(X, &m1, &n1); CHKERRQ(ierr);
ierr = MatGetSize(B, &m2, &n2); CHKERRQ(ierr);
PetscPrintf(PETSC_COMM_SELF, "X: %s \n", t1);
PetscPrintf(PETSC_COMM_SELF, "B: %s \n", t2);
PetscPrintf(PETSC_COMM_SELF, "X: %d x %d \n", m1, n1);
PetscPrintf(PETSC_COMM_SELF, "B: %d x %d \n", m2, n2);
ierr = MatTransposeMatMult(X, B, MAT_INITIAL_MATRIX, PETSC_DEFAULT, &matM); CHKERRQ(ierr);

[0]PETSC ERROR: --------------------- Error Message ------------------------------------
[0]PETSC ERROR: Arguments are incompatible!
[0]PETSC ERROR: MatTransposeMatMult requires A, seqaij, to be compatible with B, seqdense!

X: seqaij
B: seqdense
X: 3 x 12
B: 3 x 2

More information about the petsc-users mailing list