static char help[] = "Test MatTransposeMatMult() \n\n"; /* Example: mpiexec -n 8 ./ex209 -f (e.g., inputfile=ceres_solver_iteration_001_A.petsc) */ #include int main(int argc,char **args) { Mat A,C,AtA,B; PetscViewer fd; char file[PETSC_MAX_PATH_LEN]; PetscReal fill = 4.0; PetscMPIInt rank,size; PetscBool equal; PetscInt i,m,n,rstart,rend; PetscScalar one=1.0; PetscCall(PetscInitialize(&argc,&args,(char*)0,help)); PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank)); PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size)); PetscCall(PetscOptionsGetString(NULL,NULL,"-f",file,sizeof(file),NULL)); /* Load matrix A */ PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&fd)); PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetType(A,MATAIJ)); PetscCall(MatLoad(A,fd)); PetscCall(PetscViewerDestroy(&fd)); /* Create identity matrix B */ PetscCall(MatGetLocalSize(A,&m,&n)); PetscCall(MatCreate(PETSC_COMM_WORLD,&B)); PetscCall(MatSetSizes(B,m,m,PETSC_DECIDE,PETSC_DECIDE)); PetscCall(MatSetType(B,MATAIJ)); PetscCall(MatSetFromOptions(B)); PetscCall(MatSetUp(B)); PetscCall(MatGetOwnershipRange(B,&rstart,&rend)); for (i=rstart; i