PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
example_dposv_f.f
Go to the documentation of this file.
2 *
3 *********************************************************************
4 * PLASMA example routine (version 2.4.5)
5 * Author: Bilel Hadri
6 * Release Date: November, 15th 2010
7 * PLASMA is a software package provided by Univ. of Tennessee,
8 * Univ. of California Berkeley and Univ. of Colorado Denver.
9 * @generated d Tue Nov 22 14:35:54 2011
10 *********************************************************************
11 *
12  IMPLICIT NONE
13 *
14  include "plasmaf.h"
15 *
16 * Purpose
17 * =======
18 *
19 * FORTRAN EXAMPLE FOR PLASMA_DPOSV
20 * Example for solving a system of linear equations using Cholesky
21 * factorization
22 *
23 * =====================================================================
24 *
25 * .. Parameters ..
26  INTEGER cores, n, nrhs
27  parameter( cores = 2 )
28  parameter( n = 15 )
29  parameter( nrhs = 5 )
30  COMPLEX*16 zone
31  parameter( zone = ( 1.0d+0, 0.0d+0 ) )
32 * ..
33 * .. Local Scalars ..
34  COMPLEX*16 a1( n, n ), b1( n, nrhs ), work( 2*n )
35  COMPLEX*16 a2( n, n ), b2( n, nrhs )
36  DOUBLE PRECISION d( n )
37  DOUBLE PRECISION rwork ( n )
38  INTEGER i, info
39  INTEGER iseed( 4 )
40  DOUBLE PRECISION xnorm, anorm, bnorm, rnorm, eps
41  DOUBLE PRECISION dlamch, dlange
42 * ..
43 * .. External Subroutines ..
44  EXTERNAL dlarnv, zlaghe, dlamch, dlange
46  EXTERNAL dgemm
47 * ..
48 * .. Executable Statements ..
49 *
50  DO i = 1, 4
51  iseed( i ) = 1
52  ENDDO
53 *
54 * Initialize Plasma
55 *
56  CALL plasma_init( cores, info )
57  WRITE(*,*) "-- PLASMA is initialized on", cores, "cores."
58 *
59 * Initialization of the matrix A1
60 *
61  CALL dlarnv( 1, iseed, n, d )
62  CALL zlaghe( n, n-1, d, a1, n, iseed, work, info )
63 *
64 * Make it definite positive
65 *
66  DO i = 1, n
67  a1( i, i ) = a1( i, i ) + n
68  ENDDO
69  a2(:,:)=a1(:,:)
70 *
71 * Initialization of the RHS
72 *
73  CALL zlarnv( 1, iseed, n*nrhs, b1 )
74  b2(:,:)=b1(:,:)
75 *
76 * Perform the Cholesky solve
77 *
78  CALL plasma_dposv( plasmaupper, n, nrhs, a2, n, b2, n, info )
79 *
80 * Check the solution
81 *
82  xnorm = dlange('I',n, nrhs, b2, n, rwork)
83  anorm = dlange('I',n, n, a1, n, rwork)
84  bnorm = dlange('I',n, nrhs, b1, n, rwork)
85 
86  CALL dgemm('No transpose','No transpose', n, nrhs, n, zone,
87  $ a1, n, b2, n, -zone, b1, n)
88 
89  rnorm = dlange('I',n, nrhs, b1, n, rwork)
90 
91  eps= dlamch('Epsilon')
92 
93  WRITE(*,*) '============'
94  WRITE(*,*) 'Checking the Residual of the solution '
95  WRITE(*,*) '-- ||Ax-B||_oo/((||A||_oo||x||_oo+||B||_oo).N.eps)=',
96  $ rnorm / ((anorm * xnorm + bnorm) * n * eps)
97 
98  IF ((rnorm > 60.0).AND.( info < 0 )) THEN
99  WRITE(*,*) "-- Error in DPOSV example !"
100  ELSE
101  WRITE(*,*) "-- Run of DPOSV example successful !"
102  ENDIF
103 *
104 * Finalize Plasma
105 *
106  CALL plasma_finalize( info )
107 *
108 * End of EXAMPLE_DPOSV.
109 *
110  END PROGRAM example_dposv_f