umf_local_search.c 57.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952
/* ========================================================================== */
/* === UMF_local_search ===================================================== */
/* ========================================================================== */

/* -------------------------------------------------------------------------- */
/* UMFPACK Copyright (c) Timothy A. Davis, CISE,                              */
/* Univ. of Florida.  All Rights Reserved.  See ../Doc/License for License.   */
/* web: http://www.cise.ufl.edu/research/sparse/umfpack                       */
/* -------------------------------------------------------------------------- */

/*
    Perform pivot search to find pivot row and pivot column.
    The pivot column is selected from the candidate set.  The candidate set
    corresponds to a supercolumn from colamd or UMF_analyze.  The pivot column
    is then removed from that set.  Constructs the pivot column pattern and
    values.  Called by umf_kernel.  Returns UMFPACK_OK if successful, or
    UMFPACK_WARNING_singular_matrix or UMFPACK_ERROR_different_pattern if not.
*/

#include "umf_internal.h"
#include "umf_row_search.h"
#include "umf_mem_free_tail_block.h"

/* relaxed amalgamation control parameters are fixed at compile time */
#define RELAX1 0.25
#define SYM_RELAX1 0.0
#define RELAX2 0.1
#define RELAX3 0.125

/* ========================================================================== */
/* === remove_candidate ===================================================== */
/* ========================================================================== */

/* Remove a column from the set of candidate pivot columns. */

PRIVATE void remove_candidate (Int jj, WorkType *Work, SymbolicType *Symbolic)
{

#ifndef NDEBUG
    Int j ;
    DEBUGm2 (("pivot column Candidates before remove: nCand "ID" ncand "ID
	" lo "ID" hi "ID" jj "ID"\n", Work->nCandidates, Work->ncand,
	Work->lo, Work->hi, jj)) ;
    for (j = 0 ; j < Work->nCandidates ; j++)
    {
	Int col = Work->Candidates [j] ;
	DEBUGm2 ((ID" ", col));
	ASSERT (col >= 0 && col < Work->n_col) ;
	/* ASSERT (NON_PIVOTAL_COL (col)) ; */
	ASSERT (col >= Work->lo && col <= Work->hi) ;
    }
    DEBUGm2 (("\n")) ;
#endif

    if (Symbolic->fixQ)
    {
	DEBUGm2 (("FixQ\n")) ;
	/* do not modify the column ordering */
	ASSERT (Work->nCandidates == 1) ;
	ASSERT (jj == 0) ;
	if (Work->ncand > 1)
	{
	    Work->Candidates [0] = Work->nextcand++ ;
	}
	else
	{
	    Work->nCandidates = 0 ;
	}
    }
    else
    {
	/* place the next candidate in the set */
	if (Work->ncand > MAX_CANDIDATES)
	{
	    Work->Candidates [jj] = Work->nextcand++ ;
	}
	else
	{
	    ASSERT (Work->nCandidates == Work->ncand) ;
	    Work->Candidates [jj] = Work->Candidates [Work->ncand - 1] ;
	    Work->Candidates [Work->ncand - 1] = EMPTY ;
	    Work->nCandidates-- ;
	}
    }
    Work->ncand-- ;

#ifndef NDEBUG
    DEBUGm2 (("pivot column Candidates after remove: nCand "ID" ncand "ID
	" lo "ID" hi "ID" jj "ID"\n", Work->nCandidates, Work->ncand, Work->lo,
	Work->hi, jj)) ;
    for (j = 0 ; j < Work->nCandidates ; j++)
    {
	Int col = Work->Candidates [j] ;
	DEBUGm2 ((ID" ", col));
	ASSERT (col >= 0 && col < Work->n_col) ;
	/* ASSERT (NON_PIVOTAL_COL (col)) ; */
	ASSERT (col >= Work->lo && col <= Work->hi) ;
    }
    DEBUGm2 (("\n")) ;
    ASSERT (Work->ncand >= 0) ;
    ASSERT (Work->nCandidates <= Work->ncand) ;
#endif
}

/* ========================================================================== */
/* === UMF_local_search ===================================================== */
/* ========================================================================== */

