1 c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 c Copyright (C) 2013 - Michael Baudin
5 c This file must be used under the terms of the CeCILL.
6 c This source file is licensed as described in the file COPYING, which
7 c you should have received as part of this distribution. The terms
8 c are also available at
9 c http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11 subroutine intdgesv3(fname)
16 logical getrhsvar,createvar
17 logical checklhs,checkrhs
19 double precision ANORM, EPS, RCOND
20 double precision dlamch, dlange
21 double precision RCONDthresh
23 external dlamch, dlange, vfinite
32 if(.not.checkrhs(fname,minrhs,maxrhs)) return
33 if(.not.checklhs(fname,minlhs,maxlhs)) return
35 if(.not.getrhsvar(1,'d', MA, NA, lA)) return
36 if(.not.getrhsvar(2,'d', MB, NRHS, lB)) return
47 if(M.eq.0 .or. N.eq.0) then
48 if(.not.createvar(3,'d', 0, 0, lX)) return
52 c Check if A and B matrices contains Inf or NaN's
53 if (vfinite(M*N, stk(lA)).eq.0) then
57 if (vfinite(MB*NRHS, stk(lB)).eq.0) then
63 if(.not.createvar(3,'d', M, N, lAF)) return
64 if(.not.createvar(4,'d', N, NRHS, lX)) return
65 if(.not.createvar(5,'d', max(M,N), NRHS, lXB)) return
66 if(.not.createvar(6,'i', 1, 1, lRANK)) return
67 if(.not.createvar(7,'i', 1, N, lIPIV)) return
68 if(.not.createvar(8,'i', 1, N, lJPVT)) return
69 if(.not.createvar(9,'i', 1, N, lIWORK)) return
70 LWORKMIN = max( 4*N, min(M,N)+3*N+1, 2*min(M,N)+NRHS )
72 if(LWORK.le.LWORKMIN) then
77 if(.not.createvar(10,'d',1,LWORK,lDWORK)) return
81 ANORM = dlange( '1', M, N, stk(lA), M, stk(lDWORK) )
87 call DLACPY( 'F', N, N, stk(lA), N, stk(lAF), N )
88 c SUBROUTINE DLACPY( UPLO, M, N, A, LDA, B, LDB )
89 call DGETRF( N, N, stk(lAF), N, istk(lIPIV), INFO )
90 c SUBROUTINE DGETRF( N, N, A, LDA, IPIV, INFO )
93 call DGECON( '1', N, stk(lAF), N, ANORM, RCOND, stk(lDWORK),
94 $ istk(lIWORK), INFO )
95 c SUBROUTINE DGECON( NORM, N, A, LDA, ANORM, RCOND, WORK,
97 if(RCOND.gt.RCONDthresh) then
98 call DGETRS( 'N', N, NRHS, stk(lAF), N, istk(lIPIV),
100 c SUBROUTINE DGETRS( TRANS, N, NRHS, A, LDA, IPIV,
102 call DLACPY( 'F', N, NRHS, stk(lB), N, stk(lX), N )
103 c SUBROUTINE DLACPY( UPLO, M, N, A, LDA, B, LDB )
108 call writebufdgesv3(buf,RCOND)
112 c M.ne.N or A singular
115 call DLACPY( 'F', M, NRHS, stk(lB), M, stk(lXB), max(M,N) )
116 c SUBROUTINE DLACPY( UPLO, M, N, A, LDA, B, LDB )
120 call DGELSY1( M, N, NRHS, stk(lA), M, stk(lXB), max(M,N),
121 $ istk(lJPVT), RCOND, istk(lRANK), stk(lDWORK),
123 c SUBROUTINE DGELSY1( M, N, NRHS, A, LDA, B, LDB, JPVT, RCOND,
124 c $ RANK, WORK, LWORK, INFO )
128 if( M.ne.N .and. istk(lRANK).lt.min(M,N) )then
129 call msgs(9,istk(lRANK))
131 call DLACPY( 'F', N, NRHS, stk(lXB), max(M,N), stk(lX), N )
132 c SUBROUTINE DLACPY( UPLO, M, N, A, LDA, B, LDB )