summaryrefslogtreecommitdiff
path: root/Utilib/src/ALSVDS.f
blob: dfe50e928d55d6f6eb5a9460bc1ffc8947cb8960 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
*DECK ALSVDS
      SUBROUTINE ALSVDS(U,W,V,M,N,MP,NP,B,X)
*
*-----------------------------------------------------------------------
*
*Purpose:
* linear system solution after singular value decomposition.
*
*Copyright:
* Copyright (C) 1993 Ecole Polytechnique de Montreal
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version
*
*Author(s): A. Hebert
*
*Parameters: input
* U       first decomposed matrix.
* W       singular values.
* V       second decomposed matrix.
* M,N     first/second mathematical dimension of matrix A
* MP,NP   first/second physical dimension of matrix A
* B       RHS vector.
*
*Parameters: output
* X       solution vector.
*
*-----------------------------------------------------------------------
*
      INTEGER M,MP,N,NP
      DOUBLE PRECISION B(MP),U(MP,NP),V(NP,NP),W(NP),X(NP),S
      INTEGER I,J,JJ
      DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: TMP
*
      ALLOCATE(TMP(NP))
      DO 12 J=1,N
        S=0.0D0
        IF(W(J).NE.0.0D0)THEN
          DO 11 I=1,M
            S=S+U(I,J)*B(I)
11        CONTINUE
          S=S/W(J)
        ENDIF
        TMP(J)=S
12    CONTINUE
      DO 14 J=1,N
        S=0.0D0
        DO 13 JJ=1,N
          S=S+V(J,JJ)*TMP(JJ)
13      CONTINUE
        X(J)=S
14    CONTINUE
      DEALLOCATE(TMP)
      RETURN
      END