/min-dgels/base/SRC/dlantr.c

https://bitbucket.org/jeromerobert/starpu · C · 398 lines · 223 code · 39 blank · 136 comment · 70 complexity · cb82a04216daa81c5fb0606230b877de MD5 · raw file

  1. /* dlantr.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 dlantr_(char *norm, char *uplo, char *diag, integer *m, integer *n,
  16. doublereal *a, integer *lda, doublereal *work)
  17. {
  18. /* System generated locals */
  19. integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
  20. doublereal ret_val, d__1, d__2, d__3;
  21. /* Builtin functions */
  22. double sqrt(doublereal);
  23. /* Local variables */
  24. integer i__, j;
  25. doublereal sum, scale;
  26. logical udiag;
  27. extern logical lsame_(char *, char *);
  28. doublereal value;
  29. extern /* Subroutine */ int 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. /* DLANTR 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. /* trapezoidal or triangular matrix A. */
  43. /* Description */
  44. /* =========== */
  45. /* DLANTR returns the value */
  46. /* DLANTR = ( 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 DLANTR as described */
  61. /* above. */
  62. /* UPLO (input) CHARACTER*1 */
  63. /* Specifies whether the matrix A is upper or lower trapezoidal. */
  64. /* = 'U': Upper trapezoidal */
  65. /* = 'L': Lower trapezoidal */
  66. /* Note that A is triangular instead of trapezoidal if M = N. */
  67. /* DIAG (input) CHARACTER*1 */
  68. /* Specifies whether or not the matrix A has unit diagonal. */
  69. /* = 'N': Non-unit diagonal */
  70. /* = 'U': Unit diagonal */
  71. /* M (input) INTEGER */
  72. /* The number of rows of the matrix A. M >= 0, and if */
  73. /* UPLO = 'U', M <= N. When M = 0, DLANTR is set to zero. */
  74. /* N (input) INTEGER */
  75. /* The number of columns of the matrix A. N >= 0, and if */
  76. /* UPLO = 'L', N <= M. When N = 0, DLANTR is set to zero. */
  77. /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */
  78. /* The trapezoidal matrix A (A is triangular if M = N). */
  79. /* If UPLO = 'U', the leading m by n upper trapezoidal part of */
  80. /* the array A contains the upper trapezoidal matrix, and the */
  81. /* strictly lower triangular part of A is not referenced. */
  82. /* If UPLO = 'L', the leading m by n lower trapezoidal part of */
  83. /* the array A contains the lower trapezoidal matrix, and the */
  84. /* strictly upper triangular part of A is not referenced. Note */
  85. /* that when DIAG = 'U', the diagonal elements of A are not */
  86. /* referenced and are assumed to be one. */
  87. /* LDA (input) INTEGER */
  88. /* The leading dimension of the array A. LDA >= max(M,1). */
  89. /* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */
  90. /* where LWORK >= M when NORM = 'I'; otherwise, WORK is not */
  91. /* referenced. */
  92. /* ===================================================================== */
  93. /* .. Parameters .. */
  94. /* .. */
  95. /* .. Local Scalars .. */
  96. /* .. */
  97. /* .. External Subroutines .. */
  98. /* .. */
  99. /* .. External Functions .. */
  100. /* .. */
  101. /* .. Intrinsic Functions .. */
  102. /* .. */
  103. /* .. Executable Statements .. */
  104. /* Parameter adjustments */
  105. a_dim1 = *lda;
  106. a_offset = 1 + a_dim1;
  107. a -= a_offset;
  108. --work;
  109. /* Function Body */
  110. if (min(*m,*n) == 0) {
  111. value = 0.;
  112. } else if (lsame_(norm, "M")) {
  113. /* Find max(abs(A(i,j))). */
  114. if (lsame_(diag, "U")) {
  115. value = 1.;
  116. if (lsame_(uplo, "U")) {
  117. i__1 = *n;
  118. for (j = 1; j <= i__1; ++j) {
  119. /* Computing MIN */
  120. i__3 = *m, i__4 = j - 1;
  121. i__2 = min(i__3,i__4);
  122. for (i__ = 1; i__ <= i__2; ++i__) {
  123. /* Computing MAX */
  124. d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs(
  125. d__1));
  126. value = max(d__2,d__3);
  127. /* L10: */
  128. }
  129. /* L20: */
  130. }
  131. } else {
  132. i__1 = *n;
  133. for (j = 1; j <= i__1; ++j) {
  134. i__2 = *m;
  135. for (i__ = j + 1; i__ <= i__2; ++i__) {
  136. /* Computing MAX */
  137. d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs(
  138. d__1));
  139. value = max(d__2,d__3);
  140. /* L30: */
  141. }
  142. /* L40: */
  143. }
  144. }
  145. } else {
  146. value = 0.;
  147. if (lsame_(uplo, "U")) {
  148. i__1 = *n;
  149. for (j = 1; j <= i__1; ++j) {
  150. i__2 = min(*m,j);
  151. for (i__ = 1; i__ <= i__2; ++i__) {
  152. /* Computing MAX */
  153. d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs(
  154. d__1));
  155. value = max(d__2,d__3);
  156. /* L50: */
  157. }
  158. /* L60: */
  159. }
  160. } else {
  161. i__1 = *n;
  162. for (j = 1; j <= i__1; ++j) {
  163. i__2 = *m;
  164. for (i__ = j; i__ <= i__2; ++i__) {
  165. /* Computing MAX */
  166. d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs(
  167. d__1));
  168. value = max(d__2,d__3);
  169. /* L70: */
  170. }
  171. /* L80: */
  172. }
  173. }
  174. }
  175. } else if (lsame_(norm, "O") || *(unsigned char *)
  176. norm == '1') {
  177. /* Find norm1(A). */
  178. value = 0.;
  179. udiag = lsame_(diag, "U");
  180. if (lsame_(uplo, "U")) {
  181. i__1 = *n;
  182. for (j = 1; j <= i__1; ++j) {
  183. if (udiag && j <= *m) {
  184. sum = 1.;
  185. i__2 = j - 1;
  186. for (i__ = 1; i__ <= i__2; ++i__) {
  187. sum += (d__1 = a[i__ + j * a_dim1], abs(d__1));
  188. /* L90: */
  189. }
  190. } else {
  191. sum = 0.;
  192. i__2 = min(*m,j);
  193. for (i__ = 1; i__ <= i__2; ++i__) {
  194. sum += (d__1 = a[i__ + j * a_dim1], abs(d__1));
  195. /* L100: */
  196. }
  197. }
  198. value = max(value,sum);
  199. /* L110: */
  200. }
  201. } else {
  202. i__1 = *n;
  203. for (j = 1; j <= i__1; ++j) {
  204. if (udiag) {
  205. sum = 1.;
  206. i__2 = *m;
  207. for (i__ = j + 1; i__ <= i__2; ++i__) {
  208. sum += (d__1 = a[i__ + j * a_dim1], abs(d__1));
  209. /* L120: */
  210. }
  211. } else {
  212. sum = 0.;
  213. i__2 = *m;
  214. for (i__ = j; i__ <= i__2; ++i__) {
  215. sum += (d__1 = a[i__ + j * a_dim1], abs(d__1));
  216. /* L130: */
  217. }
  218. }
  219. value = max(value,sum);
  220. /* L140: */
  221. }
  222. }
  223. } else if (lsame_(norm, "I")) {
  224. /* Find normI(A). */
  225. if (lsame_(uplo, "U")) {
  226. if (lsame_(diag, "U")) {
  227. i__1 = *m;
  228. for (i__ = 1; i__ <= i__1; ++i__) {
  229. work[i__] = 1.;
  230. /* L150: */
  231. }
  232. i__1 = *n;
  233. for (j = 1; j <= i__1; ++j) {
  234. /* Computing MIN */
  235. i__3 = *m, i__4 = j - 1;
  236. i__2 = min(i__3,i__4);
  237. for (i__ = 1; i__ <= i__2; ++i__) {
  238. work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1));
  239. /* L160: */
  240. }
  241. /* L170: */
  242. }
  243. } else {
  244. i__1 = *m;
  245. for (i__ = 1; i__ <= i__1; ++i__) {
  246. work[i__] = 0.;
  247. /* L180: */
  248. }
  249. i__1 = *n;
  250. for (j = 1; j <= i__1; ++j) {
  251. i__2 = min(*m,j);
  252. for (i__ = 1; i__ <= i__2; ++i__) {
  253. work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1));
  254. /* L190: */
  255. }
  256. /* L200: */
  257. }
  258. }
  259. } else {
  260. if (lsame_(diag, "U")) {
  261. i__1 = *n;
  262. for (i__ = 1; i__ <= i__1; ++i__) {
  263. work[i__] = 1.;
  264. /* L210: */
  265. }
  266. i__1 = *m;
  267. for (i__ = *n + 1; i__ <= i__1; ++i__) {
  268. work[i__] = 0.;
  269. /* L220: */
  270. }
  271. i__1 = *n;
  272. for (j = 1; j <= i__1; ++j) {
  273. i__2 = *m;
  274. for (i__ = j + 1; i__ <= i__2; ++i__) {
  275. work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1));
  276. /* L230: */
  277. }
  278. /* L240: */
  279. }
  280. } else {
  281. i__1 = *m;
  282. for (i__ = 1; i__ <= i__1; ++i__) {
  283. work[i__] = 0.;
  284. /* L250: */
  285. }
  286. i__1 = *n;
  287. for (j = 1; j <= i__1; ++j) {
  288. i__2 = *m;
  289. for (i__ = j; i__ <= i__2; ++i__) {
  290. work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1));
  291. /* L260: */
  292. }
  293. /* L270: */
  294. }
  295. }
  296. }
  297. value = 0.;
  298. i__1 = *m;
  299. for (i__ = 1; i__ <= i__1; ++i__) {
  300. /* Computing MAX */
  301. d__1 = value, d__2 = work[i__];
  302. value = max(d__1,d__2);
  303. /* L280: */
  304. }
  305. } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
  306. /* Find normF(A). */
  307. if (lsame_(uplo, "U")) {
  308. if (lsame_(diag, "U")) {
  309. scale = 1.;
  310. sum = (doublereal) min(*m,*n);
  311. i__1 = *n;
  312. for (j = 2; j <= i__1; ++j) {
  313. /* Computing MIN */
  314. i__3 = *m, i__4 = j - 1;
  315. i__2 = min(i__3,i__4);
  316. dlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
  317. /* L290: */
  318. }
  319. } else {
  320. scale = 0.;
  321. sum = 1.;
  322. i__1 = *n;
  323. for (j = 1; j <= i__1; ++j) {
  324. i__2 = min(*m,j);
  325. dlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
  326. /* L300: */
  327. }
  328. }
  329. } else {
  330. if (lsame_(diag, "U")) {
  331. scale = 1.;
  332. sum = (doublereal) min(*m,*n);
  333. i__1 = *n;
  334. for (j = 1; j <= i__1; ++j) {
  335. i__2 = *m - j;
  336. /* Computing MIN */
  337. i__3 = *m, i__4 = j + 1;
  338. dlassq_(&i__2, &a[min(i__3, i__4)+ j * a_dim1], &c__1, &
  339. scale, &sum);
  340. /* L310: */
  341. }
  342. } else {
  343. scale = 0.;
  344. sum = 1.;
  345. i__1 = *n;
  346. for (j = 1; j <= i__1; ++j) {
  347. i__2 = *m - j + 1;
  348. dlassq_(&i__2, &a[j + j * a_dim1], &c__1, &scale, &sum);
  349. /* L320: */
  350. }
  351. }
  352. }
  353. value = scale * sqrt(sum);
  354. }
  355. ret_val = value;
  356. return ret_val;
  357. /* End of DLANTR */
  358. } /* dlantr_ */