File: test_zcomplexmult.f

package info (click to toggle)
lapack 3.12.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,912 kB
  • sloc: fortran: 622,840; ansic: 217,704; f90: 6,041; makefile: 5,100; sh: 326; python: 270; xml: 182
file content (157 lines) | stat: -rw-r--r-- 4,664 bytes parent folder | download | duplicates (2)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
*> \brief zmul tests the robustness and precision of the double complex multiplication
*
*  =========== DOCUMENTATION ===========
*
* Online html documentation available at
*            http://www.netlib.org/lapack/explore-html/
*
*  Authors:
*  ========
*
*> \author Weslley S. Pereira, University of Colorado Denver, U.S.
*
*> \verbatim
*>
*> Tests:
*>
*> (a) Inf inputs:
*>    (1) y = ( Inf + 0   * I)
*>    (2) y = (-Inf + 0   * I)
*>    (3) y = ( 0   + Inf * I)
*>    (4) y = ( 0   - Inf * I)
*>    (5) y = ( Inf + Inf * I)
*> Tests:
*>    (a) 0 * y is NaN.
*>    (b) 1 * y is y is either y or NaN.
*>    (c) y * y is either  Inf or NaN (cases 1 and 3),
*>                 either -Inf or NaN (cases 2 and 4),
*>                 NaN (case 5).
*>
*> (b) NaN inputs:
*>    (1) y = (NaN + 0   * I)
*>    (2) y = (0   + NaN * I)
*>    (3) y = (NaN + NaN * I)
*> Tests:
*>    (a) 0 * y is NaN.
*>    (b) 1 * y is NaN.
*>    (c) y * y is NaN.
*>
*> \endverbatim
*
*> \ingroup auxOTHERauxiliary
*
*  =====================================================================
      program zmul
*
*  -- LAPACK test routine --
*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..

*     ..
*     .. Constants ..
      integer           nNaN, nInf
      parameter       ( nNaN = 3, nInf = 5 )
      double complex    czero, cone
      parameter       ( czero = DCMPLX( 0.0d0, 0.0d0 ),
     $                  cone  = DCMPLX( 1.0d0, 0.0d0 ) )
*     ..
*     .. Local Variables ..
      integer           i, nFailingTests, nTests
      double precision  aInf, aNaN, OV
      double complex    Y, R, cInf( nInf ), cNaN( nNaN )
*
*     .. Intrinsic Functions ..
      intrinsic         HUGE, DCMPLX

*
*     .. Initialize error counts ..
      nFailingTests = 0
      nTests = 0
*
*     .. Inf entries ..
      OV = HUGE(0.0d0)
      aInf = OV * 2
      cInf(1) = DCMPLX( aInf, 0.0d0 )
      cInf(2) = DCMPLX(-aInf, 0.0d0 )
      cInf(3) = DCMPLX( 0.0d0, aInf )
      cInf(4) = DCMPLX( 0.0d0,-aInf )
      cInf(5) = DCMPLX( aInf,  aInf )
*
*     .. NaN entries ..
      aNaN = aInf / aInf
      cNaN(1) = DCMPLX( aNaN, 0.0d0 )
      cNaN(2) = DCMPLX( 0.0d0, aNaN )
      cNaN(3) = DCMPLX( aNaN,  aNaN )

*
*     .. Tests ..
*
*     Test (a) Infs
      do 10 i = 1, nInf
          nTests = nTests + 3
          Y = cInf(i)
          R = czero * Y
          if( R .eq. R ) then
              nFailingTests = nFailingTests + 1
              WRITE( *, FMT = 9998 ) 'ia',i, czero, Y, R, 'NaN'
          endif
          R = cone * Y
          if( (R .ne. Y) .and. (R .eq. R) ) then
              nFailingTests = nFailingTests + 1
              WRITE( *, FMT = 9998 ) 'ib',i, cone, Y, R,
     $                               'the input and NaN'
          endif
          R = Y * Y
          if( (i.eq.1) .or. (i.eq.2) ) then
              if( (R .ne. cInf(1)) .and. (R .eq. R) ) then
                  nFailingTests = nFailingTests + 1
                  WRITE( *, FMT = 9998 ) 'ic',i, Y, Y, R, 'Inf and NaN'
              endif
          else if( (i.eq.3) .or. (i.eq.4) ) then
              if( (R .ne. cInf(2)) .and. (R .eq. R) ) then
                  nFailingTests = nFailingTests + 1
                  WRITE( *, FMT = 9998 ) 'ic',i, Y, Y, R, '-Inf and NaN'
              endif
          else 
              if( R .eq. R ) then
                  nFailingTests = nFailingTests + 1
                  WRITE( *, FMT = 9998 ) 'ic',i, Y, Y, R, 'NaN'
              endif
          endif
  10  continue
*
*     Test (b) NaNs
      do 20 i = 1, nNaN
          nTests = nTests + 3
          Y = cNaN(i)
          R = czero * Y
          if( R .eq. R ) then
              nFailingTests = nFailingTests + 1
              WRITE( *, FMT = 9998 ) 'na',i, czero, Y, R, 'NaN'
          endif
          R = cone * Y
          if( R .eq. R ) then
              nFailingTests = nFailingTests + 1
              WRITE( *, FMT = 9998 ) 'nb',i, cone, Y, R, 'NaN'
          endif
          R = Y * Y
          if( R .eq. R ) then
              nFailingTests = nFailingTests + 1
              WRITE( *, FMT = 9998 ) 'nc',i, Y, Y, R, 'NaN'
          endif
  20  continue
*
      if( nFailingTests .gt. 0 ) then
         print *, "# ", nTests-nFailingTests, " tests out of ", nTests,
     $      " pass for complex multiplication,", nFailingTests," fail."
      else
         print *, "# All tests pass for complex multiplication."
      endif
*
*     .. Formats ..
 9998 FORMAT( '[',A2,I1, '] (', (ES24.16E3,SP,ES24.16E3,"*I"), ') * (',
     $         (ES24.16E3,SP,ES24.16E3,"*I"), ') = (',
     $         (ES24.16E3,SP,ES24.16E3,"*I"), ') differs from ', A17 )
*
*     End of zmul
*
      END