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
|
'\"
'\" Generated from file 'linalg\&.man' by tcllib/doctools with format 'nroff'
'\" Copyright (c) 2004-2008 Arjen Markus <arjenmarkus@users\&.sourceforge\&.net>
'\" Copyright (c) 2004 Ed Hume <http://www\&.hume\&.com/contact\&.us\&.htm>
'\" Copyright (c) 2008 Michael Buadin <relaxkmike@users\&.sourceforge\&.net>
'\"
.TH "math::linearalgebra" n 1\&.1\&.7 tcllib "Tcl Math Library"
.\" The -*- nroff -*- definitions below are for supplemental macros used
.\" in Tcl/Tk manual entries.
.\"
.\" .AP type name in/out ?indent?
.\" Start paragraph describing an argument to a library procedure.
.\" type is type of argument (int, etc.), in/out is either "in", "out",
.\" or "in/out" to describe whether procedure reads or modifies arg,
.\" and indent is equivalent to second arg of .IP (shouldn't ever be
.\" needed; use .AS below instead)
.\"
.\" .AS ?type? ?name?
.\" Give maximum sizes of arguments for setting tab stops. Type and
.\" name are examples of largest possible arguments that will be passed
.\" to .AP later. If args are omitted, default tab stops are used.
.\"
.\" .BS
.\" Start box enclosure. From here until next .BE, everything will be
.\" enclosed in one large box.
.\"
.\" .BE
.\" End of box enclosure.
.\"
.\" .CS
.\" Begin code excerpt.
.\"
.\" .CE
.\" End code excerpt.
.\"
.\" .VS ?version? ?br?
.\" Begin vertical sidebar, for use in marking newly-changed parts
.\" of man pages. The first argument is ignored and used for recording
.\" the version when the .VS was added, so that the sidebars can be
.\" found and removed when they reach a certain age. If another argument
.\" is present, then a line break is forced before starting the sidebar.
.\"
.\" .VE
.\" End of vertical sidebar.
.\"
.\" .DS
.\" Begin an indented unfilled display.
.\"
.\" .DE
.\" End of indented unfilled display.
.\"
.\" .SO ?manpage?
.\" Start of list of standard options for a Tk widget. The manpage
.\" argument defines where to look up the standard options; if
.\" omitted, defaults to "options". The options follow on successive
.\" lines, in three columns separated by tabs.
.\"
.\" .SE
.\" End of list of standard options for a Tk widget.
.\"
.\" .OP cmdName dbName dbClass
.\" Start of description of a specific option. cmdName gives the
.\" option's name as specified in the class command, dbName gives
.\" the option's name in the option database, and dbClass gives
.\" the option's class in the option database.
.\"
.\" .UL arg1 arg2
.\" Print arg1 underlined, then print arg2 normally.
.\"
.\" .QW arg1 ?arg2?
.\" Print arg1 in quotes, then arg2 normally (for trailing punctuation).
.\"
.\" .PQ arg1 ?arg2?
.\" Print an open parenthesis, arg1 in quotes, then arg2 normally
.\" (for trailing punctuation) and then a closing parenthesis.
.\"
.\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
.if t .wh -1.3i ^B
.nr ^l \n(.l
.ad b
.\" # Start an argument description
.de AP
.ie !"\\$4"" .TP \\$4
.el \{\
. ie !"\\$2"" .TP \\n()Cu
. el .TP 15
.\}
.ta \\n()Au \\n()Bu
.ie !"\\$3"" \{\
\&\\$1 \\fI\\$2\\fP (\\$3)
.\".b
.\}
.el \{\
.br
.ie !"\\$2"" \{\
\&\\$1 \\fI\\$2\\fP
.\}
.el \{\
\&\\fI\\$1\\fP
.\}
.\}
..
.\" # define tabbing values for .AP
.de AS
.nr )A 10n
.if !"\\$1"" .nr )A \\w'\\$1'u+3n
.nr )B \\n()Au+15n
.\"
.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
.nr )C \\n()Bu+\\w'(in/out)'u+2n
..
.AS Tcl_Interp Tcl_CreateInterp in/out
.\" # BS - start boxed text
.\" # ^y = starting y location
.\" # ^b = 1
.de BS
.br
.mk ^y
.nr ^b 1u
.if n .nf
.if n .ti 0
.if n \l'\\n(.lu\(ul'
.if n .fi
..
.\" # BE - end boxed text (draw box now)
.de BE
.nf
.ti 0
.mk ^t
.ie n \l'\\n(^lu\(ul'
.el \{\
.\" Draw four-sided box normally, but don't draw top of
.\" box if the box started on an earlier page.
.ie !\\n(^b-1 \{\
\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.el \}\
\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.\}
.fi
.br
.nr ^b 0
..
.\" # VS - start vertical sidebar
.\" # ^Y = starting y location
.\" # ^v = 1 (for troff; for nroff this doesn't matter)
.de VS
.if !"\\$2"" .br
.mk ^Y
.ie n 'mc \s12\(br\s0
.el .nr ^v 1u
..
.\" # VE - end of vertical sidebar
.de VE
.ie n 'mc
.el \{\
.ev 2
.nf
.ti 0
.mk ^t
\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
.sp -1
.fi
.ev
.\}
.nr ^v 0
..
.\" # Special macro to handle page bottom: finish off current
.\" # box/sidebar if in box/sidebar mode, then invoked standard
.\" # page bottom macro.
.de ^B
.ev 2
'ti 0
'nf
.mk ^t
.if \\n(^b \{\
.\" Draw three-sided box if this is the box's first page,
.\" draw two sides but no top otherwise.
.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.\}
.if \\n(^v \{\
.nr ^x \\n(^tu+1v-\\n(^Yu
\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
.\}
.bp
'fi
.ev
.if \\n(^b \{\
.mk ^y
.nr ^b 2
.\}
.if \\n(^v \{\
.mk ^Y
.\}
..
.\" # DS - begin display
.de DS
.RS
.nf
.sp
..
.\" # DE - end display
.de DE
.fi
.RE
.sp
..
.\" # SO - start of list of standard options
.de SO
'ie '\\$1'' .ds So \\fBoptions\\fR
'el .ds So \\fB\\$1\\fR
.SH "STANDARD OPTIONS"
.LP
.nf
.ta 5.5c 11c
.ft B
..
.\" # SE - end of list of standard options
.de SE
.fi
.ft R
.LP
See the \\*(So manual entry for details on the standard options.
..
.\" # OP - start of full description for a single option
.de OP
.LP
.nf
.ta 4c
Command-Line Name: \\fB\\$1\\fR
Database Name: \\fB\\$2\\fR
Database Class: \\fB\\$3\\fR
.fi
.IP
..
.\" # CS - begin code excerpt
.de CS
.RS
.nf
.ta .25i .5i .75i 1i
..
.\" # CE - end code excerpt
.de CE
.fi
.RE
..
.\" # UL - underline word
.de UL
\\$1\l'|0\(ul'\\$2
..
.\" # QW - apply quotation marks to word
.de QW
.ie '\\*(lq'"' ``\\$1''\\$2
.\"" fix emacs highlighting
.el \\*(lq\\$1\\*(rq\\$2
..
.\" # PQ - apply parens and quotation marks to word
.de PQ
.ie '\\*(lq'"' (``\\$1''\\$2)\\$3
.\"" fix emacs highlighting
.el (\\*(lq\\$1\\*(rq\\$2)\\$3
..
.\" # QR - quoted range
.de QR
.ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3
.\"" fix emacs highlighting
.el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3
..
.\" # MT - "empty" string
.de MT
.QW ""
..
.BS
.SH NAME
math::linearalgebra \- Linear Algebra
.SH SYNOPSIS
package require \fBTcl ?8\&.5 9?\fR
.sp
package require \fBmath::linearalgebra ?1\&.1\&.7?\fR
.sp
\fB::math::linearalgebra::mkVector\fR \fIndim\fR \fIvalue\fR
.sp
\fB::math::linearalgebra::mkUnitVector\fR \fIndim\fR \fIndir\fR
.sp
\fB::math::linearalgebra::mkMatrix\fR \fInrows\fR \fIncols\fR \fIvalue\fR
.sp
\fB::math::linearalgebra::getrow\fR \fImatrix\fR \fIrow\fR ?imin? ?imax?
.sp
\fB::math::linearalgebra::setrow\fR \fImatrix\fR \fIrow\fR \fInewvalues\fR ?imin? ?imax?
.sp
\fB::math::linearalgebra::getcol\fR \fImatrix\fR \fIcol\fR ?imin? ?imax?
.sp
\fB::math::linearalgebra::setcol\fR \fImatrix\fR \fIcol\fR \fInewvalues\fR ?imin? ?imax?
.sp
\fB::math::linearalgebra::getelem\fR \fImatrix\fR \fIrow\fR \fIcol\fR
.sp
\fB::math::linearalgebra::setelem\fR \fImatrix\fR \fIrow\fR ?col? \fInewvalue\fR
.sp
\fB::math::linearalgebra::swaprows\fR \fImatrix\fR \fIirow1\fR \fIirow2\fR ?imin? ?imax?
.sp
\fB::math::linearalgebra::swapcols\fR \fImatrix\fR \fIicol1\fR \fIicol2\fR ?imin? ?imax?
.sp
\fB::math::linearalgebra::show\fR \fIobj\fR ?format? ?rowsep? ?colsep?
.sp
\fB::math::linearalgebra::dim\fR \fIobj\fR
.sp
\fB::math::linearalgebra::shape\fR \fIobj\fR
.sp
\fB::math::linearalgebra::conforming\fR \fItype\fR \fIobj1\fR \fIobj2\fR
.sp
\fB::math::linearalgebra::symmetric\fR \fImatrix\fR ?eps?
.sp
\fB::math::linearalgebra::norm\fR \fIvector\fR \fItype\fR
.sp
\fB::math::linearalgebra::norm_one\fR \fIvector\fR
.sp
\fB::math::linearalgebra::norm_two\fR \fIvector\fR
.sp
\fB::math::linearalgebra::norm_max\fR \fIvector\fR ?index?
.sp
\fB::math::linearalgebra::normMatrix\fR \fImatrix\fR \fItype\fR
.sp
\fB::math::linearalgebra::dotproduct\fR \fIvect1\fR \fIvect2\fR
.sp
\fB::math::linearalgebra::unitLengthVector\fR \fIvector\fR
.sp
\fB::math::linearalgebra::normalizeStat\fR \fImv\fR
.sp
\fB::math::linearalgebra::axpy\fR \fIscale\fR \fImv1\fR \fImv2\fR
.sp
\fB::math::linearalgebra::add\fR \fImv1\fR \fImv2\fR
.sp
\fB::math::linearalgebra::sub\fR \fImv1\fR \fImv2\fR
.sp
\fB::math::linearalgebra::scale\fR \fIscale\fR \fImv\fR
.sp
\fB::math::linearalgebra::rotate\fR \fIc\fR \fIs\fR \fIvect1\fR \fIvect2\fR
.sp
\fB::math::linearalgebra::transpose\fR \fImatrix\fR
.sp
\fB::math::linearalgebra::matmul\fR \fImv1\fR \fImv2\fR
.sp
\fB::math::linearalgebra::angle\fR \fIvect1\fR \fIvect2\fR
.sp
\fB::math::linearalgebra::crossproduct\fR \fIvect1\fR \fIvect2\fR
.sp
\fB::math::linearalgebra::matmul\fR \fImv1\fR \fImv2\fR
.sp
\fB::math::linearalgebra::mkIdentity\fR \fIsize\fR
.sp
\fB::math::linearalgebra::mkDiagonal\fR \fIdiag\fR
.sp
\fB::math::linearalgebra::mkRandom\fR \fIsize\fR
.sp
\fB::math::linearalgebra::mkTriangular\fR \fIsize\fR ?uplo? ?value?
.sp
\fB::math::linearalgebra::mkHilbert\fR \fIsize\fR
.sp
\fB::math::linearalgebra::mkDingdong\fR \fIsize\fR
.sp
\fB::math::linearalgebra::mkOnes\fR \fIsize\fR
.sp
\fB::math::linearalgebra::mkMoler\fR \fIsize\fR
.sp
\fB::math::linearalgebra::mkFrank\fR \fIsize\fR
.sp
\fB::math::linearalgebra::mkBorder\fR \fIsize\fR
.sp
\fB::math::linearalgebra::mkWilkinsonW+\fR \fIsize\fR
.sp
\fB::math::linearalgebra::mkWilkinsonW-\fR \fIsize\fR
.sp
\fB::math::linearalgebra::solveGauss\fR \fImatrix\fR \fIbvect\fR
.sp
\fB::math::linearalgebra::solvePGauss\fR \fImatrix\fR \fIbvect\fR
.sp
\fB::math::linearalgebra::solveTriangular\fR \fImatrix\fR \fIbvect\fR ?uplo?
.sp
\fB::math::linearalgebra::solveGaussBand\fR \fImatrix\fR \fIbvect\fR
.sp
\fB::math::linearalgebra::solveTriangularBand\fR \fImatrix\fR \fIbvect\fR
.sp
\fB::math::linearalgebra::determineSVD\fR \fIA\fR \fIeps\fR
.sp
\fB::math::linearalgebra::eigenvectorsSVD\fR \fIA\fR \fIeps\fR
.sp
\fB::math::linearalgebra::leastSquaresSVD\fR \fIA\fR \fIy\fR \fIqmin\fR \fIeps\fR
.sp
\fB::math::linearalgebra::choleski\fR \fImatrix\fR
.sp
\fB::math::linearalgebra::orthonormalizeColumns\fR \fImatrix\fR
.sp
\fB::math::linearalgebra::orthonormalizeRows\fR \fImatrix\fR
.sp
\fB::math::linearalgebra::dger\fR \fImatrix\fR \fIalpha\fR \fIx\fR \fIy\fR ?scope?
.sp
\fB::math::linearalgebra::dgetrf\fR \fImatrix\fR
.sp
\fB::math::linearalgebra::det\fR \fImatrix\fR
.sp
\fB::math::linearalgebra::largesteigen\fR \fImatrix\fR \fItolerance\fR \fImaxiter\fR
.sp
\fB::math::linearalgebra::to_LA\fR \fImv\fR
.sp
\fB::math::linearalgebra::from_LA\fR \fImv\fR
.sp
.BE
.SH DESCRIPTION
.PP
This package offers both low-level procedures and high-level algorithms
to deal with linear algebra problems:
.IP \(bu
robust solution of linear equations or least squares problems
.IP \(bu
determining eigenvectors and eigenvalues of symmetric matrices
.IP \(bu
various decompositions of general matrices or matrices of a specific
form
.IP \(bu
(limited) support for matrices in band storage, a common type of sparse
matrices
.PP
It arose as a re-implementation of Hume's LA package and the desire to
offer low-level procedures as found in the well-known BLAS library\&.
Matrices are implemented as lists of lists rather linear lists with
reserved elements, as in the original LA package, as it was found that
such an implementation is actually faster\&.
.PP
It is advisable, however, to use the procedures that are offered, such
as \fIsetrow\fR and \fIgetrow\fR, rather than rely on this
representation explicitly: that way it is to switch to a possibly even
faster compiled implementation that supports the same API\&.
.PP
\fINote:\fR When using this package in combination with Tk, there may
be a naming conflict, as both this package and Tk define a command
\fIscale\fR\&. See the \fBNAMING CONFLICT\fR section below\&.
.SH PROCEDURES
The package defines the following public procedures (several exist as
specialised procedures, see below):
.PP
\fIConstructing matrices and vectors\fR
.TP
\fB::math::linearalgebra::mkVector\fR \fIndim\fR \fIvalue\fR
Create a vector with ndim elements, each with the value \fIvalue\fR\&.
.RS
.TP
integer \fIndim\fR
Dimension of the vector (number of components)
.TP
double \fIvalue\fR
Uniform value to be used (default: 0\&.0)
.RE
.sp
.TP
\fB::math::linearalgebra::mkUnitVector\fR \fIndim\fR \fIndir\fR
Create a unit vector in \fIndim\fR-dimensional space, along the
\fIndir\fR-th direction\&.
.RS
.TP
integer \fIndim\fR
Dimension of the vector (number of components)
.TP
integer \fIndir\fR
Direction (0, \&.\&.\&., ndim-1)
.RE
.sp
.TP
\fB::math::linearalgebra::mkMatrix\fR \fInrows\fR \fIncols\fR \fIvalue\fR
Create a matrix with \fInrows\fR rows and \fIncols\fR columns\&. All
elements have the value \fIvalue\fR\&.
.RS
.TP
integer \fInrows\fR
Number of rows
.TP
integer \fIncols\fR
Number of columns
.TP
double \fIvalue\fR
Uniform value to be used (default: 0\&.0)
.RE
.sp
.TP
\fB::math::linearalgebra::getrow\fR \fImatrix\fR \fIrow\fR ?imin? ?imax?
Returns a single row of a matrix as a list
.RS
.TP
list \fImatrix\fR
Matrix in question
.TP
integer \fIrow\fR
Index of the row to return
.TP
integer \fIimin\fR
Minimum index of the column (default: 0)
.TP
integer \fIimax\fR
Maximum index of the column (default: ncols-1)
.RE
.sp
.TP
\fB::math::linearalgebra::setrow\fR \fImatrix\fR \fIrow\fR \fInewvalues\fR ?imin? ?imax?
Set a single row of a matrix to new values (this list must have the same
number of elements as the number of \fIcolumns\fR in the matrix)
.RS
.TP
list \fImatrix\fR
\fIname\fR of the matrix in question
.TP
integer \fIrow\fR
Index of the row to update
.TP
list \fInewvalues\fR
List of new values for the row
.TP
integer \fIimin\fR
Minimum index of the column (default: 0)
.TP
integer \fIimax\fR
Maximum index of the column (default: ncols-1)
.RE
.sp
.TP
\fB::math::linearalgebra::getcol\fR \fImatrix\fR \fIcol\fR ?imin? ?imax?
Returns a single column of a matrix as a list
.RS
.TP
list \fImatrix\fR
Matrix in question
.TP
integer \fIcol\fR
Index of the column to return
.TP
integer \fIimin\fR
Minimum index of the row (default: 0)
.TP
integer \fIimax\fR
Maximum index of the row (default: nrows-1)
.RE
.sp
.TP
\fB::math::linearalgebra::setcol\fR \fImatrix\fR \fIcol\fR \fInewvalues\fR ?imin? ?imax?
Set a single column of a matrix to new values (this list must have
the same number of elements as the number of \fIrows\fR in the matrix)
.RS
.TP
list \fImatrix\fR
\fIname\fR of the matrix in question
.TP
integer \fIcol\fR
Index of the column to update
.TP
list \fInewvalues\fR
List of new values for the column
.TP
integer \fIimin\fR
Minimum index of the row (default: 0)
.TP
integer \fIimax\fR
Maximum index of the row (default: nrows-1)
.RE
.sp
.TP
\fB::math::linearalgebra::getelem\fR \fImatrix\fR \fIrow\fR \fIcol\fR
Returns a single element of a matrix/vector
.RS
.TP
list \fImatrix\fR
Matrix or vector in question
.TP
integer \fIrow\fR
Row of the element
.TP
integer \fIcol\fR
Column of the element (not present for vectors)
.RE
.sp
.TP
\fB::math::linearalgebra::setelem\fR \fImatrix\fR \fIrow\fR ?col? \fInewvalue\fR
Set a single element of a matrix (or vector) to a new value
.RS
.TP
list \fImatrix\fR
\fIname\fR of the matrix in question
.TP
integer \fIrow\fR
Row of the element
.TP
integer \fIcol\fR
Column of the element (not present for vectors)
.RE
.sp
.TP
\fB::math::linearalgebra::swaprows\fR \fImatrix\fR \fIirow1\fR \fIirow2\fR ?imin? ?imax?
Swap two rows in a matrix completely or only a selected part
.RS
.TP
list \fImatrix\fR
\fIname\fR of the matrix in question
.TP
integer \fIirow1\fR
Index of first row
.TP
integer \fIirow2\fR
Index of second row
.TP
integer \fIimin\fR
Minimum column index (default: 0)
.TP
integer \fIimin\fR
Maximum column index (default: ncols-1)
.RE
.sp
.TP
\fB::math::linearalgebra::swapcols\fR \fImatrix\fR \fIicol1\fR \fIicol2\fR ?imin? ?imax?
Swap two columns in a matrix completely or only a selected part
.RS
.TP
list \fImatrix\fR
\fIname\fR of the matrix in question
.TP
integer \fIirow1\fR
Index of first column
.TP
integer \fIirow2\fR
Index of second column
.TP
integer \fIimin\fR
Minimum row index (default: 0)
.TP
integer \fIimin\fR
Maximum row index (default: nrows-1)
.RE
.PP
.PP
\fIQuerying matrices and vectors\fR
.TP
\fB::math::linearalgebra::show\fR \fIobj\fR ?format? ?rowsep? ?colsep?
Return a string representing the vector or matrix, for easy printing\&.
(There is currently no way to print fixed sets of columns)
.RS
.TP
list \fIobj\fR
Matrix or vector in question
.TP
string \fIformat\fR
Format for printing the numbers (default: %6\&.4f)
.TP
string \fIrowsep\fR
String to use for separating rows (default: newline)
.TP
string \fIcolsep\fR
String to use for separating columns (default: space)
.RE
.sp
.TP
\fB::math::linearalgebra::dim\fR \fIobj\fR
Returns the number of dimensions for the object (either 0 for a scalar,
1 for a vector and 2 for a matrix)
.RS
.TP
any \fIobj\fR
Scalar, vector, or matrix
.RE
.sp
.TP
\fB::math::linearalgebra::shape\fR \fIobj\fR
Returns the number of elements in each dimension for the object (either
an empty list for a scalar, a single number for a vector and a list of
the number of rows and columns for a matrix)
.RS
.TP
any \fIobj\fR
Scalar, vector, or matrix
.RE
.sp
.TP
\fB::math::linearalgebra::conforming\fR \fItype\fR \fIobj1\fR \fIobj2\fR
Checks if two objects (vector or matrix) have conforming shapes, that is
if they can be applied in an operation like addition or matrix
multiplication\&.
.RS
.TP
string \fItype\fR
Type of check:
.RS
.IP \(bu
"shape" - the two objects have the same shape (for all element-wise
operations)
.IP \(bu
"rows" - the two objects have the same number of rows (for use as A and
b in a system of linear equations \fIAx = b\fR
.IP \(bu
"matmul" - the first object has the same number of columns as the number
of rows of the second object\&. Useful for matrix-matrix or matrix-vector
multiplication\&.
.RE
.TP
list \fIobj1\fR
First vector or matrix (left operand)
.TP
list \fIobj2\fR
Second vector or matrix (right operand)
.RE
.sp
.TP
\fB::math::linearalgebra::symmetric\fR \fImatrix\fR ?eps?
Checks if the given (square) matrix is symmetric\&. The argument eps
is the tolerance\&.
.RS
.TP
list \fImatrix\fR
Matrix to be inspected
.TP
float \fIeps\fR
Tolerance for determining approximate equality
(defaults to 1\&.0e-8)
.RE
.PP
.PP
\fIBasic operations\fR
.TP
\fB::math::linearalgebra::norm\fR \fIvector\fR \fItype\fR
Returns the norm of the given vector\&. The type argument can be: 1,
2, inf or max, respectively the sum of absolute values, the ordinary
Euclidean norm or the max norm\&.
.RS
.TP
list \fIvector\fR
Vector, list of coefficients
.TP
string \fItype\fR
Type of norm (default: 2, the Euclidean norm)
.RE
.TP
\fB::math::linearalgebra::norm_one\fR \fIvector\fR
Returns the L1 norm of the given vector, the sum of absolute values
.RS
.TP
list \fIvector\fR
Vector, list of coefficients
.RE
.TP
\fB::math::linearalgebra::norm_two\fR \fIvector\fR
Returns the L2 norm of the given vector, the ordinary Euclidean norm
.RS
.TP
list \fIvector\fR
Vector, list of coefficients
.RE
.TP
\fB::math::linearalgebra::norm_max\fR \fIvector\fR ?index?
Returns the Linf norm of the given vector, the maximum absolute
coefficient
.RS
.TP
list \fIvector\fR
Vector, list of coefficients
.TP
integer \fIindex\fR
(optional) if non zero, returns a list made of the maximum
value and the index where that maximum was found\&.
if zero, returns the maximum value\&.
.RE
.sp
.TP
\fB::math::linearalgebra::normMatrix\fR \fImatrix\fR \fItype\fR
Returns the norm of the given matrix\&. The type argument can be: 1,
2, inf or max, respectively the sum of absolute values, the ordinary
Euclidean norm or the max norm\&.
.RS
.TP
list \fImatrix\fR
Matrix, list of row vectors
.TP
string \fItype\fR
Type of norm (default: 2, the Euclidean norm)
.RE
.sp
.TP
\fB::math::linearalgebra::dotproduct\fR \fIvect1\fR \fIvect2\fR
Determine the inproduct or dot product of two vectors\&. These must have
the same shape (number of dimensions)
.RS
.TP
list \fIvect1\fR
First vector, list of coefficients
.TP
list \fIvect2\fR
Second vector, list of coefficients
.RE
.sp
.TP
\fB::math::linearalgebra::unitLengthVector\fR \fIvector\fR
Return a vector in the same direction with length 1\&.
.RS
.TP
list \fIvector\fR
Vector to be normalized
.RE
.sp
.TP
\fB::math::linearalgebra::normalizeStat\fR \fImv\fR
Normalize the matrix or vector in a statistical sense: the mean of the
elements of the columns of the result is zero and the standard deviation
is 1\&.
.RS
.TP
list \fImv\fR
Vector or matrix to be normalized in the above sense
.RE
.sp
.TP
\fB::math::linearalgebra::axpy\fR \fIscale\fR \fImv1\fR \fImv2\fR
Return a vector or matrix that results from a "daxpy" operation, that
is: compute a*x+y (a a scalar and x and y both vectors or matrices of
the same shape) and return the result\&.
.sp
Specialised variants are: axpy_vect and axpy_mat (slightly faster,
but no check on the arguments)
.RS
.TP
double \fIscale\fR
The scale factor for the first vector/matrix (a)
.TP
list \fImv1\fR
First vector or matrix (x)
.TP
list \fImv2\fR
Second vector or matrix (y)
.RE
.sp
.TP
\fB::math::linearalgebra::add\fR \fImv1\fR \fImv2\fR
Return a vector or matrix that is the sum of the two arguments (x+y)
.sp
Specialised variants are: add_vect and add_mat (slightly faster,
but no check on the arguments)
.RS
.TP
list \fImv1\fR
First vector or matrix (x)
.TP
list \fImv2\fR
Second vector or matrix (y)
.RE
.sp
.TP
\fB::math::linearalgebra::sub\fR \fImv1\fR \fImv2\fR
Return a vector or matrix that is the difference of the two arguments
(x-y)
.sp
Specialised variants are: sub_vect and sub_mat (slightly faster,
but no check on the arguments)
.RS
.TP
list \fImv1\fR
First vector or matrix (x)
.TP
list \fImv2\fR
Second vector or matrix (y)
.RE
.sp
.TP
\fB::math::linearalgebra::scale\fR \fIscale\fR \fImv\fR
Scale a vector or matrix and return the result, that is: compute a*x\&.
.sp
Specialised variants are: scale_vect and scale_mat (slightly faster,
but no check on the arguments)
.RS
.TP
double \fIscale\fR
The scale factor for the vector/matrix (a)
.TP
list \fImv\fR
Vector or matrix (x)
.RE
.sp
.TP
\fB::math::linearalgebra::rotate\fR \fIc\fR \fIs\fR \fIvect1\fR \fIvect2\fR
Apply a planar rotation to two vectors and return the result as a list
of two vectors: c*x-s*y and s*x+c*y\&. In algorithms you can often easily
determine the cosine and sine of the angle, so it is more efficient to
pass that information directly\&.
.RS
.TP
double \fIc\fR
The cosine of the angle
.TP
double \fIs\fR
The sine of the angle
.TP
list \fIvect1\fR
First vector (x)
.TP
list \fIvect2\fR
Seocnd vector (x)
.RE
.sp
.TP
\fB::math::linearalgebra::transpose\fR \fImatrix\fR
Transpose a matrix
.RS
.TP
list \fImatrix\fR
Matrix to be transposed
.RE
.sp
.TP
\fB::math::linearalgebra::matmul\fR \fImv1\fR \fImv2\fR
Multiply a vector/matrix with another vector/matrix\&. The result is
a matrix, if both x and y are matrices or both are vectors, in
which case the "outer product" is computed\&. If one is a vector and the
other is a matrix, then the result is a vector\&.
.RS
.TP
list \fImv1\fR
First vector/matrix (x)
.TP
list \fImv2\fR
Second vector/matrix (y)
.RE
.sp
.TP
\fB::math::linearalgebra::angle\fR \fIvect1\fR \fIvect2\fR
Compute the angle between two vectors (in radians)
.RS
.TP
list \fIvect1\fR
First vector
.TP
list \fIvect2\fR
Second vector
.RE
.sp
.TP
\fB::math::linearalgebra::crossproduct\fR \fIvect1\fR \fIvect2\fR
Compute the cross product of two (three-dimensional) vectors
.RS
.TP
list \fIvect1\fR
First vector
.TP
list \fIvect2\fR
Second vector
.RE
.sp
.TP
\fB::math::linearalgebra::matmul\fR \fImv1\fR \fImv2\fR
Multiply a vector/matrix with another vector/matrix\&. The result is
a matrix, if both x and y are matrices or both are vectors, in
which case the "outer product" is computed\&. If one is a vector and the
other is a matrix, then the result is a vector\&.
.RS
.TP
list \fImv1\fR
First vector/matrix (x)
.TP
list \fImv2\fR
Second vector/matrix (y)
.RE
.PP
.PP
\fICommon matrices and test matrices\fR
.TP
\fB::math::linearalgebra::mkIdentity\fR \fIsize\fR
Create an identity matrix of dimension \fIsize\fR\&.
.RS
.TP
integer \fIsize\fR
Dimension of the matrix
.RE
.sp
.TP
\fB::math::linearalgebra::mkDiagonal\fR \fIdiag\fR
Create a diagonal matrix whose diagonal elements are the elements of the
vector \fIdiag\fR\&.
.RS
.TP
list \fIdiag\fR
Vector whose elements are used for the diagonal
.RE
.sp
.TP
\fB::math::linearalgebra::mkRandom\fR \fIsize\fR
Create a square matrix whose elements are uniformly distributed random
numbers between 0 and 1 of dimension \fIsize\fR\&.
.RS
.TP
integer \fIsize\fR
Dimension of the matrix
.RE
.sp
.TP
\fB::math::linearalgebra::mkTriangular\fR \fIsize\fR ?uplo? ?value?
Create a triangular matrix with non-zero elements in the upper or lower
part, depending on argument \fIuplo\fR\&.
.RS
.TP
integer \fIsize\fR
Dimension of the matrix
.TP
string \fIuplo\fR
Fill the upper (U) or lower part (L)
.TP
double \fIvalue\fR
Value to fill the matrix with
.RE
.sp
.TP
\fB::math::linearalgebra::mkHilbert\fR \fIsize\fR
Create a Hilbert matrix of dimension \fIsize\fR\&.
Hilbert matrices are very ill-conditioned with respect to
eigenvalue/eigenvector problems\&. Therefore they
are good candidates for testing the accuracy
of algorithms and implementations\&.
.RS
.TP
integer \fIsize\fR
Dimension of the matrix
.RE
.sp
.TP
\fB::math::linearalgebra::mkDingdong\fR \fIsize\fR
Create a "dingdong" matrix of dimension \fIsize\fR\&.
Dingdong matrices are imprecisely represented,
but have the property of being very stable in
such algorithms as Gauss elimination\&.
.RS
.TP
integer \fIsize\fR
Dimension of the matrix
.RE
.sp
.TP
\fB::math::linearalgebra::mkOnes\fR \fIsize\fR
Create a square matrix of dimension \fIsize\fR whose entries are all 1\&.
.RS
.TP
integer \fIsize\fR
Dimension of the matrix
.RE
.sp
.TP
\fB::math::linearalgebra::mkMoler\fR \fIsize\fR
Create a Moler matrix of size \fIsize\fR\&. (Moler matrices have
a very simple Choleski decomposition\&. It has one small eigenvalue
and it can easily upset elimination methods for systems of linear
equations\&.)
.RS
.TP
integer \fIsize\fR
Dimension of the matrix
.RE
.sp
.TP
\fB::math::linearalgebra::mkFrank\fR \fIsize\fR
Create a Frank matrix of size \fIsize\fR\&. (Frank matrices are
fairly well-behaved matrices)
.RS
.TP
integer \fIsize\fR
Dimension of the matrix
.RE
.sp
.TP
\fB::math::linearalgebra::mkBorder\fR \fIsize\fR
Create a bordered matrix of size \fIsize\fR\&. (Bordered matrices have
a very low rank and can upset certain specialised algorithms\&.)
.RS
.TP
integer \fIsize\fR
Dimension of the matrix
.RE
.sp
.TP
\fB::math::linearalgebra::mkWilkinsonW+\fR \fIsize\fR
Create a Wilkinson W+ of size \fIsize\fR\&. This kind of matrix
has pairs of eigenvalues that are very close together\&. Usually
the order (size) is odd\&.
.RS
.TP
integer \fIsize\fR
Dimension of the matrix
.RE
.sp
.TP
\fB::math::linearalgebra::mkWilkinsonW-\fR \fIsize\fR
Create a Wilkinson W- of size \fIsize\fR\&. This kind of matrix
has pairs of eigenvalues with opposite signs, when the order (size)
is odd\&.
.RS
.TP
integer \fIsize\fR
Dimension of the matrix
.RE
.PP
.PP
\fICommon algorithms\fR
.TP
\fB::math::linearalgebra::solveGauss\fR \fImatrix\fR \fIbvect\fR
Solve a system of linear equations (Ax=b) using Gauss elimination\&.
Returns the solution (x) as a vector or matrix of the same shape as
bvect\&.
.RS
.TP
list \fImatrix\fR
Square matrix (matrix A)
.TP
list \fIbvect\fR
Vector or matrix whose columns are the individual
b-vectors
.RE
.TP
\fB::math::linearalgebra::solvePGauss\fR \fImatrix\fR \fIbvect\fR
Solve a system of linear equations (Ax=b) using Gauss elimination with
partial pivoting\&. Returns the solution (x) as a vector or matrix of the
same shape as bvect\&.
.RS
.TP
list \fImatrix\fR
Square matrix (matrix A)
.TP
list \fIbvect\fR
Vector or matrix whose columns are the individual
b-vectors
.RE
.sp
.TP
\fB::math::linearalgebra::solveTriangular\fR \fImatrix\fR \fIbvect\fR ?uplo?
Solve a system of linear equations (Ax=b) by backward substitution\&. The
matrix is supposed to be upper-triangular\&.
.RS
.TP
list \fImatrix\fR
Lower or upper-triangular matrix (matrix A)
.TP
list \fIbvect\fR
Vector or matrix whose columns are the individual
b-vectors
.TP
string \fIuplo\fR
Indicates whether the matrix is lower-triangular
(L) or upper-triangular (U)\&. Defaults to "U"\&.
.RE
.TP
\fB::math::linearalgebra::solveGaussBand\fR \fImatrix\fR \fIbvect\fR
Solve a system of linear equations (Ax=b) using Gauss elimination,
where the matrix is stored as a band matrix (\fIcf\&.\fR \fBSTORAGE\fR)\&.
Returns the solution (x) as a vector or matrix of the same shape as
bvect\&.
.RS
.TP
list \fImatrix\fR
Square matrix (matrix A; in band form)
.TP
list \fIbvect\fR
Vector or matrix whose columns are the individual
b-vectors
.RE
.sp
.TP
\fB::math::linearalgebra::solveTriangularBand\fR \fImatrix\fR \fIbvect\fR
Solve a system of linear equations (Ax=b) by backward substitution\&. The
matrix is supposed to be upper-triangular and stored in band form\&.
.RS
.TP
list \fImatrix\fR
Upper-triangular matrix (matrix A)
.TP
list \fIbvect\fR
Vector or matrix whose columns are the individual
b-vectors
.RE
.sp
.TP
\fB::math::linearalgebra::determineSVD\fR \fIA\fR \fIeps\fR
Determines the Singular Value Decomposition of a matrix: A = U S Vtrans\&.
Returns a list with the matrix U, the vector of singular values S and
the matrix V\&.
.RS
.TP
list \fIA\fR
Matrix to be decomposed
.TP
float \fIeps\fR
Tolerance (defaults to 2\&.3e-16)
.RE
.sp
.TP
\fB::math::linearalgebra::eigenvectorsSVD\fR \fIA\fR \fIeps\fR
Determines the eigenvectors and eigenvalues of a real
\fIsymmetric\fR matrix, using SVD\&. Returns a list with the matrix of
normalized eigenvectors and their eigenvalues\&.
.RS
.TP
list \fIA\fR
Matrix whose eigenvalues must be determined
.TP
float \fIeps\fR
Tolerance (defaults to 2\&.3e-16)
.RE
.sp
.TP
\fB::math::linearalgebra::leastSquaresSVD\fR \fIA\fR \fIy\fR \fIqmin\fR \fIeps\fR
Determines the solution to a least-sqaures problem Ax ~ y via singular
value decomposition\&. The result is the vector x\&.
.sp
Note that if you add a column of 1s to the matrix, then this column will
represent a constant like in: y = a*x1 + b*x2 + c\&. To force the
intercept to be zero, simply leave it out\&.
.RS
.TP
list \fIA\fR
Matrix of independent variables
.TP
list \fIy\fR
List of observed values
.TP
float \fIqmin\fR
Minimum singular value to be considered (defaults to 0\&.0)
.TP
float \fIeps\fR
Tolerance (defaults to 2\&.3e-16)
.RE
.sp
.TP
\fB::math::linearalgebra::choleski\fR \fImatrix\fR
Determine the Choleski decomposition of a symmetric positive
semidefinite matrix (this condition is not checked!)\&. The result
is the lower-triangular matrix L such that L Lt = matrix\&.
.RS
.TP
list \fImatrix\fR
Matrix to be decomposed
.RE
.sp
.TP
\fB::math::linearalgebra::orthonormalizeColumns\fR \fImatrix\fR
Use the modified Gram-Schmidt method to orthogonalize and normalize
the \fIcolumns\fR of the given matrix and return the result\&.
.RS
.TP
list \fImatrix\fR
Matrix whose columns must be orthonormalized
.RE
.sp
.TP
\fB::math::linearalgebra::orthonormalizeRows\fR \fImatrix\fR
Use the modified Gram-Schmidt method to orthogonalize and normalize
the \fIrows\fR of the given matrix and return the result\&.
.RS
.TP
list \fImatrix\fR
Matrix whose rows must be orthonormalized
.RE
.sp
.TP
\fB::math::linearalgebra::dger\fR \fImatrix\fR \fIalpha\fR \fIx\fR \fIy\fR ?scope?
Perform the rank 1 operation A + alpha*x*y' inline (that is: the matrix A is adjusted)\&.
For convenience the new matrix is also returned as the result\&.
.RS
.TP
list \fImatrix\fR
Matrix whose rows must be adjusted
.TP
double \fIalpha\fR
Scale factor
.TP
list \fIx\fR
A column vector
.TP
list \fIy\fR
A column vector
.TP
list \fIscope\fR
If not provided, the operation is performed on all rows/columns of A
if provided, it is expected to be the list {imin imax jmin jmax}
where:
.RS
.IP \(bu
\fIimin\fR Minimum row index
.IP \(bu
\fIimax\fR Maximum row index
.IP \(bu
\fIjmin\fR Minimum column index
.IP \(bu
\fIjmax\fR Maximum column index
.RE
.RE
.sp
.TP
\fB::math::linearalgebra::dgetrf\fR \fImatrix\fR
Computes an LU factorization of a general matrix, using partial,
pivoting with row interchanges\&. Returns the permutation vector\&.
.sp
The factorization has the form
.CS
P * A = L * U
.CE
.IP
where P is a permutation matrix, L is lower triangular with unit
diagonal elements, and U is upper triangular\&.
Returns the permutation vector, as a list of length n-1\&.
The last entry of the permutation is not stored, since it is
implicitely known, with value n (the last row is not swapped
with any other row)\&.
At index #i of the permutation is stored the index of the row #j
which is swapped with row #i at step #i\&. That means that each
index of the permutation gives the permutation at each step, not the
cumulated permutation matrix, which is the product of permutations\&.
.RS
.TP
list \fImatrix\fR
On entry, the matrix to be factored\&.
On exit, the factors L and U from the factorization
P*A = L*U; the unit diagonal elements of L are not stored\&.
.RE
.sp
.TP
\fB::math::linearalgebra::det\fR \fImatrix\fR
Returns the determinant of the given matrix, based on PA=LU
decomposition, i\&.e\&. Gauss partial pivotal\&.
.RS
.TP
list \fImatrix\fR
Square matrix (matrix A)
.TP
list \fIipiv\fR
The pivots (optionnal)\&.
If the pivots are not provided, a PA=LU decomposition
is performed\&.
If the pivots are provided, we assume that it
contains the pivots and that the matrix A contains the
L and U factors, as provided by dgterf\&.
b-vectors
.RE
.sp
.TP
\fB::math::linearalgebra::largesteigen\fR \fImatrix\fR \fItolerance\fR \fImaxiter\fR
Returns a list made of the largest eigenvalue (in magnitude)
and associated eigenvector\&.
Uses iterative Power Method as provided as algorithm #7\&.3\&.3 of Golub & Van Loan\&.
This algorithm is used here for a dense matrix (but is usually
used for sparse matrices)\&.
.RS
.TP
list \fImatrix\fR
Square matrix (matrix A)
.TP
double \fItolerance\fR
The relative tolerance of the eigenvalue (default:1\&.e-8)\&.
.TP
integer \fImaxiter\fR
The maximum number of iterations (default:10)\&.
.RE
.PP
.PP
\fICompability with the LA package\fR
Two procedures are provided for compatibility with Hume's LA package:
.TP
\fB::math::linearalgebra::to_LA\fR \fImv\fR
Transforms a vector or matrix into the format used by the original LA
package\&.
.RS
.TP
list \fImv\fR
Matrix or vector
.RE
.TP
\fB::math::linearalgebra::from_LA\fR \fImv\fR
Transforms a vector or matrix from the format used by the original LA
package into the format used by the present implementation\&.
.RS
.TP
list \fImv\fR
Matrix or vector as used by the LA package
.RE
.PP
.PP
.SH STORAGE
While most procedures assume that the matrices are given in full form,
the procedures \fIsolveGaussBand\fR and \fIsolveTriangularBand\fR
assume that the matrices are stored as \fIband matrices\fR\&. This
common type of "sparse" matrices is related to ordinary matrices as
follows:
.IP \(bu
"A" is a full-size matrix with N rows and M columns\&.
.IP \(bu
"B" is a band matrix, with m upper and lower diagonals and n rows\&.
.IP \(bu
"B" can be stored in an ordinary matrix of (2m+1) columns (one for
each off-diagonal and the main diagonal) and n rows\&.
.IP \(bu
Element i,j (i = -m,\&.\&.\&.,m; j =1,\&.\&.\&.,n) of "B" corresponds to element
k,j of "A" where k = M+i-1 and M is at least (!) n, the number of rows
in "B"\&.
.IP \(bu
To set element (i,j) of matrix "B" use:
.CS
setelem B $j [expr {$N+$i-1}] $value
.CE
.PP
(There is no convenience procedure for this yet)
.SH "REMARKS ON THE IMPLEMENTATION"
There is a difference between the original LA package by Hume and the
current implementation\&. Whereas the LA package uses a linear list, the
current package uses lists of lists to represent matrices\&. It turns out
that with this representation, the algorithms are faster and easier to
implement\&.
.PP
The LA package was used as a model and in fact the implementation of,
for instance, the SVD algorithm was taken from that package\&. The set of
procedures was expanded using ideas from the well-known BLAS library and
some algorithms were updated from the second edition of J\&.C\&. Nash's
book, Compact Numerical Methods for Computers, (Adam Hilger, 1990) that
inspired the LA package\&.
.PP
Two procedures are provided to make the transition between the two
implementations easier: \fIto_LA\fR and \fIfrom_LA\fR\&. They are
described above\&.
.SH TODO
Odds and ends: the following algorithms have not been implemented yet:
.IP \(bu
determineQR
.IP \(bu
certainlyPositive, diagonallyDominant
.PP
.SH "NAMING CONFLICT"
If you load this package in a Tk-enabled shell like wish, then the
command
.CS
namespace import ::math::linearalgebra
.CE
results in an error
message about "scale"\&. This is due to the fact that Tk defines all
its commands in the global namespace\&. The solution is to import
the linear algebra commands in a namespace that is not the global one:
.CS
package require math::linearalgebra
namespace eval compute {
namespace import ::math::linearalgebra::*
\&.\&.\&. use the linear algebra version of scale \&.\&.\&.
}
.CE
To use Tk's scale command in that same namespace you can rename it:
.CS
namespace eval compute {
rename ::scale scaleTk
scaleTk \&.scale \&.\&.\&.
}
.CE
.SH "BUGS, IDEAS, FEEDBACK"
This document, and the package it describes, will undoubtedly contain
bugs and other problems\&.
Please report such in the category \fImath :: linearalgebra\fR of the
\fITcllib Trackers\fR [http://core\&.tcl\&.tk/tcllib/reportlist]\&.
Please also report any ideas for enhancements you may have for either
package and/or documentation\&.
.PP
When proposing code changes, please provide \fIunified diffs\fR,
i\&.e the output of \fBdiff -u\fR\&.
.PP
Note further that \fIattachments\fR are strongly preferred over
inlined patches\&. Attachments can be made by going to the \fBEdit\fR
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar\&.
.SH KEYWORDS
least squares, linear algebra, linear equations, math, matrices, matrix, vectors
.SH CATEGORY
Mathematics
.SH COPYRIGHT
.nf
Copyright (c) 2004-2008 Arjen Markus <arjenmarkus@users\&.sourceforge\&.net>
Copyright (c) 2004 Ed Hume <http://www\&.hume\&.com/contact\&.us\&.htm>
Copyright (c) 2008 Michael Buadin <relaxkmike@users\&.sourceforge\&.net>
.fi
|