Changeset 95a6f3 in git for Singular/MinorProcessor.cc
- Timestamp:
- Oct 9, 2009, 3:46:30 PM (15 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 60e4be265398f8004f3b093179a74b59f4fdcb74
- Parents:
- 70f63ab39d1a6a435e42e041336a21e13c1269d9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/MinorProcessor.cc
r70f63a r95a6f3 270 270 271 271 IntMinorValue IntMinorProcessor::getMinor(const int dimension, const int* rowIndices, const int* columnIndices, 272 Cache<MinorKey, IntMinorValue>& c ) {272 Cache<MinorKey, IntMinorValue>& c, const int characteristic) { 273 273 defineSubMatrix(dimension, rowIndices, dimension, columnIndices); 274 274 _minorSize = dimension; 275 275 // call a helper method which recursively computes the minor using the cache c: 276 return getMinorPrivate(dimension, _container, false, c );277 } 278 279 IntMinorValue IntMinorProcessor::getMinor(const int dimension, const int* rowIndices, const int* columnIndices ) {276 return getMinorPrivate(dimension, _container, false, c, characteristic); 277 } 278 279 IntMinorValue IntMinorProcessor::getMinor(const int dimension, const int* rowIndices, const int* columnIndices, const int characteristic) { 280 280 defineSubMatrix(dimension, rowIndices, dimension, columnIndices); 281 281 _minorSize = dimension; 282 282 // call a helper method which recursively computes the minor (without using a cache): 283 return getMinorPrivate(_minorSize, _container );284 } 285 286 IntMinorValue IntMinorProcessor::getNextMinor( ) {283 return getMinorPrivate(_minorSize, _container, characteristic); 284 } 285 286 IntMinorValue IntMinorProcessor::getNextMinor(const int characteristic) { 287 287 // computation without cache 288 return getMinorPrivate(_minorSize, _minor );289 } 290 291 IntMinorValue IntMinorProcessor::getNextMinor(Cache<MinorKey, IntMinorValue>& c ) {288 return getMinorPrivate(_minorSize, _minor, characteristic); 289 } 290 291 IntMinorValue IntMinorProcessor::getNextMinor(Cache<MinorKey, IntMinorValue>& c, const int characteristic) { 292 292 // computation with cache 293 return getMinorPrivate(_minorSize, _minor, true, c );294 } 295 296 IntMinorValue IntMinorProcessor::getMinorPrivate(const int k, const MinorKey& mk ) {293 return getMinorPrivate(_minorSize, _minor, true, c, characteristic); 294 } 295 296 IntMinorValue IntMinorProcessor::getMinorPrivate(const int k, const MinorKey& mk, const int characteristic) { 297 297 assert(k > 0); // k is the minor's dimension; the minor must be at least 1x1 298 298 // The method works by recursion, and using Lapace's Theorem along the row/column with the most zeros. … … 317 317 MinorKey subMk = mk.getSubMinorKey(b, absoluteC); // This is MinorKey when we omit row b and column absoluteC. 318 318 if (_matrix[b][absoluteC] != 0) { // Only then do we have to consider this sub-determinante. 319 IntMinorValue mv = getMinorPrivate(k - 1, subMk ); // recursive call319 IntMinorValue mv = getMinorPrivate(k - 1, subMk, characteristic); // recursive call 320 320 m += mv.getMultiplications(); 321 321 s += mv.getAdditions(); … … 324 324 result += sign * mv.getResult() * _matrix[b][absoluteC]; // adding sub-determinante times matrix entry 325 325 // times appropriate sign 326 if (characteristic != 0) result = result % characteristic; 326 327 s++; m++; as++, am++; // This is for the addition and multiplication in the previous line of code. 327 328 } … … 339 340 MinorKey subMk = mk.getSubMinorKey(absoluteR, b); // This is MinorKey when we omit row absoluteR and column b. 340 341 if (_matrix[absoluteR][b] != 0) { // Only then do we have to consider this sub-determinante. 341 IntMinorValue mv = getMinorPrivate(k - 1, subMk ); // recursive call342 IntMinorValue mv = getMinorPrivate(k - 1, subMk, characteristic); // recursive call 342 343 m += mv.getMultiplications(); 343 344 s += mv.getAdditions(); … … 346 347 result += sign * mv.getResult() * _matrix[absoluteR][b]; // adding sub-determinante times matrix entry 347 348 // times appropriate sign 349 if (characteristic != 0) result = result % characteristic; 348 350 s++; m++; as++, am++; // This is for the addition and multiplication in the previous line of code. 349 351 } … … 362 364 363 365 IntMinorValue IntMinorProcessor::getMinorPrivate(const int k, const MinorKey& mk, 364 const bool multipleMinors, 365 Cache<MinorKey, IntMinorValue>& cch) { 366 const bool multipleMinors, 367 Cache<MinorKey, IntMinorValue>& cch, 368 const int characteristic) { 366 369 assert(k > 0); // k is the minor's dimension; the minor must be at least 1x1 367 370 // The method works by recursion, and using Lapace's Theorem along the row/column with the most zeros. … … 392 395 } 393 396 else { 394 mv = getMinorPrivate(k - 1, subMk, multipleMinors, cch ); // recursive call397 mv = getMinorPrivate(k - 1, subMk, multipleMinors, cch, characteristic); // recursive call 395 398 // As this minor was not in the cache, we count the additions and 396 399 // multiplications that we needed to do in the recursive call: … … 403 406 result += sign * mv.getResult() * _matrix[b][absoluteC]; // adding sub-determinante times matrix entry 404 407 // times appropriate sign 408 if (characteristic != 0) result = result % characteristic; 405 409 s++; m++; as++; am++; // This is for the addition and multiplication in the previous line of code. 406 410 } … … 425 429 } 426 430 else { 427 mv = getMinorPrivate(k - 1, subMk, multipleMinors, cch ); // recursive call431 mv = getMinorPrivate(k - 1, subMk, multipleMinors, cch, characteristic); // recursive call 428 432 // As this minor was not in the cache, we count the additions and 429 433 // multiplications that we needed to do in the recursive call: … … 436 440 result += sign * mv.getResult() * _matrix[absoluteR][b]; // adding sub-determinante times matrix entry 437 441 // times appropriate sign 442 if (characteristic != 0) result = result % characteristic; 438 443 s++; m++; as++; am++; // This is for the addition and multiplication in the previous line of code. 439 444 }
Note: See TracChangeset
for help on using the changeset viewer.