June 24 2002 2:56:57.499 PM SUBPAK_PRB A set of test programs for SUBPAK. TEST001 ACOSH2 computes the inverse hyperbolic cosine of a given value. X ACOSH2(X) COSH(ACOSH2(X)) 1.00000 0.00000 1.00000 1.20000 0.622362 1.20000 1.40000 0.867015 1.40000 1.60000 1.04697 1.60000 1.80000 1.19291 1.80000 2.00000 1.31696 2.00000 2.20000 1.42542 2.20000 2.40000 1.52208 2.40000 2.60000 1.60944 2.60000 2.80000 1.68924 2.80000 3.00000 1.76275 3.00000 TEST002 AGUD computes the inverse Gudermannian; GUD computes the Gudermannian. X GUD(X) AGUD(GUD(X)) 1.00000 0.865770 1.00000 1.20000 0.985692 1.20000 1.40000 1.08725 1.40000 1.60000 1.17236 1.60000 1.80000 1.24316 1.80000 2.00000 1.30176 2.00000 2.20000 1.35009 2.20000 2.40000 1.38986 2.40000 2.60000 1.42252 2.60000 2.80000 1.44933 2.80000 3.00000 1.47130 3.00000 TEST003 ASINH2 computes the inverse hyperbolic sine of a given value. X ASINH2(X) SINH(ASINH2(X)) 1.00000 0.881374 1.00000 1.20000 1.01597 1.20000 1.40000 1.13798 1.40000 1.60000 1.24898 1.60000 1.80000 1.35044 1.80000 2.00000 1.44364 2.00000 2.20000 1.52966 2.20000 2.40000 1.60944 2.40000 2.60000 1.68374 2.60000 2.80000 1.75323 2.80000 3.00000 1.81845 3.00000 TEST004 ATAN4 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.00000 0.00000 0.00000 0.00000 1.00000 1.00000 0.785398 0.785398 0.00000 1.00000 1.57080 1.57080 -1.00000 1.00000 2.35619 2.35619 -1.00000 0.00000 3.14159 3.14159 -1.00000 -1.00000 -2.35619 3.92699 0.00000 -1.00000 -1.57080 4.71239 1.00000 -1.00000 -0.785398 5.49779 TEST005 ATANH2 computes the inverse hyperbolic tangent of a given value. X ATANH2(X) TANH(ATANH2(X)) -0.200000 -0.202733 -0.200000 -0.100000 -0.100335 -0.100000 0.00000 0.00000 0.00000 0.100000 0.100335 0.100000 0.200000 0.202733 0.200000 0.300000 0.309520 0.300000 0.400000 0.423649 0.400000 0.500000 0.549306 0.500000 0.600000 0.693147 0.600000 0.700000 0.867301 0.700000 0.800000 1.09861 0.800000 0.900000 1.47222 0.900000 TEST006 AXIS_LIMITS adjusts plot limits to "nicer" values. Input XMIN = 67.3000 Input XMAX = 114.700 Input NDIVS = 6 Output PXMIN = 60.0000 Output PXMAX = 120.000 Output PXDIV = 10.0000 Output NTICKS = 5 Input XMIN = -26.0000 Input XMAX = 26.0000 Input NDIVS = 10 Output PXMIN = -50.0000 Output PXMAX = 50.0000 Output PXDIV = 10.0000 Output NTICKS = 5 TEST007 AXIS_LIMITS computes "nice" limits for a graph that must include a given range. All tests use NDIVS = 5 XMIN XMAX PXMIN PXMAX PXDIV NTICKS 1.000 9.000 0.000 10.00 2.000 4 1.003 4.125 1.000 6.000 1.000 5 101.3 193.8 100.0 200.0 20.00 4 2000. 2000. 2000. 2000. 0.4000E-01 4 -7.000 12.00 -8.000 12.00 4.000 4 TEST008 BAR_CHECK checks digits for a barcode; BAR_CODE computes the barcode for a string of 11 digits; BAR_DIGIT_CODE returns the left and right codes for each digit. Check digit is 5 Digit code: 0 0001101 1110010 1 0011001 1100110 2 0010011 1101100 3 0111101 1000010 4 0100011 1011100 5 0110001 1001110 6 0101111 1010000 7 0111011 1000100 8 0110111 1001000 9 0001011 1110100 Bar code: 000000000 101 0001101 0011001 0010011 0111101 0100011 0110001 01010 1010000 1000100 1001000 1110100 1110010 1001110 101 000000000 TEST0083 BMI_ENGLISH computes the Body Mass Index given body measurements in English Units. Weight(LB) Height (FT/IN) BMI 236.48 6.00 9.00 25.34 217.73 4.00 1.00 63.76 149.52 5.00 2.00 27.35 117.04 6.00 3.00 14.63 177.19 5.00 6.00 28.60 129.32 5.00 2.00 23.65 127.19 5.00 11.00 17.74 199.39 4.00 10.00 41.67 197.96 5.00 2.00 36.21 237.76 4.00 8.00 53.30 TEST0084 C_NORMAL_01_SAMPLE generates normally distributed random complex values. 0.288551 1.42294 1.07249 -0.182904 -0.501935 -2.13655 -1.85156 0.268764 0.398210 0.378190E-01 1.02089 0.799745 0.216596 -0.308038 0.659823 -1.48213 0.329679 -0.102432 0.632422 1.64288 2.44420 -0.362843 -1.97842 -1.49765 -0.558356 -0.539447 0.168059 0.942494 -1.55518 -1.64900 1.35987 -0.480618 -1.61881 0.932824 0.480319 1.73089 0.162274 -1.34094 1.52209 -0.942060E-01 TEST0085 CHVEC_PERMUTE applies a permutation to a character vector. Using random number seed SEED = 1685103564 The random permutation: 1 10 2 6 3 5 4 4 5 1 6 3 7 9 8 7 9 8 10 2 CHVEC before permutation: ABCDEFGHIJ CHVEC after permutation: JFEDACIGHB TEST011 For products of prime factors: FAC_DIV computes a quotient; FAC_MUL multiplies; FAC_LCM computes the LCM; FAC_GCD computes the GCD; I_TO_FAC converts an integer; FAC_TO_I converts to an integer. FAC_TO_RAT converts to a ratio. Representation of I1 = 720 Prime Power 2 4 3 2 5 1 Representation of I2 = 42 Prime Power 2 1 3 1 7 1 LCM of I1, I2: Prime Power 2 4 3 2 5 1 7 1 GCD of I1, I2: Prime Power 2 1 3 1 Product of I1, I2: Prime Power 2 5 3 3 5 1 7 1 Quotient of I2 / I1: Prime Power 2 -3 3 -1 5 -1 7 1 Quotient as a rational: 7 / 120 TEST012 GET_SEED gets a seed for the random number generator. These values are computed from the time and date. Values computed nearby in time will be near to each other, and should be passed through a random number generator a few times before use. I R(I) R2(I) R3(I) 1692985553 1997350168 2147387319 528498951 1347945122 1108673251 1903208185 451043230 1348303394 687699814 413785744 944950422 1348303394 687699814 413785744 944950422 1348303394 687699814 413785744 944950422 1348303394 687699814 413785744 944950422 1348303394 687699814 413785744 944950422 1348303394 687699814 413785744 944950422 1348303394 687699814 413785744 944950422 1348303394 687699814 413785744 944950422 TEST013 GRID1 computes a 1D grid between two NDIM dimensional points X1 and X2. Here, we will use 11 steps going from 1.000 0.000 20.00 -5.000 1.000 to 1.000 10.00 0.000 5.000 2.000 The grid matrix: 1 2 3 4 5 1 1.000000 1.000000 1.000000 1.000000 1.000000 2 0.000000 1.000000 2.000000 3.000000 4.000000 3 20.000000 18.000000 16.000000 14.000000 12.000000 4 -5.000000 -4.000000 -3.000000 -2.000000 -1.000000 5 1.000000 1.100000 1.200000 1.300000 1.400000 6 7 8 9 10 1 1.000000 1.000000 1.000000 1.000000 1.000000 2 5.000000 6.000000 7.000000 8.000000 9.000000 3 10.000000 8.000000 6.000000 4.000000 2.000000 4 0.000000 1.000000 2.000000 3.000000 4.000000 5 1.500000 1.600000 1.700000 1.800000 1.900000 11 1 1.000000 2 10.000000 3 0.000000 4 5.000000 5 2.000000 TEST014 GRID1N computes a 1D grid between two NDIM dimensional points X1 and X2, one point at a time. Here, we will use 11 steps going from 1.000 0.000 20.00 -5.000 1.000 to 1.000 10.00 0.000 5.000 2.000 1 1.000 0.000 20.00 -5.000 1.000 2 1.000 1.000 18.00 -4.000 1.100 3 1.000 2.000 16.00 -3.000 1.200 4 1.000 3.000 14.00 -2.000 1.300 5 1.000 4.000 12.00 -1.000 1.400 6 1.000 5.000 10.00 0.000 1.500 7 1.000 6.000 8.000 1.000 1.600 8 1.000 7.000 6.000 2.000 1.700 9 1.000 8.000 4.000 3.000 1.800 10 1.000 9.000 2.000 4.000 1.900 11 1.000 10.00 0.000 5.000 2.000 TEST015 GRID2 computes a 1 D grid between two NDIM dimensional points X1 and X2, computing X1 and X2 at user specified times. Here, we will use 20 steps, and on step 3 we will compute 1.000 0.000 20.00 -5.000 1.000 and on step 13 we will compute 1.000 10.00 0.000 5.000 2.000 The grid matrix: 1 2 3 4 5 1 1.000000 1.000000 1.000000 1.000000 1.000000 2 -2.000000 -1.000000 0.000000 1.000000 2.000000 3 24.000000 22.000000 20.000000 18.000000 16.000000 4 -7.000000 -6.000000 -5.000000 -4.000000 -3.000000 5 0.800000 0.900000 1.000000 1.100000 1.200000 6 7 8 9 10 1 1.000000 1.000000 1.000000 1.000000 1.000000 2 3.000000 4.000000 5.000000 6.000000 7.000000 3 14.000000 12.000000 10.000000 8.000000 6.000000 4 -2.000000 -1.000000 0.000000 1.000000 2.000000 5 1.300000 1.400000 1.500000 1.600000 1.700000 11 12 13 14 15 1 1.000000 1.000000 1.000000 1.000000 1.000000 2 8.000000 9.000000 10.000000 11.000000 12.000000 3 4.000000 2.000000 0.000000 -2.000000 -4.000000 4 3.000000 4.000000 5.000000 6.000000 7.000000 5 1.800000 1.900000 2.000000 2.100000 2.200000 16 17 18 19 20 1 1.000000 1.000000 1.000000 1.000000 1.000000 2 13.000000 14.000000 15.000000 16.000000 17.000000 3 -6.000000 -8.000000 -10.000000 -12.000000 -14.000000 4 8.000000 9.000000 10.000000 11.000000 12.000000 5 2.300000 2.400000 2.500000 2.600000 2.700000 TEST016 GRID2N computes points from a 1D grid between two NDIM dimensional points X1 and X2, one at a time, with X1 and X2 having user specified I coordinates. Here, on step 3 we would compute 1.000 0.000 20.00 -5.000 1.000 and on step 13 we would compute 1.000 10.00 0.000 5.000 2.000 1 1.000 -2.000 24.00 -7.000 0.8000 2 1.000 -1.000 22.00 -6.000 0.9000 3 1.000 0.000 20.00 -5.000 1.000 4 1.000 1.000 18.00 -4.000 1.100 5 1.000 2.000 16.00 -3.000 1.200 6 1.000 3.000 14.00 -2.000 1.300 7 1.000 4.000 12.00 -1.000 1.400 8 1.000 5.000 10.00 0.000 1.500 9 1.000 6.000 8.000 1.000 1.600 10 1.000 7.000 6.000 2.000 1.700 11 1.000 8.000 4.000 3.000 1.800 12 1.000 9.000 2.000 4.000 1.900 13 1.000 10.00 0.000 5.000 2.000 14 1.000 11.00 -2.000 6.000 2.100 15 1.000 12.00 -4.000 7.000 2.200 16 1.000 13.00 -6.000 8.000 2.300 17 1.000 14.00 -8.000 9.000 2.400 18 1.000 15.00 -10.00 10.00 2.500 19 1.000 16.00 -12.00 11.00 2.600 20 1.000 17.00 -14.00 12.00 2.700 TEST017 GRID3 computes a 2D grid in the plane containing the NDIM-dimensional points X1, X2 and X3. Here, we will use 3 steps going from 1.000 0.000 20.00 -5.000 1.000 to 1.000 10.00 0.000 5.000 2.000 and 6 steps going to 1.000 5.000 0.000 0.000 3.000 1 1 1.000 0.000 20.00 -5.000 1.000 1 2 1.000 1.000 16.00 -4.000 1.400 1 3 1.000 2.000 12.00 -3.000 1.800 1 4 1.000 3.000 8.000 -2.000 2.200 1 5 1.000 4.000 4.000 -1.000 2.600 1 6 1.000 5.000 0.000 0.000 3.000 2 1 1.000 5.000 10.00 0.000 1.500 2 2 1.000 6.000 6.000 1.000 1.900 2 3 1.000 7.000 2.000 2.000 2.300 2 4 1.000 8.000 -2.000 3.000 2.700 2 5 1.000 9.000 -6.000 4.000 3.100 2 6 1.000 10.00 -10.00 5.000 3.500 3 1 1.000 10.00 0.000 5.000 2.000 3 2 1.000 11.00 -4.000 6.000 2.400 3 3 1.000 12.00 -8.000 7.000 2.800 3 4 1.000 13.00 -12.00 8.000 3.200 3 5 1.000 14.00 -16.00 9.000 3.600 3 6 1.000 15.00 -20.00 10.00 4.000 TEST018 GRID3D computes a point from a 2D grid in the plane containing the NDIM-dimensional points X1, X2 and X3. We use 3 steps from 1.000 0.000 20.00 -5.000 1.000 to 1.000 10.00 0.000 5.000 2.000 and 6 steps going to 1.000 5.000 0.000 0.000 3.000 1 1 1.000 0.000 20.00 -5.000 1.000 1 2 1.000 1.000 16.00 -4.000 1.400 1 3 1.000 2.000 12.00 -3.000 1.800 1 4 1.000 3.000 8.000 -2.000 2.200 1 5 1.000 4.000 4.000 -1.000 2.600 1 6 1.000 5.000 0.000 0.000 3.000 2 1 1.000 5.000 10.00 0.000 1.500 2 2 1.000 6.000 6.000 1.000 1.900 2 3 1.000 7.000 2.000 2.000 2.300 2 4 1.000 8.000 -2.000 3.000 2.700 2 5 1.000 9.000 -6.000 4.000 3.100 2 6 1.000 10.00 -10.00 5.000 3.500 3 1 1.000 10.00 0.000 5.000 2.000 3 2 1.000 11.00 -4.000 6.000 2.400 3 3 1.000 12.00 -8.000 7.000 2.800 3 4 1.000 13.00 -12.00 8.000 3.200 3 5 1.000 14.00 -16.00 9.000 3.600 3 6 1.000 15.00 -20.00 10.00 4.000 TEST019 GRID4 computes a 2D planar grid containing the NDIM-dimensional points X1, X2 and X3. We compute the points on the following steps: X1 on step 2 3 X2 on step 5 3 X3 on step 2 9 We use 6 steps in the I direction and 10 steps in the J direction. The points X1, X2 and X3 are: 1.000 0.000 20.00 -5.000 1.000 1.000 10.00 0.000 5.000 2.000 1.000 5.000 0.000 0.000 3.000 1 1 1.000 -5.000 33.33 -10.00 0.000 1 2 1.000 -4.167 30.00 -9.167 0.3333 1 3 1.000 -3.333 26.67 -8.333 0.6667 1 4 1.000 -2.500 23.33 -7.500 1.000 1 5 1.000 -1.667 20.00 -6.667 1.333 1 6 1.000 -0.8333 16.67 -5.833 1.667 1 7 1.000 0.000 13.33 -5.000 2.000 1 8 1.000 0.8333 10.00 -4.167 2.333 1 9 1.000 1.667 6.667 -3.333 2.667 1 10 1.000 2.500 3.333 -2.500 3.000 2 1 1.000 -1.667 26.67 -6.667 0.3333 2 2 1.000 -0.8333 23.33 -5.833 0.6667 2 3 1.000 0.000 20.00 -5.000 1.000 2 4 1.000 0.8333 16.67 -4.167 1.333 2 5 1.000 1.667 13.33 -3.333 1.667 2 6 1.000 2.500 10.00 -2.500 2.000 2 7 1.000 3.333 6.667 -1.667 2.333 2 8 1.000 4.167 3.333 -0.8333 2.667 2 9 1.000 5.000 0.000 0.000 3.000 2 10 1.000 5.833 -3.333 0.8333 3.333 3 1 1.000 1.667 20.00 -3.333 0.6667 3 2 1.000 2.500 16.67 -2.500 1.000 3 3 1.000 3.333 13.33 -1.667 1.333 3 4 1.000 4.167 10.00 -0.8333 1.667 3 5 1.000 5.000 6.667 0.3576E-06 2.000 3 6 1.000 5.833 3.333 0.8333 2.333 3 7 1.000 6.667 -0.1192E-05 1.667 2.667 3 8 1.000 7.500 -3.333 2.500 3.000 3 9 1.000 8.333 -6.667 3.333 3.333 3 10 1.000 9.167 -10.00 4.167 3.667 4 1 1.000 5.000 13.33 0.4768E-06 1.000 4 2 1.000 5.833 10.00 0.8333 1.333 4 3 1.000 6.667 6.667 1.667 1.667 4 4 1.000 7.500 3.333 2.500 2.000 4 5 1.000 8.333 -0.5960E-06 3.333 2.333 4 6 1.000 9.167 -3.333 4.167 2.667 4 7 1.000 10.00 -6.667 5.000 3.000 4 8 1.000 10.83 -10.00 5.833 3.333 4 9 1.000 11.67 -13.33 6.667 3.667 4 10 1.000 12.50 -16.67 7.500 4.000 5 1 1.000 8.333 6.667 3.333 1.333 5 2 1.000 9.167 3.333 4.167 1.667 5 3 1.000 10.00 0.000 5.000 2.000 5 4 1.000 10.83 -3.333 5.833 2.333 5 5 1.000 11.67 -6.667 6.667 2.667 5 6 1.000 12.50 -10.00 7.500 3.000 5 7 1.000 13.33 -13.33 8.333 3.333 5 8 1.000 14.17 -16.67 9.167 3.667 5 9 1.000 15.00 -20.00 10.00 4.000 5 10 1.000 15.83 -23.33 10.83 4.333 6 1 1.000 11.67 -0.5960E-06 6.667 1.667 6 2 1.000 12.50 -3.333 7.500 2.000 6 3 1.000 13.33 -6.667 8.333 2.333 6 4 1.000 14.17 -10.00 9.167 2.667 6 5 1.000 15.00 -13.33 10.00 3.000 6 6 1.000 15.83 -16.67 10.83 3.333 6 7 1.000 16.67 -20.00 11.67 3.667 6 8 1.000 17.50 -23.33 12.50 4.000 6 9 1.000 18.33 -26.67 13.33 4.333 6 10 1.000 19.17 -30.00 14.17 4.667 TEST020 GRID4N computes, one at a time, points on a 2D grid in the plane containing the NDIM-dimensional points X1, X2 and X3. We wish to compute the points on the following steps: X1 on step 2 3 X2 on step 5 3 X3 on step 2 9 We use 6 steps in the I direction and 10 steps in the J direction. The points X1, X2 and X3 are: 1.000 0.000 20.00 -5.000 1.000 1.000 10.00 0.000 5.000 2.000 1.000 5.000 0.000 0.000 3.000 1 1 1.000 -5.000 33.33 -10.00 0.000 1 2 1.000 -4.167 30.00 -9.167 0.3333 1 3 1.000 -3.333 26.67 -8.333 0.6667 1 4 1.000 -2.500 23.33 -7.500 1.000 1 5 1.000 -1.667 20.00 -6.667 1.333 1 6 1.000 -0.8333 16.67 -5.833 1.667 1 7 1.000 0.000 13.33 -5.000 2.000 1 8 1.000 0.8333 10.00 -4.167 2.333 1 9 1.000 1.667 6.667 -3.333 2.667 1 10 1.000 2.500 3.333 -2.500 3.000 2 1 1.000 -1.667 26.67 -6.667 0.3333 2 2 1.000 -0.8333 23.33 -5.833 0.6667 2 3 1.000 0.000 20.00 -5.000 1.000 2 4 1.000 0.8333 16.67 -4.167 1.333 2 5 1.000 1.667 13.33 -3.333 1.667 2 6 1.000 2.500 10.00 -2.500 2.000 2 7 1.000 3.333 6.667 -1.667 2.333 2 8 1.000 4.167 3.333 -0.8333 2.667 2 9 1.000 5.000 0.000 0.000 3.000 2 10 1.000 5.833 -3.333 0.8333 3.333 3 1 1.000 1.667 20.00 -3.333 0.6667 3 2 1.000 2.500 16.67 -2.500 1.000 3 3 1.000 3.333 13.33 -1.667 1.333 3 4 1.000 4.167 10.00 -0.8333 1.667 3 5 1.000 5.000 6.667 0.3576E-06 2.000 3 6 1.000 5.833 3.333 0.8333 2.333 3 7 1.000 6.667 -0.1192E-05 1.667 2.667 3 8 1.000 7.500 -3.333 2.500 3.000 3 9 1.000 8.333 -6.667 3.333 3.333 3 10 1.000 9.167 -10.00 4.167 3.667 4 1 1.000 5.000 13.33 0.4768E-06 1.000 4 2 1.000 5.833 10.00 0.8333 1.333 4 3 1.000 6.667 6.667 1.667 1.667 4 4 1.000 7.500 3.333 2.500 2.000 4 5 1.000 8.333 -0.5960E-06 3.333 2.333 4 6 1.000 9.167 -3.333 4.167 2.667 4 7 1.000 10.00 -6.667 5.000 3.000 4 8 1.000 10.83 -10.00 5.833 3.333 4 9 1.000 11.67 -13.33 6.667 3.667 4 10 1.000 12.50 -16.67 7.500 4.000 5 1 1.000 8.333 6.667 3.333 1.333 5 2 1.000 9.167 3.333 4.167 1.667 5 3 1.000 10.00 0.000 5.000 2.000 5 4 1.000 10.83 -3.333 5.833 2.333 5 5 1.000 11.67 -6.667 6.667 2.667 5 6 1.000 12.50 -10.00 7.500 3.000 5 7 1.000 13.33 -13.33 8.333 3.333 5 8 1.000 14.17 -16.67 9.167 3.667 5 9 1.000 15.00 -20.00 10.00 4.000 5 10 1.000 15.83 -23.33 10.83 4.333 6 1 1.000 11.67 -0.5960E-06 6.667 1.667 6 2 1.000 12.50 -3.333 7.500 2.000 6 3 1.000 13.33 -6.667 8.333 2.333 6 4 1.000 14.17 -10.00 9.167 2.667 6 5 1.000 15.00 -13.33 10.00 3.000 6 6 1.000 15.83 -16.67 10.83 3.333 6 7 1.000 16.67 -20.00 11.67 3.667 6 8 1.000 17.50 -23.33 12.50 4.000 6 9 1.000 18.33 -26.67 13.33 4.333 6 10 1.000 19.17 -30.00 14.17 4.667 TEST0205 I_CHARACTERISTIC computes the characteristic of an integer Q, which is Q if Q is prime; P, if Q = P**N for some prime P; 0, if Q is negative, 0, 1, or the product of more than 1 distinct prime. I, I_CHARACTERISTIC 1 0 2 2 3 3 4 2 5 5 6 0 7 7 8 2 9 3 10 0 11 11 12 0 13 13 14 0 15 0 16 2 17 17 18 0 19 19 20 0 21 0 22 0 23 23 24 0 25 5 26 0 27 3 28 0 29 29 30 0 31 31 32 2 33 0 34 0 35 0 36 0 37 37 38 0 39 0 40 0 41 41 42 0 43 43 44 0 45 0 46 0 47 47 48 0 49 7 50 0 TEST021 I_FACTOR factors an integer, The integer is 2516 Prime representation: I, FACTOR(I), POWER(I) 1 2 2 2 17 1 3 37 1 TEST022 I_IS_PRIME reports whether an integer is prime. I I_IS_PRIME(I) -2 F -1 F 0 F 1 T 2 T 3 T 4 F 5 T 6 F 7 T 8 F 9 F 10 F 11 T 12 F 13 T 14 F 15 F 16 F 17 T 18 F 19 T 20 F 21 F 22 F 23 T 24 F 25 F TEST0239 I_LOG_2: whole part of log base 2. X, I_LOG_2 0 -2147483647 1 0 2 1 3 1 9 3 10 3 11 3 99 6 101 6 -1 0 -2 1 -3 1 -9 3 1000 9 1023 9 1024 10 1025 10 TEST0248 I_LOG_B: whole part of log base B, X, B, I_LOG_B 16 2.00000 4 16 3.00000 2 16 4.00000 2 16 5.00000 1 16 6.00000 1 16 7.00000 1 16 8.00000 1 16 16.0000 1 16 32.0000 0 16 256.000 0 TEST0249 I_LOG_10: whole part of log base 10, X, I_LOG_10 0 -2147483647 1 0 2 0 3 0 9 0 10 1 11 1 99 1 101 2 -1 0 -2 0 -3 0 -9 0 TEST025 I_MODDIV factors a number into a multiple and a remainder. Number Divisor Multiple Remainder 107 50 2 7 107 -50 -2 7 -107 50 -2 -7 -107 -50 2 -7 Repeat using FORTRAN MOD: 107 50 2 7 107 -50 -2 7 -107 50 -2 -7 -107 -50 2 -7 Repeat using I_MODP: 107 50 2 7 107 -50 -2 7 -107 50 -3 43 -107 -50 3 43 TEST026 I_ROUNDUP rounds reals up. -1.20000 -1 -1.00000 -1 -0.800000 0 -0.600000 0 -0.400000 0 -0.200000 0 0.00000 0 0.200000 1 0.400000 1 0.600000 1 0.800000 1 1.00000 1 1.20000 2 TEST027 I_GCD computes the greatest common factor, I_LCM computes the least common multiple. I J I_GCD I_LCM 36 30 6 180 49 -7 7 49 0 71 71 0 12 12 12 12 36 49 1 1764 1 42 1 42 91 28 7 364 TEST028 I_JACOBI_SYMBOL computes the Jacobi symbol (Q/P), which records if Q is a quadratic residue modulo the number P. Jacobi Symbols for P = 3 3 0 0 3 1 1 3 2 -1 3 3 0 Jacobi Symbols for P = 9 9 0 0 9 1 1 9 2 1 9 3 0 9 4 1 9 5 1 9 6 0 9 7 1 9 8 1 9 9 0 Jacobi Symbols for P = 10 10 0 0 10 1 1 10 2 0 10 3 -1 10 4 0 10 5 0 10 6 0 10 7 -1 10 8 0 10 9 1 10 10 0 Jacobi Symbols for P = 12 12 0 0 12 1 1 12 2 0 12 3 0 12 4 0 12 5 -1 12 6 0 12 7 1 12 8 0 12 9 0 12 10 0 12 11 -1 12 12 0 TEST029 I_LEGENDRE_SYMBOL computes the Legendre symbol (Q/P) which records whether Q is a quadratic residue modulo the prime P. Legendre Symbols for P = 7 7 0 0 7 1 1 7 2 1 7 3 -1 7 4 1 7 5 -1 7 6 -1 7 7 0 Legendre Symbols for P = 11 11 0 0 11 1 1 11 2 -1 11 3 1 11 4 1 11 5 1 11 6 -1 11 7 -1 11 8 -1 11 9 1 11 10 -1 11 11 0 Legendre Symbols for P = 13 13 0 0 13 1 1 13 2 -1 13 3 1 13 4 1 13 5 -1 13 6 -1 13 7 -1 13 8 -1 13 9 1 13 10 1 13 11 -1 13 12 1 13 13 0 Legendre Symbols for P = 17 17 0 0 17 1 1 17 2 1 17 3 -1 17 4 1 17 5 -1 17 6 -1 17 7 -1 17 8 1 17 9 1 17 10 -1 17 11 -1 17 12 -1 17 13 1 17 14 -1 17 15 1 17 16 1 17 17 0 TEST030 I_MANT decomposes an integer, Number to be decomposed is X = -314.159 I_MANT: X = -1 * (******/******) * 2** 8 TEST031 I_MEMORY I_MEMORY - Value of IVAN is 1 I_MEMORY - Value of JACK is 2 I_MEMORY - Value of KYLE is 3 I_MEMORY - Value of IVAN is 1 INC IVAN 100: I_MEMORY - Value of IVAN is 101 PUSH IVAN 17 I_MEMORY - Value of IVAN is 17 INC IVAN 100 I_MEMORY - Value of IVAN is 117 POP IVAN = 117 I_MEMORY - Value of IVAN is 101 SET JACK 99: I_MEMORY - Value of JACK is 99 INC JACK 100: I_MEMORY - Value of JACK is 199 PRINT * I_MEMORY - Value of IVAN is 101 I_MEMORY - Value of JACK is 199 I_MEMORY - Value of KYLE is 3 I_MEMORY - Value of LOU is -33 TEST032 I_MOEBIUS computes the Moebius function; I_OMEGA counts the distinct prime divisors of N; I_PHI computes the number of values less than N and relatively prime to N; I_TAU computes the number of factors; I_SIGMA computes the sum of factors. N PHI(N), TAU(N), SIGMA(N), MU(N) OMEGA(N) 1 1 1 1 1 1 2 1 2 3 -1 1 3 2 2 4 -1 1 4 2 3 7 0 1 5 4 2 6 -1 1 6 2 4 12 1 2 7 6 2 8 -1 1 8 4 4 15 0 1 9 6 3 13 0 1 10 4 4 18 1 2 11 10 2 12 -1 1 12 4 6 28 0 2 13 12 2 14 -1 1 14 6 4 24 1 2 15 8 4 24 1 2 16 8 5 31 0 1 17 16 2 18 -1 1 18 6 6 39 0 2 19 18 2 20 -1 1 20 8 6 42 0 2 TEST033 I_SIGN returns the sign of a number. -10 -1 -7 -1 0 0 5 1 9 1 TEST888 R_TO_R_DISCRETE maps real numbers to a discrete set of equally spaced real numbers in an interval. Number of discrete values = 19 Real interval: 1.00000 10.0000 R RD 8.56686 8.50000 6.14523 6.00000 0.989854 1.00000 5.72331 5.50000 4.23817 4.00000 -0.373720 1.00000 9.54310 9.50000 5.67785 5.50000 2.35561 2.50000 0.219170 1.00000 1.03040 1.00000 4.80646 5.00000 7.23627 7.00000 1.13767 1.00000 10.0689 10.0000 TEST034 For data in an interval, IINT_TO_RINT converts an integer to a real; RINT_TO_IINT converts a real to an integer. Integer interval: 1 11 Real interval: 100.000 200.000 R I(R) R(I(R)) 94.4760 0 90.0000 170.050 8 170.000 171.384 8 170.000 121.209 3 120.000 160.812 7 160.000 209.887 12 210.000 87.3461 0 90.0000 162.007 7 160.000 211.374 12 210.000 164.645 7 160.000 TEST0345 I_WRAP forces an integer to lie within given limits. ILO = 4 IHI = 8 I I_WRAP(I) -10 5 -9 6 -8 7 -7 8 -6 4 -5 5 -4 6 -3 7 -2 8 -1 4 0 5 1 6 2 7 3 8 4 4 5 5 6 6 7 7 8 8 9 4 10 5 11 6 12 7 13 8 14 4 15 5 16 6 17 7 18 8 19 4 20 5 TEST035 ICOL_SORT_A ascending sorts an integer array as a table of columns. ICOL_SORT_D descending sorts an integer array as a table of columns. The original matrix: 1 2 3 4 1 10 6 10 1 2 6 8 2 5 3 10 2 6 2 4 9 1 2 3 5 9 4 4 7 Ascending sorted: 1 2 3 4 1 1 6 10 10 2 5 8 2 6 3 2 2 6 10 4 3 1 2 9 5 7 4 4 9 Descending sorted: 1 2 3 4 1 10 10 6 1 2 6 2 8 5 3 10 6 2 2 4 9 2 1 3 5 9 4 4 7 TEST036 IMAT_RED divides common factors in a matrix; IMAT_ELIM does exact Gauss elimination. The original matrix: 1 2 3 4 5 1 1 2 3 4 5 2 6 7 8 9 10 3 11 12 13 14 15 4 16 17 18 19 20 5 21 22 23 24 25 The matrix, as returned by IMAT_RED: 1 2 3 4 1 1 6 7 8 9 2 1 11 12 13 14 3 1 16 17 18 19 4 1 21 22 23 24 5 1 1 1 1 1 5 The matrix returned by IMAT_ELIM: 1 2 3 4 5 1 1 22 23 8 5 2 0 -5 -10 -5 -4 3 0 0 0 0 0 4 0 0 0 0 0 5 0 0 0 0 0 The original matrix: 1 2 3 4 5 1 40320 20160 13440 10080 8064 2 20160 13440 10080 8064 6720 3 13440 10080 8064 6720 5760 4 10080 8064 6720 5760 5040 5 8064 6720 5760 5040 4480 The matrix, as returned by IMAT_RED: 30 15 70 105 252 2 30 20 105 168 420 1 20 15 84 140 360 1 15 12 70 120 315 1 12 10 60 105 280 1 672 672 96 48 16 The matrix returned by IMAT_ELIM: 1 2 3 4 5 1 1 3 7 7 63 2 0 -4 -16 -21 -224 3 0 0 4 9 126 4 0 0 0 1 24 5 0 0 0 0 1 The original matrix: 1 2 3 4 5 1 1 2 3 4 5 2 2 4 6 8 10 3 3 6 9 12 15 4 4 8 12 16 20 5 5 10 15 20 25 The matrix, as returned by IMAT_RED: 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 3 1 1 1 1 1 4 1 1 1 1 1 5 1 2 3 4 5 The matrix returned by IMAT_ELIM: 1 2 3 4 5 1 1 1 1 1 1 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0 5 0 0 0 0 0 TEST0365 IMAT_L1_INVERSE inverts a unit lower triangular matrix. The original matrix: 1 2 3 4 5 6 1 1 0 0 0 0 0 2 2 1 0 0 0 0 3 0 0 1 0 0 0 4 5 0 3 1 0 0 5 0 0 0 0 1 0 6 75 0 0 6 4 1 The inverse matrix: 1 2 3 4 5 6 1 1 0 0 0 0 0 2 -2 1 0 0 0 0 3 0 0 1 0 0 0 4 -5 0 -3 1 0 0 5 0 0 0 0 1 0 6 -45 0 18 -6 -4 1 The product: 1 2 3 4 5 6 1 1 0 0 0 0 0 2 0 1 0 0 0 0 3 0 0 1 0 0 0 4 0 0 0 1 0 0 5 0 0 0 0 1 0 6 0 0 0 0 0 1 TEST0366 IMAT_IMAX locates the maximum; IMAT_IMIN locates the maximum; Random array: 1 2 3 4 5 6 7 1 10 9 10 7 5 1 1 2 10 1 3 6 7 5 10 3 9 8 7 8 10 9 9 4 8 9 1 1 8 0 5 5 10 5 9 4 9 0 10 Maximum I,J indices 1 1 Minimum I,J indices 4 6 TEST037 IMAT_PERM_RANDOM applies a random permutation to a square integer matrix. The original matrix: 1 2 3 4 5 1 11 12 13 14 15 2 21 22 23 24 25 3 31 32 33 34 35 4 41 42 43 44 45 5 51 52 53 54 55 The permuted matrix: 1 2 3 4 5 1 11 12 13 14 15 2 21 22 23 24 25 3 31 32 33 34 35 4 41 42 43 44 45 5 51 52 53 54 55 TEST0375 For a rectangular integer matrix: IROW_SORT_A sorts the rows; The original matrix: 1 2 3 4 1 7 2 3 7 2 10 5 7 2 3 8 8 3 10 4 5 7 9 3 5 7 2 1 2 6 4 5 0 5 7 10 1 3 10 8 8 10 0 0 9 6 1 6 5 10 7 4 4 5 The row-sorted matrix: 1 2 3 4 1 4 5 0 5 2 5 7 9 3 3 6 1 6 5 4 7 2 1 2 5 7 2 3 7 6 7 4 4 5 7 8 8 3 10 8 8 10 0 0 9 10 1 3 10 10 10 5 7 2 TEST038 For a rectangular integer matrix: IMAT_PERM2_RANDOM applies independent random permutations to rows and columns; IROW_SORT_D sorts the rows; IROW_SORT2_D sorts the elements of the rows. The original matrix: 1 2 3 4 1 11 12 13 14 2 21 22 23 24 3 31 32 33 34 4 41 42 43 44 5 51 52 53 54 6 61 62 63 64 The permuted matrix: 1 2 3 4 1 51 52 53 54 2 61 62 63 64 3 11 12 13 14 4 21 22 23 24 5 41 42 43 44 6 31 32 33 34 The row-sorted matrix: 1 2 3 4 1 61 62 63 64 2 51 52 53 54 3 41 42 43 44 4 31 32 33 34 5 21 22 23 24 6 11 12 13 14 The element-sorted row-sorted matrix: 1 2 3 4 1 64 63 62 61 2 54 53 52 51 3 44 43 42 41 4 34 33 32 31 5 24 23 22 21 6 14 13 12 11 TEST0385 IMAT_U1_INVERSE inverts a unit upper triangular matrix. The original matrix: 1 2 3 4 5 6 1 1 2 0 5 0 75 2 0 1 0 0 0 0 3 0 0 1 3 0 0 4 0 0 0 1 0 6 5 0 0 0 0 1 4 6 0 0 0 0 0 1 The inverse matrix: 1 2 3 4 5 6 1 1 -2 0 -5 0 -45 2 0 1 0 0 0 0 3 0 0 1 -3 0 18 4 0 0 0 1 0 -6 5 0 0 0 0 1 -4 6 0 0 0 0 0 1 The product: 1 2 3 4 5 6 1 1 0 0 0 0 0 2 0 1 0 0 0 0 3 0 0 1 0 0 0 4 0 0 0 1 0 0 5 0 0 0 0 1 0 6 0 0 0 0 0 1 TEST039 IROW_MAX computes row maximums; IROW_MEAN computes row means; IROW_MIN computes row minimums; IROW_SUM computes row sums; IROW_SWAP swaps two rows; IROW_VARIANCE computes row variances; The matrix: 1 2 3 4 1 1 2 3 4 2 5 6 7 8 3 9 10 11 12 Maximum, minimum, sum, mean, variance: 1 4 1 10 2.5000 1.6667 2 8 5 26 6.5000 1.6667 3 12 9 42 10.5000 1.6667 Swap rows 1 and 3: The new matrix: 1 2 3 4 1 9 10 11 12 2 5 6 7 8 3 1 2 3 4 TEST040 ISBN_CHECK checks ISBN's. A correct ISBN has a checksum of 0. 0-8493-9640-9 0 0-201-54275-7 0 0-521-35796-9 0 0-07-034025-0 0 0-7493-9640-9 2 0-201-54275-X 3 0-521-X5796-9 -1 0-37-034025-0 5 TEST041 ISBN_FILL can fill in a single missing digit in an ISBN. 0-?493-9640-9 0-8493-9640-9 0 0-201-5427?-7 0-201-54275-7 0 0-521-35796-? 0-521-35796-9 0 ?-07-034025-0 0-07-034025-0 0 0-07-05?489-2 0-07-056489-2 0 TEST042 For an integer vector: IVEC_AMAX: maximum absolute entry; IVEC_AMIN: minimum absolute entry; IVEC_AMINZ: minimum nonzero absolute entry; IVEC_CUM: cumulative sum; IVEC_IMAX: a maximal index; IVEC_IMAX_LAST: last maximal index; IVEC_INDEX: first index of given value; IVEC_MAX: maximum entry; IVEC_MEAN: mean value; IVEC_MEDIAN: median value; IVEC_MIN: minimum entry; IVEC_NONZERO: number of nonzeroes; IVEC_VARIANCE: variance. Input vector: 1 5 2 8 3 -7 4 6 5 8 6 9 7 -4 8 -10 9 -6 10 0 Maximum: 9 Maximum index: 6 Last maximum index: 6 Minimum: -10 Minimum index: 8 Maximum abs: 10 Maximum abs index: 8 Minimum abs: 0 Minimum abs index: 10 Minimum abs nonzero: 4 Minimum abs nonzero index: 7 Index of first occurrence of 4 is 0 Index of first occurrence of 5 is 1 Sum of entries: 9 Mean: 0.900000 Median: 0 Number of nonzeroes : 9 Variance: 51.4333 Cumulative sums: 1 0 2 5 3 13 4 6 5 12 6 20 7 29 8 25 9 15 10 9 11 9 TEST0425 IVEC_ASCEND_SUB computes a longest ascending subsequence of an integer vector. The vector to be tested: 1 7 2 4 3 5 4 4 5 6 6 8 7 1 8 2 9 7 10 7 11 1 12 8 13 6 14 7 A longest ascending subsequence: 1 4 2 5 3 6 4 7 5 8 The vector to be tested: 1 1 2 6 3 8 4 1 5 8 6 3 7 1 8 10 9 3 10 7 11 2 12 1 13 2 14 7 A longest ascending subsequence: 1 1 2 6 3 8 4 10 The vector to be tested: 1 9 2 9 3 6 4 6 5 4 6 8 7 3 8 1 9 2 10 9 11 8 12 3 13 5 14 6 A longest ascending subsequence: 1 1 2 2 3 3 4 5 5 6 The vector to be tested: 1 3 2 9 3 9 4 4 5 7 6 8 7 10 8 8 9 9 10 4 11 10 12 7 13 10 14 7 A longest ascending subsequence: 1 3 2 4 3 7 4 8 5 9 6 10 The vector to be tested: 1 6 2 6 3 7 4 9 5 6 6 4 7 8 8 6 9 6 10 1 11 9 12 3 13 5 14 1 A longest ascending subsequence: 1 6 2 7 3 8 4 9 The vector to be tested: 1 6 2 3 3 7 4 3 5 10 6 8 7 5 8 1 9 3 10 7 11 2 12 1 13 3 14 3 A longest ascending subsequence: 1 1 2 2 3 3 TEST043 IVEC_BRACKET finds a pair of entries in a sorted integer array which bracket a value. IVEC_INSERT inserts a value into a vector. We use these two routines to bracket a value, and then insert it. Sorted array: 1 2 2 4 3 6 4 8 5 10 6 10 7 14 8 16 9 18 10 20 Search for AVAL = -10 Left = -1 Right = 1 A(RIGHT) = 2 Sorted, augmented array: 1 -10 2 2 3 4 4 6 5 8 6 10 7 10 8 14 9 16 10 18 11 20 Search for AVAL = 2 Left = 2 Right = 2 A(LEFT)= 2 A(RIGHT) = 2 No insertion necessary. Search for AVAL = 9 Left = 5 Right = 6 A(LEFT)= 8 A(RIGHT) = 10 Sorted, augmented array: 1 -10 2 2 3 4 4 6 5 8 6 9 7 10 8 10 9 14 10 16 11 18 12 20 Search for AVAL = 10 Left = 7 Right = 7 A(LEFT)= 10 A(RIGHT) = 10 No insertion necessary. Search for AVAL = 20 Left = 12 Right = 12 A(LEFT)= 20 A(RIGHT) = 20 No insertion necessary. Search for AVAL = 24 Left = 12 Right = -1 A(LEFT)= 20 Sorted, augmented array: 1 -10 2 2 3 4 4 6 5 8 6 9 7 10 8 10 9 14 10 16 11 18 12 20 13 24 TEST0435 IVEC_ASCENDS determines if an integer vector ascends. IVEC_DESCENDS determines if an integer vector descends. Test vector: 1 1 2 3 3 2 4 4 IVEC_ASCENDS = F IVEC_DESCENDS = F Test vector: 1 2 2 2 3 2 4 2 IVEC_ASCENDS = T IVEC_DESCENDS = T Test vector: 1 1 2 2 3 2 4 4 IVEC_ASCENDS = T IVEC_DESCENDS = F Test vector: 1 1 2 2 3 3 4 4 IVEC_ASCENDS = T IVEC_DESCENDS = F Test vector: 1 4 2 4 3 3 4 1 IVEC_ASCENDS = F IVEC_DESCENDS = T Test vector: 1 9 2 7 3 3 4 0 IVEC_ASCENDS = F IVEC_DESCENDS = T TEST044 IVEC_FRAC: K-th smallest integer vector entry. The array to search: 1 5 2 11 3 20 4 1 5 10 6 7 7 7 8 12 9 13 10 16 Fractile Value 1 1 6 11 TEST0445 For an integer vector, IVEC_HEAP_A puts into ascending heap form. IVEC_HEAP_D puts into descending heap form. Unsorted array: 1 6 2 0 3 4 4 5 5 7 6 10 7 0 8 2 9 2 10 5 Ascending heap form: 1 0 2 2 3 0 4 2 5 5 6 10 7 4 8 5 9 6 10 7 Descending heap form: 1 10 2 7 3 4 4 6 5 5 6 0 7 0 8 5 9 2 10 2 TEST045 For a descending heap of integers, IVEC_HEAP_D_INSERT inserts a value into the heap. IVEC_HEAP_D_EXTRACT extracts the maximum value; IVEC_HEAP_D_MAX reports the maximum value. These 3 operations are enough to model a priority queue. Inserting value 6 Current maximum value is 6 Inserting value 1 Current maximum value is 6 Inserting value 5 Current maximum value is 6 Inserting value 5 Current maximum value is 6 Inserting value 9 Current maximum value is 9 Inserting value 8 Current maximum value is 9 Inserting value 3 Current maximum value is 9 Inserting value 9 Current maximum value is 9 Inserting value 8 Current maximum value is 9 Inserting value 1 Current maximum value is 9 Current heap as a vector: 1 9 2 9 3 8 4 8 5 5 6 5 7 3 8 1 9 6 10 1 Now extract the maximum several times. Extracting maximum element = 9 Extracting maximum element = 9 Extracting maximum element = 8 Extracting maximum element = 8 Extracting maximum element = 6 Current heap as a vector: 1 5 2 5 3 3 4 1 5 1 TEST0451 IVEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. IVEC_INDEX_SEARCH searches for an entry with a given value. Generate some random values: Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 1 0 0 2 4 7 2 3 7 6 3 4 11 2 5 5 3 15 6 6 2 18 7 7 9 3 9 8 10 16 14 9 5 9 15 10 8 14 16 11 6 5 18 12 12 20 20 Results of search for given XVAL: XVAL Less Equal More 0 0 1 2 1 1 0 2 2 1 2 3 3 2 3 4 4 3 0 4 5 3 4 5 6 4 5 6 7 5 6 7 8 6 0 7 9 6 7 8 10 7 0 8 11 7 0 8 12 7 0 8 13 7 0 8 14 7 8 9 15 8 9 10 16 9 10 11 17 10 0 11 18 10 11 12 19 11 0 12 20 11 12 13 TEST0452 IVEC_INDEX_INSERT inserts values into an index sorted array of integers. IVEC_INDEX_DELETE_ALL deletes all copies of a particular value. IVEC_INDEX_DELETE_ONE deletes one copies of a particular value. IVEC_INDEX_DELETE_DUPES deletes duplicates. Generate some random values: 1 7 2 9 8 15 15 10 3 15 15 4 13 3 0 19 4 18 13 12 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 17 8 0 2 3 7 1 3 5 1 2 4 11 7 3 5 16 2 3 6 14 9 4 7 19 8 4 8 2 15 7 9 23 15 7 10 4 10 7 11 1 3 8 12 7 15 8 13 24 15 8 14 6 4 9 15 10 13 10 16 22 3 12 17 15 0 13 18 21 19 13 19 8 4 15 20 9 18 15 21 12 13 15 22 13 12 15 23 20 7 18 24 18 8 19 Call IVEC_INDEX_DELETE_ONE to delete a value of 8: Call IVEC_INDEX_DELETE_ALL to delete values of 7: Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 14 8 0 2 2 1 1 3 3 2 2 4 8 9 3 5 13 15 3 6 11 15 4 7 16 10 4 8 1 3 8 9 20 15 8 10 4 15 9 11 7 4 10 12 19 13 12 13 12 3 13 14 18 0 13 15 5 19 15 16 6 4 15 17 9 18 15 18 10 13 15 19 17 12 18 20 15 8 19 Call IVEC_INDEX_DELETE_DUPES to delete duplicates: Indexed list of unique entries: I INDX(I) X(I) 1 1 0 2 2 1 3 3 2 4 4 3 5 5 4 6 6 8 7 7 9 8 8 10 9 9 12 10 10 13 11 11 15 12 12 18 13 13 19 TEST0453 IVEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. IVEC_INDEX_ORDER sorts an index sorted array. Generate some random values: 1 13 18 2 13 8 7 12 4 15 15 8 14 7 1 14 9 0 6 15 Indexed list of unique entries: I INDX(I) X(I) X(INDX(I)) 1 12 1 0 2 1 13 1 3 4 18 2 4 8 2 4 5 13 8 6 6 6 7 7 7 5 12 8 8 11 4 9 9 7 15 12 10 2 14 13 11 10 9 14 12 9 0 15 13 3 6 18 Now call IVEC_INDEX_ORDER to carry out the sorting: I X(I) 1 0 2 1 3 2 4 4 5 6 6 7 7 8 8 9 9 12 10 13 11 14 12 15 13 18 TEST046 For ascending order: IVEC_MERGE_A merges two sorted integer arrays; IVEC_SEARCH_BINARY_A searchs an array for a value; IVEC_SORT_HEAP_A sorts an integer array. Input vector A: 1 4 2 4 3 5 4 5 5 5 6 5 7 5 8 6 9 9 10 10 Input vector B: 1 2 2 3 3 4 4 6 5 8 6 8 7 8 8 9 9 10 10 10 Merged vector C: 1 2 2 3 3 4 4 5 5 6 6 8 7 9 8 10 Search the array C for the value 4 SEARCH RESULT: The value occurs in index 3 TEST047 IVEC_ORDER_TYPE classifies an integer vector as -1: no order 0: all equal; 1: ascending; 2: strictly ascending; 3: descending; 4: strictly descending. The following vector has order type -1 1 1 2 3 3 2 4 4 The following vector has order type 0 1 2 2 2 3 2 4 2 The following vector has order type 1 1 1 2 2 3 2 4 4 The following vector has order type 2 1 1 2 2 3 3 4 4 The following vector has order type 3 1 4 2 4 3 3 4 1 The following vector has order type 4 1 9 2 7 3 3 4 0 TEST0475 IVEC_PAIRWISE_PRIME determines if a vector of integers is pairwise prime. Pairwise Row Vector Prime? 1 3 2 4 F 2 2 2 2 F 5 7 12 29 T 1 13 1 11 T 1 4 9 16 F 6 35 13 77 F TEST048 IVEC_PART partitions an integer. NVAL = 17 Partitioned: 1 4 2 4 3 3 4 3 5 3 NVAL = -49 Partitioned: 1 -10 2 -10 3 -10 4 -10 5 -9 TEST049 IVEC_PART_QUICK_A reorders an integer vector as part of a quick sort. Before rearrangment: 1 11 2 8 3 11 4 4 5 9 6 0 7 2 8 7 9 5 10 11 11 2 12 9 Rearranged array Left = 9 Right = 13 1 4 2 9 3 0 4 2 5 7 6 5 7 8 8 2 9 9 10 11 11 11 12 11 TEST050 IVEC_REVERSE reverses a list of integers. Original vector: 1 30 2 24 3 12 4 28 5 6 6 15 7 20 8 22 9 28 10 26 Reversed: 1 26 2 28 3 22 4 20 5 15 6 6 7 28 8 12 9 24 10 30 TEST051 For a vector of integers, IVEC_SORT_HEAP_A ascending sorts, IVEC_SORT_HEAP_D descending sorts. Unsorted: 1 55 2 36 3 45 4 34 5 47 6 7 7 9 8 18 9 37 10 0 11 40 12 32 13 24 14 55 15 31 16 49 17 21 18 41 19 47 20 41 Ascending sort: 1 0 2 7 3 9 4 18 5 21 6 24 7 31 8 32 9 34 10 36 11 37 12 40 13 41 14 41 15 45 16 47 17 47 18 49 19 55 20 55 Descending sort: 1 55 2 55 3 49 4 47 5 47 6 45 7 41 8 41 9 40 10 37 11 36 12 34 13 32 14 31 15 24 16 21 17 18 18 9 19 7 20 0 TEST052 IVEC_SORT_HEAP_A sorts an integer array; IVEC_UNIQUE finds unique entries. Input vector: 1 1 2 3 3 4 4 4 5 6 6 9 7 9 8 10 9 10 10 10 11 10 12 11 13 13 14 13 15 14 16 15 17 16 18 17 19 19 20 19 Unique entries: 1 1 2 3 3 4 4 6 5 9 6 10 7 11 8 13 9 14 10 15 11 16 12 17 13 19 TEST053 IVEC_SORT_HEAP_INDEX_A creates an ascending sort index for an integer array. IVEC_SORT_HEAP_INDEX_D creates a descending sort index for an integer array. Unsorted array: 1 25 2 55 3 15 4 8 5 16 6 22 7 35 8 28 9 15 10 38 11 31 12 20 13 55 14 37 15 56 16 31 17 15 18 60 19 5 20 46 After indexed ascending sort: I, INDX(I), A(I) 1 19 25 2 4 55 3 9 15 4 17 8 5 3 16 6 5 22 7 12 35 8 6 28 9 1 15 10 8 38 11 11 31 12 16 20 13 7 55 14 14 37 15 10 56 16 20 31 17 13 15 18 2 60 19 15 5 20 18 46 Now use the index array to carry out the permutation implicitly. I, INDX(I), A(INDX(I)) 1 19 5 2 4 8 3 9 15 4 17 15 5 3 15 6 5 16 7 12 20 8 6 22 9 1 25 10 8 28 11 11 31 12 16 31 13 7 35 14 14 37 15 10 38 16 20 46 17 13 55 18 2 55 19 15 56 20 18 60 Call IVEC_PERMUTE to carry out the permutation explicitly. I, A(I) 1 5 2 8 3 15 4 15 5 15 6 16 7 20 8 22 9 25 10 28 11 31 12 31 13 35 14 37 15 38 16 46 17 55 18 55 19 56 20 60 After indexed descending sort: I, INDX(I), A(I) 1 20 5 2 19 8 3 18 15 4 17 15 5 16 15 6 15 16 7 14 20 8 13 22 9 12 25 10 11 28 11 10 31 12 9 31 13 8 35 14 7 37 15 6 38 16 3 46 17 5 55 18 4 55 19 2 56 20 1 60 Now use the index array to carry out the permutation implicitly. INDX(I), A(INDX(I)) 1 20 60 2 19 56 3 18 55 4 17 55 5 16 46 6 15 38 7 14 37 8 13 35 9 12 31 10 11 31 11 10 28 12 9 25 13 8 22 14 7 20 15 6 16 16 3 15 17 5 15 18 4 15 19 2 8 20 1 5 TEST054 IVEC_SORT_INSERT_A sorts an integer array. Unsorted array: 1 6 2 3 3 9 4 1 5 8 6 7 7 1 8 2 9 4 10 0 Sorted array: 1 0 2 1 3 1 4 2 5 3 6 4 7 6 8 7 9 8 10 9 TEST055 IVEC_SORT_QUICK_A sorts an integer vector using quick sort. Unsorted array: 1 46 2 18 3 2 4 20 5 58 6 32 7 0 8 38 9 15 10 28 11 40 12 59 13 9 14 36 15 52 16 54 17 30 18 28 19 34 20 21 Sorted array: 1 0 2 2 3 9 4 15 5 18 6 20 7 21 8 28 9 28 10 30 11 32 12 34 13 36 14 38 15 40 16 46 17 52 18 54 19 58 20 59 TEST056 IVEC_SORT_SHELL_A sorts an integer vector using Shell's sort. Unsorted array: 1 15 2 53 3 11 4 31 5 49 6 24 7 11 8 53 9 42 10 45 11 1 12 3 13 2 14 2 15 56 16 38 17 16 18 15 19 46 20 4 Sorted array: 1 1 2 2 3 2 4 3 5 4 6 11 7 11 8 15 9 15 10 16 11 24 12 31 13 38 14 42 15 45 16 46 17 49 18 53 19 53 20 56 TEST057 IVEC_VALUE_INDEX indexes entries equal to a given value. The desired value is 3 Maximum number of indices to find is 3 Input vector A: 1 3 2 4 3 2 4 4 5 4 6 2 7 4 8 4 9 1 10 1 11 5 12 4 13 2 14 2 15 3 16 5 17 4 18 2 19 1 20 4 21 3 22 1 23 2 24 4 25 5 Indices of entries equal to given value: 1 1 2 15 3 21 TEST058 For a pair of integer vectors: IVEC2_SORT_A ascending sorts; IVEC2_SORT_D descending sorts; IVEC2_UNIQUE counts unique entries. The array: 1 2 3 2 3 2 3 2 3 4 3 1 5 3 2 6 1 2 7 3 3 8 1 3 9 2 3 10 2 3 After ascending sort: 1 1 2 2 1 3 3 2 3 4 2 3 5 2 3 6 2 3 7 3 1 8 3 2 9 3 2 10 3 3 After descending sort: 1 3 3 2 3 2 3 3 2 4 3 1 5 2 3 6 2 3 7 2 3 8 2 3 9 1 3 10 1 2 After UNIQ: 1 3 3 2 3 2 3 3 1 4 2 3 5 1 3 6 1 2 TEST059 NORMAL_01_SAMPLE generates normally distributed random values. 0.635935 0.221003 -0.541706 -0.623043 -0.890751E-01 -0.291218 -1.32745 -0.349855 0.113892 1.33752 -0.346315 0.156324 -0.100871E-01 1.68758 0.348240 0.762476 0.418841 -1.73077 0.670756 -1.54040 TEST0595 NORMAL_01_VECTOR computes a vector of normally distributed random numbers. Set the random number seed to 123456789 Test #1: Call 5 times, 1 value each time. 1 -0.506679 2 -0.256625 3 0.457141 4 -0.435639E-01 5 -0.224942 Test #2: Restore the random number seed. Call 5 times, 1 value each time. The results should be identical. 1 -0.506679 2 -0.256625 3 0.457141 4 -0.435639E-01 5 -0.224942 Test #3: Restore the random number seed. Call 1 time for 5 values. The results should be identical. 1 -0.506679 2 -0.256625 3 0.457141 4 -0.435639E-01 5 -0.224942 Test #4: Restore the random number seed. Call for 2, 1, and 2 values. The results should be identical. 1 -0.506679 2 -0.256625 1 0.457141 1 -0.435639E-01 2 -0.224942 Test #5: Number of samples was 1000 Minimum value was -3.20554 Maximum value was 2.76149 Average value was -0.278993E-01 Variance was 0.988327 Expected average 0.00000 Expected variance 1.00000 TEST060 R_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 R_DIFF(X,Y) 1.0000 0.0625 0.9375 0.8750 1.0000 0.1250 0.8750 0.8750 1.0000 0.2500 0.7500 0.7500 1.0000 0.5000 0.5000 0.5000 1.0000 0.8740 0.1260 0.1250 1.0000 0.8760 0.1240 0.1250 1.0000 0.9000 0.1000 0.1250 1.0000 0.9500 0.0500 0.0000 1.0000 0.9900 0.0100 0.0000 1.0000 1.0000 0.0000 0.0000 1.0000 1.0100 -0.0100 0.0000 1.0000 1.0500 -0.0500 0.0000 1.0000 1.1000 -0.1000 -0.1375 1.0000 3.0000 -2.0000 -1.8750 1.0000 10.0000 -9.0000 -8.7500 TEST061 R_DIGIT extracts decimal digits. Here, we get digits of 3.14159 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 3 1 4 1 5 9 2 7 4 1 0 1 2 5 7 TEST0615 R_INF returns real infinity; TEST CANCELLED! I GET A FLOATING-DIVIDE-BY-ZERO ERROR. TEST062 R_NAN returns real NaN. TEST CANCELLED! I GET A FLOATING-DIVIDE-BY-ZERO ERROR. TEST063 R_MANT decomposes a real value. Number to be decomposed: ÝZ R_MANT: X = -1 * 1.22718 * 2** 8 TEST0635 R_POWER computes R**P, economizing on multiplications. R P R**P Mults 2.00000 -10 0.976562E-03 7 2.00000 -9 0.195312E-02 7 2.00000 -8 0.390625E-02 6 2.00000 -7 0.781250E-02 7 2.00000 -6 0.156250E-01 6 2.00000 -5 0.312500E-01 6 2.00000 -4 0.625000E-01 5 2.00000 -3 0.125000 5 2.00000 -2 0.250000 4 2.00000 -1 0.500000 1 2.00000 0 1.00000 0 2.00000 1 2.00000 0 2.00000 2 4.00000 3 2.00000 3 8.00000 4 2.00000 4 16.0000 4 2.00000 5 32.0000 5 2.00000 6 64.0000 5 2.00000 7 128.000 6 2.00000 8 256.000 5 2.00000 9 512.000 6 2.00000 10 1024.00 6 2.00000 11 2048.00 7 2.00000 12 4096.00 6 2.00000 13 8192.00 7 2.00000 14 16384.0 7 2.00000 15 32768.0 8 2.00000 16 65536.0 6 2.00000 17 131072. 7 2.00000 18 262144. 7 2.00000 19 524288. 8 2.00000 20 0.104858E+07 7 2.00000 21 0.209715E+07 8 2.00000 22 0.419430E+07 8 2.00000 23 0.838861E+07 9 2.00000 24 0.167772E+08 7 2.00000 25 0.335544E+08 8 2.00000 26 0.671089E+08 8 2.00000 27 0.134218E+09 9 2.00000 28 0.268435E+09 8 2.00000 29 0.536871E+09 9 2.00000 30 0.107374E+10 9 2.00000 31 0.214748E+10 10 2.00000 32 0.429497E+10 7 2.00000 33 0.858993E+10 8 2.00000 34 0.171799E+11 8 2.00000 35 0.343597E+11 9 2.00000 36 0.687195E+11 8 2.00000 37 0.137439E+12 9 2.00000 38 0.274878E+12 9 2.00000 39 0.549756E+12 10 2.00000 40 0.109951E+13 8 TEST0636 R_RANDOM returns random real values in a given range: [ ALO, AHI ] For this problem: ALO = 10.0000 AHI = 20.0000 Initialize random numbers with SEED = 1973 15.3335 15.5882 19.4318 16.9413 14.5262 10.6287 12.9190 18.6431 12.4711 17.2741 Initialize random numbers with SEED = 123456789 11.9379 10.1245 16.0759 11.8250 15.4607 19.4644 18.1726 16.1471 12.4674 12.2612 Initialize random numbers with SEED = 1973 15.3335 15.5882 19.4318 16.9413 14.5262 10.6287 12.9190 18.6431 12.4711 17.2741 TEST064 R_ROUND2 rounds a real number to a specified number of base 2 digits. Test effect on PI: X = 3.14159 NPLACE XROUND 0 0.00000 1 2.00000 2 3.00000 3 3.00000 4 3.00000 5 3.12500 6 3.12500 7 3.12500 8 3.14062 9 3.14062 10 3.14062 11 3.14062 12 3.14062 13 3.14111 14 3.14136 15 3.14148 16 3.14154 17 3.14157 18 3.14159 19 3.14159 20 3.14159 TEST065 R_ROUNDB rounds a real number to a specified number of base IBASE digits. Here, we will use IBASE = 3 Test effect on PI: X = 3.14159 NPLACE XROUND 0 0.00000 1 3.00000 2 3.00000 3 3.00000 4 3.11111 5 3.11111 6 3.13580 7 3.13992 8 3.14129 9 3.14129 10 3.14144 11 3.14154 12 3.14158 13 3.14159 14 3.14159 15 3.14159 16 3.14159 17 3.14159 18 3.14159 19 3.14160 20 3.14160 Try with a negative base: Input quantity is X = 121.000 to be rounded in base -3 Output value to 1 places is 81.0000 Output value to 2 places is 108.000 Output value to 3 places is 117.000 Output value to 4 places is 120.000 Output value to 5 places is 120.000 TEST066 R_ROUNDX rounds a real number to a specified number of decimal digits. Test effect on PI: X = 3.14159 NPLACE XROUND 0 0.0000000 1 3.0000000 2 3.1000001 3 3.1400001 4 3.1410000 5 3.1415005 6 3.1415906 7 3.1415927 8 3.1415935 9 3.1415937 10 3.1415939 TEST067 R_SIGN returns the sign of a number. -1.2500 -1.0000 -0.2500 -1.0000 0.0000 0.0000 0.5000 1.0000 9.0000 1.0000 TEST0675 R_TO_BIN_EVEN puts a number into a bin. BIN_TO_R_EVEN returns the bin limits. The bins are equally spaced between A and B, with two extra bins, for things less than A, or greater than B. A = 10.0000 B = 20.0000 Total number of bins = 7 Generate some random values C and put them in bins. C Bin Bin_Min Bin_Max 11.3697 2 10.0000 12.0000 8.57180 1 -0.340282E+39 10.0000 8.69563 1 -0.340282E+39 10.0000 20.4665 7 20.0000 0.340282E+39 15.1497 4 14.0000 16.0000 10.7816 2 10.0000 12.0000 17.3968 5 16.0000 18.0000 14.2858 4 14.0000 16.0000 15.0029 4 14.0000 16.0000 17.2759 5 16.0000 18.0000 11.0030 2 10.0000 12.0000 19.7263 6 18.0000 20.0000 13.9934 3 12.0000 14.0000 11.5189 2 10.0000 12.0000 10.2543 2 10.0000 12.0000 10.3975 2 10.0000 12.0000 10.7574 2 10.0000 12.0000 8.53167 1 -0.340282E+39 10.0000 9.99723 1 -0.340282E+39 10.0000 17.4737 5 16.0000 18.0000 21.7862 7 20.0000 0.340282E+39 9.55384 1 -0.340282E+39 10.0000 17.2598 5 16.0000 18.0000 16.7061 5 16.0000 18.0000 14.2998 4 14.0000 16.0000 9.36352 1 -0.340282E+39 10.0000 22.1279 7 20.0000 0.340282E+39 21.8273 7 20.0000 0.340282E+39 22.7517 7 20.0000 0.340282E+39 9.32595 1 -0.340282E+39 10.0000 TEST0676 R_TO_BIN_EVEN2 puts a number into a bin. BIN_TO_R_EVEN2 returns the bin limits. The bins are equally spaced between A and B. A = 10.0000 B = 20.0000 Total number of bins = 5 Generate some random values C and put them in bins. C Bin Bin_Min Bin_Max 8.08582 1 10.0000 12.0000 19.1153 5 18.0000 20.0000 10.3929 1 10.0000 12.0000 10.9834 1 10.0000 12.0000 9.83334 1 10.0000 12.0000 21.6831 5 18.0000 20.0000 15.4903 3 14.0000 16.0000 20.7498 5 18.0000 20.0000 8.65700 1 10.0000 12.0000 14.9691 3 14.0000 16.0000 16.7647 4 16.0000 18.0000 15.1053 3 14.0000 16.0000 19.0846 5 18.0000 20.0000 13.1063 2 12.0000 14.0000 21.2964 5 18.0000 20.0000 16.5939 4 16.0000 18.0000 17.5426 4 16.0000 18.0000 12.0614 2 12.0000 14.0000 18.2729 5 18.0000 20.0000 21.9172 5 18.0000 20.0000 21.1721 5 18.0000 20.0000 9.85579 1 10.0000 12.0000 11.4364 1 10.0000 12.0000 10.9982 1 10.0000 12.0000 21.0669 5 18.0000 20.0000 17.5568 4 16.0000 18.0000 22.4412 5 18.0000 20.0000 19.9399 5 18.0000 20.0000 22.0480 5 18.0000 20.0000 13.6434 2 12.0000 14.0000 TEST0677 R2_TO_BIN_EVEN puts an R2 number into a bin. BIN_TO_R2_EVEN returns the bin limits. The bins are equally spaced between A and B, with two extra bins, for things less than A, or greater than B. A(1) = 5.00000 B(1) = 15.0000 A(2) = 0.00000 B(2) = 20.0000 Total number of bins = 7 Generate some random values C and put them in bins. We list the X and Y components on separate lines. C Bin Bin_Min Bin_Max 15.1846 7 15.0000 0.340282E+39 14.3795 5 12.0000 16.0000 20.6424 7 15.0000 0.340282E+39 15.7062 5 12.0000 16.0000 18.1525 7 15.0000 0.340282E+39 17.4515 6 16.0000 20.0000 19.9507 7 15.0000 0.340282E+39 -0.731254 1 -0.340282E+39 0.00000 9.94781 4 9.00000 11.0000 18.1130 6 16.0000 20.0000 4.65568 1 -0.340282E+39 5.00000 -1.75228 1 -0.340282E+39 0.00000 13.6216 6 13.0000 15.0000 3.98628 2 0.00000 4.00000 10.8530 4 9.00000 11.0000 12.8527 5 12.0000 16.0000 14.2924 6 13.0000 15.0000 12.8489 5 12.0000 16.0000 13.5945 6 13.0000 15.0000 -1.77701 1 -0.340282E+39 0.00000 9.46797 4 9.00000 11.0000 10.7758 4 8.00000 12.0000 13.3877 6 13.0000 15.0000 0.584327 2 0.00000 4.00000 11.6510 5 11.0000 13.0000 19.1082 6 16.0000 20.0000 8.99584 3 7.00000 9.00000 12.0727 5 12.0000 16.0000 19.8637 7 15.0000 0.340282E+39 4.01733 3 4.00000 8.00000 16.9016 7 15.0000 0.340282E+39 5.05757 3 4.00000 8.00000 16.3641 7 15.0000 0.340282E+39 12.0135 5 12.0000 16.0000 10.7765 4 9.00000 11.0000 17.3494 6 16.0000 20.0000 8.80716 3 7.00000 9.00000 4.72571 3 4.00000 8.00000 20.0541 7 15.0000 0.340282E+39 3.40185 2 0.00000 4.00000 3.07037 1 -0.340282E+39 5.00000 16.5167 6 16.0000 20.0000 4.62507 1 -0.340282E+39 5.00000 -1.70563 1 -0.340282E+39 0.00000 11.1830 5 11.0000 13.0000 1.56472 2 0.00000 4.00000 3.68140 1 -0.340282E+39 5.00000 12.2313 5 12.0000 16.0000 15.4685 7 15.0000 0.340282E+39 10.1942 4 8.00000 12.0000 5.92214 2 5.00000 7.00000 1.21706 2 0.00000 4.00000 16.2337 7 15.0000 0.340282E+39 8.58344 4 8.00000 12.0000 15.0010 7 15.0000 0.340282E+39 19.8606 6 16.0000 20.0000 21.8449 7 15.0000 0.340282E+39 11.3708 4 8.00000 12.0000 14.8969 6 13.0000 15.0000 1.06514 2 0.00000 4.00000 TEST068 R2_CHEBY computes the Chebyshev abscissas for a given interval [R1,R2]. R1: -1.00000 1 -0.951056 2 -0.587785 3 0.298023E-07 4 0.587785 5 0.951056 R2: 1.00000 R1: 0.00000 1 0.125360 2 1.09084 3 2.83058 4 5.00000 5 7.16942 6 8.90916 7 9.87464 R2: 10.0000 TEST1007 R2VEC_BIN_EVEN constructs evenly spaced bins and assigns each element of a real array to a bin. R2VEC_BINNED_REORDER can reorder the array to correspond to the bin ordering. R2VEC_BINNED_SORT_A can sort the individual bins after the array has been reordered. The bins are equally spaced between BIN_MIN and BIN_MAX, with two extra bins, for things less than BIN_MIN, or greater than BIN_MAX. Component 1 range: 10.0000 20.0000 Component 2 range: 5.00000 10.0000 Number of bins per row and column = 4 The data vector A to be binned: 1 15.4409 7.45577 2 20.3002 8.30922 3 18.5198 6.63928 4 18.3581 5.49808 5 9.14031 9.40879 6 15.2030 8.15923 7 8.48036 5.05766 8 19.8374 10.1491 9 10.3219 10.9866 10 22.3234 8.01732 11 10.1168 4.55830 12 13.4350 3.04583 13 15.6389 11.1643 14 13.1816 11.0278 15 19.6610 10.7299 16 12.5649 10.6308 17 17.0555 4.10461 18 12.5530 9.11514 19 10.2046 7.23080 20 18.0089 7.93782 21 21.3985 4.13110 22 13.2834 11.3133 23 21.9533 10.4382 24 22.7701 7.31173 25 13.4547 8.51573 26 14.4070 5.84006 27 9.03930 10.3401 28 17.2065 5.94823 29 22.3962 7.75076 30 16.4979 8.65388 The BIN_START array: 1 2 3 4 1 -1 7 5 27 2 11 19 18 9 3 17 1 6 8 4 21 24 2 23 The BIN_LAST array: 1 2 3 4 1 -1 7 5 27 2 11 19 18 9 3 17 1 6 8 4 21 24 2 23 The BIN_NEXT array: 1 3 2 10 3 4 4 28 5 0 6 20 7 0 8 13 9 14 10 29 11 12 12 0 13 15 14 16 15 0 16 22 17 0 18 25 19 26 20 30 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 Contents of bin number 1 1 Contents of bin number 1 2 1 7 8.48036 5.05766 Contents of bin number 1 3 1 5 9.14031 9.40879 Contents of bin number 1 4 1 27 9.03930 10.3401 Contents of bin number 2 1 1 11 10.1168 4.55830 2 12 13.4350 3.04583 Contents of bin number 2 2 1 19 10.2046 7.23080 2 26 14.4070 5.84006 Contents of bin number 2 3 1 18 12.5530 9.11514 2 25 13.4547 8.51573 Contents of bin number 2 4 1 9 10.3219 10.9866 2 14 13.1816 11.0278 3 16 12.5649 10.6308 4 22 13.2834 11.3133 Contents of bin number 3 1 1 17 17.0555 4.10461 Contents of bin number 3 2 1 1 15.4409 7.45577 2 3 18.5198 6.63928 3 4 18.3581 5.49808 4 28 17.2065 5.94823 Contents of bin number 3 3 1 6 15.2030 8.15923 2 20 18.0089 7.93782 3 30 16.4979 8.65388 Contents of bin number 3 4 1 8 19.8374 10.1491 2 13 15.6389 11.1643 3 15 19.6610 10.7299 Contents of bin number 4 1 1 21 21.3985 4.13110 Contents of bin number 4 2 1 24 22.7701 7.31173 Contents of bin number 4 3 1 2 20.3002 8.30922 2 10 22.3234 8.01732 3 29 22.3962 7.75076 Contents of bin number 4 4 1 23 21.9533 10.4382 Call R2VEC_BINNED_REORDER to reorder the array. The data vector, sorted by bins: 1 8.48036 5.05766 2 9.14031 9.40879 3 9.03930 10.3401 4 10.1168 4.55830 5 13.4350 3.04583 6 10.2046 7.23080 7 14.4070 5.84006 8 12.5530 9.11514 9 13.4547 8.51573 10 10.3219 10.9866 11 13.1816 11.0278 12 12.5649 10.6308 13 13.2834 11.3133 14 17.0555 4.10461 15 15.4409 7.45577 16 18.5198 6.63928 17 18.3581 5.49808 18 17.2065 5.94823 19 15.2030 8.15923 20 18.0089 7.93782 21 16.4979 8.65388 22 19.8374 10.1491 23 15.6389 11.1643 24 19.6610 10.7299 25 21.3985 4.13110 26 22.7701 7.31173 27 20.3002 8.30922 28 22.3234 8.01732 29 22.3962 7.75076 30 21.9533 10.4382 The BIN_START array: 1 2 3 4 1 -1 1 2 3 2 4 6 8 10 3 14 15 19 22 4 25 26 27 30 The BIN_LAST array: 1 2 3 4 1 -1 1 2 3 2 5 7 9 13 3 14 18 21 24 4 25 26 29 30 The BIN_NEXT array: 1 0 2 0 3 0 4 5 5 0 6 7 7 0 8 9 9 0 10 11 11 12 12 13 13 0 14 0 15 16 16 17 17 18 18 0 19 20 20 21 21 0 22 23 23 24 24 0 25 0 26 0 27 28 28 29 29 0 30 0 The data vector, with sorted bins: 1 8.48036 5.05766 2 9.14031 9.40879 3 9.03930 10.3401 4 10.1168 4.55830 5 13.4350 3.04583 6 10.2046 7.23080 7 14.4070 5.84006 8 12.5530 9.11514 9 13.4547 8.51573 10 10.3219 10.9866 11 12.5649 10.6308 12 13.1816 11.0278 13 13.2834 11.3133 14 17.0555 4.10461 15 15.4409 7.45577 16 17.2065 5.94823 17 18.3581 5.49808 18 18.5198 6.63928 19 15.2030 8.15923 20 16.4979 8.65388 21 18.0089 7.93782 22 15.6389 11.1643 23 19.6610 10.7299 24 19.8374 10.1491 25 21.3985 4.13110 26 22.7701 7.31173 27 20.3002 8.30922 28 22.3234 8.01732 29 22.3962 7.75076 30 21.9533 10.4382 TEST0683 RANDOM_INITIALIZE can make up a seed for the FORTRAN 90 random number generator RANDOM_NUMBER, or use a single SEED value from the user. Calling RANDOM_INITIALIZE with a zero input value of SEED tells the routine to make up a seed. And, at least for calls a few milliseconds apart, the output SEED should be different. In any case, if RANDOM_NUMBER is restarted by calling RANDOM_INITIALIZE with a nonzero input SEED, then the random number sequence should repeat. Call RANDOM_INITIALIZE 10 times, with a zero input SEED. Also, get the first three real random values. SEED_IN SEED_OUT Random 1, 2, 3 0 1694218206 0.39972717 0.86483634 0.32758021 0 1694218207 0.56419802 0.51386321 0.86054635 0 1694218208 0.94563019 0.55622900 0.89011765 0 1694218209 0.11010110 0.20525581 0.42308378 0 1694218209 0.11010110 0.20525581 0.42308378 0 1694218210 0.49153322 0.24762160 0.45265508 0 1694218210 0.49153322 0.24762160 0.45265508 0 1694218211 0.65600413 0.89664841 0.98562121 0 1694218212 0.03743625 0.93901426 0.01519251 0 1694218212 0.03743625 0.93901426 0.01519251 Now call RANDOM_INITIALIZE with SEED = 5, 95, 5, 95. We promise the random numbers will repeat the second time. SEED_IN SEED_OUT Random 1, 2, 3 5 5 0.36475760 0.22848153 0.40634358 95 95 0.93039435 0.34114951 0.72052807 5 5 0.36475760 0.22848153 0.40634358 95 95 0.93039435 0.34114951 0.72052807 TEST0684 RANDOM_NUMBER is an intrinsic FORTRAN 90 routine to computer uniform random numbers. Set the random number seed to 123456789 Test #1: Call 5 times, 1 value each time. 1 0.700759 2 0.108494 3 0.667681 4 0.706692 5 0.335158E-01 Test #2: Restore the random number seed. Call 5 times, 1 value each time. The results should be identical. 1 0.700759 2 0.108494 3 0.667681 4 0.706692 5 0.335158E-01 Test #3: Restore the random number seed. Call 1 time for 5 values. The results should be identical. 1 0.700759 2 0.108494 3 0.667681 4 0.706692 5 0.335158E-01 Test #4: Restore the random number seed. Call for 2, 1, and 2 values. The results should be identical. 1 0.700759 2 0.108494 1 0.667681 1 0.706692 2 0.335158E-01 Test #5: Number of samples was 1000 Minimum value was 0.102127E-02 Maximum value was 0.999112 Average value was 0.514292 Variance was 0.795816E-01 Expected average 0.500000 Expected variance 0.833333E-01 TEST0685 RANDOM_SEED is a FORTRAN90 routine which sets or gets the random number set. RANDOM_NUMBER returns a uniformly distributed random value between 0 and 1. Starting with seed = 192114431 Number of values computed was N = 1000 Average value was 0.501922 Variance was 0.850123E-01 TEST069 RAT_FACTOR factors a rational value. Rational value is 1638/ 12 Prime representation: I, FACTOR(I), POWER(I) 1 2 -1 2 3 1 3 7 1 4 13 1 TEST0695 RBLOCK_EXPAND_LINEAR linearly interpolates new data between old values in a 3D block. Original block: K = 1 1 2 3 1 1.00000 1.00000 1.00000 2 2.00000 4.00000 8.00000 3 3.00000 9.00000 27.0000 4 4.00000 16.0000 64.0000 K = 2 1 2 3 1 2.00000 2.00000 2.00000 2 4.00000 8.00000 16.0000 3 6.00000 18.0000 54.0000 4 8.00000 32.0000 128.000 LFAT = 1 MFAT = 2 NFAT = 1 Fattened block: K = 1 1 2 3 4 5 1 1.00000 1.00000 1.00000 1.00000 1.00000 2 1.50000 1.83333 2.16667 2.50000 3.16667 3 2.00000 2.66667 3.33333 4.00000 5.33333 4 2.50000 3.83333 5.16667 6.50000 10.1667 5 3.00000 5.00000 7.00000 9.00000 15.0000 6 3.50000 6.50000 9.50000 12.5000 23.5000 7 4.00000 8.00000 12.0000 16.0000 32.0000 6 7 1 1.00000 1.00000 2 3.83333 4.50000 3 6.66667 8.00000 4 13.8333 17.5000 5 21.0000 27.0000 6 34.5000 45.5000 7 48.0000 64.0000 K = 2 1 2 3 4 5 1 1.50000 1.50000 1.50000 1.50000 1.50000 2 2.25000 2.75000 3.25000 3.75000 4.75000 3 3.00000 4.00000 5.00000 6.00000 8.00000 4 3.75000 5.75000 7.75000 9.75000 15.2500 5 4.50000 7.50000 10.5000 13.5000 22.5000 6 5.25000 9.75000 14.2500 18.7500 35.2500 7 6.00000 12.0000 18.0000 24.0000 48.0000 6 7 1 1.50000 1.50000 2 5.75000 6.75000 3 10.0000 12.0000 4 20.7500 26.2500 5 31.5000 40.5000 6 51.7500 68.2500 7 72.0000 96.0000 K = 3 1 2 3 4 5 1 2.00000 2.00000 2.00000 2.00000 2.00000 2 3.00000 3.66667 4.33333 5.00000 6.33333 3 4.00000 5.33333 6.66667 8.00000 10.6667 4 5.00000 7.66667 10.3333 13.0000 20.3333 5 6.00000 10.0000 14.0000 18.0000 30.0000 6 7.00000 13.0000 19.0000 25.0000 47.0000 7 8.00000 16.0000 24.0000 32.0000 64.0000 6 7 1 2.00000 2.00000 2 7.66667 9.00000 3 13.3333 16.0000 4 27.6667 35.0000 5 42.0000 54.0000 6 69.0000 91.0000 7 96.0000 128.000 TEST070 RCOL_FIND finds a column in a table matching a given set of data. RCOL_FIND returns ICOL = 3 TEST071 RCOL_SORT_HEAP_A ascending heap sorts a table of columns. RCOL_INSERT inserts new columns. The unsorted matrix: 1 2 3 4 1 2.000000 4.000000 1.000000 3.000000 2 6.000000 8.000000 5.000000 7.000000 3 10.000000 12.000000 9.000000 11.000000 The sorted matrix: 1 2 3 4 1 1.000000 2.000000 3.000000 4.000000 2 5.000000 6.000000 7.000000 8.000000 3 9.000000 10.000000 11.000000 12.000000 New column: 1 3.00000 2 7.00000 3 11.0000 The data was already in column 3 New column: 1 3.00000 2 4.00000 3 18.0000 The updated matrix: 1 2 3 4 5 1 1.000000 2.000000 3.000000 3.000000 4.000000 2 5.000000 6.000000 4.000000 7.000000 8.000000 3 9.000000 10.000000 18.000000 11.000000 12.000000 TEST0715 RCOL_SORT_QUICK_A sorts a table of columns. The unsorted matrix: 1 2 3 4 5 1 1.619617 4.697457 7.869069 2.796270 3.760144 2 7.267112 4.331285 5.345697 9.853500 3.793654 3 5.846560 5.681570 1.691911 5.723016 1.681731 6 7 8 9 10 1 4.103792 7.022995 0.826826 0.514334 6.882014 2 4.700530 1.189778 9.003780 6.082970 7.313891 3 2.535465 7.186490 2.968212 8.975328 1.380033 The sorted matrix: 1 2 3 4 5 1 0.514334 0.826826 1.619617 2.796270 3.760144 2 6.082970 9.003780 7.267112 9.853500 3.793654 3 8.975328 2.968212 5.846560 5.723016 1.681731 6 7 8 9 10 1 4.103792 4.697457 6.882014 7.022995 7.869069 2 4.700530 4.331285 7.313891 1.189778 5.345697 3 2.535465 5.681570 1.380033 7.186490 1.691911 TEST072 For a real matrix regarded as columns; RCOL_MAX computes maximums; RCOL_MEAN computes means; RCOL_MIN computes minimums; RCOL_SUM computes sums; RCOL_SWAP swaps two; RCOL_VARIANCE computes variances; The array: 1 2 3 4 1 1.000000 2.000000 3.000000 4.000000 2 5.000000 6.000000 7.000000 8.000000 3 9.000000 10.000000 11.000000 12.000000 Column, maximum, minimum, sum, mean, variance: 1 9.0000 1.0000 15.0000 5.0000 16.0000 2 10.0000 2.0000 18.0000 6.0000 16.0000 3 11.0000 3.0000 21.0000 7.0000 16.0000 4 12.0000 4.0000 24.0000 8.0000 16.0000 Swap columns 1 and 3: The updated matrix: 1 2 3 4 1 3.000000 2.000000 1.000000 4.000000 2 7.000000 6.000000 5.000000 8.000000 3 11.000000 10.000000 9.000000 12.000000 TEST073 RCOL_SORTR_A is given an array, and reorders it so that a particular column is sorted. Here, the special column is 2 Unsorted array: 1 2 3 1 0.015438 8.348294 5.656469 2 4.593482 6.376273 5.333018 3 6.118224 6.430993 0.016868 4 7.225829 6.876879 0.133142 5 0.291428 5.252662 0.442797 6 3.438693 4.088164 2.043929 7 5.821216 8.672168 4.025978 8 4.330650 0.359868 4.498199 9 4.791577 8.311922 0.811026 10 9.883480 4.656178 0.558845 Sorted array: 1 2 3 1 4.330650 0.359868 4.498199 2 3.438693 4.088164 2.043929 3 9.883480 4.656178 0.558845 4 0.291428 5.252662 0.442797 5 4.593482 6.376273 5.333018 6 6.118224 6.430993 0.016868 7 7.225829 6.876879 0.133142 8 4.791577 8.311922 0.811026 9 0.015438 8.348294 5.656469 10 5.821216 8.672168 4.025978 TEST1735 RCOL_TO_RVEC converts an array of columns to a vector. The array of columns: 1 2 3 4 1 11.000000 12.000000 13.000000 14.000000 2 21.000000 22.000000 23.000000 24.000000 3 31.000000 32.000000 33.000000 34.000000 The resulting vector of columns: 1 11.0000 2 21.0000 3 31.0000 4 12.0000 5 22.0000 6 32.0000 7 13.0000 8 23.0000 9 33.0000 10 14.0000 11 24.0000 12 34.0000 TEST024 R_LOG_INT_10: whole part of log base 10, X, LOG10(|X|), R_LOG_INT_10 0.00000 0.00000 ****** 1.00000 0.00000 0 2.00000 0.301030 0 3.00000 0.477121 0 9.00000 0.954243 0 10.0000 1.00000 1 11.0000 1.04139 1 99.0000 1.99564 1 101.000 2.00432 2 -1.00000 0.00000 0 -2.00000 0.301030 0 -3.00000 0.477121 0 -9.00000 0.954243 0 0.500000 -0.301030 0 0.333333 -0.477121 0 0.250000 -0.602060 0 0.200000 -0.698970 0 0.101010E-01 -1.99564 -1 0.100000E-01 -2.00000 -2 0.990099E-02 -2.00432 -2 TEST023 R_LOG_INT_2: whole part of log base 2. R_LOG_2: log base 2, X, R_LOG_2, R_LOG_INT_2 0.00000 -0.340282E+39 -2147483647 1.00000 0.00000 0 2.00000 0.00000 1 3.00000 1.58496 1 9.00000 3.16992 3 10.0000 3.32193 3 11.0000 3.45943 3 99.0000 6.62936 6 101.000 6.65821 6 -1.00000 0.00000 0 -2.00000 0.00000 1 -3.00000 1.58496 1 -9.00000 3.16992 3 0.500000 0.00000 -1 0.333333 -1.58496 -1 0.250000 0.00000 -2 0.200000 -2.32193 -2 0.101010E-01 -6.62936 -6 0.100000E-01 -6.64386 -6 0.990099E-02 -6.65821 -6 TEST923 R_LOG_INT_B: whole part of log base B. R_LOG_B: log base B, X, B, R_LOG_B, R_LOG_INT_B 16.0000 2.00000 4.00000 4 16.0000 3.00000 2.52372 2 16.0000 4.00000 2.00000 2 16.0000 5.00000 1.72271 1 16.0000 6.00000 1.54741 1 16.0000 7.00000 1.42483 1 16.0000 8.00000 1.33333 1 16.0000 16.0000 1.00000 1 16.0000 32.0000 0.800000 0 16.0000 256.000 0.500000 0 TEST0775 RMAT_CHOLESKY_FACTOR computes the lower triangular Cholesky factor of a positive definite symmetric matrix. RMAT_CHOLESKY_SOLVE solves a linear system using the Cholesky factorization. Matrix to be factored: 1 2 3 4 5 1 2.000000 -1.000000 0.000000 0.000000 0.000000 2 -1.000000 2.000000 -1.000000 0.000000 0.000000 3 0.000000 -1.000000 2.000000 -1.000000 0.000000 4 0.000000 0.000000 -1.000000 2.000000 -1.000000 5 0.000000 0.000000 0.000000 -1.000000 2.000000 Cholesky factor C: 1 2 3 4 5 1 1.414214 0.000000 0.000000 0.000000 0.000000 2 -0.707107 1.224745 0.000000 0.000000 0.000000 3 0.000000 -0.816497 1.154701 0.000000 0.000000 4 0.000000 0.000000 -0.866025 1.118034 0.000000 5 0.000000 0.000000 0.000000 -0.894427 1.095445 Product C * C': 1 2 3 4 5 1 2.000000 -1.000000 0.000000 0.000000 0.000000 2 -1.000000 2.000000 -1.000000 0.000000 0.000000 3 0.000000 -1.000000 2.000000 -1.000000 0.000000 4 0.000000 0.000000 -1.000000 2.000000 -1.000000 5 0.000000 0.000000 0.000000 -1.000000 2.000000 Right hand side: 1 0.00000 2 0.00000 3 0.00000 4 0.00000 5 6.00000 Computed solution: 1 1.00000 2 2.00000 3 3.00000 4 4.00000 5 5.00000 TEST078 Determinants of matrices: RMAT_DET_2D: 2 by 2 matrix; RMAT_DET_3D: 3 by 3 matrix; RMAT_DET_4D: 4 by 4 matrix; RMAT_DET_5D: 5 by 5 matrix. RMAT_VAND2 computes the row Vandermonde matrix. Matrix: 1 2 1 1.000000 1.000000 2 1.000000 10.000000 RMAT_DET_2D computes determinant: 9.00000 Exact determinant is 9.00000 Matrix: 1 2 3 1 1.000000 1.000000 1.000000 2 1.000000 10.000000 100.000000 3 1.000000 4.000000 16.000000 RMAT_DET_3D computes determinant: -162.000 Exact determinant is -162.000 Matrix: 1 2 3 4 1 1.000000 1.000000 1.000000 1.000000 2 1.000000 10.000000 100.000000 1000.000000 3 1.000000 4.000000 16.000000 64.000000 4 1.000000 2.000000 4.000000 8.000000 RMAT_DET_4D computes determinant: -2592.00 Exact determinant is -2592.00 Matrix: 1 2 3 4 5 1 1.000000 1.000000 1.000000 1.000000 1.000000 2 1.000000 10.000000 100.000000 1000.000000 10000.000000 3 1.000000 4.000000 16.000000 64.000000 256.000000 4 1.000000 2.000000 4.000000 8.000000 16.000000 5 1.000000 3.000000 9.000000 27.000000 81.000000 RMAT_DET_5D computes determinant: -36288.0 Exact determinant is -36288.0 TEST0744 RMAT_EXPAND_LINEAR linearly interpolates new data between old values in a matrix. Original matrix: 1 2 3 1 1.000000 1.000000 1.000000 2 2.000000 4.000000 8.000000 3 3.000000 9.000000 27.000000 4 4.000000 16.000000 64.000000 MFAT = 2 NFAT = 1 Fattened matrix: 1 2 3 4 5 1 1.000000 1.000000 1.000000 1.000000 1.000000 2 1.333333 1.666667 2.000000 2.666667 3.333333 3 1.666667 2.333333 3.000000 4.333333 5.666667 4 2.000000 3.000000 4.000000 6.000000 8.000000 5 2.333333 4.000000 5.666667 10.000000 14.333334 6 2.666667 5.000000 7.333333 14.000001 20.666668 7 3.000000 6.000000 9.000000 18.000000 27.000000 8 3.333333 7.333333 11.333334 25.333334 39.333336 9 3.666667 8.666667 13.666667 32.666668 51.666668 10 4.000000 10.000000 16.000000 40.000000 64.000000 TEST0745 RMAT_EXPAND_LINEAR2 fills in a large array by interpolating data from a small array. Original matrix has dimensions: 3 2 Expanded matrix has dimensions: 10 5 The little matrix A: 1 2 1 11.000000 12.000000 2 21.000000 22.000000 3 31.000000 32.000000 Expanded array A2: 1 2 3 4 5 1 11.000000 11.250000 11.500000 11.750000 12.000000 2 13.222221 13.472222 13.722222 13.972222 14.222223 3 15.444445 15.694446 15.944445 16.194445 16.444445 4 17.666666 17.916666 18.166666 18.416666 18.666666 5 19.888887 20.138889 20.388889 20.638889 20.888889 6 22.111113 22.361111 22.611111 22.861113 23.111111 7 24.333334 24.583332 24.833334 25.083332 25.333334 8 26.555557 26.805555 27.055557 27.305557 27.555555 9 28.777777 29.027779 29.277777 29.527779 29.777779 10 31.000000 31.250000 31.500000 31.750000 32.000000 TEST075 RMAT_GIVENS_POST computes a Givens postmultiplier rotation matrices. Matrix A: 1 2 3 1 1.000000 1.000000 1.000000 2 1.000000 2.000000 4.000000 3 1.000000 3.000000 9.000000 I, J= 3 2 G 1 2 3 1 1.000000 0.000000 0.000000 2 0.000000 0.948683 0.316228 3 0.000000 -0.316228 0.948683 A*G 1 2 3 1 1.000000 0.632456 1.264911 2 1.000000 0.632456 4.427189 3 1.000000 0.000000 9.486834 TEST0756 RMAT_GIVENS_PRE computes a Givens premultiplier rotation matrices. Matrix A: 1 2 3 1 1.000000 1.000000 1.000000 2 1.000000 2.000000 4.000000 3 1.000000 3.000000 9.000000 I, J= 3 2 G 1 2 3 1 1.000000 0.000000 0.000000 2 0.000000 0.554700 0.832050 3 0.000000 -0.832050 0.554700 GA 1 2 3 1 1.000000 1.000000 1.000000 2 1.386750 3.605551 9.707253 3 -0.277350 0.000000 1.664101 TEST009 RVEC_DIF estimates derivatives. Estimate the derivative of order N = 4 Using H = 0.100000E-01 at argument X = 1.00000 The difference coefficients: 1 0.625000E+07 2 -0.250000E+08 3 0.375000E+08 4 -0.250000E+08 5 0.625000E+07 Estimate is FDIF = 0.00000 TEST0754 RVEC_HOUSE_COLUMN returns the compact form of a Householder matrix that "packs" a column of a matrix. Matrix A: 1 2 3 4 1 0.130115 2.822901 2.160737 0.744405 2 2.405853 1.650810 1.719789 3.315329 3 2.990373 0.441548 0.132292 0.628294 4 4.500462 4.782508 2.753745 3.227400 Working on column K = 1 Householder matrix H: 1 2 3 4 1 -0.021993 -0.406654 -0.505454 -0.760700 2 -0.406654 0.838191 -0.201122 -0.302685 3 -0.505454 -0.201122 0.750014 -0.376225 4 -0.760700 -0.302685 -0.376225 0.433788 Product H*A: 1 2 3 4 1 -5.916210 -4.594629 -2.908522 -4.137222 2 0.000000 -1.300651 -0.297286 1.372914 3 0.000000 -3.226991 -2.374847 -1.786046 4 0.000000 -0.738583 -1.019457 -0.406142 Working on column K = 2 Householder matrix H: 1 2 3 4 1 1.000000 0.000000 0.000000 0.000000 2 0.000000 -0.365682 -0.907279 -0.207655 3 0.000000 -0.907279 0.397257 -0.137954 4 0.000000 -0.207655 -0.137954 0.968426 Product H*A: 1 2 3 4 1 -5.916210 -4.594629 -2.908522 -4.137222 2 0.000000 3.556778 2.475058 1.202730 3 0.000000 0.000000 -0.533064 -1.899106 4 0.000000 0.000000 -0.597916 -0.432019 Working on column K = 3 Householder matrix H: 1 2 3 4 1 1.000000 0.000000 0.000000 0.000000 2 0.000000 1.000000 0.000000 0.000000 3 0.000000 0.000000 -0.665467 -0.746427 4 0.000000 0.000000 -0.746427 0.665467 Product H*A: 1 2 3 4 1 -5.916210 -4.594629 -2.908522 -4.137222 2 0.000000 3.556778 2.475058 1.202730 3 0.000000 0.000000 0.801038 1.586263 4 0.000000 0.000000 0.000000 1.130051 TEST0755 RMAT_HOUSE_FORM forms a Householder matrix from its compact form. Compact vector form V: 1 0.00000 2 0.00000 3 1.00000 4 2.00000 5 3.00000 Householder matrix H: 1 2 3 4 5 1 1.000000 0.000000 0.000000 0.000000 0.000000 2 0.000000 1.000000 0.000000 0.000000 0.000000 3 0.000000 0.000000 0.857143 -0.285714 -0.428571 4 0.000000 0.000000 -0.285714 0.428571 -0.857143 5 0.000000 0.000000 -0.428571 -0.857143 -0.285714 TEST076 RMAT_HOUSE_POST computes a Householder postmultiplier; Matrix A: 1 2 3 4 5 1 3.450140 1.202086 2.228443 3.478873 1.974363 2 1.076504 0.170902 1.060888 2.214956 0.768456 3 1.830328 4.865435 4.272889 0.037710 1.830738 4 1.739525 1.399145 3.035105 1.215684 3.817950 5 1.020045 4.840981 1.096750 4.266931 4.634237 I, J= 2 3 Householder matrix H: 1 2 3 4 5 1 1.000000 0.000000 0.000000 0.000000 0.000000 2 0.000000 1.000000 0.000000 0.000000 0.000000 3 0.000000 0.000000 -0.412262 -0.860735 -0.298623 4 0.000000 0.000000 -0.860735 0.475406 -0.182002 5 0.000000 0.000000 -0.298623 -0.182002 0.936856 Product A*H: 1 2 3 4 5 1 3.450140 1.202086 -4.502680 -0.623559 0.551066 2 1.076504 0.170902 -2.573332 0.000000 0.000000 3 1.830328 4.865435 -2.340710 -3.993094 0.432291 4 1.739525 1.399145 -3.437769 -2.729352 2.449259 5 1.020045 4.840981 -5.508733 0.241073 3.237506 TEST0761 RMAT_HOUSE_PRE computes a Householder premultiplier; Matrix A: 1 2 3 4 5 1 2.160673 1.320656 0.812611 2.185214 1.348202 2 2.317095 4.146151 0.840824 3.788062 4.016928 3 1.945053 0.499373 2.329233 4.913516 2.913581 4 4.576427 4.720003 4.256157 1.029645 0.381284 5 2.553380 4.883664 2.119604 1.669495 0.642444 I, J= 2 3 Householder matrix H: 1 2 3 4 5 1 1.000000 0.000000 0.000000 0.000000 0.000000 2 0.000000 -0.156842 -0.434480 -0.793917 -0.395378 3 0.000000 -0.434480 0.836820 -0.298175 -0.148494 4 0.000000 -0.793917 -0.298175 0.455151 -0.271340 5 0.000000 -0.395378 -0.148494 -0.271340 0.864870 Product H*A: 1 2 3 4 5 1 2.160673 1.320656 0.812611 2.185214 1.348202 2 -5.851357 -6.545440 -5.360961 -4.206487 -2.452633 3 -1.122809 -3.516117 0.000000 1.910966 0.483778 4 -1.029412 -2.617414 0.000000 -4.456849 -4.058642 5 -0.238379 1.229564 0.000000 -1.062828 -1.568679 TEST082 RMAT_INVERSE_2D inverts a 2 by 2 matrix. Matrix A to invert: 1 2 1 1.000000 2.000000 2 3.000000 4.000000 Inverse matrix B: 1 2 1 -2.000000 1.000000 2 1.500000 -0.500000 Product C = A * B: 1 2 1 1.000000 0.000000 2 0.000000 1.000000 TEST083 RMAT_INVERSE_3D inverts a 3 by 3 matrix. Matrix A to be inverted: 1 2 3 1 1.000000 2.000000 3.000000 2 4.000000 5.000000 6.000000 3 7.000000 8.000000 0.000000 Inverse matrix B: 1 2 3 1 -1.777778 0.888889 -0.111111 2 1.555556 -0.777778 0.222222 3 -0.111111 0.222222 -0.111111 Product C = A * B: 1 2 3 1 1.000000 0.000000 0.000000 2 0.000000 1.000000 0.000000 3 0.000000 0.000000 1.000000 TEST084 RMAT_INVERSE_4D inverts a 4 x 4 matrix. Matrix A to be inverted: 1 2 3 4 1 4.000000 3.000000 2.000000 1.000000 2 3.000000 3.000000 2.000000 1.000000 3 0.000000 2.000000 2.000000 1.000000 4 0.000000 0.000000 1.000000 1.000000 Determinant is 1.00000 Inverse B: 1 2 3 4 1 1.000000 -1.000000 0.000000 0.000000 2 -3.000000 4.000000 -1.000000 0.000000 3 6.000000 -8.000000 3.000000 -1.000000 4 -6.000000 8.000000 -3.000000 2.000000 Product C = A * B: 1 2 3 4 1 1.000000 0.000000 0.000000 0.000000 2 0.000000 1.000000 0.000000 0.000000 3 0.000000 0.000000 1.000000 0.000000 4 0.000000 0.000000 0.000000 1.000000 TEST0734 RMAT_L_INVERSE inverts a lower triangular matrix. Matrix A to be inverted: 1 2 3 4 1 1.000000 0.000000 0.000000 0.000000 2 2.000000 3.000000 0.000000 0.000000 3 4.000000 5.000000 6.000000 0.000000 4 7.000000 8.000000 9.000000 10.000000 Inverse matrix B: 1 2 3 4 1 1.000000 0.000000 0.000000 0.000000 2 -0.666667 0.333333 0.000000 0.000000 3 -0.111111 -0.277778 0.166667 0.000000 4 -0.066667 -0.016667 -0.150000 0.100000 Product C = A * B: 1 2 3 4 1 1.000000 0.000000 0.000000 0.000000 2 0.000000 1.000000 0.000000 0.000000 3 0.000000 0.000000 1.000000 0.000000 4 0.000000 0.000000 0.000000 1.000000 TEST0735 RMAT_L1_INVERSE inverts a unit lower triangular matrix. Matrix A to be inverted: 1 2 3 4 5 1 1.000000 0.000000 0.000000 0.000000 0.000000 2 2.000000 1.000000 0.000000 0.000000 0.000000 3 0.000000 0.000000 1.000000 0.000000 0.000000 4 5.000000 0.000000 3.000000 1.000000 0.000000 5 0.000000 0.000000 0.000000 0.000000 1.000000 6 75.000000 0.000000 0.000000 6.000000 4.000000 6 1 0.000000 2 0.000000 3 0.000000 4 0.000000 5 0.000000 6 1.000000 Inverse matrix B: 1 2 3 4 5 1 1.000000 0.000000 0.000000 0.000000 0.000000 2 -2.000000 1.000000 0.000000 0.000000 0.000000 3 0.000000 0.000000 1.000000 0.000000 0.000000 4 -5.000000 0.000000 -3.000000 1.000000 0.000000 5 0.000000 0.000000 0.000000 0.000000 1.000000 6 -45.000000 0.000000 18.000000 -6.000000 -4.000000 6 1 0.000000 2 0.000000 3 0.000000 4 0.000000 5 0.000000 6 1.000000 Product C = A * B: 1 2 3 4 5 1 1.000000 0.000000 0.000000 0.000000 0.000000 2 0.000000 1.000000 0.000000 0.000000 0.000000 3 0.000000 0.000000 1.000000 0.000000 0.000000 4 0.000000 0.000000 0.000000 1.000000 0.000000 5 0.000000 0.000000 0.000000 0.000000 1.000000 6 0.000000 0.000000 0.000000 0.000000 0.000000 6 1 0.000000 2 0.000000 3 0.000000 4 0.000000 5 0.000000 6 1.000000 TEST079 RMAT_LU computes the LU factors of a matrix. Matrix to be factored: 1 2 3 4 5 1 1.000000 1.000000 1.000000 1.000000 1.000000 2 1.000000 10.000000 100.000000 1000.000000 10000.000000 3 1.000000 4.000000 16.000000 64.000000 256.000000 4 1.000000 2.000000 4.000000 8.000000 16.000000 5 1.000000 3.000000 9.000000 27.000000 81.000000 P factor: 1 2 3 4 5 1 1.000000 0.000000 0.000000 0.000000 0.000000 2 0.000000 1.000000 0.000000 0.000000 0.000000 3 0.000000 0.000000 1.000000 0.000000 0.000000 4 0.000000 0.000000 0.000000 1.000000 0.000000 5 0.000000 0.000000 0.000000 0.000000 1.000000 L factor: 1 2 3 4 5 1 1.000000 0.000000 0.000000 0.000000 0.000000 2 1.000000 1.000000 0.000000 0.000000 0.000000 3 1.000000 0.333333 1.000000 0.000000 0.000000 4 1.000000 0.111111 0.444444 1.000000 0.000000 5 1.000000 0.222222 0.777778 0.875000 1.000000 U factor: 1 2 3 4 5 1 1.000000 1.000000 1.000000 1.000000 1.000000 2 0.000000 9.000000 99.000000 999.000000 9999.000000 3 0.000000 0.000000 -18.000000 -270.000000 -3078.000000 4 0.000000 0.000000 0.000000 16.000000 272.000000 5 0.000000 0.000000 0.000000 0.000000 14.000000 P*L*U: 1 2 3 4 5 1 1.000000 1.000000 1.000000 1.000000 1.000000 2 1.000000 10.000000 100.000000 1000.000000 10000.000000 3 1.000000 4.000000 16.000000 64.000000 256.000000 4 1.000000 2.000000 4.000000 8.000000 16.000000 5 1.000000 3.000000 9.000000 27.000000 81.000000 TEST074 RMAT_IMAX locates the maximum; RMAT_IMIN locates the minimum; RMAT_MAX computes the maximum; RMAT_MAXCOL_MINROW computes the maximum over columns of the mininum over rows; RMAT_MAXROW_MINCOL computes the maximum over rows of the mininum over columns; RMAT_MIN computes the minimum; RMAT_MINCOL_MAXROW computes the minimum over columns of the maxinum over rows; RMAT_MINROW_MAXCOL computes the minimum over rows of the maxinum over columns; Random array: 1 2 3 1 6.112042 2.101245 8.168935 2 8.134748 2.157263 4.181006 3 3.927285 7.683659 7.759583 4 9.850443 9.097551 0.744877 5 5.859490 3.869825 3.918276 In each pair of numbers, the smaller should occur first: Minimum, Maximum = 9.85044 0.744877 Maximum I,J indices 4 1 Minimum I,J indices 4 3 MAXCOL_MINROW, MINROW_MAXCOL = 3.92729 8.16893 MAXROW_MINCOL, MINCOL_MAXROW = 3.92729 5.85949 TEST0799 RMAT_ORTH_RANDOM computes a random orthogonal matrix. Random orthogonal matrix A 1 2 3 4 5 1 -0.672586 0.367137 0.441934 -0.419448 0.203951 2 -0.565589 -0.677331 -0.355006 -0.181423 -0.249776 3 0.318553 0.226126 -0.381900 -0.813065 -0.201170 4 0.113662 -0.083595 0.570625 -0.046915 -0.807638 5 0.336663 -0.590179 0.455198 -0.357595 0.450852 AT*A 1 2 3 4 5 1 1.000000 0.000000 0.000000 0.000000 0.000000 2 0.000000 1.000000 0.000000 0.000000 0.000000 3 0.000000 0.000000 1.000000 0.000000 0.000000 4 0.000000 0.000000 0.000000 1.000000 0.000000 5 0.000000 0.000000 0.000000 0.000000 1.000000 TEST07995 RMAT_POWER_METHOD applies the power method to a matrix. Estimated eigenvalue = 3.73198 Estimated eigenvector V: 1 0.292882 2 -0.500045 3 0.573096 4 -0.499777 5 0.293187 Value of A*V: 1 1.08581 2 -1.86607 3 2.14601 4 -1.86584 5 1.08615 TEST080 RMAT_SOLVE solves linear systems. The linear system: 1 2 3 4 5 1 1.000000 2.000000 3.000000 14.000000 7.000000 2 4.000000 5.000000 6.000000 32.000000 16.000000 3 7.000000 8.000000 0.000000 23.000000 7.000000 The computed solutions: 1.00000 1.00000 2.00000 0.00000 3.00000 2.00000 TEST077 For a real symmetric matrix: RMAT_SYMM_JACOBI diagonalizes; RMAT_SYMM_RANDOM randomizes. Matrix to diagonalize: 1 2 3 4 5 1 2.564900 -1.162037 -0.023151 0.277058 0.885121 2 -1.162037 2.875445 -0.106035 -0.083887 0.019754 3 -0.023151 -0.106035 3.082212 -0.688449 0.234986 4 0.277058 -0.083887 -0.688449 3.156874 -1.439307 5 0.885121 0.019754 0.234986 -1.439307 3.320568 Computed Eigenvalues: 1.00000 4.00000 2.00000 3.00000 5.00000 TEST081 RMAT_TRACE computes the trace of a matrix Matrix: 1 2 3 4 1 4.000000 3.000000 2.000000 1.000000 2 3.000000 3.000000 2.000000 1.000000 3 0.000000 2.000000 2.000000 1.000000 4 0.000000 0.000000 1.000000 1.000000 Trace is 10.0000 TEST0814 RMAT_U_INVERSE inverts an upper triangular matrix. Input matrix A 1 2 3 4 1 1.000000 2.000000 4.000000 7.000000 2 0.000000 3.000000 5.000000 8.000000 3 0.000000 0.000000 6.000000 9.000000 4 0.000000 0.000000 0.000000 10.000000 Inverse matrix B: 1 2 3 4 1 1.000000 -0.666667 -0.111111 -0.066667 2 0.000000 0.333333 -0.277778 -0.016667 3 0.000000 0.000000 0.166667 -0.150000 4 0.000000 0.000000 0.000000 0.100000 Product C = A * B: 1 2 3 4 1 1.000000 0.000000 0.000000 0.000000 2 0.000000 1.000000 0.000000 0.000000 3 0.000000 0.000000 1.000000 0.000000 4 0.000000 0.000000 0.000000 1.000000 TEST0815 RMAT_U1_INVERSE inverts a unit upper triangular matrix. Input matrix A 1 2 3 4 5 1 1.000000 2.000000 0.000000 5.000000 0.000000 2 0.000000 1.000000 0.000000 0.000000 0.000000 3 0.000000 0.000000 1.000000 3.000000 0.000000 4 0.000000 0.000000 0.000000 1.000000 0.000000 5 0.000000 0.000000 0.000000 0.000000 1.000000 6 0.000000 0.000000 0.000000 0.000000 0.000000 6 1 75.000000 2 0.000000 3 0.000000 4 6.000000 5 4.000000 6 1.000000 Inverse matrix B: 1 2 3 4 5 1 1.000000 -2.000000 0.000000 -5.000000 0.000000 2 0.000000 1.000000 0.000000 0.000000 0.000000 3 0.000000 0.000000 1.000000 -3.000000 0.000000 4 0.000000 0.000000 0.000000 1.000000 0.000000 5 0.000000 0.000000 0.000000 0.000000 1.000000 6 0.000000 0.000000 0.000000 0.000000 0.000000 6 1 -45.000000 2 0.000000 3 18.000000 4 -6.000000 5 -4.000000 6 1.000000 Product C = A * B: 1 2 3 4 5 1 1.000000 0.000000 0.000000 0.000000 0.000000 2 0.000000 1.000000 0.000000 0.000000 0.000000 3 0.000000 0.000000 1.000000 0.000000 0.000000 4 0.000000 0.000000 0.000000 1.000000 0.000000 5 0.000000 0.000000 0.000000 0.000000 1.000000 6 0.000000 0.000000 0.000000 0.000000 0.000000 6 1 0.000000 2 0.000000 3 0.000000 4 0.000000 5 0.000000 6 1.000000 TEST085 ROOTS_TO_RPOLY computes the coefficients of a polynomial from its roots. RPOLY_PRINT prints a polynomial. Roots: 1 1.00000 2 2.00000 3 3.00000 4 4.00000 The polynomial p(x) = 1.00000 * x ^ 4 - 10.0000 * x ^ 3 + 35.0000 * x ^ 2 - 50.0000 * x + 24.0000 TEST0855 R2POLY2_TYPE determines the type of a second order equation in two variables. 9.0000 * x^2 + -4.0000 * y^2 + 0.0000 * xy + -36.0000 * x + -24.0000 * y + -36.0000 = 0 Type = 1 The set of solutions forms a hyperbola. 4.0000 * x^2 + 1.0000 * y^2 + -4.0000 * xy + 3.0000 * x + -4.0000 * y + 1.0000 = 0 Type = 2 The set of solutions forms a parabola. 9.0000 * x^2 + 16.0000 * y^2 + 0.0000 * xy + 36.0000 * x + -32.0000 * y + -92.0000 = 0 Type = 3 The set of solutions forms an ellipse. 1.0000 * x^2 + 1.0000 * y^2 + 0.0000 * xy + -6.0000 * x + -10.0000 * y + 115.0000 = 0 Type = 4 The set of solutions forms an imaginary ellipse. (There are no real solutions). 0.0000 * x^2 + 0.0000 * y^2 + 1.0000 * xy + 3.0000 * x + -1.0000 * y + -3.0000 = 0 Type = 5 The set of solutions forms a pair of intersecting lines. 1.0000 * x^2 + 2.0000 * y^2 + 0.0000 * xy + -2.0000 * x + 16.0000 * y + 33.0000 = 0 Type = 6 The set of solutions is a single point. 0.0000 * x^2 + 1.0000 * y^2 + 0.0000 * xy + 0.0000 * x + -6.0000 * y + 8.0000 = 0 Type = 7 The set of solutions forms a pair of distinct parallel lines. 0.0000 * x^2 + 1.0000 * y^2 + 0.0000 * xy + 0.0000 * x + -6.0000 * y + 10.0000 = 0 Type = 8 The set of solutions forms a pair of imaginary parallel lines. (There are no real solutions). 0.0000 * x^2 + 1.0000 * y^2 + 0.0000 * xy + 0.0000 * x + -2.0000 * y + 1.0000 = 0 Type = 9 The set of solutions forms a pair of coincident lines. 0.0000 * x^2 + 0.0000 * y^2 + 0.0000 * xy + 2.0000 * x + -1.0000 * y + 1.0000 = 0 Type = 10 The set of solutions forms a single line. 0.0000 * x^2 + 0.0000 * y^2 + 0.0000 * xy + 0.0000 * x + 0.0000 * y + 0.0000 = 0 Type = 11 The set of solutions is all space. 0.0000 * x^2 + 0.0000 * y^2 + 0.0000 * xy + 0.0000 * x + 0.0000 * y + 1.0000 = 0 Type = 12 The set of solutions is empty. TEST0856 RPOLY_DERIV computes the coefficients of the derivative of a polynomial. The initial polynomial p(x) = 1.00000 * x ^ 4 - 10.0000 * x ^ 3 + 35.0000 * x ^ 2 - 50.0000 * x + 24.0000 The derivative of order 0 p(x) = 1.00000 * x ^ 4 - 10.0000 * x ^ 3 + 35.0000 * x ^ 2 - 50.0000 * x + 24.0000 The derivative of order 1 p(x) = 4.00000 * x ^ 3 - 30.0000 * x ^ 2 + 70.0000 * x - 50.0000 The derivative of order 2 p(x) = 12.0000 * x ^ 2 - 60.0000 * x + 70.0000 The derivative of order 3 p(x) = 24.0000 * x - 60.0000 The derivative of order 4 p(x) = 0.00000 TEST086 RPOLY_LAGRANGE_COEF returns the coefficients for a Lagrange basis polynomial. RPOLY_PRINT prints a polynomial. Abscissas: 1 1.00000 2 2.00000 3 3.00000 4 4.00000 5 5.00000 The Lagrange basis polynomial: p(x) = 0.416667E-01 * x ^ 4 - 0.583333 * x ^ 3 + 2.95833 * x ^ 2 - 6.41667 * x + 5.00000 The Lagrange basis polynomial: p(x) = - 0.166667 * x ^ 4 + 2.16667 * x ^ 3 - 9.83333 * x ^ 2 + 17.8333 * x - 10.0000 The Lagrange basis polynomial: p(x) = 0.250000 * x ^ 4 - 3.00000 * x ^ 3 + 12.2500 * x ^ 2 - 19.5000 * x + 10.0000 The Lagrange basis polynomial: p(x) = - 0.166667 * x ^ 4 + 1.83333 * x ^ 3 - 6.83333 * x ^ 2 + 10.1667 * x - 5.00000 The Lagrange basis polynomial: p(x) = 0.416667E-01 * x ^ 4 - 0.416667 * x ^ 3 + 1.45833 * x ^ 2 - 2.08333 * x + 1.00000 TEST0865 RPOLY_LAGRANGE_COEF returns the coefficients for a Lagrange basis polynomial. RPOLY_DERIV computes derivatives of a polynomial. Abscissas: 1 1.00000 2 2.00000 3 3.00000 4 4.00000 5 5.00000 The Lagrange basis polynomial: p(x) = 0.416667E-01 * x ^ 4 - 0.583333 * x ^ 3 + 2.95833 * x ^ 2 - 6.41667 * x + 5.00000 The derivative of order 1 p(x) = 0.166667 * x ^ 3 - 1.75000 * x ^ 2 + 5.91667 * x - 6.41667 The derivative of order 2 p(x) = 0.500000 * x ^ 2 - 3.50000 * x + 5.91667 The derivative of order 3 p(x) = 1.00000 * x - 3.50000 The derivative of order 4 p(x) = 0.00000 The Lagrange basis polynomial: p(x) = - 0.166667 * x ^ 4 + 2.16667 * x ^ 3 - 9.83333 * x ^ 2 + 17.8333 * x - 10.0000 The derivative of order 1 p(x) = - 0.666667 * x ^ 3 + 6.50000 * x ^ 2 - 19.6667 * x + 17.8333 The derivative of order 2 p(x) = - 2.00000 * x ^ 2 + 13.0000 * x - 19.6667 The derivative of order 3 p(x) = - 4.00000 * x + 13.0000 The derivative of order 4 p(x) = 0.00000 The Lagrange basis polynomial: p(x) = 0.250000 * x ^ 4 - 3.00000 * x ^ 3 + 12.2500 * x ^ 2 - 19.5000 * x + 10.0000 The derivative of order 1 p(x) = 1.00000 * x ^ 3 - 9.00000 * x ^ 2 + 24.5000 * x - 19.5000 The derivative of order 2 p(x) = 3.00000 * x ^ 2 - 18.0000 * x + 24.5000 The derivative of order 3 p(x) = 6.00000 * x - 18.0000 The derivative of order 4 p(x) = 0.00000 The Lagrange basis polynomial: p(x) = - 0.166667 * x ^ 4 + 1.83333 * x ^ 3 - 6.83333 * x ^ 2 + 10.1667 * x - 5.00000 The derivative of order 1 p(x) = - 0.666667 * x ^ 3 + 5.50000 * x ^ 2 - 13.6667 * x + 10.1667 The derivative of order 2 p(x) = - 2.00000 * x ^ 2 + 11.0000 * x - 13.6667 The derivative of order 3 p(x) = - 4.00000 * x + 11.0000 The derivative of order 4 p(x) = 0.00000 The Lagrange basis polynomial: p(x) = 0.416667E-01 * x ^ 4 - 0.416667 * x ^ 3 + 1.45833 * x ^ 2 - 2.08333 * x + 1.00000 The derivative of order 1 p(x) = 0.166667 * x ^ 3 - 1.25000 * x ^ 2 + 2.91667 * x - 2.08333 The derivative of order 2 p(x) = 0.500000 * x ^ 2 - 2.50000 * x + 2.91667 The derivative of order 3 p(x) = 1.00000 * x - 2.50000 The derivative of order 4 p(x) = 0.00000 TEST087 RPOLY_LAGRANGE_0 evaluates the Lagrange factor W(X) at a point. RPOLY_LAGRANGE_1 evaluates the Lagrange factor W'(X) at a point. RPOLY_LAGRANGE_2 evaluates the Lagrange factor W"(X) at a point. The number of data points is 5 Abscissas: 1 0.00000 2 1.00000 3 2.00000 4 3.00000 5 4.00000 X W(X) W'(X) W"(X) 0.000 0.000 24.00 -100.0 0.2222 3.224 6.536 -59.04 0.4444 3.490 -3.020 -28.61 0.6667 2.305 -6.864 -7.407 0.8889 0.7208 -6.898 5.898 1.111 -0.5988 -4.730 12.62 1.333 -1.317 -1.679 14.07 1.556 -1.356 1.232 11.58 1.778 -0.8346 3.271 6.447 2.000 0.000 4.000 0.000 2.222 0.8346 3.271 -6.447 2.444 1.356 1.232 -11.58 2.667 1.317 -1.679 -14.07 2.889 0.5988 -4.730 -12.62 3.111 -0.7208 -6.898 -5.898 3.333 -2.305 -6.864 7.407 3.556 -3.490 -3.020 28.61 3.778 -3.224 6.536 59.04 4.000 0.000 24.00 100.0 TEST088 RPOLY_LAGRANGE_VAL evaluates a Lagrange interpolating polynomial at a point. Number of data points = 5 Abscissas: 1 0.00000 2 1.00000 3 2.00000 4 3.00000 5 4.00000 Here are the values of the functions at several points: X L1 L2 L3 L4 L5 0.000 1.000 0.000 0.000 0.000 0.000 0.5000 0.2734 1.094 -0.5469 0.2188 -0.3906E-01 1.000 0.000 1.000 0.000 0.000 0.000 1.500 -0.3906E-01 0.4688 0.7031 -0.1563 0.2344E-01 2.000 0.000 0.000 1.000 0.000 0.000 2.500 0.2344E-01 -0.1563 0.7031 0.4688 -0.3906E-01 3.000 0.000 0.000 0.000 1.000 0.000 3.500 -0.3906E-01 0.2188 -0.5469 1.094 0.2734 4.000 0.000 0.000 0.000 0.000 1.000 And the derivatives: X L'1 L'2 L'3 L'4 L'5 0.000 -2.083 4.000 -3.000 1.333 -0.2500 0.5000 -0.9167 0.7083 0.3750 -0.2083 0.4167E-01 1.000 -0.2500 -0.8333 1.500 -0.5000 0.8333E-01 1.500 0.4167E-01 -1.125 1.125 -0.4167E-01 0.000 2.000 0.8333E-01 -0.6667 0.000 0.6667 -0.8333E-01 2.500 0.000 0.4167E-01 -1.125 1.125 -0.4167E-01 3.000 -0.8333E-01 0.5000 -1.500 0.8333 0.2500 3.500 -0.4167E-01 0.2083 -0.3750 -0.7083 0.9167 4.000 0.2500 -1.333 3.000 -4.000 2.083 TEST089 RPOLY_LS_SET sets a least squares polynomial, RPOLY_LS_VAL evaluates it. X, F(X), P(X), Error K = 1 -1.00000 0.370000 1.19429 0.824286 -0.900000 0.410000 1.19429 0.784286 -0.800000 0.450000 1.19429 0.744286 -0.700000 0.500000 1.19429 0.694286 -0.600000 0.550000 1.19429 0.644286 -0.500000 0.610000 1.19429 0.584286 -0.400000 0.670000 1.19429 0.524286 -0.300000 0.740000 1.19429 0.454286 -0.200000 0.820000 1.19429 0.374286 -0.100000 0.900000 1.19429 0.294286 0.00000 1.00000 1.19429 0.194286 0.100000 1.11000 1.19429 0.842857E-01 0.200000 1.22000 1.19429 -0.257143E-01 0.300000 1.35000 1.19429 -0.155714 0.400000 1.49000 1.19429 -0.295714 0.500000 1.65000 1.19429 -0.455714 0.600000 1.82000 1.19429 -0.625714 0.700000 2.01000 1.19429 -0.815714 0.800000 2.23000 1.19429 -1.03571 0.900000 2.46000 1.19429 -1.26571 1.00000 2.72000 1.19429 -1.52571 K = 2 -1.00000 0.370000 0.812988E-01 -0.288701 -0.900000 0.410000 0.192598 -0.217402 -0.800000 0.450000 0.303896 -0.146104 -0.700000 0.500000 0.415195 -0.848051E-01 -0.600000 0.550000 0.526494 -0.235065E-01 -0.500000 0.610000 0.637792 0.277923E-01 -0.400000 0.670000 0.749091 0.790910E-01 -0.300000 0.740000 0.860390 0.120390 -0.200000 0.820000 0.971688 0.151688 -0.100000 0.900000 1.08299 0.182987 0.00000 1.00000 1.19429 0.194286 0.100000 1.11000 1.30558 0.195584 0.200000 1.22000 1.41688 0.196883 0.300000 1.35000 1.52818 0.178182 0.400000 1.49000 1.63948 0.149480 0.500000 1.65000 1.75078 0.100779 0.600000 1.82000 1.86208 0.420779E-01 0.700000 2.01000 1.97338 -0.366234E-01 0.800000 2.23000 2.08468 -0.145325 0.900000 2.46000 2.19597 -0.264026 1.00000 2.72000 2.30727 -0.412727 K = 3 -1.00000 0.370000 0.425003 0.550028E-01 -0.900000 0.410000 0.433190 0.231903E-01 -0.800000 0.450000 0.452232 0.223160E-02 -0.700000 0.500000 0.482127 -0.178733E-01 -0.600000 0.550000 0.522876 -0.271243E-01 -0.500000 0.610000 0.574478 -0.355216E-01 -0.400000 0.670000 0.636935 -0.330651E-01 -0.300000 0.740000 0.710245 -0.297548E-01 -0.200000 0.820000 0.794409 -0.255905E-01 -0.100000 0.900000 0.889427 -0.105726E-01 0.00000 1.00000 0.995299 -0.470078E-02 0.100000 1.11000 1.11202 0.202477E-02 0.200000 1.22000 1.23960 0.196042E-01 0.300000 1.35000 1.37804 0.280373E-01 0.400000 1.49000 1.52732 0.373244E-01 0.500000 1.65000 1.68747 0.374652E-01 0.600000 1.82000 1.85846 0.384599E-01 0.700000 2.01000 2.04031 0.303085E-01 0.800000 2.23000 2.23301 0.301051E-02 0.900000 2.46000 2.43657 -0.234332E-01 1.00000 2.72000 2.65098 -0.690234E-01 K = 4 -1.00000 0.370000 0.363870 -0.613022E-02 -0.900000 0.410000 0.408737 -0.126290E-02 -0.800000 0.450000 0.454806 0.480568E-02 -0.700000 0.500000 0.503148 0.314790E-02 -0.600000 0.550000 0.554836 0.483638E-02 -0.500000 0.610000 0.610944 0.943661E-03 -0.400000 0.670000 0.672542 0.254220E-02 -0.300000 0.740000 0.740705 0.704527E-03 -0.200000 0.820000 0.816503 -0.349683E-02 -0.100000 0.900000 0.901011 0.101054E-02 0.00000 1.00000 0.995299 -0.470078E-02 0.100000 1.11000 1.10044 -0.955832E-02 0.200000 1.22000 1.21751 -0.248945E-02 0.300000 1.35000 1.34758 -0.242186E-02 0.400000 1.49000 1.49172 0.171709E-02 0.500000 1.65000 1.65100 0.100005E-02 0.600000 1.82000 1.82650 0.649929E-02 0.700000 2.01000 2.01929 0.928736E-02 0.800000 2.23000 2.23044 0.436544E-03 0.900000 2.46000 2.46102 0.101995E-02 1.00000 2.72000 2.71211 -0.789022E-02 TEST090 RPOLY_LS_SET sets a least squares polynomial, RPOLY_LS_VAL2 evaluates it. X, F(X), P(X), FP(X), PP(X) K = 1 -1.00000 -4.00000 -5.63333 -3.00000 0.00000 -0.900000 -4.29000 -5.63333 -2.80000 0.00000 -0.800000 -4.56000 -5.63333 -2.60000 0.00000 -0.700000 -4.81000 -5.63333 -2.40000 0.00000 -0.600000 -5.04000 -5.63333 -2.20000 0.00000 -0.500000 -5.25000 -5.63333 -2.00000 0.00000 -0.400000 -5.44000 -5.63333 -1.80000 0.00000 -0.300000 -5.61000 -5.63333 -1.60000 0.00000 -0.200000 -5.76000 -5.63333 -1.40000 0.00000 -0.100000 -5.89000 -5.63333 -1.20000 0.00000 0.00000 -6.00000 -5.63333 -1.00000 0.00000 0.100000 -6.09000 -5.63333 -0.800000 0.00000 0.200000 -6.16000 -5.63333 -0.600000 0.00000 0.300000 -6.21000 -5.63333 -0.400000 0.00000 0.400000 -6.24000 -5.63333 -0.200000 0.00000 0.500000 -6.25000 -5.63333 0.00000 0.00000 0.600000 -6.24000 -5.63333 0.200000 0.00000 0.700000 -6.21000 -5.63333 0.400000 0.00000 0.800000 -6.16000 -5.63333 0.600000 0.00000 0.900000 -6.09000 -5.63333 0.800000 0.00000 1.00000 -6.00000 -5.63333 1.00000 0.00000 K = 2 -1.00000 -4.00000 -4.63333 -3.00000 -0.999999 -0.900000 -4.29000 -4.73333 -2.80000 -0.999999 -0.800000 -4.56000 -4.83333 -2.60000 -0.999999 -0.700000 -4.81000 -4.93333 -2.40000 -0.999999 -0.600000 -5.04000 -5.03333 -2.20000 -0.999999 -0.500000 -5.25000 -5.13333 -2.00000 -0.999999 -0.400000 -5.44000 -5.23333 -1.80000 -0.999999 -0.300000 -5.61000 -5.33333 -1.60000 -0.999999 -0.200000 -5.76000 -5.43333 -1.40000 -0.999999 -0.100000 -5.89000 -5.53333 -1.20000 -0.999999 0.00000 -6.00000 -5.63333 -1.00000 -0.999999 0.100000 -6.09000 -5.73333 -0.800000 -0.999999 0.200000 -6.16000 -5.83333 -0.600000 -0.999999 0.300000 -6.21000 -5.93333 -0.400000 -0.999999 0.400000 -6.24000 -6.03333 -0.200000 -0.999999 0.500000 -6.25000 -6.13333 0.00000 -0.999999 0.600000 -6.24000 -6.23333 0.200000 -0.999999 0.700000 -6.21000 -6.33333 0.400000 -0.999999 0.800000 -6.16000 -6.43333 0.600000 -0.999999 0.900000 -6.09000 -6.53333 0.800000 -0.999999 1.00000 -6.00000 -6.63333 1.00000 -0.999999 K = 3 -1.00000 -4.00000 -4.00000 -3.00000 -3.00000 -0.900000 -4.29000 -4.29000 -2.80000 -2.80000 -0.800000 -4.56000 -4.56000 -2.60000 -2.60000 -0.700000 -4.81000 -4.81000 -2.40000 -2.40000 -0.600000 -5.04000 -5.04000 -2.20000 -2.20000 -0.500000 -5.25000 -5.25000 -2.00000 -2.00000 -0.400000 -5.44000 -5.44000 -1.80000 -1.80000 -0.300000 -5.61000 -5.61000 -1.60000 -1.60000 -0.200000 -5.76000 -5.76000 -1.40000 -1.40000 -0.100000 -5.89000 -5.89000 -1.20000 -1.20000 0.00000 -6.00000 -6.00000 -1.00000 -0.999999 0.100000 -6.09000 -6.09000 -0.800000 -0.799999 0.200000 -6.16000 -6.16000 -0.600000 -0.599999 0.300000 -6.21000 -6.21000 -0.400000 -0.399999 0.400000 -6.24000 -6.24000 -0.200000 -0.199999 0.500000 -6.25000 -6.25000 0.00000 0.107288E-05 0.600000 -6.24000 -6.24000 0.200000 0.200001 0.700000 -6.21000 -6.21000 0.400000 0.400001 0.800000 -6.16000 -6.16000 0.600000 0.600001 0.900000 -6.09000 -6.09000 0.800000 0.800002 1.00000 -6.00000 -6.00000 1.00000 1.00000 K = 4 -1.00000 -4.00000 -4.00000 -3.00000 -3.00000 -0.900000 -4.29000 -4.29000 -2.80000 -2.80000 -0.800000 -4.56000 -4.56000 -2.60000 -2.60000 -0.700000 -4.81000 -4.81000 -2.40000 -2.40000 -0.600000 -5.04000 -5.04000 -2.20000 -2.20000 -0.500000 -5.25000 -5.25000 -2.00000 -2.00000 -0.400000 -5.44000 -5.44000 -1.80000 -1.80000 -0.300000 -5.61000 -5.61000 -1.60000 -1.60000 -0.200000 -5.76000 -5.76000 -1.40000 -1.40000 -0.100000 -5.89000 -5.89000 -1.20000 -1.20000 0.00000 -6.00000 -6.00000 -1.00000 -1.00000 0.100000 -6.09000 -6.09000 -0.800000 -0.800000 0.200000 -6.16000 -6.16000 -0.600000 -0.599999 0.300000 -6.21000 -6.21000 -0.400000 -0.399999 0.400000 -6.24000 -6.24000 -0.200000 -0.199999 0.500000 -6.25000 -6.25000 0.00000 0.117098E-05 0.600000 -6.24000 -6.24000 0.200000 0.200001 0.700000 -6.21000 -6.21000 0.400000 0.400002 0.800000 -6.16000 -6.16000 0.600000 0.600002 0.900000 -6.09000 -6.09000 0.800000 0.800002 1.00000 -6.00000 -6.00000 1.00000 1.00000 TEST091 RPOLY_VAL_HORNER evaluates a polynomial at a point, using Horner's method. The polynomial: p(x) = 1.00000 * x ^ 4 - 10.0000 * x ^ 3 + 35.0000 * x ^ 2 - 50.0000 * x + 24.0000 X, P(X) 0.00000 24.0000 0.333333 10.8642 0.666667 3.45679 1.00000 0.00000 1.33333 -0.987656 1.66667 -0.691359 2.00000 0.00000 2.33333 0.493820 2.66667 0.493835 3.00000 0.00000 3.33333 -0.691378 3.66667 -0.987644 4.00000 0.00000 4.33333 3.45680 4.66667 10.8642 5.00000 24.0000 TEST092 RPOLY2_EX finds the extreme value of a parabola determined by three points. RPOLY2_EX2 finds the extreme value of a parabola determined by three points. Parabolic coefficients A, B, C = 2.00000 -4.00000 10.0000 Point 1 : ( 1.00000 , 8.00000 ) Point 2 : ( 2.00000 , 10.0000 ) Point 3 : ( 3.00000 , 16.0000 ) RPOLY2_EX returns XMIN, YMIN = 1.00000 8.00000 RPOLY2_EX2 returns XMIN, YMIN = 1.00000 8.00000 and A, B, C = 2.00000 -4.00000 10.0000 TEST093 RPOLY2_VAL evaluates a parabola given 3 data points. Our parabola will be 2*x**2 + 3 * x + 1. Case 1: 3 distinct data points: -1.00000 0.00000 1.00000 6.00000 3.00000 28.0000 Sampled data: X, Y, Y', Y" 0.00000 1.00000 3.00000 4.00000 1.00000 6.00000 7.00000 4.00000 2.00000 15.0000 11.0000 4.00000 3.00000 28.0000 15.0000 4.00000 Case 2: X1=X2, X3 distinct: -1.00000 0.00000 -1.00000 -1.00000 3.00000 28.0000 Sampled data: X, Y, Y', Y" 0.00000 1.00000 3.00000 4.00000 1.00000 6.00000 7.00000 4.00000 2.00000 15.0000 11.0000 4.00000 3.00000 28.0000 15.0000 4.00000 Case 3: X1=X2=X3: -1.00000 0.00000 -1.00000 -1.00000 -1.00000 4.00000 Sampled data: X, Y, Y', Y" 0.00000 1.00000 3.00000 4.00000 1.00000 6.00000 7.00000 4.00000 2.00000 15.0000 11.0000 4.00000 3.00000 28.0000 15.0000 4.00000 TEST094 RPOLY2_VAL2 evaluates parabolas through 3 points in a table Our data tables will actually be parabolas: A: 2*x**2 + 3 * x + 1. B: 4*x**2 - 2 * x + 5. 1 2.00000 15.0000 17.0000 2 4.00000 45.0000 61.0000 3 6.00000 91.0000 137.000 4 8.00000 153.000 245.000 5 10.0000 231.000 385.000 Interpolated data: LEFT, X, Y1, Y2 1 1.00000 6.00000 7.00000 2 3.00000 28.0000 35.0000 3 5.00000 66.0000 95.0000 3 7.00000 120.000 187.000 3 9.00000 190.000 311.000 TEST095 RPOLY2_ROOT finds quadratic equation roots. A B C R1 R2 2.0 -2.0 -24.0 4.00000 0.00000 -3.00000 0.00000 1.0 -20.0 100.0 10.0000 0.00000 10.0000 0.00000 1.0 -2.0 10.0 1.00000 3.00000 1.00000 -3.00000 TEST096 RPOLY3_ROOT finds roots of cubic equations. Polynomial coefficients A, B, C, D: 1.00000 -6.00000 11.0000 -6.00000 Roots: 1.00000 0.00000 3.00000 0.00000 2.00000 0.00000 Polynomial coefficients A, B, C, D: 8.00000 -36.0000 54.0000 -27.0000 Roots: 1.50000 0.00000 1.50000 0.00000 1.50000 0.00000 Polynomial coefficients A, B, C, D: 1.00000 -5.00000 8.00000 -4.00000 Roots: 1.00000 0.00000 2.00000 0.00000 2.00000 0.00000 Polynomial coefficients A, B, C, D: 1.00000 -8.00000 25.0000 -26.0000 Roots: 2.00000 0.00000 3.00000 2.00000 3.00000 -2.00000 TEST097 RPOLY4_ROOT finds roots of quartic equations. A = 1.00000 B = -10.0000 C = 35.0000 D = -50.0000 E = 24.0000 Roots: 4.00000 0.00000 1.00000 0.00000 3.00000 0.00000 2.00000 0.00000 A = 1.00000 B = -5.00000 C = 1.00000 D = 21.0000 E = -18.0000 Roots: 3.00000 0.00000 3.00000 0.00000 1.00000 0.00000 -2.00000 0.00000 A = 1.00000 B = -22.0000 C = 141.000 D = -220.000 E = 100.000 Roots: 10.0000 0.00000 10.0000 0.00000 1.00000 0.00000 1.00000 0.00000 A = 1.00000 B = -16.0000 C = 72.0000 D = -128.000 E = 80.0000 Roots: 10.0000 0.00000 2.00000 0.00000 2.00000 0.00000 2.00000 0.00000 A = 1.00000 B = -20.0000 C = 150.000 D = -500.000 E = 625.000 Roots: 5.00000 0.00000 5.00000 0.00000 5.00000 0.00000 5.00000 0.00000 A = 1.00000 B = 2.00000 C = 1.00000 D = 8.00000 E = -12.0000 Roots: -0.298023E-07 2.00000 -0.298023E-07 -2.00000 1.00000 0.00000 -3.00000 0.00000 A = 1.00000 B = 0.00000 C = 13.0000 D = 0.00000 E = 36.0000 Roots: 0.00000 3.00000 0.00000 2.00000 0.00000 -2.00000 0.00000 -3.00000 TEST098 For a real matrix regarded as rows: RROW_MAX computes maximums; RROW_MEAN computes means; RROW_MIN computes minimums; RROW_SUM computes sums; RROW_SWAP swaps two; RROW_VARIANCE computes variances; The original matrix: 1 2 3 4 1 1.000000 2.000000 3.000000 4.000000 2 5.000000 6.000000 7.000000 8.000000 3 9.000000 10.000000 11.000000 12.000000 Maximum, minimum, sum, mean, variance: 1 4.0000 1.0000 10.0000 2.5000 1.6667 2 8.0000 5.0000 26.0000 6.5000 1.6667 3 12.0000 9.0000 42.0000 10.5000 1.6667 Swap rows 1 and 3: The modified matrix: 1 2 3 4 1 9.000000 10.000000 11.000000 12.000000 2 5.000000 6.000000 7.000000 8.000000 3 1.000000 2.000000 3.000000 4.000000 TEST0985 RROW_TO_RVEC converts an array of rows into a vector. The array of rows: 1 2 3 4 1 11.000000 12.000000 13.000000 14.000000 2 21.000000 22.000000 23.000000 24.000000 3 31.000000 32.000000 33.000000 34.000000 The resulting vector of rows: 1 11.0000 2 12.0000 3 13.0000 4 14.0000 5 21.0000 6 22.0000 7 23.0000 8 24.0000 9 31.0000 10 32.0000 11 33.0000 12 34.0000 TEST099 For a real vector: RVEC_AMAX: maximum magnitude entry; RVEC_AMIN: minimum magnitude entry. RVEC_MAX: maximum entry; RVEC_MEAN: mean value; RVEC_MEDIAN: median value; RVEC_MIN: minimum entry. RVEC_NORM_L1: L1 norm. RVEC_NORM_L2: L2 norm. RVEC_NORM_LI: L-infinity norm. RVEC_UNIT_SUM: make unit sum; Input vector: 1 -7.49586 2 -1.41443 3 -2.98397 4 -5.64039 5 -2.99609 6 -4.98063 7 -8.89896 8 0.855381 9 0.675139 10 -3.09856 Maximum: 0.855381 Maximum index: 8 Minimum: -8.89896 Minimum index: 7 Maximum absolute: 8.89896 Maximum absolute index: 7 Minimum absolute: 0.675139 Minimum absolute index: 9 Mean: -3.59784 Median: -3.09856 L1 norm: 39.0394 L2 norm: 14.9221 L-Infinity norm: 8.89896 After calling RVEC_UNIT_SUM: 1 0.208344 2 0.138434 3 0.247342 4 0.156772 5 0.861228E-01 6 0.832748E-01 7 0.829378E-01 8 -0.237749E-01 9 -0.187652E-01 10 0.393134E-01 TEST100 RVEC_BIN computes bins for a real vector. The vector to be binned: 1 9.88458 2 8.39159 3 6.62941 4 0.615121 5 6.16795 6 8.12982 7 7.85097 8 10.4800 9 5.31621 10 5.76784 11 -1.72630 12 1.72277 13 0.413491 14 -0.606221E-01 15 9.92685 16 -1.26525 17 5.69231 18 0.776301 19 0.924015 20 8.77706 21 6.46359 22 0.684746 23 3.02861 24 9.92599 25 1.26937 Number of bins is 5 Bin minimum is 0.00000 Bin maximum is 10.0000 Lower Limit Upper Limit Count 0.0000 0.0000 3 0.0000 2.0000 7 2.0000 4.0000 1 4.0000 6.0000 3 6.0000 8.0000 4 8.0000 10.0000 6 10.0000 1 TEST1005 RVEC_BIN_EVEN constructs evenly spaced bins and assigns each element of a real array to a bin. RVEC_BINNED_REORDER can reorder the array to correspond to the bin ordering. RVEC_BINNED_SORT can sort the array once it has been reordered. The bins are equally spaced between BIN_MIN and BIN_MAX, with two extra bins, for things less than BIN_MIN, or greater than BIN_MAX. BIN_MIN = 10.0000 BIN_MAX = 20.0000 Total number of bins = 7 The data vector A to be binned: 1 19.2081 2 15.0946 3 16.7862 4 12.6251 5 11.6203 6 15.4989 7 22.3740 8 20.9905 9 9.97871 10 8.04441 11 11.6012 12 13.6644 13 10.1185 14 10.2196 15 20.8551 16 14.8009 17 22.7612 18 16.7592 19 19.1814 20 16.8407 21 12.7649 22 16.2909 23 12.8406 24 9.72604 25 18.0799 26 15.3762 27 16.1679 28 21.7504 29 22.3215 30 14.6782 The BIN_START array: 1 9 2 5 3 4 4 2 5 3 6 1 7 7 The BIN_LAST array: 1 24 2 14 3 23 4 30 5 27 6 25 7 29 The BIN_NEXT array: 1 19 2 6 3 18 4 12 5 11 6 16 7 8 8 15 9 10 10 24 11 13 12 21 13 14 14 0 15 17 16 26 17 28 18 20 19 25 20 22 21 23 22 27 23 0 24 0 25 0 26 30 27 0 28 29 29 0 30 0 Contents of bin number 1 1 9 9.97871 2 10 8.04441 3 24 9.72604 Contents of bin number 2 1 5 11.6203 2 11 11.6012 3 13 10.1185 4 14 10.2196 Contents of bin number 3 1 4 12.6251 2 12 13.6644 3 21 12.7649 4 23 12.8406 Contents of bin number 4 1 2 15.0946 2 6 15.4989 3 16 14.8009 4 26 15.3762 5 30 14.6782 Contents of bin number 5 1 3 16.7862 2 18 16.7592 3 20 16.8407 4 22 16.2909 5 27 16.1679 Contents of bin number 6 1 1 19.2081 2 19 19.1814 3 25 18.0799 Contents of bin number 7 1 7 22.3740 2 8 20.9905 3 15 20.8551 4 17 22.7612 5 28 21.7504 6 29 22.3215 Call RVEC_BINNED_REORDER to reorder the array. The data vector A: 1 9.97871 2 8.04441 3 9.72604 4 11.6203 5 11.6012 6 10.1185 7 10.2196 8 12.6251 9 13.6644 10 12.7649 11 12.8406 12 15.0946 13 15.4989 14 14.8009 15 15.3762 16 14.6782 17 16.7862 18 16.7592 19 16.8407 20 16.2909 21 16.1679 22 19.2081 23 19.1814 24 18.0799 25 22.3740 26 20.9905 27 20.8551 28 22.7612 29 21.7504 30 22.3215 The BIN_START array: 1 1 2 4 3 8 4 12 5 17 6 22 7 25 The BIN_LAST array: 1 3 2 7 3 11 4 16 5 21 6 24 7 30 The BIN_NEXT array: 1 2 2 3 3 0 4 5 5 6 6 7 7 0 8 9 9 10 10 11 11 0 12 13 13 14 14 15 15 16 16 0 17 18 18 19 19 20 20 21 21 0 22 23 23 24 24 0 25 26 26 27 27 28 28 29 29 30 30 0 The sorted data vector A: 1 8.04441 2 9.72604 3 9.97871 4 10.1185 5 10.2196 6 11.6012 7 11.6203 8 12.6251 9 12.7649 10 12.8406 11 13.6644 12 14.6782 13 14.8009 14 15.0946 15 15.3762 16 15.4989 17 16.1679 18 16.2909 19 16.7592 20 16.7862 21 16.8407 22 18.0799 23 19.1814 24 19.2081 25 20.8551 26 20.9905 27 21.7504 28 22.3215 29 22.3740 30 22.7612 TEST101 RVEC_BRACKET finds a pair of entries in a sorted real array which bracket a value. Sorted array: 1 1.00000 2 2.00000 3 3.00000 4 4.00000 5 5.00000 6 5.00000 7 7.00000 8 8.00000 9 9.00000 10 10.0000 LEFT RIGHT X(LEFT) XVAL X(RIGHT) 1 2 1.00000 -10.0000 2.00000 1 2 1.00000 1.00000 2.00000 4 5 4.00000 4.50000 5.00000 6 7 5.00000 5.00000 7.00000 9 10 9.00000 10.0000 10.0000 9 10 9.00000 12.0000 10.0000 TEST102 RVEC_BRACKET2 finds a pair of entries in a sorted real array which bracket a value. Sorted array: 1 1.00000 2 2.00000 3 3.00000 4 4.00000 5 5.00000 6 5.00000 7 7.00000 8 8.00000 9 9.00000 10 10.0000 Search for XVAL = -10.0000 Start = 5 Left = 1 Right = 2 X(LEFT)= 1.00000 X(RIGHT) = 2.00000 Search for XVAL = 1.00000 Start = 1 Left = 1 Right = 1 X(LEFT)= 1.00000 X(RIGHT) = 1.00000 Search for XVAL = 4.50000 Start = 1 Left = 4 Right = 5 X(LEFT)= 4.00000 X(RIGHT) = 5.00000 Search for XVAL = 5.00000 Start = 4 Left = 5 Right = 5 X(LEFT)= 5.00000 X(RIGHT) = 5.00000 Search for XVAL = 10.0000 Start = 5 Left = 9 Right = 10 X(LEFT)= 9.00000 X(RIGHT) = 10.0000 Search for XVAL = 12.0000 Start = 9 Left = 10 Right = -1 X(LEFT)= 10.0000 TEST103 RVEC_BRACKET3 finds a pair of entries in a sorted real array which bracket a value. Sorted array: 1 1.00000 2 2.00000 3 3.00000 4 4.00000 5 5.00000 6 5.00000 7 7.00000 8 8.00000 9 9.00000 10 10.0000 Search for XVAL = -10.0000 Starting guess for interval is = 5 Nearest interval: X[ 1 ]= 1.00000 X[ 2 ]= 2.00000 Search for XVAL = 1.00000 Starting guess for interval is = 1 Nearest interval: X[ 1 ]= 1.00000 X[ 2 ]= 2.00000 Search for XVAL = 4.50000 Starting guess for interval is = 1 Nearest interval: X[ 4 ]= 4.00000 X[ 5 ]= 5.00000 Search for XVAL = 5.00000 Starting guess for interval is = 4 Nearest interval: X[ 4 ]= 4.00000 X[ 5 ]= 5.00000 Search for XVAL = 10.0000 Starting guess for interval is = 4 Nearest interval: X[ 9 ]= 9.00000 X[ 10 ]= 10.0000 Search for XVAL = 12.0000 Starting guess for interval is = 9 Nearest interval: X[ 9 ]= 9.00000 X[ 10 ]= 10.0000 TEST1035 RVEC_CONVOLVE_CIRC computes the circular convolution of two vectors. The factor X: 1 1.00000 2 2.00000 3 3.00000 4 4.00000 The factor Y: 1 1.00000 2 2.00000 3 4.00000 4 8.00000 The circular convolution z = xCCy: 1 37.0000 2 44.0000 3 43.0000 4 26.0000 Correct answer: 1 37.0000 2 44.0000 3 43.0000 4 26.0000 TEST104 RVEC_EVEN computes N evenly spaced values between XLO and XHI. XLO = 0.00000 XHI = 99.0000 while N = 10 Resulting array: 1 0.00000 2 11.0000 3 22.0000 4 33.0000 5 44.0000 6 55.0000 7 66.0000 8 77.0000 9 88.0000 10 99.0000 TEST105 RVEC_EVEN2 interpolates a specified number of points pairs of values in a vector. Input data: 0.00000 4 1.00000 3 5.00000 5 2.00000 0 0.00000 Resulting vector: * 0.00000 0.200000 0.400000 0.600000 0.800000 * 1.00000 2.00000 3.00000 4.00000 * 5.00000 4.50000 4.00000 3.50000 3.00000 2.50000 * 2.00000 * 0.00000 TEST106 RVEC_EVEN3 tries to evenly interpolate new data between old values. Original vector: 1 0.00000 2 5.10000 3 7.00000 4 10.0000 New vector: 1 0.00000 2 1.02000 3 2.04000 4 3.06000 5 4.08000 6 5.10000 7 5.73333 8 6.36667 9 7.00000 10 8.00000 11 9.00000 12 10.0000 TEST1065 RVEC_EXPAND_LINEAR linearly interpolates new data between old values. Original vector: 1 16.0000 2 4.00000 3 0.00000 4 4.00000 5 16.0000 6 36.0000 Expansion factor is 3 Fattened vector: 1 16.0000 2 13.0000 3 10.0000 4 7.00000 5 4.00000 6 3.00000 7 2.00000 8 1.00000 9 0.00000 10 1.00000 11 2.00000 12 3.00000 13 4.00000 14 7.00000 15 10.0000 16 13.0000 17 16.0000 18 21.0000 19 26.0000 20 31.0000 21 36.0000 TEST107 RVEC_FRAC: K-th smallest real vector entry; Array to search: 1 0.413623 2 0.587879 3 0.147635E-01 4 0.443522 5 0.828453 6 0.166669 7 0.790582E-01 8 0.461118 9 0.723311 10 0.798722 Fractile Value 1 0.147635E-01 6 0.461118 TEST1071 RVEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. RVEC_INDEX_SEARCH searches for an entry with a given value. Generate some random values: 10.00 17.00 0.00 10.00 12.00 10.00 10.00 12.00 11.00 7.00 5.00 8.00 10.00 15.00 11.00 2.00 9.00 12.00 10.00 2.00 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 3 10.00 0.00 2 10 17.00 2.00 3 7 0.00 5.00 4 6 12.00 7.00 5 8 11.00 8.00 6 11 7.00 9.00 7 1 5.00 10.00 8 5 8.00 11.00 9 4 15.00 12.00 10 9 2.00 15.00 11 2 9.00 17.00 Results of search for given XVAL: XVAL Less Equal More 0.00 0 1 2 1.00 1 0 2 2.00 1 2 3 3.00 2 0 3 4.00 2 0 3 5.00 2 3 4 6.00 3 0 4 7.00 3 4 5 8.00 4 5 6 9.00 5 6 7 10.00 6 7 8 11.00 7 8 9 12.00 8 9 10 13.00 9 0 10 14.00 9 0 10 15.00 9 10 11 16.00 10 0 11 17.00 10 11 12 18.00 11 0 12 19.00 11 0 12 20.00 11 0 12 TEST1072 RVEC_INDEX_INSERT inserts values into an index sorted array. RVEC_INDEX_DELETE_ALL deletes all copies of a particular value. RVEC_INDEX_DELETE_ONE deletes one copies of a particular value. RVEC_INDEX_DELETE_DUPES deletes duplicates. Generate some random values: 17.00 1.00 10.00 11.00 10.00 4.00 10.00 11.00 9.00 8.00 16.00 9.00 2.00 6.00 17.00 7.00 8.00 12.00 8.00 4.00 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 4 8.00 1.00 2 15 7.00 2.00 3 8 17.00 4.00 4 22 1.00 4.00 5 16 10.00 6.00 6 2 11.00 7.00 7 23 10.00 7.00 8 18 4.00 7.00 9 1 10.00 8.00 10 21 11.00 8.00 11 19 9.00 8.00 12 12 8.00 8.00 13 24 16.00 8.00 14 11 9.00 9.00 15 14 2.00 9.00 16 5 6.00 10.00 17 7 17.00 10.00 18 9 7.00 10.00 19 6 8.00 11.00 20 10 12.00 11.00 21 20 8.00 12.00 22 13 4.00 16.00 23 3 7.00 17.00 24 17 8.00 17.00 Call RVEC_INDEX_DELETE_ONE to delete one value equal to 8: Call RVEC_INDEX_DELETE_ALL to delete all values equal to 7: Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 3 8.00 1.00 2 13 17.00 2.00 3 7 1.00 4.00 4 19 10.00 4.00 5 14 11.00 6.00 6 1 10.00 8.00 7 18 4.00 8.00 8 16 10.00 8.00 9 20 11.00 8.00 10 10 9.00 9.00 11 12 16.00 9.00 12 4 9.00 10.00 13 6 2.00 10.00 14 8 6.00 10.00 15 5 17.00 11.00 16 9 8.00 11.00 17 17 12.00 12.00 18 11 8.00 16.00 19 2 4.00 17.00 20 15 8.00 17.00 Call RVEC_INDEX_DELETE_DUPES to delete duplicates: Indexed list of unique entries: I INDX(I) X(I) 1 1 1.00 2 2 2.00 3 3 4.00 4 4 6.00 5 5 8.00 6 6 9.00 7 7 10.00 8 8 11.00 9 9 12.00 10 10 16.00 11 11 17.00 TEST1073 RVEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. RVEC_INDEX_ORDER sorts an index sorted array. Generate some random values: 5.00 1.00 19.00 16.00 6.00 2.00 8.00 8.00 13.00 14.00 9.00 19.00 16.00 5.00 5.00 1.00 18.00 11.00 5.00 19.00 Indexed list of unique entries: I INDX(I) X(I) X(INDX(I)) 1 2 5.00 1.00 2 6 1.00 2.00 3 1 19.00 5.00 4 5 16.00 6.00 5 7 6.00 8.00 6 10 2.00 9.00 7 12 8.00 11.00 8 8 13.00 13.00 9 9 14.00 14.00 10 4 9.00 16.00 11 11 18.00 18.00 12 3 11.00 19.00 Now call RVEC_INDEX_ORDER to carry out the sorting: I X(I) 1 1.00 2 2.00 3 5.00 4 6.00 5 8.00 6 9.00 7 11.00 8 13.00 9 14.00 10 16.00 11 18.00 12 19.00 TEST108 For ascending order: RVEC_MERGE_A merges two sorted real arrays; RVEC_SEARCH_BINARY_A searches a sorted array; RVEC_SORT_HEAP_A sorts a real array. Sorted vector A: 1 0.417362E-01 2 0.133304 3 0.140255 4 0.330714 5 0.435357 6 0.502141 7 0.652508 8 0.695599 9 0.751226 10 0.841122 Sorted vector B: 1 0.103625 2 0.196614 3 0.235079 4 0.350535 5 0.478195 6 0.613536 7 0.626527 8 0.768425 9 0.953590 10 0.996970 Merged vector C: 1 0.417362E-01 2 0.103625 3 0.133304 4 0.140255 5 0.196614 6 0.235079 7 0.330714 8 0.350535 9 0.435357 10 0.478195 11 0.502141 12 0.613536 13 0.626527 14 0.652508 15 0.695599 16 0.751226 17 0.768425 18 0.841122 19 0.953590 20 0.996970 Search the array C for the value 0.417362E-01 SEARCH RESULT: The value occurs in index 1 TEST109 RVEC_ORDER_TYPE classifies a real vector as -1: no order 0: all equal; 1: ascending; 2: strictly ascending; 3: descending; 4: strictly descending. The following vector has order type -1 1 1.00000 2 3.00000 3 2.00000 4 4.00000 The following vector has order type 0 1 2.00000 2 2.00000 3 2.00000 4 2.00000 The following vector has order type 1 1 1.00000 2 2.00000 3 2.00000 4 4.00000 The following vector has order type 2 1 1.00000 2 2.00000 3 3.00000 4 4.00000 The following vector has order type 3 1 4.00000 2 4.00000 3 3.00000 4 1.00000 The following vector has order type 4 1 9.00000 2 7.00000 3 3.00000 4 0.00000 TEST110 RVEC_PERMUTE permutes a real vector in place. I, Perm(I), X(I) 1 2 1.00000 2 4 2.00000 3 5 3.00000 4 1 4.00000 5 3 5.00000 Permuted array: 1 2.00000 2 4.00000 3 5.00000 4 1.00000 5 3.00000 TEST1104 RVEC_POLARIZE decomposes a vector into components parallel and normal to a direction. Original vector: 1 1.00000 2 2.00000 3 3.00000 Direction vector: 1 3.00000 2 1.00000 3 -2.00000 Normal component: 1 1.21429 2 2.07143 3 2.85714 Parallel component: 1 -0.214286 2 -0.714286E-01 3 0.142857 Dot product of P and A_normal (should be 0) 0.00000 Cosine of angle between P and A_parallel (should be 1 or -1) -1.00000 Sum of components (should equal A): 1 1.00000 2 2.00000 3 3.00000 TEST1105 RVEC_RANDOM returns a random real vector with entries in a given range [ ALO, AHI ] For this problem: ALO = 10.0000 AHI = 20.0000 Initialize random numbers with SEED = 1973 15.3335 15.5882 19.4318 16.9413 14.5262 10.6287 12.9190 18.6431 12.4711 17.2741 Initialize random numbers with SEED = 123456789 11.9379 10.1245 16.0759 11.8250 15.4607 19.4644 18.1726 16.1471 12.4674 12.2612 Initialize random numbers with SEED = 1973 15.3335 15.5882 19.4318 16.9413 14.5262 10.6287 12.9190 18.6431 12.4711 17.2741 TEST111 RVEC_ROTATE rotates a real vector in place. Rotate entries 2 places to the right. Original array: 1 1.00000 2 2.00000 3 3.00000 4 4.00000 5 5.00000 Rotated array: 1 4.00000 2 5.00000 3 1.00000 4 2.00000 5 3.00000 TEST112 RVEC_REVERSE reverses a real vector. Original array: 1 1.00000 2 2.00000 3 3.00000 4 4.00000 5 5.00000 Reversed array: 1 5.00000 2 4.00000 3 3.00000 4 2.00000 5 1.00000 TEST113 RVEC_SORT_HEAP_A sorts a real vector. Original array: 1 13.4788 2 2.28721 3 2.78250 4 49.8660 5 28.5986 6 11.1266 7 37.5872 8 25.1433 9 28.0115 10 37.1036 11 12.0120 12 46.9053 13 23.9738 14 14.0758 15 9.01730 16 9.59008 17 11.0297 18 2.12667 19 7.98894 20 37.8946 Sorted array: 1 2.12667 2 2.28721 3 2.78250 4 7.98894 5 9.01730 6 9.59008 7 11.0297 8 11.1266 9 12.0120 10 13.4788 11 14.0758 12 23.9738 13 25.1433 14 28.0115 15 28.5986 16 37.1036 17 37.5872 18 37.8946 19 46.9053 20 49.8660 TEST114 RVEC_SORT_HEAP_A sorts a real array; RVEC_UNIQUE finds the unique entries in a sorted real array; RVEC_UNIQUE_COUNT counts the unique entries of a sorted real array; RVEC_UNIQUE_HIST makes a histogram. Unsorted array: 1 27.0000 2 4.00000 3 18.0000 4 17.0000 5 13.0000 6 3.00000 7 28.0000 8 27.0000 9 29.0000 10 3.00000 11 1.00000 12 22.0000 13 5.00000 14 6.00000 15 4.00000 16 27.0000 17 15.0000 18 25.0000 19 2.00000 20 14.0000 21 17.0000 22 14.0000 23 22.0000 24 10.0000 25 26.0000 26 17.0000 27 19.0000 28 8.00000 29 20.0000 30 27.0000 Unique entries 1 1.00000 2 2.00000 3 3.00000 4 4.00000 5 5.00000 6 6.00000 7 8.00000 8 10.0000 9 13.0000 10 14.0000 11 15.0000 12 17.0000 13 18.0000 14 19.0000 15 20.0000 16 22.0000 17 25.0000 18 26.0000 19 27.0000 20 28.0000 21 29.0000 RVEC_UNIQUE_COUNT counts 21 unique entries in A. RVEC_UNIQUE_HIST counts 21 unique entries. Value Multiplicity 1 1.00000 1 2 2.00000 1 3 3.00000 2 4 4.00000 2 5 5.00000 1 6 6.00000 1 7 8.00000 1 8 10.0000 1 9 13.0000 1 10 14.0000 2 11 15.0000 1 12 17.0000 3 13 18.0000 1 14 19.0000 1 15 20.0000 1 16 22.0000 2 17 25.0000 1 18 26.0000 1 19 27.0000 4 20 28.0000 1 21 29.0000 1 TEST115 RVEC_SORT_HEAP_INDEX_A creates an ascending sort index for a real array. RVEC_SORT_HEAP_INDEX_D creates a descending sort index for a real array. Unsorted array: 1 52.6884 2 7.42318 3 13.7456 4 11.9929 5 52.2676 6 38.2272 7 57.7649 8 47.7594 9 56.1921 10 22.5734 11 36.5538 12 42.7290 13 52.9271 14 46.1900 15 45.4576 16 50.7430 17 50.8522 18 3.30977 19 20.8434 20 52.4687 After indexed ascending sort: I, INDX(I), A(I) 1 18 52.6884 2 2 7.42318 3 4 13.7456 4 3 11.9929 5 19 52.2676 6 10 38.2272 7 11 57.7649 8 6 47.7594 9 12 56.1921 10 15 22.5734 11 14 36.5538 12 8 42.7290 13 16 52.9271 14 17 46.1900 15 5 45.4576 16 20 50.7430 17 1 50.8522 18 13 3.30977 19 9 20.8434 20 7 52.4687 Now use the index array to carry out the permutation implicitly. INDX(I), A(INDX(I)) 18 3.30977 2 7.42318 4 11.9929 3 13.7456 19 20.8434 10 22.5734 11 36.5538 6 38.2272 12 42.7290 15 45.4576 14 46.1900 8 47.7594 16 50.7430 17 50.8522 5 52.2676 20 52.4687 1 52.6884 13 52.9271 9 56.1921 7 57.7649 Call RVEC_PERMUTE to carry out the permutation explicitly. I, A(I) 1 3.30977 2 7.42318 3 11.9929 4 13.7456 5 20.8434 6 22.5734 7 36.5538 8 38.2272 9 42.7290 10 45.4576 11 46.1900 12 47.7594 13 50.7430 14 50.8522 15 52.2676 16 52.4687 17 52.6884 18 52.9271 19 56.1921 20 57.7649 After indexed descending sort: I, INDX(I), A(I) 1 20 3.30977 2 19 7.42318 3 18 11.9929 4 17 13.7456 5 16 20.8434 6 15 22.5734 7 14 36.5538 8 13 38.2272 9 12 42.7290 10 11 45.4576 11 10 46.1900 12 9 47.7594 13 8 50.7430 14 7 50.8522 15 6 52.2676 16 5 52.4687 17 4 52.6884 18 3 52.9271 19 2 56.1921 20 1 57.7649 Now use the index array to carry out the permutation implicitly. INDX(I), ARRAY(INDX(I)) 20 57.7649 19 56.1921 18 52.9271 17 52.6884 16 52.4687 15 52.2676 14 50.8522 13 50.7430 12 47.7594 11 46.1900 10 45.4576 9 42.7290 8 38.2272 7 36.5538 6 22.5734 5 20.8434 4 13.7456 3 11.9929 2 7.42318 1 3.30977 TEST1154 RVEC_SORT_INSERT_A ascending sorts a real array. Unsorted array: 1 4.96703 2 0.646237 3 31.8647 4 15.6164 5 23.5589 6 38.7463 7 33.8773 8 38.7364 9 31.7834 10 0.581707 11 19.4039 12 33.3283 13 31.1632 14 6.74172 15 25.9530 16 55.0650 17 17.9875 18 36.7114 19 50.5910 20 15.6974 Sorted array: 1 0.581707 2 0.646237 3 4.96703 4 6.74172 5 15.6164 6 15.6974 7 17.9875 8 19.4039 9 23.5589 10 25.9530 11 31.1632 12 31.7834 13 31.8647 14 33.3283 15 33.8773 16 36.7114 17 38.7364 18 38.7463 19 50.5910 20 55.0650 TEST1155 RVEC_SORT_INSERT_INDEX_A creates an ascending sort index for a real array. Unsorted array: 1 41.7047 2 18.4111 3 40.0922 4 36.5569 5 23.3296 6 50.4767 7 17.4215 8 17.5453 9 51.1624 10 14.0918 11 0.211097 12 48.3044 13 4.87522 14 0.767909 15 24.5489 16 9.29926 17 2.04419 18 37.1252 19 37.4055 20 31.8109 After indexed ascending sort: I, INDX(I), A(I) 1 11 41.7047 2 14 18.4111 3 17 40.0922 4 13 36.5569 5 16 23.3296 6 10 50.4767 7 7 17.4215 8 8 17.5453 9 2 51.1624 10 5 14.0918 11 15 0.211097 12 20 48.3044 13 4 4.87522 14 18 0.767909 15 19 24.5489 16 3 9.29926 17 1 2.04419 18 12 37.1252 19 6 37.4055 20 9 31.8109 Now use the index array to carry out the permutation implicitly. I, INDX(I), A(INDX(I)) 1 11 0.211097 2 14 0.767909 3 17 2.04419 4 13 4.87522 5 16 9.29926 6 10 14.0918 7 7 17.4215 8 8 17.5453 9 2 18.4111 10 5 23.3296 11 15 24.5489 12 20 31.8109 13 4 36.5569 14 18 37.1252 15 19 37.4055 16 3 40.0922 17 1 41.7047 18 12 48.3044 19 6 50.4767 20 9 51.1624 Call RVEC_PERMUTE to carry out the permutation explicitly. I, A(I) 1 0.211097 2 0.767909 3 2.04419 4 4.87522 5 9.29926 6 14.0918 7 17.4215 8 17.5453 9 18.4111 10 23.3296 11 24.5489 12 31.8109 13 36.5569 14 37.1252 15 37.4055 16 40.0922 17 41.7047 18 48.3044 19 50.4767 20 51.1624 TEST1156 RVEC_SORT_HEAP_MASK_A creates an ascending sort index for a masked real array. Unsorted array: 1 8.76642 2 8.39232 3 39.7012 4 27.6090 5 36.0031 6 57.0276 7 56.5348 8 34.8804 9 35.6908 10 7.99603 11 29.7635 12 49.2009 13 42.0792 14 41.4325 15 4.56126 16 28.8121 17 1.92144 18 47.3498 19 9.28771 20 57.2937 The mask array: 1 2 2 4 3 7 4 8 5 9 6 12 7 13 8 16 9 18 10 19 Masked vector printout: The masked unsorted array: 1 2 8.39232 2 4 27.6090 3 7 56.5348 4 8 34.8804 5 9 35.6908 6 12 49.2009 7 13 42.0792 8 16 28.8121 9 18 47.3498 10 19 9.28771 After masked indexed ascending sort: I, INDX(I), MASK(INDX(I)), A(MASK(INDX(I))) 1 1 2 8.39232 2 10 19 9.28771 3 2 4 27.6090 4 8 16 28.8121 5 4 8 34.8804 6 5 9 35.6908 7 7 13 42.0792 8 9 18 47.3498 9 6 12 49.2009 10 3 7 56.5348 Call IVEC_PERMUTE to carry out the index permutation explicitly on the MASK vector. The reordered mask array: 1 2 2 19 3 4 4 16 5 8 6 9 7 13 8 18 9 12 10 7 Masked vector printout: The reordered masked sorted array: 1 2 8.39232 2 19 9.28771 3 4 27.6090 4 16 28.8121 5 8 34.8804 6 9 35.6908 7 13 42.0792 8 18 47.3498 9 12 49.2009 10 7 56.5348 TEST116 RVEC_SPLIT_SORT splits a sorted vector into entries less than and greater than a splitting value. RVEC_SPLIT_UNSORT splits an unsorted vector in the same way. The sorted array: 1 0.500000 2 0.500000 3 0.500000 4 1.50000 5 1.50000 6 1.50000 7 1.50000 8 2.00000 9 2.00000 10 2.00000 11 2.00000 12 2.00000 13 2.50000 14 2.50000 15 3.00000 16 3.00000 17 3.00000 18 3.00000 19 3.50000 20 3.50000 21 4.00000 22 4.50000 23 4.50000 24 5.00000 25 5.00000 Splitting value is 2.75000 Lower index I_LT = 14 Upper index I_GT = 15 Now repeat test with RVEC_SPLIT_UNSORT. The shuffled array: 1 3.00000 2 1.50000 3 4.00000 4 4.50000 5 3.00000 6 2.00000 7 0.500000 8 5.00000 9 2.00000 10 1.50000 11 2.00000 12 2.50000 13 0.500000 14 3.50000 15 2.00000 16 3.00000 17 5.00000 18 1.50000 19 4.50000 20 2.00000 21 2.50000 22 1.50000 23 3.50000 24 0.500000 25 3.00000 The split array: 1 0.500000 2 1.50000 3 1.50000 4 2.50000 5 2.00000 6 2.00000 7 0.500000 8 1.50000 9 2.00000 10 1.50000 11 2.00000 12 2.50000 13 0.500000 14 2.00000 15 3.00000 16 5.00000 17 3.50000 18 4.50000 19 5.00000 20 3.00000 21 4.50000 22 3.50000 23 4.00000 24 3.00000 25 3.00000 Array entries <= SPLIT up to index 14 TEST1165 For a pair of real vectors: RVEC2_SORT_A ascending sorts; RVEC2_SORT_D descending sorts; RVEC2_UNIQUE counts unique entries. The pair of arrays: 1 1.41109 5.26108 2 2.31813 9.42696 3 1.41109 5.26108 4 2.03479 9.07452 5 2.40837 8.44866 6 2.31813 9.42696 7 1.35157 7.32674 8 1.68621 5.24503 9 1.41109 5.26108 10 1.01266 7.65756 Arrays after ascending sort: 1 1.01266 7.65756 2 1.35157 7.32674 3 1.41109 5.26108 4 1.41109 5.26108 5 1.41109 5.26108 6 1.68621 5.24503 7 2.03479 9.07452 8 2.31813 9.42696 9 2.31813 9.42696 10 2.40837 8.44866 Arrays after descending sort: 1 2.40837 8.44866 2 2.31813 9.42696 3 2.31813 9.42696 4 2.03479 9.07452 5 1.68621 5.24503 6 1.41109 5.26108 7 1.41109 5.26108 8 1.41109 5.26108 9 1.35157 7.32674 10 1.01266 7.65756 UNIQed array: 1 2.40837 8.44866 2 2.31813 9.42696 3 2.03479 9.07452 4 1.68621 5.24503 5 1.41109 5.26108 6 1.35157 7.32674 7 1.01266 7.65756 TEST1168 For a pair of real vectors: RVEC2_UNIQUE_INDEX indexes unique entries. Sorted arrays: 1 1.00122 9.20587 2 1.00122 9.20587 3 1.08387 7.14179 4 1.20862 6.21678 5 1.21961 5.57136 6 1.21961 5.57136 7 1.21961 5.57136 8 2.04437 5.39319 9 2.15233 7.71890 10 2.51851 5.18854 The number of unique elements is 7 Index of Unique Elements: 1 1 2 3 3 4 4 5 5 8 6 9 7 10 Arrays after Indexed Nonunique Deletion. 1 1.00122 9.20587 2 1.08387 7.14179 3 1.20862 6.21678 4 1.21961 5.57136 5 2.04437 5.39319 6 2.15233 7.71890 7 2.51851 5.18854 TEST126 RVEC2_SORT_HEAP_INDEX_A creates a sort index for an (X,Y) array. The unsorted array: I, X(I), Y(I) 1 0.500000E-01 0.600000 2 0.950000 0.150000 3 0.800000 0.850000 4 0.300000 0.650000 5 0.700000 0.100000 6 0.500000 0.800000 7 0.300000 0.850000 8 0.300000 0.950000 9 0.500000E-01 0.550000 10 0.750000 0.850000 11 0.850000 0.00000 12 0.450000 0.900000 13 0.900000 0.750000 14 0.700000 0.150000 15 0.250000 0.100000 16 0.300000 0.00000 17 0.900000 0.350000 18 0.350000 0.350000 19 0.500000 0.500000 20 0.700000 0.850000 After sorting: I, INDX(I), X(I), Y(I) 1 9 0.500000E-01 0.600000 2 1 0.950000 0.150000 3 15 0.800000 0.850000 4 16 0.300000 0.650000 5 4 0.700000 0.100000 6 7 0.500000 0.800000 7 8 0.300000 0.850000 8 18 0.300000 0.950000 9 12 0.500000E-01 0.550000 10 19 0.750000 0.850000 11 6 0.850000 0.00000 12 5 0.450000 0.900000 13 14 0.900000 0.750000 14 20 0.700000 0.150000 15 10 0.250000 0.100000 16 3 0.300000 0.00000 17 11 0.900000 0.350000 18 17 0.350000 0.350000 19 13 0.500000 0.500000 20 2 0.700000 0.850000 Now use the index array to carry out the permutation implicitly. I, INDX(I), X(INDX(I)), Y(INDX(I)) 1 9 0.500000E-01 0.550000 2 1 0.500000E-01 0.600000 3 15 0.250000 0.100000 4 16 0.300000 0.00000 5 4 0.300000 0.650000 6 7 0.300000 0.850000 7 8 0.300000 0.950000 8 18 0.350000 0.350000 9 12 0.450000 0.900000 10 19 0.500000 0.500000 11 6 0.500000 0.800000 12 5 0.700000 0.100000 13 14 0.700000 0.150000 14 20 0.700000 0.850000 15 10 0.750000 0.850000 16 3 0.800000 0.850000 17 11 0.850000 0.00000 18 17 0.900000 0.350000 19 13 0.900000 0.750000 20 2 0.950000 0.150000 RVEC_PERMUTE carries out the permutation. I, X(I), Y(I) 1 0.500000E-01 0.550000 2 0.500000E-01 0.600000 3 0.250000 0.100000 4 0.300000 0.00000 5 0.300000 0.650000 6 0.300000 0.850000 7 0.300000 0.950000 8 0.350000 0.350000 9 0.450000 0.900000 10 0.500000 0.500000 11 0.500000 0.800000 12 0.700000 0.100000 13 0.700000 0.150000 14 0.700000 0.850000 15 0.750000 0.850000 16 0.800000 0.850000 17 0.850000 0.00000 18 0.900000 0.350000 19 0.900000 0.750000 20 0.950000 0.150000 TEST117 For 2 real vectors: RVEC2_SUM_IMAX: index of the sum vector with maximum value. The pair of vectors: 1 0.805824 2.87042 2 1.01472 0.526901 3 2.22724 2.86630 4 5.10418 4.42323 5 0.897002 1.21811 6 1.70408 2.80599 7 8.04803 0.636435 8 2.19292 1.25818 9 4.51992 0.694632 10 8.78347 3.25785 Index of maximum in A+B: 10 TEST1173 RRVEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. RRVEC_INDEX_SEARCH searches for an entry with a given value. Generate  random values: XVAL YVAL Index 2.00 1.00 1 3.00 2.00 2 2.00 1.00 1 2.00 3.00 3 1.00 3.00 4 4.00 3.00 5 3.00 3.00 6 3.00 1.00 7 3.00 2.00 2 3.00 1.00 7 3.00 2.00 2 3.00 2.00 2 2.00 2.00 8 2.00 2.00 8 4.00 2.00 9 4.00 1.00 10 3.00 1.00 7 1.00 1.00 11 1.00 2.00 12 4.00 2.00 9 2.00 1.00 1 2.00 1.00 1 1.00 3.00 4 3.00 2.00 2 3.00 1.00 7 2.00 2.00 8 4.00 2.00 9 3.00 3.00 6 3.00 3.00 6 1.00 1.00 11 Vector of unique X Y values: I X(I) Y(I) 1 2.00 1.00 2 3.00 2.00 3 2.00 3.00 4 1.00 3.00 5 4.00 3.00 6 3.00 3.00 7 3.00 1.00 8 2.00 2.00 9 4.00 2.00 10 4.00 1.00 11 1.00 1.00 12 1.00 2.00 X, Y sorted by index I INDX(I) X(INDX(I)) Y(INDX(I)) 1 11 1.00 1.00 2 12 1.00 2.00 3 4 1.00 3.00 4 1 2.00 1.00 5 8 2.00 2.00 6 3 2.00 3.00 7 7 3.00 1.00 8 2 3.00 2.00 9 6 3.00 3.00 10 10 4.00 1.00 11 9 4.00 2.00 12 5 4.00 3.00 TEST1174 RRRVEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. RRRVEC_INDEX_SEARCH searches for an entry with a given value. Number of random values to generate = 30 XVAL YVAL ZVAL Index 2.00 1.00 2.00 1 1.00 1.00 1.00 2 2.00 2.00 4.00 3 2.00 1.00 4.00 4 3.00 2.00 4.00 5 2.00 3.00 3.00 6 1.00 3.00 1.00 7 2.00 1.00 2.00 1 4.00 1.00 2.00 8 4.00 3.00 2.00 9 3.00 1.00 3.00 10 3.00 1.00 1.00 11 4.00 1.00 2.00 8 4.00 2.00 1.00 12 4.00 2.00 1.00 12 1.00 2.00 2.00 13 1.00 2.00 4.00 14 2.00 2.00 1.00 15 1.00 1.00 4.00 16 2.00 3.00 3.00 6 3.00 1.00 3.00 10 2.00 2.00 2.00 17 1.00 2.00 2.00 13 4.00 1.00 1.00 18 2.00 2.00 3.00 19 3.00 2.00 2.00 20 1.00 2.00 1.00 21 3.00 2.00 2.00 20 3.00 2.00 2.00 20 3.00 1.00 3.00 10 Vector of unique X Y Z values: I X(I) Y(I) Z(I) 1 2.00 1.00 2.00 2 1.00 1.00 1.00 3 2.00 2.00 4.00 4 2.00 1.00 4.00 5 3.00 2.00 4.00 6 2.00 3.00 3.00 7 1.00 3.00 1.00 8 4.00 1.00 2.00 9 4.00 3.00 2.00 10 3.00 1.00 3.00 11 3.00 1.00 1.00 12 4.00 2.00 1.00 13 1.00 2.00 2.00 14 1.00 2.00 4.00 15 2.00 2.00 1.00 16 1.00 1.00 4.00 17 2.00 2.00 2.00 18 4.00 1.00 1.00 19 2.00 2.00 3.00 20 3.00 2.00 2.00 21 1.00 2.00 1.00 X Y Z sorted by index: I INDX(I) X(I) X(INDX(I)) 1 2 1.00 1.00 1.00 2 16 1.00 1.00 4.00 3 21 1.00 2.00 1.00 4 13 1.00 2.00 2.00 5 14 1.00 2.00 4.00 6 7 1.00 3.00 1.00 7 1 2.00 1.00 2.00 8 4 2.00 1.00 4.00 9 15 2.00 2.00 1.00 10 17 2.00 2.00 2.00 11 19 2.00 2.00 3.00 12 3 2.00 2.00 4.00 13 6 2.00 3.00 3.00 14 11 3.00 1.00 1.00 15 10 3.00 1.00 3.00 16 20 3.00 2.00 2.00 17 5 3.00 2.00 4.00 18 18 4.00 1.00 1.00 19 8 4.00 1.00 2.00 20 12 4.00 2.00 1.00 21 9 4.00 3.00 2.00 TEST1175 RMAT_HESS estimates the Hessian matrix of a scalar function. Estimated jacobian: 1 2 3 1 1.991398 1.001231 0.000000 2 1.001231 0.000000 9.840458 3 0.000000 9.840458 -30.788492 Exact jacobian: 1 2 3 1 2.000000 1.000000 0.000000 2 1.000000 0.000000 9.880316 3 0.000000 9.880316 -30.850292 TEST118 RMAT_JAC estimates the M by N jacobian matrix of a nonlinear function. Estimated jacobian: 1 2 3 4 1 -0.831485 -0.415246 0.000000 0.000000 2 0.691414 0.000000 1.001358 0.000000 3 0.953674 2.034505 3.004074 4.005432 Exact jacobian: 1 2 3 4 1 -0.832294 -0.416147 0.000000 0.000000 2 0.707107 0.000000 1.000000 0.000000 3 1.000000 2.000000 3.000000 4.000000 TEST119 RMAT_SOLVE is a linear solver. Right hand side: 1 5.00000 2 11.0000 The system is nonsingular. Computed solution: 1 1.00000 2 2.00000 Right hand side: 1 4.00000 2 2.00000 3 2.00000 RMAT_SOLVE2 - Warning: Consistent singularity, equation = 3 The system is singular, but consistent. Computed solution: 1 2.00000 2 0.00000 3 0.00000 Right hand side: 1 5.00000 2 16.0000 3 14.0000 4 15.0000 The system is nonsingular. Computed solution: 1 0.999999 2 2.00000 3 3.00000 4 4.00000 Right hand side: 1 13.0000 2 17.0000 3 20.0000 RMAT_SOLVE2 - Error: Inconsistent singularity, equation = 2 The system is singular and inconsistent. Computed solution: 1 -0.714285 2 0.00000 3 4.42857 TEST120 SORT_HEAP_EXTERNAL sorts objects externally. Unsorted array: 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 Sorted array: 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 TEST121 SVEC_SORT_HEAP_A sorts a string vector. SVEC_REVERSE reverses a string vector. Unsorted list: FRED fred Abacus beetles XYLOPHONE banana goofball abbot BARBECUE abbots Sorted list: Abacus BARBECUE FRED XYLOPHONE abbot abbots banana beetles fred goofball Reversed sorted list: goofball fred beetles banana abbots abbot XYLOPHONE FRED BARBECUE Abacus TEST122 For ascending order: SVEC_SORT_HEAP_A sorts a character array; SVEC_MERGE_A merges two sorted character arrays into a single sorted array. SVEC_SEARCH_BINARY_A searches a string array for a particular value. Sorted vector A: EEEE EEEE EEEE EEEE EEEE EEEE EEEE EEEE EEEE EEEE Sorted vector B: FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF Merged output vector C = A + B: EEEE FFFF Search C for value EEEE The value occurs at index 1 TEST123 SVEC_SORT_HEAP_A sorts a character array; SVEC_UNIQUE finds the unique entries in a sorted character array. Input vector A: Ax Ax Ax Bat Bat Cat Mat Pyx Tab Tab Unique entries: Ax Bat Cat Mat Pyx Tab TEST124 For implicitly capitalized strings, SVECI_SORT_HEAP_A sorts; SVECI_SEARCH_BINARY_A searches. Unsorted list: FRED fred Abacus beetles XYLOPHONE banana goofball abbot BARBECUE abbots Sorted list: Abacus abbot abbots banana BARBECUE beetles fred FRED goofball XYLOPHONE Now search for the string ABBoT The search string occurs in index 2 TEST1245 UNIFORM_01_SAMPLE samples a uniform random distribution in [0,1]. Starting with seed = 1381956693 Number of values computed was N = 1000 Average value was 0.492593 Variance was 0.849899E-01 TEST127 C_CUBE_ROOT finds complex cube roots. X Y=C_CUBE_ROOT(X) Y**3 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 -1.00000 0.00000 0.50000 0.86603 -1.00000 0.00000 0.00000 8.00000 1.73205 1.00000 0.00000 8.00000 0.70711 0.70711 0.96593 0.25882 0.70711 0.70711 0.00000 -1.00000 0.00000 1.00000 0.00000 -1.00000 TEST128 R_ZETA computes the Riemann Zeta function. P Zeta(P) 1.50000 2.54915 2.00000 1.64493 2.50000 1.34144 3.00000 1.20206 3.50000 1.12673 4.00000 1.08232 4.50000 1.05471 5.00000 1.03693 5.50000 1.02520 6.00000 1.01734 TEST129 UPC_CHECK_DIGIT determines the check digit for a UPC. P-LLLLL-RRRRR-C 0-72890-00011-8 0-12345-67890-5 TEST999 LCM_12N computes the least common multiple of the integers 1 through N. N LCM_12N ( N ) 1 1 2 2 3 6 4 12 5 60 6 60 7 420 8 420 9 1260 10 1260 11 13860 12 13860 SUBPAK_PRB Normal end of SUBPAK tests.