Add intro and pdf for lognormal
[maxima.git] / share / colnew / fortran / dgefa.f
blob37d705f14ff31205bec16f87fa8f327f29de3a04
1 subroutine dgefa(a,lda,n,ipvt,info)
2 integer lda,n,ipvt(1),info
3 double precision a(lda,1)
5 c dgefa factors a double precision matrix by gaussian elimination.
7 c dgefa is usually called by dgeco, but it can be called
8 c directly with a saving in time if rcond is not needed.
9 c (time for dgeco) = (1 + 9/n)*(time for dgefa) .
11 c on entry
13 c a double precision(lda, n)
14 c the matrix to be factored.
16 c lda integer
17 c the leading dimension of the array a .
19 c n integer
20 c the order of the matrix a .
22 c on return
24 c a an upper triangular matrix and the multipliers
25 c which were used to obtain it.
26 c the factorization can be written a = l*u where
27 c l is a product of permutation and unit lower
28 c triangular matrices and u is upper triangular.
30 c ipvt integer(n)
31 c an integer vector of pivot indices.
33 c info integer
34 c = 0 normal value.
35 c = k if u(k,k) .eq. 0.0 . this is not an error
36 c condition for this subroutine, but it does
37 c indicate that dgesl or dgedi will divide by zero
38 c if called. use rcond in dgeco for a reliable
39 c indication of singularity.
41 c linpack. this version dated 08/14/78 .
42 c cleve moler, university of new mexico, argonne national lab.
44 c subroutines and functions
46 c blas daxpy,dscal,idamax
48 c internal variables
50 double precision t
51 integer idamax,j,k,kp1,l,nm1
54 c gaussian elimination with partial pivoting
56 info = 0
57 nm1 = n - 1
58 if (nm1 .lt. 1) go to 70
59 do 60 k = 1, nm1
60 kp1 = k + 1
62 c find l = pivot index
64 l = idamax(n-k+1,a(k,k),1) + k - 1
65 ipvt(k) = l
67 c zero pivot implies this column already triangularized
69 if (a(l,k) .eq. 0.0d0) go to 40
71 c interchange if necessary
73 if (l .eq. k) go to 10
74 t = a(l,k)
75 a(l,k) = a(k,k)
76 a(k,k) = t
77 10 continue
79 c compute multipliers
81 t = -1.0d0/a(k,k)
82 call dscal(n-k,t,a(k+1,k),1)
84 c row elimination with column indexing
86 do 30 j = kp1, n
87 t = a(l,j)
88 if (l .eq. k) go to 20
89 a(l,j) = a(k,j)
90 a(k,j) = t
91 20 continue
92 call daxpy(n-k,t,a(k+1,k),1,a(k+1,j),1)
93 30 continue
94 go to 50
95 40 continue
96 info = k
97 50 continue
98 60 continue
99 70 continue
100 ipvt(n) = n
101 if (a(n,n) .eq. 0.0d0) info = n
102 return