Changeset 1050 for cpp/frams/model/similarity/EMD
- Timestamp:
- 12/11/20 21:40:59 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/model/similarity/EMD/emd.c
r1044 r1050 54 54 /* GLOBAL VARIABLE DECLARATION */ 55 55 static int _n1, _n2; /* SIGNATURES SIZES */ 56 static float _C [MAX_SIG_SIZE1][MAX_SIG_SIZE1];/* THE COST MATRIX */57 static node2_t _X [MAX_SIG_SIZE1*2]; /* THE BASIC VARIABLES VECTOR */56 static float _CM[MAX_SIG_SIZE1][MAX_SIG_SIZE1];/* THE COST MATRIX */ 57 static node2_t _XV[MAX_SIG_SIZE1*2]; /* THE BASIC VARIABLES VECTOR */ 58 58 /* VARIABLES TO HANDLE _X EFFICIENTLY */ 59 59 static node2_t *_EndX, *_EnterX; … … 146 146 if (Flow != NULL) 147 147 FlowP = Flow; 148 for(XP=_X ; XP < _EndX; XP++)148 for(XP=_XV; XP < _EndX; XP++) 149 149 { 150 150 if (XP == _EnterX) /* _EnterX IS THE EMPTY SLOT */ … … 156 156 continue; 157 157 158 totalCost += (double)XP->val * _C [XP->i][XP->j];158 totalCost += (double)XP->val * _CM[XP->i][XP->j]; 159 159 if (Flow != NULL) 160 160 { … … 205 205 for(j=0, P2=Signature2->Features; j < _n2; j++, P2++) 206 206 { 207 _C [i][j] = Dist(P1, P2);208 if (_C [i][j] > _maxC)209 _maxC = _C [i][j];207 _CM[i][j] = Dist(P1, P2); 208 if (_CM[i][j] > _maxC) 209 _maxC = _CM[i][j]; 210 210 } 211 211 … … 233 233 { 234 234 for (j=0; j < _n2; j++) 235 _C [_n1][j] = 0;235 _CM[_n1][j] = 0; 236 236 S[_n1] = -diff; 237 237 _RowsX[_n1] = NULL; … … 241 241 { 242 242 for (i=0; i < _n1; i++) 243 _C [i][_n2] = 0;243 _CM[i][_n2] = 0; 244 244 D[_n2] = diff; 245 245 _ColsX[_n2] = NULL; … … 252 252 for (j=0; j < _n2; j++) 253 253 _IsX[i][j] = 0; 254 _EndX = _X ;254 _EndX = _XV; 255 255 256 256 _maxW = sSum > dSum ? sSum : dSum; … … 345 345 { 346 346 /* COMPUTE U[i] */ 347 CurU->val = _C [i][j] - CurV->val;347 CurU->val = _CM[i][j] - CurV->val; 348 348 /* ...AND ADD IT TO THE MARKED LIST */ 349 349 PrevU->Next = CurU->Next; … … 375 375 { 376 376 /* COMPUTE V[j] */ 377 CurV->val = _C [i][j] - CurU->val;377 CurV->val = _CM[i][j] - CurU->val; 378 378 /* ...AND ADD IT TO THE MARKED LIST */ 379 379 PrevV->Next = CurV->Next; … … 417 417 if (! _IsX[i][j]) 418 418 { 419 delta = _C [i][j] - U[i].val - V[j].val;419 delta = _CM[i][j] - U[i].val - V[j].val; 420 420 if (deltaMin > delta) 421 421 { … … 540 540 CurX = Loop; 541 541 NewX = *CurX = _EnterX; 542 IsUsed[_EnterX-_X ] = 1;542 IsUsed[_EnterX-_XV] = 1; 543 543 steps = 1; 544 544 … … 549 549 /* FIND AN UNUSED X IN THE ROW */ 550 550 NewX = _RowsX[NewX->i]; 551 while (NewX != NULL && IsUsed[NewX-_X ])551 while (NewX != NULL && IsUsed[NewX-_XV]) 552 552 NewX = NewX->NextC; 553 553 } … … 556 556 /* FIND AN UNUSED X IN THE COLUMN, OR THE ENTERING X */ 557 557 NewX = _ColsX[NewX->j]; 558 while (NewX != NULL && IsUsed[NewX-_X ] && NewX != _EnterX)558 while (NewX != NULL && IsUsed[NewX-_XV] && NewX != _EnterX) 559 559 NewX = NewX->NextR; 560 560 if (NewX == _EnterX) … … 566 566 /* ADD X TO THE LOOP */ 567 567 *++CurX = NewX; 568 IsUsed[NewX-_X ] = 1;568 IsUsed[NewX-_XV] = 1; 569 569 steps++; 570 570 #if DEBUG_LEVEL > 3 … … 584 584 else 585 585 NewX = NewX->NextC; 586 } while (NewX != NULL && IsUsed[NewX-_X ]);586 } while (NewX != NULL && IsUsed[NewX-_XV]); 587 587 588 588 if (NewX == NULL) 589 589 { 590 IsUsed[*CurX-_X ] = 0;590 IsUsed[*CurX-_XV] = 0; 591 591 CurX--; 592 592 steps--; … … 598 598 steps, NewX->i, NewX->j); 599 599 #endif 600 IsUsed[*CurX-_X ] = 0;600 IsUsed[*CurX-_XV] = 0; 601 601 *CurX = NewX; 602 IsUsed[NewX-_X ] = 1;602 IsUsed[NewX-_XV] = 1; 603 603 } 604 604 } while(CurX >= Loop); … … 659 659 { 660 660 float v; 661 v = _C [i][j];661 v = _CM[i][j]; 662 662 if (Ur[i].val <= v) 663 663 Ur[i].val = v; … … 669 669 for(i=0; i < _n1 ; i++) 670 670 for(j=0; j < _n2 ; j++) 671 Delta[i][j] = _C [i][j] - Ur[i].val - Vr[j].val;671 Delta[i][j] = _CM[i][j] - Ur[i].val - Vr[j].val; 672 672 673 673 /* FIND THE BASIC VARIABLES */ … … 727 727 int j; 728 728 j = CurV->i; 729 if (CurV->val == _C [minI][j]) /* COLUMN j NEEDS UPDATING */729 if (CurV->val == _CM[minI][j]) /* COLUMN j NEEDS UPDATING */ 730 730 { 731 731 /* FIND THE NEW MAXIMUM VALUE IN THE COLUMN */ … … 736 736 int i; 737 737 i = CurU->i; 738 if (CurV->val <= _C [i][j])739 CurV->val = _C [i][j];738 if (CurV->val <= _CM[i][j]) 739 CurV->val = _CM[i][j]; 740 740 } 741 741 … … 754 754 int i; 755 755 i = CurU->i; 756 if (CurU->val == _C [i][minJ]) /* ROW i NEEDS UPDATING */756 if (CurU->val == _CM[i][minJ]) /* ROW i NEEDS UPDATING */ 757 757 { 758 758 /* FIND THE NEW MAXIMUM VALUE IN THE ROW */ … … 763 763 int j; 764 764 j = CurV->i; 765 if(CurU->val <= _C [i][j])766 CurU->val = _C [i][j];765 if(CurU->val <= _CM[i][j]) 766 CurU->val = _CM[i][j]; 767 767 } 768 768
Note: See TracChangeset
for help on using the changeset viewer.