Copyright 1994-2004 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, CA 94303, U.S.A. All rights reserved. -------- IBLAS Example 1 -------- math% cat lin_sys.f95 PROGRAM lin_sys !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! This program shows how to use IBLAS routine ! TRSV for solving system of linear equations ! A*x = b ! ! WARNING. Matrix of the system should be with diagonal predominance. ! INPUT DATA: ! A(5,5) - matrix of the linear equation ! 13 1 2 3 2 ! 1 12 3 2 4 ! 1 1 11 3 2 ! 2 1 3 16 4 ! 3 2 1 5 18 ! ! b(5) - vector of the right parts ! 22.5 39, 30, 59.5, 40 ! ! This system of linear equations has the following solution: ! 0.5, 2, 1.5, 3, 1 ! ! The program finds intervals containing this solution: ! [0.49999999999999861,0.50000000000000145] ! [1.999999999999998,2.0000000000000027] ! [1.4999999999999982,1.5000000000000018] ! [2.9999999999999977,3.0000000000000018] ! [0.99999999999999822,1.0000000000000018] ! ! The solving method: ! ! Step1. The algorithm of LU expansion is applied to the matrix A. ! Matrixes L (lower triangular with unity plased diagonaly) ! and U (upper triangular) are written into the matrix A. ! ! Step2. Using IBLAS routine TRSV a triangular system is solved: ! L*y = b ! The result is written into array b ! ! Step3. By application of IBLAS routine TRSV a triangular system is solved: ! U*x = y ! vector x - is an unknown quantity decision, ! the result of which is written to array b !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! USE IATYPESUNPERF;USE IASUNPERF INTEGER, PARAMETER :: N = 5 INTERVAL a(N,N), x(N),y(N),b(N) INTEGER i, j, k, l, m ! Input matrix a: a(1,1:N) = (/[13], [1], [2], [3], [2]/) a(2,1:N) = (/[1], [12], [3], [2], [4]/) a(3,1:N) = (/[1], [1], [11], [3], [2]/) a(4,1:N) = (/[2], [1], [3], [16], [4]/) a(5,1:N) = (/[3], [2], [1], [5], [18]/) ! Input vector b: b(1:N) = (/[22.5_8], [39], [30], [59.5_8], [40]/) ! LU expansion l = N -1 DO k = 1, l m = k+1 a(k+1:n,k) = a(k+1:n,k)/a(k,k) DO j = m, N DO i = m, N a(i,j) = a(i,j) - a(i,k)*a(k,j) END DO END DO END DO ! Solving of the system L*y = b CALL TRSV_I(a, b, blas_lower, blas_no_trans, blas_unit_diag, [1._8]) ! Solving of the system U*x = y CALL TRSV_I(a, b, blas_upper, blas_no_trans, blas_non_unit_diag, [1._8]) PRINT*, " Solution of the system:" DO i=1,N WRITE(*,10) b(i) END DO 10 FORMAT(Y33.11) END PROGRAM lin_sys math%f95 -xia -dalign lin_sys.f95 -xlic_lib=suniperf math% a.out Solution of the system: 0.50000000000000 2.00000000000000 1.50000000000000 3.00000000000000 1.00000000000000 -------- IBLAS Example 2 -------- math%cat lin_sys_ia.f95 PROGRAM lin_sys !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! This program shows how to use IBLAS routine ! TRSV for solving interval system of linear equations ! A*x = b ! ! WARNING. Matrix of the system should be with diagonal predominance. ! INPUT DATA: ! A(5,5) - interval matrix of the linear equation ! [13, 13.1] [0.98, 1] [2, 2.03] [3, 3.03] [1.96, 2] ! [0.9, 1] [11.8, 12] [3] [2] [3.7, 4] ! [0.9, 1] [1, 1.03] [11, 11.2] [3] [2] ! [2, 2] [1, 1.07] [2.8, 3] [15.73, 16] [3.87, 4] ! [2.89, 3] [2, 2.05] [1, 1.09] [5] [17.8, 18] ! ! b(5) - vector of the right parts ! [22.5,2.6], [39, 39.08], [29.02, 30], [59.5, 59.6], [39.04, 40] ! ! ! The program finds intervals containing all solution this system: ! ! [0.41278254279267828,0.58609201690112456] ! [1.9274793383777839,2.1857570500282173] ! [1.2984648887924143,1.5612658893845497] ! [2.9420216678111259,3.1737989895019907] ! [0.85146900390660762,1.0604054728730122] ! ! The solving method: ! ! Step1. The algorithm of LU expansion is applied to the matrix A. ! Matrixes L (lower triangular with unity plased diagonaly) ! and U (upper triangular) ara written into the matrix A. ! ! Step2. Using IBLAS routine TRSV a triangular system is solved: ! L*y = b ! The result is written into array b ! ! Step3. By application of IBLAS routine TRSV a triangular system is solved: ! U*x = y ! vector x - is an unknown quantity decision, ! the result of which is written to array b !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! USE IATYPESUNPERF;USE IASUNPERF INTEGER, PARAMETER :: N = 5 INTEGER, PARAMETER :: kind = 8 INTERVAL a(N,N), x(N),y(N),b(N) INTEGER i, j, k, l, m ! Input matrix a: a(1,1:N) = (/[13, 13.1_kind], [0.98_kind, 1], [2,2.03_kind], [3, 3.03_kind], [1.96_kind, 2]/) a(2,1:N) = (/[0.9_kind, 1], [11.8_kind, 12], [3], [2], [3.7_kind, 4]/) a(3,1:N) = (/[0.9_kind, 1], [1, 1.03_kind], [11, 11.2_kind], [3], [2]/) a(4,1:N) = (/[2], [1, 1.07_kind], [2.8_kind, 3], [15.73_kind, 16], [3.87_kind,4]/) a(5,1:N) = (/[2.89_kind,3], [2, 2.05_kind], [1, 1.09_kind], [5], [17.8_kind,18]/) ! Input vector b: b(1:N) = (/[22.5_kind, 22.6_kind], [39, 39.08_kind], [29.02_kind,30], & [59.5_kind, 59.6_kind], [39.04_kind,40]/) ! LU expansion l = N -1 DO k = 1, l m = k+1 a(k+1:n,k) = a(k+1:n,k)/a(k,k) DO j = m, N DO i = m, N a(i,j) = a(i,j) - a(i,k)*a(k,j) END DO END DO END DO ! Solving of the system L*y = b CALL TRSV_I(a, b, blas_lower, blas_no_trans, blas_unit_diag, [1._8]) ! Solving of the system U*x = y CALL TRSV_I(a, b, blas_upper, blas_no_trans, blas_non_unit_diag, [1._8]) PRINT*, "" PRINT*, " -- Solution of the system: --" PRINT*, "" DO i=1,N WRITE(*,10) b(i) END DO 10 FORMAT(Y22.9) END PROGRAM lin_sys math% f95 -xia -dalign lin_sys_ia.f95 -xlic_lib=suniperf math% a.out -- Solution of the system: -- 0.5 2. [1.29 ,1.57 ] 3. [.851 ,1.07 ] -------- IBLAS Example 3 -------- math% cat simulation.f95 PROGRAM simulation !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! This program shows how to use IBLAS routine GBMV in simulation. ! ! We want to solve the following problem of the simulation. ! Let sensitivity matrix A be calculated beforehand ! and the values of variables D are know at the initial moment t_0 - D(t_0). ! It is required to know how these variables will change to the moment t_0 + 5, ! the step being set equal to 1.0. ! The values of variables at the moment t_i are solved by formula: ! ! D(t_i) = A*D(t_i-1) ! ! INPUT DATA: ! A(6,12) - interval sensitivity matrix ! ! D(12) - vector of the variables at the time t_0: ! ! We show that the matrix A is a band matrix, ! therefore it will be represented in band format ! ! The program finds the following values of variables at the moment t_0 + 5: ! ! [43.112730016774492,58.55637578192598] ! [5.3374764228693472,12.878799388316458] ! [11.764039044887818,17.037995872753819] ! [6.4700252695753732,11.511222849306695] ! [15.074069013762125,21.342772676003176] ! [14.393626076154417,24.276777777399705] ! [26.232408745661356,37.539386446144882] ! [20.905263679527777,27.231582305560732] ! [10.593215273894557,14.388387564471284] ! [15.506376729130048,19.722929218923931] ! [13.7579385074616,15.931658465921684] ! [11.108345298705444,12.338279330110336] ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! USE IATYPESUNPERF;USE IASUNPERF INTEGER, PARAMETER :: N = 12, M = 12, Mb = 6 INTEGER, PARAMETER :: kind = 8 INTERVAL a(Mb,N),d(N) INTEGER i, Nstep ! Input matrix A: do i = 1, Mb read*, a(i, 1:N) enddo ! Input vector D: do i = 1, N read*, d(i) enddo ! Solving of the vector D at the moment t_0+5 Nstep = 5 DO i= 1, Nstep CALL GBMV_I(a, M, 2, d, d, blas_no_trans, [1.], [1.]) END DO PRINT*, "" PRINT*, " Vector D at the moment t_0 + 5:" PRINT*, "" DO i=1,N PRINT*, d(i) END DO END PROGRAM simulation math% f95 -xia -dalign simulation.f95 -xlic_lib=suniperf math% a.out < simulation.in Vector D at the moment t_0 + 5: [43.112730016774492,58.55637578192598] [5.3374764228693472,12.878799388316458] [11.764039044887818,17.037995872753819] [6.4700252695753732,11.511222849306695] [15.074069013762125,21.342772676003176] [14.393626076154417,24.276777777399705] [26.232408745661356,37.539386446144882] [20.905263679527777,27.231582305560732] [10.593215273894557,14.388387564471284] [15.506376729130048,19.722929218923931] [13.7579385074616,15.931658465921684] [11.108345298705444,12.338279330110336] math% cat simulation.in [0] [0] [0] [0.11, 0.12] [0.028, 0.03] [-0.03,-0.023] [0.07, 0.08] [-0.06, -0.05] [0.06, 0.07] [-0.034, -0.03][0.56, 0.57] [0.09, 0.1] [0] [0] [0.9, 1] [-0.6, -0.58] [0.037, 0.038] [-0.08, -0.06] [0.07, 0.08] [0.26, 0.31] [-0.067, -0.05] [0.045, 0.046] [0.031, 0.032] [0.12, 0.13] [0] [0.09, 0.091] [0.1, 0.103] [0.11, 0.12] [0.03, 0.033] [0.02, 0.022] [-0.086, -0.08] [0.37, 0.375] [-0.01, -0.009] [0.067, 0.068] [-0.081, -0.078] [0.22, 0.224] [-0.023, -0.02 ] [0.009, 0.0091] [0.071, 0.075] [-0.051, -0.04] [0.2, 0.21] [0.07, 0.08] [-0.056, -0.05] [0.07, 0.08] [-0.011, -0.009] [0.067, 0.068] [-0.065, -0.047] [0.12, 0.124] [0.03, 0.034] [0.09, 0.091] [0.021, 0.023] [-0.01, -0.009] [0.03, 0.033] [0.2, 0.22] [-0.086, -0.08] [0.037, 0.0375] [-0.01, -0.009] [0.067, 0.068] [-0.081, -0.078] [0] [0] [0.019, 0.0191] [0.1, 0.103] [-0.11, -0.1] [0.03, 0.033] [0.02, 0.022] [-0.066, -0.06] [0.12, 0.135] [-0.01,-0.009] [0.027, 0.028] [0] [0] [9.5, 9.6] [18, 18.08] [2.02,3] [5.5, 5.6] [3.04,3.1] [5.9, 5.91] [6.1, 6.2] [4.6, 4.67] [7.8, 7.82] [3.4, 3.45] [3.06, 3.1] [8.2, 8.22]