PlayaIncrementallyConfigurableMatrixFactory.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 //   
00003 /* @HEADER@ */
00004 
00005 #ifndef PLAYA_INCREMENTALLYCONFIGURABLEMATRIXFACTORY_HPP
00006 #define PLAYA_INCREMENTALLYCONFIGURABLEMATRIXFACTORY_HPP
00007 
00008 #include "PlayaDefs.hpp"
00009 
00010 namespace Playa
00011 {
00012   /** 
00013    * Class IncrementallyConfigurableMatrixFactory provides an abstract 
00014    * interface for row-at-a-time configuration of matrix factories.
00015    */
00016   class IncrementallyConfigurableMatrixFactory
00017   {
00018   public:
00019     /** Virtual dtor */
00020     virtual ~IncrementallyConfigurableMatrixFactory(){;}
00021 
00022     /** Initialize a set of nonzero elements in the matrix's graph.
00023      * @param globalRowIndex the global index of the row to which these
00024      * elements belong.
00025      * @param nElemsToInsert the number of elements being inserted in this
00026      * step
00027      * @param globalColumnIndices array of column indices. Must 
00028      * be nElemsToInsert in length. 
00029      */
00030     virtual void initializeNonzerosInRow(int globalRowIndex,
00031                                          int nElemsToInsert,
00032                                          const int* globalColumnIndices) = 0 ;
00033 
00034     /** 
00035      * Initialize nonzeros in a batch of rows. 
00036      */
00037     virtual void initializeNonzeroBatch(int numRows, 
00038                                         int rowBlockSize,
00039                                         const int* globalRowIndices,
00040                                         int numColumnsPerRow,
00041                                         const int* globalColumnIndices,
00042                                         const int* skipRow);
00043 
00044     /** Finalize values of the matrix. This is a hook for any
00045      * implementation-dependent steps that must be done after
00046      * loading of elements. */
00047     virtual void finalize() = 0 ;
00048 
00049   private:
00050     
00051     
00052   };
00053 
00054   /* Default implementation of initializeElementBatch */
00055   inline void IncrementallyConfigurableMatrixFactory
00056   ::initializeNonzeroBatch(int numRows, 
00057                            int rowBlockSize,
00058                            const int* globalRowIndices,
00059                            int numColumnsPerRow,
00060                            const int* globalColumnIndices,
00061                            const int* skipRow)
00062   {
00063     int numRowBlocks = numRows/rowBlockSize;
00064     int row = 0;
00065 
00066     for (int rb=0; rb<numRowBlocks; rb++)
00067       {
00068         const int* cols = globalColumnIndices + rb*numColumnsPerRow;
00069         for (int r=0; r<rowBlockSize; r++, row++)
00070           {
00071             if (skipRow[row]) continue;
00072             initializeNonzerosInRow(globalRowIndices[row], 
00073                                     numColumnsPerRow, cols);
00074           }
00075       }
00076   }
00077 }
00078 
00079 #endif

Site Contact