dlansb.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /* dlansb.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_dlansb_(char *norm, char *uplo, integer *n, integer *k, doublereal
  16. *ab, integer *ldab, doublereal *work)
  17. {
  18. /* System generated locals */
  19. integer ab_dim1, ab_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, l;
  25. doublereal sum, absa, 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. /* DLANSB 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 symmetric band matrix A, with k super-diagonals. */
  42. /* Description */
  43. /* =========== */
  44. /* DLANSB returns the value */
  45. /* DLANSB = ( 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 DLANSB as described */
  60. /* above. */
  61. /* UPLO (input) CHARACTER*1 */
  62. /* Specifies whether the upper or lower triangular part of the */
  63. /* band matrix A is supplied. */
  64. /* = 'U': Upper triangular part is supplied */
  65. /* = 'L': Lower triangular part is supplied */
  66. /* N (input) INTEGER */
  67. /* The order of the matrix A. N >= 0. When N = 0, DLANSB is */
  68. /* set to zero. */
  69. /* K (input) INTEGER */
  70. /* The number of super-diagonals or sub-diagonals of the */
  71. /* band matrix A. K >= 0. */
  72. /* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */
  73. /* The upper or lower triangle of the symmetric band matrix A, */
  74. /* stored in the first K+1 rows of AB. The j-th column of A is */
  75. /* stored in the j-th column of the array AB as follows: */
  76. /* if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for max(1,j-k)<=i<=j; */
  77. /* if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+k). */
  78. /* LDAB (input) INTEGER */
  79. /* The leading dimension of the array AB. LDAB >= K+1. */
  80. /* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */
  81. /* where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */
  82. /* WORK is not referenced. */
  83. /* ===================================================================== */
  84. /* .. Parameters .. */
  85. /* .. */
  86. /* .. Local Scalars .. */
  87. /* .. */
  88. /* .. External Subroutines .. */
  89. /* .. */
  90. /* .. External Functions .. */
  91. /* .. */
  92. /* .. Intrinsic Functions .. */
  93. /* .. */
  94. /* .. Executable Statements .. */
  95. /* Parameter adjustments */
  96. ab_dim1 = *ldab;
  97. ab_offset = 1 + ab_dim1;
  98. ab -= ab_offset;
  99. --work;
  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. value = 0.;
  106. if (_starpu_lsame_(uplo, "U")) {
  107. i__1 = *n;
  108. for (j = 1; j <= i__1; ++j) {
  109. /* Computing MAX */
  110. i__2 = *k + 2 - j;
  111. i__3 = *k + 1;
  112. for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
  113. /* Computing MAX */
  114. d__2 = value, d__3 = (d__1 = ab[i__ + j * ab_dim1], abs(
  115. d__1));
  116. value = max(d__2,d__3);
  117. /* L10: */
  118. }
  119. /* L20: */
  120. }
  121. } else {
  122. i__1 = *n;
  123. for (j = 1; j <= i__1; ++j) {
  124. /* Computing MIN */
  125. i__2 = *n + 1 - j, i__4 = *k + 1;
  126. i__3 = min(i__2,i__4);
  127. for (i__ = 1; i__ <= i__3; ++i__) {
  128. /* Computing MAX */
  129. d__2 = value, d__3 = (d__1 = ab[i__ + j * ab_dim1], abs(
  130. d__1));
  131. value = max(d__2,d__3);
  132. /* L30: */
  133. }
  134. /* L40: */
  135. }
  136. }
  137. } else if (_starpu_lsame_(norm, "I") || _starpu_lsame_(norm, "O") || *(unsigned char *)norm == '1') {
  138. /* Find normI(A) ( = norm1(A), since A is symmetric). */
  139. value = 0.;
  140. if (_starpu_lsame_(uplo, "U")) {
  141. i__1 = *n;
  142. for (j = 1; j <= i__1; ++j) {
  143. sum = 0.;
  144. l = *k + 1 - j;
  145. /* Computing MAX */
  146. i__3 = 1, i__2 = j - *k;
  147. i__4 = j - 1;
  148. for (i__ = max(i__3,i__2); i__ <= i__4; ++i__) {
  149. absa = (d__1 = ab[l + i__ + j * ab_dim1], abs(d__1));
  150. sum += absa;
  151. work[i__] += absa;
  152. /* L50: */
  153. }
  154. work[j] = sum + (d__1 = ab[*k + 1 + j * ab_dim1], abs(d__1));
  155. /* L60: */
  156. }
  157. i__1 = *n;
  158. for (i__ = 1; i__ <= i__1; ++i__) {
  159. /* Computing MAX */
  160. d__1 = value, d__2 = work[i__];
  161. value = max(d__1,d__2);
  162. /* L70: */
  163. }
  164. } else {
  165. i__1 = *n;
  166. for (i__ = 1; i__ <= i__1; ++i__) {
  167. work[i__] = 0.;
  168. /* L80: */
  169. }
  170. i__1 = *n;
  171. for (j = 1; j <= i__1; ++j) {
  172. sum = work[j] + (d__1 = ab[j * ab_dim1 + 1], abs(d__1));
  173. l = 1 - j;
  174. /* Computing MIN */
  175. i__3 = *n, i__2 = j + *k;
  176. i__4 = min(i__3,i__2);
  177. for (i__ = j + 1; i__ <= i__4; ++i__) {
  178. absa = (d__1 = ab[l + i__ + j * ab_dim1], abs(d__1));
  179. sum += absa;
  180. work[i__] += absa;
  181. /* L90: */
  182. }
  183. value = max(value,sum);
  184. /* L100: */
  185. }
  186. }
  187. } else if (_starpu_lsame_(norm, "F") || _starpu_lsame_(norm, "E")) {
  188. /* Find normF(A). */
  189. scale = 0.;
  190. sum = 1.;
  191. if (*k > 0) {
  192. if (_starpu_lsame_(uplo, "U")) {
  193. i__1 = *n;
  194. for (j = 2; j <= i__1; ++j) {
  195. /* Computing MIN */
  196. i__3 = j - 1;
  197. i__4 = min(i__3,*k);
  198. /* Computing MAX */
  199. i__2 = *k + 2 - j;
  200. _starpu_dlassq_(&i__4, &ab[max(i__2, 1)+ j * ab_dim1], &c__1, &
  201. scale, &sum);
  202. /* L110: */
  203. }
  204. l = *k + 1;
  205. } else {
  206. i__1 = *n - 1;
  207. for (j = 1; j <= i__1; ++j) {
  208. /* Computing MIN */
  209. i__3 = *n - j;
  210. i__4 = min(i__3,*k);
  211. _starpu_dlassq_(&i__4, &ab[j * ab_dim1 + 2], &c__1, &scale, &sum);
  212. /* L120: */
  213. }
  214. l = 1;
  215. }
  216. sum *= 2;
  217. } else {
  218. l = 1;
  219. }
  220. _starpu_dlassq_(n, &ab[l + ab_dim1], ldab, &scale, &sum);
  221. value = scale * sqrt(sum);
  222. }
  223. ret_val = value;
  224. return ret_val;
  225. /* End of DLANSB */
  226. } /* _starpu_dlansb_ */