GLOBAL Int UMF_local_search
(
    NumericType *Numeric,
    WorkType *Work,
    SymbolicType *Symbolic
)
{
    /* ---------------------------------------------------------------------- */
    /* local variables */
    /* ---------------------------------------------------------------------- */

    double relax1 ;
    Entry *Flblock, *Fublock, *Fs, *Fcblock, *C, *Wx, *Wy, *Fu, *Flublock,
	*Flu ;
    Int pos, nrows, *Cols, *Rows, e, f, status, max_cdeg, fnzeros, nb, j, col,
	i, row, cdeg_in, rdeg [2][2], fnpiv, nothing [2], new_LUsize,
	pivrow [2][2], pivcol [2], *Wp, *Fcpos, *Frpos, new_fnzeros, cdeg_out,
	*Wm, *Wio, *Woi, *Woo, *Frows, *Fcols, fnrows, fncols, *E, deg, nr_in,
	nc, thiscost, bestcost, nr_out, do_update, extra_cols, extra_rows,
	extra_zeros, relaxed_front, do_extend, fnr_curr, fnc_curr, tpi,
	*Col_tuples, *Col_degree, *Col_tlen, jj, jcand [2], freebie [2],
	did_rowmerge, fnrows_new [2][2], fncols_new [2][2], search_pivcol_out,
	*Diagonal_map, *Diagonal_imap, row2, col2 ;
    Unit *Memory, *p ;
    Tuple *tp, *tpend, *tp1, *tp2 ;
    Element *ep ;

#ifndef NBLAS
    Int blas_ok = TRUE ;
#else
#define blas_ok FALSE
#endif

#ifndef NDEBUG
    Int debug_ok, n_row, n_col, *Row_degree ;
    Row_degree = Numeric->Rperm ;	/* for NON_PIVOTAL_ROW macro only */
#endif

    /* ---------------------------------------------------------------------- */
    /* get parameters */
    /* ---------------------------------------------------------------------- */

    Memory = Numeric->Memory ;
    E = Work->E ;
    Col_degree = Numeric->Cperm ;

    Col_tuples = Numeric->Lip ;
    Col_tlen   = Numeric->Lilen ;

    Wx = Work->Wx ;
    Wy = Work->Wy ;
    Wp = Work->Wp ;
    Wm = Work->Wm ;
    Woi = Work->Woi ;
    Wio = Work->Wio ;
    Woo = Work->Woo ;
    Fcpos = Work->Fcpos ;
    Frpos = Work->Frpos ;
    Frows = Work->Frows ;
    Fcols = Work->Fcols ;
    fnrows = Work->fnrows ;
    fncols = Work->fncols ;
    nb = Work->nb ;
    fnr_curr = Work->fnr_curr ;
    fnc_curr = Work->fnc_curr ;
    fnpiv = Work->fnpiv ;
    nothing [0] = EMPTY ;
    nothing [1] = EMPTY ;
    relax1 = (Symbolic->prefer_diagonal) ? SYM_RELAX1 : RELAX1 ;
    fnzeros = Work->fnzeros ;
    new_fnzeros = fnzeros ;
    jj = EMPTY ;

    Fcblock = Work->Fcblock ;	    /* current contribution block */
    Flblock = Work->Flblock ;	    /* current L block */
    Fublock = Work->Fublock ;	    /* current U block */
    Flublock = Work->Flublock ;	    /* current LU block */

    /* The pivot column degree cannot exceed max_cdeg */
    max_cdeg = Work->fnrows_max ;
    ASSERT (Work->fnrows_max <= Symbolic->maxnrows) ;
    ASSERT (Work->fncols_max <= Symbolic->maxncols) ;

    if (fnrows == 0 && fncols == 0)
    {
	/* frontal matrix is empty */
	Work->firstsuper = Work->ksuper ;
    }

#ifndef NDEBUG
    n_row = Work->n_row ;
    n_col = Work->n_col ;
    DEBUG2 (("\n========LOCAL SEARCH:  current frontal matrix: ========= \n")) ;
    UMF_dump_current_front (Numeric, Work, TRUE) ;
    if (UMF_debug > 0 || MAX (n_row, n_col) < 1000)
    {
	for (i = 0 ; i < MAX (n_row, n_col) ; i++)
	{
	    ASSERT (Wp [i] < 0) ;
	}
    }

    DEBUGm2 ((ID" pivot column Candidates: lo "ID" hi "ID"\n",
	Work->nCandidates, Work->lo, Work->hi)) ;
    for (j = 0 ; j < Work->nCandidates ; j++)
    {
	col = Work->Candidates [j] ;
	DEBUGm2 ((ID" ", col));
	ASSERT (col >= 0 && col < n_col) ;
	ASSERT (NON_PIVOTAL_COL (col)) ;
	ASSERT (col >= Work->lo && col <= Work->hi) ;
    }

    DEBUGm2 (("\n")) ;
    /* there are no 0-by-c or r-by-0 fronts, where c and r are > 0 */
    /* a front is either 0-by-0, or r-by-c */
    DEBUG2 (("\n\n::: "ID" : Npiv: "ID" + fnpiv "ID" = "ID". "
	"size "ID"-by-"ID"\n", Work->frontid,
	Work->npiv, Work->fnpiv, Work->npiv + Work->fnpiv, fnrows, fncols)) ;
    ASSERT ((fnrows == 0 && fncols == 0) ||(fnrows != 0 && fncols != 0)) ;
#endif

    /* ====================================================================== */
    /* === PIVOT SEARCH ===================================================== */
    /* ====================================================================== */

    /* initialize */

    pivcol [IN] = EMPTY ;
    pivcol [OUT] = EMPTY ;

    cdeg_in = Int_MAX ;
    cdeg_out = Int_MAX ;

    pivrow [IN][IN] = EMPTY ;
    pivrow [IN][OUT] = EMPTY ;
    pivrow [OUT][IN] = EMPTY ;
    pivrow [OUT][OUT] = EMPTY ;

    rdeg [IN][IN] = Int_MAX ;
    rdeg [IN][OUT] = Int_MAX ;
    rdeg [OUT][IN] = Int_MAX ;
    rdeg [OUT][OUT] = Int_MAX ;

    freebie [IN] = FALSE ;
    freebie [OUT] = FALSE ;

    Work->pivot_case = EMPTY ;
    bestcost = EMPTY ;

    nr_out = EMPTY ;
    nr_in = EMPTY ;

    jcand [IN] = EMPTY ;
    jcand [OUT] = EMPTY ;

    fnrows_new [IN][IN] = EMPTY ;
    fnrows_new [IN][OUT] = EMPTY ;
    fnrows_new [OUT][IN] = EMPTY ;
    fnrows_new [OUT][OUT] = EMPTY ;

    fncols_new [IN][IN] = EMPTY ;
    fncols_new [IN][OUT] = EMPTY ;
    fncols_new [OUT][IN] = EMPTY ;
    fncols_new [OUT][OUT] = EMPTY ;

#ifndef NDEBUG
	/* check Frpos */
	DEBUG4 (("Check Frpos : fnrows "ID" col "ID" maxcdeg "ID"\n",
		fnrows, pivcol [IN], max_cdeg)) ;
	for (i = 0 ; i < fnrows ; i++)
	{
	    row = Frows [i] ;
	    DEBUG4 (("  row: "ID"\n", row)) ;
	    ASSERT (row >= 0 && row < n_row) ;
	    ASSERT (Frpos [row] == i) ;
	}
	DEBUG4 (("All:\n")) ;
	if (UMF_debug > 0 || n_row < 1000)
	{
	    Int cnt = fnrows ;
	    for (row = 0 ; row < n_row ; row++)
	    {
		if (Frpos [row] == EMPTY)
		{
		    cnt++ ;
		}
		else
		{
		    DEBUG4 (("  row: "ID" pos "ID"\n", row, Frpos [row])) ;
		}
	    }
	    ASSERT (cnt == n_row) ;
	}
#endif

    /* ---------------------------------------------------------------------- */
    /* find shortest column in the front, and shortest column not in the */
    /* front, from the candidate pivot column set */
    /* ---------------------------------------------------------------------- */

    /* If there are too many candidates, then only look at the first */
    /* MAX_CANDIDATES of them.   Otherwise, if there are O(n) candidates, */
    /* this code could take O(n^2) time. */

    /* ------------------------------------------------------------------ */
    /* look in the candidate set for the best column */
    /* ------------------------------------------------------------------ */

    DEBUG2 (("Max candidates %d, Work->ncand "ID" jmax "ID"\n",
	MAX_CANDIDATES, Work->ncand, Work->nCandidates)) ;
    col = Work->Candidates [0] ;
    ASSERT (Work->nCandidates > 0) ;
    DEBUG3 (("Pivot column candidate: "ID" j = "ID"\n", col, j)) ;
    ASSERT (col >= 0 && col < n_col) ;

    /* there is no Col_degree if fixQ is true */
    deg = Symbolic->fixQ ? EMPTY : Col_degree [col] ;

#ifndef NDEBUG
    DEBUG3 (("Pivot column candidate: "ID" cost: "ID"  Fcpos[col] "ID"\n",
	col, deg, Fcpos [col])) ;
    UMF_dump_rowcol (1, Numeric, Work, col, !Symbolic->fixQ) ;
    if (Symbolic->fixQ)
    {
	DEBUG1 (("FIXQ: Candidates "ID" pivcol "ID" npiv "ID" fnpiv "ID
	    " ndiscard "ID "\n", Work->nCandidates, col, Work->npiv,
	    Work->fnpiv, Work->ndiscard)) ;
	ASSERT (Work->nCandidates == 1) ;
	ASSERT (col == Work->npiv + Work->fnpiv + Work->ndiscard) ;
    }
#endif

    if (Fcpos [col] >= 0)
    {
	/* best column in front, so far */
	pivcol [IN] = col ;
	cdeg_in = deg ;		/* ignored, if fixQ is true */
	jcand [IN] = 0 ;
    }
    else
    {
	/* best column not in front, so far */
	pivcol [OUT] = col ;
	cdeg_out = deg ;	/* ignored, if fixQ is true */
	jcand [OUT] = 0 ;
    }

    /* look at the rest of the candidates */
    for (j = 1 ; j < Work->nCandidates ; j++)
    {
	col = Work->Candidates [j] ;

	DEBUG3 (("Pivot col candidate: "ID" j = "ID"\n", col, j)) ;
	ASSERT (col >= 0 && col < n_col) ;
	ASSERT (!Symbolic->fixQ) ;
	deg = Col_degree [col] ;
#ifndef NDEBUG
	DEBUG3 (("Pivot col candidate: "ID" cost: "ID" Fcpos[col] "ID"\n",
		col, deg, Fcpos [col])) ;
	UMF_dump_rowcol (1, Numeric, Work, col, !Symbolic->fixQ) ;
#endif
	if (Fcpos [col] >= 0)
	{
#ifndef NDEBUG
	    Int fs ;
	    fs = Fcpos [col] / fnr_curr ;
	    ASSERT (fs >= 0 && fs < fncols) ;
#endif
	    if (deg < cdeg_in || (deg == cdeg_in && col < pivcol [IN]))
	    {
		/* best column in front, so far */
		pivcol [IN] = col ;
		cdeg_in = deg ;
		jcand [IN] = j ;
	    }
	}
	else
	{
	    if (deg < cdeg_out || (deg == cdeg_out && col < pivcol [OUT]))
	    {
		/* best column not in front, so far */
		pivcol [OUT] = col ;
		cdeg_out = deg ;
		jcand [OUT] = j ;
	    }
	}
    }

    DEBUG2 (("Pivcol in "ID" out "ID"\n", pivcol [IN], pivcol [OUT])) ;
    ASSERT ((pivcol [IN] >= 0 && pivcol [IN] < n_col)
	|| (pivcol [OUT] >= 0 && pivcol [OUT] < n_col)) ;

    cdeg_in = EMPTY ;
    cdeg_out = EMPTY ;

    /* ---------------------------------------------------------------------- */
    /* construct candidate column in front, and search for pivot rows */
    /* ---------------------------------------------------------------------- */

#ifndef NDEBUG
    /* check Frpos */
    DEBUG4 (("Prior to col update: fnrows "ID" col "ID" maxcdeg "ID"\n",
	    fnrows, pivcol [IN], max_cdeg)) ;
    for (i = 0 ; i < fnrows ; i++)
    {
	row = Frows [i] ;
	DEBUG4 (("  row: "ID"\n", row)) ;
	ASSERT (row >= 0 && row < n_row) ;
	ASSERT (Frpos [row] == i) ;
    }
    DEBUG4 (("All:\n")) ;
    if (UMF_debug > 0 || n_row < 1000)
    {
	Int cnt = fnrows ;
	for (row = 0 ; row < n_row ; row++)
	{
	    if (Frpos [row] == EMPTY)
	    {
		cnt++ ;
	    }
	    else
	    {
		DEBUG4 (("  row: "ID" pos "ID"\n", row, Frpos [row])) ;
	    }
	}
	ASSERT (cnt == n_row) ;
    }
#endif

    if (pivcol [IN] != EMPTY)
    {

#ifndef NDEBUG
	DEBUG2 (("col[IN] column "ID" in front at position = "ID"\n",
		pivcol [IN], Fcpos [pivcol [IN]])) ;
	UMF_dump_rowcol (1, Numeric, Work, pivcol [IN], !Symbolic->fixQ) ;
#endif

	/* the only way we can have a pivcol[IN] is if the front is not empty */
	ASSERT (fnrows > 0 && fncols > 0) ;

	DEBUG4 (("Update pivot column:\n")) ;
	Fs  = Fcblock  +  Fcpos [pivcol [IN]] ;
	Fu  = Fublock  + (Fcpos [pivcol [IN]] / fnr_curr) ;
	Flu = Flublock + fnpiv * nb ;

	/* ------------------------------------------------------------------ */
	/* copy the pivot column from the U block into the LU block */
	/* ------------------------------------------------------------------ */

	/* This copy is permanent if the pivcol [IN] is chosen. */
	for (i = 0 ; i < fnpiv ; i++)
	{
	    Flu [i] = Fu [i*fnc_curr] ;
	}

	/* ------------------------------------------------------------------ */
	/* update the pivot column in the LU block using a triangular solve */
	/* ------------------------------------------------------------------ */

	/* This work will be discarded if the pivcol [OUT] is chosen instead.
	 * It is permanent if the pivcol [IN] is chosen. */

	if (fnpiv > 1)
	{
	    /* solve Lx=b, where b = U (:,k), stored in the LU block */

#ifndef NBLAS
	    BLAS_TRSV (fnpiv, Flublock, Flu, nb) ;
#endif
	    if (!blas_ok)
	    {
		/* use plain C code if no BLAS, or on integer overflow */
		Entry *Flub = Flublock ;
		for (j = 0 ; j < fnpiv ; j++)
		{
		    Entry Fuj = Flu [j] ;
#pragma ivdep
		    for (i = j+1 ; i < fnpiv ; i++)
		    {
			/* Flu [i] -= Flublock [i + j*nb] * Flu [j] ; */
			MULT_SUB (Flu [i], Flub [i], Fuj) ;
		    }
		    Flub += nb ;
		}
	    }
	}

	/* ------------------------------------------------------------------ */
	/* copy the pivot column from the C block into Wy */
	/* ------------------------------------------------------------------ */

	for (i = 0 ; i < fnrows ; i++)
	{
	    Wy [i] = Fs [i] ;
	}

	/* ------------------------------------------------------------------ */
	/* update the pivot column of L using a matrix-vector multiply */
	/* ------------------------------------------------------------------ */

	/* this work will be discarded if the pivcol [OUT] is chosen instead */

#ifdef NBLAS
	/* no BLAS available - use plain C code instead */
	for (j = 0 ; j < fnpiv ; j++)
	{
	    Entry Fuj, *Flub = Flblock + j * fnr_curr ;
	    Fuj = Flu [j] ;
	    if (IS_NONZERO (Fuj))
	    {
#pragma ivdep
		for (i = 0 ; i < fnrows ; i++)
		{
		    /* Wy [i] -= Flblock [i+j*fnr_curr] * Fuj ; */
		    MULT_SUB (Wy [i], Flub [i], Fuj) ;
		}
	    }
	    /* Flblock += fnr_curr ; */
	}
#else
	/* Using 1-based notation:
	 * Wy (1:fnrows) -= Flblock (1:fnrows,1:fnpiv) * Flu (1:fnpiv) */
	BLAS_GEMV (fnrows, fnpiv, Flblock, Flu, Wy, fnr_curr) ;
#endif

	/* ------------------------------------------------------------------ */

#ifndef NDEBUG
	DEBUG2 (("Wy after update: fnrows="ID"\n", fnrows)) ;
	DEBUG4 ((" fnpiv="ID" \n", fnpiv)) ;
	for (i = 0 ; i < fnrows ; i++)
	{
	    DEBUG4 ((ID" "ID" "ID, i, Frows [i], Frpos [Frows [i]])) ;
	    EDEBUG4 (Wy [i]) ;
	    DEBUG4 (("\n")) ;
	}
#endif

	/* ------------------------------------------------------------------ */
	/* construct the candidate column */
	/* ------------------------------------------------------------------ */

	cdeg_in = fnrows ;

#ifndef NDEBUG
	/* check Frpos */
	DEBUG4 (("After col update: fnrows "ID" col "ID" maxcdeg "ID"\n",
		fnrows, pivcol [IN], max_cdeg)) ;
	for (i = 0 ; i < fnrows ; i++)
	{
	    row = Frows [i] ;
	    DEBUG4 (("  row: "ID"\n", row)) ;
	    ASSERT (row >= 0 && row < n_row) ;
	    ASSERT (Frpos [row] == i) ;
	}
	DEBUG4 (("All:\n")) ;
	if (UMF_debug > 0 || n_row < 1000)
	{
	    Int cnt = fnrows ;
	    for (row = 0 ; row < n_row ; row++)
	    {
		if (Frpos [row] == EMPTY)
		{
		    cnt++ ;
		}
		else
		{
		    DEBUG4 (("  row: "ID" pos "ID"\n", row, Frpos [row])) ;
		}
	    }
	    ASSERT (cnt == n_row) ;
	}
#endif

#ifndef NDEBUG
	/* check Frpos */
	DEBUG4 (("COL ASSEMBLE: cdeg "ID"\nREDUCE COL in "ID" max_cdeg "ID"\n",
		cdeg_in, pivcol [IN], max_cdeg)) ;
	for (i = 0 ; i < cdeg_in ; i++)
	{
	    row = Frows [i] ;
	    ASSERT (row >= 0 && row < n_row) ;
	    ASSERT (Frpos [row] == i) ;
	}
	if (UMF_debug > 0 || n_row < 1000)
	{
	    Int cnt = cdeg_in ;
	    for (row = 0 ; row < n_row ; row++)
	    {
		if (Frpos [row] == EMPTY) cnt++ ;
	    }
	    ASSERT (cnt == n_row) ;
	}
#endif

	/* assemble column into Wy */

	ASSERT (pivcol [IN] >= 0 && pivcol [IN] < n_col) ;
	ASSERT (NON_PIVOTAL_COL (pivcol [IN])) ;

	tpi = Col_tuples [pivcol [IN]] ;
	if (tpi)
	{
	    tp = (Tuple *) (Memory + tpi) ;
	    tp1 = tp ;
	    tp2 = tp ;
	    tpend = tp + Col_tlen [pivcol [IN]] ;
	    for ( ; tp < tpend ; tp++)
	    {
		e = tp->e ;
		ASSERT (e > 0 && e <= Work->nel) ;
		if (!E [e]) continue ;	/* element already deallocated */
		f = tp->f ;
		p = Memory + E [e] ;
		ep = (Element *) p ;
		p += UNITS (Element, 1) ;
		Cols = (Int *) p ;
		if (Cols [f] == EMPTY) continue ; /* column already assembled */
		ASSERT (pivcol [IN] == Cols [f]) ;

		Rows = Cols + ep->ncols ;
		nrows = ep->nrows ;
		p += UNITS (Int, ep->ncols + nrows) ;
		C = ((Entry *) p) + f * nrows ;

		for (i = 0 ; i < nrows ; i++)
		{
		    row = Rows [i] ;
		    if (row >= 0) /* skip this if already gone from element */
		    {
			ASSERT (row < n_row) ;
			pos = Frpos [row] ;
			if (pos < 0)
			{
			    /* new entry in the pattern - save Frpos */
			    ASSERT (cdeg_in < n_row) ;
			    if (cdeg_in >= max_cdeg)
			    {
				/* :: pattern change (cdeg in failure) :: */
				DEBUGm4 (("cdeg_in failure\n")) ;
				return (UMFPACK_ERROR_different_pattern) ;
			    }
			    Frpos [row] = cdeg_in ;
			    Frows [cdeg_in] = row ;
			    Wy [cdeg_in++] = C [i] ;
			}
			else
			{
			    /* entry already in pattern - sum values in Wy */
			    /* Wy [pos] += C [i] ; */
			    ASSERT (pos < max_cdeg) ;
			    ASSEMBLE (Wy [pos], C [i]) ;
			}
		    }
		}
		*tp2++ = *tp ;	/* leave the tuple in the list */
	    }
	    Col_tlen [pivcol [IN]] = tp2 - tp1 ;
	}

	/* ------------------------------------------------------------------ */

#ifndef NDEBUG
	/* check Frpos again */
	DEBUG4 (("COL DONE: cdeg "ID"\nREDUCE COL in "ID" max_cdeg "ID"\n",
		cdeg_in, pivcol [IN], max_cdeg)) ;
	for (i = 0 ; i < cdeg_in ; i++)
	{
	    row = Frows [i] ;
	    ASSERT (row >= 0 && row < n_row) ;
	    ASSERT (Frpos [row] == i) ;
	}
	if (UMF_debug > 0 || n_row < 1000)
	{
	    Int cnt = cdeg_in ;
	    for (row = 0 ; row < n_row ; row++)
	    {
		if (Frpos [row] == EMPTY) cnt++ ;
	    }
	    ASSERT (cnt == n_row) ;
	}
#endif

#ifndef NDEBUG
	DEBUG4 (("Reduced column: cdeg in  "ID" fnrows_max "ID"\n",
	    cdeg_in, Work->fnrows_max)) ;
	for (i = 0 ; i < cdeg_in ; i++)
	{
	    DEBUG4 ((" "ID" "ID" "ID, i, Frows [i], Frpos [Frows [i]])) ;
	    EDEBUG4 (Wy [i]) ;
	    DEBUG4 (("\n")) ;
	    ASSERT (i == Frpos [Frows [i]]) ;
	}
	ASSERT (cdeg_in <= Work->fnrows_max) ;
#endif

	/* ------------------------------------------------------------------ */
	/* cdeg_in is now the exact degree of this column */
	/* ------------------------------------------------------------------ */

	nr_in = cdeg_in - fnrows ;

	/* since there are no 0-by-x fronts, if there is a pivcol [IN] the */
	/* front must have at least one row. */
	ASSERT (cdeg_in > 0) ;

	/* new degree of pivcol [IN], excluding current front is nr_in */
	/* column expands by nr_in rows */

	/* ------------------------------------------------------------------ */
	/* search for two candidate pivot rows */
	/* ------------------------------------------------------------------ */

	/* for the IN_IN pivot row (if any), */
	/* extend the pattern in place, using Fcols */
	status = UMF_row_search (Numeric, Work, Symbolic,
	    fnrows, cdeg_in, Frows, Frpos,   /* pattern of column to search */
	    pivrow [IN], rdeg [IN], Fcols, Wio, nothing, Wy,
	    pivcol [IN], freebie) ;
	ASSERT (!freebie [IN] && !freebie [OUT]) ;

	/* ------------------------------------------------------------------ */
	/* fatal error if matrix pattern has changed since symbolic analysis */
	/* ------------------------------------------------------------------ */

	if (status == UMFPACK_ERROR_different_pattern)
	{
	    /* :: pattern change (row search IN failure) :: */
	    DEBUGm4 (("row search IN failure\n")) ;
	    return (UMFPACK_ERROR_different_pattern) ;
	}

	/* ------------------------------------------------------------------ */
	/* we now must have a structural pivot */
	/* ------------------------------------------------------------------ */

	/* Since the pivcol[IN] exists, there must be at least one row in the */
	/* current frontal matrix, and so we must have found a structural */
	/* pivot.  The numerical value might be zero, of course. */

	ASSERT (status != UMFPACK_WARNING_singular_matrix) ;

	/* ------------------------------------------------------------------ */
	/* evaluate IN_IN option */
	/* ------------------------------------------------------------------ */

	if (pivrow [IN][IN] != EMPTY)
	{
	    /* The current front would become an (implicit) LUson.
	     * Both candidate pivot row and column are in the current front.
	     * Cost is how much the current front would expand */

	    /* pivrow[IN][IN] candidates are not found via row merge search */

	    ASSERT (fnrows >= 0 && fncols >= 0) ;

	    ASSERT (cdeg_in > 0) ;
	    nc = rdeg [IN][IN] - fncols ;

	    thiscost =
		/* each column in front (except pivot column) grows by nr_in: */
		(nr_in * (fncols - 1)) +
		/* new columns not in old front: */
		(nc * (cdeg_in - 1)) ;

	    /* no extra cost to relaxed amalgamation */

	    ASSERT (fnrows + nr_in == cdeg_in) ;
	    ASSERT (fncols + nc == rdeg [IN][IN]) ;

	    /* size of relaxed front (after pivot row column removed): */
	    fnrows_new [IN][IN] = (fnrows-1) + nr_in ;
	    fncols_new [IN][IN] = (fncols-1) + nc ;
	    /* relaxed_front = fnrows_new [IN][IN] * fncols_new [IN][IN] ; */

	    do_extend = TRUE ;

	    DEBUG2 (("Evaluating option IN-IN:\n")) ;
	    DEBUG2 (("Work->fnzeros "ID" fnpiv "ID" nr_in "ID" nc "ID"\n",
		Work->fnzeros, fnpiv, nr_in, nc)) ;
	    DEBUG2 (("fncols "ID" fnrows "ID"\n", fncols, fnrows)) ;

	    /* determine if BLAS-3 update should be applied before extending. */
	    /* update if too many zero entries accumulate in the LU block */
	    fnzeros = Work->fnzeros + fnpiv * (nr_in + nc) ;

	    DEBUG2 (("fnzeros "ID"\n", fnzeros)) ;

	    new_LUsize = (fnpiv+1) * (fnrows + nr_in + fncols + nc) ;

	    DEBUG2 (("new_LUsize "ID"\n", new_LUsize)) ;

	    /* There are fnpiv pivots currently in the front.  This one
	     * will be the (fnpiv+1)st pivot, if it is extended. */

	    /* RELAX2 parameter uses a double relop, but ignore NaN case: */
	    do_update = fnpiv > 0 &&
		(((double) fnzeros) / ((double) new_LUsize)) > RELAX2 ;

	    DEBUG2 (("do_update "ID"\n", do_update))

	    DEBUG2 (("option IN  IN : nr "ID" nc "ID" cost "ID"(0) relax "ID
		"\n", nr_in, nc, thiscost, do_extend)) ;

	    /* this is the best option seen so far */
	    Work->pivot_case = IN_IN ;
	    bestcost = thiscost ;

	    /* do the amalgamation and extend the front */
	    Work->do_extend = do_extend ;
	    Work->do_update = do_update ;
	    new_fnzeros = fnzeros ;

	}

	/* ------------------------------------------------------------------ */
	/* evaluate IN_OUT option */
	/* ------------------------------------------------------------------ */

	if (pivrow [IN][OUT] != EMPTY)
	{
	    /* The current front would become a Uson of the new front.
	     * Candidate pivot column is in the current front, but the
	     * candidate pivot row is not. */

	    ASSERT (fnrows >= 0 && fncols > 0) ;
	    ASSERT (cdeg_in > 0) ;

	    /* must be at least one row outside the front */
	    /* (the pivrow [IN][OUT] itself) */
	    ASSERT (nr_in >= 1) ;

	    /* count columns not in current front */
	    nc = 0 ;
#ifndef NDEBUG
	    debug_ok = FALSE ;
#endif
	    for (i = 0 ; i < rdeg [IN][OUT] ; i++)
	    {
		col = Wio [i] ;
		DEBUG4 (("counting col "ID" Fcpos[] = "ID"\n", col,
		    Fcpos [col])) ;
		ASSERT (col >= 0 && col < n_col && NON_PIVOTAL_COL (col)) ;
		if (Fcpos [col] < 0) nc++ ;
#ifndef NDEBUG
		/* we must see the pivot column somewhere */
		if (col == pivcol [IN])
		{
		    ASSERT (Fcpos [col] >= 0) ;
		    debug_ok = TRUE ;
		}
#endif
	    }
	    ASSERT (debug_ok) ;

	    thiscost =
		/* each row in front grows by nc: */
		(nc * fnrows) +
		/* new rows not affected by front: */
		((nr_in-1) * (rdeg [IN][OUT]-1)) ;

	    /* check the cost of relaxed IN_OUT amalgamation */

	    extra_cols = ((fncols-1) + nc ) - (rdeg [IN][OUT] - 1) ;
	    ASSERT (extra_cols >= 0) ;
	    ASSERT (fncols + nc == extra_cols + rdeg [IN][OUT]) ;
	    extra_zeros = (nr_in-1) * extra_cols ;	/* symbolic fill-in */

	    ASSERT (fnrows + nr_in == cdeg_in) ;
	    ASSERT (fncols + nc == rdeg [IN][OUT] + extra_cols) ;

	    /* size of relaxed front (after pivot column removed): */
	    fnrows_new [IN][OUT] = fnrows + (nr_in-1) ;
	    fncols_new [IN][OUT] = (fncols-1) + nc ;
	    relaxed_front = fnrows_new [IN][OUT] * fncols_new [IN][OUT] ;

	    /* do relaxed amalgamation if the extra zeros are no more */
	    /* than a fraction (default 0.25) of the relaxed front */
	    /* if relax = 0: no extra zeros allowed */
	    /* if relax = +inf: always amalgamate */

	    /* relax parameter uses a double relop, but ignore NaN case: */
	    if (extra_zeros == 0)
	    {
		do_extend = TRUE ;
	    }
	    else
	    {
		do_extend = ((double) extra_zeros) <
		   (relax1 * (double) relaxed_front) ;
	    }

	    if (do_extend)
	    {
		/* count the cost of relaxed amalgamation */
		thiscost += extra_zeros ;

		DEBUG2 (("Evaluating option IN-OUT:\n")) ;
		DEBUG2 (("Work->fnzeros "ID" fnpiv "ID" nr_in "ID" nc "ID"\n",
		    Work->fnzeros, fnpiv, nr_in, nc)) ;
		DEBUG2 (("fncols "ID" fnrows "ID"\n", fncols, fnrows)) ;

		/* determine if BLAS-3 update to be applied before extending. */
		/* update if too many zero entries accumulate in the LU block */
		fnzeros = Work->fnzeros + fnpiv * (nr_in + nc) ;

		DEBUG2 (("fnzeros "ID"\n", fnzeros)) ;

		new_LUsize = (fnpiv+1) * (fnrows + nr_in + fncols + nc) ;

		DEBUG2 (("new_LUsize "ID"\n", new_LUsize)) ;

		/* RELAX3 parameter uses a double relop, ignore NaN case: */
		do_update = fnpiv > 0 &&
		    (((double) fnzeros) / ((double) new_LUsize)) > RELAX3 ;
		DEBUG2 (("do_update "ID"\n", do_update))

	    }
	    else
	    {
		/* the current front would not be extended */
		do_update = fnpiv > 0 ;
		fnzeros = 0 ;
		DEBUG2 (("IN-OUT do_update forced true: "ID"\n", do_update)) ;

		/* The new front would be just big enough to hold the new
		 * pivot row and column. */
		fnrows_new [IN][OUT] = cdeg_in - 1 ;
		fncols_new [IN][OUT] = rdeg [IN][OUT] - 1 ;

	    }

	    DEBUG2 (("option IN  OUT: nr "ID" nc "ID" cost "ID"("ID") relax "ID
		"\n", nr_in, nc, thiscost, extra_zeros, do_extend)) ;

	    if (bestcost == EMPTY || thiscost < bestcost)
	    {
		/* this is the best option seen so far */
		Work->pivot_case = IN_OUT ;
		bestcost = thiscost ;
		Work->do_extend = do_extend ;
		Work->do_update = do_update ;
		new_fnzeros = fnzeros ;
	    }
	}
    }

    /* ---------------------------------------------------------------------- */
    /* construct candidate column not in front, and search for pivot rows */
    /* ---------------------------------------------------------------------- */

    search_pivcol_out = (bestcost != 0 && pivcol [OUT] != EMPTY) ;
    if (Symbolic->prefer_diagonal)
    {
	search_pivcol_out = search_pivcol_out && (pivrow [IN][IN] == EMPTY) ;
    }

    if (search_pivcol_out)
    {

#ifndef NDEBUG
	DEBUG2 (("out_col column "ID" NOT in front at position = "ID"\n",
		pivcol [OUT], Fcpos [pivcol [OUT]])) ;
	UMF_dump_rowcol (1, Numeric, Work, pivcol [OUT], !Symbolic->fixQ) ;
	DEBUG2 (("fncols "ID" fncols_max "ID"\n", fncols, Work->fncols_max)) ;
	ASSERT (fncols < Work->fncols_max) ;
#endif

	/* Use Wx as temporary workspace to construct the pivcol [OUT] */


	/* ------------------------------------------------------------------ */
	/* construct the candidate column (currently not in the front) */
	/* ------------------------------------------------------------------ */

	/* Construct the column in Wx, Wm, using Wp for the positions: */
	/* Wm [0..cdeg_out-1]	list of row indices in the column */
	/* Wx [0..cdeg_out-1]	list of corresponding numerical values */
	/* Wp [0..n-1] starts as all negative, and ends that way too. */

	cdeg_out = 0 ;

#ifndef NDEBUG
	/* check Wp */
	DEBUG4 (("COL ASSEMBLE: cdeg 0\nREDUCE COL out "ID"\n", pivcol [OUT])) ;
	if (UMF_debug > 0 || MAX (n_row, n_col) < 1000)
	{
	    for (i = 0 ; i < MAX (n_row, n_col) ; i++)
	    {
		ASSERT (Wp [i] < 0) ;
	    }
	}
	DEBUG4 (("max_cdeg: "ID"\n", max_cdeg)) ;
#endif

	ASSERT (pivcol [OUT] >= 0 && pivcol [OUT] < n_col) ;
	ASSERT (NON_PIVOTAL_COL (pivcol [OUT])) ;

	tpi = Col_tuples [pivcol [OUT]] ;
	if (tpi)
	{
	    tp = (Tuple *) (Memory + tpi) ;
	    tp1 = tp ;
	    tp2 = tp ;
	    tpend = tp + Col_tlen [pivcol [OUT]] ;
	    for ( ; tp < tpend ; tp++)
	    {
		e = tp->e ;
		ASSERT (e > 0 && e <= Work->nel) ;
		if (!E [e]) continue ;	/* element already deallocated */
		f = tp->f ;
		p = Memory + E [e] ;
		ep = (Element *) p ;
		p += UNITS (Element, 1) ;
		Cols = (Int *) p ;
		if (Cols [f] == EMPTY) continue ; /* column already assembled */
		ASSERT (pivcol [OUT] == Cols [f]) ;

		Rows = Cols + ep->ncols ;
		nrows = ep->nrows ;
		p += UNITS (Int, ep->ncols + nrows) ;
		C = ((Entry *) p) + f * nrows ;

		for (i = 0 ; i < nrows ; i++)
		{
		    row = Rows [i] ;
		    if (row >= 0) /* skip this if already gone from element */
		    {
			ASSERT (row < n_row) ;
			pos = Wp [row] ;
			if (pos < 0)
			{
			    /* new entry in the pattern - save Wp */
			    ASSERT (cdeg_out < n_row) ;
			    if (cdeg_out >= max_cdeg)
			    {
				/* :: pattern change (cdeg out failure) :: */
				DEBUGm4 (("cdeg out failure\n")) ;
				return (UMFPACK_ERROR_different_pattern) ;
			    }
			    Wp [row] = cdeg_out ;
			    Wm [cdeg_out] = row ;
			    Wx [cdeg_out++] = C [i] ;
			}
			else
			{
			    /* entry already in pattern - sum the values */
			    /* Wx [pos] += C [i] ; */
			    ASSEMBLE (Wx [pos], C [i]) ;
			}
		    }
		}
		*tp2++ = *tp ;	/* leave the tuple in the list */
	    }
	    Col_tlen [pivcol [OUT]] = tp2 - tp1 ;
	}

	/* ------------------------------------------------------------------ */

#ifndef NDEBUG
	DEBUG4 (("Reduced column: cdeg out "ID"\n", cdeg_out)) ;
	for (i = 0 ; i < cdeg_out ; i++)
	{
	    DEBUG4 ((" "ID" "ID" "ID, i, Wm [i], Wp [Wm [i]])) ;
	    EDEBUG4 (Wx [i]) ;
	    DEBUG4 (("\n")) ;
	    ASSERT (i == Wp [Wm [i]]) ;
	}
#endif

	/* ------------------------------------------------------------------ */
	/* new degree of pivcol [OUT] is cdeg_out */
	/* ------------------------------------------------------------------ */

	/* search for two candidate pivot rows */
	status = UMF_row_search (Numeric, Work, Symbolic,
	    0, cdeg_out, Wm, Wp, /* pattern of column to search */
	    pivrow [OUT], rdeg [OUT], Woi, Woo, pivrow [IN], Wx,
	    pivcol [OUT], freebie) ;

	/* ------------------------------------------------------------------ */
	/* fatal error if matrix pattern has changed since symbolic analysis */
	/* ------------------------------------------------------------------ */

	if (status == UMFPACK_ERROR_different_pattern)
	{
	    /* :: pattern change detected in umf_local_search :: */
	    return (UMFPACK_ERROR_different_pattern) ;
	}

	/* ------------------------------------------------------------------ */
	/* Clear Wp */
	/* ------------------------------------------------------------------ */

	for (i = 0 ; i < cdeg_out ; i++)
	{
	    Wp [Wm [i]] = EMPTY ;	/* clear Wp */
	}

	/* ------------------------------------------------------------------ */
	/* check for rectangular, singular matrix */
	/* ------------------------------------------------------------------ */

	if (status == UMFPACK_WARNING_singular_matrix)
	{
	    /* Pivot column is empty, and row-merge set is empty too.  The
	     * matrix is structurally singular.  The current frontal matrix must
	     * be empty, too.  It it weren't, and pivcol [OUT] exists, then
	     * there would be at least one row that could be selected.  Since
	     * the current front is empty, pivcol [IN] must also be EMPTY.
	     */

	    DEBUGm4 (("Note: pivcol [OUT]: "ID" discard\n", pivcol [OUT])) ;
	    ASSERT ((Work->fnrows == 0 && Work->fncols == 0)) ;
	    ASSERT (pivcol [IN] == EMPTY) ;

	    /* remove the failed pivcol [OUT] from candidate set */
	    ASSERT (pivcol [OUT] == Work->Candidates [jcand [OUT]]) ;
	    remove_candidate (jcand [OUT], Work, Symbolic) ;
	    Work->ndiscard++ ;

	    /* delete all of the tuples, and all contributions to this column */
	    DEBUG1 (("Prune tuples of dead outcol: "ID"\n", pivcol [OUT])) ;
	    Col_tlen [pivcol [OUT]] = 0 ;
	    UMF_mem_free_tail_block (Numeric, Col_tuples [pivcol [OUT]]) ;
	    Col_tuples [pivcol [OUT]] = 0 ;

	    /* no pivot found at all */
	    return (UMFPACK_WARNING_singular_matrix) ;
	}

	/* ------------------------------------------------------------------ */

	if (freebie [IN])
	{
	    /* the "in" row is the same as the "in" row for the "in" column */
	    Woi = Fcols ;
	    rdeg [OUT][IN] = rdeg [IN][IN] ;
	    DEBUG4 (("Freebie in, row "ID"\n", pivrow [IN][IN])) ;
	}

	if (freebie [OUT])
	{
	    /* the "out" row is the same as the "out" row for the "in" column */
	    Woo = Wio ;
	    rdeg [OUT][OUT] = rdeg [IN][OUT] ;
	    DEBUG4 (("Freebie out, row "ID"\n", pivrow [IN][OUT])) ;
	}

	/* ------------------------------------------------------------------ */
	/* evaluate OUT_IN option */
	/* ------------------------------------------------------------------ */

	if (pivrow [OUT][IN] != EMPTY)
	{
	    /* The current front would become an Lson of the new front.
	     * The candidate pivot row is in the current front, but the
	     * candidate pivot column is not. */

	    ASSERT (fnrows > 0 && fncols >= 0) ;

	    did_rowmerge = (cdeg_out == 0) ;
	    if (did_rowmerge)
	    {
		/* pivrow [OUT][IN] was found via row merge search */
		/* it is not (yet) in the pivot column pattern (add it now) */
		DEBUGm4 (("did row merge OUT col, IN row\n")) ;
		Wm [0] = pivrow [OUT][IN] ;
		CLEAR (Wx [0]) ;
		cdeg_out = 1 ;
		ASSERT (nr_out == EMPTY) ;
	    }

	    nc = rdeg [OUT][IN] - fncols ;
	    ASSERT (nc >= 1) ;

	    /* count rows not in current front */
	    nr_out = 0 ;
#ifndef NDEBUG
	    debug_ok = FALSE ;
#endif
	    for (i = 0 ; i < cdeg_out ; i++)
	    {
		row = Wm [i] ;
		ASSERT (row >= 0 && row < n_row && NON_PIVOTAL_ROW (row)) ;
		if (Frpos [row] < 0 || Frpos [row] >= fnrows) nr_out++ ;
#ifndef NDEBUG
		/* we must see the pivot row somewhere */
		if (row == pivrow [OUT][IN])
		{
		    ASSERT (Frpos [row] >= 0) ;
		    debug_ok = TRUE ;
		}
#endif
	    }
	    ASSERT (debug_ok) ;

	    thiscost =
		/* each column in front grows by nr_out: */
		(nr_out * fncols) +
		/* new cols not affected by front: */
		((nc-1) * (cdeg_out-1)) ;

	    /* check the cost of relaxed OUT_IN amalgamation */

	    extra_rows = ((fnrows-1) + nr_out) - (cdeg_out - 1) ;
	    ASSERT (extra_rows >= 0) ;
	    ASSERT (fnrows + nr_out == extra_rows + cdeg_out) ;
	    extra_zeros = (nc-1) * extra_rows ;	/* symbolic fill-in */

	    ASSERT (fnrows + nr_out == cdeg_out + extra_rows) ;
	    ASSERT (fncols + nc == rdeg [OUT][IN]) ;

	    /* size of relaxed front (after pivot row removed): */
	    fnrows_new [OUT][IN] = (fnrows-1) + nr_out ;
	    fncols_new [OUT][IN] = fncols + (nc-1) ;
	    relaxed_front = fnrows_new [OUT][IN] * fncols_new [OUT][IN] ;

	    /* do relaxed amalgamation if the extra zeros are no more */
	    /* than a fraction (default 0.25) of the relaxed front */
	    /* if relax = 0: no extra zeros allowed */
	    /* if relax = +inf: always amalgamate */
	    if (did_rowmerge)
	    {
		do_extend = FALSE ;
	    }
	    else
	    {
		/* relax parameter uses a double relop, but ignore NaN case: */
		if (extra_zeros == 0)
		{
		    do_extend = TRUE ;
		}
		else
		{
		    do_extend = ((double) extra_zeros) <
		       (relax1 * (double) relaxed_front) ;
		}
	    }

	    if (do_extend)
	    {
		/* count the cost of relaxed amalgamation */
		thiscost += extra_zeros ;

		DEBUG2 (("Evaluating option OUT-IN:\n")) ;
		DEBUG2 ((" Work->fnzeros "ID" fnpiv "ID" nr_out "ID" nc "ID"\n",
		Work->fnzeros, fnpiv, nr_out, nc)) ;
		DEBUG2 (("fncols "ID" fnrows "ID"\n", fncols, fnrows)) ;

		/* determine if BLAS-3 update to be applied before extending. */
		/* update if too many zero entries accumulate in the LU block */
		fnzeros = Work->fnzeros + fnpiv * (nr_out + nc) ;

		DEBUG2 (("fnzeros "ID"\n", fnzeros)) ;

		new_LUsize = (fnpiv+1) * (fnrows + nr_out + fncols + nc) ;

		DEBUG2 (("new_LUsize "ID"\n", new_LUsize)) ;

		/* RELAX3 parameter uses a double relop, ignore NaN case: */
		do_update = fnpiv > 0 &&
		    (((double) fnzeros) / ((double) new_LUsize)) > RELAX3 ;
		DEBUG2 (("do_update "ID"\n", do_update))
	    }
	    else
	    {
		/* the current front would not be extended */
		do_update = fnpiv > 0 ;
		fnzeros = 0 ;
		DEBUG2 (("OUT-IN do_update forced true: "ID"\n", do_update)) ;

		/* The new front would be just big enough to hold the new
		 * pivot row and column. */
		fnrows_new [OUT][IN] = cdeg_out - 1 ;
		fncols_new [OUT][IN] = rdeg [OUT][IN] - 1 ;
	    }

	    DEBUG2 (("option OUT IN : nr "ID" nc "ID" cost "ID"("ID") relax "ID
		"\n", nr_out, nc, thiscost, extra_zeros, do_extend)) ;

	    if (bestcost == EMPTY || thiscost < bestcost)
	    {
		/* this is the best option seen so far */
		Work->pivot_case = OUT_IN ;
		bestcost = thiscost ;
		Work->do_extend = do_extend ;
		Work->do_update = do_update ;
		new_fnzeros = fnzeros ;
	    }
	}

	/* ------------------------------------------------------------------ */
	/* evaluate OUT_OUT option */
	/* ------------------------------------------------------------------ */

	if (pivrow [OUT][OUT] != EMPTY)
	{
	    /* Neither the candidate pivot row nor the candidate pivot column
	     * are in the current front. */

	    ASSERT (fnrows >= 0 && fncols >= 0) ;

	    did_rowmerge = (cdeg_out == 0) ;
	    if (did_rowmerge)
	    {
		/* pivrow [OUT][OUT] was found via row merge search */
		/* it is not (yet) in the pivot column pattern (add it now) */
		DEBUGm4 (("did row merge OUT col, OUT row\n")) ;
		Wm [0] = pivrow [OUT][OUT] ;
		CLEAR (Wx [0]) ;
		cdeg_out = 1 ;
		ASSERT (nr_out == EMPTY) ;
		nr_out = 1 ;
	    }

	    if (fnrows == 0 && fncols == 0)
	    {
		/* the current front is completely empty */
		ASSERT (fnpiv == 0) ;
		nc = rdeg [OUT][OUT] ;
		extra_cols = 0 ;
		nr_out = cdeg_out ;
		extra_rows = 0 ;
		extra_zeros = 0 ;

		thiscost = (nc-1) * (cdeg_out-1) ; /* new columns only */

		/* size of new front: */
		fnrows_new [OUT][OUT] = nr_out-1 ;
		fncols_new [OUT][OUT] = nc-1 ;
		relaxed_front = fnrows_new [OUT][OUT] * fncols_new [OUT][OUT] ;
	    }
	    else
	    {

		/* count rows not in current front */
		if (nr_out == EMPTY)
		{
		    nr_out = 0 ;
#ifndef NDEBUG
		    debug_ok = FALSE ;
#endif
		    for (i = 0 ; i < cdeg_out ; i++)
		    {
			row = Wm [i] ;
			ASSERT (row >= 0 && row < n_row) ;
			ASSERT (NON_PIVOTAL_ROW (row)) ;
			if (Frpos [row] < 0 || Frpos [row] >= fnrows) nr_out++ ;
#ifndef NDEBUG
			/* we must see the pivot row somewhere */
			if (row == pivrow [OUT][OUT])
			{
			    ASSERT (Frpos [row] < 0 || Frpos [row] >= fnrows) ;
			    debug_ok = TRUE ;
			}
#endif
		    }
		    ASSERT (debug_ok) ;
		}

		/* count columns not in current front */
		nc = 0 ;
#ifndef NDEBUG
		debug_ok = FALSE ;
#endif
		for (i = 0 ; i < rdeg [OUT][OUT] ; i++)
		{
		    col = Woo [i] ;
		    ASSERT (col >= 0 && col < n_col && NON_PIVOTAL_COL (col)) ;
		    if (Fcpos [col] < 0) nc++ ;
#ifndef NDEBUG
		    /* we must see the pivot column somewhere */
		    if (col == pivcol [OUT])
		    {
			ASSERT (Fcpos [col] < 0) ;
			debug_ok = TRUE ;
		    }
#endif
		}
		ASSERT (debug_ok) ;

		extra_cols = (fncols + (nc-1)) - (rdeg [OUT][OUT] - 1) ;
		extra_rows = (fnrows + (nr_out-1)) - (cdeg_out - 1) ;
		ASSERT (extra_rows >= 0) ;
		ASSERT (extra_cols >= 0) ;
		extra_zeros = ((nc-1) * extra_rows) + ((nr_out-1) * extra_cols);

		ASSERT (fnrows + nr_out == cdeg_out + extra_rows) ;
		ASSERT (fncols + nc == rdeg [OUT][OUT] + extra_cols) ;

		thiscost =
		    /* new columns: */
		    ((nc-1) * (cdeg_out-1)) +
		    /* old columns in front grow by nr_out-1: */
		    ((nr_out-1) * (fncols - extra_cols)) ;

		/* size of relaxed front: */
		fnrows_new [OUT][OUT] = fnrows + (nr_out-1) ;
		fncols_new [OUT][OUT] = fncols + (nc-1) ;
		relaxed_front = fnrows_new [OUT][OUT] * fncols_new [OUT][OUT] ;

	    }

	    /* do relaxed amalgamation if the extra zeros are no more */
	    /* than a fraction (default 0.25) of the relaxed front */
	    /* if relax = 0: no extra zeros allowed */
	    /* if relax = +inf: always amalgamate */
	    if (did_rowmerge)
	    {
		do_extend = FALSE ;
	    }
	    else
	    {
		/* relax parameter uses a double relop, but ignore NaN case: */
		if (extra_zeros == 0)
		{
		    do_extend = TRUE ;
		}
		else
		{
		    do_extend = ((double) extra_zeros) <
		       (relax1 * (double) relaxed_front) ;
		}
	    }

	    if (do_extend)
	    {
		/* count the cost of relaxed amalgamation */
		thiscost += extra_zeros ;

		DEBUG2 (("Evaluating option OUT-OUT:\n")) ;
		DEBUG2 (("Work->fnzeros "ID" fnpiv "ID" nr_out "ID" nc "ID"\n",
		    Work->fnzeros, fnpiv, nr_out, nc)) ;
		DEBUG2 (("fncols "ID" fnrows "ID"\n", fncols, fnrows)) ;

		/* determine if BLAS-3 update to be applied before extending. */
		/* update if too many zero entries accumulate in the LU block */
		fnzeros = Work->fnzeros + fnpiv * (nr_out + nc) ;

		DEBUG2 (("fnzeros "ID"\n", fnzeros)) ;

		new_LUsize = (fnpiv+1) * (fnrows + nr_out + fncols + nc) ;

		DEBUG2 (("new_LUsize "ID"\n", new_LUsize)) ;

		/* RELAX3 parameter uses a double relop, ignore NaN case: */
		do_update = fnpiv > 0 &&
		    (((double) fnzeros) / ((double) new_LUsize)) > RELAX3 ;
		DEBUG2 (("do_update "ID"\n", do_update))
	    }
	    else
	    {
		/* the current front would not be extended */
		do_update = fnpiv > 0 ;
		fnzeros = 0 ;
		DEBUG2 (("OUT-OUT do_update forced true: "ID"\n", do_update)) ;

		/* The new front would be just big enough to hold the new
		 * pivot row and column. */
		fnrows_new [OUT][OUT] = cdeg_out - 1 ;
		fncols_new [OUT][OUT] = rdeg [OUT][OUT] - 1 ;
	    }

	    DEBUG2 (("option OUT OUT: nr "ID" nc "ID" cost "ID"\n",
		rdeg [OUT][OUT], cdeg_out, thiscost)) ;

	    if (bestcost == EMPTY || thiscost < bestcost)
	    {
		/* this is the best option seen so far */
		Work->pivot_case = OUT_OUT ;
		bestcost = thiscost ;
		Work->do_extend = do_extend ;
		Work->do_update = do_update ;
		new_fnzeros = fnzeros ;
	    }
	}
    }

    /* At this point, a structural pivot has been found. */
    /* It may be numerically zero, however. */
    ASSERT (Work->pivot_case != EMPTY) ;
    DEBUG2 (("local search, best option "ID", best cost "ID"\n",
	Work->pivot_case, bestcost)) ;

    /* ====================================================================== */
    /* Pivot row and column, and extension, now determined */
    /* ====================================================================== */

    Work->fnzeros = new_fnzeros ;

    /* ---------------------------------------------------------------------- */
    /* finalize the pivot row and column */
    /* ---------------------------------------------------------------------- */

    switch (Work->pivot_case)
    {
	case IN_IN:
	    DEBUG2 (("IN-IN option selected\n")) ;
	    ASSERT (fnrows > 0 && fncols > 0) ;
	    Work->pivcol_in_front = TRUE ;
	    Work->pivrow_in_front = TRUE ;
	    Work->pivcol = pivcol [IN] ;
	    Work->pivrow = pivrow [IN][IN] ;
	    Work->ccdeg = nr_in ;
	    Work->Wrow = Fcols ;
	    Work->rrdeg = rdeg [IN][IN] ;
	    jj = jcand [IN] ;
	    Work->fnrows_new = fnrows_new [IN][IN] ;
	    Work->fncols_new = fncols_new [IN][IN] ;
	    break ;

	case IN_OUT:
	    DEBUG2 (("IN-OUT option selected\n")) ;
	    ASSERT (fnrows >= 0 && fncols > 0) ;
	    Work->pivcol_in_front = TRUE ;
	    Work->pivrow_in_front = FALSE ;
	    Work->pivcol = pivcol [IN] ;
	    Work->pivrow = pivrow [IN][OUT] ;
	    Work->ccdeg = nr_in ;
	    Work->Wrow = Wio ;
	    Work->rrdeg = rdeg [IN][OUT] ;
	    jj = jcand [IN] ;
	    Work->fnrows_new = fnrows_new [IN][OUT] ;
	    Work->fncols_new = fncols_new [IN][OUT] ;
	    break ;

	case OUT_IN:
	    DEBUG2 (("OUT-IN option selected\n")) ;
	    ASSERT (fnrows > 0 && fncols >= 0) ;
	    Work->pivcol_in_front = FALSE ;
	    Work->pivrow_in_front = TRUE ;
	    Work->pivcol = pivcol [OUT] ;
	    Work->pivrow = pivrow [OUT][IN] ;
	    Work->ccdeg = cdeg_out ;
	    /* Wrow might be equivalenced to Fcols (Freebie in): */
	    Work->Wrow = Woi ;
	    Work->rrdeg = rdeg [OUT][IN] ;
	    /* Work->Wrow[0..fncols-1] is not there.  See Fcols instead */
	    jj = jcand [OUT] ;
	    Work->fnrows_new = fnrows_new [OUT][IN] ;
	    Work->fncols_new = fncols_new [OUT][IN] ;
	    break ;

	case OUT_OUT:
	    DEBUG2 (("OUT-OUT option selected\n")) ;
	    ASSERT (fnrows >= 0 && fncols >= 0) ;
	    Work->pivcol_in_front = FALSE ;
	    Work->pivrow_in_front = FALSE ;
	    Work->pivcol = pivcol [OUT] ;
	    Work->pivrow = pivrow [OUT][OUT] ;
	    Work->ccdeg = cdeg_out ;
	    /* Wrow might be equivalenced to Wio (Freebie out): */
	    Work->Wrow = Woo ;
	    Work->rrdeg = rdeg [OUT][OUT] ;
	    jj = jcand [OUT] ;
	    Work->fnrows_new = fnrows_new [OUT][OUT] ;
	    Work->fncols_new = fncols_new [OUT][OUT] ;
	    break ;

    }

    ASSERT (IMPLIES (fnrows == 0 && fncols == 0, Work->pivot_case == OUT_OUT)) ;

    if (!Work->pivcol_in_front && pivcol [IN] != EMPTY)
    {
	/* clear Frpos if pivcol [IN] was searched, but not selected */
	for (i = fnrows ; i < cdeg_in ; i++)
	{
	    Frpos [Frows [i]] = EMPTY;
	}
    }

    /* ---------------------------------------------------------------------- */
    /* Pivot row and column have been found */
    /* ---------------------------------------------------------------------- */

    /* ---------------------------------------------------------------------- */
    /* remove pivot column from candidate pivot column set */
    /* ---------------------------------------------------------------------- */

    ASSERT (jj >= 0 && jj < Work->nCandidates) ;
    ASSERT (Work->pivcol == Work->Candidates [jj]) ;
    remove_candidate (jj, Work, Symbolic) ;

    /* ---------------------------------------------------------------------- */
    /* check for frontal matrix growth */
    /* ---------------------------------------------------------------------- */

    DEBUG1 (("Check frontal growth:\n")) ;
    DEBUG1 (("fnrows_new "ID" + 1 = "ID",  fnr_curr "ID"\n",
	    Work->fnrows_new, Work->fnrows_new + 1, fnr_curr)) ;
    DEBUG1 (("fncols_new "ID" + 1 = "ID",  fnc_curr "ID"\n",
	    Work->fncols_new, Work->fncols_new + 1, fnc_curr)) ;

    Work->do_grow = (Work->fnrows_new + 1 > fnr_curr
		  || Work->fncols_new + 1 > fnc_curr) ;
    if (Work->do_grow)
    {
	DEBUG0 (("\nNeed to grow frontal matrix, force do_update true\n")) ;
	/* If the front must grow, then apply the pending updates and remove
	 * the current pivot rows/columns from the front prior to growing the
	 * front.  This frees up as much space as possible for the new front. */
	if (!Work->do_update && fnpiv > 0)
	{
	    /* This update would not have to be done if the current front
	     * was big enough. */
	    Work->nforced++ ;
	    Work->do_update = TRUE ;
	}
    }

    /* ---------------------------------------------------------------------- */
    /* current pivot column */
    /* ---------------------------------------------------------------------- */

    /*
	c1) If pivot column index is in the current front:

	    The pivot column pattern is in Frows [0 .. fnrows-1] and
	    the extension is in Frows [fnrows ... fnrows+ccdeg-1].

	    Frpos [Frows [0 .. fnrows+ccdeg-1]] is
	    equal to 0 .. fnrows+ccdeg-1.  Wm is not needed.

	    The values are in Wy [0 .. fnrows+ccdeg-1].

	c2) Otherwise, if the pivot column index is not in the current front:

	    c2a) If the front is being extended, old row indices in the the
		pivot column pattern are in Frows [0 .. fnrows-1].

		All entries are in Wm [0 ... ccdeg-1], with values in
		Wx [0 .. ccdeg-1].  These may include entries already in
		Frows [0 .. fnrows-1].

		Frpos [Frows [0 .. fnrows-1]] is equal to 0 .. fnrows-1.
		Frpos [Wm [0 .. ccdeg-1]] for new entries is < 0.

	    c2b) If the front is not being extended, then the entire pivot
		column pattern is in Wm [0 .. ccdeg-1].  It includes
		the pivot row index.  It is does not contain the pattern
		Frows [0..fnrows-1].  The intersection of these two
		sets may or may not be empty.  The values are in Wx [0..ccdeg-1]

	In both cases c1 and c2, Frpos [Frows [0 .. fnrows-1]] is equal
	to 0 .. fnrows-1, which is the pattern of the current front.
	Any entry of Frpos that is not specified above is < 0.
    */


#ifndef NDEBUG
    DEBUG2 (("\n\nSEARCH DONE: Pivot col "ID" in: ("ID") pivot row "ID" in: ("ID
	") extend: "ID"\n\n", Work->pivcol, Work->pivcol_in_front,
	Work->pivrow, Work->pivrow_in_front, Work->do_extend)) ;
    UMF_dump_rowcol (1, Numeric, Work, Work->pivcol, !Symbolic->fixQ) ;
    DEBUG2 (("Pivot col "ID": fnrows "ID" ccdeg "ID"\n", Work->pivcol, fnrows,
	Work->ccdeg)) ;
    if (Work->pivcol_in_front)	/* case c1 */
    {
	Int found = FALSE ;
	DEBUG3 (("Pivcol in front\n")) ;
	for (i = 0 ; i < fnrows ; i++)
	{
	    row = Frows [i] ;
	    DEBUG3 ((ID":   row:: "ID" in front ", i, row)) ;
	    ASSERT (row >= 0 && row < n_row && NON_PIVOTAL_ROW (row)) ;
	    ASSERT (Frpos [row] == i) ;
	    EDEBUG3 (Wy [i]) ;
	    if (row == Work->pivrow)
	    {
		DEBUG3 ((" <- pivrow")) ;
		found = TRUE ;
	    }
	    DEBUG3 (("\n")) ;
	}
	ASSERT (found == Work->pivrow_in_front) ;
	found = FALSE ;
	for (i = fnrows ; i < fnrows + Work->ccdeg ; i++)
	{
	    row = Frows [i] ;
	    DEBUG3 ((ID":   row:: "ID" (new)", i, row)) ;
	    ASSERT (row >= 0 && row < n_row && NON_PIVOTAL_ROW (row)) ;
	    ASSERT (Frpos [row] == i) ;
	    EDEBUG3 (Wy [i]) ;
	    if (row == Work->pivrow)
	    {
		DEBUG3 ((" <- pivrow")) ;
		found = TRUE ;
	    }
	    DEBUG3 (("\n")) ;
	}
	ASSERT (found == !Work->pivrow_in_front) ;
    }
    else
    {
	if (Work->do_extend)
	{
	    Int found = FALSE ;
	    DEBUG3 (("Pivcol not in front (extend)\n")) ;
	    for (i = 0 ; i < fnrows ; i++)
	    {
		row = Frows [i] ;
		DEBUG3 ((ID":   row:: "ID" in front ", i, row)) ;
		ASSERT (row >= 0 && row < n_row && NON_PIVOTAL_ROW (row)) ;
		ASSERT (Frpos [row] == i) ;
		if (row == Work->pivrow)
		{
		    DEBUG3 ((" <- pivrow")) ;
		    found = TRUE ;
		}
		DEBUG3 (("\n")) ;
	    }
	    ASSERT (found == Work->pivrow_in_front) ;
	    found = FALSE ;
	    DEBUG3 (("----\n")) ;
	    for (i = 0 ; i < Work->ccdeg ; i++)
	    {
		row = Wm [i] ;
		ASSERT (row >= 0 && row < n_row && NON_PIVOTAL_ROW (row)) ;
		DEBUG3 ((ID":   row:: "ID" ", i, row)) ;
		EDEBUG3 (Wx [i]) ;
		if (Frpos [row] < 0)
		{
		    DEBUG3 ((" (new) ")) ;
		}
		if (row == Work->pivrow)
		{
		    DEBUG3 ((" <- pivrow")) ;
		    found = TRUE ;
		    /* ... */
		    if (Work->pivrow_in_front) ASSERT (Frpos [row] >= 0) ;
		    else ASSERT (Frpos [row] < 0) ;
		}
		DEBUG3 (("\n")) ;
	    }
	    ASSERT (found) ;
	}
	else
	{
	    Int found = FALSE ;
	    DEBUG3 (("Pivcol not in front (no extend)\n")) ;
	    for (i = 0 ; i < Work->ccdeg ; i++)
	    {
		row = Wm [i] ;
		ASSERT (row >= 0 && row < n_row && NON_PIVOTAL_ROW (row)) ;
		DEBUG3 ((ID":   row:: "ID" ", i, row)) ;
		EDEBUG3 (Wx [i]) ;
		DEBUG3 ((" (new) ")) ;
		if (row == Work->pivrow)
		{
		    DEBUG3 ((" <- pivrow")) ;
		    found = TRUE ;
		}
		DEBUG3 (("\n")) ;
	    }
	    ASSERT (found) ;
	}
    }
#endif

    /* ---------------------------------------------------------------------- */
    /* current pivot row */
    /* ---------------------------------------------------------------------- */

    /*
	r1) If the pivot row index is in the current front:

	    The pivot row pattern is in Fcols [0..fncols-1] and the extenson is
	    in Wrow [fncols .. rrdeg-1].  If the pivot column is in the current
	    front, then Fcols and Wrow are equivalenced.

	r2)  If the pivot row index is not in the current front:

	    r2a) If the front is being extended, the pivot row pattern is in
		Fcols [0 .. fncols-1].  New entries are in Wrow [0 .. rrdeg-1],
		but these may include entries already in Fcols [0 .. fncols-1].

	    r2b) Otherwise, the pivot row pattern is Wrow [0 .. rrdeg-1].

	Fcpos [Fcols [0..fncols-1]] is (0..fncols-1) * fnr_curr.
	All other entries in Fcpos are < 0.

	These conditions are asserted below.

	------------------------------------------------------------------------
	Other items in Work structure that are relevant:

	pivcol: the pivot column index
	pivrow: the pivot column index

	rrdeg:
	ccdeg:

	fnrows: the number of rows in the currnt contribution block
	fncols: the number of columns in the current contribution block

	fnrows_new: the number of rows in the new contribution block
	fncols_new: the number of rows in the new contribution block

	------------------------------------------------------------------------
    */


#ifndef NDEBUG
    UMF_dump_rowcol (0, Numeric, Work, Work->pivrow, TRUE) ;
    DEBUG2 (("Pivot row "ID":\n", Work->pivrow)) ;
    if (Work->pivrow_in_front)
    {
	Int found = FALSE ;
	for (i = 0 ; i < fncols ; i++)
	{
	    col = Fcols [i] ;
	    DEBUG3 (("   col:: "ID" in front\n", col)) ;
	    ASSERT (col >= 0 && col < n_col && NON_PIVOTAL_COL (col)) ;
	    ASSERT (Fcpos [col] == i * fnr_curr) ;
	    if (col == Work->pivcol) found = TRUE ;
	}
	ASSERT (found == Work->pivcol_in_front) ;
	found = FALSE ;
	ASSERT (IMPLIES (Work->pivcol_in_front, Fcols == Work->Wrow)) ;
	for (i = fncols ; i < Work->rrdeg ; i++)
	{
	    col = Work->Wrow [i] ;
	    ASSERT (col >= 0 && col < n_col && NON_PIVOTAL_COL (col)) ;
	    ASSERT (Fcpos [col] < 0) ;
	    if (col == Work->pivcol) found = TRUE ;
	    else DEBUG3 (("   col:: "ID" (new)\n", col)) ;
	}
	ASSERT (found == !Work->pivcol_in_front) ;
    }
    else
    {
	if (Work->do_extend)
	{
	    Int found = FALSE ;
	    for (i = 0 ; i < fncols ; i++)
	    {
		col = Fcols [i] ;
		DEBUG3 (("   col:: "ID" in front\n", col)) ;
		ASSERT (col >= 0 && col < n_col && NON_PIVOTAL_COL (col)) ;
		ASSERT (Fcpos [col] == i * fnr_curr) ;
		if (col == Work->pivcol) found = TRUE ;
	    }
	    ASSERT (found == Work->pivcol_in_front) ;
	    found = FALSE ;
	    for (i = 0 ; i < Work->rrdeg ; i++)
	    {
		col = Work->Wrow [i] ;
		ASSERT (col >= 0 && col < n_col && NON_PIVOTAL_COL (col)) ;
		if (Fcpos [col] >= 0) continue ;
		if (col == Work->pivcol) found = TRUE ;
		else DEBUG3 (("   col:: "ID" (new, extend)\n", col)) ;
	    }
	    ASSERT (found == !Work->pivcol_in_front) ;
	}
	else
	{
	    Int found = FALSE ;
	    for (i = 0 ; i < Work->rrdeg ; i++)
	    {
		col = Work->Wrow [i] ;
		ASSERT (col >= 0 && col < n_col && NON_PIVOTAL_COL (col)) ;
		if (col == Work->pivcol) found = TRUE ;
		else DEBUG3 (("   col:: "ID" (all new)\n", col)) ;
	    }
	    ASSERT (found) ;
	}
    }
#endif

    /* ---------------------------------------------------------------------- */
    /* determine whether to do scan2-row and scan2-col */
    /* ---------------------------------------------------------------------- */

    if (Work->do_extend)
    {
	Work->do_scan2row = (fncols > 0) ;
	Work->do_scan2col = (fnrows > 0) ;
    }
    else
    {
	Work->do_scan2row = (fncols > 0) && Work->pivrow_in_front ;
	Work->do_scan2col = (fnrows > 0) && Work->pivcol_in_front ;
    }

    /* ---------------------------------------------------------------------- */

    DEBUG2 (("LOCAL SEARCH DONE: pivot column "ID" pivot row: "ID"\n",
	Work->pivcol, Work->pivrow)) ;
    DEBUG2 (("do_extend: "ID"\n", Work->do_extend)) ;
    DEBUG2 (("do_update: "ID"\n", Work->do_update)) ;
    DEBUG2 (("do_grow:   "ID"\n", Work->do_grow)) ;

    /* ---------------------------------------------------------------------- */
    /* keep track of the diagonal */
    /* ---------------------------------------------------------------------- */

    if (Symbolic->prefer_diagonal
	&& Work->pivcol < Work->n_col - Symbolic->nempty_col)
    {
	Diagonal_map = Work->Diagonal_map ;
	Diagonal_imap = Work->Diagonal_imap ;
	ASSERT (Diagonal_map != (Int *) NULL) ;
	ASSERT (Diagonal_imap != (Int *) NULL) ;

	row2 = Diagonal_map  [Work->pivcol] ;
	col2 = Diagonal_imap [Work->pivrow] ;

	if (row2 < 0)
	{
	    /* this was an off-diagonal pivot row */
	    Work->noff_diagonal++ ;
	    row2 = UNFLIP (row2) ;
	}

	ASSERT (Diagonal_imap [row2] == Work->pivcol) ;
	ASSERT (UNFLIP (Diagonal_map [col2]) == Work->pivrow) ;

	if (row2 != Work->pivrow)
	{
	    /* swap the diagonal map to attempt to maintain symmetry later on.
	     * Also mark the map for col2 (via FLIP) to denote that the entry
	     * now on the diagonal is not the original entry on the diagonal. */

	    DEBUG0 (("Unsymmetric pivot\n")) ;
	    Diagonal_map  [Work->pivcol] = FLIP (Work->pivrow) ;
	    Diagonal_imap [Work->pivrow] = Work->pivcol ;

	    Diagonal_map  [col2] = FLIP (row2) ;
	    Diagonal_imap [row2] = col2 ;

	}
	ASSERT (n_row == n_col) ;
#ifndef NDEBUG
	UMF_dump_diagonal_map (Diagonal_map, Diagonal_imap, Symbolic->n1,
	    Symbolic->n_col, Symbolic->nempty_col) ;
#endif
    }

    return (UMFPACK_OK) ;
}