00001
00002
00003
00004
00005 #ifndef PLAYA_INCREMENTALLYCONFIGURABLEMATRIXFACTORY_HPP
00006 #define PLAYA_INCREMENTALLYCONFIGURABLEMATRIXFACTORY_HPP
00007
00008 #include "PlayaDefs.hpp"
00009
00010 namespace Playa
00011 {
00012
00013
00014
00015
00016 class IncrementallyConfigurableMatrixFactory
00017 {
00018 public:
00019
00020 virtual ~IncrementallyConfigurableMatrixFactory(){;}
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 virtual void initializeNonzerosInRow(int globalRowIndex,
00031 int nElemsToInsert,
00032 const int* globalColumnIndices) = 0 ;
00033
00034
00035
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
00045
00046
00047 virtual void finalize() = 0 ;
00048
00049 private:
00050
00051
00052 };
00053
00054
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