Rev 5457 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
c Triangular Solve dtrsl()c ----------------c solves systems of the formcc t * x = bc orc trans(t) * x = bcc where t is a triangular matrix of order n. here trans(t)c denotes the transpose of the matrix t.cc on entrycc t double precision(ldt,n)c t contains the matrix of the system. the zeroc elements of the matrix are not referenced, andc the corresponding elements of the array can bec used to store other information.cc ldt integerc ldt is the leading dimension of the array t.cc n integerc n is the order of the system.cc b double precision(n).c b contains the right hand side of the system.cc job integerc job specifies what kind of system is to be solved.c if job iscc 00 solve t*x=b, t lower triangular,c 01 solve t*x=b, t upper triangular,c 10 solve trans(t)*x=b, t lower triangular,c 11 solve trans(t)*x=b, t upper triangular.cc on returncc b b contains the solution, if info .eq. 0.c otherwise b is unaltered.cc info integerc info contains zero if the system is nonsingular.c otherwise info contains the index ofc the first zero diagonal element of t.cc linpack. this version dated 08/14/78 .c g. w. stewart, university of maryland, argonne national lab.cc subroutines and functionscc blas: daxpy,ddotc fortran modcsubroutine dtrsl(t,ldt,n,b,job,info)integer ldt,n,job,infodouble precision t(ldt,*),b(*)cc internal variablescdouble precision ddot,tempinteger case,j,jjcc begin block permitting ...exits to 150cc check for zero diagonal elements.cdo 10 info = 1, nif (t(info,info) .eq. 0.0d0) go to 150c ......exit10 continueinfo = 0cc determine the task and go to it.ccase = 1if (mod(job,10) .ne. 0) case = 2if (mod(job,100)/10 .ne. 0) case = case + 2go to (20,50,80,110), casecC Case 1 (job = 00):c solve t*x=b for t lower triangularc20 continueb(1) = b(1)/t(1,1)if (n .ge. 2) thendo 30 j = 2, ntemp = -b(j-1)call daxpy(n-j+1,temp,t(j,j-1),1,b(j),1)b(j) = b(j)/t(j,j)30 continueendifgo to 140cC Case 2 (job = 01):c solve t*x=b for t upper triangular.c50 continueb(n) = b(n)/t(n,n)if (n .ge. 2) thendo 60 jj = 2, nj = n - jj + 1temp = -b(j+1)call daxpy(j,temp,t(1,j+1),1,b(1),1)b(j) = b(j)/t(j,j)60 continueendifgo to 140cC Case 3 (job = 10):c solve trans(t)*x=b for t lower triangular.c80 continueb(n) = b(n)/t(n,n)if (n .ge. 2) thendo 90 jj = 2, nj = n - jj + 1b(j) = b(j) - ddot(jj-1,t(j+1,j),1,b(j+1),1)b(j) = b(j)/t(j,j)90 continueendifgo to 140cC Case 4 (job = 11):c solve trans(t)*x=b for t upper triangular.c110 continueb(1) = b(1)/t(1,1)if (n .ge. 2) thendo 120 j = 2, nb(j) = b(j) - ddot(j-1,t(1,j),1,b(1),1)b(j) = b(j)/t(j,j)120 continueendifC140 continuec EXIT:150 continuereturnend