[MAP Logo]

Materials Algorithms Project
Program Library



Subroutine MAP_UTIL_3DSOLV

  1. Provenance of code.
  2. Purpose of code.
  3. Specification.
  4. Description of subroutine's operation.
  5. References.
  6. Parameter descriptions.
  7. Error indicators.
  8. Accuracy estimate.
  9. Any additional information.
  10. Example of code
  11. Auxiliary subroutines required.
  12. Keywords.
  13. Download source code.
  14. Links.

Provenance of Source Code

D. Gaude-Fugarolas,
Phase Transformations Group,
Department of Materials Science and Metallurgy,
University of Cambridge,
Cambridge CB2 3QZ, U.K.

E-mail: dg241@cam.ac.uk
 
 

Added to MAP:  2006.

Top | Next

Purpose

This routine solves a tri-diagonal system of simultaneous linear equations AX=B.

Top | Next | Prev

Specification

 
Language:  FORTRAN 
Product form:  Source code. 
 
    SUBROUTINE D3SOLV(N, DA, UA, LA, B, X)


    INTEGER N
    DOUBLE PRECISION DA(N), UA(N), LA(N), B(N), X(N)
Top | Next | Prev

Description

The routine solves tri-diagonal systems of simultaneous linear equations (AX=B). The matrices are assumed to be of dimension N=3 or larger, and tri-diagonal. Only the positions at the main diagonal of the coefficient matrix A and the upper and lower subdiagonals are non-zero. The rest of the positions in such matrix are zero.

The main diagonal and the lower and upper subdiagonals are sent to the routine in vectors DA(1-N), LA(1-(N-1)), UA(2-N), respectively. The independent coefficient vector B is sent in vector B(1-N). The system is solved and the results are returned to the main program in the vector B(1-N).

Top | Next | Prev

References

  1. Bonet, C.; Jorba, A.; M-Seara, M.T.; Masdemont, J.; Olle, M.; Susin, A.; Valencia, M. Calcul numeric. Universitat Politecnica de Catalunya, Barcelona, 1993.
Top | Next | Prev

Parameters

Input parameters

N- integer
N is the dimension of the system.
DA - double precision array of dimension N
DA is an array containing the main diagonal of the coefficient matrix A.
UA - double precision array of dimension N.
UA is an array containing the upper subdiagonal of the coefficient matrix A. Only positions 1 to (N-1) are used.
LA - double precision array of dimension N
LA is an array containing the lower subdiagonal of the coefficient matrix A. Only positions 2 to N are used.
B - double precision array of dimension N
B is an array containing the elements of the independent coefficient vector B.

Output parameters

B - double precision array of dimension N
B is an array containing the result of solving the system, X.
Top | Next | Prev

Error Indicators

None.

Top | Next | Prev

Accuracy

This is not an approximate method. The result is as accurate as the computer calculations allow using double precision.

Top | Next | Prev

Further Comments

None.

Top | Next | Prev

Example

1. Program text
    PROGRAM TEST3DS

C
C      ...PARAMETERS...
      INTEGER           NMAX
      PARAMETER         (NMAX=100)
      INTEGER           NIN, NOUT
      PARAMETER         (NIN=5,NOUT=6)
C
C      ...LOCAL SCALARS...
C
      INTEGER           I, N
C
C      ...Arrays...
C
      DOUBLE PRECISION DA(NMAX), UA(NMAX), LA(NMAX), B(NMAX), X(NMAX)
C
C      ...Program starts...
C      ...Reads entries...
C
      WRITE(NOUT,*) 'Dimension?'
      READ(NIN,*) N
      WRITE(NOUT,*) 'Main diagonal:', N, 'values'
      READ(NIN,*) (DA(I), I=1, N)
      WRITE(NOUT,*) 'Upper diagonal:', (N-1), ' values'
      READ(NIN,*) (UA(I), I=1, (N-1))
      WRITE(NOUT,*) 'Lower diagonal:', (N-1), 'values'
      READ(NIN,*) (LA(I), I=2, N)
      WRITE(NOUT,*) 'Independent terms:', N, 'values'
      READ(NIN,*) (B(I), I=1, N)
CC
C      ...Calls routine...
C
      CALL D3SOLV(N, DA, UA, LA, B, X)
C
C     ...and shows results...
C
      WRITE(NOUT,*) 'Solution vector'
      WRITE(NOUT,*)(X(I), I=1, N)
      WRITE(NOUT,*)'and new upper diagonal'
      WRITE(NOUT,*)(UA(I), I=1, (N-1))
C
C     ...End of program...
C 
      STOP
      END

2. Program data

5
3.0    2.3    -5.0    -0.9    7.1
2.1    -1.0    1.9    8.0
3.4    3.6    7.0    -6.0
2.7    0.5    2.6    0.6    2.7

3. Program results

-4.000    7.000    3.000    -4.000 -3.000
Top | Next | Prev

Auxiliary Routines

None.

Top | Next | Prev

Keywords

tri-diagonal

Top | Next | Prev

Download

Download source code

Top | Prev


MAP originated from a joint project of the National Physical Laboratory and the University of Cambridge.

MAP originated from a joint project of the National Physical Laboratory and the University of Cambridge.

Top | MAP Homepage