1 c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 c This file must be used under the terms of the CeCILL.
5 c This source file is licensed as described in the file COPYING, which
6 c you should have received as part of this distribution. The terms
7 c are also available at
8 c http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 subroutine intdgesv3(fname)
15 logical getrhsvar,createvar
16 logical checklhs,checkrhs
18 double precision ANORM, EPS, RCOND
19 double precision dlamch, dlange
21 external dlamch, dlange, vfinite
29 if(.not.checkrhs(fname,minrhs,maxrhs)) return
30 if(.not.checklhs(fname,minlhs,maxlhs)) return
32 if(.not.getrhsvar(1,'d', MA, NA, lA)) return
33 if(.not.getrhsvar(2,'d', MB, NRHS, lB)) return
44 if(M.eq.0 .or. N.eq.0) then
45 if(.not.createvar(3,'d', 0, 0, lX)) return
49 c Check if A and B matrices contains Inf or NaN's
50 if (vfinite(M*N, stk(lA)).eq.0) then
54 if (vfinite(MB*NRHS, stk(lB)).eq.0) then
60 if(.not.createvar(3,'d', M, N, lAF)) return
61 if(.not.createvar(4,'d', N, NRHS, lX)) return
62 if(.not.createvar(5,'d', max(M,N), NRHS, lXB)) return
63 if(.not.createvar(6,'i', 1, 1, lRANK)) return
64 if(.not.createvar(7,'i', 1, N, lIPIV)) return
65 if(.not.createvar(8,'i', 1, N, lJPVT)) return
66 if(.not.createvar(9,'i', 1, N, lIWORK)) return
67 LWORKMIN = max( 4*N, min(M,N)+3*N+1, 2*min(M,N)+NRHS )
69 if(LWORK.le.LWORKMIN) then
74 if(.not.createvar(10,'d',1,LWORK,lDWORK)) return
77 ANORM = dlange( '1', M, N, stk(lA), M, stk(lDWORK) )
83 call DLACPY( 'F', N, N, stk(lA), N, stk(lAF), N )
84 c SUBROUTINE DLACPY( UPLO, M, N, A, LDA, B, LDB )
85 call DGETRF( N, N, stk(lAF), N, istk(lIPIV), INFO )
86 c SUBROUTINE DGETRF( N, N, A, LDA, IPIV, INFO )
89 call DGECON( '1', N, stk(lAF), N, ANORM, RCOND, stk(lDWORK),
90 $ istk(lIWORK), INFO )
91 c SUBROUTINE DGECON( NORM, N, A, LDA, ANORM, RCOND, WORK,
93 if(RCOND.gt.sqrt(EPS)) then
94 call DGETRS( 'N', N, NRHS, stk(lAF), N, istk(lIPIV),
96 c SUBROUTINE DGETRS( TRANS, N, NRHS, A, LDA, IPIV,
98 call DLACPY( 'F', N, NRHS, stk(lB), N, stk(lX), N )
99 c SUBROUTINE DLACPY( UPLO, M, N, A, LDA, B, LDB )
104 call writebufdgesv3(buf,RCOND)
108 c M.ne.N or A singular
111 call DLACPY( 'F', M, NRHS, stk(lB), M, stk(lXB), max(M,N) )
112 c SUBROUTINE DLACPY( UPLO, M, N, A, LDA, B, LDB )
116 call DGELSY1( M, N, NRHS, stk(lA), M, stk(lXB), max(M,N),
117 $ istk(lJPVT), RCOND, istk(lRANK), stk(lDWORK),
119 c SUBROUTINE DGELSY1( M, N, NRHS, A, LDA, B, LDB, JPVT, RCOND,
120 c $ RANK, WORK, LWORK, INFO )
124 if( M.ne.N .and. istk(lRANK).lt.min(M,N) )then
125 call msgs(9,istk(lRANK))
127 call DLACPY( 'F', N, NRHS, stk(lXB), max(M,N), stk(lX), N )
128 c SUBROUTINE DLACPY( UPLO, M, N, A, LDA, B, LDB )