sspr.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /* sspr.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 sspr_(char *uplo, integer *n, real *alpha, real *x,
  14. integer *incx, real *ap)
  15. {
  16. /* System generated locals */
  17. integer i__1, i__2;
  18. /* Local variables */
  19. integer i__, j, k, kk, ix, jx, kx, info;
  20. real 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. /* SSPR 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, supplied in packed form. */
  33. /* Arguments */
  34. /* ========== */
  35. /* UPLO - CHARACTER*1. */
  36. /* On entry, UPLO specifies whether the upper or lower */
  37. /* triangular part of the matrix A is supplied in the packed */
  38. /* array AP as follows: */
  39. /* UPLO = 'U' or 'u' The upper triangular part of A is */
  40. /* supplied in AP. */
  41. /* UPLO = 'L' or 'l' The lower triangular part of A is */
  42. /* supplied in AP. */
  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 - REAL . */
  49. /* On entry, ALPHA specifies the scalar alpha. */
  50. /* Unchanged on exit. */
  51. /* X - REAL 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. /* AP - REAL array of DIMENSION at least */
  61. /* ( ( n*( n + 1 ) )/2 ). */
  62. /* Before entry with UPLO = 'U' or 'u', the array AP must */
  63. /* contain the upper triangular part of the symmetric matrix */
  64. /* packed sequentially, column by column, so that AP( 1 ) */
  65. /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) */
  66. /* and a( 2, 2 ) respectively, and so on. On exit, the array */
  67. /* AP is overwritten by the upper triangular part of the */
  68. /* updated matrix. */
  69. /* Before entry with UPLO = 'L' or 'l', the array AP must */
  70. /* contain the lower triangular part of the symmetric matrix */
  71. /* packed sequentially, column by column, so that AP( 1 ) */
  72. /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) */
  73. /* and a( 3, 1 ) respectively, and so on. On exit, the array */
  74. /* AP is overwritten by the lower triangular part of the */
  75. /* updated matrix. */
  76. /* Level 2 Blas routine. */
  77. /* -- Written on 22-October-1986. */
  78. /* Jack Dongarra, Argonne National Lab. */
  79. /* Jeremy Du Croz, Nag Central Office. */
  80. /* Sven Hammarling, Nag Central Office. */
  81. /* Richard Hanson, Sandia National Labs. */
  82. /* .. Parameters .. */
  83. /* .. */
  84. /* .. Local Scalars .. */
  85. /* .. */
  86. /* .. External Functions .. */
  87. /* .. */
  88. /* .. External Subroutines .. */
  89. /* .. */
  90. /* Test the input parameters. */
  91. /* Parameter adjustments */
  92. --ap;
  93. --x;
  94. /* Function Body */
  95. info = 0;
  96. if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
  97. info = 1;
  98. } else if (*n < 0) {
  99. info = 2;
  100. } else if (*incx == 0) {
  101. info = 5;
  102. }
  103. if (info != 0) {
  104. xerbla_("SSPR ", &info);
  105. return 0;
  106. }
  107. /* Quick return if possible. */
  108. if (*n == 0 || *alpha == 0.f) {
  109. return 0;
  110. }
  111. /* Set the start point in X if the increment is not unity. */
  112. if (*incx <= 0) {
  113. kx = 1 - (*n - 1) * *incx;
  114. } else if (*incx != 1) {
  115. kx = 1;
  116. }
  117. /* Start the operations. In this version the elements of the array AP */
  118. /* are accessed sequentially with one pass through AP. */
  119. kk = 1;
  120. if (lsame_(uplo, "U")) {
  121. /* Form A when upper triangle is stored in AP. */
  122. if (*incx == 1) {
  123. i__1 = *n;
  124. for (j = 1; j <= i__1; ++j) {
  125. if (x[j] != 0.f) {
  126. temp = *alpha * x[j];
  127. k = kk;
  128. i__2 = j;
  129. for (i__ = 1; i__ <= i__2; ++i__) {
  130. ap[k] += x[i__] * temp;
  131. ++k;
  132. /* L10: */
  133. }
  134. }
  135. kk += j;
  136. /* L20: */
  137. }
  138. } else {
  139. jx = kx;
  140. i__1 = *n;
  141. for (j = 1; j <= i__1; ++j) {
  142. if (x[jx] != 0.f) {
  143. temp = *alpha * x[jx];
  144. ix = kx;
  145. i__2 = kk + j - 1;
  146. for (k = kk; k <= i__2; ++k) {
  147. ap[k] += x[ix] * temp;
  148. ix += *incx;
  149. /* L30: */
  150. }
  151. }
  152. jx += *incx;
  153. kk += j;
  154. /* L40: */
  155. }
  156. }
  157. } else {
  158. /* Form A when lower triangle is stored in AP. */
  159. if (*incx == 1) {
  160. i__1 = *n;
  161. for (j = 1; j <= i__1; ++j) {
  162. if (x[j] != 0.f) {
  163. temp = *alpha * x[j];
  164. k = kk;
  165. i__2 = *n;
  166. for (i__ = j; i__ <= i__2; ++i__) {
  167. ap[k] += x[i__] * temp;
  168. ++k;
  169. /* L50: */
  170. }
  171. }
  172. kk = kk + *n - j + 1;
  173. /* L60: */
  174. }
  175. } else {
  176. jx = kx;
  177. i__1 = *n;
  178. for (j = 1; j <= i__1; ++j) {
  179. if (x[jx] != 0.f) {
  180. temp = *alpha * x[jx];
  181. ix = jx;
  182. i__2 = kk + *n - j;
  183. for (k = kk; k <= i__2; ++k) {
  184. ap[k] += x[ix] * temp;
  185. ix += *incx;
  186. /* L70: */
  187. }
  188. }
  189. jx += *incx;
  190. kk = kk + *n - j + 1;
  191. /* L80: */
  192. }
  193. }
  194. }
  195. return 0;
  196. /* End of SSPR . */
  197. } /* sspr_ */