Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

SparseBitmatrix_setdifference.hpp

Go to the documentation of this file.
00001 
00006 #ifndef __SPARSEBITMATRIX_SETDIFFERENCE_HPP_
00007 #define __SPARSEBITMATRIX_SETDIFFERENCE_HPP_ t
00008 
00009 #include "eclat/SparseBitvector_setdifference.hpp"
00010 // #include "SparseBitmatrix.hpp"
00011 //#include "eclat/SparseBitmatrix_singleblock.hpp"
00012 #include "common/debug.hpp"
00013 
00014 
00030 template <bool EARLY_FILTERING, bool REMOVE_IDENTICAL_ROWS, class OutputIterator>
00031 int setdifferenceOfSparseBitmatrix(const SparseBitmatrix& bmIn, const int row, SparseBitmatrix& bmOut, 
00032                                    const int maximalLength, OutputIterator identicalRowsIterator) {
00033   assert(row >= 0 && row < bmIn.nRows());
00034 
00035   // 1. setup loop.
00036   bmOut.setNRows(bmIn.nRows() - row - 1);
00037   const GET_ROW(row1, bmIn, row); // legacy: const SparseBitvector row1(bmIn.getRow(row));
00038   int tor = 0;
00039   int maxRowLength = 0;
00040 
00041   // 2. iterate over all other rows:
00042   for (int fromr = row+1; fromr < bmIn.nRows(); fromr++) {
00043     // const SparseBitvector row2(bmIn.getRow(fromr));
00044     // SparseBitvector rowOut(bmOut.getRow(tor));
00045     const GET_ROW(row2, bmIn, fromr);
00046     GET_ROW(rowOut, bmOut, tor);
00047 
00048     const bool hasMaximalLength = EARLY_FILTERING && row1.length() > maximalLength
00049       ? setdifference<EARLY_FILTERING>(rowOut, row1, row2, maximalLength)
00050       : setdifference<false>(rowOut, row1, row2, maximalLength);
00051 
00052     // b. compute setdifference and retain if the defect is large enough.
00053     if (hasMaximalLength) {
00054       if (REMOVE_IDENTICAL_ROWS && rowOut.length() == 0)
00055         *identicalRowsIterator++ = bmIn.rowLabel(fromr); 
00056       else {
00057         if (rowOut.length() > maxRowLength)
00058           maxRowLength = rowOut.length();
00059         // bmOut.setRowLength(tor, rowOut.length());
00060         bmOut.setRowLabel(tor, bmIn.rowLabel(fromr));
00061         tor++;
00062       }
00063     }
00064   }
00065 
00066   bmOut.setNRows(tor);
00067   bmOut.setMaxRowLength(maxRowLength);
00068   return tor;
00069 }
00070 
00071 
00072 
00088 template <bool EARLY_FILTERING, bool REMOVE_IDENTICAL_ROWS, class OutputIterator>
00089 int setdifferenceBySparseBitmatrix(const SparseBitmatrix& bmIn, const int row, SparseBitmatrix& bmOut, 
00090                                    const int maximalLength, OutputIterator identicalRowsIterator) {
00091   assert(row >= 0 && row < bmIn.nRows());
00092 
00093   // 1. setup loop.
00094   bmOut.setNRows(bmIn.nRows() - row - 1);
00095   const GET_ROW(row1, bmIn, row); // legacy: const SparseBitvector row1(bmIn.getRow(row));
00096   int tor = 0;
00097   int maxRowLength = 0;
00098 
00099   // 2. iterate over all other rows:
00100   for (int fromr = row+1; fromr < bmIn.nRows(); fromr++) {
00101     const GET_ROW(row2, bmIn, fromr); // legacy: const SparseBitvector row2(bmIn.getRow(fromr));
00102     GET_ROW(rowOut, bmOut, tor);      // legacy: SparseBitvector rowOut(bmOut.getRow(tor));
00103 
00104     const bool hasMaximalLength = EARLY_FILTERING && row2.length() > maximalLength
00105       ? setdifference<EARLY_FILTERING>(rowOut, row2, row1, maximalLength)
00106       : setdifference<false>(rowOut, row2, row1, maximalLength);
00107 
00108     // b. compute setdifference and retain if the defect is large enough.
00109     if (hasMaximalLength) {
00110       if (REMOVE_IDENTICAL_ROWS && rowOut.length() == 0)
00111         *identicalRowsIterator++ = bmIn.rowLabel(fromr); 
00112       else {
00113         if (rowOut.length() > maxRowLength)
00114           maxRowLength = rowOut.length();
00115         // bmOut.setRowLength(tor, rowOut.length());
00116         bmOut.setRowLabel(tor, bmIn.rowLabel(fromr));
00117         tor++;
00118       }
00119     }
00120   }
00121 
00122   bmOut.setNRows(tor);
00123   bmOut.setMaxRowLength(maxRowLength);
00124   return tor;
00125 }
00126 
00127 
00132 template <bool EARLY_FILTERING>
00133 int cardinalitySetdifferenceBySparseBitmatrix_TwoRows(const SparseBitmatrix& bmIn, const int maximalLength) {
00134   const GET_ROW(row0, bmIn, 0); // legacy: const SparseBitvector row0(bmIn.getRow(0));
00135   const GET_ROW(row1, bmIn, 1); // legacy: const SparseBitvector row1(bmIn.getRow(1));
00136   return EARLY_FILTERING && row1.length() > maximalLength
00137     ? cardinalityOfSetdifference<EARLY_FILTERING>(row1, row0, maximalLength)
00138     : cardinalityOfSetdifference<false>(row1, row0, maximalLength);
00139 }
00140 
00141 
00142 #endif

Generated on Sun Sep 17 17:50:40 2006 for FIM environment by  doxygen 1.4.4