dsyr.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /* dsyr.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. /* Subroutine */ int dsyr_(char *uplo, integer *n, doublereal *alpha,
  14. doublereal *x, integer *incx, doublereal *a, integer *lda)
  15. {
  16. /* System generated locals */
  17. integer a_dim1, a_offset, i__1, i__2;
  18. /* Local variables */
  19. integer i__, j, ix, jx, kx, info;
  20. doublereal temp;
  21. extern logical lsame_(char *, char *);
  22. extern /* Subroutine */ int xerbla_(char *, integer *);
  23. /* .. Scalar Arguments .. */
  24. /* .. */
  25. /* .. Array Arguments .. */
  26. /* .. */
  27. /* Purpose */
  28. /* ======= */
  29. /* DSYR performs the symmetric rank 1 operation */
  30. /* A := alpha*x*x' + A, */
  31. /* where alpha is a real scalar, x is an n element vector and A is an */
  32. /* n by n symmetric matrix. */
  33. /* Arguments */
  34. /* ========== */
  35. /* UPLO - CHARACTER*1. */
  36. /* On entry, UPLO specifies whether the upper or lower */
  37. /* triangular part of the array A is to be referenced as */
  38. /* follows: */
  39. /* UPLO = 'U' or 'u' Only the upper triangular part of A */
  40. /* is to be referenced. */
  41. /* UPLO = 'L' or 'l' Only the lower triangular part of A */
  42. /* is to be referenced. */
  43. /* Unchanged on exit. */
  44. /* N - INTEGER. */
  45. /* On entry, N specifies the order of the matrix A. */
  46. /* N must be at least zero. */
  47. /* Unchanged on exit. */
  48. /* ALPHA - DOUBLE PRECISION. */
  49. /* On entry, ALPHA specifies the scalar alpha. */
  50. /* Unchanged on exit. */
  51. /* X - DOUBLE PRECISION array of dimension at least */
  52. /* ( 1 + ( n - 1 )*abs( INCX ) ). */
  53. /* Before entry, the incremented array X must contain the n */
  54. /* element vector x. */
  55. /* Unchanged on exit. */
  56. /* INCX - INTEGER. */
  57. /* On entry, INCX specifies the increment for the elements of */
  58. /* X. INCX must not be zero. */
  59. /* Unchanged on exit. */
  60. /* A - DOUBLE PRECISION array of DIMENSION ( LDA, n ). */
  61. /* Before entry with UPLO = 'U' or 'u', the leading n by n */
  62. /* upper triangular part of the array A must contain the upper */
  63. /* triangular part of the symmetric matrix and the strictly */
  64. /* lower triangular part of A is not referenced. On exit, the */
  65. /* upper triangular part of the array A is overwritten by the */
  66. /* upper triangular part of the updated matrix. */
  67. /* Before entry with UPLO = 'L' or 'l', the leading n by n */
  68. /* lower triangular part of the array A must contain the lower */
  69. /* triangular part of the symmetric matrix and the strictly */
  70. /* upper triangular part of A is not referenced. On exit, the */
  71. /* lower triangular part of the array A is overwritten by the */
  72. /* lower triangular part of the updated matrix. */
  73. /* LDA - INTEGER. */
  74. /* On entry, LDA specifies the first dimension of A as declared */
  75. /* in the calling (sub) program. LDA must be at least */
  76. /* max( 1, n ). */
  77. /* Unchanged on exit. */
  78. /* Level 2 Blas routine. */
  79. /* -- Written on 22-October-1986. */
  80. /* Jack Dongarra, Argonne National Lab. */
  81. /* Jeremy Du Croz, Nag Central Office. */
  82. /* Sven Hammarling, Nag Central Office. */
  83. /* Richard Hanson, Sandia National Labs. */
  84. /* .. Parameters .. */
  85. /* .. */
  86. /* .. Local Scalars .. */
  87. /* .. */
  88. /* .. External Functions .. */
  89. /* .. */
  90. /* .. External Subroutines .. */
  91. /* .. */
  92. /* .. Intrinsic Functions .. */
  93. /* .. */
  94. /* Test the input parameters. */
  95. /* Parameter adjustments */
  96. --x;
  97. a_dim1 = *lda;
  98. a_offset = 1 + a_dim1;
  99. a -= a_offset;
  100. /* Function Body */
  101. info = 0;
  102. if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
  103. info = 1;
  104. } else if (*n < 0) {
  105. info = 2;
  106. } else if (*incx == 0) {
  107. info = 5;
  108. } else if (*lda < max(1,*n)) {
  109. info = 7;
  110. }
  111. if (info != 0) {
  112. xerbla_("DSYR ", &info);
  113. return 0;
  114. }
  115. /* Quick return if possible. */
  116. if (*n == 0 || *alpha == 0.) {
  117. return 0;
  118. }
  119. /* Set the start point in X if the increment is not unity. */
  120. if (*incx <= 0) {
  121. kx = 1 - (*n - 1) * *incx;
  122. } else if (*incx != 1) {
  123. kx = 1;
  124. }
  125. /* Start the operations. In this version the elements of A are */
  126. /* accessed sequentially with one pass through the triangular part */
  127. /* of A. */
  128. if (lsame_(uplo, "U")) {
  129. /* Form A when A is stored in upper triangle. */
  130. if (*incx == 1) {
  131. i__1 = *n;
  132. for (j = 1; j <= i__1; ++j) {
  133. if (x[j] != 0.) {
  134. temp = *alpha * x[j];
  135. i__2 = j;
  136. for (i__ = 1; i__ <= i__2; ++i__) {
  137. a[i__ + j * a_dim1] += x[i__] * temp;
  138. /* L10: */
  139. }
  140. }
  141. /* L20: */
  142. }
  143. } else {
  144. jx = kx;
  145. i__1 = *n;
  146. for (j = 1; j <= i__1; ++j) {
  147. if (x[jx] != 0.) {
  148. temp = *alpha * x[jx];
  149. ix = kx;
  150. i__2 = j;
  151. for (i__ = 1; i__ <= i__2; ++i__) {
  152. a[i__ + j * a_dim1] += x[ix] * temp;
  153. ix += *incx;
  154. /* L30: */
  155. }
  156. }
  157. jx += *incx;
  158. /* L40: */
  159. }
  160. }
  161. } else {
  162. /* Form A when A is stored in lower triangle. */
  163. if (*incx == 1) {
  164. i__1 = *n;
  165. for (j = 1; j <= i__1; ++j) {
  166. if (x[j] != 0.) {
  167. temp = *alpha * x[j];
  168. i__2 = *n;
  169. for (i__ = j; i__ <= i__2; ++i__) {
  170. a[i__ + j * a_dim1] += x[i__] * temp;
  171. /* L50: */
  172. }
  173. }
  174. /* L60: */
  175. }
  176. } else {
  177. jx = kx;
  178. i__1 = *n;
  179. for (j = 1; j <= i__1; ++j) {
  180. if (x[jx] != 0.) {
  181. temp = *alpha * x[jx];
  182. ix = jx;
  183. i__2 = *n;
  184. for (i__ = j; i__ <= i__2; ++i__) {
  185. a[i__ + j * a_dim1] += x[ix] * temp;
  186. ix += *incx;
  187. /* L70: */
  188. }
  189. }
  190. jx += *incx;
  191. /* L80: */
  192. }
  193. }
  194. }
  195. return 0;
  196. /* End of DSYR . */
  197. } /* dsyr_ */