/usr/lib/ats-anairiats-0.2.11/libats/SATS/genarrays.sats is in ats-lang-anairiats 0.2.11-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | (***********************************************************************)
(* *)
(* Applied Type System *)
(* *)
(* Hongwei Xi *)
(* *)
(***********************************************************************)
(*
** ATS - Unleashing the Potential of Types!
** Copyright (C) 2002-2009 Hongwei Xi, Boston University
** All rights reserved
**
** ATS is free software; you can redistribute it and/or modify it under
** the terms of the GNU General Public License as published by the Free
** Software Foundation; either version 2.1, or (at your option) any later
** version.
**
** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
** WARRANTY; without even the implied warranty of MERCHANTABILITY or
** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
** for more details.
**
** You should have received a copy of the GNU General Public License
** along with ATS; see the file COPYING. If not, write to the Free
** Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
** 02110-1301, USA.
*)
(* ****** ****** *)
(*
**
** Various kinds of (generic) arrays
**
** Contributed by Hongwei Xi (hwxi AT cs DOT bu DOT edu)
** Contributed by Shivkumar Chandrasekaran (shiv AT ece DOT ucsb DOT edu)
**
** Start Time: Summer, 2009
**
*)
(* ****** ****** *)
//
// License: LGPL 3.0 (available at http://www.gnu.org/licenses/lgpl.txt)
//
(* ****** ****** *)
%{#
#include "libats/CATS/genarrays.cats"
%} // end of [%{#]
(* ****** ****** *)
sortdef inc = {i: int | i > 0} // for leading dimensions
(* ****** ****** *)
// general vector // elt, size, delta
absviewt@ype GEVEC (a:viewt@ype+, n:int, d:int)
viewdef GEVEC_v
(a:viewt@ype, n:int, d:int, l:addr) = GEVEC (a, n, d) @ l
// end of [GEVEC_v]
(* ****** ****** *)
prfun GEVEC_v_nil
{a:viewt@ype} {d:inc} {l:addr} ():<prf> GEVEC_v (a, 0, d, l)
// end of [GEVEC_v_nil]
prfun GEVEC_v_unnil
{a:viewt@ype} {d:inc} {l:addr} (pf: GEVEC_v (a, 0, d, l)):<prf> void
// end of [GEVEC_v_unnil]
prfun GEVEC_v_cons
{a:viewt@ype}
{n:pos} {d:inc} {l:addr} {ofs:int} (
pf_mul: MUL (d, sizeof a, ofs), pf_at: a @ l, pf_vec: GEVEC_v (a, n-1, d, l+ofs)
) :<prf> GEVEC_v (a, n, d, l) // end of [GEVEC_v_cons]
prfun GEVEC_v_uncons
{a:viewt@ype}
{n:pos} {d:inc} {l:addr} {ofs:int} (
pf_mul: MUL (d, sizeof a, ofs), pf_vec: GEVEC_v (a, n, d, l)
) :<prf> (
a @ l, GEVEC_v (a, n-1, d, l+ofs)
) // end of [GEVEC_v_uncons]
(* ****** ****** *)
prfun array_v_of_GEVEC_v
{a:viewt@ype} {n:nat} {l:addr}
(pf: GEVEC_v (a, n, 1, l)):<prf> array_v (a, n, l)
// end [array_v_of_GEVEC_v]
prfun GEVEC_v_of_array_v
{a:viewt@ype} {n:nat} {l:addr}
(pf: array_v (a, n, l)):<prf> GEVEC_v (a, n, 1, l)
// end [array_v_of_GEVEC_v]
(* ****** ****** *)
fun{a:viewt@ype}
GEVEC_ptr_takeout
{n:nat} {d:inc} {l0:addr} (
pf: GEVEC_v (a, n, d, l0)
| p_vec: ptr l0, d: size_t d, i: sizeLt n
) :<> [l:addr] (
a @ l
, a @ l -<lin,prf> GEVEC_v (a, n, d, l0)
| ptr l
) // end of [GEVEC_ptr_takeout]
(* ****** ****** *)
stadef tszeq
(a1:viewt@ype, a2:viewt@ype) = (sizeof a1 == sizeof a2)
// end of [tszeq]
fun{a1:viewt@ype}
GEVEC_ptr_split
{n,i:nat | i <= n} {d:inc} {l0:addr} (
pf: GEVEC_v (a1, n, d, l0)
| p_vec: ptr l0, d: size_t d, i: size_t i
) :<> [l:addr] (
GEVEC_v (a1, i, d, l0)
, GEVEC_v (a1, n-i, d, l)
, {a2:viewt@ype | a1 \tszeq a2} (
// [fpf: for unsplitting]
GEVEC_v (a2, i, d, l0), GEVEC_v (a2, n-i, d, l)
) -<prf> GEVEC_v (a2, n, d, l0)
| ptr l
) // end of [GEVEC_ptr_split]
(* ****** ****** *)
fun{a:t@ype} GEVEC_ptr_get_elt_at {n:nat}
{d:inc} (V: &GEVEC (a, n, d), d: size_t d, i: sizeLt n):<> a
// end of [GEVEC_ptr_get_elt_at]
fun{a:t@ype}
GEVEC_ptr_set_elt_at {n:nat}
{d:inc} (V: &GEVEC (a, n, d), d: size_t d, i: sizeLt n, x: a):<> void
// end of [GEVEC_ptr_set_elt_at]
(* ****** ****** *)
fun{a:t@ype}
GEVEC_ptr_initialize_elt {m:nat} {d:inc} (
X: &GEVEC (a?, m, d) >> GEVEC (a, m, d), m: size_t m, inc: size_t d, alpha: a
) :<> void // end of [GEVEC_ptr_initialize_elt]
(* ****** ****** *)
fun{a:t@ype}
GEVEC_ptr_copy {m:nat} {d1,d2:inc} (
X1: &GEVEC (a, m, d1), X2: &GEVEC (a?, m, d2) >> GEVEC (a, m, d2)
, m: size_t m, d1: size_t d1, d2: size_t d2
) :<> void // end of [GEVEC_ptr_copy]
(* ****** ****** *)
fun GEVEC_ptr_foreach_funenv_tsz
{a:viewt@ype} {v:view} {vt:viewtype} {n:nat} {d:inc} (
pf: !v
| base: &GEVEC (a, n, d)
, f: (!v | &a, !vt) -<> void, vsz: size_t n, inc: size_t d, tsz: sizeof_t a
, env: !vt
) :<> void
= "atslib_GEVEC_ptr_foreach_funenv_tsz"
// end of [GEVEC_ptr_foreach_funenv_tsz]
fun{a:viewt@ype}
GEVEC_ptr_foreach_fun
{n:nat} {d:inc} (
base: &GEVEC (a, n, d)
, f: (&a) -<fun> void, vsz: size_t n, inc: size_t d
) :<> void // end of [GEVEC_ptr_foreach_fun]
fun{a:viewt@ype}
GEVEC_ptr_foreach_vclo
{v:view} {n:nat} {d:inc} (
pf: !v
| base: &GEVEC (a, n, d)
, f: &(!v | &a) -<clo> void, vsz: size_t n, inc: size_t d
) :<> void // end of [GEVEC_ptr_foreach_vclo]
(* ****** ****** *)
fun GEVEC_ptr_iforeach_funenv_tsz
{a:viewt@ype} {v:view} {vt:viewtype} {n:nat} {d:inc} (
pf: !v
| base: &GEVEC (a, n, d)
, f: (!v | sizeLt n, &a, !vt) -<> void
, vsz: size_t n
, inc: size_t d
, tsz: sizeof_t a
, env: !vt
) :<> void
= "atslib_GEVEC_ptr_iforeach_funenv_tsz"
// end of [GEVEC_ptr_iforeach_funenv_tsz]
fun{a:viewt@ype}
GEVEC_ptr_iforeach_fun
{n:nat} {d:inc} (
base: &GEVEC (a, n, d)
, f: (sizeLt n, &a) -<fun> void, vsz: size_t n, inc: size_t d
) :<> void // end of [fun]
fun GEVEC_ptr_iforeach_cloenv_tsz
{a:viewt@ype} {v:view} {vt:viewtype} {n:nat} {d:inc} (
pf: !v
| base: &GEVEC (a, n, d)
, f: &(!v | sizeLt n, &a, !vt) -<clo> void
, vsz: size_t n
, inc: size_t d
, tsz: sizeof_t a
, env: !vt
) :<> void
= "atslib_GEVEC_ptr_iforeach_cloenv_tsz"
// end of [fun]
fun{a:viewt@ype}
GEVEC_ptr_iforeach_vclo
{v:view} {n:nat} {d:inc} (
pf: !v
| base: &GEVEC (a, n, d)
, f: &(!v | sizeLt n, &a) -<clo> void, vsz: size_t n, inc: size_t d
) :<> void // end of [GEVEC_ptr_iforeach_vclo]
(* ****** ****** *)
datasort order =
| row | col // row major / column major
// end of [order]
datatype ORDER (order) =
| ORDERrow (row) of () | ORDERcol (col) of ()
// end of [ORDER]
(* ****** ****** *)
(*
datasort uplo =
| upper | lower // upper right / lower left
// end of [uplo]
*)
sortdef uplo = int
stadef upper = 1 and lower = 0
datatype UPLO (uplo) =
| UPLOupper (upper) of () | UPLOlower (lower) of ()
// end of [UPLO]
(* ****** ****** *)
datasort diag = unit | nonunit // unit / non-unit
datatype DIAG (diag) = DIAGunit (unit()) | DIAGnonunit (nonunit())
(* ****** ****** *)
datasort transpose = TPN | TPT | TPC
(*
dataprop
transpose_NT (transpose) =
| TRANSPOSE_NT_N (TPN) of ()
| TRANSPOSE_NT_T (TPT) of ()
// end of [transpose_NT]
dataprop
transpose_NC (transpose) =
| TRANSPOSE_NC_N (TPN) of ()
| TRANSPOSE_NC_C (TPC) of ()
// end of [transpose_NC]
*)
datatype
TRANSPOSE (transpose) =
| TRANSPOSE_N (TPN) of ()
| TRANSPOSE_T (TPT) of ()
| TRANSPOSE_C (TPC) of ()
// end of [TRANSPOSE]
(* ****** ****** *)
(*
** capturing the relation between transpose and order
*)
dataprop tranord_p (order, order) =
| TRANORDrowcol (row, col) | TRANORDcolrow (col, row)
// end of [tranord_p]
(*
//
// capturing the relation between transpose and uplo
//
dataprop tranuplo_p (uplo, uplo) =
| TRANUPLOupperlower (upper, lower) | TRANUPLOlowerupper (lower, upper)
// end of [transuplo_p]
*)
(* ****** ****** *)
(*
** capturing the relation between transpose and dimensions
*)
dataprop trandim_p (
transpose
, int // row
, int // col
, int // new row
, int // new col
) =
| {m,n:nat} TRANDIM_N (TPN, m, n, m, n) of ()
| {m,n:nat} TRANDIM_T (TPT, m, n, n, m) of ()
| {m,n:nat} TRANDIM_C (TPC, m, n, n, m) of ()
(*
| {m,n:nat} TRANDIM_AC (AC, m, n, m, n) of ()
*)
// end of [trandim_p]
(* ****** ****** *)
datasort side = left | right
datatype SIDE (side) = SIDEleft (left) | SIDEright (right)
(* ****** ****** *)
(*
** capturing the relation between side and row/col
*)
dataprop sidedim_p (
side, int(*row*), int(*col*), int(*row/col*)
) =
| {m,n:nat} SIDEDIM_L (left, m, n, m)
| {m,n:nat} SIDEDIM_R (right, m, n, n)
// end of [sidedim_p]
(* ****** ****** *)
//
// GEneral MATrix representation
//
// elt, row, col, ord, ld
absviewt@ype GEMAT
(a:viewt@ype+, m:int, n:int, ord:order, ld:int)
// end of [GEMAT]
viewdef GEMAT_v
(a:viewt@ype, m:int, n:int, ord: order, ld:int, l:addr) =
GEMAT (a, m, n, ord, ld) @ l
// end of [GEMAT_v]
(* ****** ****** *)
prfun GEMAT_v_trans // HX: yes, [ld:int] is fine
{a:viewt@ype} {ord1:order} {m,n:nat} {ld:int} {l:addr} (
pf_mat: !GEMAT_v (a, m, n, ord1, ld, l) >> GEMAT_v (a, n, m, ord2, ld, l)
) :<> #[ord2:order] tranord_p (ord1, ord2)
// end of [GEMAT_v_trans]
(* ****** ****** *)
dataprop
MATVECINC (order, order, int, int) =
| {ld:inc} MATVECINCrowrow (row, row, ld, 1)
| {ld:inc} MATVECINCrowcol (row, col, ld, ld)
| {ld:inc} MATVECINCcolrow (col, row, ld, ld)
| {ld:inc} MATVECINCcolcol (col, col, ld, 1)
// end of [MATVECINC]
// implemented in [genarrays.dats]
fun MATVECINC_get
{ord1,ord2:order} {ld:int} {d:inc} (
pf: MATVECINC (ord1, ord2, ld, d)
| x1: ORDER ord1, x2: ORDER ord2, ld: size_t ld
) :<> size_t d
// end of [MATVECINC_get]
(* ****** ****** *)
prfun GEMAT_v_nil_row {a:viewt@ype}
{ord:order} {n:nat} {ld:inc} {l:addr} () :<prf> GEMAT_v (a, 0, n, ord, ld, l)
// end of [GEMAT_v_nil_row]
prfun GEMAT_v_unnil_row {a:viewt@ype}
{ord:order} {n:nat} {ld:inc} {l:addr}
(pf: GEMAT_v (a, 0, n, ord, ld, l)):<prf> void
// end of [GEMAT_v_unnil_row]
prfun GEMAT_v_nil_col {a:viewt@ype}
{ord:order} {m:nat} {ld:inc} {l:addr} () :<prf> GEMAT_v (a, m, 0, ord, ld, l)
// end of [GEMAT_v_nil_col]
prfun GEMAT_v_unnil_col {a:viewt@ype}
{ord:order} {m:nat} {ld:inc} {l:addr}
(pf: GEMAT_v (a, m, 0, ord, ld, l)):<prf> void
// end of [GEMAT_v_unnil_col]
(* ****** ****** *)
prfun GEMAT_v_uncons_row {a:viewt@ype}
{ord:order} {m:pos;n:nat} {ld:inc} {l:addr}
(pf: GEMAT_v (a, m, n, ord, ld, l))
:<prf> [d:inc] (
MATVECINC (row, ord, ld, d)
, GEVEC_v (a, n, d, l)
, GEVEC_v (a, n, d, l) -<lin,prf> GEMAT_v (a, m, n, ord, ld, l)
)
// end of [GEMAT_uncons_row]
prfun GEMAT_v_uncons_col {a:viewt@ype}
{ord:order} {m:nat;n:pos} {ld:inc} {l:addr}
(pf: GEMAT_v (a, m, n, ord, ld, l))
:<prf> [d:inc] (
MATVECINC (col, ord, ld, d)
, GEVEC_v (a, m, d, l)
, GEVEC_v (a, m, d, l) -<lin,prf> GEMAT_v (a, m, n, ord, ld, l)
)
// end of [GEMAT_v_uncons_col]
(* ****** ****** *)
prfun GEVEC_v_of_GEMAT_v_row
{a1:viewt@ype}
{ord:order} {n:nat} {ld:inc}
{l:addr} (
pf: GEMAT_v (a1, 1, n, ord, ld, l)
) :<> [d:inc] (
MATVECINC (row, ord, ld, d)
, GEVEC_v (a1, n, d, l)
, {a2:viewt@ype | a1 \tszeq a2}
// [fpf: for unsplitting]
GEVEC_v (a2, n, d, l) -<prf> GEMAT_v (a2, 1, n, ord, ld, l)
) // end of [GEVEC_v_of_GEMAT_v_row]
prfun GEVEC_v_of_GEMAT_v_col
{a1:viewt@ype}
{ord:order} {m:nat} {ld:inc}
{l:addr} (
pf: GEMAT_v (a1, m, 1, ord, ld, l)
) :<> [d:inc] (
MATVECINC (col, ord, ld, d)
, GEVEC_v (a1, m, d, l)
, {a2:viewt@ype | a1 \tszeq a2}
// [fpf: for unsplitting]
GEVEC_v (a2, m, d, l) -<prf> GEMAT_v (a2, m, 1, ord, ld, l)
) // end of [GEVEC_v_of_GEMAT_v_col]
(* ****** ****** *)
fun{a:viewt@ype}
GEMAT_ptr_takeout
{ord:order}
{m,n:nat} {ld:inc} {l0:addr} (
pf_mat: GEMAT_v (a, m, n, ord, ld, l0)
| ord: ORDER ord
, p_mat: ptr l0
, ld: size_t ld, i: sizeLt m, j: sizeLt n
) :<> [l:addr] (
a @ l
, a @ l -<lin,prf> GEMAT_v (a, m, n, ord, ld, l0)
| ptr l
) // end of [GEMAT_ptr_takeout]
(* ****** ****** *)
fun{a:t@ype}
GEMAT_ptr_get_elt_at
{ord:order} {m,n:nat} {ld:inc} (
ord: ORDER ord
, A: &GEMAT (a, m, n, ord, ld)
, ld: size_t ld, i: sizeLt m, j: sizeLt n
) :<> a // end of [GEMAT_ptr_get_elt_at]
fun{a:t@ype}
GEMAT_ptr_set_elt_at
{ord:order} {m,n:nat} {ld:inc} (
ord: ORDER ord
, A: &GEMAT (a, m, n, ord, ld)
, ld: size_t ld, i: sizeLt m, j: sizeLt n
, x: a
) :<> void // end of [GEMAT_ptr_set_elt_at]
(* ****** ****** *)
(*
** HX: this is likely to be slightly more efficient
** than GEMAT_ptr_split2x1
*)
fun{a:viewt@ype}
GEMAT_ptr_tail_row
{ord:order}
{m:pos;n:nat}
{ld:inc}
{l0:addr} (
pf_mat: GEMAT_v (a, m, n, ord, ld, l0)
| ord: ORDER ord
, p_mat: ptr l0
, ld: size_t ld
) :<> [l:addr] (
GEMAT_v (a, m-1, n, ord, ld, l)
, GEMAT_v (a, m-1, n, ord, ld, l) -<lin,prf> GEMAT_v (a, m, n, ord, ld, l0)
| ptr l
) // end of [GEMAT_ptr_tail_row]
(*
** HX: this is likely to be slightly more efficient than GEMAT_ptr_split1x2
*)
fun{a:viewt@ype}
GEMAT_ptr_tail_col
{ord:order} {m:nat;n:pos} {ld:inc} {l0:addr} (
pf_mat: GEMAT_v (a, m, n, ord, ld, l0)
| ord: ORDER ord
, p_mat: ptr l0
, ld: size_t ld
) :<> [l:addr] (
GEMAT_v (a, m, n-1, ord, ld, l)
, GEMAT_v (a, m, n-1, ord, ld, l) -<lin,prf> GEMAT_v (a, m, n, ord, ld, l0)
| ptr l
) // end of [GEMAT_ptr_tail_col]
(* ****** ****** *)
viewtypedef
GEMAT_ptr_split1x2_res_t (
a1:viewt@ype, m:int, n:int, j:int, ord:order, ld:int, l0:addr
) = [l1,l2:addr] @(
GEMAT_v (a1, m, j, ord, ld, l1)
, GEMAT_v (a1, m, n-j, ord, ld, l2)
, {a2:viewt@ype | a1 \tszeq a2} (
// [fpf: for unsplitting]
GEMAT_v (a2, m, j, ord, ld, l1), GEMAT_v (a2, m, n-j, ord, ld, l2)
) -<prf>
GEMAT_v (a2, m, n, ord, ld, l0)
| ptr l1 // l1 should equal l0
, ptr l2
) // end of [GEMAT_ptr_split1x2_res_t]
fun{a1:viewt@ype}
GEMAT_ptr_split1x2
{ord:order}
{m,n,j:nat | j <= n}
{ld:inc}
{l0:addr} (
pf_mat: GEMAT_v (a1, m, n, ord, ld, l0)
| ord: ORDER ord, p_mat: ptr l0, ld: size_t ld, j: size_t j
) :<> GEMAT_ptr_split1x2_res_t (a1, m, n, j, ord, ld, l0)
// end of [GEMAT_ptr_split1x2]
(* ****** ****** *)
viewtypedef
GEMAT_ptr_split2x1_res_t (
a1:viewt@ype, m:int, n:int, i:int, ord:order, ld:int, l0:addr
) = [l1,l2:addr] @(
GEMAT_v (a1, i, n, ord, ld, l1)
, GEMAT_v (a1, m-i, n, ord, ld, l2)
, {a2:viewt@ype | a1 \tszeq a2} (
// [fpf: for unsplitting]
GEMAT_v (a2, i, n, ord, ld, l1)
, GEMAT_v (a2, m-i, n, ord, ld, l2)
) -<prf>
GEMAT_v (a2, m, n, ord, ld, l0)
| ptr l1 // l1 should equal l0
, ptr l2
) // end of [GEMAT_ptr_split2x1_res_t]
fun{a1:viewt@ype}
GEMAT_ptr_split2x1
{ord:order}
{m,n,i:nat | i <= m}
{ld:inc}
{l0:addr} (
pf_mat: GEMAT_v (a1, m, n, ord, ld, l0)
| ord: ORDER ord, p_mat: ptr l0, ld: size_t ld, i: size_t i
) :<> GEMAT_ptr_split2x1_res_t (a1, m, n, i, ord, ld, l0)
// end of [GEMAT_ptr_split2x1]
(* ****** ****** *)
viewtypedef
GEMAT_ptr_split2x2_res_t (
a1:viewt@ype, m:int, n:int, i:int, j:int, ord:order, ld:int, l0:addr
) = [l11,l12,l21,l22:addr] @(
GEMAT_v (a1, i, j, ord, ld, l11)
, GEMAT_v (a1, i, n-j, ord, ld, l12)
, GEMAT_v (a1, m-i, j, ord, ld, l21)
, GEMAT_v (a1, m-i, n-j, ord, ld, l22)
, {a2:viewt@ype | a1 \tszeq a2} (
// [fpf: for unsplitting]
GEMAT_v (a2, i, j, ord, ld, l11)
, GEMAT_v (a2, i, n-j, ord, ld, l12)
, GEMAT_v (a2, m-i, j, ord, ld, l21)
, GEMAT_v (a2, m-i, n-j, ord, ld, l22)
) -<prf>
GEMAT_v (a2, m, n, ord, ld, l0)
| ptr l11 // l11 should equal l0
, ptr l12
, ptr l21
, ptr l22
) // end of [GEMAT_ptr_split2x2_res_t]
fun{a1:viewt@ype}
GEMAT_ptr_split2x2
{ord:order}
{m,n,i,j:nat | i <= m; j <= n}
{ld:inc}
{l0:addr} (
pf_mat: GEMAT_v (a1, m, n, ord, ld, l0)
| ord: ORDER ord, p_mat: ptr l0, ld: size_t ld, i: size_t i, j: size_t j
) :<> GEMAT_ptr_split2x2_res_t (a1, m, n, i, j, ord, ld, l0)
// end of [GEMAT_ptr_split2x2]
(* ****** ****** *)
fun{a:t@ype}
GEMAT_row_ptr_allocfree
{m,n:nat} (m: size_t m, n: size_t n)
: [l:addr] (
GEMAT (a?, m, n, row, n) @ l
| ptr l
, (GEMAT (a?, m, n, row, n) @ l | ptr l) -<lin> void
) // end of [GEMAT_row_ptr_allocfree]
fun{a:t@ype}
GEMAT_col_ptr_allocfree
{m,n:nat} (m: size_t m, n: size_t n)
: [l:addr] (
GEMAT (a?, m, n, col, m) @ l
| ptr l
, (GEMAT (a?, m, n, col, m) @ l | ptr l) -<lin> void
) // end of [GEMAT_col_ptr_allocfree]
(* ****** ****** *)
fun{a:t@ype}
GEMAT_ptr_initialize_elt
{ord:order} {m,n:nat} {ld:inc} (
ord: ORDER ord
, X: &GEMAT (a?, m, n, ord, ld) >> GEMAT (a, m, n, ord, ld)
, m: size_t m, n: size_t n, ld: size_t ld
, alpha: a
) :<> void // end of [GEMAT_ptr_initialize_elt]
//
// HX: based on [GEMAT_ptr_iforeach_fun]
//
fun{a:t@ype}
GEMAT_ptr_initialize_fun
{ord:order} {m,n:nat} {ld:inc} (
ord: ORDER ord
, M: &GEMAT (a?, m, n, ord, ld) >> GEMAT (a, m, n, ord, ld)
, m: size_t m, n: size_t n, ld: size_t ld
, f: (sizeLt m, sizeLt n, &(a?) >> a) -<> void
) :<> void // end of [GEMAT_ptr_initialize_fun]
//
// HX: based on [GEMAT_ptr_iforeach_vclo]
//
fun{a:t@ype}
GEMAT_ptr_initialize_vclo
{v:view} {ord:order} {m,n:nat} {ld:inc} (
pf: !v
| ord: ORDER ord
, M: &GEMAT (a?, m, n, ord, ld) >> GEMAT (a, m, n, ord, ld)
, m: size_t m, n: size_t n, ld: size_t ld
, f: &(!v | sizeLt m, sizeLt n, &(a?) >> a) -<clo> void
) :<> void // end of [GEMAT_ptr_initialize_vclo]
(* ****** ****** *)
(*
** M2 <- M1
*)
fun{a:t@ype} GEMAT_ptr_copy
{ord:order} {m,n:nat} {ld1,ld2:inc} (
ord: ORDER ord
, M1: &GEMAT (a, m, n, ord, ld1)
, M2: &GEMAT (a?, m, n, ord, ld2) >> GEMAT (a, m, n, ord, ld2)
, m: size_t m, n: size_t n, ld1: size_t ld1, ld2: size_t ld2
) :<> void // end of [GEMAT_ptr_copy]
fun GEMAT_ptr_copy_tsz {a:t@ype}
{ord:order} {m,n:nat} {ld1,ld2:inc} (
ord: ORDER ord
, M1: &GEMAT (a, m, n, ord, ld1)
, M2: &GEMAT (a?, m, n, ord, ld2) >> GEMAT (a, m, n, ord, ld2)
, m: size_t m, n: size_t n, ld1: size_t ld1, ld2: size_t ld2, tsz: sizeof_t a
) :<> void // end of [GEMAT_ptr_copy_tsz]
(* ****** ****** *)
fun GEMAT_ptr_foreach_funenv_tsz
{a:viewt@ype} {v:view} {vt:viewtype}
{ord1,ord2:order} {m,n:nat} {ld:inc} (
pf: !v
| ord1: ORDER ord1
, M: &GEMAT (a, m, n, ord1, ld)
, f: (!v | &a, !vt) -<fun> void
, ord2: ORDER ord2
, m: size_t m, n: size_t n, ld: size_t ld
, tsz: sizeof_t a
, env: !vt
) :<> void // end of [GEMAT_ptr_foreach_funenv_tsz]
fun{a:viewt@ype}
GEMAT_ptr_foreach_fun
{ord1,ord2:order} {m,n:nat} {ld:inc} (
ord1: ORDER ord1
, M: &GEMAT (a, m, n, ord1, ld)
, f: (&a) -<fun> void
, ord2: ORDER ord2
, m: size_t m, n: size_t n, ld: size_t ld
) :<> void // end of [GEMAT_ptr_foreach_fun]
fun{a:viewt@ype}
GEMAT_ptr_foreach_vclo
{v:view} {ord1,ord2:order} {m,n:nat} {ld:inc} (
pf: !v
| ord1: ORDER ord1
, M: &GEMAT (a, m, n, ord1, ld)
, f: &(!v | &a) -<clo> void
, ord2: ORDER ord2
, m: size_t m, n: size_t n, ld: size_t ld
) :<> void // end of [GEMAT_ptr_foreach_vclo]
(* ****** ****** *)
fun GEMAT_ptr_iforeach_funenv_tsz
{a:viewt@ype} {v:view} {vt:viewtype}
{ord1,ord2:order} {m,n:nat} {ld:inc} (
pf: !v
| ord1: ORDER ord1
, M: &GEMAT (a, m, n, ord1, ld)
, f: (!v | sizeLt m, sizeLt n, &a, !vt) -<fun> void
, ord2: ORDER ord2
, m: size_t m, n: size_t n, ld: size_t ld
, tsz: sizeof_t a
, env: !vt
) :<> void // end of [GEMAT_ptr_iforeach_funenv_tsz]
fun{a:viewt@ype}
GEMAT_ptr_iforeach_fun
{ord1,ord2:order} {m,n:nat} {ld:inc} (
ord1: ORDER ord1
, M: &GEMAT (a, m, n, ord1, ld)
, f: (sizeLt m, sizeLt n, &a) -<fun> void
, ord2: ORDER ord2
, m: size_t m, n: size_t n, ld: size_t ld
) :<> void // end of [GEMAT_ptr_iforeach_fun]
fun{a:viewt@ype}
GEMAT_ptr_iforeach_vclo
{v:view} {ord1,ord2:order} {m,n:nat} {ld:inc} (
pf: !v
| ord1: ORDER ord1
, M: &GEMAT (a, m, n, ord1, ld)
, f: &(!v | sizeLt m, sizeLt n, &a) -<clo> void
, ord2: ORDER ord2
, m: size_t m, n: size_t n, ld: size_t ld
) :<> void // end of [GEMAT_ptr_iforeach_vclo]
(* ****** ****** *)
dataprop realtyp_p (a:t@ype) =
| REALTYPfloat (float) of () | REALTYPdouble (double) of ()
// end of [TYPE_IS_REAL]
(* ****** ****** *)
//
// TRiangular MATrix representation (part of GEMAT)
//
// elt, row/col, ord, ul
absviewt@ype TRMAT // dimension: n x n
(a:viewt@ype+, n:int, ord: order, ul: uplo, dg: diag, ld: int)
// end of [TRMAT]
viewdef TRMAT_v
(a:viewt@ype, n:int, ord: order, ul: uplo, dg: diag, ld: int, l:addr) =
TRMAT (a, n, ord, ul, dg, ld) @ l
// end of [TRMAT_v]
(* ****** ****** *)
prfun TRMAT_v_nil {a:viewt@ype} {ord:order}
{ul:uplo} {dg:diag} {ld:inc} {l:addr} ():<prf> TRMAT_v (a, 0, ord, ul, dg, ld, l)
// end of [TRMAT_v_nil]
prfun TRMAT_v_unnil {a:viewt@ype}
{ord:order} {ul:uplo} {dg:diag} {ld:inc} {l:addr}
(pf: TRMAT_v (a, 0, ord, ul, dg, ld, l)):<prf> void
// end of [TRMAT_v_unnil]
(* ****** ****** *)
prfun TRMAT1x1_v_takeout_unit
{a1:viewt@ype}
{ord:order} {ul:uplo} {ld:inc} {l:addr} (
pf: TRMAT_v (a1, 1, ord, ul, unit(), ld, l)
) : (
{a2:viewt@ype | a1 \tszeq a2} () -<prf> TRMAT_v (a2, 1, ord, ul, unit(), ld, l)
) // end of [TRMAT1x1_v_takeout_unit]
prfun TRMAT1x1_v_takeout_nonunit
{a1:viewt@ype}
{ord:order} {ul:uplo} {ld:inc} {l:addr} (
pf: TRMAT_v (a1, 1, ord, ul, nonunit(), ld, l)
) : (
a1 @ l
, {a2:viewt@ype | a1 \tszeq a2} a2 @ l -<prf> TRMAT_v (a2, 1, ord, ul, nonunit(), ld, l)
) // end of [TRMAT1x1_v_takeout_nonunit]
(* ****** ****** *)
prfun TRMAT_v_trans {a:viewt@ype}
{ord1:order} {ul:uplo} {dg:diag} {m:nat} {ld:inc} {l:addr} (
pf_mat: !TRMAT_v (a, m, ord1, ul, dg, ld, l) >> TRMAT_v (a, m, ord2, 1-ul, dg, ld, l)
) :<> #[ord2:order] tranord_p (ord1, ord2)
// end of [TRMAT_v_trans]
prfun TRMAT_v_of_GEMAT_v {a:viewt@ype}
{ord:order} {ul:uplo} {dg:diag} {n:nat} {ld:inc} {l:addr} (
pf: GEMAT_v (a, n, n, ord, ld, l), ul: UPLO ul, dg: DIAG dg
) :<> (
TRMAT_v (a, n, ord, ul, dg, ld, l)
, TRMAT_v (a, n, ord, ul, dg, ld, l) -<lin,prf> GEMAT_v (a, n, n, ord, ld, l)
) // end of [TRMAT_v_of_GEMAT_v]
(* ****** ****** *)
// UN: upper non-unit
fun{a:t@ype} TRMAT_UN_ptr_get_elt_at
{ord:order} {m,i,j:nat | i <= j; j < m} {ld:inc} (
ord: ORDER ord
, A: &TRMAT (a, m, ord, upper, nonunit(), ld)
, ld: size_t ld, i: size_t i, j: size_t j
) :<> a // end of [TRMAT_UN_ptr_get_elt_at]
fun{a:t@ype} TRMAT_UN_ptr_set_elt_at
{ord:order} {m,i,j:nat | i <= j; j < m} {ld:inc} (
ord: ORDER ord
, A: &TRMAT (a, m, ord, upper, nonunit(), ld)
, ld: size_t ld, i: size_t i, j: size_t j
, x: a
) :<> void // end of [TRMAT_UN_ptr_set_elt_at]
(* ****** ****** *)
// UU: upper unit
fun{a:t@ype} TRMAT_UU_ptr_get_elt_at
{ord:order} {m,i,j:nat | i < j; j < m} {ld:inc} (
ord: ORDER ord
, A: &TRMAT (a, m, ord, upper, unit(), ld)
, ld: size_t ld, i: size_t i, j: size_t j
) :<> a // end of [TRMAT_UU_ptr_get_elt_at]
fun{a:t@ype} TRMAT_UU_ptr_set_elt_at
{ord:order} {m,i,j:nat | i < j; j < m} {ld:inc} (
ord: ORDER ord
, A: &TRMAT (a, m, ord, upper, unit(), ld)
, ld: size_t ld, i: size_t i, j: size_t j
, x: a
) :<> void // end of [TRMAT_UU_ptr_set_elt_at]
(* ****** ****** *)
// LN: lower non-unit
fun{a:t@ype} TRMAT_LN_ptr_get_elt_at
{ord:order} {m,i,j:nat | j <= i; i < m} {ld:inc} (
ord: ORDER ord
, A: &TRMAT (a, m, ord, lower, nonunit(), ld)
, ld: size_t ld, i: size_t i, j: size_t j
) :<> a // end of [TRMAT_LN_ptr_get_elt_at]
fun{a:t@ype} TRMAT_LN_ptr_set_elt_at
{ord:order} {m,i,j:nat | j <= i; i < m} {ld:inc} (
ord: ORDER ord
, A: &TRMAT (a, m, ord, lower, nonunit(), ld)
, ld: size_t ld, i: size_t i, j: size_t j
, x: a
) :<> void // end of [TRMAT_LN_ptr_set_elt_at]
(* ****** ****** *)
// LU: lower unit
fun{a:t@ype} TRMAT_LU_ptr_get_elt_at
{ord:order} {m,i,j:nat | j < i; i < m} {ld:inc} (
ord: ORDER ord
, A: &TRMAT (a, m, ord, lower, unit(), ld)
, ld: size_t ld, i: size_t i, j: size_t j
) :<> a // end of [TRMAT_LU_ptr_get_elt_at]
fun{a:t@ype} TRMAT_LU_ptr_set_elt_at
{ord:order} {m,i,j:nat | j < i; i < m} {ld:inc} (
ord: ORDER ord
, A: &TRMAT (a, m, ord, lower, unit(), ld)
, ld: size_t ld, i: size_t i, j: size_t j
, x: a
) :<> void // end of [TRMAT_LU_ptr_set_elt_at]
(* ****** ****** *)
viewtypedef TRMAT_U_ptr_split2x2_res_t (
a1:viewt@ype, m:int, i:int, ord:order, dg:diag, ld:int, l0:addr
) = [lu,lo,ll:addr] @(
TRMAT_v (a1, i, ord, upper, dg, ld, lu)
, GEMAT_v (a1, i, m-i, ord, ld, lo)
, TRMAT_v (a1, m-i, ord, upper, dg, ld, ll)
, {a2:viewt@ype | a1 \tszeq a2} (
// [fpf: for unsplitting]
TRMAT_v (a2, i, ord, upper, dg, ld, lu)
, GEMAT_v (a2, i, m-i, ord, ld, lo)
, TRMAT_v (a2, m-i, ord, upper, dg, ld, ll)
) -<prf>
TRMAT_v (a2, m, ord, upper, dg, ld, l0)
| ptr lu // l11 should equal l0
, ptr lo
, ptr ll
) // end of [TRMAT_U_ptr_split2x2_res_t]
fun{a1:viewt@ype}
TRMAT_U_ptr_split2x2
{ord:order} {dg:diag}
{m,i:nat | i <= m} {ld:inc} {l0:addr} (
pf_mat: TRMAT_v (a1, m, ord, upper, dg, ld, l0)
| ord: ORDER ord, A: ptr l0, ld: size_t ld, i: size_t i
) :<> TRMAT_U_ptr_split2x2_res_t (a1, m, i, ord, dg, ld, l0)
// end of [TRMAT_U_ptr_split2x2]
viewtypedef
TRMAT_L_ptr_split2x2_res_t (
a1:viewt@ype, m:int, i:int, ord:order, dg:diag, ld:int, l0:addr
) = [lu,lo,ll:addr] @(
TRMAT_v (a1, i, ord, lower, dg, ld, lu)
, GEMAT_v (a1, m-i, i, ord, ld, lo)
, TRMAT_v (a1, m-i, ord, lower, dg, ld, ll)
, {a2:viewt@ype | a1 \tszeq a2} (
// [fpf: for unsplitting]
TRMAT_v (a2, i, ord, lower, dg, ld, lu)
, GEMAT_v (a2, m-i, i, ord, ld, lo)
, TRMAT_v (a2, m-i, ord, lower, dg, ld, ll)
) -<prf>
TRMAT_v (a2, m, ord, lower, dg, ld, l0)
| ptr lu // l11 should equal l0
, ptr lo
, ptr ll
) // end of [TRMAT_L_ptr_split2x2_res_t]
fun{a1:viewt@ype}
TRMAT_L_ptr_split2x2
{ord:order} {dg:diag}
{m,i:nat | i <= m} {ld:inc} {l0:addr} (
pf_mat: TRMAT_v (a1, m, ord, lower, dg, ld, l0)
| ord: ORDER ord, A: ptr l0, ld: size_t ld, i: size_t i
) :<> TRMAT_L_ptr_split2x2_res_t (a1, m, i, ord, dg, ld, l0)
// end of [TRMAT_L_ptr_split2x2]
(* ****** ****** *)
(*
** M2 <- M1
*)
fun{a:t@ype} TRMAT_ptr_copy
{ord:order} {ul:uplo} {dg:diag} {m:nat} {ld1,ld2:inc} (
ord: ORDER ord, ul: UPLO ul, dg: DIAG dg
, M1: &TRMAT (a, m, ord, ul, dg, ld1)
, M2: &TRMAT (a?, m, ord, ul, dg, ld2) >> TRMAT (a, m, ord, ul, dg, ld2)
, m: size_t m, ld1: size_t ld1, ld2: size_t ld2
) :<> void // end of [TRMAT_ptr_copy]
(* ****** ****** *)
//
// SYmmetric MATrix representation (part of GEMAT)
//
// elt, row/col, ord, ul
absviewt@ype SYMAT // dimension: n x n
(a:viewt@ype+, n:int, ord: order, ul: uplo, ld: int)
// end of [SYMAT]
viewdef SYMAT_v
(a:viewt@ype, n:int, ord: order, ul: uplo, ld: int, l:addr) =
SYMAT (a, n, ord, ul, ld) @ l
// end of [SYMAT_v]
prfun SYMAT_v_of_GEMAT_v
{a:viewt@ype} {n:nat}
{ord:order} {ul:uplo} {ld:inc} {l:addr} (
pf: GEMAT_v (a, n, n, ord, ld, l), ul: UPLO ul
) :<> (
SYMAT_v (a, n, ord, ul, ld, l)
, SYMAT_v (a, n, ord, ul, ld, l) -<lin,prf> GEMAT_v (a, n, n, ord, ld, l)
) // end of [SYMAT_v_of_GEMAT_v]
(* ****** ****** *)
//
// HErmitian matrix representation (* part of GEMAT *)
//
// elt, row/col, ord, ul
absviewt@ype HEMAT // dimension: n x n
(a:viewt@ype+, n:int, ord: order, ul: uplo, ld: int)
// end of [HEMAT]
viewdef HEMAT_v
(a:viewt@ype, n:int, ord: order, ul: uplo, ld: int, l:addr) =
HEMAT (a, n, ord, ul, ld) @ l
// end of [HEMAT_v]
prfun HEMAT_v_of_SYMAT_v
{a:t@ype} {n:nat}
{ord:order} {ul:uplo} {ld:inc} {l:addr} (
pf_typ: realtyp_p (a), pf_mat: SYMAT_v (a, n, ord, ul, ld, l)
) :<> HEMAT_v (a, n, ord, ul, ld, l)
// end of [HEMAT_v_of_SYMAT_v]
prfun SYMAT_v_of_HEMAT_v
{a:t@ype} {n:nat}
{ord:order} {ul:uplo} {ld:inc} {l:addr} (
pf_typ: realtyp_p (a), pf_mat: HEMAT_v (a, n, ord, ul, ld, l)
) :<> SYMAT_v (a, n, ord, ul, ld, l)
// end of [SYMAT_v_of_HEMAT_v]
prfun HEMAT_v_of_GEMAT_v
{a:viewt@ype} {n:nat}
{ord:order} {ul:uplo} {ld:inc} {l:addr} (
pf: GEMAT_v (a, n, n, ord, ld, l), ul: UPLO ul
) :<> (
HEMAT_v (a, n, ord, ul, ld, l)
, HEMAT_v (a, n, ord, ul, ld, l) -<lin,prf> GEMAT_v (a, n, n, ord, ld, l)
) // end of [HEMAT_v_of_GEMAT_v]
(* ****** ****** *)
//
// General Band MATrix representation
//
// elt, row, col, ord, lower-bandwidth, upper-bandwidth
absviewt@ype GBMAT // dimension: m x n, lower-bandwidth: kl, upper-bandwidth: ku
(a:viewt@ype+, m:int, n:int, ord: order, kl: int, ku: int, ld: int)
// end of [GBMAT]
viewdef GBMAT_v
(a:viewt@ype, m:int, n:int, ord: order, kl: int, ku: int, ld: int, l: addr) =
GBMAT (a, m, n, ord, kl, ku, ld) @ l
// end of [GBMAT_v]
(* ****** ****** *)
//
// Triangular Band MATrix representation
//
// elt, row/col, ord, ul, diag, bandwidth
absviewt@ype TBMAT // dimension: n x n, bandwidth: k
(a:viewt@ype+, n:int, ord: order, ul: uplo, dg: diag, k: int, ld: int)
// end of [TBMAT]
viewdef TBMAT_v
(a:viewt@ype, n:int, ord: order, ul: uplo, dg: diag, k: int, ld: int, l: addr) =
TBMAT (a, n, ord, ul, dg, k, ld) @ l
prfun TBMAT_v_of_GEMAT_v
{a:viewt@ype} {n,k:nat}
{ul:uplo} {dg:diag} {l:addr} (
pf_gmat: GEMAT_v (a, 1+k, n, col, 1+k, l)
, ul: UPLO ul
, dg: DIAG dg
, k: size_t k
) :<prf> (
TBMAT_v (a, n, col, ul, dg, k, 1+k, l)
, TBMAT_v (a, n, col, ul, dg, k, 1+k, l) -<prf> GEMAT_v (a, 1+k, n, col, 1+k, l)
) // end of [TBMAT_v_of_GEMAT_v]
(* ****** ****** *)
//
// Triangular Packed MATrix representation
//
// elt, row/col, ord, ul, diag
absviewt@ype TPMAT // dimension: n x n
(a:viewt@ype+, n:int, ord: order, ul: uplo, dg: diag)
// end of [TPMAT]
viewdef TPMAT_v
(a:viewt@ype, n:int, ord: order, ul: uplo, dg: diag, l: addr) =
TPMAT (a, n, ord, ul, dg) @ l
// end of [TPMAT_v]
prfun TPMAT_v_of_GEVEC_v {a:viewt@ype}
{ord:order} {ul:uplo} {dg:diag} {m,n:nat} {l:addr} (
pf_mul: MUL (n, n+1, m+m)
, pf_vec: GEVEC_v (a, m, 1, l)
, ord: ORDER (ord)
, ul: UPLO (ul), dg: DIAG (dg)
) :<> (
TPMAT_v (a, n, ord, ul, dg, l)
, TPMAT_v (a, n, ord, ul, dg, l) -<prf> GEVEC_v (a, m, 1, l)
) // end of [TPMAT_v_of_GEVEC_v]
(* ****** ****** *)
//
// Symmetric Band MATrix representation
//
// elt, row/col, ord, ul, band-width
absviewt@ype SBMAT // dimension: n x n
(a:viewt@ype+, n:int, ord: order, ul: uplo, k:int, ld:int)
// end of [SBMAT]
viewdef SBMAT_v
(a:viewt@ype, n:int, ord: order, ul: uplo, k:int, ld:int, l: addr) =
SBMAT (a, n, ord, ul, k, ld) @ l
// end of [SBMAT_v]
(* ****** ****** *)
//
// Symmetric Packed MATrix representation
//
// elt, row/col, ord, ul, diag
absviewt@ype SPMAT // dimension: n x n
(a:viewt@ype+, n:int, ord: order, ul: uplo)
// end of [SPMAT]
viewdef SPMAT_v
(a:viewt@ype, n:int, ord: order, ul: uplo, l: addr) =
SPMAT (a, n, ord, ul) @ l
// end of [SPMAT_v]
prfun SPMAT_v_of_GEVEC_v {a:viewt@ype}
{ord:order} {ul:uplo} {m,n:nat} {l:addr} (
pf_mul: MUL (n, n+1, m+m)
, pf_arr: GEVEC_v (a, m, 1, l)
, ord: ORDER (ord), ul: UPLO (ul)
) :<> (
SPMAT_v (a, n, ord, ul, l)
, SPMAT_v (a, n, ord, ul, l) -<prf> GEVEC_v (a, m, 1, l)
) // end of [HPMAT_v_of_GEVEC_v]
(* ****** ****** *)
//
// Hermitian Band MATrix representation
//
// elt, row/col, ord, ul, band-width
absviewt@ype HBMAT // dimension: n x n
(a:viewt@ype+, n:int, ord: order, ul: uplo, k:int, ld:int)
// end of [HBMAT]
viewdef HBMAT_v
(a:viewt@ype, n:int, ord: order, ul: uplo, k:int, ld:int, l: addr) =
HBMAT (a, n, ord, ul, k, ld) @ l
// end of [HBMAT_v]
prfun HBMAT_v_of_SBMAT_v {a:t@ype}
{ord:order} {ul:uplo} {n:nat} {k:int} {ld:int} {l:addr} (
pf_typ: realtyp_p (a), pf_mat: SBMAT_v (a, n, ord, ul, k, ld, l)
) :<> HBMAT_v (a, n, ord, ul, k, ld, l)
// end of [HBMAT_v_of_SBMAT_v]
prfun SBMAT_v_of_HBMAT_v {a:t@ype}
{ord:order} {ul:uplo} {n:nat} {k:int} {ld:int} {l:addr} (
pf_typ: realtyp_p (a), pf_mat: HBMAT_v (a, n, ord, ul, k, ld, l)
) :<> SBMAT_v (a, n, ord, ul, k, ld, l)
// end of [SBMAT_v_of_HBMAT_v]
(* ****** ****** *)
//
// Hermitian Packed MATrix representation
//
// elt, row/col, ord, ul, diag
absviewt@ype HPMAT // dimension: n x n
(a:viewt@ype+, n:int, ord:order, ul:uplo)
// end of [HPMAT]
viewdef HPMAT_v
(a:viewt@ype, n:int, ord:order, ul:uplo, l:addr) =
HPMAT (a, n, ord, ul) @ l
// end of [HPMAT_v]
prfun HPMAT_v_of_SPMAT_v {a:t@ype}
{ord:order} {ul:uplo} {n:nat} {l:addr} (
pf_typ: realtyp_p (a), pf_mat: SPMAT_v (a, n, ord, ul, l)
) :<> HPMAT_v (a, n, ord, ul, l)
// end of [HPMAT_v_of_SPMAT_v]
prfun SPMAT_v_of_HPMAT_v {a:t@ype}
{ord:order} {ul:uplo} {n:nat} {l:addr} (
pf_typ: realtyp_p (a), pf_mat: HPMAT_v (a, n, ord, ul, l)
) :<> SPMAT_v (a, n, ord, ul, l)
// end of [SPMAT_v_of_HPMAT_v]
prfun HPMAT_v_of_GEVEC_v {a:viewt@ype}
{ord:order} {ul:uplo} {m,n:nat} {l:addr} (
pf_mul: MUL (n, n+1, m+m)
, pf_arr: GEVEC_v (a, m, 1, l)
, ord: ORDER (ord), ul: UPLO (ul)
) :<> (
HPMAT_v (a, n, ord, ul, l)
, HPMAT_v (a, n, ord, ul, l) -<prf> GEVEC_v (a, m, 1, l)
) // end of [HPMAT_v_of_GEVEC_v]
(* ****** ****** *)
(* end of [genarrays.sats] *)
|