14 January 2017 02:55:30 PM R4LIB_PRB C version Test the R4LIB library. TEST001 R4_ABS returns the absolute value of an R4. -1.252654 1.252654 4.650541 4.650541 3.636074 3.636074 1.493564 1.493564 0.322457 0.322457 -2.471050 2.471050 -0.939378 0.939378 -2.120346 2.120346 -2.649368 2.649368 2.071726 2.071726 TEST002 R4_ATAN computes the arc-tangent given Y and X; ATAN2 is the system version of this routine. X Y ATAN2(Y,X) ATAN4(Y,X) 1.000000 0.000000 0.000000 0.000000 1.000000 1.000000 0.785398 0.785398 0.000000 1.000000 1.570796 1.570796 -1.000000 1.000000 2.356194 2.356194 -1.000000 0.000000 3.141593 3.141593 -1.000000 -1.000000 -2.356194 3.926991 0.000000 -1.000000 -1.570796 4.712389 1.000000 -1.000000 -0.785398 5.497787 TEST003 R4_CAS evaluates the casine of a number. X R4_CAS ( X ) 0.000000 1.000000 0.261799 1.224745 0.523599 1.366025 0.785398 1.414214 1.047198 1.366025 1.308997 1.224745 1.570796 1.000000 1.832596 0.707107 2.094395 0.366025 2.356194 -0.000000 2.617994 -0.366026 2.879793 -0.707107 3.141593 -1.000000 TEST004 R4_CEILING rounds a value up. -1.200000 -1.000000 -1.000000 -1.000000 -0.800000 0.000000 -0.600000 0.000000 -0.400000 0.000000 -0.200000 0.000000 0.000000 0.000000 0.200000 1.000000 0.400000 1.000000 0.600000 1.000000 0.800000 1.000000 1.000000 1.000000 1.200000 2.000000 TEST005 R4_DIFF computes a difference X-Y to a given number of binary places. For this test, we use 3 binary places. X Y X-Y R4_DIFF(X,Y) 1.000000 0.062500 0.937500 0.875000 1.000000 0.125000 0.875000 0.875000 1.000000 0.250000 0.750000 0.750000 1.000000 0.500000 0.500000 0.500000 1.000000 0.874000 0.126000 0.125000 1.000000 0.876000 0.124000 0.125000 1.000000 0.900000 0.100000 0.125000 1.000000 0.950000 0.050000 0.000000 1.000000 0.990000 0.010000 0.000000 1.000000 1.000000 0.000000 0.000000 1.000000 1.010000 -0.010000 0.000000 1.000000 1.050000 -0.050000 0.000000 1.000000 1.100000 -0.100000 -0.137500 1.000000 3.000000 -2.000000 -1.875000 1.000000 10.000000 -9.000000 -8.750000 TEST006 R4_DIGIT extracts decimal digits. Here, we get digits of 3.1415927410125732 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 0 0 0 3 1 4 1 5 9 2 7 4 1 0 1 2 5 7 3 2 4 2 1 TEST007 R4_EPSILON produces the R4 roundoff unit. R = R4_EPSILON() = 1.192093e-07 ( 1 + R ) - 1 = 1.192093e-07 ( 1 + (R/2) ) - 1 = 0.000000e+00 TEST009 R4_HUGE returns a large R4 value; R4_HUGE = 3.40282e+38 TEST010 R4_LOG_2 computes the logarithm base 2. X, R4_LOG_2 0 -1e+30 1 0 2 1 3 1.58496 9 3.16992 10 3.32193 11 3.45943 99 6.62936 101 6.65821 -1 0 -2 1 -3 1.58496 -9 3.16992 0.5 -1 0.33 -1.59946 0.25 -2 0.2 -2.32193 0.01 -6.64386 TEST023 R4_SIGN returns the sign of an R4. R4_SIGN3 returns the three-way sign of an R4. R4 R4_SIGN(R4) R4_SIGN3(R4) -1.2500 -1 -1 -0.2500 -1 -1 0.0000 1 0 0.5000 1 1 9.0000 1 1 TEST0235 R4_SWAP swaps two reals. Before swapping: X = 1.000000 Y = 3.141590 After swapping: X = 3.141590 Y = 1.000000 TEST026 R4_UNIFORM_AB produces a random real in a given range. Using range 10.000000 <= A <= 25.000000. I A 0 10.001996 1 13.542136 2 22.679358 3 21.955784 4 10.855645 5 20.834593 6 21.996376 7 18.110504 8 18.220585 9 23.346687 TEST027 R4_UNIFORM_01 produces a sequence of random values. Using random seed 123456789. SEED R4_UNIFORM_01(SEED) 123456789 0.218418 469049721 0.956318 2053676357 0.829509 1781357515 0.561695 1206231778 0.415307 891865166 0.066119 141988902 0.257578 553144097 0.109957 236130416 0.043829 94122056 0.633966 Verify that the sequence can be restarted. Set the seed back to its original value, and see that we generate the same sequence. SEED R4_UNIFORM_01(SEED) 123456789 0.218418 469049721 0.956318 2053676357 0.829509 1781357515 0.561695 1206231778 0.415307 891865166 0.066119 141988902 0.257578 553144097 0.109957 236130416 0.043829 94122056 0.633966 TEST028 R4_UNIFORM_01 samples a uniform random distribution in [0,1]. distributed random numbers. Using initial random number seed = 123456789 First few values: 0 0.218418 1 0.956318 2 0.829509 3 0.561695 4 0.415307 5 0.066119 6 0.257578 7 0.109957 8 0.043829 9 0.633966 Number of samples was 1000 Minimum value was 0.001838 Maximum value was 0.997908 Average value was 0.503040 Variance was 0.082332 TEST12555 R4VEC_INDICATOR0_NEW returns an indicator vector. Indicator0 vector: 0: 0.000000 1: 1.000000 2: 2.000000 3: 3.000000 4: 4.000000 5: 5.000000 6: 6.000000 7: 7.000000 8: 8.000000 9: 9.000000 R4LIB_PRB Normal end of execution. 14 January 2017 02:55:30 PM