dlantp.c 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. /* dlantp.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Table of constant values */
  14. static integer c__1 = 1;
  15. doublereal _starpu_dlantp_(char *norm, char *uplo, char *diag, integer *n, doublereal
  16. *ap, doublereal *work)
  17. {
  18. /* System generated locals */
  19. integer i__1, i__2;
  20. doublereal ret_val, d__1, d__2, d__3;
  21. /* Builtin functions */
  22. double sqrt(doublereal);
  23. /* Local variables */
  24. integer i__, j, k;
  25. doublereal sum, scale;
  26. logical udiag;
  27. extern logical _starpu_lsame_(char *, char *);
  28. doublereal value;
  29. extern /* Subroutine */ int _starpu_dlassq_(integer *, doublereal *, integer *,
  30. doublereal *, doublereal *);
  31. /* -- LAPACK auxiliary routine (version 3.2) -- */
  32. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  33. /* November 2006 */
  34. /* .. Scalar Arguments .. */
  35. /* .. */
  36. /* .. Array Arguments .. */
  37. /* .. */
  38. /* Purpose */
  39. /* ======= */
  40. /* DLANTP returns the value of the one norm, or the Frobenius norm, or */
  41. /* the infinity norm, or the element of largest absolute value of a */
  42. /* triangular matrix A, supplied in packed form. */
  43. /* Description */
  44. /* =========== */
  45. /* DLANTP returns the value */
  46. /* DLANTP = ( max(abs(A(i,j))), NORM = 'M' or 'm' */
  47. /* ( */
  48. /* ( norm1(A), NORM = '1', 'O' or 'o' */
  49. /* ( */
  50. /* ( normI(A), NORM = 'I' or 'i' */
  51. /* ( */
  52. /* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */
  53. /* where norm1 denotes the one norm of a matrix (maximum column sum), */
  54. /* normI denotes the infinity norm of a matrix (maximum row sum) and */
  55. /* normF denotes the Frobenius norm of a matrix (square root of sum of */
  56. /* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */
  57. /* Arguments */
  58. /* ========= */
  59. /* NORM (input) CHARACTER*1 */
  60. /* Specifies the value to be returned in DLANTP as described */
  61. /* above. */
  62. /* UPLO (input) CHARACTER*1 */
  63. /* Specifies whether the matrix A is upper or lower triangular. */
  64. /* = 'U': Upper triangular */
  65. /* = 'L': Lower triangular */
  66. /* DIAG (input) CHARACTER*1 */
  67. /* Specifies whether or not the matrix A is unit triangular. */
  68. /* = 'N': Non-unit triangular */
  69. /* = 'U': Unit triangular */
  70. /* N (input) INTEGER */
  71. /* The order of the matrix A. N >= 0. When N = 0, DLANTP is */
  72. /* set to zero. */
  73. /* AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
  74. /* The upper or lower triangular matrix A, packed columnwise in */
  75. /* a linear array. The j-th column of A is stored in the array */
  76. /* AP as follows: */
  77. /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
  78. /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
  79. /* Note that when DIAG = 'U', the elements of the array AP */
  80. /* corresponding to the diagonal elements of the matrix A are */
  81. /* not referenced, but are assumed to be one. */
  82. /* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */
  83. /* where LWORK >= N when NORM = 'I'; otherwise, WORK is not */
  84. /* referenced. */
  85. /* ===================================================================== */
  86. /* .. Parameters .. */
  87. /* .. */
  88. /* .. Local Scalars .. */
  89. /* .. */
  90. /* .. External Subroutines .. */
  91. /* .. */
  92. /* .. External Functions .. */
  93. /* .. */
  94. /* .. Intrinsic Functions .. */
  95. /* .. */
  96. /* .. Executable Statements .. */
  97. /* Parameter adjustments */
  98. --work;
  99. --ap;
  100. /* Function Body */
  101. if (*n == 0) {
  102. value = 0.;
  103. } else if (_starpu_lsame_(norm, "M")) {
  104. /* Find max(abs(A(i,j))). */
  105. k = 1;
  106. if (_starpu_lsame_(diag, "U")) {
  107. value = 1.;
  108. if (_starpu_lsame_(uplo, "U")) {
  109. i__1 = *n;
  110. for (j = 1; j <= i__1; ++j) {
  111. i__2 = k + j - 2;
  112. for (i__ = k; i__ <= i__2; ++i__) {
  113. /* Computing MAX */
  114. d__2 = value, d__3 = (d__1 = ap[i__], abs(d__1));
  115. value = max(d__2,d__3);
  116. /* L10: */
  117. }
  118. k += j;
  119. /* L20: */
  120. }
  121. } else {
  122. i__1 = *n;
  123. for (j = 1; j <= i__1; ++j) {
  124. i__2 = k + *n - j;
  125. for (i__ = k + 1; i__ <= i__2; ++i__) {
  126. /* Computing MAX */
  127. d__2 = value, d__3 = (d__1 = ap[i__], abs(d__1));
  128. value = max(d__2,d__3);
  129. /* L30: */
  130. }
  131. k = k + *n - j + 1;
  132. /* L40: */
  133. }
  134. }
  135. } else {
  136. value = 0.;
  137. if (_starpu_lsame_(uplo, "U")) {
  138. i__1 = *n;
  139. for (j = 1; j <= i__1; ++j) {
  140. i__2 = k + j - 1;
  141. for (i__ = k; i__ <= i__2; ++i__) {
  142. /* Computing MAX */
  143. d__2 = value, d__3 = (d__1 = ap[i__], abs(d__1));
  144. value = max(d__2,d__3);
  145. /* L50: */
  146. }
  147. k += j;
  148. /* L60: */
  149. }
  150. } else {
  151. i__1 = *n;
  152. for (j = 1; j <= i__1; ++j) {
  153. i__2 = k + *n - j;
  154. for (i__ = k; i__ <= i__2; ++i__) {
  155. /* Computing MAX */
  156. d__2 = value, d__3 = (d__1 = ap[i__], abs(d__1));
  157. value = max(d__2,d__3);
  158. /* L70: */
  159. }
  160. k = k + *n - j + 1;
  161. /* L80: */
  162. }
  163. }
  164. }
  165. } else if (_starpu_lsame_(norm, "O") || *(unsigned char *)
  166. norm == '1') {
  167. /* Find norm1(A). */
  168. value = 0.;
  169. k = 1;
  170. udiag = _starpu_lsame_(diag, "U");
  171. if (_starpu_lsame_(uplo, "U")) {
  172. i__1 = *n;
  173. for (j = 1; j <= i__1; ++j) {
  174. if (udiag) {
  175. sum = 1.;
  176. i__2 = k + j - 2;
  177. for (i__ = k; i__ <= i__2; ++i__) {
  178. sum += (d__1 = ap[i__], abs(d__1));
  179. /* L90: */
  180. }
  181. } else {
  182. sum = 0.;
  183. i__2 = k + j - 1;
  184. for (i__ = k; i__ <= i__2; ++i__) {
  185. sum += (d__1 = ap[i__], abs(d__1));
  186. /* L100: */
  187. }
  188. }
  189. k += j;
  190. value = max(value,sum);
  191. /* L110: */
  192. }
  193. } else {
  194. i__1 = *n;
  195. for (j = 1; j <= i__1; ++j) {
  196. if (udiag) {
  197. sum = 1.;
  198. i__2 = k + *n - j;
  199. for (i__ = k + 1; i__ <= i__2; ++i__) {
  200. sum += (d__1 = ap[i__], abs(d__1));
  201. /* L120: */
  202. }
  203. } else {
  204. sum = 0.;
  205. i__2 = k + *n - j;
  206. for (i__ = k; i__ <= i__2; ++i__) {
  207. sum += (d__1 = ap[i__], abs(d__1));
  208. /* L130: */
  209. }
  210. }
  211. k = k + *n - j + 1;
  212. value = max(value,sum);
  213. /* L140: */
  214. }
  215. }
  216. } else if (_starpu_lsame_(norm, "I")) {
  217. /* Find normI(A). */
  218. k = 1;
  219. if (_starpu_lsame_(uplo, "U")) {
  220. if (_starpu_lsame_(diag, "U")) {
  221. i__1 = *n;
  222. for (i__ = 1; i__ <= i__1; ++i__) {
  223. work[i__] = 1.;
  224. /* L150: */
  225. }
  226. i__1 = *n;
  227. for (j = 1; j <= i__1; ++j) {
  228. i__2 = j - 1;
  229. for (i__ = 1; i__ <= i__2; ++i__) {
  230. work[i__] += (d__1 = ap[k], abs(d__1));
  231. ++k;
  232. /* L160: */
  233. }
  234. ++k;
  235. /* L170: */
  236. }
  237. } else {
  238. i__1 = *n;
  239. for (i__ = 1; i__ <= i__1; ++i__) {
  240. work[i__] = 0.;
  241. /* L180: */
  242. }
  243. i__1 = *n;
  244. for (j = 1; j <= i__1; ++j) {
  245. i__2 = j;
  246. for (i__ = 1; i__ <= i__2; ++i__) {
  247. work[i__] += (d__1 = ap[k], abs(d__1));
  248. ++k;
  249. /* L190: */
  250. }
  251. /* L200: */
  252. }
  253. }
  254. } else {
  255. if (_starpu_lsame_(diag, "U")) {
  256. i__1 = *n;
  257. for (i__ = 1; i__ <= i__1; ++i__) {
  258. work[i__] = 1.;
  259. /* L210: */
  260. }
  261. i__1 = *n;
  262. for (j = 1; j <= i__1; ++j) {
  263. ++k;
  264. i__2 = *n;
  265. for (i__ = j + 1; i__ <= i__2; ++i__) {
  266. work[i__] += (d__1 = ap[k], abs(d__1));
  267. ++k;
  268. /* L220: */
  269. }
  270. /* L230: */
  271. }
  272. } else {
  273. i__1 = *n;
  274. for (i__ = 1; i__ <= i__1; ++i__) {
  275. work[i__] = 0.;
  276. /* L240: */
  277. }
  278. i__1 = *n;
  279. for (j = 1; j <= i__1; ++j) {
  280. i__2 = *n;
  281. for (i__ = j; i__ <= i__2; ++i__) {
  282. work[i__] += (d__1 = ap[k], abs(d__1));
  283. ++k;
  284. /* L250: */
  285. }
  286. /* L260: */
  287. }
  288. }
  289. }
  290. value = 0.;
  291. i__1 = *n;
  292. for (i__ = 1; i__ <= i__1; ++i__) {
  293. /* Computing MAX */
  294. d__1 = value, d__2 = work[i__];
  295. value = max(d__1,d__2);
  296. /* L270: */
  297. }
  298. } else if (_starpu_lsame_(norm, "F") || _starpu_lsame_(norm, "E")) {
  299. /* Find normF(A). */
  300. if (_starpu_lsame_(uplo, "U")) {
  301. if (_starpu_lsame_(diag, "U")) {
  302. scale = 1.;
  303. sum = (doublereal) (*n);
  304. k = 2;
  305. i__1 = *n;
  306. for (j = 2; j <= i__1; ++j) {
  307. i__2 = j - 1;
  308. _starpu_dlassq_(&i__2, &ap[k], &c__1, &scale, &sum);
  309. k += j;
  310. /* L280: */
  311. }
  312. } else {
  313. scale = 0.;
  314. sum = 1.;
  315. k = 1;
  316. i__1 = *n;
  317. for (j = 1; j <= i__1; ++j) {
  318. _starpu_dlassq_(&j, &ap[k], &c__1, &scale, &sum);
  319. k += j;
  320. /* L290: */
  321. }
  322. }
  323. } else {
  324. if (_starpu_lsame_(diag, "U")) {
  325. scale = 1.;
  326. sum = (doublereal) (*n);
  327. k = 2;
  328. i__1 = *n - 1;
  329. for (j = 1; j <= i__1; ++j) {
  330. i__2 = *n - j;
  331. _starpu_dlassq_(&i__2, &ap[k], &c__1, &scale, &sum);
  332. k = k + *n - j + 1;
  333. /* L300: */
  334. }
  335. } else {
  336. scale = 0.;
  337. sum = 1.;
  338. k = 1;
  339. i__1 = *n;
  340. for (j = 1; j <= i__1; ++j) {
  341. i__2 = *n - j + 1;
  342. _starpu_dlassq_(&i__2, &ap[k], &c__1, &scale, &sum);
  343. k = k + *n - j + 1;
  344. /* L310: */
  345. }
  346. }
  347. }
  348. value = scale * sqrt(sum);
  349. }
  350. ret_val = value;
  351. return ret_val;
  352. /* End of DLANTP */
  353. } /* _starpu_dlantp_ */