Changeset 364ccf in git for Singular/svd_si.h
- Timestamp:
- Sep 21, 2017, 3:33:15 PM (7 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- f166afac68e9933694b0ff29efc419fc621d35c4
- Parents:
- 2206a04585b4cd3234b11b58891ba713a1955554
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/svd_si.h
r2206a04 r364ccf 34 34 35 35 /******************************************************************** 36 This symbol is used for debugging. Do not define it and do not remove 37 comments. 36 This symbol is used for debugging. Do not define it and do not remove 37 comments. 38 38 ********************************************************************/ 39 39 //#define UNSAFE_MEM_COPY … … 130 130 131 131 /******************************************************************** 132 Template defining vector in memory. It is used by the basic 132 Template defining vector in memory. It is used by the basic 133 133 subroutines of linear algebra. 134 134 135 Vector consists of Length elements of type T, starting from an element, 136 which Data is pointed to. Interval between adjacent elements equals 135 Vector consists of Length elements of type T, starting from an element, 136 which Data is pointed to. Interval between adjacent elements equals 137 137 the value of Step. 138 138 … … 164 164 It is used by the basic subroutines of linear algebra. 165 165 166 Vector consists of Length elements of type T, starting from an element, 167 which Data is pointed to. Interval between adjacent elements equals 166 Vector consists of Length elements of type T, starting from an element, 167 which Data is pointed to. Interval between adjacent elements equals 168 168 the value of Step. 169 169 … … 694 694 }; 695 695 696 696 697 697 const template_1d_array& operator=(const template_1d_array &rhs) 698 698 { … … 720 720 }; 721 721 722 722 723 723 const T& operator()(int i) const 724 724 { … … 729 729 }; 730 730 731 731 732 732 T& operator()(int i) 733 733 { … … 738 738 }; 739 739 740 740 741 741 void setbounds( int iLow, int iHigh ) 742 742 { … … 749 749 }; 750 750 751 751 752 752 void setcontent( int iLow, int iHigh, const T *pContent ) 753 753 { … … 757 757 }; 758 758 759 759 760 760 T* getcontent() 761 761 { … … 768 768 }; 769 769 770 770 771 771 int getlowbound(int iBoundNum = 0) const 772 772 { … … 774 774 }; 775 775 776 776 777 777 int gethighbound(int iBoundNum = 0) const 778 778 { … … 788 788 }; 789 789 790 790 791 791 const_raw_vector<T> getvector(int iStart, int iEnd) const 792 792 { … … 1034 1034 namespace amp 1035 1035 { 1036 class exception {}; 1036 class exception {}; 1037 1037 class incorrectPrecision : public exception {}; 1038 1038 class overflow : public exception {}; … … 1043 1043 class internalError : public exception {}; 1044 1044 class domainError : public exception {}; 1045 1045 1046 1046 typedef unsigned long unsigned32; 1047 1047 typedef signed long signed32; 1048 1048 1049 1049 struct mpfr_record 1050 1050 { … … 1054 1054 mpfr_record *next; 1055 1055 }; 1056 1056 1057 1057 typedef mpfr_record* mpfr_record_ptr; 1058 1058 1059 1059 // 1060 1060 // storage for mpfr_t instances … … 1062 1062 class mpfr_storage 1063 1063 { 1064 public: 1064 public: 1065 1065 static mpfr_record* newMpfr(unsigned int Precision); 1066 1066 static void deleteMpfr(mpfr_record* ref); … … 1070 1070 static mpfr_record_ptr& getList(unsigned int Precision); 1071 1071 }; 1072 1072 1073 1073 // 1074 1074 // mpfr_t reference … … 1081 1081 mpfr_reference& operator= (const mpfr_reference &r); 1082 1082 ~mpfr_reference(); 1083 1083 1084 1084 void initialize(int Precision); 1085 1085 void free(); 1086 1086 1087 1087 mpfr_srcptr getReadPtr() const; 1088 1088 mpfr_ptr getWritePtr(); … … 1090 1090 mpfr_record *ref; 1091 1091 }; 1092 1092 1093 1093 // 1094 1094 // ampf template … … 1107 1107 mpfr_storage::deleteMpfr(rval); 1108 1108 } 1109 1109 1110 1110 // 1111 1111 // Initializing … … 1113 1113 ampf () { InitializeAsZero(); } 1114 1114 ampf(mpfr_record *v) { rval = v; } 1115 1115 1116 1116 ampf (long double v) { InitializeAsDouble(v); } 1117 1117 ampf (double v) { InitializeAsDouble(v); } … … 1125 1125 ampf (signed char v) { InitializeAsSLong(v); } 1126 1126 ampf (unsigned char v) { InitializeAsULong(v); } 1127 1127 1128 1128 // 1129 1129 // initializing from string … … 1132 1132 ampf (const std::string &s) { InitializeAsString(s.c_str()); } 1133 1133 ampf (const char *s) { InitializeAsString(s); } 1134 1134 1135 1135 // 1136 1136 // copy constructors … … 1192 1192 } 1193 1193 #endif 1194 1194 1195 1195 // 1196 1196 // in-place operators … … 1201 1201 template<class T> ampf& operator*=(const T& v){ *this = *this * v; return *this; }; 1202 1202 template<class T> ampf& operator/=(const T& v){ *this = *this / v; return *this; }; 1203 1203 1204 1204 // 1205 1205 // MPFR access … … 1207 1207 mpfr_srcptr getReadPtr() const; 1208 1208 mpfr_ptr getWritePtr(); 1209 1209 1210 1210 // 1211 1211 // properties and information … … 1224 1224 std::string toDec() const; 1225 1225 char * toString() const; 1226 1227 1226 1227 1228 1228 // 1229 1229 // static methods 1230 // 1230 // 1231 1231 static const ampf getUlpOf(const ampf &x); 1232 1232 static const ampf getUlp(); … … 1246 1246 void InitializeAsDouble(long double v); 1247 1247 void InitializeAsString(const char *s); 1248 1248 1249 1249 //mpfr_reference ref; 1250 1250 mpfr_record *rval; … … 1262 1262 if( Precision<32 ) 1263 1263 //throw incorrectPrecision(); 1264 1264 WerrorS("incorrectPrecision"); 1265 1265 } 1266 1266 … … 1280 1280 mpfr_set_si(getWritePtr(), sv, GMP_RNDN); 1281 1281 } 1282 1282 1283 1283 template<unsigned int Precision> 1284 1284 void ampf<Precision>::InitializeAsULong(unsigned long v) … … 1288 1288 mpfr_set_ui(getWritePtr(), v, GMP_RNDN); 1289 1289 } 1290 1290 1291 1291 template<unsigned int Precision> 1292 1292 void ampf<Precision>::InitializeAsDouble(long double v) … … 1303 1303 rval = mpfr_storage::newMpfr(Precision); 1304 1304 mpfr_strtofr(getWritePtr(), s, NULL, 0, GMP_RNDN); 1305 } 1305 } 1306 1306 1307 1307 template<unsigned int Precision> … … 1310 1310 return rval->value; 1311 1311 } 1312 1312 1313 1313 template<unsigned int Precision> 1314 1314 mpfr_ptr ampf<Precision>::getWritePtr() … … 1322 1322 return rval->value; 1323 1323 } 1324 1324 1325 1325 template<unsigned int Precision> 1326 1326 bool ampf<Precision>::isFiniteNumber() const … … 1336 1336 return mpfr_sgn(getReadPtr())>0; 1337 1337 } 1338 1338 1339 1339 template<unsigned int Precision> 1340 1340 bool ampf<Precision>::isZero() const … … 1342 1342 return mpfr_zero_p(getReadPtr())!=0; 1343 1343 } 1344 1344 1345 1345 template<unsigned int Precision> 1346 1346 bool ampf<Precision>::isNegativeNumber() const … … 1356 1356 return getUlpOf(*this); 1357 1357 } 1358 1358 1359 1359 template<unsigned int Precision> 1360 1360 double ampf<Precision>::toDouble() const … … 1362 1362 return mpfr_get_d(getReadPtr(), GMP_RNDN); 1363 1363 } 1364 1364 1365 1365 template<unsigned int Precision> 1366 1366 std::string ampf<Precision>::toHex() const … … 1379 1379 return r; 1380 1380 } 1381 1381 1382 1382 // 1383 1383 // general case … … 1393 1393 iexpval = expval; 1394 1394 if( iexpval!=expval ) 1395 throw internalError(); 1395 // throw internalError(); 1396 WerrorS("internalError"); 1396 1397 sprintf(buf_e, "%ld", long(iexpval)); 1397 1398 if( *ptr=='-' ) … … 1407 1408 return r; 1408 1409 } 1409 1410 1410 1411 template<unsigned int Precision> 1411 1412 std::string ampf<Precision>::toDec() const 1412 1413 { 1413 1414 // TODO: advanced output formatting (zero, integers) 1414 1415 1415 1416 // 1416 1417 // some special cases … … 1426 1427 return r; 1427 1428 } 1428 1429 1429 1430 // 1430 1431 // general case … … 1440 1441 iexpval = expval; 1441 1442 if( iexpval!=expval ) 1442 throw internalError(); 1443 // throw internalError(); 1444 WerrorS("internalError"); 1443 1445 sprintf(buf_e, "%ld", long(iexpval)); 1444 1446 if( *ptr=='-' ) … … 1470 1472 return toString_Block; 1471 1473 } 1472 1474 1473 1475 // 1474 1476 // general case … … 1485 1487 if( iexpval!=expval ) 1486 1488 //throw internalError(); 1487 1489 WerrorS("internalError"); 1488 1490 sprintf(buf_e, "%ld", long(iexpval)); 1489 1491 if( *ptr=='-' ) … … 1520 1522 return r; 1521 1523 } 1522 1524 1523 1525 template<unsigned int Precision> 1524 1526 const ampf<Precision> ampf<Precision>::getUlp() … … 1529 1531 return r; 1530 1532 } 1531 1533 1532 1534 template<unsigned int Precision> 1533 1535 const ampf<Precision> ampf<Precision>::getUlp256() … … 1543 1545 return r; 1544 1546 } 1545 1547 1546 1548 template<unsigned int Precision> 1547 1549 const ampf<Precision> ampf<Precision>::getUlp512() … … 1556 1558 GMP_RNDN); 1557 1559 return r; 1558 } 1560 } 1559 1561 1560 1562 template<unsigned int Precision> … … 1566 1568 return r; 1567 1569 } 1568 1570 1569 1571 template<unsigned int Precision> 1570 1572 const ampf<Precision> ampf<Precision>::getMinNumber() … … 1580 1582 return getUlp256(); 1581 1583 } 1582 1584 1583 1585 template<unsigned int Precision> 1584 1586 const ampf<Precision> ampf<Precision>::getAlgoPascalMaxNumber() … … 1591 1593 return r; 1592 1594 } 1593 1595 1594 1596 template<unsigned int Precision> 1595 1597 const ampf<Precision> ampf<Precision>::getAlgoPascalMinNumber() … … 1610 1612 return r; 1611 1613 } 1612 1614 1613 1615 // 1614 1616 // comparison operators … … 1625 1627 return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())!=0; 1626 1628 } 1627 1629 1628 1630 template<unsigned int Precision> 1629 1631 const bool operator<(const ampf<Precision>& op1, const ampf<Precision>& op2) … … 1631 1633 return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())<0; 1632 1634 } 1633 1635 1634 1636 template<unsigned int Precision> 1635 1637 const bool operator>(const ampf<Precision>& op1, const ampf<Precision>& op2) … … 1637 1639 return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())>0; 1638 1640 } 1639 1641 1640 1642 template<unsigned int Precision> 1641 1643 const bool operator<=(const ampf<Precision>& op1, const ampf<Precision>& op2) … … 1643 1645 return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())<=0; 1644 1646 } 1645 1647 1646 1648 template<unsigned int Precision> 1647 1649 const bool operator>=(const ampf<Precision>& op1, const ampf<Precision>& op2) … … 1649 1651 return mpfr_cmp(op1.getReadPtr(), op2.getReadPtr())>=0; 1650 1652 } 1651 1653 1652 1654 // 1653 1655 // arithmetic operators … … 1658 1660 return op1; 1659 1661 } 1660 1662 1661 1663 template<unsigned int Precision> 1662 1664 const ampf<Precision> operator-(const ampf<Precision>& op1) … … 1666 1668 return v; 1667 1669 } 1668 1670 1669 1671 template<unsigned int Precision> 1670 1672 const ampf<Precision> operator+(const ampf<Precision>& op1, const ampf<Precision>& op2) … … 1674 1676 return v; 1675 1677 } 1676 1678 1677 1679 template<unsigned int Precision> 1678 1680 const ampf<Precision> operator-(const ampf<Precision>& op1, const ampf<Precision>& op2) … … 1682 1684 return v; 1683 1685 } 1684 1685 1686 1687 1686 1688 template<unsigned int Precision> 1687 1689 const ampf<Precision> operator*(const ampf<Precision>& op1, const ampf<Precision>& op2) … … 1691 1693 return v; 1692 1694 } 1693 1695 1694 1696 template<unsigned int Precision> 1695 1697 const ampf<Precision> operator/(const ampf<Precision>& op1, const ampf<Precision>& op2) … … 1699 1701 return v; 1700 1702 } 1701 1703 1702 1704 // 1703 1705 // basic functions … … 1766 1768 mpfr_trunc(tmp.getWritePtr(), x.getReadPtr()); 1767 1769 if( mpfr_integer_p(tmp.getReadPtr())==0 ) 1768 throw invalidConversion(); 1770 //throw invalidConversion(); 1771 WerrorS("internalError"); 1769 1772 mpfr_clear_erangeflag(); 1770 1773 r = mpfr_get_si(tmp.getReadPtr(), GMP_RNDN); 1771 1774 if( mpfr_erangeflag_p()!=0 ) 1772 throw invalidConversion(); 1775 //throw invalidConversion(); 1776 WerrorS("internalError"); 1773 1777 return r; 1774 1778 } … … 1790 1794 mpfr_floor(tmp.getWritePtr(), x.getReadPtr()); 1791 1795 if( mpfr_integer_p(tmp.getReadPtr())==0 ) 1792 throw invalidConversion(); 1796 //throw invalidConversion(); 1797 WerrorS("internalError"); 1793 1798 mpfr_clear_erangeflag(); 1794 1799 r = mpfr_get_si(tmp.getReadPtr(), GMP_RNDN); 1795 1800 if( mpfr_erangeflag_p()!=0 ) 1796 throw invalidConversion(); 1801 //throw invalidConversion(); 1802 WerrorS("internalError"); 1797 1803 return r; 1798 1804 } … … 1805 1811 mpfr_ceil(tmp.getWritePtr(), x.getReadPtr()); 1806 1812 if( mpfr_integer_p(tmp.getReadPtr())==0 ) 1807 throw invalidConversion(); 1813 //throw invalidConversion(); 1814 WerrorS("internalError"); 1808 1815 mpfr_clear_erangeflag(); 1809 1816 r = mpfr_get_si(tmp.getReadPtr(), GMP_RNDN); 1810 1817 if( mpfr_erangeflag_p()!=0 ) 1811 throw invalidConversion(); 1818 //throw invalidConversion(); 1819 WerrorS("internalError"); 1812 1820 return r; 1813 1821 } … … 1820 1828 mpfr_round(tmp.getWritePtr(), x.getReadPtr()); 1821 1829 if( mpfr_integer_p(tmp.getReadPtr())==0 ) 1822 throw invalidConversion(); 1830 //throw invalidConversion(); 1831 WerrorS("internalError"); 1823 1832 mpfr_clear_erangeflag(); 1824 1833 r = mpfr_get_si(tmp.getReadPtr(), GMP_RNDN); 1825 1834 if( mpfr_erangeflag_p()!=0 ) 1826 throw invalidConversion(); 1835 //throw invalidConversion(); 1836 WerrorS("internalError"); 1827 1837 return r; 1828 1838 } … … 1834 1844 ampf<Precision> r; 1835 1845 if( !x.isFiniteNumber() ) 1836 throw invalidConversion(); 1846 //throw invalidConversion(); 1847 WerrorS("internalError"); 1837 1848 if( x.isZero() ) 1838 1849 { … … 1855 1866 return r; 1856 1867 } 1857 1868 1858 1869 // 1859 1870 // different types of arguments … … 1930 1941 __AMP_BINARY_OPF(long double) 1931 1942 #undef __AMP_BINARY_OPF 1932 1943 1933 1944 // 1934 1945 // transcendent functions … … 2015 2026 return v; 2016 2027 } 2017 2028 2018 2029 template<unsigned int Precision> 2019 2030 const ampf<Precision> log(const ampf<Precision> &x) … … 2089 2100 campf():x(0),y(0){}; 2090 2101 campf(long double v) { x=v; y=0; } 2091 campf(double v) { x=v; y=0; } 2102 campf(double v) { x=v; y=0; } 2092 2103 campf(float v) { x=v; y=0; } 2093 2104 campf(signed long v) { x=v; y=0; } … … 2138 2149 ampf<Precision> x, y; 2139 2150 }; 2140 2151 2141 2152 // 2142 2153 // complex operations … … 2145 2156 const bool operator==(const campf<Precision>& lhs, const campf<Precision>& rhs) 2146 2157 { return lhs.x==rhs.x && lhs.y==rhs.y; } 2147 2158 2148 2159 template<unsigned int Precision> 2149 2160 const bool operator!=(const campf<Precision>& lhs, const campf<Precision>& rhs) 2150 2161 { return lhs.x!=rhs.x || lhs.y!=rhs.y; } 2151 2162 2152 2163 template<unsigned int Precision> 2153 2164 const campf<Precision> operator+(const campf<Precision>& lhs) 2154 2165 { return lhs; } 2155 2166 2156 2167 template<unsigned int Precision> 2157 2168 campf<Precision>& operator+=(campf<Precision>& lhs, const campf<Precision>& rhs) 2158 2169 { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; } 2159 2170 2160 2171 template<unsigned int Precision> 2161 2172 const campf<Precision> operator+(const campf<Precision>& lhs, const campf<Precision>& rhs) 2162 2173 { campf<Precision> r = lhs; r += rhs; return r; } 2163 2174 2164 2175 template<unsigned int Precision> 2165 2176 const campf<Precision> operator-(const campf<Precision>& lhs) 2166 2177 { return campf<Precision>(-lhs.x, -lhs.y); } 2167 2178 2168 2179 template<unsigned int Precision> 2169 2180 campf<Precision>& operator-=(campf<Precision>& lhs, const campf<Precision>& rhs) 2170 2181 { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; } 2171 2182 2172 2183 template<unsigned int Precision> 2173 2184 const campf<Precision> operator-(const campf<Precision>& lhs, const campf<Precision>& rhs) 2174 2185 { campf<Precision> r = lhs; r -= rhs; return r; } 2175 2186 2176 2187 template<unsigned int Precision> 2177 2188 campf<Precision>& operator*=(campf<Precision>& lhs, const campf<Precision>& rhs) … … 2182 2193 return lhs; 2183 2194 } 2184 2195 2185 2196 template<unsigned int Precision> 2186 2197 const campf<Precision> operator*(const campf<Precision>& lhs, const campf<Precision>& rhs) 2187 2198 { campf<Precision> r = lhs; r *= rhs; return r; } 2188 2199 2189 2200 template<unsigned int Precision> 2190 2201 const campf<Precision> operator/(const campf<Precision>& lhs, const campf<Precision>& rhs) … … 2209 2220 return result; 2210 2221 } 2211 2222 2212 2223 template<unsigned int Precision> 2213 2224 campf<Precision>& operator/=(campf<Precision>& lhs, const campf<Precision>& rhs) … … 2216 2227 return lhs; 2217 2228 } 2218 2229 2219 2230 template<unsigned int Precision> 2220 2231 const ampf<Precision> abscomplex(const campf<Precision> &z) 2221 2232 { 2222 2233 ampf<Precision> w, xabs, yabs, v; 2223 2234 2224 2235 xabs = abs(z.x); 2225 2236 yabs = abs(z.y); 2226 2237 w = xabs>yabs ? xabs : yabs; 2227 v = xabs<yabs ? xabs : yabs; 2238 v = xabs<yabs ? xabs : yabs; 2228 2239 if( v==0 ) 2229 2240 return w; … … 2234 2245 } 2235 2246 } 2236 2247 2237 2248 template<unsigned int Precision> 2238 2249 const campf<Precision> conj(const campf<Precision> &z) 2239 2250 { 2240 return campf<Precision>(z.x, -z.y); 2241 } 2242 2251 return campf<Precision>(z.x, -z.y); 2252 } 2253 2243 2254 template<unsigned int Precision> 2244 2255 const campf<Precision> csqr(const campf<Precision> &z) 2245 2256 { 2246 ampf<Precision> t = z.x*z.y; 2247 return campf<Precision>(sqr(z.x)-sqr(z.y), t+t); 2248 } 2249 2257 ampf<Precision> t = z.x*z.y; 2258 return campf<Precision>(sqr(z.x)-sqr(z.y), t+t); 2259 } 2260 2250 2261 // 2251 2262 // different types of arguments … … 2293 2304 template<unsigned int Precision> bool operator==(const campf<Precision>& op1, const type& op2) { return op1.x==op2 && op1.y==0; } \ 2294 2305 template<unsigned int Precision> bool operator!=(const type& op1, const campf<Precision>& op2) { return op1!=op2.x || op2.y!=0; } \ 2295 template<unsigned int Precision> bool operator!=(const campf<Precision>& op1, const type& op2) { return op1.x!=op2 || op1.y!=0; } 2306 template<unsigned int Precision> bool operator!=(const campf<Precision>& op1, const type& op2) { return op1.x!=op2 || op1.y!=0; } 2296 2307 __AMP_BINARY_OPF(float) 2297 2308 __AMP_BINARY_OPF(double) … … 2299 2310 __AMP_BINARY_OPF(ampf<Precision>) 2300 2311 #undef __AMP_BINARY_OPF 2301 2312 2302 2313 // 2303 2314 // Real linear algebra … … 2327 2338 return r; 2328 2339 } 2329 catch(...)2330 {2331 if( r!=NULL )2332 mpfr_storage::deleteMpfr(r);2333 if( t!=NULL )2334 mpfr_storage::deleteMpfr(t);2335 throw;2336 }2340 //catch(...) 2341 //{ 2342 // if( r!=NULL ) 2343 // mpfr_storage::deleteMpfr(r); 2344 // if( t!=NULL ) 2345 // mpfr_storage::deleteMpfr(t); 2346 // throw; 2347 //} 2337 2348 } 2338 2349 … … 2353 2364 } 2354 2365 } 2355 2366 2356 2367 template<unsigned int Precision> 2357 2368 void vMoveNeg(ap::raw_vector< ampf<Precision> > vDst, ap::const_raw_vector< ampf<Precision> > vSrc) … … 2370 2381 } 2371 2382 } 2372 2383 2373 2384 template<unsigned int Precision, class T2> 2374 2385 void vMove(ap::raw_vector< ampf<Precision> > vDst, ap::const_raw_vector< ampf<Precision> > vSrc, T2 alpha) … … 2388 2399 } 2389 2400 } 2390 2401 2391 2402 template<unsigned int Precision> 2392 2403 void vAdd(ap::raw_vector< ampf<Precision> > vDst, ap::const_raw_vector< ampf<Precision> > vSrc) … … 2405 2416 } 2406 2417 } 2407 2418 2408 2419 template<unsigned int Precision, class T2> 2409 2420 void vAdd(ap::raw_vector< ampf<Precision> > vDst, ap::const_raw_vector< ampf<Precision> > vSrc, T2 alpha) … … 2424 2435 } 2425 2436 } 2426 2437 2427 2438 template<unsigned int Precision> 2428 2439 void vSub(ap::raw_vector< ampf<Precision> > vDst, ap::const_raw_vector< ampf<Precision> > vSrc) … … 2441 2452 } 2442 2453 } 2443 2454 2444 2455 template<unsigned int Precision, class T2> 2445 2456 void vSub(ap::raw_vector< ampf<Precision> > vDst, ap::const_raw_vector< ampf<Precision> > vSrc, T2 alpha) … … 2447 2458 vAdd(vDst, vSrc, -alpha); 2448 2459 } 2449 2460 2450 2461 template<unsigned int Precision, class T2> 2451 2462 void vMul(ap::raw_vector< ampf<Precision> > vDst, T2 alpha) … … 2462 2473 } 2463 2474 } 2464 2475 2465 2476 #endif 2466 2477 … … 2587 2598 2588 2599 2589 2600 2590 2601 // 2591 2602 // Executable Statements .. … … 2596 2607 return; 2597 2608 } 2598 2609 2599 2610 // 2600 2611 // XNORM = DNRM2( N-1, X, INCX ) … … 2617 2628 if( xnorm==0 ) 2618 2629 { 2619 2630 2620 2631 // 2621 2632 // H = I … … 2624 2635 return; 2625 2636 } 2626 2637 2627 2638 // 2628 2639 // general case … … 2688 2699 return; 2689 2700 } 2690 2701 2691 2702 // 2692 2703 // w := C' * v … … 2702 2713 ap::vadd(work.getvector(n1, n2), c.getrow(i, n1, n2), t); 2703 2714 } 2704 2715 2705 2716 // 2706 2717 // C := C - tau * v * w' … … 2761 2772 return; 2762 2773 } 2763 2774 2764 2775 // 2765 2776 // w := C * v … … 2771 2782 work(i) = t; 2772 2783 } 2773 2784 2774 2785 // 2775 2786 // C := C - w * v' … … 2992 3003 2993 3004 2994 3005 2995 3006 // 2996 3007 // Prepare … … 3016 3027 if( m>=n ) 3017 3028 { 3018 3029 3019 3030 // 3020 3031 // Reduce to upper bidiagonal form … … 3022 3033 for(i=0; i<=n-1; i++) 3023 3034 { 3024 3035 3025 3036 // 3026 3037 // Generate elementary reflector H(i) to annihilate A(i+1:m-1,i) … … 3031 3042 ap::vmove(a.getcolumn(i, i, m-1), t.getvector(1, m-i)); 3032 3043 t(1) = 1; 3033 3044 3034 3045 // 3035 3046 // Apply H(i) to A(i:m-1,i+1:n-1) from the left … … 3038 3049 if( i<n-1 ) 3039 3050 { 3040 3051 3041 3052 // 3042 3053 // Generate elementary reflector G(i) to annihilate … … 3048 3059 ap::vmove(a.getrow(i, i+1, n-1), t.getvector(1, n-1-i)); 3049 3060 t(1) = 1; 3050 3061 3051 3062 // 3052 3063 // Apply G(i) to A(i+1:m-1,i+1:n-1) from the right … … 3062 3073 else 3063 3074 { 3064 3075 3065 3076 // 3066 3077 // Reduce to lower bidiagonal form … … 3068 3079 for(i=0; i<=m-1; i++) 3069 3080 { 3070 3081 3071 3082 // 3072 3083 // Generate elementary reflector G(i) to annihilate A(i,i+1:n-1) … … 3077 3088 ap::vmove(a.getrow(i, i, n-1), t.getvector(1, n-i)); 3078 3089 t(1) = 1; 3079 3090 3080 3091 // 3081 3092 // Apply G(i) to A(i+1:m-1,i:n-1) from the right … … 3084 3095 if( i<m-1 ) 3085 3096 { 3086 3097 3087 3098 // 3088 3099 // Generate elementary reflector H(i) to annihilate … … 3094 3105 ap::vmove(a.getcolumn(i, i+1, m-1), t.getvector(1, m-1-i)); 3095 3106 t(1) = 1; 3096 3107 3097 3108 // 3098 3109 // Apply H(i) to A(i+1:m-1,i+1:n-1) from the left … … 3148 3159 return; 3149 3160 } 3150 3161 3151 3162 // 3152 3163 // prepare Q … … 3167 3178 } 3168 3179 } 3169 3180 3170 3181 // 3171 3182 // Calculate … … 3229 3240 } 3230 3241 ap::ap_error::make_assertion(fromtheright && zcolumns==m || !fromtheright && zrows==m); 3231 3242 3232 3243 // 3233 3244 // init … … 3240 3251 if( m>=n ) 3241 3252 { 3242 3253 3243 3254 // 3244 3255 // setup … … 3263 3274 istep = -istep; 3264 3275 } 3265 3276 3266 3277 // 3267 3278 // Process … … 3286 3297 else 3287 3298 { 3288 3299 3289 3300 // 3290 3301 // setup … … 3309 3320 istep = -istep; 3310 3321 } 3311 3322 3312 3323 // 3313 3324 // Process … … 3375 3386 return; 3376 3387 } 3377 3388 3378 3389 // 3379 3390 // prepare PT … … 3394 3405 } 3395 3406 } 3396 3407 3397 3408 // 3398 3409 // Calculate … … 3456 3467 } 3457 3468 ap::ap_error::make_assertion(fromtheright && zcolumns==n || !fromtheright && zrows==n); 3458 3469 3459 3470 // 3460 3471 // init … … 3469 3480 if( m>=n ) 3470 3481 { 3471 3482 3472 3483 // 3473 3484 // setup … … 3492 3503 istep = -istep; 3493 3504 } 3494 3505 3495 3506 // 3496 3507 // Process … … 3518 3529 else 3519 3530 { 3520 3531 3521 3532 // 3522 3533 // setup … … 3541 3552 istep = -istep; 3542 3553 } 3543 3554 3544 3555 // 3545 3556 // Process … … 3660 3671 if( m>=n ) 3661 3672 { 3662 3673 3663 3674 // 3664 3675 // Reduce to upper bidiagonal form … … 3666 3677 for(i=1; i<=n; i++) 3667 3678 { 3668 3679 3669 3680 // 3670 3681 // Generate elementary reflector H(i) to annihilate A(i+1:m,i) … … 3676 3687 ap::vmove(a.getcolumn(i, i, m), t.getvector(1, mmip1)); 3677 3688 t(1) = 1; 3678 3689 3679 3690 // 3680 3691 // Apply H(i) to A(i:m,i+1:n) from the left … … 3683 3694 if( i<n ) 3684 3695 { 3685 3696 3686 3697 // 3687 3698 // Generate elementary reflector G(i) to annihilate … … 3695 3706 ap::vmove(a.getrow(i, ip1, n), t.getvector(1, nmi)); 3696 3707 t(1) = 1; 3697 3708 3698 3709 // 3699 3710 // Apply G(i) to A(i+1:m,i+1:n) from the right … … 3709 3720 else 3710 3721 { 3711 3722 3712 3723 // 3713 3724 // Reduce to lower bidiagonal form … … 3715 3726 for(i=1; i<=m; i++) 3716 3727 { 3717 3728 3718 3729 // 3719 3730 // Generate elementary reflector G(i) to annihilate A(i,i+1:n) … … 3725 3736 ap::vmove(a.getrow(i, i, n), t.getvector(1, nmip1)); 3726 3737 t(1) = 1; 3727 3738 3728 3739 // 3729 3740 // Apply G(i) to A(i+1:m,i:n) from the right … … 3732 3743 if( i<m ) 3733 3744 { 3734 3745 3735 3746 // 3736 3747 // Generate elementary reflector H(i) to annihilate … … 3744 3755 ap::vmove(a.getcolumn(i, ip1, m), t.getvector(1, mmi)); 3745 3756 t(1) = 1; 3746 3757 3747 3758 // 3748 3759 // Apply H(i) to A(i+1:m,i+1:n) from the left … … 3784 3795 return; 3785 3796 } 3786 3797 3787 3798 // 3788 3799 // init … … 3791 3802 v.setbounds(1, m); 3792 3803 work.setbounds(1, qcolumns); 3793 3804 3794 3805 // 3795 3806 // prepare Q … … 3864 3875 } 3865 3876 ap::ap_error::make_assertion(fromtheright && zcolumns==m || !fromtheright && zrows==m); 3866 3877 3867 3878 // 3868 3879 // init … … 3875 3886 if( m>=n ) 3876 3887 { 3877 3888 3878 3889 // 3879 3890 // setup … … 3898 3909 istep = -istep; 3899 3910 } 3900 3911 3901 3912 // 3902 3913 // Process … … 3922 3933 else 3923 3934 { 3924 3935 3925 3936 // 3926 3937 // setup … … 3945 3956 istep = -istep; 3946 3957 } 3947 3958 3948 3959 // 3949 3960 // Process … … 3999 4010 return; 4000 4011 } 4001 4012 4002 4013 // 4003 4014 // init … … 4006 4017 v.setbounds(1, n); 4007 4018 work.setbounds(1, ptrows); 4008 4019 4009 4020 // 4010 4021 // prepare PT … … 4079 4090 } 4080 4091 ap::ap_error::make_assertion(fromtheright && zcolumns==n || !fromtheright && zrows==n); 4081 4092 4082 4093 // 4083 4094 // init … … 4092 4103 if( m>=n ) 4093 4104 { 4094 4105 4095 4106 // 4096 4107 // setup … … 4115 4126 istep = -istep; 4116 4127 } 4117 4128 4118 4129 // 4119 4130 // Process … … 4143 4154 else 4144 4155 { 4145 4156 4146 4157 // 4147 4158 // setup … … 4166 4177 istep = -istep; 4167 4178 } 4168 4179 4169 4180 // 4170 4181 // Process … … 4380 4391 t.setbounds(1, m); 4381 4392 tau.setbounds(0, minmn-1); 4382 4393 4383 4394 // 4384 4395 // Test the input arguments … … 4387 4398 for(i=0; i<=k-1; i++) 4388 4399 { 4389 4400 4390 4401 // 4391 4402 // Generate elementary reflector H(i) to annihilate A(i+1:m,i) … … 4398 4409 if( i<n ) 4399 4410 { 4400 4411 4401 4412 // 4402 4413 // Apply H(i) to A(i:m-1,i+1:n-1) from the left … … 4449 4460 return; 4450 4461 } 4451 4462 4452 4463 // 4453 4464 // init … … 4472 4483 } 4473 4484 } 4474 4485 4475 4486 // 4476 4487 // unpack Q … … 4478 4489 for(i=k-1; i>=0; i--) 4479 4490 { 4480 4491 4481 4492 // 4482 4493 // Apply H(i) … … 4557 4568 t.setbounds(1, m); 4558 4569 tau.setbounds(1, minmn); 4559 4570 4560 4571 // 4561 4572 // Test the input arguments … … 4564 4575 for(i=1; i<=k; i++) 4565 4576 { 4566 4577 4567 4578 // 4568 4579 // Generate elementary reflector H(i) to annihilate A(i+1:m,i) … … 4576 4587 if( i<n ) 4577 4588 { 4578 4589 4579 4590 // 4580 4591 // Apply H(i) to A(i:m,i+1:n) from the left … … 4611 4622 return; 4612 4623 } 4613 4624 4614 4625 // 4615 4626 // init … … 4634 4645 } 4635 4646 } 4636 4647 4637 4648 // 4638 4649 // unpack Q … … 4640 4651 for(i=k; i>=1; i--) 4641 4652 { 4642 4653 4643 4654 // 4644 4655 // Apply H(i) … … 4678 4689 q.setbounds(1, m, 1, m); 4679 4690 r.setbounds(1, m, 1, n); 4680 4691 4681 4692 // 4682 4693 // QRDecomposition 4683 4694 // 4684 4695 qrdecomposition<Precision>(a, m, n, tau); 4685 4696 4686 4697 // 4687 4698 // R … … 4699 4710 ap::vmove(r.getrow(i, i, n), a.getrow(i, i, n)); 4700 4711 } 4701 4712 4702 4713 // 4703 4714 // Q … … 4842 4853 for(i=0; i<=k-1; i++) 4843 4854 { 4844 4855 4845 4856 // 4846 4857 // Generate elementary reflector H(i) to annihilate A(i,i+1:n-1) … … 4853 4864 if( i<n ) 4854 4865 { 4855 4866 4856 4867 // 4857 4868 // Apply H(i) to A(i+1:m,i:n) from the right … … 4904 4915 return; 4905 4916 } 4906 4917 4907 4918 // 4908 4919 // init … … 4927 4938 } 4928 4939 } 4929 4940 4930 4941 // 4931 4942 // unpack Q … … 4933 4944 for(i=k-1; i>=0; i--) 4934 4945 { 4935 4946 4936 4947 // 4937 4948 // Apply H(i) … … 5015 5026 t.setbounds(1, n); 5016 5027 tau.setbounds(1, minmn); 5017 5028 5018 5029 // 5019 5030 // Test the input arguments … … 5022 5033 for(i=1; i<=k; i++) 5023 5034 { 5024 5035 5025 5036 // 5026 5037 // Generate elementary reflector H(i) to annihilate A(i,i+1:n) … … 5034 5045 if( i<n ) 5035 5046 { 5036 5047 5037 5048 // 5038 5049 // Apply H(i) to A(i+1:m,i:n) from the right … … 5070 5081 return; 5071 5082 } 5072 5083 5073 5084 // 5074 5085 // init … … 5093 5104 } 5094 5105 } 5095 5106 5096 5107 // 5097 5108 // unpack Q … … 5099 5110 for(i=k; i>=1; i--) 5100 5111 { 5101 5112 5102 5113 // 5103 5114 // Apply H(i) … … 5132 5143 q.setbounds(1, n, 1, n); 5133 5144 l.setbounds(1, m, 1, n); 5134 5145 5135 5146 // 5136 5147 // LQDecomposition 5137 5148 // 5138 5149 lqdecomposition<Precision>(a, m, n, tau); 5139 5150 5140 5151 // 5141 5152 // L … … 5155 5166 } 5156 5167 } 5157 5168 5158 5169 // 5159 5170 // Q … … 5566 5577 if( !trans ) 5567 5578 { 5568 5579 5569 5580 // 5570 5581 // y := alpha*A*x + beta*y; … … 5576 5587 ap::ap_error::make_assertion(j2-j1==ix2-ix1); 5577 5588 ap::ap_error::make_assertion(i2-i1==iy2-iy1); 5578 5589 5579 5590 // 5580 5591 // beta*y … … 5591 5602 ap::vmul(y.getvector(iy1, iy2), beta); 5592 5603 } 5593 5604 5594 5605 // 5595 5606 // alpha*A*x … … 5603 5614 else 5604 5615 { 5605 5616 5606 5617 // 5607 5618 // y := alpha*A'*x + beta*y; … … 5613 5624 ap::ap_error::make_assertion(i2-i1==ix2-ix1); 5614 5625 ap::ap_error::make_assertion(j2-j1==iy2-iy1); 5615 5626 5616 5627 // 5617 5628 // beta*y … … 5628 5639 ap::vmul(y.getvector(iy1, iy2), beta); 5629 5640 } 5630 5641 5631 5642 // 5632 5643 // alpha*A'*x … … 5704 5715 5705 5716 5706 5717 5707 5718 // 5708 5719 // Setup … … 5735 5746 crows = arows; 5736 5747 ccols = bcols; 5737 5748 5738 5749 // 5739 5750 // Test WORK … … 5744 5755 work(1) = 0; 5745 5756 work(i) = 0; 5746 5757 5747 5758 // 5748 5759 // Prepare C … … 5765 5776 } 5766 5777 } 5767 5778 5768 5779 // 5769 5780 // A*B … … 5782 5793 return; 5783 5794 } 5784 5795 5785 5796 // 5786 5797 // A*B' … … 5813 5824 } 5814 5825 } 5815 5826 5816 5827 // 5817 5828 // A'*B … … 5830 5841 return; 5831 5842 } 5832 5843 5833 5844 // 5834 5845 // A'*B' … … 5994 6005 return; 5995 6006 } 5996 6007 5997 6008 // 5998 6009 // Form P * A … … 6002 6013 if( n1!=n2 ) 6003 6014 { 6004 6015 6005 6016 // 6006 6017 // Common case: N1<>N2 … … 6023 6034 else 6024 6035 { 6025 6036 6026 6037 // 6027 6038 // Special case: N1=N2 … … 6044 6055 if( n1!=n2 ) 6045 6056 { 6046 6057 6047 6058 // 6048 6059 // Common case: N1<>N2 … … 6065 6076 else 6066 6077 { 6067 6078 6068 6079 // 6069 6080 // Special case: N1=N2 … … 6128 6139 6129 6140 6130 6141 6131 6142 // 6132 6143 // Form A * P' … … 6136 6147 if( m1!=m2 ) 6137 6148 { 6138 6149 6139 6150 // 6140 6151 // Common case: M1<>M2 … … 6157 6168 else 6158 6169 { 6159 6170 6160 6171 // 6161 6172 // Special case: M1=M2 … … 6178 6189 if( m1!=m2 ) 6179 6190 { 6180 6191 6181 6192 // 6182 6193 // Common case: M1<>M2 … … 6199 6210 else 6200 6211 { 6201 6212 6202 6213 // 6203 6214 // Special case: M1=M2 … … 6618 6629 return result; 6619 6630 } 6620 6631 6621 6632 // 6622 6633 // init … … 6635 6646 rightside = true; 6636 6647 fwddir = true; 6637 6648 6638 6649 // 6639 6650 // resize E from N-1 to N … … 6651 6662 e(n) = 0; 6652 6663 idir = 0; 6653 6664 6654 6665 // 6655 6666 // Get machine constants … … 6657 6668 eps = amp::ampf<Precision>::getAlgoPascalEpsilon(); 6658 6669 unfl = amp::ampf<Precision>::getAlgoPascalMinNumber(); 6659 6670 6660 6671 // 6661 6672 // If matrix lower bidiagonal, rotate to be upper bidiagonal … … 6673 6684 work1(i) = sn; 6674 6685 } 6675 6686 6676 6687 // 6677 6688 // Update singular vectors if desired … … 6686 6697 } 6687 6698 } 6688 6699 6689 6700 // 6690 6701 // Compute singular values to relative accuracy TOL … … 6698 6709 tol = -tol; 6699 6710 } 6700 6711 6701 6712 // 6702 6713 // Compute approximate maximum, minimum singular values … … 6714 6725 if( tol>=0 ) 6715 6726 { 6716 6727 6717 6728 // 6718 6729 // Relative accuracy desired … … 6737 6748 else 6738 6749 { 6739 6750 6740 6751 // 6741 6752 // Absolute accuracy desired … … 6743 6754 thresh = amp::maximum<Precision>(amp::abs<Precision>(tol)*smax, maxitr*n*n*unfl); 6744 6755 } 6745 6756 6746 6757 // 6747 6758 // Prepare for main iteration loop for the singular values … … 6753 6764 oldll = -1; 6754 6765 oldm = -1; 6755 6766 6756 6767 // 6757 6768 // M points to last element of unconverged part of matrix 6758 6769 // 6759 6770 m = n; 6760 6771 6761 6772 // 6762 6773 // Begin main iteration loop … … 6764 6775 while( true ) 6765 6776 { 6766 6777 6767 6778 // 6768 6779 // Check for convergence or exceeding iteration count … … 6777 6788 return result; 6778 6789 } 6779 6790 6780 6791 // 6781 6792 // Find diagonal block of matrix to work on … … 6811 6822 else 6812 6823 { 6813 6824 6814 6825 // 6815 6826 // Matrix splits since E(LL) = 0 … … 6818 6829 if( ll==m-1 ) 6819 6830 { 6820 6831 6821 6832 // 6822 6833 // Convergence of bottom singular value, return to top of loop … … 6827 6838 } 6828 6839 ll = ll+1; 6829 6840 6830 6841 // 6831 6842 // E(LL) through E(M-1) are nonzero, E(LL-1) is zero … … 6833 6844 if( ll==m-1 ) 6834 6845 { 6835 6846 6836 6847 // 6837 6848 // 2 by 2 block, handle separately … … 6841 6852 e(m-1) = 0; 6842 6853 d(m) = sigmn; 6843 6854 6844 6855 // 6845 6856 // Compute singular vectors, if desired … … 6878 6889 continue; 6879 6890 } 6880 6891 6881 6892 // 6882 6893 // If working on new submatrix, choose shift direction … … 6901 6912 if( amp::abs<Precision>(d(ll))>=amp::abs<Precision>(d(m)) ) 6902 6913 { 6903 6914 6904 6915 // 6905 6916 // Chase bulge from top (big end) to bottom (small end) … … 6909 6920 else 6910 6921 { 6911 6922 6912 6923 // 6913 6924 // Chase bulge from bottom (big end) to top (small end) … … 6916 6927 } 6917 6928 } 6918 6929 6919 6930 // 6920 6931 // Apply convergence tests … … 6922 6933 if( idir==1 ) 6923 6934 { 6924 6935 6925 6936 // 6926 6937 // Run convergence test in forward direction … … 6934 6945 if( tol>=0 ) 6935 6946 { 6936 6947 6937 6948 // 6938 6949 // If relative accuracy desired, … … 6962 6973 else 6963 6974 { 6964 6975 6965 6976 // 6966 6977 // Run convergence test in backward direction … … 6974 6985 if( tol>=0 ) 6975 6986 { 6976 6987 6977 6988 // 6978 6989 // If relative accuracy desired, … … 7002 7013 oldll = ll; 7003 7014 oldm = m; 7004 7015 7005 7016 // 7006 7017 // Compute shift. First, test if shifting would ruin relative … … 7009 7020 if( tol>=0 && n*tol*(sminl/smax)<=amp::maximum<Precision>(eps, amp::ampf<Precision>("0.01")*tol) ) 7010 7021 { 7011 7022 7012 7023 // 7013 7024 // Use a zero shift to avoid loss of relative accuracy … … 7017 7028 else 7018 7029 { 7019 7030 7020 7031 // 7021 7032 // Compute the shift from 2-by-2 block at end of matrix … … 7031 7042 svd2x2<Precision>(d(ll), e(ll), d(ll+1), shift, r); 7032 7043 } 7033 7044 7034 7045 // 7035 7046 // Test if shift negligible, and if so set to zero … … 7043 7054 } 7044 7055 } 7045 7056 7046 7057 // 7047 7058 // Increment iteration count 7048 7059 // 7049 7060 iter = iter+m-ll; 7050 7061 7051 7062 // 7052 7063 // If SHIFT = 0, do simplified QR iteration … … 7056 7067 if( idir==1 ) 7057 7068 { 7058 7069 7059 7070 // 7060 7071 // Chase bulge from top to bottom … … 7080 7091 d(m) = h*oldcs; 7081 7092 e(m-1) = h*oldsn; 7082 7093 7083 7094 // 7084 7095 // Update singular vectors … … 7096 7107 rotations::applyrotationsfromtheleft<Precision>(fwddir, ll+cstart-1, m+cstart-1, cstart, cend, work2, work3, c, ctemp); 7097 7108 } 7098 7109 7099 7110 // 7100 7111 // Test convergence … … 7107 7118 else 7108 7119 { 7109 7120 7110 7121 // 7111 7122 // Chase bulge from bottom to top … … 7131 7142 d(ll) = h*oldcs; 7132 7143 e(ll) = h*oldsn; 7133 7144 7134 7145 // 7135 7146 // Update singular vectors … … 7147 7158 rotations::applyrotationsfromtheleft<Precision>(!fwddir, ll+cstart-1, m+cstart-1, cstart, cend, work0, work1, c, ctemp); 7148 7159 } 7149 7160 7150 7161 // 7151 7162 // Test convergence … … 7159 7170 else 7160 7171 { 7161 7172 7162 7173 // 7163 7174 // Use nonzero shift … … 7165 7176 if( idir==1 ) 7166 7177 { 7167 7178 7168 7179 // 7169 7180 // Chase bulge from top to bottom … … 7198 7209 } 7199 7210 e(m-1) = f; 7200 7211 7201 7212 // 7202 7213 // Update singular vectors … … 7214 7225 rotations::applyrotationsfromtheleft<Precision>(fwddir, ll+cstart-1, m+cstart-1, cstart, cend, work2, work3, c, ctemp); 7215 7226 } 7216 7227 7217 7228 // 7218 7229 // Test convergence … … 7225 7236 else 7226 7237 { 7227 7238 7228 7239 // 7229 7240 // Chase bulge from bottom to top … … 7258 7269 } 7259 7270 e(ll) = f; 7260 7271 7261 7272 // 7262 7273 // Test convergence … … 7266 7277 e(ll) = 0; 7267 7278 } 7268 7279 7269 7280 // 7270 7281 // Update singular vectors if desired … … 7284 7295 } 7285 7296 } 7286 7297 7287 7298 // 7288 7299 // QR iteration finished, go back and check convergence … … 7290 7301 continue; 7291 7302 } 7292 7303 7293 7304 // 7294 7305 // All singular values converged, so make them positive … … 7299 7310 { 7300 7311 d(i) = -d(i); 7301 7312 7302 7313 // 7303 7314 // Change sign of singular vectors, if desired … … 7309 7320 } 7310 7321 } 7311 7322 7312 7323 // 7313 7324 // Sort the singular values into decreasing order (insertion sort on … … 7316 7327 for(i=1; i<=n-1; i++) 7317 7328 { 7318 7329 7319 7330 // 7320 7331 // Scan for smallest D(I) … … 7332 7343 if( isub!=n+1-i ) 7333 7344 { 7334 7345 7335 7346 // 7336 7347 // Swap singular values and vectors … … 7435 7446 if( au==0 ) 7436 7447 { 7437 7448 7438 7449 // 7439 7450 // Avoid possible harmful underflow if exponent range … … 7500 7511 ht = h; 7501 7512 ha = amp::abs<Precision>(h); 7502 7513 7503 7514 // 7504 7515 // PMAX points to the maximum absolute element of matrix … … 7511 7522 if( swp ) 7512 7523 { 7513 7524 7514 7525 // 7515 7526 // Now FA .ge. HA … … 7527 7538 if( ga==0 ) 7528 7539 { 7529 7540 7530 7541 // 7531 7542 // Diagonal matrix … … 7546 7557 if( fa/ga<amp::ampf<Precision>::getAlgoPascalEpsilon() ) 7547 7558 { 7548 7559 7549 7560 // 7550 7561 // Case of very large GA … … 7570 7581 if( gasmal ) 7571 7582 { 7572 7583 7573 7584 // 7574 7585 // Normal case … … 7601 7612 if( mm==0 ) 7602 7613 { 7603 7614 7604 7615 // 7605 7616 // Note that M is very tiny … … 7640 7651 snr = srt; 7641 7652 } 7642 7653 7643 7654 // 7644 7655 // Correct signs of SSMAX and SSMIN
Note: See TracChangeset
for help on using the changeset viewer.