dlanhs.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* dlanhs.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_dlanhs_(char *norm, integer *n, doublereal *a, integer *lda,
  16. 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. 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. /* DLANHS returns the value of the one norm, or the Frobenius norm, or */
  40. /* the infinity norm, or the element of largest absolute value of a */
  41. /* Hessenberg matrix A. */
  42. /* Description */
  43. /* =========== */
  44. /* DLANHS returns the value */
  45. /* DLANHS = ( 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 DLANHS as described */
  60. /* above. */
  61. /* N (input) INTEGER */
  62. /* The order of the matrix A. N >= 0. When N = 0, DLANHS is */
  63. /* set to zero. */
  64. /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */
  65. /* The n by n upper Hessenberg matrix A; the part of A below the */
  66. /* first sub-diagonal is not referenced. */
  67. /* LDA (input) INTEGER */
  68. /* The leading dimension of the array A. LDA >= max(N,1). */
  69. /* WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */
  70. /* where LWORK >= N when NORM = 'I'; otherwise, WORK is not */
  71. /* referenced. */
  72. /* ===================================================================== */
  73. /* .. Parameters .. */
  74. /* .. */
  75. /* .. Local Scalars .. */
  76. /* .. */
  77. /* .. External Subroutines .. */
  78. /* .. */
  79. /* .. External Functions .. */
  80. /* .. */
  81. /* .. Intrinsic Functions .. */
  82. /* .. */
  83. /* .. Executable Statements .. */
  84. /* Parameter adjustments */
  85. a_dim1 = *lda;
  86. a_offset = 1 + a_dim1;
  87. a -= a_offset;
  88. --work;
  89. /* Function Body */
  90. if (*n == 0) {
  91. value = 0.;
  92. } else if (_starpu_lsame_(norm, "M")) {
  93. /* Find max(abs(A(i,j))). */
  94. value = 0.;
  95. i__1 = *n;
  96. for (j = 1; j <= i__1; ++j) {
  97. /* Computing MIN */
  98. i__3 = *n, i__4 = j + 1;
  99. i__2 = min(i__3,i__4);
  100. for (i__ = 1; i__ <= i__2; ++i__) {
  101. /* Computing MAX */
  102. d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs(d__1));
  103. value = max(d__2,d__3);
  104. /* L10: */
  105. }
  106. /* L20: */
  107. }
  108. } else if (_starpu_lsame_(norm, "O") || *(unsigned char *)
  109. norm == '1') {
  110. /* Find norm1(A). */
  111. value = 0.;
  112. i__1 = *n;
  113. for (j = 1; j <= i__1; ++j) {
  114. sum = 0.;
  115. /* Computing MIN */
  116. i__3 = *n, i__4 = j + 1;
  117. i__2 = min(i__3,i__4);
  118. for (i__ = 1; i__ <= i__2; ++i__) {
  119. sum += (d__1 = a[i__ + j * a_dim1], abs(d__1));
  120. /* L30: */
  121. }
  122. value = max(value,sum);
  123. /* L40: */
  124. }
  125. } else if (_starpu_lsame_(norm, "I")) {
  126. /* Find normI(A). */
  127. i__1 = *n;
  128. for (i__ = 1; i__ <= i__1; ++i__) {
  129. work[i__] = 0.;
  130. /* L50: */
  131. }
  132. i__1 = *n;
  133. for (j = 1; j <= i__1; ++j) {
  134. /* Computing MIN */
  135. i__3 = *n, i__4 = j + 1;
  136. i__2 = min(i__3,i__4);
  137. for (i__ = 1; i__ <= i__2; ++i__) {
  138. work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1));
  139. /* L60: */
  140. }
  141. /* L70: */
  142. }
  143. value = 0.;
  144. i__1 = *n;
  145. for (i__ = 1; i__ <= i__1; ++i__) {
  146. /* Computing MAX */
  147. d__1 = value, d__2 = work[i__];
  148. value = max(d__1,d__2);
  149. /* L80: */
  150. }
  151. } else if (_starpu_lsame_(norm, "F") || _starpu_lsame_(norm, "E")) {
  152. /* Find normF(A). */
  153. scale = 0.;
  154. sum = 1.;
  155. i__1 = *n;
  156. for (j = 1; j <= i__1; ++j) {
  157. /* Computing MIN */
  158. i__3 = *n, i__4 = j + 1;
  159. i__2 = min(i__3,i__4);
  160. _starpu_dlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
  161. /* L90: */
  162. }
  163. value = scale * sqrt(sum);
  164. }
  165. ret_val = value;
  166. return ret_val;
  167. /* End of DLANHS */
  168. } /* _starpu_dlanhs_ */