Free cookie consent management tool by TermsFeed Policy Generator

source: branches/MathNetNumerics-Exploration-2789/HeuristicLab.Algorithms.DataAnalysis.Experimental/sbart/sspmv.f @ 15457

Last change on this file since 15457 was 15457, checked in by gkronber, 7 years ago

#2789 added Finbarr O'Sullivan smoothing spline code

File size: 7.7 KB
Line 
1      SUBROUTINE SSPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY)
2*     .. Scalar Arguments ..
3      REAL ALPHA,BETA
4      INTEGER INCX,INCY,N
5      CHARACTER UPLO
6*     ..
7*     .. Array Arguments ..
8      REAL AP(*),X(*),Y(*)
9*     ..
10*
11*  Purpose
12*  =======
13*
14*  SSPMV  performs the matrix-vector operation
15*
16*     y := alpha*A*x + beta*y,
17*
18*  where alpha and beta are scalars, x and y are n element vectors and
19*  A is an n by n symmetric matrix, supplied in packed form.
20*
21*  Arguments
22*  ==========
23*
24*  UPLO   - CHARACTER*1.
25*           On entry, UPLO specifies whether the upper or lower
26*           triangular part of the matrix A is supplied in the packed
27*           array AP as follows:
28*
29*              UPLO = 'U' or 'u'   The upper triangular part of A is
30*                                  supplied in AP.
31*
32*              UPLO = 'L' or 'l'   The lower triangular part of A is
33*                                  supplied in AP.
34*
35*           Unchanged on exit.
36*
37*  N      - INTEGER.
38*           On entry, N specifies the order of the matrix A.
39*           N must be at least zero.
40*           Unchanged on exit.
41*
42*  ALPHA  - REAL            .
43*           On entry, ALPHA specifies the scalar alpha.
44*           Unchanged on exit.
45*
46*  AP     - REAL             array of DIMENSION at least
47*           ( ( n*( n + 1 ) )/2 ).
48*           Before entry with UPLO = 'U' or 'u', the array AP must
49*           contain the upper triangular part of the symmetric matrix
50*           packed sequentially, column by column, so that AP( 1 )
51*           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 )
52*           and a( 2, 2 ) respectively, and so on.
53*           Before entry with UPLO = 'L' or 'l', the array AP must
54*           contain the lower triangular part of the symmetric matrix
55*           packed sequentially, column by column, so that AP( 1 )
56*           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 )
57*           and a( 3, 1 ) respectively, and so on.
58*           Unchanged on exit.
59*
60*  X      - REAL             array of dimension at least
61*           ( 1 + ( n - 1 )*abs( INCX ) ).
62*           Before entry, the incremented array X must contain the n
63*           element vector x.
64*           Unchanged on exit.
65*
66*  INCX   - INTEGER.
67*           On entry, INCX specifies the increment for the elements of
68*           X. INCX must not be zero.
69*           Unchanged on exit.
70*
71*  BETA   - REAL            .
72*           On entry, BETA specifies the scalar beta. When BETA is
73*           supplied as zero then Y need not be set on input.
74*           Unchanged on exit.
75*
76*  Y      - REAL             array of dimension at least
77*           ( 1 + ( n - 1 )*abs( INCY ) ).
78*           Before entry, the incremented array Y must contain the n
79*           element vector y. On exit, Y is overwritten by the updated
80*           vector y.
81*
82*  INCY   - INTEGER.
83*           On entry, INCY specifies the increment for the elements of
84*           Y. INCY must not be zero.
85*           Unchanged on exit.
86*
87*
88*  Level 2 Blas routine.
89*
90*  -- Written on 22-October-1986.
91*     Jack Dongarra, Argonne National Lab.
92*     Jeremy Du Croz, Nag Central Office.
93*     Sven Hammarling, Nag Central Office.
94*     Richard Hanson, Sandia National Labs.
95*
96*
97*     .. Parameters ..
98      REAL ONE,ZERO
99      PARAMETER (ONE=1.0E+0,ZERO=0.0E+0)
100*     ..
101*     .. Local Scalars ..
102      REAL TEMP1,TEMP2
103      INTEGER I,INFO,IX,IY,J,JX,JY,K,KK,KX,KY
104*     ..
105*     .. External Functions ..
106      LOGICAL LSAME
107      EXTERNAL LSAME
108*     ..
109*     .. External Subroutines ..
110      EXTERNAL XERBLA
111*     ..
112*
113*     Test the input parameters.
114*
115      INFO = 0
116      IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
117          INFO = 1
118      ELSE IF (N.LT.0) THEN
119          INFO = 2
120      ELSE IF (INCX.EQ.0) THEN
121          INFO = 6
122      ELSE IF (INCY.EQ.0) THEN
123          INFO = 9
124      END IF
125      IF (INFO.NE.0) THEN
126          CALL XERBLA('SSPMV ',INFO)
127          RETURN
128      END IF
129*
130*     Quick return if possible.
131*
132      IF ((N.EQ.0) .OR. ((ALPHA.EQ.ZERO).AND. (BETA.EQ.ONE))) RETURN
133*
134*     Set up the start points in  X  and  Y.
135*
136      IF (INCX.GT.0) THEN
137          KX = 1
138      ELSE
139          KX = 1 - (N-1)*INCX
140      END IF
141      IF (INCY.GT.0) THEN
142          KY = 1
143      ELSE
144          KY = 1 - (N-1)*INCY
145      END IF
146*
147*     Start the operations. In this version the elements of the array AP
148*     are accessed sequentially with one pass through AP.
149*
150*     First form  y := beta*y.
151*
152      IF (BETA.NE.ONE) THEN
153          IF (INCY.EQ.1) THEN
154              IF (BETA.EQ.ZERO) THEN
155                  DO 10 I = 1,N
156                      Y(I) = ZERO
157   10             CONTINUE
158              ELSE
159                  DO 20 I = 1,N
160                      Y(I) = BETA*Y(I)
161   20             CONTINUE
162              END IF
163          ELSE
164              IY = KY
165              IF (BETA.EQ.ZERO) THEN
166                  DO 30 I = 1,N
167                      Y(IY) = ZERO
168                      IY = IY + INCY
169   30             CONTINUE
170              ELSE
171                  DO 40 I = 1,N
172                      Y(IY) = BETA*Y(IY)
173                      IY = IY + INCY
174   40             CONTINUE
175              END IF
176          END IF
177      END IF
178      IF (ALPHA.EQ.ZERO) RETURN
179      KK = 1
180      IF (LSAME(UPLO,'U')) THEN
181*
182*        Form  y  when AP contains the upper triangle.
183*
184          IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
185              DO 60 J = 1,N
186                  TEMP1 = ALPHA*X(J)
187                  TEMP2 = ZERO
188                  K = KK
189                  DO 50 I = 1,J - 1
190                      Y(I) = Y(I) + TEMP1*AP(K)
191                      TEMP2 = TEMP2 + AP(K)*X(I)
192                      K = K + 1
193   50             CONTINUE
194                  Y(J) = Y(J) + TEMP1*AP(KK+J-1) + ALPHA*TEMP2
195                  KK = KK + J
196   60         CONTINUE
197          ELSE
198              JX = KX
199              JY = KY
200              DO 80 J = 1,N
201                  TEMP1 = ALPHA*X(JX)
202                  TEMP2 = ZERO
203                  IX = KX
204                  IY = KY
205                  DO 70 K = KK,KK + J - 2
206                      Y(IY) = Y(IY) + TEMP1*AP(K)
207                      TEMP2 = TEMP2 + AP(K)*X(IX)
208                      IX = IX + INCX
209                      IY = IY + INCY
210   70             CONTINUE
211                  Y(JY) = Y(JY) + TEMP1*AP(KK+J-1) + ALPHA*TEMP2
212                  JX = JX + INCX
213                  JY = JY + INCY
214                  KK = KK + J
215   80         CONTINUE
216          END IF
217      ELSE
218*
219*        Form  y  when AP contains the lower triangle.
220*
221          IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
222              DO 100 J = 1,N
223                  TEMP1 = ALPHA*X(J)
224                  TEMP2 = ZERO
225                  Y(J) = Y(J) + TEMP1*AP(KK)
226                  K = KK + 1
227                  DO 90 I = J + 1,N
228                      Y(I) = Y(I) + TEMP1*AP(K)
229                      TEMP2 = TEMP2 + AP(K)*X(I)
230                      K = K + 1
231   90             CONTINUE
232                  Y(J) = Y(J) + ALPHA*TEMP2
233                  KK = KK + (N-J+1)
234  100         CONTINUE
235          ELSE
236              JX = KX
237              JY = KY
238              DO 120 J = 1,N
239                  TEMP1 = ALPHA*X(JX)
240                  TEMP2 = ZERO
241                  Y(JY) = Y(JY) + TEMP1*AP(KK)
242                  IX = JX
243                  IY = JY
244                  DO 110 K = KK + 1,KK + N - J
245                      IX = IX + INCX
246                      IY = IY + INCY
247                      Y(IY) = Y(IY) + TEMP1*AP(K)
248                      TEMP2 = TEMP2 + AP(K)*X(IX)
249  110             CONTINUE
250                  Y(JY) = Y(JY) + ALPHA*TEMP2
251                  JX = JX + INCX
252                  JY = JY + INCY
253                  KK = KK + (N-J+1)
254  120         CONTINUE
255          END IF
256      END IF
257*
258      RETURN
259*
260*     End of SSPMV .
261*
262      END
Note: See TracBrowser for help on using the repository browser.