Date: 2015-10-02T22:12:55+00:00

Actual source code: power.c
petsc-3.6.2 2015-10-02
Report Typos and Errors

      1: #include <petsc/private/matimpl.h>      /*I "petscmat.h"  I*/

      5: PETSC_EXTERN PetscErrorCode MatColoringApply_Power(MatColoring mc,ISColoring *iscoloring)
      6: {
      7:   PetscErrorCode  ierr;
      8:   Mat             m = mc->mat,mp,ms;
      9:   MatColoring     imc;
     10:   PetscInt        i;
     11:   const char      *optionsprefix;

     14:   /* square the matrix repeatedly if necessary */
     15:   if (mc->dist == 1) {
     16:     mp = m;
     17:   } else {
     18:     MatMatMult(m,m,MAT_INITIAL_MATRIX,2.0,&mp);
     19:     for (i=2;i<mc->dist;i++) {
     20:       ms = mp;
     21:       MatMatMult(m,ms,MAT_INITIAL_MATRIX,2.0,&mp);
     22:       MatDestroy(&ms);
     23:     }
     24:   }
     25:   MatColoringCreate(mp,&imc);
     26:   PetscObjectGetOptionsPrefix((PetscObject)mc,&optionsprefix);
     27:   PetscObjectSetOptionsPrefix((PetscObject)imc,optionsprefix);
     28:   PetscObjectAppendOptionsPrefix((PetscObject)imc,"power_");
     29:   MatColoringSetType(imc,MATCOLORINGGREEDY);
     30:   MatColoringSetDistance(imc,1);
     31:   MatColoringSetWeightType(imc,mc->weight_type);
     32:   MatColoringSetFromOptions(imc);
     33:   MatColoringApply(imc,iscoloring);
     34:   MatColoringDestroy(&imc);
     35:   if (mp != m) {MatDestroy(&mp);}
     36:   return(0);
     37: }

     41: /*MC
     42:   MATCOLORINGPOWER - Take the matrix's nth power, then do one-coloring on it.

     44:    Level: beginner

     46:    Notes:
     47:    This is merely a trivial test algorithm.

     49: .seealso: MatColoringCreate(), MatColoring, MatColoringSetType()
     50: M*/
     51: PETSC_EXTERN PetscErrorCode MatColoringCreate_Power(MatColoring mc)
     52: {
     54:   mc->ops->apply          = MatColoringApply_Power;
     55:   mc->ops->view           = NULL;
     56:   mc->ops->destroy        = NULL;
     57:   mc->ops->setfromoptions = NULL;
     58:   return(0);
     59: }