1
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5
* daxpy dcopy ddot dnrm2
7
*** from netlib, Thu May 16 21:00:13 EDT 1991 ***
8
*** Declarations of the form dx(1) changed to dx(*)
10
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13
subroutine daxpy(n,da,dx,incx,dy,incy)
15
c constant times a vector plus a vector.
16
c uses unrolled loops for increments equal to one.
17
c jack dongarra, linpack, 3/11/78.
19
double precision dx(*),dy(*),da
20
integer i,incx,incy,ix,iy,m,mp1,n
23
if (da .eq. 0.0d0) return
24
if(incx.eq.1.and.incy.eq.1)go to 20
26
c code for unequal increments or equal increments
31
if(incx.lt.0)ix = (-n+1)*incx + 1
32
if(incy.lt.0)iy = (-n+1)*incy + 1
34
dy(iy) = dy(iy) + da*dx(ix)
40
c code for both increments equal to 1
46
if( m .eq. 0 ) go to 40
48
dy(i) = dy(i) + da*dx(i)
53
dy(i) = dy(i) + da*dx(i)
54
dy(i + 1) = dy(i + 1) + da*dx(i + 1)
55
dy(i + 2) = dy(i + 2) + da*dx(i + 2)
56
dy(i + 3) = dy(i + 3) + da*dx(i + 3)
61
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
63
subroutine dcopy(n,dx,incx,dy,incy)
65
c copies a vector, x, to a vector, y.
66
c uses unrolled loops for increments equal to one.
67
c jack dongarra, linpack, 3/11/78.
69
double precision dx(*),dy(*)
70
integer i,incx,incy,ix,iy,m,mp1,n
73
if(incx.eq.1.and.incy.eq.1)go to 20
75
c code for unequal increments or equal increments
80
if(incx.lt.0)ix = (-n+1)*incx + 1
81
if(incy.lt.0)iy = (-n+1)*incy + 1
89
c code for both increments equal to 1
95
if( m .eq. 0 ) go to 40
103
dy(i + 1) = dx(i + 1)
104
dy(i + 2) = dx(i + 2)
105
dy(i + 3) = dx(i + 3)
106
dy(i + 4) = dx(i + 4)
107
dy(i + 5) = dx(i + 5)
108
dy(i + 6) = dx(i + 6)
113
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
115
double precision function ddot(n,dx,incx,dy,incy)
117
c forms the dot product of two vectors.
118
c uses unrolled loops for increments equal to one.
119
c jack dongarra, linpack, 3/11/78.
121
double precision dx(*),dy(*),dtemp
122
integer i,incx,incy,ix,iy,m,mp1,n
127
if(incx.eq.1.and.incy.eq.1)go to 20
129
c code for unequal increments or equal increments
134
if(incx.lt.0)ix = (-n+1)*incx + 1
135
if(incy.lt.0)iy = (-n+1)*incy + 1
137
dtemp = dtemp + dx(ix)*dy(iy)
144
c code for both increments equal to 1
150
if( m .eq. 0 ) go to 40
152
dtemp = dtemp + dx(i)*dy(i)
154
if( n .lt. 5 ) go to 60
157
dtemp = dtemp + dx(i)*dy(i) + dx(i + 1)*dy(i + 1) +
158
* dx(i + 2)*dy(i + 2) + dx(i + 3)*dy(i + 3) + dx(i + 4)*dy(i + 4)
164
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
166
double precision function dnrm2 ( n, dx, incx)
168
double precision dx(*), cutlo, cuthi, hitest, sum, xmax,zero,one
169
data zero, one /0.0d0, 1.0d0/
171
c euclidean norm of the n-vector stored in dx() with storage
173
c if n .le. 0 return with result = 0.
174
c if n .ge. 1 then incx must be .ge. 1
176
c c.l.lawson, 1978 jan 08
178
c four phase method using two built-in constants that are
179
c hopefully applicable to all machines.
180
c cutlo = maximum of dsqrt(u/eps) over all known machines.
181
c cuthi = minimum of dsqrt(v) over all known machines.
183
c eps = smallest no. such that eps + 1. .gt. 1.
184
c u = smallest positive no. (underflow limit)
185
c v = largest no. (overflow limit)
187
c brief outline of algorithm..
189
c phase 1 scans zero components.
190
c move to phase 2 when a component is nonzero and .le. cutlo
191
c move to phase 3 when a component is .gt. cutlo
192
c move to phase 4 when a component is .ge. cuthi/m
193
c where m = n for x() real and m = 2*n for complex.
195
c values for cutlo and cuthi..
196
c from the environmental parameters listed in the imsl converter
197
c document the limiting values are as follows..
198
c cutlo, s.p. u/eps = 2**(-102) for honeywell. close seconds are
199
c univac and dec at 2**(-103)
200
c thus cutlo = 2**(-51) = 4.44089e-16
201
c cuthi, s.p. v = 2**127 for univac, honeywell, and dec.
202
c thus cuthi = 2**(63.5) = 1.30438e19
203
c cutlo, d.p. u/eps = 2**(-67) for honeywell and dec.
204
c thus cutlo = 2**(-33.5) = 8.23181d-11
205
c cuthi, d.p. same as s.p. cuthi = 1.30438d19
206
c data cutlo, cuthi / 8.232d-11, 1.304d19 /
207
c data cutlo, cuthi / 4.441e-16, 1.304e19 /
208
data cutlo, cuthi / 8.232d-11, 1.304d19 /
210
if(n .gt. 0) go to 10
219
20 go to next,(30, 50, 70, 110)
220
30 if( dabs(dx(i)) .gt. cutlo) go to 85
224
c phase 1. sum is zero
226
50 if( dx(i) .eq. zero) go to 200
227
if( dabs(dx(i)) .gt. cutlo) go to 85
229
c prepare for phase 2.
233
c prepare for phase 4.
237
sum = (sum / dx(i)) / dx(i)
238
105 xmax = dabs(dx(i))
241
c phase 2. sum is small.
242
c scale to avoid destructive underflow.
244
70 if( dabs(dx(i)) .gt. cutlo ) go to 75
246
c common code for phases 2 and 4.
247
c in phase 4 sum is large. scale to avoid overflow.
249
110 if( dabs(dx(i)) .le. xmax ) go to 115
250
sum = one + sum * (xmax / dx(i))**2
254
115 sum = sum + (dx(i)/xmax)**2
258
c prepare for phase 3.
260
75 sum = (sum * xmax) * xmax
263
c for real or d.p. set hitest = cuthi/n
264
c for complex set hitest = cuthi/(2*n)
266
85 hitest = cuthi/float( n )
268
c phase 3. sum is mid-range. no scaling.
271
if(dabs(dx(j)) .ge. hitest) go to 100
272
95 sum = sum + dx(j)**2
278
if ( i .le. nn ) go to 20
282
c compute square root and adjust for scaling.
284
dnrm2 = xmax * dsqrt(sum)