/usr/include/trilinos/Teuchos_BLAS.hpp is in libtrilinos-teuchos-dev 12.10.1-3.
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 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 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 | // @HEADER
// ***********************************************************************
//
// Teuchos: Common Tools Package
// Copyright (2004) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
//
// ***********************************************************************
// @HEADER
// Kris
// 06.16.03 -- Start over from scratch
// 06.16.03 -- Initial templatization (Tpetra_BLAS.cpp is no longer needed)
// 06.18.03 -- Changed xxxxx_() function calls to XXXXX_F77()
// -- Added warning messages for generic calls
// 07.08.03 -- Move into Teuchos package/namespace
// 07.24.03 -- The first iteration of BLAS generics is nearing completion. Caveats:
// * TRSM isn't finished yet; it works for one case at the moment (left side, upper tri., no transpose, no unit diag.)
// * Many of the generic implementations are quite inefficient, ugly, or both. I wrote these to be easy to debug, not for efficiency or legibility. The next iteration will improve both of these aspects as much as possible.
// * Very little verification of input parameters is done, save for the character-type arguments (TRANS, etc.) which is quite robust.
// * All of the routines that make use of both an incx and incy parameter (which includes much of the L1 BLAS) are set up to work iff incx == incy && incx > 0. Allowing for differing/negative values of incx/incy should be relatively trivial.
// * All of the L2/L3 routines assume that the entire matrix is being used (that is, if A is mxn, lda = m); they don't work on submatrices yet. This *should* be a reasonably trivial thing to fix, as well.
// -- Removed warning messages for generic calls
// 08.08.03 -- TRSM now works for all cases where SIDE == L and DIAG == N. DIAG == U is implemented but does not work correctly; SIDE == R is not yet implemented.
// 08.14.03 -- TRSM now works for all cases and accepts (and uses) leading-dimension information.
// 09.26.03 -- character input replaced with enumerated input to cause compiling errors and not run-time errors ( suggested by RAB ).
#ifndef _TEUCHOS_BLAS_HPP_
#define _TEUCHOS_BLAS_HPP_
/*! \file Teuchos_BLAS.hpp
\brief Templated interface class to BLAS routines.
*/
/** \example BLAS/cxx_main.cpp
This is an example of how to use the Teuchos::BLAS class.
*/
#include "Teuchos_ConfigDefs.hpp"
#include "Teuchos_ScalarTraits.hpp"
#include "Teuchos_OrdinalTraits.hpp"
#include "Teuchos_BLAS_types.hpp"
#include "Teuchos_Assert.hpp"
/*! \class Teuchos::BLAS
\brief Templated BLAS wrapper.
The Teuchos::BLAS class provides functionality similar to the BLAS
(Basic Linear Algebra Subprograms). The BLAS provide portable,
high- performance implementations of kernels such as dense vector
sums, inner products, and norms (the BLAS 1 routines), dense
matrix-vector multiplication and triangular solve (the BLAS 2
routines), and dense matrix-matrix multiplication and triangular
solve with multiple right-hand sides (the BLAS 3 routines).
The standard BLAS interface is Fortran-specific. Unfortunately,
the interface between C++ and Fortran is not standard across all
computer platforms. The Teuchos::BLAS class provides C++ bindings
for the BLAS kernels in order to insulate the rest of Petra from
the details of C++ to Fortran translation.
In addition to giving access to the standard BLAS functionality,
Teuchos::BLAS also provides a generic fall-back implementation for
any ScalarType class that defines the +, - * and / operators.
Teuchos::BLAS only operates within a single shared-memory space,
just like the BLAS. It does not attempt to implement
distributed-memory parallel matrix operations.
\note This class has specializations for ScalarType=float and
double, which use the BLAS library directly. If you configure
Teuchos to enable complex arithmetic support, via the CMake
option -DTeuchos_ENABLE_COMPLEX:BOOL=ON, then this class will
also invoke the BLAS library directly for
ScalarType=std::complex<float> and std::complex<double>.
*/
namespace Teuchos
{
extern TEUCHOSNUMERICS_LIB_DLL_EXPORT const char ESideChar[];
extern TEUCHOSNUMERICS_LIB_DLL_EXPORT const char ETranspChar[];
extern TEUCHOSNUMERICS_LIB_DLL_EXPORT const char EUploChar[];
extern TEUCHOSNUMERICS_LIB_DLL_EXPORT const char EDiagChar[];
extern TEUCHOSNUMERICS_LIB_DLL_EXPORT const char ETypeChar[];
// Forward declaration
namespace details {
template<typename ScalarType,
bool isComplex = Teuchos::ScalarTraits<ScalarType>::isComplex>
class GivensRotator;
}
//! Default implementation for BLAS routines
/*!
* This class provides the default implementation for the BLAS routines. It
* is put in a separate class so that specializations of BLAS for other types
* still have this implementation available.
*/
template<typename OrdinalType, typename ScalarType>
class DefaultBLASImpl
{
typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
public:
//! @name Constructor/Destructor.
//@{
//! Default constructor.
inline DefaultBLASImpl(void) {}
//! Copy constructor.
inline DefaultBLASImpl(const DefaultBLASImpl<OrdinalType, ScalarType>& /*BLAS_source*/) {}
//! Destructor.
inline virtual ~DefaultBLASImpl(void) {}
//@}
//! @name Level 1 BLAS Routines.
//@{
//! The type used for c in ROTG
/*! This is MagnitudeType if ScalarType is complex and ScalarType otherwise.
*/
typedef typename details::GivensRotator<ScalarType>::c_type rotg_c_type;
//! Computes a Givens plane rotation.
void ROTG(ScalarType* da, ScalarType* db, rotg_c_type* c, ScalarType* s) const;
//! Applies a Givens plane rotation.
void ROT(const OrdinalType n, ScalarType* dx, const OrdinalType incx, ScalarType* dy, const OrdinalType incy, MagnitudeType* c, ScalarType* s) const;
//! Scale the vector \c x by the constant \c alpha.
void SCAL(const OrdinalType n, const ScalarType alpha, ScalarType* x, const OrdinalType incx) const;
//! Copy the vector \c x to the vector \c y.
void COPY(const OrdinalType n, const ScalarType* x, const OrdinalType incx, ScalarType* y, const OrdinalType incy) const;
//! Perform the operation: \c y \c <- \c y+alpha*x.
template <typename alpha_type, typename x_type>
void AXPY(const OrdinalType n, const alpha_type alpha, const x_type* x, const OrdinalType incx, ScalarType* y, const OrdinalType incy) const;
//! Sum the absolute values of the entries of \c x.
typename ScalarTraits<ScalarType>::magnitudeType ASUM(const OrdinalType n, const ScalarType* x, const OrdinalType incx) const;
//! Form the dot product of the vectors \c x and \c y.
template <typename x_type, typename y_type>
ScalarType DOT(const OrdinalType n, const x_type* x, const OrdinalType incx, const y_type* y, const OrdinalType incy) const;
//! Compute the 2-norm of the vector \c x.
typename ScalarTraits<ScalarType>::magnitudeType NRM2(const OrdinalType n, const ScalarType* x, const OrdinalType incx) const;
//! Return the index of the element of \c x with the maximum magnitude.
OrdinalType IAMAX(const OrdinalType n, const ScalarType* x, const OrdinalType incx) const;
//@}
//! @name Level 2 BLAS Routines.
//@{
//! Performs the matrix-vector operation: \c y \c <- \c alpha*A*x+beta*y or \c y \c <- \c alpha*A'*x+beta*y where \c A is a general \c m by \c n matrix.
template <typename alpha_type, typename A_type, typename x_type, typename beta_type>
void GEMV(ETransp trans, const OrdinalType m, const OrdinalType n, const alpha_type alpha, const A_type* A,
const OrdinalType lda, const x_type* x, const OrdinalType incx, const beta_type beta, ScalarType* y, const OrdinalType incy) const;
//! Performs the matrix-vector operation: \c x \c <- \c A*x or \c x \c <- \c A'*x where \c A is a unit/non-unit \c n by \c n upper/lower triangular matrix.
template <typename A_type>
void TRMV(EUplo uplo, ETransp trans, EDiag diag, const OrdinalType n, const A_type* A,
const OrdinalType lda, ScalarType* x, const OrdinalType incx) const;
//! \brief Performs the rank 1 operation: \c A \c <- \c alpha*x*y'+A.
/// \note For complex arithmetic, this routine performs [Z/C]GERU.
template <typename alpha_type, typename x_type, typename y_type>
void GER(const OrdinalType m, const OrdinalType n, const alpha_type alpha, const x_type* x, const OrdinalType incx,
const y_type* y, const OrdinalType incy, ScalarType* A, const OrdinalType lda) const;
//@}
//! @name Level 3 BLAS Routines.
//@{
/// \brief General matrix-matrix multiply.
///
/// This computes C = alpha*op(A)*op(B) + beta*C. op(X) here may
/// be either X, the transpose of X, or the conjugate transpose of
/// X. op(A) has m rows and k columns, op(B) has k rows and n
/// columns, and C has m rows and n columns.
template <typename alpha_type, typename A_type, typename B_type, typename beta_type>
void GEMM(ETransp transa, ETransp transb, const OrdinalType m, const OrdinalType n, const OrdinalType k, const alpha_type alpha, const A_type* A, const OrdinalType lda, const B_type* B, const OrdinalType ldb, const beta_type beta, ScalarType* C, const OrdinalType ldc) const;
//! Swap the entries of x and y.
void
SWAP (const OrdinalType n, ScalarType* const x, const OrdinalType incx,
ScalarType* const y, const OrdinalType incy) const;
//! Performs the matrix-matrix operation: \c C \c <- \c alpha*A*B+beta*C or \c C \c <- \c alpha*B*A+beta*C where \c A is an \c m by \c m or \c n by \c n symmetric matrix and \c B is a general matrix.
template <typename alpha_type, typename A_type, typename B_type, typename beta_type>
void SYMM(ESide side, EUplo uplo, const OrdinalType m, const OrdinalType n, const alpha_type alpha, const A_type* A, const OrdinalType lda, const B_type* B, const OrdinalType ldb, const beta_type beta, ScalarType* C, const OrdinalType ldc) const;
//! Performs the symmetric rank k operation: \c C <- \c alpha*A*A'+beta*C or \c C <- \c alpha*A'*A+beta*C, where \c alpha and \c beta are scalars, \c C is an \c n by \c n symmetric matrix and \c A is an \c n by \c k matrix in the first case or \c k by \c n matrix in the second case.
template <typename alpha_type, typename A_type, typename beta_type>
void SYRK(EUplo uplo, ETransp trans, const OrdinalType n, const OrdinalType k, const alpha_type alpha, const A_type* A, const OrdinalType lda, const beta_type beta, ScalarType* C, const OrdinalType ldc) const;
//! Performs the matrix-matrix operation: \c B \c <- \c alpha*op(A)*B or \c B \c <- \c alpha*B*op(A) where \c op(A) is an unit/non-unit, upper/lower triangular matrix and \c B is a general matrix.
template <typename alpha_type, typename A_type>
void TRMM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const OrdinalType m, const OrdinalType n,
const alpha_type alpha, const A_type* A, const OrdinalType lda, ScalarType* B, const OrdinalType ldb) const;
//! Solves the matrix equations: \c op(A)*X=alpha*B or \c X*op(A)=alpha*B where \c X and \c B are \c m by \c n matrices, \c A is a unit/non-unit, upper/lower triangular matrix and \c op(A) is \c A or \c A'. The matrix \c X is overwritten on \c B.
template <typename alpha_type, typename A_type>
void TRSM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const OrdinalType m, const OrdinalType n,
const alpha_type alpha, const A_type* A, const OrdinalType lda, ScalarType* B, const OrdinalType ldb) const;
//@}
};
template<typename OrdinalType, typename ScalarType>
class TEUCHOSNUMERICS_LIB_DLL_EXPORT BLAS : public DefaultBLASImpl<OrdinalType,ScalarType>
{
typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
public:
//! @name Constructor/Destructor.
//@{
//! Default constructor.
inline BLAS(void) {}
//! Copy constructor.
inline BLAS(const BLAS<OrdinalType, ScalarType>& /*BLAS_source*/) {}
//! Destructor.
inline virtual ~BLAS(void) {}
//@}
};
//------------------------------------------------------------------------------------------
// LEVEL 1 BLAS ROUTINES
//------------------------------------------------------------------------------------------
/// \namespace details
/// \brief Teuchos implementation details.
///
/// \warning Teuchos users should not use anything in this
/// namespace. They should not even assume that the namespace
/// will continue to exist between releases. The namespace's name
/// itself or anything it contains may change at any time.
namespace details {
// Compute magnitude.
template<typename ScalarType, bool isComplex>
class MagValue {
public:
void
blas_dabs1(const ScalarType* a, typename ScalarTraits<ScalarType>::magnitudeType* ret) const;
};
// Complex-arithmetic specialization.
template<typename ScalarType>
class MagValue<ScalarType, true> {
public:
void
blas_dabs1(const ScalarType* a, typename ScalarTraits<ScalarType>::magnitudeType* ret) const;
};
// Real-arithmetic specialization.
template<typename ScalarType>
class MagValue<ScalarType, false> {
public:
void
blas_dabs1(const ScalarType* a, ScalarType* ret) const;
};
template<typename ScalarType, bool isComplex>
class GivensRotator {};
// Complex-arithmetic specialization.
template<typename ScalarType>
class GivensRotator<ScalarType, true> {
public:
typedef typename ScalarTraits<ScalarType>::magnitudeType c_type;
void
ROTG (ScalarType* ca,
ScalarType* cb,
typename ScalarTraits<ScalarType>::magnitudeType* c,
ScalarType* s) const;
};
// Real-arithmetic specialization.
template<typename ScalarType>
class GivensRotator<ScalarType, false> {
public:
typedef ScalarType c_type;
void
ROTG (ScalarType* da,
ScalarType* db,
ScalarType* c,
ScalarType* s) const;
/// Return ABS(x) if y > 0 or y is +0, else -ABS(x) (if y is -0 or < 0).
///
/// Note that SIGN respects IEEE 754 floating-point signed zero.
/// This is a hopefully correct implementation of the Fortran
/// type-generic SIGN intrinsic. ROTG for complex arithmetic
/// doesn't require this function. C99 provides a copysign()
/// math library function, but we are not able to rely on the
/// existence of C99 functions here.
///
/// We provide this method on purpose only for the
/// real-arithmetic specialization of GivensRotator. Complex
/// numbers don't have a sign; they have an angle.
ScalarType SIGN (ScalarType x, ScalarType y) const {
typedef ScalarTraits<ScalarType> STS;
if (y > STS::zero()) {
return STS::magnitude (x);
} else if (y < STS::zero()) {
return -STS::magnitude (x);
} else { // y == STS::zero()
// Suppose that ScalarType implements signed zero, as IEEE
// 754 - compliant floating-point numbers should. You can't
// use == to test for signed zero, since +0 == -0. However,
// 1/0 = Inf > 0 and 1/-0 = -Inf < 0. Let's hope ScalarType
// supports Inf... we don't need to test for Inf, just see
// if it's greater than or less than zero.
//
// NOTE: This ONLY works if ScalarType is real. Complex
// infinity doesn't have a sign, so we can't compare it with
// zero. That's OK, because finite complex numbers don't
// have a sign either; they have an angle.
ScalarType signedInfinity = STS::one() / y;
if (signedInfinity > STS::zero()) {
return STS::magnitude (x);
} else {
// Even if ScalarType doesn't implement signed zero,
// Fortran's SIGN intrinsic returns -ABS(X) if the second
// argument Y is zero. We imitate this behavior here.
return -STS::magnitude (x);
}
}
}
};
// Implementation of complex-arithmetic specialization.
template<typename ScalarType>
void
GivensRotator<ScalarType, true>::
ROTG (ScalarType* ca,
ScalarType* cb,
typename ScalarTraits<ScalarType>::magnitudeType* c,
ScalarType* s) const
{
typedef ScalarTraits<ScalarType> STS;
typedef typename STS::magnitudeType MagnitudeType;
typedef ScalarTraits<MagnitudeType> STM;
// This is a straightforward translation into C++ of the
// reference BLAS' implementation of ZROTG. You can get
// the Fortran 77 source code of ZROTG here:
//
// http://www.netlib.org/blas/zrotg.f
//
// I used the following rules to translate Fortran types and
// intrinsic functions into C++:
//
// DOUBLE PRECISION -> MagnitudeType
// DOUBLE COMPLEX -> ScalarType
// CDABS -> STS::magnitude
// DCMPLX -> ScalarType constructor (assuming that ScalarType
// is std::complex<MagnitudeType>)
// DCONJG -> STS::conjugate
// DSQRT -> STM::squareroot
ScalarType alpha;
MagnitudeType norm, scale;
if (STS::magnitude (*ca) == STM::zero()) {
*c = STM::zero();
*s = STS::one();
*ca = *cb;
} else {
scale = STS::magnitude (*ca) + STS::magnitude (*cb);
{ // I introduced temporaries into the translated BLAS code in
// order to make the expression easier to read and also save a
// few floating-point operations.
const MagnitudeType ca_scaled =
STS::magnitude (*ca / ScalarType(scale, STM::zero()));
const MagnitudeType cb_scaled =
STS::magnitude (*cb / ScalarType(scale, STM::zero()));
norm = scale *
STM::squareroot (ca_scaled*ca_scaled + cb_scaled*cb_scaled);
}
alpha = *ca / STS::magnitude (*ca);
*c = STS::magnitude (*ca) / norm;
*s = alpha * STS::conjugate (*cb) / norm;
*ca = alpha * norm;
}
}
// Implementation of real-arithmetic specialization.
template<typename ScalarType>
void
GivensRotator<ScalarType, false>::
ROTG (ScalarType* da,
ScalarType* db,
ScalarType* c,
ScalarType* s) const
{
typedef ScalarTraits<ScalarType> STS;
// This is a straightforward translation into C++ of the
// reference BLAS' implementation of DROTG. You can get
// the Fortran 77 source code of DROTG here:
//
// http://www.netlib.org/blas/drotg.f
//
// I used the following rules to translate Fortran types and
// intrinsic functions into C++:
//
// DOUBLE PRECISION -> ScalarType
// DABS -> STS::magnitude
// DSQRT -> STM::squareroot
// DSIGN -> SIGN (see below)
//
// DSIGN(x,y) (the old DOUBLE PRECISION type-specific form of
// the Fortran type-generic SIGN intrinsic) required special
// translation, which we did in a separate utility function in
// the specializaton of GivensRotator for real arithmetic.
// (ROTG for complex arithmetic doesn't require this function.)
// C99 provides a copysign() math library function, but we are
// not able to rely on the existence of C99 functions here.
ScalarType r, roe, scale, z;
roe = *db;
if (STS::magnitude (*da) > STS::magnitude (*db)) {
roe = *da;
}
scale = STS::magnitude (*da) + STS::magnitude (*db);
if (scale == STS::zero()) {
*c = STS::one();
*s = STS::zero();
r = STS::zero();
z = STS::zero();
} else {
// I introduced temporaries into the translated BLAS code in
// order to make the expression easier to read and also save
// a few floating-point operations.
const ScalarType da_scaled = *da / scale;
const ScalarType db_scaled = *db / scale;
r = scale * STS::squareroot (da_scaled*da_scaled + db_scaled*db_scaled);
r = SIGN (STS::one(), roe) * r;
*c = *da / r;
*s = *db / r;
z = STS::one();
if (STS::magnitude (*da) > STS::magnitude (*db)) {
z = *s;
}
if (STS::magnitude (*db) >= STS::magnitude (*da) && *c != STS::zero()) {
z = STS::one() / *c;
}
}
*da = r;
*db = z;
}
// Real-valued implementation of MagValue
template<typename ScalarType>
void
MagValue<ScalarType, false>::
blas_dabs1(const ScalarType* a, ScalarType* ret) const
{
*ret = Teuchos::ScalarTraits<ScalarType>::magnitude( *a );
}
// Complex-valued implementation of MagValue
template<typename ScalarType>
void
MagValue<ScalarType, true>::
blas_dabs1(const ScalarType* a, typename ScalarTraits<ScalarType>::magnitudeType* ret) const
{
*ret = ScalarTraits<typename ScalarTraits<ScalarType>::magnitudeType>::magnitude(a->real());
*ret += ScalarTraits<typename ScalarTraits<ScalarType>::magnitudeType>::magnitude(a->imag());
}
} // namespace details
template<typename OrdinalType, typename ScalarType>
void
DefaultBLASImpl<OrdinalType, ScalarType>::
ROTG (ScalarType* da,
ScalarType* db,
rotg_c_type* c,
ScalarType* s) const
{
details::GivensRotator<ScalarType> rotator;
rotator.ROTG (da, db, c, s);
}
template<typename OrdinalType, typename ScalarType>
void DefaultBLASImpl<OrdinalType,ScalarType>::ROT(const OrdinalType n, ScalarType* dx, const OrdinalType incx, ScalarType* dy, const OrdinalType incy, MagnitudeType* c, ScalarType* s) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
ScalarType sconj = Teuchos::ScalarTraits<ScalarType>::conjugate(*s);
if (n <= 0) return;
if (incx==1 && incy==1) {
for(OrdinalType i=0; i<n; ++i) {
ScalarType temp = *c*dx[i] + sconj*dy[i];
dy[i] = *c*dy[i] - sconj*dx[i];
dx[i] = temp;
}
}
else {
OrdinalType ix = 0, iy = 0;
if (incx < izero) ix = (-n+1)*incx;
if (incy < izero) iy = (-n+1)*incy;
for(OrdinalType i=0; i<n; ++i) {
ScalarType temp = *c*dx[ix] + sconj*dy[iy];
dy[iy] = *c*dy[iy] - sconj*dx[ix];
dx[ix] = temp;
ix += incx;
iy += incy;
}
}
}
template<typename OrdinalType, typename ScalarType>
void DefaultBLASImpl<OrdinalType, ScalarType>::SCAL(const OrdinalType n, const ScalarType alpha, ScalarType* x, const OrdinalType incx) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
OrdinalType i, ix = izero;
if ( n < ione || incx < ione )
return;
// Scale the vector.
for(i = izero; i < n; i++)
{
x[ix] *= alpha;
ix += incx;
}
} /* end SCAL */
template<typename OrdinalType, typename ScalarType>
void DefaultBLASImpl<OrdinalType, ScalarType>::COPY(const OrdinalType n, const ScalarType* x, const OrdinalType incx, ScalarType* y, const OrdinalType incy) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
OrdinalType i, ix = izero, iy = izero;
if ( n > izero ) {
// Set the initial indices (ix, iy).
if (incx < izero) { ix = (-n+ione)*incx; }
if (incy < izero) { iy = (-n+ione)*incy; }
for(i = izero; i < n; i++)
{
y[iy] = x[ix];
ix += incx;
iy += incy;
}
}
} /* end COPY */
template<typename OrdinalType, typename ScalarType>
template <typename alpha_type, typename x_type>
void DefaultBLASImpl<OrdinalType, ScalarType>::AXPY(const OrdinalType n, const alpha_type alpha, const x_type* x, const OrdinalType incx, ScalarType* y, const OrdinalType incy) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
OrdinalType i, ix = izero, iy = izero;
if( n > izero && alpha != ScalarTraits<alpha_type>::zero())
{
// Set the initial indices (ix, iy).
if (incx < izero) { ix = (-n+ione)*incx; }
if (incy < izero) { iy = (-n+ione)*incy; }
for(i = izero; i < n; i++)
{
y[iy] += alpha * x[ix];
ix += incx;
iy += incy;
}
}
} /* end AXPY */
template<typename OrdinalType, typename ScalarType>
typename ScalarTraits<ScalarType>::magnitudeType DefaultBLASImpl<OrdinalType, ScalarType>::ASUM(const OrdinalType n, const ScalarType* x, const OrdinalType incx) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
typename ScalarTraits<ScalarType>::magnitudeType temp, result =
ScalarTraits<typename ScalarTraits<ScalarType>::magnitudeType>::zero();
OrdinalType i, ix = izero;
if ( n < ione || incx < ione )
return result;
details::MagValue<ScalarType, ScalarTraits<ScalarType>::isComplex> mval;
for (i = izero; i < n; i++)
{
mval.blas_dabs1( &x[ix], &temp );
result += temp;
ix += incx;
}
return result;
} /* end ASUM */
template<typename OrdinalType, typename ScalarType>
template <typename x_type, typename y_type>
ScalarType DefaultBLASImpl<OrdinalType, ScalarType>::DOT(const OrdinalType n, const x_type* x, const OrdinalType incx, const y_type* y, const OrdinalType incy) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
ScalarType result = ScalarTraits<ScalarType>::zero();
OrdinalType i, ix = izero, iy = izero;
if( n > izero )
{
// Set the initial indices (ix,iy).
if (incx < izero) { ix = (-n+ione)*incx; }
if (incy < izero) { iy = (-n+ione)*incy; }
for(i = izero; i < n; i++)
{
result += ScalarTraits<x_type>::conjugate(x[ix]) * y[iy];
ix += incx;
iy += incy;
}
}
return result;
} /* end DOT */
template<typename OrdinalType, typename ScalarType>
typename ScalarTraits<ScalarType>::magnitudeType DefaultBLASImpl<OrdinalType, ScalarType>::NRM2(const OrdinalType n, const ScalarType* x, const OrdinalType incx) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
typename ScalarTraits<ScalarType>::magnitudeType result =
ScalarTraits<typename ScalarTraits<ScalarType>::magnitudeType>::zero();
OrdinalType i, ix = izero;
if ( n < ione || incx < ione )
return result;
for(i = izero; i < n; i++)
{
result += ScalarTraits<ScalarType>::magnitude(ScalarTraits<ScalarType>::conjugate(x[ix]) * x[ix]);
ix += incx;
}
result = ScalarTraits<typename ScalarTraits<ScalarType>::magnitudeType>::squareroot(result);
return result;
} /* end NRM2 */
template<typename OrdinalType, typename ScalarType>
OrdinalType DefaultBLASImpl<OrdinalType, ScalarType>::IAMAX(const OrdinalType n, const ScalarType* x, const OrdinalType incx) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
OrdinalType result = izero, ix = izero, i;
typename ScalarTraits<ScalarType>::magnitudeType curval =
ScalarTraits<typename ScalarTraits<ScalarType>::magnitudeType>::zero();
typename ScalarTraits<ScalarType>::magnitudeType maxval =
ScalarTraits<typename ScalarTraits<ScalarType>::magnitudeType>::zero();
if ( n < ione || incx < ione )
return result;
details::MagValue<ScalarType, ScalarTraits<ScalarType>::isComplex> mval;
mval.blas_dabs1( &x[ix], &maxval );
ix += incx;
for(i = ione; i < n; i++)
{
mval.blas_dabs1( &x[ix], &curval );
if(curval > maxval)
{
result = i;
maxval = curval;
}
ix += incx;
}
return result + 1; // the BLAS I?AMAX functions return 1-indexed (Fortran-style) values
} /* end IAMAX */
//------------------------------------------------------------------------------------------
// LEVEL 2 BLAS ROUTINES
//------------------------------------------------------------------------------------------
template<typename OrdinalType, typename ScalarType>
template <typename alpha_type, typename A_type, typename x_type, typename beta_type>
void DefaultBLASImpl<OrdinalType, ScalarType>::GEMV(ETransp trans, const OrdinalType m, const OrdinalType n, const alpha_type alpha, const A_type* A, const OrdinalType lda, const x_type* x, const OrdinalType incx, const beta_type beta, ScalarType* y, const OrdinalType incy) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
alpha_type alpha_zero = ScalarTraits<alpha_type>::zero();
beta_type beta_zero = ScalarTraits<beta_type>::zero();
x_type x_zero = ScalarTraits<x_type>::zero();
ScalarType y_zero = ScalarTraits<ScalarType>::zero();
beta_type beta_one = ScalarTraits<beta_type>::one();
bool noConj = true;
bool BadArgument = false;
// Quick return if there is nothing to do!
if( m == izero || n == izero || ( alpha == alpha_zero && beta == beta_one ) ){ return; }
// Otherwise, we need to check the argument list.
if( m < izero ) {
std::cout << "BLAS::GEMV Error: M == " << m << std::endl;
BadArgument = true;
}
if( n < izero ) {
std::cout << "BLAS::GEMV Error: N == " << n << std::endl;
BadArgument = true;
}
if( lda < m ) {
std::cout << "BLAS::GEMV Error: LDA < MAX(1,M)"<< std::endl;
BadArgument = true;
}
if( incx == izero ) {
std::cout << "BLAS::GEMV Error: INCX == 0"<< std::endl;
BadArgument = true;
}
if( incy == izero ) {
std::cout << "BLAS::GEMV Error: INCY == 0"<< std::endl;
BadArgument = true;
}
if(!BadArgument) {
OrdinalType i, j, lenx, leny, ix, iy, jx, jy;
OrdinalType kx = izero, ky = izero;
ScalarType temp;
// Determine the lengths of the vectors x and y.
if(ETranspChar[trans] == 'N') {
lenx = n;
leny = m;
} else {
lenx = m;
leny = n;
}
// Determine if this is a conjugate tranpose
noConj = (ETranspChar[trans] == 'T');
// Set the starting pointers for the vectors x and y if incx/y < 0.
if (incx < izero ) { kx = (ione - lenx)*incx; }
if (incy < izero ) { ky = (ione - leny)*incy; }
// Form y = beta*y
ix = kx; iy = ky;
if(beta != beta_one) {
if (incy == ione) {
if (beta == beta_zero) {
for(i = izero; i < leny; i++) { y[i] = y_zero; }
} else {
for(i = izero; i < leny; i++) { y[i] *= beta; }
}
} else {
if (beta == beta_zero) {
for(i = izero; i < leny; i++) {
y[iy] = y_zero;
iy += incy;
}
} else {
for(i = izero; i < leny; i++) {
y[iy] *= beta;
iy += incy;
}
}
}
}
// Return if we don't have to do anything more.
if(alpha == alpha_zero) { return; }
if( ETranspChar[trans] == 'N' ) {
// Form y = alpha*A*y
jx = kx;
if (incy == ione) {
for(j = izero; j < n; j++) {
if (x[jx] != x_zero) {
temp = alpha*x[jx];
for(i = izero; i < m; i++) {
y[i] += temp*A[j*lda + i];
}
}
jx += incx;
}
} else {
for(j = izero; j < n; j++) {
if (x[jx] != x_zero) {
temp = alpha*x[jx];
iy = ky;
for(i = izero; i < m; i++) {
y[iy] += temp*A[j*lda + i];
iy += incy;
}
}
jx += incx;
}
}
} else {
jy = ky;
if (incx == ione) {
for(j = izero; j < n; j++) {
temp = y_zero;
if ( noConj ) {
for(i = izero; i < m; i++) {
temp += A[j*lda + i]*x[i];
}
} else {
for(i = izero; i < m; i++) {
temp += ScalarTraits<A_type>::conjugate(A[j*lda + i])*x[i];
}
}
y[jy] += alpha*temp;
jy += incy;
}
} else {
for(j = izero; j < n; j++) {
temp = y_zero;
ix = kx;
if ( noConj ) {
for (i = izero; i < m; i++) {
temp += A[j*lda + i]*x[ix];
ix += incx;
}
} else {
for (i = izero; i < m; i++) {
temp += ScalarTraits<A_type>::conjugate(A[j*lda + i])*x[ix];
ix += incx;
}
}
y[jy] += alpha*temp;
jy += incy;
}
}
}
} /* if (!BadArgument) */
} /* end GEMV */
template<typename OrdinalType, typename ScalarType>
template <typename A_type>
void DefaultBLASImpl<OrdinalType, ScalarType>::TRMV(EUplo uplo, ETransp trans, EDiag diag, const OrdinalType n, const A_type* A, const OrdinalType lda, ScalarType* x, const OrdinalType incx) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
ScalarType zero = ScalarTraits<ScalarType>::zero();
bool BadArgument = false;
bool noConj = true;
// Quick return if there is nothing to do!
if( n == izero ){ return; }
// Otherwise, we need to check the argument list.
if( n < izero ) {
std::cout << "BLAS::TRMV Error: N == " << n << std::endl;
BadArgument = true;
}
if( lda < n ) {
std::cout << "BLAS::TRMV Error: LDA < MAX(1,N)"<< std::endl;
BadArgument = true;
}
if( incx == izero ) {
std::cout << "BLAS::TRMV Error: INCX == 0"<< std::endl;
BadArgument = true;
}
if(!BadArgument) {
OrdinalType i, j, ix, jx, kx = izero;
ScalarType temp;
bool noUnit = (EDiagChar[diag] == 'N');
// Determine if this is a conjugate tranpose
noConj = (ETranspChar[trans] == 'T');
// Set the starting pointer for the vector x if incx < 0.
if (incx < izero) { kx = (-n+ione)*incx; }
// Start the operations for a nontransposed triangular matrix
if (ETranspChar[trans] == 'N') {
/* Compute x = A*x */
if (EUploChar[uplo] == 'U') {
/* A is an upper triangular matrix */
if (incx == ione) {
for (j=izero; j<n; j++) {
if (x[j] != zero) {
temp = x[j];
for (i=izero; i<j; i++) {
x[i] += temp*A[j*lda + i];
}
if ( noUnit )
x[j] *= A[j*lda + j];
}
}
} else {
jx = kx;
for (j=izero; j<n; j++) {
if (x[jx] != zero) {
temp = x[jx];
ix = kx;
for (i=izero; i<j; i++) {
x[ix] += temp*A[j*lda + i];
ix += incx;
}
if ( noUnit )
x[jx] *= A[j*lda + j];
}
jx += incx;
}
} /* if (incx == ione) */
} else { /* A is a lower triangular matrix */
if (incx == ione) {
for (j=n-ione; j>-ione; j--) {
if (x[j] != zero) {
temp = x[j];
for (i=n-ione; i>j; i--) {
x[i] += temp*A[j*lda + i];
}
if ( noUnit )
x[j] *= A[j*lda + j];
}
}
} else {
kx += (n-ione)*incx;
jx = kx;
for (j=n-ione; j>-ione; j--) {
if (x[jx] != zero) {
temp = x[jx];
ix = kx;
for (i=n-ione; i>j; i--) {
x[ix] += temp*A[j*lda + i];
ix -= incx;
}
if ( noUnit )
x[jx] *= A[j*lda + j];
}
jx -= incx;
}
}
} /* if (EUploChar[uplo]=='U') */
} else { /* A is transposed/conjugated */
/* Compute x = A'*x */
if (EUploChar[uplo]=='U') {
/* A is an upper triangular matrix */
if (incx == ione) {
for (j=n-ione; j>-ione; j--) {
temp = x[j];
if ( noConj ) {
if ( noUnit )
temp *= A[j*lda + j];
for (i=j-ione; i>-ione; i--) {
temp += A[j*lda + i]*x[i];
}
} else {
if ( noUnit )
temp *= ScalarTraits<A_type>::conjugate(A[j*lda + j]);
for (i=j-ione; i>-ione; i--) {
temp += ScalarTraits<A_type>::conjugate(A[j*lda + i])*x[i];
}
}
x[j] = temp;
}
} else {
jx = kx + (n-ione)*incx;
for (j=n-ione; j>-ione; j--) {
temp = x[jx];
ix = jx;
if ( noConj ) {
if ( noUnit )
temp *= A[j*lda + j];
for (i=j-ione; i>-ione; i--) {
ix -= incx;
temp += A[j*lda + i]*x[ix];
}
} else {
if ( noUnit )
temp *= ScalarTraits<A_type>::conjugate(A[j*lda + j]);
for (i=j-ione; i>-ione; i--) {
ix -= incx;
temp += ScalarTraits<A_type>::conjugate(A[j*lda + i])*x[ix];
}
}
x[jx] = temp;
jx -= incx;
}
}
} else {
/* A is a lower triangular matrix */
if (incx == ione) {
for (j=izero; j<n; j++) {
temp = x[j];
if ( noConj ) {
if ( noUnit )
temp *= A[j*lda + j];
for (i=j+ione; i<n; i++) {
temp += A[j*lda + i]*x[i];
}
} else {
if ( noUnit )
temp *= ScalarTraits<A_type>::conjugate(A[j*lda + j]);
for (i=j+ione; i<n; i++) {
temp += ScalarTraits<A_type>::conjugate(A[j*lda + i])*x[i];
}
}
x[j] = temp;
}
} else {
jx = kx;
for (j=izero; j<n; j++) {
temp = x[jx];
ix = jx;
if ( noConj ) {
if ( noUnit )
temp *= A[j*lda + j];
for (i=j+ione; i<n; i++) {
ix += incx;
temp += A[j*lda + i]*x[ix];
}
} else {
if ( noUnit )
temp *= ScalarTraits<A_type>::conjugate(A[j*lda + j]);
for (i=j+ione; i<n; i++) {
ix += incx;
temp += ScalarTraits<A_type>::conjugate(A[j*lda + i])*x[ix];
}
}
x[jx] = temp;
jx += incx;
}
}
} /* if (EUploChar[uplo]=='U') */
} /* if (ETranspChar[trans]=='N') */
} /* if (!BadArgument) */
} /* end TRMV */
template<typename OrdinalType, typename ScalarType>
template <typename alpha_type, typename x_type, typename y_type>
void DefaultBLASImpl<OrdinalType, ScalarType>::GER(const OrdinalType m, const OrdinalType n, const alpha_type alpha, const x_type* x, const OrdinalType incx, const y_type* y, const OrdinalType incy, ScalarType* A, const OrdinalType lda) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
alpha_type alpha_zero = ScalarTraits<alpha_type>::zero();
y_type y_zero = ScalarTraits<y_type>::zero();
bool BadArgument = false;
// Quick return if there is nothing to do!
if( m == izero || n == izero || alpha == alpha_zero ){ return; }
// Otherwise, we need to check the argument list.
if( m < izero ) {
std::cout << "BLAS::GER Error: M == " << m << std::endl;
BadArgument = true;
}
if( n < izero ) {
std::cout << "BLAS::GER Error: N == " << n << std::endl;
BadArgument = true;
}
if( lda < m ) {
std::cout << "BLAS::GER Error: LDA < MAX(1,M)"<< std::endl;
BadArgument = true;
}
if( incx == 0 ) {
std::cout << "BLAS::GER Error: INCX == 0"<< std::endl;
BadArgument = true;
}
if( incy == 0 ) {
std::cout << "BLAS::GER Error: INCY == 0"<< std::endl;
BadArgument = true;
}
if(!BadArgument) {
OrdinalType i, j, ix, jy = izero, kx = izero;
ScalarType temp;
// Set the starting pointers for the vectors x and y if incx/y < 0.
if (incx < izero) { kx = (-m+ione)*incx; }
if (incy < izero) { jy = (-n+ione)*incy; }
// Start the operations for incx == 1
if( incx == ione ) {
for( j=izero; j<n; j++ ) {
if ( y[jy] != y_zero ) {
temp = alpha*y[jy];
for ( i=izero; i<m; i++ ) {
A[j*lda + i] += x[i]*temp;
}
}
jy += incy;
}
}
else { // Start the operations for incx != 1
for( j=izero; j<n; j++ ) {
if ( y[jy] != y_zero ) {
temp = alpha*y[jy];
ix = kx;
for( i=izero; i<m; i++ ) {
A[j*lda + i] += x[ix]*temp;
ix += incx;
}
}
jy += incy;
}
}
} /* if(!BadArgument) */
} /* end GER */
//------------------------------------------------------------------------------------------
// LEVEL 3 BLAS ROUTINES
//------------------------------------------------------------------------------------------
template<typename OrdinalType, typename ScalarType>
template <typename alpha_type, typename A_type, typename B_type, typename beta_type>
void DefaultBLASImpl<OrdinalType, ScalarType>::GEMM(ETransp transa, ETransp transb, const OrdinalType m, const OrdinalType n, const OrdinalType k, const alpha_type alpha, const A_type* A, const OrdinalType lda, const B_type* B, const OrdinalType ldb, const beta_type beta, ScalarType* C, const OrdinalType ldc) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
alpha_type alpha_zero = ScalarTraits<alpha_type>::zero();
beta_type beta_zero = ScalarTraits<beta_type>::zero();
B_type B_zero = ScalarTraits<B_type>::zero();
ScalarType C_zero = ScalarTraits<ScalarType>::zero();
beta_type beta_one = ScalarTraits<beta_type>::one();
OrdinalType i, j, p;
OrdinalType NRowA = m, NRowB = k;
ScalarType temp;
bool BadArgument = false;
bool conjA = false, conjB = false;
// Change dimensions of matrix if either matrix is transposed
if( !(ETranspChar[transa]=='N') ) {
NRowA = k;
}
if( !(ETranspChar[transb]=='N') ) {
NRowB = n;
}
// Quick return if there is nothing to do!
if( (m==izero) || (n==izero) || (((alpha==alpha_zero)||(k==izero)) && (beta==beta_one)) ){ return; }
if( m < izero ) {
std::cout << "BLAS::GEMM Error: M == " << m << std::endl;
BadArgument = true;
}
if( n < izero ) {
std::cout << "BLAS::GEMM Error: N == " << n << std::endl;
BadArgument = true;
}
if( k < izero ) {
std::cout << "BLAS::GEMM Error: K == " << k << std::endl;
BadArgument = true;
}
if( lda < NRowA ) {
std::cout << "BLAS::GEMM Error: LDA < "<<NRowA<<std::endl;
BadArgument = true;
}
if( ldb < NRowB ) {
std::cout << "BLAS::GEMM Error: LDB < "<<NRowB<<std::endl;
BadArgument = true;
}
if( ldc < m ) {
std::cout << "BLAS::GEMM Error: LDC < MAX(1,M)"<< std::endl;
BadArgument = true;
}
if(!BadArgument) {
// Determine if this is a conjugate tranpose
conjA = (ETranspChar[transa] == 'C');
conjB = (ETranspChar[transb] == 'C');
// Only need to scale the resulting matrix C.
if( alpha == alpha_zero ) {
if( beta == beta_zero ) {
for (j=izero; j<n; j++) {
for (i=izero; i<m; i++) {
C[j*ldc + i] = C_zero;
}
}
} else {
for (j=izero; j<n; j++) {
for (i=izero; i<m; i++) {
C[j*ldc + i] *= beta;
}
}
}
return;
}
//
// Now start the operations.
//
if ( ETranspChar[transb]=='N' ) {
if ( ETranspChar[transa]=='N' ) {
// Compute C = alpha*A*B + beta*C
for (j=izero; j<n; j++) {
if( beta == beta_zero ) {
for (i=izero; i<m; i++){
C[j*ldc + i] = C_zero;
}
} else if( beta != beta_one ) {
for (i=izero; i<m; i++){
C[j*ldc + i] *= beta;
}
}
for (p=izero; p<k; p++){
if (B[j*ldb + p] != B_zero ){
temp = alpha*B[j*ldb + p];
for (i=izero; i<m; i++) {
C[j*ldc + i] += temp*A[p*lda + i];
}
}
}
}
} else if ( conjA ) {
// Compute C = alpha*conj(A')*B + beta*C
for (j=izero; j<n; j++) {
for (i=izero; i<m; i++) {
temp = C_zero;
for (p=izero; p<k; p++) {
temp += ScalarTraits<A_type>::conjugate(A[i*lda + p])*B[j*ldb + p];
}
if (beta == beta_zero) {
C[j*ldc + i] = alpha*temp;
} else {
C[j*ldc + i] = alpha*temp + beta*C[j*ldc + i];
}
}
}
} else {
// Compute C = alpha*A'*B + beta*C
for (j=izero; j<n; j++) {
for (i=izero; i<m; i++) {
temp = C_zero;
for (p=izero; p<k; p++) {
temp += A[i*lda + p]*B[j*ldb + p];
}
if (beta == beta_zero) {
C[j*ldc + i] = alpha*temp;
} else {
C[j*ldc + i] = alpha*temp + beta*C[j*ldc + i];
}
}
}
}
} else if ( ETranspChar[transa]=='N' ) {
if ( conjB ) {
// Compute C = alpha*A*conj(B') + beta*C
for (j=izero; j<n; j++) {
if (beta == beta_zero) {
for (i=izero; i<m; i++) {
C[j*ldc + i] = C_zero;
}
} else if ( beta != beta_one ) {
for (i=izero; i<m; i++) {
C[j*ldc + i] *= beta;
}
}
for (p=izero; p<k; p++) {
if (B[p*ldb + j] != B_zero) {
temp = alpha*ScalarTraits<B_type>::conjugate(B[p*ldb + j]);
for (i=izero; i<m; i++) {
C[j*ldc + i] += temp*A[p*lda + i];
}
}
}
}
} else {
// Compute C = alpha*A*B' + beta*C
for (j=izero; j<n; j++) {
if (beta == beta_zero) {
for (i=izero; i<m; i++) {
C[j*ldc + i] = C_zero;
}
} else if ( beta != beta_one ) {
for (i=izero; i<m; i++) {
C[j*ldc + i] *= beta;
}
}
for (p=izero; p<k; p++) {
if (B[p*ldb + j] != B_zero) {
temp = alpha*B[p*ldb + j];
for (i=izero; i<m; i++) {
C[j*ldc + i] += temp*A[p*lda + i];
}
}
}
}
}
} else if ( conjA ) {
if ( conjB ) {
// Compute C = alpha*conj(A')*conj(B') + beta*C
for (j=izero; j<n; j++) {
for (i=izero; i<m; i++) {
temp = C_zero;
for (p=izero; p<k; p++) {
temp += ScalarTraits<A_type>::conjugate(A[i*lda + p])
* ScalarTraits<B_type>::conjugate(B[p*ldb + j]);
}
if (beta == beta_zero) {
C[j*ldc + i] = alpha*temp;
} else {
C[j*ldc + i] = alpha*temp + beta*C[j*ldc + i];
}
}
}
} else {
// Compute C = alpha*conj(A')*B' + beta*C
for (j=izero; j<n; j++) {
for (i=izero; i<m; i++) {
temp = C_zero;
for (p=izero; p<k; p++) {
temp += ScalarTraits<A_type>::conjugate(A[i*lda + p])
* B[p*ldb + j];
}
if (beta == beta_zero) {
C[j*ldc + i] = alpha*temp;
} else {
C[j*ldc + i] = alpha*temp + beta*C[j*ldc + i];
}
}
}
}
} else {
if ( conjB ) {
// Compute C = alpha*A'*conj(B') + beta*C
for (j=izero; j<n; j++) {
for (i=izero; i<m; i++) {
temp = C_zero;
for (p=izero; p<k; p++) {
temp += A[i*lda + p]
* ScalarTraits<B_type>::conjugate(B[p*ldb + j]);
}
if (beta == beta_zero) {
C[j*ldc + i] = alpha*temp;
} else {
C[j*ldc + i] = alpha*temp + beta*C[j*ldc + i];
}
}
}
} else {
// Compute C = alpha*A'*B' + beta*C
for (j=izero; j<n; j++) {
for (i=izero; i<m; i++) {
temp = C_zero;
for (p=izero; p<k; p++) {
temp += A[i*lda + p]*B[p*ldb + j];
}
if (beta == beta_zero) {
C[j*ldc + i] = alpha*temp;
} else {
C[j*ldc + i] = alpha*temp + beta*C[j*ldc + i];
}
}
}
} // end if (ETranspChar[transa]=='N') ...
} // end if (ETranspChar[transb]=='N') ...
} // end if (!BadArgument) ...
} // end of GEMM
template<typename OrdinalType, typename ScalarType>
void DefaultBLASImpl<OrdinalType, ScalarType>::
SWAP (const OrdinalType n, ScalarType* const x, const OrdinalType incx,
ScalarType* const y, const OrdinalType incy) const
{
if (n <= 0) {
return;
}
if (incx == 1 && incy == 1) {
for (int i = 0; i < n; ++i) {
ScalarType tmp = x[i];
x[i] = y[i];
y[i] = tmp;
}
return;
}
int ix = 1;
int iy = 1;
if (incx < 0) {
ix = (1-n) * incx + 1;
}
if (incy < 0) {
iy = (1-n) * incy + 1;
}
for (int i = 1; i <= n; ++i) {
ScalarType tmp = x[ix - 1];
x[ix - 1] = y[iy - 1];
y[iy - 1] = tmp;
ix += incx;
iy += incy;
}
}
template<typename OrdinalType, typename ScalarType>
template <typename alpha_type, typename A_type, typename B_type, typename beta_type>
void DefaultBLASImpl<OrdinalType, ScalarType>::SYMM(ESide side, EUplo uplo, const OrdinalType m, const OrdinalType n, const alpha_type alpha, const A_type* A, const OrdinalType lda, const B_type* B, const OrdinalType ldb, const beta_type beta, ScalarType* C, const OrdinalType ldc) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
alpha_type alpha_zero = ScalarTraits<alpha_type>::zero();
beta_type beta_zero = ScalarTraits<beta_type>::zero();
ScalarType C_zero = ScalarTraits<ScalarType>::zero();
beta_type beta_one = ScalarTraits<beta_type>::one();
OrdinalType i, j, k, NRowA = m;
ScalarType temp1, temp2;
bool BadArgument = false;
bool Upper = (EUploChar[uplo] == 'U');
if (ESideChar[side] == 'R') { NRowA = n; }
// Quick return.
if ( (m==izero) || (n==izero) || ( (alpha==alpha_zero)&&(beta==beta_one) ) ) { return; }
if( m < izero ) {
std::cout << "BLAS::SYMM Error: M == "<< m << std::endl;
BadArgument = true; }
if( n < izero ) {
std::cout << "BLAS::SYMM Error: N == "<< n << std::endl;
BadArgument = true; }
if( lda < NRowA ) {
std::cout << "BLAS::SYMM Error: LDA < "<<NRowA<<std::endl;
BadArgument = true; }
if( ldb < m ) {
std::cout << "BLAS::SYMM Error: LDB < MAX(1,M)"<<std::endl;
BadArgument = true; }
if( ldc < m ) {
std::cout << "BLAS::SYMM Error: LDC < MAX(1,M)"<<std::endl;
BadArgument = true; }
if(!BadArgument) {
// Only need to scale C and return.
if (alpha == alpha_zero) {
if (beta == beta_zero ) {
for (j=izero; j<n; j++) {
for (i=izero; i<m; i++) {
C[j*ldc + i] = C_zero;
}
}
} else {
for (j=izero; j<n; j++) {
for (i=izero; i<m; i++) {
C[j*ldc + i] *= beta;
}
}
}
return;
}
if ( ESideChar[side] == 'L') {
// Compute C = alpha*A*B + beta*C
if (Upper) {
// The symmetric part of A is stored in the upper triangular part of the matrix.
for (j=izero; j<n; j++) {
for (i=izero; i<m; i++) {
temp1 = alpha*B[j*ldb + i];
temp2 = C_zero;
for (k=izero; k<i; k++) {
C[j*ldc + k] += temp1*A[i*lda + k];
temp2 += B[j*ldb + k]*A[i*lda + k];
}
if (beta == beta_zero) {
C[j*ldc + i] = temp1*A[i*lda + i] + alpha*temp2;
} else {
C[j*ldc + i] = beta*C[j*ldc + i] + temp1*A[i*lda + i] + alpha*temp2;
}
}
}
} else {
// The symmetric part of A is stored in the lower triangular part of the matrix.
for (j=izero; j<n; j++) {
for (i=m-ione; i>-ione; i--) {
temp1 = alpha*B[j*ldb + i];
temp2 = C_zero;
for (k=i+ione; k<m; k++) {
C[j*ldc + k] += temp1*A[i*lda + k];
temp2 += B[j*ldb + k]*A[i*lda + k];
}
if (beta == beta_zero) {
C[j*ldc + i] = temp1*A[i*lda + i] + alpha*temp2;
} else {
C[j*ldc + i] = beta*C[j*ldc + i] + temp1*A[i*lda + i] + alpha*temp2;
}
}
}
}
} else {
// Compute C = alpha*B*A + beta*C.
for (j=izero; j<n; j++) {
temp1 = alpha*A[j*lda + j];
if (beta == beta_zero) {
for (i=izero; i<m; i++) {
C[j*ldc + i] = temp1*B[j*ldb + i];
}
} else {
for (i=izero; i<m; i++) {
C[j*ldc + i] = beta*C[j*ldc + i] + temp1*B[j*ldb + i];
}
}
for (k=izero; k<j; k++) {
if (Upper) {
temp1 = alpha*A[j*lda + k];
} else {
temp1 = alpha*A[k*lda + j];
}
for (i=izero; i<m; i++) {
C[j*ldc + i] += temp1*B[k*ldb + i];
}
}
for (k=j+ione; k<n; k++) {
if (Upper) {
temp1 = alpha*A[k*lda + j];
} else {
temp1 = alpha*A[j*lda + k];
}
for (i=izero; i<m; i++) {
C[j*ldc + i] += temp1*B[k*ldb + i];
}
}
}
} // end if (ESideChar[side]=='L') ...
} // end if(!BadArgument) ...
} // end SYMM
template<typename OrdinalType, typename ScalarType>
template <typename alpha_type, typename A_type, typename beta_type>
void DefaultBLASImpl<OrdinalType, ScalarType>::SYRK(EUplo uplo, ETransp trans, const OrdinalType n, const OrdinalType k, const alpha_type alpha, const A_type* A, const OrdinalType lda, const beta_type beta, ScalarType* C, const OrdinalType ldc) const
{
typedef TypeNameTraits<OrdinalType> OTNT;
typedef TypeNameTraits<ScalarType> STNT;
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
alpha_type alpha_zero = ScalarTraits<alpha_type>::zero();
beta_type beta_zero = ScalarTraits<beta_type>::zero();
beta_type beta_one = ScalarTraits<beta_type>::one();
A_type temp, A_zero = ScalarTraits<A_type>::zero();
ScalarType C_zero = ScalarTraits<ScalarType>::zero();
OrdinalType i, j, l, NRowA = n;
bool BadArgument = false;
bool Upper = (EUploChar[uplo] == 'U');
TEUCHOS_TEST_FOR_EXCEPTION(
Teuchos::ScalarTraits<ScalarType>::isComplex
&& (trans == CONJ_TRANS),
std::logic_error,
"Teuchos::BLAS<"<<OTNT::name()<<","<<STNT::name()<<">::SYRK()"
" does not support CONJ_TRANS for complex data types."
);
// Change dimensions of A matrix is transposed
if( !(ETranspChar[trans]=='N') ) {
NRowA = k;
}
// Quick return.
if ( n==izero ) { return; }
if ( ( (alpha==alpha_zero) || (k==izero) ) && (beta==beta_one) ) { return; }
if( n < izero ) {
std::cout << "BLAS::SYRK Error: N == "<< n <<std::endl;
BadArgument = true; }
if( k < izero ) {
std::cout << "BLAS::SYRK Error: K == "<< k <<std::endl;
BadArgument = true; }
if( lda < NRowA ) {
std::cout << "BLAS::SYRK Error: LDA < "<<NRowA<<std::endl;
BadArgument = true; }
if( ldc < n ) {
std::cout << "BLAS::SYRK Error: LDC < MAX(1,N)"<<std::endl;
BadArgument = true; }
if(!BadArgument) {
// Scale C when alpha is zero
if (alpha == alpha_zero) {
if (Upper) {
if (beta==beta_zero) {
for (j=izero; j<n; j++) {
for (i=izero; i<=j; i++) {
C[j*ldc + i] = C_zero;
}
}
}
else {
for (j=izero; j<n; j++) {
for (i=izero; i<=j; i++) {
C[j*ldc + i] *= beta;
}
}
}
}
else {
if (beta==beta_zero) {
for (j=izero; j<n; j++) {
for (i=j; i<n; i++) {
C[j*ldc + i] = C_zero;
}
}
}
else {
for (j=izero; j<n; j++) {
for (i=j; i<n; i++) {
C[j*ldc + i] *= beta;
}
}
}
}
return;
}
// Now we can start the computation
if ( ETranspChar[trans]=='N' ) {
// Form C <- alpha*A*A' + beta*C
if (Upper) {
for (j=izero; j<n; j++) {
if (beta==beta_zero) {
for (i=izero; i<=j; i++) {
C[j*ldc + i] = C_zero;
}
}
else if (beta!=beta_one) {
for (i=izero; i<=j; i++) {
C[j*ldc + i] *= beta;
}
}
for (l=izero; l<k; l++) {
if (A[l*lda + j] != A_zero) {
temp = alpha*A[l*lda + j];
for (i = izero; i <=j; i++) {
C[j*ldc + i] += temp*A[l*lda + i];
}
}
}
}
}
else {
for (j=izero; j<n; j++) {
if (beta==beta_zero) {
for (i=j; i<n; i++) {
C[j*ldc + i] = C_zero;
}
}
else if (beta!=beta_one) {
for (i=j; i<n; i++) {
C[j*ldc + i] *= beta;
}
}
for (l=izero; l<k; l++) {
if (A[l*lda + j] != A_zero) {
temp = alpha*A[l*lda + j];
for (i=j; i<n; i++) {
C[j*ldc + i] += temp*A[l*lda + i];
}
}
}
}
}
}
else {
// Form C <- alpha*A'*A + beta*C
if (Upper) {
for (j=izero; j<n; j++) {
for (i=izero; i<=j; i++) {
temp = A_zero;
for (l=izero; l<k; l++) {
temp += A[i*lda + l]*A[j*lda + l];
}
if (beta==beta_zero) {
C[j*ldc + i] = alpha*temp;
}
else {
C[j*ldc + i] = alpha*temp + beta*C[j*ldc + i];
}
}
}
}
else {
for (j=izero; j<n; j++) {
for (i=j; i<n; i++) {
temp = A_zero;
for (l=izero; l<k; ++l) {
temp += A[i*lda + l]*A[j*lda + l];
}
if (beta==beta_zero) {
C[j*ldc + i] = alpha*temp;
}
else {
C[j*ldc + i] = alpha*temp + beta*C[j*ldc + i];
}
}
}
}
}
} /* if (!BadArgument) */
} /* END SYRK */
template<typename OrdinalType, typename ScalarType>
template <typename alpha_type, typename A_type>
void DefaultBLASImpl<OrdinalType, ScalarType>::TRMM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const OrdinalType m, const OrdinalType n, const alpha_type alpha, const A_type* A, const OrdinalType lda, ScalarType* B, const OrdinalType ldb) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
alpha_type alpha_zero = ScalarTraits<alpha_type>::zero();
A_type A_zero = ScalarTraits<A_type>::zero();
ScalarType B_zero = ScalarTraits<ScalarType>::zero();
ScalarType one = ScalarTraits<ScalarType>::one();
OrdinalType i, j, k, NRowA = m;
ScalarType temp;
bool BadArgument = false;
bool LSide = (ESideChar[side] == 'L');
bool noUnit = (EDiagChar[diag] == 'N');
bool Upper = (EUploChar[uplo] == 'U');
bool noConj = (ETranspChar[transa] == 'T');
if(!LSide) { NRowA = n; }
// Quick return.
if (n==izero || m==izero) { return; }
if( m < izero ) {
std::cout << "BLAS::TRMM Error: M == "<< m <<std::endl;
BadArgument = true; }
if( n < izero ) {
std::cout << "BLAS::TRMM Error: N == "<< n <<std::endl;
BadArgument = true; }
if( lda < NRowA ) {
std::cout << "BLAS::TRMM Error: LDA < "<<NRowA<<std::endl;
BadArgument = true; }
if( ldb < m ) {
std::cout << "BLAS::TRMM Error: LDB < MAX(1,M)"<<std::endl;
BadArgument = true; }
if(!BadArgument) {
// B only needs to be zeroed out.
if( alpha == alpha_zero ) {
for( j=izero; j<n; j++ ) {
for( i=izero; i<m; i++ ) {
B[j*ldb + i] = B_zero;
}
}
return;
}
// Start the computations.
if ( LSide ) {
// A is on the left side of B.
if ( ETranspChar[transa]=='N' ) {
// Compute B = alpha*A*B
if ( Upper ) {
// A is upper triangular
for( j=izero; j<n; j++ ) {
for( k=izero; k<m; k++) {
if ( B[j*ldb + k] != B_zero ) {
temp = alpha*B[j*ldb + k];
for( i=izero; i<k; i++ ) {
B[j*ldb + i] += temp*A[k*lda + i];
}
if ( noUnit )
temp *=A[k*lda + k];
B[j*ldb + k] = temp;
}
}
}
} else {
// A is lower triangular
for( j=izero; j<n; j++ ) {
for( k=m-ione; k>-ione; k-- ) {
if( B[j*ldb + k] != B_zero ) {
temp = alpha*B[j*ldb + k];
B[j*ldb + k] = temp;
if ( noUnit )
B[j*ldb + k] *= A[k*lda + k];
for( i=k+ione; i<m; i++ ) {
B[j*ldb + i] += temp*A[k*lda + i];
}
}
}
}
}
} else {
// Compute B = alpha*A'*B or B = alpha*conj(A')*B
if( Upper ) {
for( j=izero; j<n; j++ ) {
for( i=m-ione; i>-ione; i-- ) {
temp = B[j*ldb + i];
if ( noConj ) {
if( noUnit )
temp *= A[i*lda + i];
for( k=izero; k<i; k++ ) {
temp += A[i*lda + k]*B[j*ldb + k];
}
} else {
if( noUnit )
temp *= ScalarTraits<A_type>::conjugate(A[i*lda + i]);
for( k=izero; k<i; k++ ) {
temp += ScalarTraits<A_type>::conjugate(A[i*lda + k])*B[j*ldb + k];
}
}
B[j*ldb + i] = alpha*temp;
}
}
} else {
for( j=izero; j<n; j++ ) {
for( i=izero; i<m; i++ ) {
temp = B[j*ldb + i];
if ( noConj ) {
if( noUnit )
temp *= A[i*lda + i];
for( k=i+ione; k<m; k++ ) {
temp += A[i*lda + k]*B[j*ldb + k];
}
} else {
if( noUnit )
temp *= ScalarTraits<A_type>::conjugate(A[i*lda + i]);
for( k=i+ione; k<m; k++ ) {
temp += ScalarTraits<A_type>::conjugate(A[i*lda + k])*B[j*ldb + k];
}
}
B[j*ldb + i] = alpha*temp;
}
}
}
}
} else {
// A is on the right hand side of B.
if( ETranspChar[transa] == 'N' ) {
// Compute B = alpha*B*A
if( Upper ) {
// A is upper triangular.
for( j=n-ione; j>-ione; j-- ) {
temp = alpha;
if( noUnit )
temp *= A[j*lda + j];
for( i=izero; i<m; i++ ) {
B[j*ldb + i] *= temp;
}
for( k=izero; k<j; k++ ) {
if( A[j*lda + k] != A_zero ) {
temp = alpha*A[j*lda + k];
for( i=izero; i<m; i++ ) {
B[j*ldb + i] += temp*B[k*ldb + i];
}
}
}
}
} else {
// A is lower triangular.
for( j=izero; j<n; j++ ) {
temp = alpha;
if( noUnit )
temp *= A[j*lda + j];
for( i=izero; i<m; i++ ) {
B[j*ldb + i] *= temp;
}
for( k=j+ione; k<n; k++ ) {
if( A[j*lda + k] != A_zero ) {
temp = alpha*A[j*lda + k];
for( i=izero; i<m; i++ ) {
B[j*ldb + i] += temp*B[k*ldb + i];
}
}
}
}
}
} else {
// Compute B = alpha*B*A' or B = alpha*B*conj(A')
if( Upper ) {
for( k=izero; k<n; k++ ) {
for( j=izero; j<k; j++ ) {
if( A[k*lda + j] != A_zero ) {
if ( noConj )
temp = alpha*A[k*lda + j];
else
temp = alpha*ScalarTraits<A_type>::conjugate(A[k*lda + j]);
for( i=izero; i<m; i++ ) {
B[j*ldb + i] += temp*B[k*ldb + i];
}
}
}
temp = alpha;
if( noUnit ) {
if ( noConj )
temp *= A[k*lda + k];
else
temp *= ScalarTraits<A_type>::conjugate(A[k*lda + k]);
}
if( temp != one ) {
for( i=izero; i<m; i++ ) {
B[k*ldb + i] *= temp;
}
}
}
} else {
for( k=n-ione; k>-ione; k-- ) {
for( j=k+ione; j<n; j++ ) {
if( A[k*lda + j] != A_zero ) {
if ( noConj )
temp = alpha*A[k*lda + j];
else
temp = alpha*ScalarTraits<A_type>::conjugate(A[k*lda + j]);
for( i=izero; i<m; i++ ) {
B[j*ldb + i] += temp*B[k*ldb + i];
}
}
}
temp = alpha;
if( noUnit ) {
if ( noConj )
temp *= A[k*lda + k];
else
temp *= ScalarTraits<A_type>::conjugate(A[k*lda + k]);
}
if( temp != one ) {
for( i=izero; i<m; i++ ) {
B[k*ldb + i] *= temp;
}
}
}
}
} // end if( ETranspChar[transa] == 'N' ) ...
} // end if ( LSide ) ...
} // end if (!BadArgument)
} // end TRMM
template<typename OrdinalType, typename ScalarType>
template <typename alpha_type, typename A_type>
void DefaultBLASImpl<OrdinalType, ScalarType>::TRSM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const OrdinalType m, const OrdinalType n, const alpha_type alpha, const A_type* A, const OrdinalType lda, ScalarType* B, const OrdinalType ldb) const
{
OrdinalType izero = OrdinalTraits<OrdinalType>::zero();
OrdinalType ione = OrdinalTraits<OrdinalType>::one();
alpha_type alpha_zero = ScalarTraits<alpha_type>::zero();
A_type A_zero = ScalarTraits<A_type>::zero();
ScalarType B_zero = ScalarTraits<ScalarType>::zero();
alpha_type alpha_one = ScalarTraits<alpha_type>::one();
ScalarType B_one = ScalarTraits<ScalarType>::one();
ScalarType temp;
OrdinalType NRowA = m;
bool BadArgument = false;
bool noUnit = (EDiagChar[diag]=='N');
bool noConj = (ETranspChar[transa] == 'T');
if (!(ESideChar[side] == 'L')) { NRowA = n; }
// Quick return.
if (n == izero || m == izero) { return; }
if( m < izero ) {
std::cout << "BLAS::TRSM Error: M == "<<m<<std::endl;
BadArgument = true; }
if( n < izero ) {
std::cout << "BLAS::TRSM Error: N == "<<n<<std::endl;
BadArgument = true; }
if( lda < NRowA ) {
std::cout << "BLAS::TRSM Error: LDA < "<<NRowA<<std::endl;
BadArgument = true; }
if( ldb < m ) {
std::cout << "BLAS::TRSM Error: LDB < MAX(1,M)"<<std::endl;
BadArgument = true; }
if(!BadArgument)
{
int i, j, k;
// Set the solution to the zero vector.
if(alpha == alpha_zero) {
for(j = izero; j < n; j++) {
for( i = izero; i < m; i++) {
B[j*ldb+i] = B_zero;
}
}
}
else
{ // Start the operations.
if(ESideChar[side] == 'L') {
//
// Perform computations for OP(A)*X = alpha*B
//
if(ETranspChar[transa] == 'N') {
//
// Compute B = alpha*inv( A )*B
//
if(EUploChar[uplo] == 'U') {
// A is upper triangular.
for(j = izero; j < n; j++) {
// Perform alpha*B if alpha is not 1.
if(alpha != alpha_one) {
for( i = izero; i < m; i++) {
B[j*ldb+i] *= alpha;
}
}
// Perform a backsolve for column j of B.
for(k = (m - ione); k > -ione; k--) {
// If this entry is zero, we don't have to do anything.
if (B[j*ldb + k] != B_zero) {
if ( noUnit ) {
B[j*ldb + k] /= A[k*lda + k];
}
for(i = izero; i < k; i++) {
B[j*ldb + i] -= B[j*ldb + k] * A[k*lda + i];
}
}
}
}
}
else
{ // A is lower triangular.
for(j = izero; j < n; j++) {
// Perform alpha*B if alpha is not 1.
if(alpha != alpha_one) {
for( i = izero; i < m; i++) {
B[j*ldb+i] *= alpha;
}
}
// Perform a forward solve for column j of B.
for(k = izero; k < m; k++) {
// If this entry is zero, we don't have to do anything.
if (B[j*ldb + k] != B_zero) {
if ( noUnit ) {
B[j*ldb + k] /= A[k*lda + k];
}
for(i = k+ione; i < m; i++) {
B[j*ldb + i] -= B[j*ldb + k] * A[k*lda + i];
}
}
}
}
} // end if (uplo == 'U')
} // if (transa =='N')
else {
//
// Compute B = alpha*inv( A' )*B
// or B = alpha*inv( conj(A') )*B
//
if(EUploChar[uplo] == 'U') {
// A is upper triangular.
for(j = izero; j < n; j++) {
for( i = izero; i < m; i++) {
temp = alpha*B[j*ldb+i];
if ( noConj ) {
for(k = izero; k < i; k++) {
temp -= A[i*lda + k] * B[j*ldb + k];
}
if ( noUnit ) {
temp /= A[i*lda + i];
}
} else {
for(k = izero; k < i; k++) {
temp -= ScalarTraits<A_type>::conjugate(A[i*lda + k])
* B[j*ldb + k];
}
if ( noUnit ) {
temp /= ScalarTraits<A_type>::conjugate(A[i*lda + i]);
}
}
B[j*ldb + i] = temp;
}
}
}
else
{ // A is lower triangular.
for(j = izero; j < n; j++) {
for(i = (m - ione) ; i > -ione; i--) {
temp = alpha*B[j*ldb+i];
if ( noConj ) {
for(k = i+ione; k < m; k++) {
temp -= A[i*lda + k] * B[j*ldb + k];
}
if ( noUnit ) {
temp /= A[i*lda + i];
}
} else {
for(k = i+ione; k < m; k++) {
temp -= ScalarTraits<A_type>::conjugate(A[i*lda + k])
* B[j*ldb + k];
}
if ( noUnit ) {
temp /= ScalarTraits<A_type>::conjugate(A[i*lda + i]);
}
}
B[j*ldb + i] = temp;
}
}
}
}
} // if (side == 'L')
else {
// side == 'R'
//
// Perform computations for X*OP(A) = alpha*B
//
if (ETranspChar[transa] == 'N') {
//
// Compute B = alpha*B*inv( A )
//
if(EUploChar[uplo] == 'U') {
// A is upper triangular.
// Perform a backsolve for column j of B.
for(j = izero; j < n; j++) {
// Perform alpha*B if alpha is not 1.
if(alpha != alpha_one) {
for( i = izero; i < m; i++) {
B[j*ldb+i] *= alpha;
}
}
for(k = izero; k < j; k++) {
// If this entry is zero, we don't have to do anything.
if (A[j*lda + k] != A_zero) {
for(i = izero; i < m; i++) {
B[j*ldb + i] -= A[j*lda + k] * B[k*ldb + i];
}
}
}
if ( noUnit ) {
temp = B_one/A[j*lda + j];
for(i = izero; i < m; i++) {
B[j*ldb + i] *= temp;
}
}
}
}
else
{ // A is lower triangular.
for(j = (n - ione); j > -ione; j--) {
// Perform alpha*B if alpha is not 1.
if(alpha != alpha_one) {
for( i = izero; i < m; i++) {
B[j*ldb+i] *= alpha;
}
}
// Perform a forward solve for column j of B.
for(k = j+ione; k < n; k++) {
// If this entry is zero, we don't have to do anything.
if (A[j*lda + k] != A_zero) {
for(i = izero; i < m; i++) {
B[j*ldb + i] -= A[j*lda + k] * B[k*ldb + i];
}
}
}
if ( noUnit ) {
temp = B_one/A[j*lda + j];
for(i = izero; i < m; i++) {
B[j*ldb + i] *= temp;
}
}
}
} // end if (uplo == 'U')
} // if (transa =='N')
else {
//
// Compute B = alpha*B*inv( A' )
// or B = alpha*B*inv( conj(A') )
//
if(EUploChar[uplo] == 'U') {
// A is upper triangular.
for(k = (n - ione); k > -ione; k--) {
if ( noUnit ) {
if ( noConj )
temp = B_one/A[k*lda + k];
else
temp = B_one/ScalarTraits<A_type>::conjugate(A[k*lda + k]);
for(i = izero; i < m; i++) {
B[k*ldb + i] *= temp;
}
}
for(j = izero; j < k; j++) {
if (A[k*lda + j] != A_zero) {
if ( noConj )
temp = A[k*lda + j];
else
temp = ScalarTraits<A_type>::conjugate(A[k*lda + j]);
for(i = izero; i < m; i++) {
B[j*ldb + i] -= temp*B[k*ldb + i];
}
}
}
if (alpha != alpha_one) {
for (i = izero; i < m; i++) {
B[k*ldb + i] *= alpha;
}
}
}
}
else
{ // A is lower triangular.
for(k = izero; k < n; k++) {
if ( noUnit ) {
if ( noConj )
temp = B_one/A[k*lda + k];
else
temp = B_one/ScalarTraits<A_type>::conjugate(A[k*lda + k]);
for (i = izero; i < m; i++) {
B[k*ldb + i] *= temp;
}
}
for(j = k+ione; j < n; j++) {
if(A[k*lda + j] != A_zero) {
if ( noConj )
temp = A[k*lda + j];
else
temp = ScalarTraits<A_type>::conjugate(A[k*lda + j]);
for(i = izero; i < m; i++) {
B[j*ldb + i] -= temp*B[k*ldb + i];
}
}
}
if (alpha != alpha_one) {
for (i = izero; i < m; i++) {
B[k*ldb + i] *= alpha;
}
}
}
}
}
}
}
}
}
// Explicit instantiation for template<int,float>
template <>
class TEUCHOSNUMERICS_LIB_DLL_EXPORT BLAS<int, float>
{
public:
inline BLAS(void) {}
inline BLAS(const BLAS<int, float>& /*BLAS_source*/) {}
inline virtual ~BLAS(void) {}
void ROTG(float* da, float* db, float* c, float* s) const;
void ROT(const int n, float* dx, const int incx, float* dy, const int incy, float* c, float* s) const;
float ASUM(const int n, const float* x, const int incx) const;
void AXPY(const int n, const float alpha, const float* x, const int incx, float* y, const int incy) const;
void COPY(const int n, const float* x, const int incx, float* y, const int incy) const;
float DOT(const int n, const float* x, const int incx, const float* y, const int incy) const;
float NRM2(const int n, const float* x, const int incx) const;
void SCAL(const int n, const float alpha, float* x, const int incx) const;
int IAMAX(const int n, const float* x, const int incx) const;
void GEMV(ETransp trans, const int m, const int n, const float alpha, const float* A, const int lda, const float* x, const int incx, const float beta, float* y, const int incy) const;
void TRMV(EUplo uplo, ETransp trans, EDiag diag, const int n, const float* A, const int lda, float* x, const int incx) const;
void GER(const int m, const int n, const float alpha, const float* x, const int incx, const float* y, const int incy, float* A, const int lda) const;
void GEMM(ETransp transa, ETransp transb, const int m, const int n, const int k, const float alpha, const float* A, const int lda, const float* B, const int ldb, const float beta, float* C, const int ldc) const;
void SWAP(const int n, float* const x, const int incx, float* const y, const int incy) const;
void SYMM(ESide side, EUplo uplo, const int m, const int n, const float alpha, const float* A, const int lda, const float *B, const int ldb, const float beta, float *C, const int ldc) const;
void SYRK(EUplo uplo, ETransp trans, const int n, const int k, const float alpha, const float* A, const int lda, const float beta, float* C, const int ldc) const;
void HERK(EUplo uplo, ETransp trans, const int n, const int k, const float alpha, const float* A, const int lda, const float beta, float* C, const int ldc) const;
void TRMM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const int m, const int n, const float alpha, const float* A, const int lda, float* B, const int ldb) const;
void TRSM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const int m, const int n, const float alpha, const float* A, const int lda, float* B, const int ldb) const;
};
// Explicit instantiation for template<int,double>
template<>
class TEUCHOSNUMERICS_LIB_DLL_EXPORT BLAS<int, double>
{
public:
inline BLAS(void) {}
inline BLAS(const BLAS<int, double>& /*BLAS_source*/) {}
inline virtual ~BLAS(void) {}
void ROTG(double* da, double* db, double* c, double* s) const;
void ROT(const int n, double* dx, const int incx, double* dy, const int incy, double* c, double* s) const;
double ASUM(const int n, const double* x, const int incx) const;
void AXPY(const int n, const double alpha, const double* x, const int incx, double* y, const int incy) const;
void COPY(const int n, const double* x, const int incx, double* y, const int incy) const;
double DOT(const int n, const double* x, const int incx, const double* y, const int incy) const;
double NRM2(const int n, const double* x, const int incx) const;
void SCAL(const int n, const double alpha, double* x, const int incx) const;
int IAMAX(const int n, const double* x, const int incx) const;
void GEMV(ETransp trans, const int m, const int n, const double alpha, const double* A, const int lda, const double* x, const int incx, const double beta, double* y, const int incy) const;
void TRMV(EUplo uplo, ETransp trans, EDiag diag, const int n, const double* A, const int lda, double* x, const int incx) const;
void GER(const int m, const int n, const double alpha, const double* x, const int incx, const double* y, const int incy, double* A, const int lda) const;
void GEMM(ETransp transa, ETransp transb, const int m, const int n, const int k, const double alpha, const double* A, const int lda, const double* B, const int ldb, const double beta, double* C, const int ldc) const;
void SWAP(const int n, double* const x, const int incx, double* const y, const int incy) const;
void SYMM(ESide side, EUplo uplo, const int m, const int n, const double alpha, const double* A, const int lda, const double *B, const int ldb, const double beta, double *C, const int ldc) const;
void SYRK(EUplo uplo, ETransp trans, const int n, const int k, const double alpha, const double* A, const int lda, const double beta, double* C, const int ldc) const;
void HERK(EUplo uplo, ETransp trans, const int n, const int k, const double alpha, const double* A, const int lda, const double beta, double* C, const int ldc) const;
void TRMM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const int m, const int n, const double alpha, const double* A, const int lda, double* B, const int ldb) const;
void TRSM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const int m, const int n, const double alpha, const double* A, const int lda, double* B, const int ldb) const;
};
// Explicit instantiation for template<int,complex<float> >
template<>
class TEUCHOSNUMERICS_LIB_DLL_EXPORT BLAS<int, std::complex<float> >
{
public:
inline BLAS(void) {}
inline BLAS(const BLAS<int, std::complex<float> >& /*BLAS_source*/) {}
inline virtual ~BLAS(void) {}
void ROTG(std::complex<float>* da, std::complex<float>* db, float* c, std::complex<float>* s) const;
void ROT(const int n, std::complex<float>* dx, const int incx, std::complex<float>* dy, const int incy, float* c, std::complex<float>* s) const;
float ASUM(const int n, const std::complex<float>* x, const int incx) const;
void AXPY(const int n, const std::complex<float> alpha, const std::complex<float>* x, const int incx, std::complex<float>* y, const int incy) const;
void COPY(const int n, const std::complex<float>* x, const int incx, std::complex<float>* y, const int incy) const;
std::complex<float> DOT(const int n, const std::complex<float>* x, const int incx, const std::complex<float>* y, const int incy) const;
float NRM2(const int n, const std::complex<float>* x, const int incx) const;
void SCAL(const int n, const std::complex<float> alpha, std::complex<float>* x, const int incx) const;
int IAMAX(const int n, const std::complex<float>* x, const int incx) const;
void GEMV(ETransp trans, const int m, const int n, const std::complex<float> alpha, const std::complex<float>* A, const int lda, const std::complex<float>* x, const int incx, const std::complex<float> beta, std::complex<float>* y, const int incy) const;
void TRMV(EUplo uplo, ETransp trans, EDiag diag, const int n, const std::complex<float>* A, const int lda, std::complex<float>* x, const int incx) const;
void GER(const int m, const int n, const std::complex<float> alpha, const std::complex<float>* x, const int incx, const std::complex<float>* y, const int incy, std::complex<float>* A, const int lda) const;
void GEMM(ETransp transa, ETransp transb, const int m, const int n, const int k, const std::complex<float> alpha, const std::complex<float>* A, const int lda, const std::complex<float>* B, const int ldb, const std::complex<float> beta, std::complex<float>* C, const int ldc) const;
void SWAP(const int n, std::complex<float>* const x, const int incx, std::complex<float>* const y, const int incy) const;
void SYMM(ESide side, EUplo uplo, const int m, const int n, const std::complex<float> alpha, const std::complex<float>* A, const int lda, const std::complex<float> *B, const int ldb, const std::complex<float> beta, std::complex<float> *C, const int ldc) const;
void SYRK(EUplo uplo, ETransp trans, const int n, const int k, const std::complex<float> alpha, const std::complex<float>* A, const int lda, const std::complex<float> beta, std::complex<float>* C, const int ldc) const;
void HERK(EUplo uplo, ETransp trans, const int n, const int k, const std::complex<float> alpha, const std::complex<float>* A, const int lda, const std::complex<float> beta, std::complex<float>* C, const int ldc) const;
void TRMM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const int m, const int n, const std::complex<float> alpha, const std::complex<float>* A, const int lda, std::complex<float>* B, const int ldb) const;
void TRSM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const int m, const int n, const std::complex<float> alpha, const std::complex<float>* A, const int lda, std::complex<float>* B, const int ldb) const;
};
// Explicit instantiation for template<int,complex<double> >
template<>
class TEUCHOSNUMERICS_LIB_DLL_EXPORT BLAS<int, std::complex<double> >
{
public:
inline BLAS(void) {}
inline BLAS(const BLAS<int, std::complex<double> >& /*BLAS_source*/) {}
inline virtual ~BLAS(void) {}
void ROTG(std::complex<double>* da, std::complex<double>* db, double* c, std::complex<double>* s) const;
void ROT(const int n, std::complex<double>* dx, const int incx, std::complex<double>* dy, const int incy, double* c, std::complex<double>* s) const;
double ASUM(const int n, const std::complex<double>* x, const int incx) const;
void AXPY(const int n, const std::complex<double> alpha, const std::complex<double>* x, const int incx, std::complex<double>* y, const int incy) const;
void COPY(const int n, const std::complex<double>* x, const int incx, std::complex<double>* y, const int incy) const;
std::complex<double> DOT(const int n, const std::complex<double>* x, const int incx, const std::complex<double>* y, const int incy) const;
double NRM2(const int n, const std::complex<double>* x, const int incx) const;
void SCAL(const int n, const std::complex<double> alpha, std::complex<double>* x, const int incx) const;
int IAMAX(const int n, const std::complex<double>* x, const int incx) const;
void GEMV(ETransp trans, const int m, const int n, const std::complex<double> alpha, const std::complex<double>* A, const int lda, const std::complex<double>* x, const int incx, const std::complex<double> beta, std::complex<double>* y, const int incy) const;
void TRMV(EUplo uplo, ETransp trans, EDiag diag, const int n, const std::complex<double>* A, const int lda, std::complex<double>* x, const int incx) const;
void GER(const int m, const int n, const std::complex<double> alpha, const std::complex<double>* x, const int incx, const std::complex<double>* y, const int incy, std::complex<double>* A, const int lda) const;
void GEMM(ETransp transa, ETransp transb, const int m, const int n, const int k, const std::complex<double> alpha, const std::complex<double>* A, const int lda, const std::complex<double>* B, const int ldb, const std::complex<double> beta, std::complex<double>* C, const int ldc) const;
void SWAP(const int n, std::complex<double>* const x, const int incx, std::complex<double>* const y, const int incy) const;
void SYMM(ESide side, EUplo uplo, const int m, const int n, const std::complex<double> alpha, const std::complex<double>* A, const int lda, const std::complex<double> *B, const int ldb, const std::complex<double> beta, std::complex<double> *C, const int ldc) const;
void SYRK(EUplo uplo, ETransp trans, const int n, const int k, const std::complex<double> alpha, const std::complex<double>* A, const int lda, const std::complex<double> beta, std::complex<double>* C, const int ldc) const;
void HERK(EUplo uplo, ETransp trans, const int n, const int k, const std::complex<double> alpha, const std::complex<double>* A, const int lda, const std::complex<double> beta, std::complex<double>* C, const int ldc) const;
void TRMM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const int m, const int n, const std::complex<double> alpha, const std::complex<double>* A, const int lda, std::complex<double>* B, const int ldb) const;
void TRSM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const int m, const int n, const std::complex<double> alpha, const std::complex<double>* A, const int lda, std::complex<double>* B, const int ldb) const;
};
} // namespace Teuchos
#endif // _TEUCHOS_BLAS_HPP_
|