00001
00019 #include "mvc.h"
00020
00024
00028
00040 Mvc_Cover_t * Mvc_CoverAlgebraicMultiply( Mvc_Cover_t * pCover1, Mvc_Cover_t * pCover2 )
00041 {
00042 Mvc_Cover_t * pCover;
00043 Mvc_Cube_t * pCube1, * pCube2, * pCube;
00044 int CompResult;
00045
00046
00047 assert( pCover1->nBits == pCover2->nBits );
00048
00049 Mvc_CoverAllocateMask( pCover1 );
00050 Mvc_CoverAllocateMask( pCover2 );
00051 Mvc_CoverSupport( pCover1, pCover1->pMask );
00052 Mvc_CoverSupport( pCover2, pCover2->pMask );
00053
00054 Mvc_CubeBitDisjoint( CompResult, pCover1->pMask, pCover2->pMask );
00055 if ( !CompResult )
00056 printf( "Mvc_CoverMultiply(): Cover supports are not disjoint!\n" );
00057
00058
00059 pCover = Mvc_CoverClone( pCover1 );
00060 Mvc_CoverForEachCube( pCover1, pCube1 )
00061 Mvc_CoverForEachCube( pCover2, pCube2 )
00062 {
00063
00064 pCube = Mvc_CubeAlloc( pCover );
00065
00066 Mvc_CubeBitOr( pCube, pCube1, pCube2 );
00067
00068 Mvc_CoverAddCubeTail( pCover, pCube );
00069 }
00070 return pCover;
00071 }
00072
00073
00085 Mvc_Cover_t * Mvc_CoverAlgebraicSubtract( Mvc_Cover_t * pCover1, Mvc_Cover_t * pCover2 )
00086 {
00087 Mvc_Cover_t * pCover;
00088 Mvc_Cube_t * pCube1, * pCube2, * pCube;
00089 int fFound;
00090 int CompResult;
00091
00092
00093 assert( pCover1->nBits == pCover2->nBits );
00094
00095
00096 pCover = Mvc_CoverClone( pCover1 );
00097 Mvc_CoverForEachCube( pCover1, pCube1 )
00098 {
00099 fFound = 0;
00100 Mvc_CoverForEachCube( pCover2, pCube2 )
00101 {
00102 Mvc_CubeBitEqual( CompResult, pCube1, pCube2 );
00103 if ( CompResult )
00104 {
00105 fFound = 1;
00106 break;
00107 }
00108 }
00109 if ( !fFound )
00110 {
00111
00112 pCube = Mvc_CubeDup( pCover, pCube1 );
00113
00114 Mvc_CoverAddCubeTail( pCover, pCube );
00115 }
00116 }
00117 return pCover;
00118 }
00119
00131 int Mvc_CoverAlgebraicEqual( Mvc_Cover_t * pCover1, Mvc_Cover_t * pCover2 )
00132 {
00133 Mvc_Cube_t * pCube1, * pCube2;
00134 int fFound;
00135 int CompResult;
00136
00137
00138 assert( pCover1->nBits == pCover2->nBits );
00139
00140 Mvc_CoverForEachCube( pCover1, pCube1 )
00141 {
00142 fFound = 0;
00143 Mvc_CoverForEachCube( pCover2, pCube2 )
00144 {
00145 Mvc_CubeBitEqual( CompResult, pCube1, pCube2 );
00146 if ( CompResult )
00147 {
00148 fFound = 1;
00149 break;
00150 }
00151 }
00152 if ( !fFound )
00153 return 0;
00154 }
00155 return 1;
00156 }
00157
00158
00162
00163