dlangb.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /* dlangb.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_dlangb_(char *norm, integer *n, integer *kl, integer *ku,
  16. doublereal *ab, integer *ldab, doublereal *work)
  17. {
  18. /* System generated locals */
  19. integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5, i__6;
  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, l;
  25. doublereal sum, scale;
  26. extern logical _starpu_lsame_(char *, char *);
  27. doublereal value;
  28. extern /* Subroutine */ int _starpu_dlassq_(integer *, doublereal *, integer *,
  29. doublereal *, doublereal *);
  30. /* -- LAPACK auxiliary routine (version 3.2) -- */
  31. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  32. /* November 2006 */
  33. /* .. Scalar Arguments .. */
  34. /* .. */
  35. /* .. Array Arguments .. */
  36. /* .. */
  37. /* Purpose */
  38. /* ======= */
  39. /* DLANGB returns the value of the one norm, or the Frobenius norm, or */
  40. /* the infinity norm, or the element of largest absolute value of an */
  41. /* n by n band matrix A, with kl sub-diagonals and ku super-diagonals. */
  42. /* Description */
  43. /* =========== */
  44. /* DLANGB returns the value */
  45. /* DLANGB = ( max(abs(A(i,j))), NORM = 'M' or 'm' */
  46. /* ( */
  47. /* ( norm1(A), NORM = '1', 'O' or 'o' */
  48. /* ( */
  49. /* ( normI(A), NORM = 'I' or 'i' */
  50. /* ( */
  51. /* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */
  52. /* where norm1 denotes the one norm of a matrix (maximum column sum), */
  53. /* normI denotes the infinity norm of a matrix (maximum row sum) and */
  54. /* normF denotes the Frobenius norm of a matrix (square root of sum of */
  55. /* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */
  56. /* Arguments */
  57. /* ========= */
  58. /* NORM (input) CHARACTER*1 */
  59. /* Specifies the value to be returned in DLANGB as described */
  60. /* above. */
  61. /* N (input) INTEGER */
  62. /* The order of the matrix A. N >= 0. When N = 0, DLANGB is */
  63. /* set to zero. */
  64. /* KL (input) INTEGER */
  65. /* The number of sub-diagonals of the matrix A. KL >= 0. */
  66. /* KU (input) INTEGER */
  67. /* The number of super-diagonals of the matrix A. KU >= 0. */
  68. /* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */
  69. /* The band matrix A, stored in rows 1 to KL+KU+1. The j-th */
  70. /* column of A is stored in the j-th column of the array AB as */
  71. /* follows: */
  72. /* AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl). */
  73. /* LDAB (input) INTEGER */
  74. /* The leading dimension of the array AB. LDAB >= KL+KU+1. */
  75. /* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */
  76. /* where LWORK >= N when NORM = 'I'; otherwise, WORK is not */
  77. /* referenced. */
  78. /* ===================================================================== */
  79. /* .. Parameters .. */
  80. /* .. */
  81. /* .. Local Scalars .. */
  82. /* .. */
  83. /* .. External Subroutines .. */
  84. /* .. */
  85. /* .. External Functions .. */
  86. /* .. */
  87. /* .. Intrinsic Functions .. */
  88. /* .. */
  89. /* .. Executable Statements .. */
  90. /* Parameter adjustments */
  91. ab_dim1 = *ldab;
  92. ab_offset = 1 + ab_dim1;
  93. ab -= ab_offset;
  94. --work;
  95. /* Function Body */
  96. if (*n == 0) {
  97. value = 0.;
  98. } else if (_starpu_lsame_(norm, "M")) {
  99. /* Find max(abs(A(i,j))). */
  100. value = 0.;
  101. i__1 = *n;
  102. for (j = 1; j <= i__1; ++j) {
  103. /* Computing MAX */
  104. i__2 = *ku + 2 - j;
  105. /* Computing MIN */
  106. i__4 = *n + *ku + 1 - j, i__5 = *kl + *ku + 1;
  107. i__3 = min(i__4,i__5);
  108. for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
  109. /* Computing MAX */
  110. d__2 = value, d__3 = (d__1 = ab[i__ + j * ab_dim1], abs(d__1))
  111. ;
  112. value = max(d__2,d__3);
  113. /* L10: */
  114. }
  115. /* L20: */
  116. }
  117. } else if (_starpu_lsame_(norm, "O") || *(unsigned char *)
  118. norm == '1') {
  119. /* Find norm1(A). */
  120. value = 0.;
  121. i__1 = *n;
  122. for (j = 1; j <= i__1; ++j) {
  123. sum = 0.;
  124. /* Computing MAX */
  125. i__3 = *ku + 2 - j;
  126. /* Computing MIN */
  127. i__4 = *n + *ku + 1 - j, i__5 = *kl + *ku + 1;
  128. i__2 = min(i__4,i__5);
  129. for (i__ = max(i__3,1); i__ <= i__2; ++i__) {
  130. sum += (d__1 = ab[i__ + j * ab_dim1], abs(d__1));
  131. /* L30: */
  132. }
  133. value = max(value,sum);
  134. /* L40: */
  135. }
  136. } else if (_starpu_lsame_(norm, "I")) {
  137. /* Find normI(A). */
  138. i__1 = *n;
  139. for (i__ = 1; i__ <= i__1; ++i__) {
  140. work[i__] = 0.;
  141. /* L50: */
  142. }
  143. i__1 = *n;
  144. for (j = 1; j <= i__1; ++j) {
  145. k = *ku + 1 - j;
  146. /* Computing MAX */
  147. i__2 = 1, i__3 = j - *ku;
  148. /* Computing MIN */
  149. i__5 = *n, i__6 = j + *kl;
  150. i__4 = min(i__5,i__6);
  151. for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
  152. work[i__] += (d__1 = ab[k + i__ + j * ab_dim1], abs(d__1));
  153. /* L60: */
  154. }
  155. /* L70: */
  156. }
  157. value = 0.;
  158. i__1 = *n;
  159. for (i__ = 1; i__ <= i__1; ++i__) {
  160. /* Computing MAX */
  161. d__1 = value, d__2 = work[i__];
  162. value = max(d__1,d__2);
  163. /* L80: */
  164. }
  165. } else if (_starpu_lsame_(norm, "F") || _starpu_lsame_(norm, "E")) {
  166. /* Find normF(A). */
  167. scale = 0.;
  168. sum = 1.;
  169. i__1 = *n;
  170. for (j = 1; j <= i__1; ++j) {
  171. /* Computing MAX */
  172. i__4 = 1, i__2 = j - *ku;
  173. l = max(i__4,i__2);
  174. k = *ku + 1 - j + l;
  175. /* Computing MIN */
  176. i__2 = *n, i__3 = j + *kl;
  177. i__4 = min(i__2,i__3) - l + 1;
  178. _starpu_dlassq_(&i__4, &ab[k + j * ab_dim1], &c__1, &scale, &sum);
  179. /* L90: */
  180. }
  181. value = scale * sqrt(sum);
  182. }
  183. ret_val = value;
  184. return ret_val;
  185. /* End of DLANGB */
  186. } /* _starpu_dlangb_ */