24 May 2015 11:39:00 AM R8LIB_PRB C++ version Test the R8LIB library. I4INT_TO_R8INT_TEST For data in an interval, I4INT_TO_R8INT converts an integer to a real; Integer interval: [1, 11] Real interval: [100, 200] R I(R) R(I(R)) 113.394 2 110 209.321 12 210 192.836 10 190 158.02 7 160 138.99 5 140 93.5954 0 90 118.485 3 120 99.2944 1 100 90.6978 0 90 167.416 8 170 PERM0_CHECK_TEST PERM0_CHECK checks a permutation of 0, ..., N-1. Permutation 1: 5 2 3 4 1 PERM0_CHECK - Fatal error! Permutation is missing value 0 Permutation 2: 4 1 3 0 2 Permutation 3: 0 2 1 3 2 PERM0_CHECK - Fatal error! Permutation is missing value 4 PERM0_UNIFORM_TEST PERM0_UNIFORM randomly selects a permutation of 0,...,N-1. 2 9 8 6 3 5 7 4 0 1 0 5 1 8 3 2 9 4 7 6 8 0 2 3 5 9 6 1 4 7 6 0 8 1 9 7 3 4 2 5 5 4 6 0 3 8 2 7 9 1 PERM1_CHECK_TEST PERM1_CHECK checks a permutation of 1, ..., N. Permutation 1: 5 2 3 4 1 Permutation 2: 4 1 3 0 2 PERM1_CHECK - Fatal error! Permutation is missing value 5 Permutation 3: 0 2 1 3 2 PERM1_CHECK - Fatal error! Permutation is missing value 4 PERM1_UNIFORM_TEST PERM1_UNIFORM randomly selects a permutation of 1,...,N. 3 10 9 7 4 6 8 5 1 2 1 6 2 9 4 3 10 5 8 7 9 1 3 4 6 10 7 2 5 8 7 1 9 2 10 8 4 5 3 6 6 5 7 1 4 9 3 8 10 2 R8_ABS_TEST R8_ABS returns the absolute value of an R8. X R8_ABS(X) -1.25265 1.25265 4.65054 4.65054 3.63607 3.63607 1.49356 1.49356 0.322457 0.322457 -2.47105 2.47105 -0.939378 0.939378 -2.12035 2.12035 -2.64937 2.64937 2.07173 2.07173 R8_ACOS_TEST R8_ACOS computes the arc-cosine of an angle. C R8_ACOS(C) ACOS(C) -1.16667 3.14159 -1 3.14159 3.14159 -0.833333 2.55591 2.55591 -0.666667 2.30052 2.30052 -0.5 2.0944 2.0944 -0.333333 1.91063 1.91063 -0.166667 1.73824 1.73824 0 1.5708 1.5708 0.166667 1.40335 1.40335 0.333333 1.23096 1.23096 0.5 1.0472 1.0472 0.666667 0.841069 0.841069 0.833333 0.585686 0.585686 1 0 0 1.16667 0 R8_ACOSH_TEST R8_ACOSH computes the arc-hyperbolic-cosine of an angle. X A=R8_ACOSH(X) COSH(A) 1 0 1 1.5 0.962424 1.5 2 1.31696 2 2.5 1.5668 2.5 3 1.76275 3 3.5 1.92485 3.5 4 2.06344 4 4.5 2.18464 4.5 5 2.29243 5 R8_ASINH_TEST R8_ASINH computes the inverse hyperbolic sine of a given value. X R8_ASINH(X) SINH(R8_ASINH(X)) 1 0.881374 1 1.2 1.01597 1.2 1.4 1.13798 1.4 1.6 1.24898 1.6 1.8 1.35044 1.8 2 1.44364 2 2.2 1.52966 2.2 2.4 1.60944 2.4 2.6 1.68374 2.6 2.8 1.75323 2.8 3 1.81845 3 R8_ATAN_TEST R8_ATAN computes the arc-tangent given Y and X; ATAN2 is the system version of this routine. X Y ATAN2(Y,X) R8_ATAN(Y,X) 1 0 0 0 1 1 0.785398 0.785398 0 1 1.5708 1.5708 -1 1 2.35619 2.35619 -1 0 3.14159 3.14159 -1 -1 -2.35619 3.92699 0 -1 -1.5708 4.71239 1 -1 -0.785398 5.49779 R8_ATANH_TEST R8_ATANH computes the inverse hyperbolic tangent of a given value. X R8_ATANH(X) TANH(R8_ATANH(X)) -0.2 -0.202733 -0.2 -0.1 -0.100335 -0.1 0 0 0 0.1 0.100335 0.1 0.2 0.202733 0.2 0.3 0.30952 0.3 0.4 0.423649 0.4 0.5 0.549306 0.5 0.6 0.693147 0.6 0.7 0.867301 0.7 0.8 1.09861 0.8 0.9 1.47222 0.9 R8_BIG_TEST R8_BIG returns a 'big' R8 value; R8_BIG = 1e+30 R8_CAS_TEST R8_CAS evaluates the casine of a number. X R8_CAS ( X ) 0 1 0.261799 1.22474 0.523599 1.36603 0.785398 1.41421 1.0472 1.36603 1.309 1.22474 1.5708 1 1.8326 0.707107 2.0944 0.366025 2.35619 1.11022e-16 2.61799 -0.366025 2.87979 -0.707107 3.14159 -1 R8_CEILING_TEST R8_CEILING rounds a value up. X R8_CEILING(X) -1.2 -1 -1 -1 -0.8 0 -0.6 0 -0.4 0 -0.2 0 0 0 0.2 1 0.4 1 0.6 1 0.8 1 1 1 1.2 2 R8_CHOOSE_TEST R8_CHOOSE evaluates C(N,K). N K CNK 0 0 1 1 0 1 1 1 1 2 0 1 2 1 2 2 2 1 3 0 1 3 1 3 3 2 3 3 3 1 4 0 1 4 1 4 4 2 6 4 3 4 4 4 1 5 0 1 5 1 5 5 2 10 5 3 10 5 4 5 5 5 1 R8_COSD_TEST R8_COSD computes the cosine of an angle given in degrees. ANGLE R8_COSD(ANGLE) 0 1 15 0.965926 30 0.866025 45 0.707107 60 0.5 75 0.258819 90 6.12323e-17 105 -0.258819 120 -0.5 135 -0.707107 150 -0.866025 165 -0.965926 180 -1 195 -0.965926 210 -0.866025 225 -0.707107 240 -0.5 255 -0.258819 270 -1.83697e-16 285 0.258819 300 0.5 315 0.707107 330 0.866025 345 0.965926 360 1 R8_COTD_TEST R8_COTD computes the cotangent of an angle given in degrees. ANGLE R8_COTD(ANGLE) 0 Undefined 15 3.73205 30 1.73205 45 1 60 0.57735 75 0.267949 90 6.12323e-17 105 -0.267949 120 -0.57735 135 -1 150 -1.73205 165 -3.73205 180 Undefined 195 3.73205 210 1.73205 225 1 240 0.57735 255 0.267949 270 1.83697e-16 285 -0.267949 300 -0.57735 315 -1 330 -1.73205 345 -3.73205 360 Undefined R8_CSCD_TEST R8_CSCD computes the cosecant of an angle given in degrees. ANGLE R8_CSCD(ANGLE) 0 Undefined 15 3.8637 30 2 45 1.41421 60 1.1547 75 1.03528 90 1 105 1.03528 120 1.1547 135 1.41421 150 2 165 3.8637 180 Undefined 195 -3.8637 210 -2 225 -1.41421 240 -1.1547 255 -1.03528 270 -1 285 -1.03528 300 -1.1547 315 -1.41421 330 -2 345 -3.8637 360 Undefined R8_CUBE_ROOT_TEST R8_CUBE_ROOT computes the cube root of an R8. X Y Y^3 -5.63163 -1.77915 -5.63163 9.12635 2.08977 9.12635 6.59018 1.87485 6.59018 1.23391 1.07258 1.23391 -1.69386 -1.19204 -1.69386 -8.67763 -2.05495 -8.67763 -4.84844 -1.69252 -4.84844 -7.80086 -1.98327 -7.80086 -9.12342 -2.08955 -9.12342 2.67931 1.38891 2.67931 R8_DIFF_TEST R8_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 R8_DIFF(X,Y) 1 0.0625 0.9375 0.875 1 0.125 0.875 0.875 1 0.25 0.75 0.75 1 0.5 0.5 0.5 1 0.874 0.126 0.125 1 0.876 0.124 0.125 1 0.9 0.1 0.125 1 0.95 0.05 0 1 0.99 0.01 0 1 1 0 0 1 1.01 -0.01 0 1 1.05 -0.05 0 1 1.1 -0.1 -0.1375 1 3 -2 -1.875 1 10 -9 -8.75 R8_DIGIT_TEST R8_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 16 17 18 19 20 0 0 0 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 1 1 5 9 R8_E_TEST R8_E returns the value of E. Compare E to (1+1/n)^n R8_E = 2.71828 N Estimate Error 1 2 0.718282 2 2.25 0.468282 4 2.44141 0.276876 8 2.56578 0.152497 16 2.63793 0.0803533 32 2.67699 0.0412917 64 2.69734 0.0209369 128 2.70774 0.0105428 256 2.71299 0.0052902 512 2.71563 0.00264983 1024 2.71696 0.0013261 2048 2.71762 0.000663346 4096 2.71795 0.000331747 8192 2.71812 0.000165892 16384 2.7182 8.29507e-05 32768 2.71824 4.14765e-05 65536 2.71826 2.07386e-05 131072 2.71827 1.03694e-05 262144 2.71828 5.18469e-06 524288 2.71828 2.59234e-06 1048576 2.71828 1.29618e-06 R8_EPSILON_TEST R8_EPSILON produces the R8 roundoff unit. R = R8_EPSILON() = 2.220446049250313e-16 ( 1 + R ) - 1 = 2.220446049250313e-16 ( 1 + (R/2) ) - 1 = 0 R8_EPSILON_COMPUTE_TEST R8_EPSILON_COMPUTE computes the R8 roundoff unit. R = R8_EPSILON_COMPUTE() = 2.220446049250313e-16 ( 1 + R ) - 1 = 2.220446049250313e-16 ( 1 + (R/2) ) - 1 = 0 R8_FACTORIAL_TEST R8_FACTORIAL evaluates the factorial function. N Exact Computed 0 1 1 1 1 1 2 2 2 3 6 6 4 24 24 5 120 120 6 720 720 7 5040 5040 8 40320 40320 9 362880 362880 10 3628800 3628800 11 39916800 39916800 12 479001600 479001600 13 6227020800 6227020800 14 87178291200 87178291200 15 1307674368000 1307674368000 16 20922789888000 20922789888000 17 355687428096000 355687428096000 18 6402373705728000 6402373705728000 19 1.21645100408832e+17 1.21645100408832e+17 20 2.43290200817664e+18 2.43290200817664e+18 25 1.551121004333099e+25 1.551121004333099e+25 50 3.041409320171338e+64 3.041409320171338e+64 100 9.332621544394415e+157 9.33262154439441e+157 150 5.713383956445855e+262 5.71338395644585e+262 R8_FACTORIAL2_TEST R8_FACTORIAL2 evaluates the double factorial function. N Exact Computed 0 1 1 1 1 1 2 2 2 3 3 3 4 8 8 5 15 15 6 48 48 7 105 105 8 384 384 9 945 945 10 3840 3840 11 10395 10395 12 46080 46080 13 135135 135135 14 645120 645120 15 2027025 2027025 R8_FALL_TEST R8_FALL evaluates the falling factorial Fall(X,N). X N Exact Computed 5 4 120 120 5.25 4 163.16015625 163.16015625 5.5 4 216.5625 216.5625 5.75 4 281.66015625 281.66015625 6 4 360 360 7.5 0 1 1 7.5 1 7.5 7.5 7.5 2 48.75 48.75 7.5 3 268.125 268.125 7.5 4 1206.5625 1206.5625 7.5 5 4222.96875 4222.96875 7.5 6 10557.421875 10557.421875 7.5 7 15836.1328125 15836.1328125 7.5 8 7918.06640625 7918.06640625 7.5 9 -3959.033203125 -3959.033203125 R8_FRACTIONAL_TEST R8_FRACTIONAL returns the fractional part of an R8. X R8_FRACTIONAL ( X ) -1.25265 0.252654 4.65054 0.650541 3.63607 0.636074 1.49356 0.493564 0.322457 0.322457 -2.47105 0.47105 -0.939378 0.939378 -2.12035 0.120346 -2.64937 0.649368 2.07173 0.0717257 R8_GAMMA_TEST: R8_GAMMA evaluates the Gamma function. X GAMMA(X) R8_GAMMA(X) -0.5 -3.544907701811032 -3.544907701811032 -0.01 -100.5871979644108 -100.5871979644108 0.01 99.4325851191506 99.4325851191506 0.1 9.513507698668732 9.513507698668731 0.2 4.590843711998803 4.590843711998803 0.4 2.218159543757688 2.218159543757688 0.5 1.772453850905516 1.772453850905516 0.6 1.489192248812817 1.489192248812817 0.8 1.164229713725303 1.164229713725303 1 1 1 1.1 0.9513507698668732 0.9513507698668732 1.2 0.9181687423997607 0.9181687423997607 1.3 0.8974706963062772 0.8974706963062772 1.4 0.8872638175030753 0.8872638175030754 1.5 0.8862269254527581 0.8862269254527581 1.6 0.8935153492876903 0.8935153492876903 1.7 0.9086387328532904 0.9086387328532904 1.8 0.9313837709802427 0.9313837709802427 1.9 0.9617658319073874 0.9617658319073874 2 1 1 3 2 2 4 6 6 10 362880 362880 20 1.21645100408832e+17 1.216451004088321e+17 30 8.841761993739702e+30 8.841761993739751e+30 R8_GAMMA_LOG_TEST: R8_GAMMA_LOG evaluates the logarithm of the Gamma function. X GAMMA_LOG(X) R8_GAMMA_LOG(X) 0.2 1.524063822430784 1.524063822430784 0.4 0.7966778177017837 0.7966778177017837 0.6 0.3982338580692348 0.3982338580692349 0.8 0.1520596783998375 0.1520596783998376 1 0 0 1.1 -0.04987244125983972 -0.04987244125983976 1.2 -0.08537409000331583 -0.08537409000331585 1.3 -0.1081748095078604 -0.1081748095078605 1.4 -0.1196129141723712 -0.1196129141723713 1.5 -0.1207822376352452 -0.1207822376352453 1.6 -0.1125917656967557 -0.1125917656967558 1.7 -0.09580769740706586 -0.09580769740706586 1.8 -0.07108387291437215 -0.07108387291437215 1.9 -0.03898427592308333 -0.03898427592308337 2 0 0 3 0.6931471805599453 0.6931471805599454 4 1.791759469228055 1.791759469228055 10 12.80182748008147 12.80182748008147 20 39.33988418719949 39.33988418719949 30 71.25703896716801 71.257038967168 R8_HUGE_TEST R8_HUGE returns a 'huge' R8 value; R8_HUGE = 1.79769e+308 R8_LOG_2_TEST R8_LOG_2: computes the logarithm base 2. X R8_LOG_2 0 -1e+30 1 0 2 1 3 1.58496 9 3.16993 10 3.32193 11 3.45943 99 6.62936 101 6.65821 -1 0 -2 1 -3 1.58496 -9 3.16993 0.5 -1 0.33 -1.59946 0.25 -2 0.2 -2.32193 0.01 -6.64386 R8_LOG_B_TEST R8_LOG_B computes the logarithm base B. X B R8_LOG_B 16 2 4 16 3 2.52372 16 4 2 16 5 1.72271 16 6 1.54741 16 7 1.42483 16 8 1.33333 16 16 1 16 32 0.8 16 256 0.5 R8_MANT_TEST R8_MANT decomposes a value. Number to be decomposed: X = -314.159 X = -1 * 1.22718 * 2 ^ 8 R8_MAX_TEST R8_MAX returns the maximum of two R8's. A B C=R8_MAX(A,B) -2.81582 4.56318 4.56318 3.29509 0.616954 3.29509 -0.846929 -4.33881 -0.846929 -2.42422 -3.90043 -2.42422 -4.56171 1.33966 1.33966 -4.38273 -0.50461 -0.50461 -0.986937 2.54673 2.54673 2.97287 -4.98162 2.97287 3.97504 -1.49248 3.97504 -4.05455 -4.86383 -4.05455 R8_MIN_TEST R8_MIN returns the minimum of two R8's. A B C=R8_MIN(A,B) -2.81582 4.56318 -2.81582 3.29509 0.616954 0.616954 -0.846929 -4.33881 -4.33881 -2.42422 -3.90043 -3.90043 -4.56171 1.33966 -4.56171 -4.38273 -0.50461 -4.38273 -0.986937 2.54673 -0.986937 2.97287 -4.98162 -4.98162 3.97504 -1.49248 -1.49248 -4.05455 -4.86383 -4.86383 R8_MOD_TEST R8_MOD returns the remainder after division. R8_MOD ( X, Y ) has the same sign as X. X Y FMOD(X,Y) R8_MOD(X,Y) -5.63163 9.12635 -5.63163 -5.63163 6.59018 1.23391 0.42064 0.42064 -1.69386 -8.67763 -1.69386 -1.69386 -4.84844 -7.80086 -4.84844 -4.84844 -9.12342 2.67931 -1.08548 -1.08548 -8.76546 -1.00922 -0.691689 -0.691689 -1.97387 5.09347 -1.97387 -1.97387 5.94574 -9.96323 5.94574 5.94574 7.95008 -2.98495 1.98017 1.98017 -8.1091 -9.72766 -8.1091 -8.1091 R8_MODP_TEST R8_MODP returns the remainder after division. R8_MODP ( X, Y ) is positive. X Y FMOD(X,Y) R8_MODP(X,Y) -5.63163 9.12635 -5.63163 3.49472 6.59018 1.23391 0.42064 0.42064 -1.69386 -8.67763 -1.69386 6.98377 -4.84844 -7.80086 -4.84844 2.95242 -9.12342 2.67931 -1.08548 1.59384 -8.76546 -1.00922 -0.691689 0.317532 -1.97387 5.09347 -1.97387 3.1196 5.94574 -9.96323 5.94574 5.94574 7.95008 -2.98495 1.98017 1.98017 -8.1091 -9.72766 -8.1091 1.61856 R8_MOP_TEST R8_MOP evaluates (-1.0)^I4 as an R8. I4 R8_MOP(I4) -57 -1 92 1 66 1 12 1 -17 -1 -87 -1 -49 -1 -78 1 -92 1 27 -1 R8_NINT_TEST R8_NINT produces the nearest integer. X R8_NINT(X) -5.63163 -6 9.12635 9 6.59018 7 1.23391 1 -1.69386 -2 -8.67763 -9 -4.84844 -5 -7.80086 -8 -9.12342 -9 2.67931 3 R8_NORMAL_01_TEST R8_NORMAL_01 generates normally distributed random values. Using initial random number seed = 123456789 1.67904 -0.56606 1.21293 1.26938 -1.66609 -2.24246 0.0396749 0.673068 -0.275127 2.164 0.297785 2.04454 1.39882 -1.24299 -0.0670837 -0.794396 -0.523768 -0.350567 0.1317 0.53738 R8_PI_TEST R8_PI returns the value of PI. R8_PI = 3.14159 4*atan(1) = 3.14159 R8_POWER_TEST R8_POWER computes R^P R P R^P 2 -5 0.03125 2 -4 0.0625 2 -3 0.125 2 -2 0.25 2 -1 0.5 2 0 1 2 1 2 2 2 4 2 3 8 2 4 16 2 5 32 R8_POWER_FAST_TEST R8_POWER_FAST computes R^P, economizing on multiplications. R P R^P Mults 2 -10 0.000976562 7 2 -9 0.00195312 7 2 -8 0.00390625 6 2 -7 0.0078125 7 2 -6 0.015625 6 2 -5 0.03125 6 2 -4 0.0625 5 2 -3 0.125 5 2 -2 0.25 4 2 -1 0.5 1 2 0 1 0 2 1 2 0 2 2 4 3 2 3 8 4 2 4 16 4 2 5 32 5 2 6 64 5 2 7 128 6 2 8 256 5 2 9 512 6 2 10 1024 6 2 11 2048 7 2 12 4096 6 2 13 8192 7 2 14 16384 7 2 15 32768 8 2 16 65536 6 2 17 131072 7 2 18 262144 7 2 19 524288 8 2 20 1.04858e+06 7 2 21 2.09715e+06 8 2 22 4.1943e+06 8 2 23 8.38861e+06 9 2 24 1.67772e+07 7 2 25 3.35544e+07 8 2 26 6.71089e+07 8 2 27 1.34218e+08 9 2 28 2.68435e+08 8 2 29 5.36871e+08 9 2 30 1.07374e+09 9 2 31 2.14748e+09 10 2 32 4.29497e+09 7 2 33 8.58993e+09 8 2 34 1.71799e+10 8 2 35 3.43597e+10 9 2 36 6.87195e+10 8 2 37 1.37439e+11 9 2 38 2.74878e+11 9 2 39 5.49756e+11 10 2 40 1.09951e+12 8 R8_RISE_TEST R8_RISE evaluates the rising factorial Fall(X,N). X N Exact Computed 5 4 1680 1680 5.25 4 1962.59765625 1962.59765625 5.5 4 2279.0625 2279.0625 5.75 4 2631.97265625 2631.97265625 6 4 3024 3024 7.5 0 1 1 7.5 1 7.5 7.5 7.5 2 63.75 63.75 7.5 3 605.625 605.625 7.5 4 6359.0625 6359.0625 7.5 5 73129.21875 73129.21875 7.5 6 914115.234375 914115.234375 7.5 7 12340555.6640625 12340555.6640625 7.5 8 178938057.1289063 178938057.1289062 7.5 9 2773539885.498047 2773539885.498047 R8_ROUND2_TEST R8_ROUND2 rounds a number to a specified number of base 2 digits. Test effect on PI: X = 3.14159 NPLACE XROUND 0 0 1 2 2 3 3 3 4 3 5 3.125 6 3.125 7 3.125 8 3.140625 9 3.140625 10 3.140625 11 3.140625 12 3.140625 13 3.14111328125 14 3.141357421875 15 3.1414794921875 16 3.14154052734375 17 3.141571044921875 18 3.141586303710938 19 3.141586303710938 20 3.141590118408203 R8_ROUNDB_TEST R8_ROUNDB rounds a number to a specified number of base IBASE digits. Here, we will use IBASE = 3 Test effect on PI: X = 3.141592653589793 NPLACE XROUND 0 0 1 3 2 3 3 3 4 3.111111111111111 5 3.111111111111111 6 3.135802469135802 7 3.139917695473252 8 3.141289437585734 9 3.141289437585734 10 3.14144185337601 11 3.14154346390286 12 3.141577334078477 13 3.141588624137016 14 3.141592387489863 15 3.141592387489863 16 3.141592596565021 17 3.141592596565021 18 3.141592643026167 19 3.141592650769691 20 3.141592653350866 Try with a negative base: Input quantity is X = 121 to be rounded in base -3 Output value to 1 places is 81 Output value to 2 places is 108 Output value to 3 places is 117 Output value to 4 places is 120 Output value to 5 places is 121 R8_ROUNDX_TEST R8_ROUNDX rounds a number to a specified number of decimal digits. Test effect on PI: X = 3.141592653589793 NPLACE XROUND 0 0 1 3 2 3.1 3 3.14 4 3.141 5 3.1415 6 3.14159 7 3.141592 8 3.1415926 9 3.14159265 10 3.141592653 Test effect on random values: NPLACE X XROUND 0 0.2184182969823758 0 2 0.2184182969823758 0.21 4 0.2184182969823758 0.2184 6 0.2184182969823758 0.218418 8 0.2184182969823758 0.21841829 10 0.2184182969823758 0.2184182969 0 0.9563175765089297 0 2 0.9563175765089297 0.9500000000000001 4 0.9563175765089297 0.9563 6 0.9563175765089297 0.956317 8 0.9563175765089297 0.9563175700000001 10 0.9563175765089297 0.9563175765 0 0.8295092339327006 0 2 0.8295092339327006 0.8200000000000001 4 0.8295092339327006 0.8295 6 0.8295092339327006 0.8295089999999999 8 0.8295092339327006 0.82950923 10 0.8295092339327006 0.8295092339 0 0.5616954427668942 0 2 0.5616954427668942 0.5600000000000001 4 0.5616954427668942 0.5616 6 0.5616954427668942 0.5616949999999999 8 0.5616954427668942 0.56169544 10 0.5616954427668942 0.5616954427 0 0.4153070814759612 0 2 0.4153070814759612 0.41 4 0.4153070814759612 0.4153 6 0.4153070814759612 0.415307 8 0.4153070814759612 0.41530708 10 0.4153070814759612 0.4153070814 R8_SECD_TEST R8_SECD computes the secant of an angle given in degrees. ANGLE R8_SECD(ANGLE) 0 1 15 1.03528 30 1.1547 45 1.41421 60 2 75 3.8637 90 Undefined 105 -3.8637 120 -2 135 -1.41421 150 -1.1547 165 -1.03528 180 -1 195 -1.03528 210 -1.1547 225 -1.41421 240 -2 255 -3.8637 270 Undefined 285 3.8637 300 2 315 1.41421 330 1.1547 345 1.03528 360 1 R8_SIGN_TEST R8_SIGN returns the sign of an R8. R8 R8_SIGN(R8) -1.25 -1 -0.25 -1 0 1 0.5 1 9 1 R8_SIGN3_TEST R8_SIGN3 returns the three-way sign of an R8. R8 R8_SIGN3(R8) -1.25 -1 -0.25 -1 0 0 0.5 1 9 1 R8_SIND_TEST R8_SIND computes the sine of an angle given in degrees. ANGLE R8_SIND(ANGLE) 0 0 15 0.258819 30 0.5 45 0.707107 60 0.866025 75 0.965926 90 1 105 0.965926 120 0.866025 135 0.707107 150 0.5 165 0.258819 180 1.22465e-16 195 -0.258819 210 -0.5 225 -0.707107 240 -0.866025 255 -0.965926 270 -1 285 -0.965926 300 -0.866025 315 -0.707107 330 -0.5 345 -0.258819 360 -2.44929e-16 R8_SWAP_TEST R8_SWAP swaps two reals. Before swapping: X = 1 Y = 3.14159 After swapping: X = 3.14159 Y = 1 R8_SWAP3_TEST R8_SWAP3 swaps three reals. X Y Z Start: 1 3.14159 1952 Swap 1 3.14159 1952 1 Swap 2 1952 1 3.14159 Swap 3 1 3.14159 1952 R8_TAND_TEST R8_TAND computes the tangent of an angle given in degrees. ANGLE R8_TAND(ANGLE) 0 0 15 0.267949 30 0.57735 45 1 60 1.73205 75 3.73205 90 Undefined 105 -3.73205 120 -1.73205 135 -1 150 -0.57735 165 -0.267949 180 -1.22465e-16 195 0.267949 210 0.57735 225 1 240 1.73205 255 3.73205 270 Undefined 285 -3.73205 300 -1.73205 315 -1 330 -0.57735 345 -0.267949 360 -2.44929e-16 R8_TO_I4_TEST R8_TO_I4 finds an integer IX in [IXMIN,IXMAX] corresponding to X in [XMIN,XMAX]. XMIN 2.5 X = 3.5 XMAX = 5.5 IXMIN 10 IX = 20 IXMAX = 40 R8_TO_R8_DISCRETE_TEST R8_TO_R8_DISCRETE maps numbers to a discrete set of equally spaced numbers in an interval. Number of discrete values = 19 Real interval: 1 10 R RD 1.83944 1.94737 11.4321 10 9.78362 10 6.30204 6.21053 4.39899 4.31579 -0.140456 1 2.34851 2.42105 0.429438 1 -0.430223 1 7.24155 7.15789 -0.197546 1 4.84401 4.78947 4.21698 4.31579 8.81076 8.57895 9.36473 9.52632 R8_UNIFORM_01_TEST R8_UNIFORM_01 samples a uniform random distribution in [0,1]. distributed random numbers. Using initial random number seed = 123456789 First few values: 0 0.218418 1 0.956318 2 0.829509 3 0.561695 4 0.415307 5 0.0661187 6 0.257578 7 0.109957 8 0.043829 9 0.633966 Number of samples was 1000 Minimum value was 0.00183837 Maximum value was 0.997908 Average value was 0.50304 Variance was 0.082332 R8_UNIFORM_AB_TEST R8_UNIFORM_AB produces a random real in a given range. Using range 10 <= A <= 25. I A 0 10.002 1 13.5421 2 22.6794 3 21.9558 4 10.8556 5 20.8346 6 21.9964 7 18.1105 8 18.2206 9 23.3467 R8_WALSH_1D_TEST R8_WALSH_1D evaluates 1D Walsh functions: X W(+2) W(+1) W(0) W(-1) W(-2) W(-3) 0 0 0 0 0 0 0 0.25 0 0 0 0 1 0 0.5 0 0 0 1 0 0 0.75 0 0 0 1 1 0 1 0 0 1 0 0 0 1.25 0 0 1 0 1 0 1.5 0 0 1 1 0 0 1.75 0 0 1 1 1 0 2 0 1 0 0 0 0 2.25 0 1 0 0 1 0 2.5 0 1 0 1 0 0 2.75 0 1 0 1 1 0 3 0 1 1 0 0 0 3.25 0 1 1 0 1 0 3.5 0 1 1 1 0 0 3.75 0 1 1 1 1 0 4 1 0 0 0 0 0 4.25 1 0 0 0 1 0 4.5 1 0 0 1 0 0 4.75 1 0 0 1 1 0 5 1 0 1 0 0 0 5.25 1 0 1 0 1 0 5.5 1 0 1 1 0 0 5.75 1 0 1 1 1 0 6 1 1 0 0 0 0 6.25 1 1 0 0 1 0 6.5 1 1 0 1 0 0 6.75 1 1 0 1 1 0 7 1 1 1 0 0 0 7.25 1 1 1 0 1 0 7.5 1 1 1 1 0 0 7.75 1 1 1 1 1 0 8 0 0 0 0 0 0 R8_WRAP_TEST R8_WRAP "wraps" an R8 to lie within an interval: Wrapping interval is 3, 6.5 R R8_WRAP ( R ) 1.05786 4.55786 11.3884 4.38845 9.61313 6.11313 5.86374 5.86374 3.8143 3.8143 -1.07434 5.92566 1.60609 5.10609 -0.460605 3.0394 -1.38639 5.61361 6.87552 3.37552 -1.13582 5.86418 4.29355 4.29355 3.61829 3.61829 8.56543 5.06543 9.16202 5.66202 -1.97426 5.02574 10.5651 3.56506 2.91053 6.41053 -0.676373 6.32363 -1.80936 5.19064 R82COL_PRINT_PART_TEST R82COL_PRINT_PART prints part of an R82COL. Output with MAX_PRINT = 2 0: 11 12 1: 21 22 ...more entries... Output with MAX_PRINT = 5 0: 11 12 1: 21 22 2: 31 32 ........ .............. .............. 9: 101 102 Output with MAX_PRINT = 25 0 11 12 1 21 22 2 31 32 3 41 42 4 51 52 5 61 62 6 71 72 7 81 82 8 91 92 9 101 102 R82POLY2_TYPE_TEST R82POLY2_TYPE determines the type of a second order equation in two variables. 9 * x^2 + -4 * y^2 + 0 * xy + -36 * x + -24 * y + -36 Type = 1 The set of solutions forms a hyperbola. 4 * x^2 + 1 * y^2 + -4 * xy + 3 * x + -4 * y + 1 Type = 2 The set of solutions forms a parabola. 9 * x^2 + 16 * y^2 + 0 * xy + 36 * x + -32 * y + -92 Type = 3 The set of solutions forms an ellipse. 1 * x^2 + 1 * y^2 + 0 * xy + -6 * x + -10 * y + 115 Type = 4 The set of solutions forms an imaginary ellipse. (There are no real solutions). 0 * x^2 + 0 * y^2 + 1 * xy + 3 * x + -1 * y + -3 Type = 5 The set of solutions forms a pair of intersecting lines. 1 * x^2 + 2 * y^2 + 0 * xy + -2 * x + 16 * y + 33 Type = 6 The set of solutions is a single point. 0 * x^2 + 1 * y^2 + 0 * xy + 0 * x + -6 * y + 8 Type = 7 The set of solutions form a pair of distinct parallel lines. 0 * x^2 + 1 * y^2 + 0 * xy + 0 * x + -6 * y + 10 Type = 8 The set of solutions forms a pair of imaginary parallel lines. (There are no real solutions). 0 * x^2 + 1 * y^2 + 0 * xy + 0 * x + -2 * y + 1 Type = 9 The set of solutions forms a pair of coincident lines. 0 * x^2 + 0 * y^2 + 0 * xy + 2 * x + -1 * y + 1 Type = 10 The set of solutions forms a single line. 0 * x^2 + 0 * y^2 + 0 * xy + 0 * x + 0 * y + 0 Type = 11 The set of solutions is all space. 0 * x^2 + 0 * y^2 + 0 * xy + 0 * x + 0 * y + 1 Type = 12 The set of solutions is empty. R82ROW_ORDER_TYPE_TEST R82ROW_ORDER_TYPE classifies an R8VEC as -1: no order 0: all equal; 1: ascending; 2: strictly ascending; 3: descending; 4: strictly descending. Order type = -1 0: 1 3 1: 2 2 2: 1 0 3: 1 0 Order type = -1 0: 0 2 1: 0 1 2: 1 2 3: 2 0 Order type = -1 0: 3 1 1: 0 0 2: 3 3 3: 0 0 Order type = -1 0: 1 3 1: 0 1 2: 2 1 3: 2 2 Order type = -1 0: 3 1 1: 3 2 2: 1 2 3: 1 1 Order type = 4 0: 2 1 1: 2 1 2: 1 2 3: 0 1 Order type = -1 0: 2 2 1: 0 2 2: 0 2 3: 2 1 Order type = -1 0: 3 2 1: 2 1 2: 3 2 3: 0 2 Order type = -1 0: 0 1 1: 1 3 2: 0 0 3: 0 0 Order type = -1 0: 1 0 1: 1 1 2: 2 2 3: 2 1 R82ROW_PART_QUICK_A_TEST R82ROW_PART_QUICK_A reorders an R82ROW as part of a quick sort. Using initial random number seed = 123456789 Before rearrangment: 0: 0.436837 1.91264 1: 1.65902 1.12339 2: 0.830614 0.132237 3: 0.515156 0.219914 4: 0.087658 1.26793 5: 0.123454 0.899078 6: 0.802613 1.50935 7: 1.59457 0.00367674 8: 1.79501 0.701505 9: 0.18909 0.0272338 10: 1.71819 1.68169 11: 0.246208 0.0150247 Rearranged array Left index = 4 Key index = 5 Right index = 6 Left half: 0: 0.246208 0.0150247 1: 0.18909 0.0272338 2: 0.123454 0.899078 3: 0.087658 1.26793 Key: 0: 0.436837 1.91264 Right half: 0: 0.802613 1.50935 1: 1.59457 0.00367674 2: 1.79501 0.701505 3: 0.515156 0.219914 4: 1.71819 1.68169 5: 0.830614 0.132237 6: 1.65902 1.12339 R82ROW_PRINT_PART_TEST R82ROW_PRINT_PART prints part of an R82ROW. Output with MAX_PRINT = 2 0: 11 21 1: 12 22 ...more entries... Output with MAX_PRINT = 5 0: 11 21 1: 12 22 2: 13 23 ........ .............. .............. 9: 20 30 Output with MAX_PRINT = 25 0 11 21 1 12 22 2 13 23 3 14 24 4 15 25 5 16 26 6 17 27 7 18 28 8 19 29 9 20 30 R82ROW_SORT_HEAP_INDEX_A_TEST R82ROW_SORT_HEAP_INDEX_A index sorts an R82ROW using heapsort. Using initial random number seed = 123456789 Before rearrangement: 0: 2.18418 9.56318 1: 8.29509 3.50752 2: 0.43829 0.661187 3: 1.23104 1.09957 4: 0.43829 6.33966 5: 0.617272 9.56318 6: 8.59097 8.40847 7: 7.97287 0.0183837 8: 8.97504 3.50752 9: 0.945448 0.136169 10: 8.59097 8.40847 11: 1.23104 0.0751236 I Index A(Index) 0 2 0.43829 0.661187 1 4 0.43829 6.33966 2 5 0.617272 9.56318 3 9 0.945448 0.136169 4 11 1.23104 0.0751236 5 3 1.23104 1.09957 6 0 2.18418 9.56318 7 7 7.97287 0.0183837 8 1 8.29509 3.50752 9 6 8.59097 8.40847 10 10 8.59097 8.40847 11 8 8.97504 3.50752 After rearrangement by R82ROW_PERMUTE: 0: 0.43829 0.661187 1: 0.43829 6.33966 2: 0.617272 9.56318 3: 0.945448 0.136169 4: 1.23104 0.0751236 5: 1.23104 1.09957 6: 2.18418 9.56318 7: 7.97287 0.0183837 8: 8.29509 3.50752 9: 8.59097 8.40847 10: 8.59097 8.40847 11: 8.97504 3.50752 R82ROW_SORT_QUICK_A_TEST R82ROW_SORT_QUICK_A sorts an R82ROW as part of a quick sort. Using initial random number seed = 123456789 Before sorting: 0: 2.18418 9.56318 1: 8.29509 5.61695 2: 0.43829 0.661187 3: 1.23104 1.09957 4: 0.43829 6.33966 5: 0.617272 4.49539 6: 8.59097 8.40847 7: 7.97287 0.0183837 8: 8.97504 3.50752 9: 0.945448 0.136169 10: 8.59097 8.40847 11: 1.23104 0.0751236 Sorted array: 0: 0.43829 0.661187 1: 0.43829 6.33966 2: 0.617272 4.49539 3: 0.945448 0.136169 4: 1.23104 0.0751236 5: 1.23104 1.09957 6: 2.18418 9.56318 7: 7.97287 0.0183837 8: 8.29509 5.61695 9: 8.59097 8.40847 10: 8.59097 8.40847 11: 8.97504 3.50752 R83COL_PRINT_PART_TEST R83COL_PRINT_PART prints part of an R83COL. Output with MAX_PRINT = 2 0: 11 12 13 1: 21 22 23 ...more entries... Output with MAX_PRINT = 5 0: 11 12 13 1: 21 22 23 2: 31 32 33 ........ .............. .............. .............. 9: 101 102 103 Output with MAX_PRINT = 25 0 11 12 13 1 21 22 23 2 31 32 33 3 41 42 43 4 51 52 53 5 61 62 63 6 71 72 73 7 81 82 83 8 91 92 93 9 101 102 103 R83ROW_PRINT_PART_TEST R83ROW_PRINT_PART prints part of an R83ROW. Output with MAX_PRINT = 2 0: 11 21 31 1: 12 22 32 ...more entries... Output with MAX_PRINT = 5 0: 11 21 31 1: 12 22 32 2: 13 23 33 ........ .............. .............. .............. 9: 20 30 40 Output with MAX_PRINT = 25 0 11 21 31 1 12 22 32 2 13 23 33 3 14 24 34 4 15 25 35 5 16 26 36 6 17 27 37 7 18 28 38 8 19 29 39 9 20 30 40 R8BLOCK_EXPAND_LINEAR_TEST R8BLOCK_EXPAND_LINEAR linearly interpolates new data between old values in a 3D block. Original block: K = 1 1 2 3 1: 1 1 1 2: 2 4 8 3: 3 9 27 4: 4 16 64 K = 2 1 2 3 1: 2 2 2 2: 4 8 16 3: 6 18 54 4: 8 32 128 LFAT = 1 MFAT = 2 NFAT = 1 Fattened block: K = 1 1 2 3 4 5 1: 1 1 1 1 1 2: 1.5 1.83333 2.16667 2.5 3.16667 3: 2 2.66667 3.33333 4 5.33333 4: 2.5 3.83333 5.16667 6.5 10.1667 5: 3 5 7 9 15 6: 3.5 6.5 9.5 12.5 23.5 7: 4 8 12 16 32 6 7 1: 1 1 2: 3.83333 4.5 3: 6.66667 8 4: 13.8333 17.5 5: 21 27 6: 34.5 45.5 7: 48 64 K = 2 1 2 3 4 5 1: 1.5 1.5 1.5 1.5 1.5 2: 2.25 2.75 3.25 3.75 4.75 3: 3 4 5 6 8 4: 3.75 5.75 7.75 9.75 15.25 5: 4.5 7.5 10.5 13.5 22.5 6: 5.25 9.75 14.25 18.75 35.25 7: 6 12 18 24 48 6 7 1: 1.5 1.5 2: 5.75 6.75 3: 10 12 4: 20.75 26.25 5: 31.5 40.5 6: 51.75 68.25 7: 72 96 K = 3 1 2 3 4 5 1: 2 2 2 2 2 2: 3 3.66667 4.33333 5 6.33333 3: 4 5.33333 6.66667 8 10.6667 4: 5 7.66667 10.3333 13 20.3333 5: 6 10 14 18 30 6: 7 13 19 25 47 7: 8 16 24 32 64 6 7 1: 2 2 2: 7.66667 9 3: 13.3333 16 4: 27.6667 35 5: 42 54 6: 69 91 7: 96 128 R8BLOCK_NEW_TEST: R8BLOCK_NEW dynamically creates a 3D array. Array entries can be addressed using the notation "a[i][j][k]". Allocating memory for array A of size 2 by 3 by 2. Assigning values to A. Dynamically allocated matrix A: 0 1 10 11 20 21 100 101 110 111 120 121 R8BLOCK_PRINT_TEST R8BLOCK_PRINT prints an R8BLOCK. The 3D array: K = 1 1 2 3 1: 1 1 1 2: 2 4 8 3: 3 9 27 4: 4 16 64 K = 2 1 2 3 1: 2 2 2 2: 4 8 16 3: 6 18 54 4: 8 32 128 R8CMAT_TO_R8MAT_NEW_TEST R8CMAT_TO_R8MAT_NEW converts an R8CMAT to an R8MAT. Data is of order (5,4. The R8MAT A: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 The R8CMAT B: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 The R8MAT C: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 R8COL_FIND_TEST R8COL_FIND finds a column in a table matching a given set of data. R8COL_FIND returns COL = 3 R8COL_INSERT_TEST R8COL_INSERT inserts new columns into a sorted R8COL. The unsorted matrix: Col: 0 1 2 3 Row 0: 2 4 1 3 1: 6 8 5 7 2: 10 12 9 11 The sorted matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 New column: 0: 3 1: 7 2: 11 The data was already in column 3 New column: 0: 3 1: 4 2: 18 The updated matrix: Col: 0 1 2 3 Row 0: 1 2 3 3 1: 5 6 4 7 2: 9 10 18 11 R8COL_SORT_HEAP_A_TEST R8COL_SORT_HEAP_A ascending heap sorts a table of columns. The unsorted matrix: Col: 0 1 2 3 Row 0: 2 4 1 3 1: 6 8 5 7 2: 10 12 9 11 The sorted matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 R8COL_SORT_HEAP_INDEX_A_TEST R8COL_SORT_HEAP_INDEX_A computes an index vector which ascending sorts an R8COL. The unsorted R8COL (transposed): Row: 0 1 2 Col 0: 2 6 10 1: 4 8 12 2: 1 5 9 3: 3 7 11 4: 2 6 0 5: 3 4 18 6: 0 0 0 7: 0 6 10 8: 2 6 10 9: 3 7 11 10: 2 0 10 11: 2 6 10 12: 1 5 9 13: 1 5 9.1 14: 1 5.1 9 The implicitly sorted R8COL (transposed) 6: 0 0 0 7: 0 6 10 12: 1 5 9 2: 1 5 9 13: 1 5 9.1 14: 1 5.1 9 10: 2 0 10 4: 2 6 0 11: 2 6 10 8: 2 6 10 0: 2 6 10 5: 3 4 18 9: 3 7 11 3: 3 7 11 1: 4 8 12 R8COL_SORT_QUICK_A_TEST R8COL_SORT_QUICK_A sorts a table of columns. The unsorted matrix: Col: 0 1 2 3 4 Row 0: 2.18418 5.61695 2.57578 6.33966 4.01306 1: 9.56318 4.15307 1.09957 0.617272 7.54673 2: 8.29509 0.661187 0.43829 4.49539 7.97287 Col: 5 6 7 8 9 Row 0: 0.0183837 0.945448 8.40847 2.60303 3.51629 1: 8.97504 0.136169 1.23104 9.12484 8.22887 2: 3.50752 8.59097 0.0751236 1.13664 2.67132 The sorted matrix: Col: 0 1 2 3 4 Row 0: 0.0183837 0.945448 2.18418 2.57578 2.60303 1: 8.97504 0.136169 9.56318 1.09957 9.12484 2: 3.50752 8.59097 8.29509 0.43829 1.13664 Col: 5 6 7 8 9 Row 0: 3.51629 4.01306 5.61695 6.33966 8.40847 1: 8.22887 7.54673 4.15307 0.617272 1.23104 2: 2.67132 7.97287 0.661187 4.49539 0.0751236 R8COL_SORTED_TOL_UNIQUE_TEST R8COL_SORTED_TOL_UNIQUE finds tolerably unique columns in a sorted R8COL. The unsorted R8COL (transposed): Row: 0 1 2 Col 0: 1.9 0 10 1: 2 6 10 2: 4 8 12 3: 1 5 9 4: 3 7 11 5: 2 6 0 6: 2 0 10.1 7: 2 0.1 10 8: 3 4 18 9: 1.9 8 10 10: 0 0 0 11: 0 6 10 12: 2.1 0 10 13: 2 6 10 14: 3 7 11 15: 2 0 10 16: 2 0 10 17: 2 6 10 18: 1 5 9 19: 2 0 10.1 20: 1 5 9.1 21: 1 5.1 9 The sorted R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1 5 9 4: 1 5 9.1 5: 1 5.1 9 6: 1.9 0 10 7: 1.9 8 10 8: 2 0 10 9: 2 0 10 10: 2 0 10.1 11: 2 0 10.1 12: 2 0.1 10 13: 2 6 0 14: 2 6 10 15: 2 6 10 16: 2 6 10 17: 2.1 0 10 18: 3 4 18 19: 3 7 11 20: 3 7 11 21: 4 8 12 Using tolerance = 0.25 Number of tolerably unique columns is 10 The sorted tolerably unique R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1.9 0 10 4: 1.9 8 10 5: 2 6 0 6: 2 6 10 7: 3 4 18 8: 3 7 11 9: 4 8 12 R8COL_SORTED_UNIQUE_COUNT_TEST R8COL_SORTED_UNIQUE_COUNT counts tolerably unique columns in a sorted R8COL. The unsorted R8COL (transposed): Row: 0 1 2 Col 0: 1.9 0 10 1: 2 6 10 2: 4 8 12 3: 1 5 9 4: 3 7 11 5: 2 6 0 6: 2 0 10.1 7: 2 0.1 10 8: 3 4 18 9: 1.9 8 10 10: 0 0 0 11: 0 6 10 12: 2.1 0 10 13: 2 6 10 14: 3 7 11 15: 2 0 10 16: 2 0 10 17: 2 6 10 18: 1 5 9 19: 2 0 10.1 20: 1 5 9.1 21: 1 5.1 9 The sorted R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1 5 9 4: 1 5 9.1 5: 1 5.1 9 6: 1.9 0 10 7: 1.9 8 10 8: 2 0 10 9: 2 0 10 10: 2 0 10.1 11: 2 0 10.1 12: 2 0.1 10 13: 2 6 0 14: 2 6 10 15: 2 6 10 16: 2 6 10 17: 2.1 0 10 18: 3 4 18 19: 3 7 11 20: 3 7 11 21: 4 8 12 Using tolerance = 0.25 Number of tolerably unique columns is 10 R8COL_SORTED_TOL_UNDEX_TEST R8COL_SORTED_TOL_UNDEX produces index vectors which create a sorted list of the tolerably unique columns of a sorted R8COL, and a map from the original R8COL to the (implicit) R8COL of sorted tolerably unique elements. The unsorted R8COL (transposed): Row: 0 1 2 Col 0: 1.9 0 10 1: 2 6 10 2: 4 8 12 3: 1 5 9 4: 3 7 11 5: 2 6 0 6: 2 0 10.1 7: 2 0.1 10 8: 3 4 18 9: 1.9 8 10 10: 0 0 0 11: 0 6 10 12: 2.1 0 10 13: 2 6 10 14: 3 7 11 15: 2 0 10 16: 2 0 10 17: 2 6 10 18: 1 5 9 19: 2 0 10.1 20: 1 5 9.1 21: 1 5.1 9 The sorted R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1 5 9 4: 1 5 9.1 5: 1 5.1 9 6: 1.9 0 10 7: 1.9 8 10 8: 2 0 10 9: 2 0 10 10: 2 0 10.1 11: 2 0 10.1 12: 2 0.1 10 13: 2 6 0 14: 2 6 10 15: 2 6 10 16: 2 6 10 17: 2.1 0 10 18: 3 4 18 19: 3 7 11 20: 3 7 11 21: 4 8 12 Using tolerance = 0.25 Number of tolerably unique columns is 10 XDNU points to the representative for each item. UNDX selects the representatives. I XDNU UNDX 0 0 0 1 1 1 2 2 2 3 2 6 4 2 7 5 2 13 6 3 14 7 4 18 8 3 19 9 3 21 10 3 11 3 12 3 13 5 14 6 15 6 16 6 17 3 18 7 19 8 20 8 21 9 The tolerably unique R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1.9 0 10 4: 1.9 8 10 5: 2 6 0 6: 2 6 10 7: 3 4 18 8: 3 7 11 9: 4 8 12 R8COL_MAX_TEST R8COL_MAX computes maximums of an R8COL; The array: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Column maximums: 0: 9 1: 10 2: 11 3: 12 R8COL_MEAN_TEST R8COL_MEAN computes means of an R8COL; The array: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 The column means: 0: 5 1: 6 2: 7 3: 8 R8COL_MIN_TEST R8COL_MIN computes minimums of an R8COL; The array: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Column minimums: 0: 1 1: 2 2: 3 3: 4 R8COL_PERMUTE_TEST R8COL_PERMUTE permutes an R8COL in place. A (unpermuted): Col: 0 1 2 3 4 Row 0: 11 12 13 14 15 1: 21 22 23 24 25 2: 31 32 33 34 35 The (column) permutation vector: 0: 1 1: 3 2: 4 3: 0 4: 2 A (permuted): Col: 0 1 2 3 4 Row 0: 12 14 15 11 13 1: 22 24 25 21 23 2: 32 34 35 31 33 R8COL_SORTR_A_TEST R8COL_SORTR_A is given an array, and reorders it so that a particular column is sorted. Here, the special column is 2 Unsorted array: Col: 0 1 2 Row 0: 2.18418 0.617272 8.59097 1: 9.56318 4.49539 8.40847 2: 8.29509 4.01306 1.23104 3: 5.61695 7.54673 0.0751236 4: 4.15307 7.97287 2.60303 5: 0.661187 0.0183837 9.12484 6: 2.57578 8.97504 1.13664 7: 1.09957 3.50752 3.51629 8: 0.43829 0.945448 8.22887 9: 6.33966 0.136169 2.67132 Sorted array: Col: 0 1 2 Row 0: 0.661187 0.0183837 9.12484 1: 6.33966 0.136169 2.67132 2: 2.18418 0.617272 8.59097 3: 0.43829 0.945448 8.22887 4: 1.09957 3.50752 3.51629 5: 8.29509 4.01306 1.23104 6: 9.56318 4.49539 8.40847 7: 5.61695 7.54673 0.0751236 8: 4.15307 7.97287 2.60303 9: 2.57578 8.97504 1.13664 R8COL_SUM_TEST R8COL_SUM computes sums of an R8COL; The array: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 The column sums 0: 15 1: 18 2: 21 3: 24 R8COL_SWAP_TEST R8COL_SWAP swaps two columns of an R8COL; The array: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 Swap columns 1 and 3: The updated matrix: Col: 0 1 2 3 Row 0: 13 12 11 14 1: 23 22 21 24 2: 33 32 31 34 R8COL_TO_R8VEC_TEST R8COL_TO_R8VEC converts an array of columns to a vector. The array of columns: Col: 0 1 2 3 Row 0: 0 1 2 3 1: 10 11 12 13 2: 20 21 22 23 The resulting vector of columns: 0: 0 1: 10 2: 20 3: 1 4: 11 5: 21 6: 2 7: 12 8: 22 9: 3 10: 13 11: 23 R8COL_TOL_UNDEX_TEST R8COL_TOL_UNDEX produces index vectors which create a sorted list of the tolerably unique columns of an R8COL, and a map from the original R8COL to the (implicit) R8COL of sorted tolerably unique elements. The unsorted R8COL (transposed): Row: 0 1 2 Col 0: 1.9 0 10 1: 2 6 10 2: 4 8 12 3: 1 5 9 4: 3 7 11 5: 2 6 0 6: 2 0 10.1 7: 2 0.1 10 8: 3 4 18 9: 1.9 8 10 10: 0 0 0 11: 0 6 10 12: 2.1 0 10 13: 2 6 10 14: 3 7 11 15: 2 0 10 16: 2 0 10 17: 2 6 10 18: 1 5 9 19: 2 0 10.1 20: 1 5 9.1 21: 1 5.1 9 Using tolerance = 0.25 Number of tolerably unique columns is 10 XDNU points to the representative for each item. UNDX selects the representatives. I XDNU UNDX 0 3 10 1 6 11 2 9 18 3 2 0 4 8 9 5 5 5 6 3 13 7 3 8 8 7 14 9 4 2 10 0 11 1 12 3 13 6 14 8 15 3 16 3 17 6 18 2 19 3 20 2 21 2 The tolerably unique R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1.9 0 10 4: 1.9 8 10 5: 2 6 0 6: 2 6 10 7: 3 4 18 8: 3 7 11 9: 4 8 12 R8COL_UNDEX_TEST R8COL_UNDEX produces index vectors which create a sorted list of the unique columns of an (unsorted) R8COL, and a map from the original R8COL to the (implicit) R8COL of sorted unique elements. The R8COL (transposed): Row: 0 1 2 Col 0: 1.9 0 10 1: 2 6 10 2: 4 8 12 3: 1 5 9 4: 3 7 11 5: 2 6 0 6: 2 0 10.1 7: 2 0.1 10 8: 3 4 18 9: 1.9 8 10 10: 0 0 0 11: 0 6 10 12: 2.1 0 10 13: 2 6 10 14: 3 7 11 15: 2 0 10 16: 2 0 10 17: 2 6 10 18: 1 5 9 19: 2 0 10.1 20: 1 5 9.1 21: 1 5.1 9 Number of unique columns is 16 XDNU points to the representative for each item. UNDX selects the representatives. I XDNU UNDX 0 5 10 1 11 11 2 15 18 3 2 20 4 14 21 5 10 0 6 8 9 7 9 15 8 13 6 9 6 7 10 0 5 11 1 13 12 12 12 13 11 8 14 14 14 15 7 2 16 7 17 11 18 2 19 8 20 3 21 4 The Unique R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1 5 9.1 4: 1 5.1 9 5: 1.9 0 10 6: 1.9 8 10 7: 2 0 10 8: 2 0 10.1 9: 2 0.1 10 10: 2 6 0 11: 2 6 10 12: 2.1 0 10 13: 3 4 18 14: 3 7 11 15: 4 8 12 R8COL_UNIQUE_COUNT_TEST R8COL_UNIQUE_COUNT counts unique columns. The R8COL (transposed): Row: 0 1 2 Col 0: 1.9 0 10 1: 2 6 10 2: 4 8 12 3: 1 5 9 4: 3 7 11 5: 2 6 0 6: 2 0 10.1 7: 2 0.1 10 8: 3 4 18 9: 1.9 8 10 10: 0 0 0 11: 0 6 10 12: 2.1 0 10 13: 2 6 10 14: 3 7 11 15: 2 0 10 16: 2 0 10 17: 2 6 10 18: 1 5 9 19: 2 0 10.1 20: 1 5 9.1 21: 1 5.1 9 Number of unique columns is 16 R8COL_VARIANCE_TEST R8COL_VARIANCE computes variances of an R8COL; The array: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Column variance: 0 16 1 16 2 16 3 16 R8INT_TO_I4INT_TEST For data in an interval, R8INT_TO_I4INT converts a real to an integer. Integer interval: [1, 11] Real interval: [100, 200] R I(R) R(I(R)) 113.394 2 110 209.321 12 210 192.836 10 190 158.02 7 160 138.99 5 140 93.5954 0 90 118.485 3 120 99.2944 1 100 90.6978 0 90 167.416 8 170 R8MAT_CHOLESKY_INVERSE_TEST For a positive definite symmetric matrix, R8MAT_CHOLESKY_INVERSE computes the inverse. Matrix to be inverted: Col: 0 1 2 3 4 Row 0: 2 -1 0 0 0 1: -1 2 -1 0 0 2: 0 -1 2 -1 0 3: 0 0 -1 2 -1 4: 0 0 0 -1 2 Inverse matrix: Col: 0 1 2 3 4 Row 0: 0.833333 0.666667 0.5 0.333333 0.166667 1: 0.666667 1.33333 1 0.666667 0.333333 2: 0.5 1 1.5 1 0.5 3: 0.333333 0.666667 1 1.33333 0.666667 4: 0.166667 0.333333 0.5 0.666667 0.833333 Product inv(A) * A: Col: 0 1 2 3 4 Row 0: 1 2.22045e-16 0 -1.11022e-16 0 1: -6.66134e-16 1 2.22045e-16 -1.66533e-16 -1.11022e-16 2: -6.66134e-16 1.11022e-15 1 -2.22045e-16 0 3: -4.44089e-16 6.66134e-16 0 1 0 4: -1.66533e-16 2.22045e-16 0 -2.22045e-16 1 R8MAT_CHOLESKY_SOLVE_TEST For a positive definite symmetric matrix, R8MAT_CHOLESKY_SOLVE solves a linear system using the lower Cholesky factorization. Matrix to be factored: Col: 0 1 2 3 4 Row 0: 2 -1 0 0 0 1: -1 2 -1 0 0 2: 0 -1 2 -1 0 3: 0 0 -1 2 -1 4: 0 0 0 -1 2 Cholesky factor L: Col: 0 1 2 3 4 Row 0: 1.41421 0 0 0 0 1: -0.707107 1.22474 0 0 0 2: 0 -0.816497 1.1547 0 0 3: 0 0 -0.866025 1.11803 0 4: 0 0 0 -0.894427 1.09545 Product L * L': Col: 0 1 2 3 4 Row 0: 2 -1 0 0 0 1: -1 2 -1 0 0 2: 0 -1 2 -1 0 3: 0 0 -1 2 -1 4: 0 0 0 -1 2 Right hand side: 0: 0 1: 0 2: 0 3: 0 4: 6 Computed solution: 0: 1 1: 2 2: 3 3: 4 4: 5 R8MAT_CHOLESKY_SOLVE_UPPER_TEST For a positive definite symmetric matrix, R8MAT_CHOLESKY_SOLVE_UPPER solves a linear system using the upper Cholesky factorization. Matrix to be factored: Col: 0 1 2 3 4 Row 0: 2 -1 0 0 0 1: -1 2 -1 0 0 2: 0 -1 2 -1 0 3: 0 0 -1 2 -1 4: 0 0 0 -1 2 Cholesky factor R: Col: 0 1 2 3 4 Row 0: 1.41421 -0.707107 0 0 0 1: 0 1.22474 -0.816497 0 0 2: 0 0 1.1547 -0.866025 0 3: 0 0 0 1.11803 -0.894427 4: 0 0 0 0 1.09545 Product R' * R: Col: 0 1 2 3 4 Row 0: 2 -1 0 0 0 1: -1 2 -1 0 0 2: 0 -1 2 -1 0 3: 0 0 -1 2 -1 4: 0 0 0 -1 2 Right hand side: 0: 0 1: 0 2: 0 3: 0 4: 6 Computed solution: 0: 1 1: 2 2: 3 3: 4 4: 5 R8MAT_DET_2D_TEST R8MAT_DET_2D: determinant of a 2 by 2 matrix; Matrix: Col: 0 1 Row 0: 1 1 1: 1 10 R8MAT_DET_2D computes determinant:9 Exact determinant is 9 R8MAT_DET_3D_TEST R8MAT_DET_3D: determinant of a 3 by 3 matrix; Matrix: Col: 0 1 2 Row 0: 1 1 1 1: 1 10 100 2: 1 4 16 R8MAT_DET_3D computes determinant:-162 Exact determinant is -162 R8MAT_DET_4D_TEST R8MAT_DET_4D determinant of a 4 by 4 matrix; Matrix: Col: 0 1 2 3 Row 0: 1 1 1 1 1: 1 10 100 1000 2: 1 4 16 64 3: 1 2 4 8 R8MAT_DET_4D computes determinant:-2592 Exact determinant is -2592 R8MAT_DET_5D_TEST R8MAT_DET_5D determinant of a 5 by 5 matrix; Matrix: Col: 0 1 2 3 4 Row 0: 1 1 1 1 1 1: 1 10 100 1000 10000 2: 1 4 16 64 256 3: 1 2 4 8 16 4: 1 3 9 27 81 R8MAT_DET_5D computes determinant:-36288 Exact determinant is -36288 R8MAT_EXPAND_LINEAR_TEST R8MAT_EXPAND_LINEAR linearly interpolates new data between old values in a matrix. Original matrix: Col: 0 1 2 Row 0: 1 1 1 1: 2 4 8 2: 3 9 27 3: 4 16 64 MFAT = 2 NFAT = 1 Fattened matrix: Col: 0 1 2 3 4 Row 0: 1 1 1 1 1 1: 1.33333 1.66667 2 2.66667 3.33333 2: 1.66667 2.33333 3 4.33333 5.66667 3: 2 3 4 6 8 4: 2.33333 4 5.66667 10 14.3333 5: 2.66667 5 7.33333 14 20.6667 6: 3 6 9 18 27 7: 3.33333 7.33333 11.3333 25.3333 39.3333 8: 3.66667 8.66667 13.6667 32.6667 51.6667 9: 4 10 16 40 64 R8MAT_EXPAND_LINEAR2_TEST R8MAT_EXPAND_LINEAR2 fills in a large array by interpolating data from a small array. Original matrix has dimensions: M = 3, N = 2 Expanded matrix has dimensions: M2 = 10, N2 = 5 The little matrix A: Col: 0 1 Row 0: 11 12 1: 21 22 2: 31 32 Expanded array A2: Col: 0 1 2 3 4 Row 0: 11 11.25 11.5 11.75 12 1: 13.2222 13.4722 13.7222 13.9722 14.2222 2: 15.4444 15.6944 15.9444 16.1944 16.4444 3: 17.6667 17.9167 18.1667 18.4167 18.6667 4: 19.8889 20.1389 20.3889 20.6389 20.8889 5: 22.1111 22.3611 22.6111 22.8611 23.1111 6: 24.3333 24.5833 24.8333 25.0833 25.3333 7: 26.5556 26.8056 27.0556 27.3056 27.5556 8: 28.7778 29.0278 29.2778 29.5278 29.7778 9: 31 31.25 31.5 31.75 32 R8MAT_FS_NEW_TEST For a matrix in general storage, R8MAT_FS_NEW factors and solves a linear system. Matrix order N = 10 Solution: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 R8MAT_FSS_NEW_TEST For a matrix in general storage, R8MAT_FSS_NEW factors and solves multiple linear systems. Matrix order N = 10 Number of systems NB = 3 Solutions: Col: 0 1 2 Row 0: 1 1 1 1: 1 2 2 2: 1 3 3 3: 1 4 1 4: 1 5 2 5: 1 6 3 6: 1 7 1 7: 1 8 2 8: 1 9 3 9: 1 10 1 R8MAT_GIVENS_POST_TEST R8MAT_GIVENS_POST computes a Givens postmultiplier rotation matrix. Matrix A: Col: 0 1 2 Row 0: 1 1 1 1: 1 2 4 2: 1 3 9 I = 3 J = 2 G Col: 0 1 2 Row 0: 1 0 0 1: 0 0.948683 0.316228 2: 0 -0.316228 0.948683 A*G Col: 0 1 2 Row 0: 1 0.632456 1.26491 1: 1 0.632456 4.42719 2: 1 -4.44089e-16 9.48683 R8MAT_GIVENS_PRE_TEST R8MAT_GIVENS_PRE computes a Givens premultiplier rotation matrix. Matrix A: Col: 0 1 2 Row 0: 1 1 1 1: 1 2 4 2: 1 3 9 I = 3 J = 2 G Col: 0 1 2 Row 0: 1 0 0 1: 0 0.5547 0.83205 2: 0 -0.83205 0.5547 G*A Col: 0 1 2 Row 0: 1 1 1 1: 1.38675 3.60555 9.70725 2: -0.27735 0 1.6641 R8MAT_HESS_TEST R8MAT_HESS estimates the Hessian matrix of a scalar function. Estimated jacobian: Col: 0 1 2 Row 0: 2 1 0 1: 1 2.381e-06 9.88032 2: 0 9.88032 -30.8503 Exact jacobian: Col: 0 1 2 Row 0: 2 1 0 1: 1 0 9.88032 2: 0 9.88032 -30.8503 R8MAT_HOUSE_AXH_TEST R8MAT_HOUSE_AXH multiplies a matrix A times a compact Householder matrix. Matrix A: Col: 0 1 2 3 4 Row 0: -2.81582 -4.33881 -4.38273 -4.98162 3.59097 1: 4.56318 -2.42422 -0.50461 3.97504 3.40847 2: 3.29509 -3.90043 -0.986937 -1.49248 -3.76896 3: 0.616954 -4.56171 2.54673 -4.05455 -4.92488 4: -0.846929 1.33966 2.97287 -4.86383 -2.39697 Compact vector V so H*A packs column 3: 0: 0 1: 0 2: -0.788819 3: 0.399863 4: 0.466771 Householder matrix H: Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: 0 1 0 0 0 2: 0 0 -0.244469 0.630839 0.736395 3: 0 0 0.630839 0.680219 -0.373289 4: 0 0 0.736395 -0.373289 0.56425 Indirect product A*H: Col: 0 1 2 3 4 Row 0: -2.81582 -4.33881 0.573215 -7.49385 0.65837 1: 4.56318 -2.42422 5.14095 1.11322 0.0678026 2: 3.29509 -3.90043 -3.47568 -0.230898 -2.29629 3: 0.616954 -4.56171 -6.80702 0.686997 0.610057 4: -0.846929 1.33966 -5.56019 -0.538306 2.65233 Direct product A*H: Col: 0 1 2 3 4 Row 0: -2.81582 -4.33881 0.573215 -7.49385 0.65837 1: 4.56318 -2.42422 5.14095 1.11322 0.0678026 2: 3.29509 -3.90043 -3.47568 -0.230898 -2.29629 3: 0.616954 -4.56171 -6.80702 0.686997 0.610057 4: -0.846929 1.33966 -5.56019 -0.538306 2.65233 H*A should have packed column 3: Col: 0 1 2 3 4 Row 0: -2.81582 -4.33881 -4.38273 -4.98162 3.59097 1: 4.56318 -2.42422 -0.50461 3.97504 3.40847 2: -1.04002 -0.937652 4.03706 -5.7746 -3.95052 3: 2.81449 -6.06358 -2.22045e-16 -1.88388 -4.83284 4: 1.71831 -0.41352 0 -2.32995 -2.28953 R8MAT_HOUSE_FORM_TEST R8MAT_HOUSE_FORM forms a Householder matrix from its compact form. Compact vector form V: 0: 0 1: 0 2: 1 3: 2 4: 3 Householder matrix H: Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: 0 1 0 0 0 2: 0 0 0.857143 -0.285714 -0.428571 3: 0 0 -0.285714 0.428571 -0.857143 4: 0 0 -0.428571 -0.857143 -0.285714 R8MAT_HOUSE_POST_TEST R8MAT_HOUSE_POST computes a Householder postmultiplier; Matrix A: Col: 0 1 2 3 4 Row 0: 1.09209 0.330594 0.308636 0.00919186 4.29548 1: 4.78159 1.28789 2.24769 4.48752 4.20424 2: 4.14755 0.549784 2.00653 1.75376 0.61552 3: 2.80848 0.219145 3.77337 0.472724 0.0375618 4: 2.07654 3.16983 3.98643 0.0680845 1.30151 I = 2 J = 3 Householder matrix H: Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: 0 1 0 0 0 2: 0 0 -0.733626 -0.641208 -0.225046 3: 0 0 -0.641208 0.762839 -0.0832366 4: 0 0 -0.225046 -0.0832366 0.970786 Product A*H: Col: 0 1 2 3 4 Row 0: 1.09209 0.330594 -1.199 -0.548429 4.09978 1: 4.78159 1.28789 -5.47255 1.63207 3.20206 2: 4.14755 0.549784 -2.73509 -2.08167e-16 -1.11022e-16 3: 2.80848 0.219145 -3.07981 -2.06203 -0.852063 4: 2.07654 3.16983 -3.26111 -2.61253 0.360697 R8MAT_HOUSE_PRE_TEST R8MAT_HOUSE_PRE computes a Householder premultiplier; Matrix A: Col: 0 1 2 3 4 Row 0: 1.09209 0.330594 0.308636 0.00919186 4.29548 1: 4.78159 1.28789 2.24769 4.48752 4.20424 2: 4.14755 0.549784 2.00653 1.75376 0.61552 3: 2.80848 0.219145 3.77337 0.472724 0.0375618 4: 2.07654 3.16983 3.98643 0.0680845 1.30151 I = 2 J = 3 Householder matrix H: Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: 0 -0.926857 -0.362224 -0.0976368 -0.0140622 2: 0 -0.362224 0.931907 -0.0183544 -0.00264351 3: 0 -0.0976368 -0.0183544 0.995053 -0.000712555 4: 0 -0.0140622 -0.00264351 -0.000712555 0.999897 Product H*A: Col: 0 1 2 3 4 Row 0: 1.09209 0.330594 0.308636 0.00919186 4.29548 1: -6.2376 -1.4588 -3.23458 -4.84165 -4.14165 2: 2.07608 0.0334418 0.975936 -1.96918e-16 -0.953397 3: 2.25012 0.0799658 3.49557 -3.43895e-17 -0.385337 4: 1.99612 3.14978 3.94643 0 1.24061 R8MAT_INDICATOR_NEW_TEST R8MAT_INDICATOR_NEW returns an indicator matrix. The indicator matrix: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 R8MAT_INVERSE_2D_TEST R8MAT_INVERSE_2D inverts a 2 by 2 matrix. Matrix A: Col: 0 1 Row 0: 1 2 1: 3 4 Inverse matrix B: Col: 0 1 Row 0: -2 1 1: 1.5 -0.5 C = A * B: Col: 0 1 Row 0: 1 0 1: 0 1 R8MAT_INVERSE_3D_TEST R8MAT_INVERSE_3D inverts a 3 by 3 matrix. Matrix A: Col: 0 1 2 Row 0: 3 2 1 1: 2 2 1 2: 0 1 1 Inverse matrix B: Col: 0 1 2 Row 0: 1 -1 0 1: -2 3 -1 2: 2 -3 2 C = A * B: Col: 0 1 2 Row 0: 1 0 0 1: 0 1 0 2: 0 0 1 R8MAT_INVERSE_4D_TEST R8MAT_INVERSE_4D inverts a 4 x 4 matrix. Matrix A: Col: 0 1 2 3 Row 0: 4 3 2 1 1: 3 3 2 1 2: 0 2 2 1 3: 0 0 1 1 Inverse matrix B: Col: 0 1 2 3 Row 0: 1 -1 0 -0 1: -3 4 -1 0 2: 6 -8 3 -1 3: -6 8 -3 2 C = A * B: Col: 0 1 2 3 Row 0: 1 0 0 0 1: 0 1 0 0 2: 0 0 1 0 3: 0 0 0 1 R8MAT_JAC_TEST R8MAT_JAC estimates the M by N jacobian matrix of a nonlinear function. Estimated jacobian: Col: 0 1 2 3 Row 0: -0.83233 -0.41616 0 0 1: 0.70711 0 1 0 2: 1 2 3 4 Exact jacobian: Col: 0 1 2 3 Row 0: -0.832294 -0.416147 0 0 1: 0.707107 0 1 0 2: 1 2 3 4 R8MAT_KRONECKER_TEST R8MAT_KRONECKER computes the Kronecker product of two R8MAT's. Factor matrix A: Col: 0 1 2 Row 0: 1 2 3 1: 4 5 6 Factor matrix B: Col: 0 1 Row 0: 7 8 1: 9 10 2: 11 12 Kronecker product C = kron(A,B) Col: 0 1 2 3 4 Row 0: 7 8 14 16 21 1: 9 10 18 20 27 2: 11 12 22 24 33 3: 28 32 35 40 42 4: 36 40 45 50 54 5: 44 48 55 60 66 Col: 5 Row 0: 24 1: 30 2: 36 3: 48 4: 60 5: 72 R8MAT_L_INVERSE_TEST R8MAT_L_INVERSE inverts a lower triangular R8MAT. Matrix A to be inverted: Col: 0 1 2 3 Row 0: 1 0 0 0 1: 2 3 0 0 2: 4 5 6 0 3: 7 8 9 10 Inverse matrix B: Col: 0 1 2 3 Row 0: 1 0 0 0 1: -0.666667 0.333333 0 0 2: -0.111111 -0.277778 0.166667 0 3: -0.0666667 -0.0166667 -0.15 0.1 Product C = A * B: Col: 0 1 2 3 Row 0: 1 0 0 0 1: 0 1 0 0 2: 0 0 1 0 3: 0 0 0 1 R8MAT_L_PRINT_TEST R8MAT_L_PRINT prints a lower triangular R8MAT stored compactly. Only the (possibly) nonzero elements are printed. A 7 by 7 matrix. Col 1 2 3 4 5 6 7 Row 1 11 2 21 22 3 31 32 33 4 41 42 43 44 5 51 52 53 54 55 6 61 62 63 64 65 66 7 71 72 73 74 75 76 77 A 7 by 3 matrix. Col 1 2 3 Row 1 11 2 21 22 3 31 32 33 4 41 42 43 5 51 52 53 6 61 62 63 7 71 72 73 A 4 by 7 matrix. Col 1 2 3 4 Row 1 11 2 21 22 3 31 32 33 4 41 42 43 44 R8MAT_L1_INVERSE_TEST R8MAT_L1_INVERSE inverts a unit lower triangular R8MAT. Matrix A to be inverted: Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: 2 1 0 0 0 2: 0 0 1 0 0 3: 5 0 3 1 0 4: 0 0 0 0 1 5: 75 0 0 6 4 Col: 5 Row 0: 0 1: 0 2: 0 3: 0 4: 0 5: 1 Inverse matrix B: Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: -2 1 0 0 0 2: 0 0 1 0 0 3: -5 0 -3 1 0 4: 0 0 0 0 1 5: -45 0 18 -6 -4 Col: 5 Row 0: 0 1: 0 2: 0 3: 0 4: 0 5: 1 Product C = A * B: Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: 0 1 0 0 0 2: 0 0 1 0 0 3: 0 0 0 1 0 4: 0 0 0 0 1 5: 0 0 0 0 0 Col: 5 Row 0: 0 1: 0 2: 0 3: 0 4: 0 5: 1 R8MAT_LU_TEST R8MAT_LU computes the LU factors of an R8MAT. Matrix to be factored: Col: 0 1 2 3 4 Row 0: 1 1 1 1 1 1: 1 10 100 1000 10000 2: 1 4 16 64 256 3: 1 2 4 8 16 4: 1 3 9 27 81 P factor: Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: 0 1 0 0 0 2: 0 0 1 0 0 3: 0 0 0 1 0 4: 0 0 0 0 1 L factor: Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: 1 1 0 0 0 2: 1 0.333333 1 0 0 3: 1 0.111111 0.444444 1 0 4: 1 0.222222 0.777778 0.875 1 U factor: Col: 0 1 2 3 4 Row 0: 1 1 1 1 1 1: 0 9 99 999 9999 2: 0 0 -18 -270 -3078 3: 0 0 0 16 272 4: 0 0 0 0 14 P*L*U: Col: 0 1 2 3 4 Row 0: 1 1 1 1 1 1: 1 10 100 1000 10000 2: 1 4 16 64 256 3: 1 2 4 8 16 4: 1 3 9 27 81 R8MAT_MAX_TEST R8MAT_MAX computes the maximum value of an R8MAT. Random array: Col: 0 1 2 Row 0: 2.18418 0.661187 0.617272 1: 9.56318 2.57578 4.49539 2: 8.29509 1.09957 4.01306 3: 5.61695 0.43829 7.54673 4: 4.15307 6.33966 7.97287 Maximum value = 9.56318 R8MAT_MAX_INDEX_TEST R8MAT_MAX_INDEX locates the maximum entry of an R8MAT; Random array: Col: 0 1 2 Row 0: 2.18418 0.661187 0.617272 1: 9.56318 2.57578 4.49539 2: 8.29509 1.09957 4.01306 3: 5.61695 0.43829 7.54673 4: 4.15307 6.33966 7.97287 Maximum I,J indices 2 1 R8MAT_MAXCOL_MINROW_TEST R8MAT_MAXCOL_MINROW computes the maximum over columns of the mininum over rows; Random array: Col: 0 1 2 Row 0: 2.18418 0.661187 0.617272 1: 9.56318 2.57578 4.49539 2: 8.29509 1.09957 4.01306 3: 5.61695 0.43829 7.54673 4: 4.15307 6.33966 7.97287 MAXCOL_MINROW = 4.15307 R8MAT_MAXROW_MINCOL_TEST R8MAT_MAXROW_MINCOL computes the maximum over rows of the mininum over columns; Random array: Col: 0 1 2 Row 0: 2.18418 0.661187 0.617272 1: 9.56318 2.57578 4.49539 2: 8.29509 1.09957 4.01306 3: 5.61695 0.43829 7.54673 4: 4.15307 6.33966 7.97287 MAXROW_MINCOL = 2.18418 R8MAT_MIN_TESTn For a real matrix, R8MAT_MIN computes the minimum value; Random array: Col: 0 1 2 Row 0: 2.18418 0.661187 0.617272 1: 9.56318 2.57578 4.49539 2: 8.29509 1.09957 4.01306 3: 5.61695 0.43829 7.54673 4: 4.15307 6.33966 7.97287 Minimum value = 0.43829 R8MAT_MIN_INDEX_TEST R8MAT_MIN_INDEX locates the minimum entry of an R8MAT; Random array: Col: 0 1 2 Row 0: 2.18418 0.661187 0.617272 1: 9.56318 2.57578 4.49539 2: 8.29509 1.09957 4.01306 3: 5.61695 0.43829 7.54673 4: 4.15307 6.33966 7.97287 Minimum I,J indices 4 2 R8MAT_MINCOL_MAXROW_TEST R8MAT_MINCOL_MAXROW computes the minimum over columns of the maxinum over rows; Random array: Col: 0 1 2 Row 0: 2.18418 0.661187 0.617272 1: 9.56318 2.57578 4.49539 2: 8.29509 1.09957 4.01306 3: 5.61695 0.43829 7.54673 4: 4.15307 6.33966 7.97287 MINCOL_MAXROW = 2.18418 R8MAT_MINROW_MAXCOL_TEST R8MAT_MINROW_MAXCOL computes the minimum over rows of the maxinum over columns; Random array: Col: 0 1 2 Row 0: 2.18418 0.661187 0.617272 1: 9.56318 2.57578 4.49539 2: 8.29509 1.09957 4.01306 3: 5.61695 0.43829 7.54673 4: 4.15307 6.33966 7.97287 MINROW_MAXCOL = 6.33966 R8MAT_MM_TEST R8MAT_MM multiplies two (rectangular) matrices and returns the result as an argument. Matrix A: Col: 0 1 2 Row 0: 1 2 3 1: 4 5 6 Matrix B: Col: 0 1 2 3 Row 0: 1 4 0 -1 1: 2 5 0 2 2: 3 6 1 -1 Product C = A * B: Col: 0 1 2 3 Row 0: 14 32 3 0 1: 32 77 6 0 R8MAT_MM_NEW_TEST R8MAT_MM_NEW multiplies two (rectangular) matrices and returns the result as the function value. Matrix A: Col: 0 1 2 Row 0: 1 2 3 1: 4 5 6 Matrix B: Col: 0 1 2 3 Row 0: 1 4 0 -1 1: 2 5 0 2 2: 3 6 1 -1 Product C = A * B: Col: 0 1 2 3 Row 0: 14 32 3 0 1: 32 77 6 0 R8MAT_MV_NEW_TEST R8MAT_MV_NEW multiplies a (rectangular) matrix times a vector, and returns the result as the function value. Matrix A: Col: 0 1 2 Row 0: 1 2 3 1: 4 5 6 Vector B: 0: 1 1: 2 2: 3 Product C = A * B: 0: 14 1: 32 R8MAT_MV_TEST R8MAT_MV multiplies a (rectangular) matrix times a vector, and returns the result as an argument. Matrix A: Col: 0 1 2 Row 0: 1 2 3 1: 4 5 6 Vector B: 0: 1 1: 2 2: 3 Product C = A * B: 0: 14 1: 32 R8MAT_MTV_NEW_TEST R8MAT_MTV_NEW multiplies a transposed matrix times a vector, and returns the result as the function value. Matrix A: Col: 0 1 2 Row 0: 1 2 3 1: 4 5 6 Vector B: 0: 1 1: 2 Product C = A' * B: 0: 9 1: 12 2: 15 R8MAT_MTV_TEST R8MAT_MTV multiplies a transposed matrix times a vector, and returns the result as an argument. Matrix A: Col: 0 1 2 Row 0: 1 2 3 1: 4 5 6 Vector B: 0: 1 1: 2 Product C = A' * B: 0: 9 1: 12 2: 15 R8MAT_NINT_TEST R8MAT_NINT rounds an R8MAT. Matrix A: Col: 0 1 2 3 Row 0: -2.81582 -4.33881 -4.38273 -4.98162 1: 4.56318 -2.42422 -0.50461 3.97504 2: 3.29509 -3.90043 -0.986937 -1.49248 3: 0.616954 -4.56171 2.54673 -4.05455 4: -0.846929 1.33966 2.97287 -4.86383 Rounded matrix A: Col: 0 1 2 3 Row 0: -3 -4 -4 -5 1: 5 -2 -1 4 2: 3 -4 -1 -1 3: 1 -5 3 -4 4: -1 1 3 -5 R8MAT_NONZEROS_TEST R8MAT_NONZEROS counts nonzeros in an R8MAT. Matrix A: Col: 0 1 2 3 Row 0: 1 0 1 0 1: 0 0 0 0 2: 1 0 1 0 3: 0 0 0 0 4: 1 0 1 0 Expected nonzeros = 6 Computed nonzeros = 6 R8MAT_NORM_FRO_TEST R8MAT_NORM_FRO computes the Frobenius norm of a matrix. Matrix A: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 3: 13 14 15 16 4: 17 18 19 20 Expected Frobenius norm = 53.5724 Computed Frobenius norm = 53.5724 R8MAT_NORM_L1_TEST R8MAT_NORM_L1 computes the L1 norm of a matrix. Matrix A: Col: 0 1 2 3 Row 0: -3 -4 -4 -5 1: 5 -2 -1 4 2: 3 -4 -1 -1 3: 1 -5 3 -4 4: -1 1 3 -5 L1 norm = 19 R8MAT_NULLSPACE_TEST R8MAT_NULLSPACE computes the nullspace of a matrix. Input A: Col: 0 1 2 3 4 Row 0: 1 3 0 2 6 1: -2 -6 0 -2 -8 2: 3 9 0 0 6 3: -1 -3 0 1 0 Col: 5 6 Row 0: 3 1 1: 3 1 2: 6 2 3: 9 3 Nullspace size is 4 Nullspace vectors: Col: 0 1 2 3 Row 0: -3 0 -2 0 1: 1 0 0 0 2: 0 1 0 0 3: 0 0 -2 0 4: 0 0 1 0 5: 0 0 0 -0.333333 6: 0 0 0 1 Product A * Nullspace vectors: Col: 0 1 2 3 Row 0: 0 0 0 0 1: 0 0 0 0 2: 0 0 0 0 3: 0 0 0 0 R8MAT_NULLSPACE_SIZE_TEST R8MAT_NULLSPACE_SIZE computes the size of the nullspace of a matrix. Input A: Col: 0 1 2 3 4 Row 0: 1 3 0 2 6 1: -2 -6 0 -2 -8 2: 3 9 0 0 6 3: -1 -3 0 1 0 Col: 5 6 Row 0: 3 1 1: 3 1 2: 6 2 3: 9 3 Nullspace size is 4 R8MAT_ORTH_UNIFORM_NEW_TEST R8MAT_ORTH_UNIFORM_NEW computes a random orthogonal matrix. Random orthogonal matrix A Col: 0 1 2 3 4 Row 0: -0.559743 -0.371903 -0.0337166 0.68224 0.285986 1: 0.188708 -0.906112 0.0432361 -0.368531 0.0752686 2: -0.404357 -0.0795868 -0.732356 -0.200174 -0.503733 3: -0.423174 0.184571 -0.114406 -0.542494 0.692437 4: 0.555425 0.0157436 -0.668999 0.253702 0.423476 AT*A Col: 0 1 2 3 4 Row 0: 1 -2.60209e-17 -1.66533e-16 5.55112e-17 2.22045e-16 1: -2.60209e-17 1 -2.60209e-17 -2.68882e-17 3.03577e-17 2: -1.66533e-16 -2.60209e-17 1 -1.94289e-16 -2.22045e-16 3: 5.55112e-17 -2.68882e-17 -1.94289e-16 1 1.38778e-17 4: 2.22045e-16 3.03577e-17 -2.22045e-16 1.38778e-17 1 R8MAT_PLOT_TEST R8MAT_PLOT prints a symbolic picture of a matrix. Typically, - for negative, 0 for zero, and + for positive entries or X for nonzero and 0 for zero. A plot of the matrix: 1234567890123456789012345678901234567890123456789012345678901234567890 1 -+00000000000000000000000000000000000000000000000000000000000000000000 2 +-+0000000000000000000000000000000000000000000000000000000000000000000 3 0+-+000000000000000000000000000000000000000000000000000000000000000000 4 00+-+00000000000000000000000000000000000000000000000000000000000000000 5 000+-+0000000000000000000000000000000000000000000000000000000000000000 6 0000+-+000000000000000000000000000000000000000000000000000000000000000 7 00000+-+00000000000000000000000000000000000000000000000000000000000000 8 000000+-+0000000000000000000000000000000000000000000000000000000000000 9 0000000+-+000000000000000000000000000000000000000000000000000000000000 10 00000000+-+00000000000000000000000000000000000000000000000000000000000 123456789012345678901234567890 1 00000000000000000000000000000+ 2 000000000000000000000000000000 3 000000000000000000000000000000 4 000000000000000000000000000000 5 000000000000000000000000000000 6 000000000000000000000000000000 7 000000000000000000000000000000 8 000000000000000000000000000000 9 000000000000000000000000000000 10 000000000000000000000000000000 R8MAT_POWER_METHOD_TEST R8MAT_POWER_METHOD applies the power method to a matrix. Estimated eigenvalue = 3.73198 Estimated eigenvector V: 0: 0.292877 1: -0.499987 2: 0.573126 3: -0.499987 4: 0.292877 Value of A*V: 0: 1.08574 1: -1.86598 2: 2.14622 3: -1.86598 4: 1.08574 R8MAT_PRINT_TEST R8MAT_PRINT prints an R8MAT. The R8MAT: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 5: 61 62 63 64 R8MAT_PRINT_SOME_TEST R8MAT_PRINT_SOME prints some of an R8MAT. The R8MAT, rows 2:4, cols 1:2: Col: 0 1 Row 1: 21 22 2: 31 32 3: 41 42 R8MAT_REF_TEST R8MAT_REF computes the row echelon form of a matrix. Input A: Col: 0 1 2 3 4 Row 0: 1 3 0 2 6 1: -2 -6 0 -2 -8 2: 3 9 0 0 6 3: -1 -3 0 1 0 Col: 5 6 Row 0: 3 1 1: 3 1 2: 6 2 3: 9 3 REF form: Col: 0 1 2 3 4 Row 0: 1 3 0 2 6 1: 0 0 0 1 2 2: 0 0 0 0 0 3: 0 0 0 0 0 Col: 5 6 Row 0: 3 1 1: 4.5 1.5 2: 1 0.333333 3: 0 0 R8MAT_RREF_TEST R8MAT_RREF computes the reduced row echelon form of a matrix. Input A: Col: 0 1 2 3 4 Row 0: 1 3 0 2 6 1: -2 -6 0 -2 -8 2: 3 9 0 0 6 3: -1 -3 0 1 0 Col: 5 6 Row 0: 3 1 1: 3 1 2: 6 2 3: 9 3 REF form: Col: 0 1 2 3 4 Row 0: 1 3 0 0 2 1: 0 0 0 1 2 2: 0 0 0 0 0 3: 0 0 0 0 0 Col: 5 6 Row 0: 0 0 1: 0 0 2: 1 0.333333 3: 0 0 R8MAT_SOLVE_TEST R8MAT_SOLVE solves linear systems. The linear system: Col: 0 1 2 3 4 Row 0: 1 2 3 14 7 1: 4 5 6 32 16 2: 7 8 0 23 7 The computed solutions: 1 1 2 0 3 2 R8MAT_SOLVE_2D_TEST R8MAT_SOLVE_2D solves 2D linear systems. Solution / Computed: 0.415307 0.415307 0.0661187 0.0661187 Solution / Computed: 0.0617272 0.0617272 0.449539 0.449539 Solution / Computed: 0.897504 0.897504 0.350752 0.350752 Solution / Computed: 0.123104 0.123104 0.00751236 0.00751236 Solution / Computed: 0.822887 0.822887 0.267132 0.267132 R8MAT_SOLVE_3D_TEST R8MAT_SOLVE_3D solves 3D linear systems. Solution / Computed: 0.633966 0.633966 0.0617272 0.0617272 0.449539 0.449539 Solution / Computed: 0.840847 0.840847 0.123104 0.123104 0.00751236 0.00751236 Solution / Computed: 0.453794 0.453794 0.911977 0.911977 0.597917 0.597917 Solution / Computed: 0.714471 0.714471 0.117707 0.117707 0.299329 0.299329 Solution / Computed: 0.763537 0.763537 0.761731 0.761731 0.40697 0.40697 R8MAT_SOLVE2_TEST R8MAT_SOLVE2 is a linear solver. Right hand side: 0: 5 1: 11 The system is nonsingular. Computed solution: 0: 1 1: 2 Right hand side: 0: 4 1: 2 2: 2 R8MAT_SOLVE2 - Warning: Consistent singularity, equation = 3 The system is singular, but consistent. Computed solution: 0: 2 1: 0 2: 0 Right hand side: 0: 5 1: 11 2: 16 3: 15 The system is nonsingular. Computed solution: 0: -2 1: -6 2: 10 3: 7 Right hand side: 0: 13 1: 17 2: 20 R8MAT_SOLVE2 - Warning: Inconsistent singularity, equation = 2 The system is singular and inconsistent. Computed solution: 0: 6.42857 1: 0 2: 0.142857 R8MAT_SUB_NEW_TEST R8MAT_SUB_NEW computes C = A - B for R8MAT's A: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 B: Col: 0 1 2 3 Row 0: 11 21 31 41 1: 12 22 32 42 2: 13 23 33 43 3: 14 24 34 44 C = A-B: Col: 0 1 2 3 Row 0: 0 -9 -18 -27 1: 9 0 -9 -18 2: 18 9 0 -9 3: 27 18 9 0 R8MAT_SYMM_JACOBI_TEST For a symmetric R8MAT: R8MAT_SYMM_JACOBI diagonalizes; Matrix to diagonalize: Col: 0 1 2 3 4 Row 0: 2.86409 -0.334105 -0.906958 -0.379152 1.04295 1: -0.334105 2.25488 0.0784356 0.631118 -0.225108 2: -0.906958 0.0784356 3.21422 -0.91655 -0.026989 3: -0.379152 0.631118 -0.91655 3.86102 0.916005 4: 1.04295 -0.225108 -0.026989 0.916005 2.80579 Computed Eigenvalues: 1 2 4 5 3 R8MAT_TO_R8CMAT_NEW_TEST R8MAT_TO_R8CMAT_NEW converts an R8MAT to an R8CMAT. Data is of order (5,4. The R8MAT A: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 The R8CMAT B: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 The R8MAT C: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 R8MAT_TO_R8PLU_TEST R8MAT_TO_R8PLU determines the compressed PLU factors of a real general matrix. Matrix order N = 5 The matrix A: Col: 0 1 2 3 4 Row 0: 0.218418 0.0661187 0.0617272 0.00183837 0.859097 1: 0.956318 0.257578 0.449539 0.897504 0.840847 2: 0.829509 0.109957 0.401306 0.350752 0.123104 3: 0.561695 0.043829 0.754673 0.0945448 0.00751236 4: 0.415307 0.633966 0.797287 0.0136169 0.260303 The pivot vector P: 0: 2 1: 5 2: 4 3: 4 4: 5 The compressed LU factors: Col: 0 1 2 3 4 Row 0: 0.956318 0.257578 0.449539 0.897504 0.840847 1: -0.228395 0.522106 0.602062 -0.376149 -0.104858 2: -0.867399 0.217324 0.614552 -0.510026 -0.507943 3: -0.587352 0.20582 -0.231419 -0.391459 -0.511487 4: -0.434277 -0.0139612 0.0803036 -0.610161 0.939815 The recovered matrix A2: Col: 0 1 2 3 4 Row 0: 0.218418 0.0661187 0.0617272 0.00183837 0.859097 1: 0.956318 0.257578 0.449539 0.897504 0.840847 2: 0.829509 0.109957 0.401306 0.350752 0.123104 3: 0.561695 0.043829 0.754673 0.0945448 0.00751236 4: 0.415307 0.633966 0.797287 0.0136169 0.260303 R8MAT_TO_R8RMAT_TEST R8MAT_TO_R8RMAT converts an R8MAT to an R8RMAT. Data is of order (5,4). The R8MAT A: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 The R8RMAT B: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 The R8MAT C: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 R8MAT_TRACE_TEST R8MAT_TRACE computes the trace of an R8MAT Matrix: Col: 0 1 2 3 Row 0: 4 3 2 1 1: 3 3 2 1 2: 0 2 2 1 3: 0 0 1 1 Trace is 10 R8MAT_TRANSPOSE_NEW_TEST R8MAT_TRANSPOSE_NEW transposes an R8MAT. Matrix A: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 Transposed matrix At: Col: 0 1 2 3 4 Row 0: 11 21 31 41 51 1: 12 22 32 42 52 2: 13 23 33 43 53 3: 14 24 34 44 54 R8MAT_TRANSPOSE_PRINT_TEST R8MAT_TRANSPOSE_PRINT prints an R8MAT, transposed. Matrix row order M = 7 Matrix column order N = 12 The transposed matrix A: Row: 0 1 2 3 4 Col 0: 101 201 301 401 501 1: 102 202 302 402 502 2: 103 203 303 403 503 3: 104 204 304 404 504 4: 105 205 305 405 505 5: 106 206 306 406 506 6: 107 207 307 407 507 7: 108 208 308 408 508 8: 109 209 309 409 509 9: 110 210 310 410 510 10: 111 211 311 411 511 11: 112 212 312 412 512 Row: 5 6 Col 0: 601 701 1: 602 702 2: 603 703 3: 604 704 4: 605 705 5: 606 706 6: 607 707 7: 608 708 8: 609 709 9: 610 710 10: 611 711 11: 612 712 R8MAT_U_INVERSE_TEST R8MAT_U_INVERSE inverts an upper triangular R8MAT. Input matrix A Col: 0 1 2 3 Row 0: 1 2 4 7 1: 0 3 5 8 2: 0 0 6 9 3: 0 0 0 10 Inverse matrix B: Col: 0 1 2 3 Row 0: 1 -0.666667 -0.111111 -0.0666667 1: 0 0.333333 -0.277778 -0.0166667 2: 0 0 0.166667 -0.15 3: 0 0 0 0.1 Product C = A * B: Col: 0 1 2 3 Row 0: 1 0 0 0 1: 0 1 0 0 2: 0 0 1 1.11022e-16 3: 0 0 0 1 R8MAT_U1_INVERSE_TEST R8MAT_U1_INVERSE inverts a unit upper triangular R8MAT. Input matrix A Col: 0 1 2 3 4 Row 0: 1 2 0 5 0 1: 0 1 0 0 0 2: 0 0 1 3 0 3: 0 0 0 1 0 4: 0 0 0 0 1 5: 0 0 0 0 0 Col: 5 Row 0: 75 1: 0 2: 0 3: 6 4: 4 5: 1 Inverse matrix B: Col: 0 1 2 3 4 Row 0: 1 -2 0 -5 0 1: 0 1 0 0 0 2: 0 0 1 -3 0 3: 0 0 0 1 0 4: 0 0 0 0 1 5: 0 0 0 0 0 Col: 5 Row 0: -45 1: 0 2: 18 3: -6 4: -4 5: 1 Product C = A * B: Col: 0 1 2 3 4 Row 0: 1 0 0 0 0 1: 0 1 0 0 0 2: 0 0 1 0 0 3: 0 0 0 1 0 4: 0 0 0 0 1 5: 0 0 0 0 0 Col: 5 Row 0: 0 1: 0 2: 0 3: 0 4: 0 5: 1 R8MAT_UNIFORM_AB_NEW_TEST R8MAT_UNIFORM_AB_NEW returns a random R8MAT in [A,B]. The random R8MAT: Col: 0 1 2 3 Row 0: 3.74735 2.52895 2.49382 2.01471 1: 9.65054 4.06062 5.59631 9.18003 2: 8.63607 2.87965 5.21045 4.80602 3: 6.49356 2.35063 8.03739 2.75636 4: 5.32246 7.07173 8.3783 2.10894 R8PLU_DET_TEST R8PLU_DET determines the determinant of an R8MAT from its compressed PLU factors. Matrix order N = 5 The matrix A: Col: 0 1 2 3 4 Row 0: 0.218418 0.0661187 0.0617272 0.00183837 0.859097 1: 0.956318 0.257578 0.449539 0.897504 0.840847 2: 0.829509 0.109957 0.401306 0.350752 0.123104 3: 0.561695 0.043829 0.754673 0.0945448 0.00751236 4: 0.415307 0.633966 0.797287 0.0136169 0.260303 The determinant = 0.112888 R8PLU_INVERSE_TEST R8PLU_INVERSE determines the inverse of an R8MAT from its compressed PLU factors. Matrix order N = 5 The matrix A: Col: 0 1 2 3 4 Row 0: 0.218418 0.0661187 0.0617272 0.00183837 0.859097 1: 0.956318 0.257578 0.449539 0.897504 0.840847 2: 0.829509 0.109957 0.401306 0.350752 0.123104 3: 0.561695 0.043829 0.754673 0.0945448 0.00751236 4: 0.415307 0.633966 0.797287 0.0136169 0.260303 The inverse B: Col: 0 1 2 3 4 Row 0: 0.625209 -1.0222 2.84978 -0.868794 -0.0840984 1: -0.471548 -0.149728 0.892032 -2.1207 1.67928 2: -0.274368 0.546937 -1.95265 2.05705 0.00285593 3: -1.39029 1.75848 -1.70625 0.283212 -0.293107 4: 1.06404 0.228349 -0.649235 0.235691 -0.107439 Product C = A * B: Col: 0 1 2 3 4 Row 0: 1 1.11022e-16 -1.11022e-16 0 -1.38778e-17 1: -2.22045e-16 1 1.11022e-16 -1.38778e-16 -2.77556e-17 2: -2.498e-16 3.53884e-16 1 -1.76942e-16 0 3: -3.01842e-16 3.60389e-16 -2.10769e-16 1 -1.01915e-17 4: -1.11022e-16 6.245e-17 -1.66533e-16 -1.94289e-16 1 R8PLU_MUL_TEST R8PLU_MUL computes the product A*x using the compressed PLU factors of A. Matrix order N = 5 The matrix A: Col: 0 1 2 3 4 Row 0: 0.218418 0.0661187 0.0617272 0.00183837 0.859097 1: 0.956318 0.257578 0.449539 0.897504 0.840847 2: 0.829509 0.109957 0.401306 0.350752 0.123104 3: 0.561695 0.043829 0.754673 0.0945448 0.00751236 4: 0.415307 0.633966 0.797287 0.0136169 0.260303 The right hand side B (computed from A): 0: 4.83868 1: 10.6143 2: 4.27187 3: 3.32911 4: 5.43108 The right hand side B (computed from PLU): 0: 4.83868 1: 10.6143 2: 4.27187 3: 3.32911 4: 5.43108 R8PLU_SOL_TEST R8PLU_SOL solves the linear system A*x=b using the compressed PLU factors of A. Matrix order N = 5 The matrix A: Col: 0 1 2 3 4 Row 0: 0.218418 0.0661187 0.0617272 0.00183837 0.859097 1: 0.956318 0.257578 0.449539 0.897504 0.840847 2: 0.829509 0.109957 0.401306 0.350752 0.123104 3: 0.561695 0.043829 0.754673 0.0945448 0.00751236 4: 0.415307 0.633966 0.797287 0.0136169 0.260303 The right hand side B (computed from A): 0: 4.83868 1: 10.6143 2: 4.27187 3: 3.32911 4: 5.43108 The computed solution X: 0: 1 1: 2 2: 3 3: 4 4: 5 R8PLU_TO_R8MAT_TEST R8PLU_TO_R8MAT determines the original matrix from the compressed PLU factors. Matrix order N = 5 The matrix A: Col: 0 1 2 3 4 Row 0: 0.218418 0.0661187 0.0617272 0.00183837 0.859097 1: 0.956318 0.257578 0.449539 0.897504 0.840847 2: 0.829509 0.109957 0.401306 0.350752 0.123104 3: 0.561695 0.043829 0.754673 0.0945448 0.00751236 4: 0.415307 0.633966 0.797287 0.0136169 0.260303 The pivot vector P: 0: 2 1: 5 2: 4 3: 4 4: 5 The compressed LU factors: Col: 0 1 2 3 4 Row 0: 0.956318 0.257578 0.449539 0.897504 0.840847 1: -0.228395 0.522106 0.602062 -0.376149 -0.104858 2: -0.867399 0.217324 0.614552 -0.510026 -0.507943 3: -0.587352 0.20582 -0.231419 -0.391459 -0.511487 4: -0.434277 -0.0139612 0.0803036 -0.610161 0.939815 The recovered matrix A2: Col: 0 1 2 3 4 Row 0: 0.218418 0.0661187 0.0617272 0.00183837 0.859097 1: 0.956318 0.257578 0.449539 0.897504 0.840847 2: 0.829509 0.109957 0.401306 0.350752 0.123104 3: 0.561695 0.043829 0.754673 0.0945448 0.00751236 4: 0.415307 0.633966 0.797287 0.0136169 0.260303 R8POLY_DEGREE_TEST R8POLY_DEGREE determines the degree of an R8POLY. The R8POLY: p(x) = 4 * x ^ 3 + 3 * x ^ 2 + 2 * x + 1 Dimensioned degree = 3, Actual degree = 3 The R8POLY: p(x) = 0 * x ^ 3 + 3 * x ^ 2 + 2 * x + 1 Dimensioned degree = 3, Actual degree = 2 The R8POLY: p(x) = 4 * x ^ 3 + 2 * x + 1 Dimensioned degree = 3, Actual degree = 3 The R8POLY: p(x) = 0 * x ^ 3 + 1 Dimensioned degree = 3, Actual degree = 0 The R8POLY: p(x) = 0 * x ^ 3 Dimensioned degree = 3, Actual degree = 0 R8POLY_DERIV_TEST R8POLY_DERIV computes the coefficients of the derivative of a polynomial. The initial polynomial p(x) = 1 * x ^ 4 - 10 * x ^ 3 + 35 * x ^ 2 - 50 * x + 24 The derivative of order 0 p(x) = 1 * x ^ 4 - 10 * x ^ 3 + 35 * x ^ 2 - 50 * x + 24 The derivative of order 1 p(x) = 4 * x ^ 3 - 30 * x ^ 2 + 70 * x - 50 The derivative of order 2 p(x) = 12 * x ^ 2 - 60 * x + 70 The derivative of order 3 p(x) = 24 * x - 60 The derivative of order 4 p(x) = 0 R8POLY_LAGRANGE_COEF_TEST R8POLY_LAGRANGE_COEF returns the coefficients for a Lagrange basis polynomial. Abscissas: 0: 1 1: 2 2: 3 Lagrange basis polynomial 1: 3 0 -2.5 1 0.5 2 Lagrange basis polynomial 2: -3 0 4 1 -1 2 Lagrange basis polynomial 3: 1 0 -1.5 1 0.5 2 R8POLY_LAGRANGE_0_TEST R8POLY_LAGRANGE_0 evaluates the Lagrange factor W(X) at a point. The number of data points is 5 Abscissas: 0: 0 1: 1 2: 2 3: 3 4: 4 X W(X) 0 0 0.222222 3.22444 0.444444 3.48998 0.666667 2.30453 0.888889 0.720757 1.11111 -0.598825 1.33333 -1.31687 1.55556 -1.35616 1.77778 -0.834561 2 0 2.22222 0.834561 2.44444 1.35616 2.66667 1.31687 2.88889 0.598825 3.11111 -0.720757 3.33333 -2.30453 3.55556 -3.48998 3.77778 -3.22444 4 0 R8POLY_LAGRANGE_1_TEST R8POLY_LAGRANGE_1 evaluates the Lagrange factor W'(X) at a point. The number of data points is 5 Abscissas: 0: 0 1: 1 2: 2 3: 3 4: 4 X W'(X) 0 24 0.222222 6.5362 0.444444 -3.02027 0.666667 -6.8642 0.888889 -6.89773 1.11111 -4.73038 1.33333 -1.67901 1.55556 1.23213 1.77778 3.27145 2 4 2.22222 3.27145 2.44444 1.23213 2.66667 -1.67901 2.88889 -4.73038 3.11111 -6.89773 3.33333 -6.8642 3.55556 -3.02027 3.77778 6.5362 4 24 R8POLY_LAGRANGE_2_TEST R8POLY_LAGRANGE_2 evaluates the Lagrange factor W''(X) at a point. The number of data points is 5 Abscissas: 0: 0 1: 1 2: 2 3: 3 4: 4 X W''(X) 0 -100 0.222222 -59.0398 0.444444 -28.6145 0.666667 -7.40741 0.888889 5.89849 1.11111 12.62 1.33333 14.0741 1.55556 11.5775 1.77778 6.44719 2 0 2.22222 -6.44719 2.44444 -11.5775 2.66667 -14.0741 2.88889 -12.62 3.11111 -5.89849 3.33333 7.40741 3.55556 28.6145 3.77778 59.0398 4 100 R8POLY_LAGRANGE_FACTOR_TEST R8POLY_LAGRANGE_FACTOR evaluates the Lagrange factor W(X) at a point. For this test, we use 5 functions. Abscissas: 0: 0 1: 0.8 2: 1.6 3: 2.4 4: 3.2 X W(X) W'(X) 4.5 131.818 274.543 4 39.3216 112.23 3.5 5.92515 32.1429 3 -1.1088 2.0304 2.5 -0.26775 -2.8571 2 0.4608 0.2304 1.5 -0.16065 1.5429 1 -0.3696 -1.1696 R8POLY_LAGRANGE_VAL_TEST R8POLY_LAGRANGE_VAL evaluates a Lagrange interpolating polynomial at a point. For this test, we use 5 functions. Abscissas: 0: 0 1: 1 2: 2 3: 3 4: 4 Here are the values of the functions at several points: X L1 L2 L3 L4 L5 4.5 0.273438 -1.40625 2.95312 -3.28125 2.46094 4 0 -0 0 -0 1 3.5 -0.0390625 0.21875 -0.546875 1.09375 0.273438 3 -0 0 -0 1 0 2.5 0.0234375 -0.15625 0.703125 0.46875 -0.0390625 2 0 -0 1 0 -0 1.5 -0.0390625 0.46875 0.703125 -0.15625 0.0234375 1 -0 1 0 -0 0 0.5 0.273438 1.09375 -0.546875 0.21875 -0.0390625 And the derivatives: X L'1 L'2 L'3 L'4 L'5 4.5 0.916667 -4.625 9.375 -9.54167 3.875 4 0.25 -1.33333 3 -4 2.08333 3.5 -0.0416667 0.208333 -0.375 -0.708333 0.916667 3 -0.0833333 0.5 -1.5 0.833333 0.25 2.5 0 0.0416667 -1.125 1.125 -0.0416667 2 0.0833333 -0.666667 0 0.666667 -0.0833333 1.5 0.0416667 -1.125 1.125 -0.0416667 0 1 -0.25 -0.833333 1.5 -0.5 0.0833333 0.5 -0.916667 0.708333 0.375 -0.208333 0.0416667 R8POLY_PRINT_TEST R8POLY_PRINT prints an R8POLY. The R8POLY: p(x) = 9 * x ^ 5 + 0.78 * x ^ 4 + 56 * x ^ 2 - 3.4 * x + 2 R8POLY_VALUE_HORNER_TEST R8POLY_VALUE_HORNER evaluates a polynomial at one point, using Horner's method. The polynomial coefficients: p(x) = 1 * x ^ 4 - 10 * x ^ 3 + 35 * x ^ 2 - 50 * x + 24 I X P(X) 0 0 24 1 0.333333 10.8642 2 0.666667 3.45679 3 1 0 4 1.33333 -0.987654 5 1.66667 -0.691358 6 2 0 7 2.33333 0.493827 8 2.66667 0.493827 9 3 0 10 3.33333 -0.691358 11 3.66667 -0.987654 12 4 0 13 4.33333 3.45679 14 4.66667 10.8642 15 5 24 R8POLY_VALUES_HORNER_TEST R8POLY_VALUES_HORNER evaluates a polynomial at a point, using Horner's method. The polynomial: p(x) = 1 * x ^ 4 - 10 * x ^ 3 + 35 * x ^ 2 - 50 * x + 24 X, P(X): 0: 0 24 1: 0.333333 10.8642 2: 0.666667 3.45679 3: 1 0 4: 1.33333 -0.987654 5: 1.66667 -0.691358 6: 2 0 7: 2.33333 0.493827 8: 2.66667 0.493827 9: 3 0 10: 3.33333 -0.691358 11: 3.66667 -0.987654 12: 4 0 13: 4.33333 3.45679 14: 4.66667 10.8642 15: 5 24 R8POLY2_EX_TEST R8POLY2_EX finds the extreme value of a parabola determined by three points. Parabolic coefficients A = 2, B = -4, c = 10 X, Y data: 1 8 2 10 3 16 R8POLY2_EX returns XMIN = 1, YMIN = 8 R8POLY2_EX2_TEST R8POLY2_EX2 finds the extreme value of a parabola determined by three points. Parabolic coefficients A = 2, B = -4, c = 10 X, Y data: 1 8 2 10 3 16 R8POLY2_EX2 returns XMIN = 1, YMIN = 8 and A = 2, B = -4, c = 10 R8POLY2_VAL_TEST R8POLY2_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 0 1 6 3 28 Sampled data: X, Y, Y', Y'' 0 1 3 4 1 6 7 4 2 15 11 4 3 28 15 4 Case 2: X1=X2, X3 distinct: -1 0 -1 -1 3 28 Sampled data: X, Y, Y', Y'' 0 1 3 4 1 6 7 4 2 15 11 4 3 28 15 4 Case 3: X1=X2=X3: -1 0 -1 -1 -1 4 Sampled data: X, Y, Y', Y'' 0 1 3 4 1 6 7 4 2 15 11 4 3 28 15 4 R8POLY2_VAL2_TEST R8POLY2_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. 0 2 15 17 1 4 45 61 2 6 91 137 3 8 153 245 4 10 231 385 Interpolated data: LEFT, X, Y1, Y2 0 1 6 7 1 3 28 35 2 5 66 95 2 7 120 187 2 9 190 311 R8R8_INDEX_INSERT_UNIQUE_TEST R8R8VEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. Generate 30 random values: XVAL YVAL Index 1 2 3 2 3 2 3 2 1 3 2 1 4 1 2 4 1 2 1 2 3 5 3 1 6 4 2 7 1 1 8 4 3 7 1 1 1 2 3 4 1 2 2 3 2 2 3 2 6 4 2 6 4 2 1 2 3 3 2 1 2 3 2 2 3 2 9 2 2 4 1 2 10 3 3 4 1 2 11 1 3 2 3 2 8 4 3 2 3 2 Vector of unique X Y values: I X(I) Y(I) 1 2 3 2 3 2 3 2 1 4 1 2 5 3 1 6 4 2 7 1 1 8 4 3 9 2 2 10 3 3 11 1 3 X, Y sorted by index I INDX(I) X(INDX(I)) Y(INDX(I)) 1 7 1 1 2 4 1 2 3 11 1 3 4 3 2 1 5 9 2 2 6 1 2 3 7 5 3 1 8 2 3 2 9 10 3 3 10 6 4 2 11 8 4 3 R8R8R8VEC_INDEX_INSERT_UNIQUE_TEST R8R8R8VEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. Number of random values to generate = 30 XVAL YVAL ZVAL Index 2 3 3 1 3 2 1 2 2 1 1 3 3 1 2 4 2 3 3 1 1 3 2 5 1 1 4 6 4 1 1 7 2 3 1 8 2 3 2 9 3 2 4 10 2 3 3 1 2 3 2 9 2 2 2 11 3 2 2 12 3 1 2 4 3 3 1 13 3 1 3 14 3 2 4 10 3 3 2 15 4 2 1 16 3 1 2 4 2 3 1 8 1 1 1 17 2 1 2 18 2 2 3 19 3 1 3 14 3 2 4 10 4 3 3 20 1 2 2 21 Vector of unique X Y Z values: I X(I) Y(I) Z(I) 1 2 3 3 2 3 2 1 3 2 1 1 4 3 1 2 5 1 3 2 6 1 1 4 7 4 1 1 8 2 3 1 9 2 3 2 10 3 2 4 11 2 2 2 12 3 2 2 13 3 3 1 14 3 1 3 15 3 3 2 16 4 2 1 17 1 1 1 18 2 1 2 19 2 2 3 20 4 3 3 21 1 2 2 X Y Z sorted by index: I INDX(I) X(I) X(INDX(I)) 1 17 1 1 1 2 6 1 1 4 3 21 1 2 2 4 5 1 3 2 5 3 2 1 1 6 18 2 1 2 7 11 2 2 2 8 19 2 2 3 9 8 2 3 1 10 9 2 3 2 11 1 2 3 3 12 4 3 1 2 13 14 3 1 3 14 2 3 2 1 15 12 3 2 2 16 10 3 2 4 17 13 3 3 1 18 15 3 3 2 19 7 4 1 1 20 16 4 2 1 21 20 4 3 3 R8RMAT_NEW_TEST: R8RMAT_NEW dynamically creates a 2D array. Array entries can be addressed using the notation "a[i][j]". Allocating memory for array A of size 4 by 5. Assigning values to A. Dynamically allocated matrix A: 0 1 2 3 4 10 11 12 13 14 20 21 22 23 24 30 31 32 33 34 Dynamically allocated matrix B = A' * A: 1400 1460 1520 1580 1640 1460 1524 1588 1652 1716 1520 1588 1656 1724 1792 1580 1652 1724 1796 1868 1640 1716 1792 1868 1944 R8RMAT_TO_R8MAT_TEST R8RMAT_TO_R8MAT converts an R8RMAT to an R8MAT. Data is of order (5,4). The R8MAT A: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 The R8RMAT B: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 The R8MAT C: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 R8ROW_MAX_TEST For an R8ROW (a matrix regarded as rows): R8ROW_MAX computes maximums; The original matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 The row maximums: 0: 4 1: 8 2: 12 R8ROW_MEAN_TEST For an R8ROW (a matrix regarded as rows): R8ROW_MEAN computes means; The original matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Row means: 0: 2.5 1: 6.5 2: 10.5 R8ROW_MIN_TEST For an R8ROW (a matrix regarded as rows): R8ROW_MIN computes minimums; The original matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 The row minimums: 0: 1 1: 5 2: 9 R8ROW_SUM_TEST For an R8ROW (a matrix regarded as rows): R8ROW_SUM computes sums; The original matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 The row sums: 0: 10 1: 26 2: 42 R8ROW_SWAP_TEST For an R8ROW (a matrix regarded as rows): R8ROW_SWAP swaps two rows; The original matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Swap rows 1 and 3 The modified matrix: Col: 0 1 2 3 Row 0: 9 10 11 12 1: 5 6 7 8 2: 1 2 3 4 R8ROW_TO_R8VEC_TEST R8ROW_TO_R8VEC converts an array of rows into a vector. The array of rows: Col: 0 1 2 3 Row 0: 0 1 2 3 1: 10 11 12 13 2: 20 21 22 23 The resulting vector of rows: 0: 0 1: 10 2: 20 3: 1 4: 11 5: 21 6: 2 7: 12 8: 22 9: 3 10: 13 11: 23 R8ROW_VARIANCE_TEST For an R8ROW (a matrix regarded as rows): R8ROW_VARIANCE computes variances; The original matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Row variances: 1 1.66667 2 1.66667 3 1.66667 R8SLMAT_PRINT_TEST R8SLMAT_PRINT prints a strictly lower triangular matrix stored compactly. Only the (possibly) nonzero elements are printed. R8SLMAT: Col 1 2 3 4 5 Row 2: 21 3: 31 32 4: 41 42 43 5: 51 52 53 54 6: 61 62 63 64 65 7: 71 72 73 74 75 Col 6 Row 7: 76 R8SLMAT: Col 1 2 3 Row 2: 21 3: 31 32 4: 41 42 43 5: 51 52 53 6: 61 62 63 7: 71 72 73 R8SLMAT: Col 1 2 3 Row 2: 21 3: 31 32 4: 41 42 43 R8VEC_AMAX_TEST For an R8VEC: R8VEC_AMAX: maximum magnitude entry; Input vector: 0: -5.63163 1: 9.12635 2: 6.59018 3: 1.23391 4: -1.69386 5: -8.67763 6: -4.84844 7: -7.80086 8: -9.12342 9: 2.67931 Maximum absolute: 9.12635 R8VEC_AMIN_TEST For an R8VEC: R8VEC_AMIN: minimum magnitude entry. Input vector: 0: -5.63163 1: 9.12635 2: 6.59018 3: 1.23391 4: -1.69386 5: -8.67763 6: -4.84844 7: -7.80086 8: -9.12342 9: 2.67931 Minimum absolute: 1.23391 R8VEC_BRACKET_TEST R8VEC_BRACKET finds a pair of entries in a sorted real array which bracket a value. The array (must be in ascending order!) 0: 1 1: 2 2: 3 3: 4 4: 5 5: 5 6: 7 7: 8 8: 9 9: 10 Search for XVAL = -10 X[1-1] = 1 X[2-1] = 2 Search for XVAL = 1 X[1-1] = 1 X[2-1] = 2 Search for XVAL = 4.5 X[4-1] = 4 X[5-1] = 5 Search for XVAL = 5 X[6-1] = 5 X[7-1] = 7 Search for XVAL = 10 X[9-1] = 9 X[10-1] = 10 Search for XVAL = 12 X[9-1] = 9 X[10-1] = 10 R8VEC_BRACKET2_TEST R8VEC_BRACKET2 finds a pair of entries in a sorted R8VEC which bracket a value. The array (must be in ascending order!) 0: 1 1: 2 2: 3 3: 4 4: 5 5: 5 6: 7 7: 8 8: 9 9: 10 Search for XVAL = -10 Start = 9 Left = 1 Right = 2 X[1-1] = 1 X[2-1] = 2 Search for XVAL = 1 Start = 1 Left = 1 Right = 1 X[1-1] = 1 X[1-1] = 1 Search for XVAL = 4.5 Start = 1 Left = 4 Right = 5 X[4-1] = 4 X[5-1] = 5 Search for XVAL = 5 Start = 4 Left = 5 Right = 5 X[5-1] = 5 X[5-1] = 5 Search for XVAL = 10 Start = 5 Left = 9 Right = 10 X[9-1] = 9 X[10-1] = 10 Search for XVAL = 12 Start = 9 Left = 10 Right = -1 X[10-1] = 10 R8VEC_BRACKET3_TEST R8VEC_BRACKET3 finds a pair of entries in a sorted real array which bracket a value. The array (must be in ascending order!): 0: 1 1: 2 2: 3 3: 4 4: 5 5: 5 6: 7 7: 8 8: 9 9: 10 Search for XVAL = -10 Starting guess for interval is = 4 Nearest interval: X[0]= 1 X[1]= 2 Search for XVAL = 1 Starting guess for interval is = 0 Nearest interval: X[0]= 1 X[1]= 2 Search for XVAL = 4.5 Starting guess for interval is = 0 Nearest interval: X[3]= 4 X[4]= 5 Search for XVAL = 5 Starting guess for interval is = 3 Nearest interval: X[3]= 4 X[4]= 5 Search for XVAL = 10 Starting guess for interval is = 3 Nearest interval: X[8]= 9 X[9]= 10 Search for XVAL = 12 Starting guess for interval is = 8 Nearest interval: X[8]= 9 X[9]= 10 R8VEC_BRACKET5_TEST R8VEC_BRACKET5 finds a pair of entries in a sorted R8VEC which bracket a value. Sorted array: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 5 6: 7 7: 8 8: 9 9: 10 LEFT RIGHT X(LEFT) XVAL X(RIGHT) -1 -10 (Not bracketed!) 0 1 1 1 2 3 4 4 4.5 5 5 6 5 5 7 8 9 9 10 10 -1 12 (Not bracketed!) R8VEC_CHEBYSPACE_NEW_TEST R8VEC_CHEBYSPACE_NEW computes N Chebyshev points in [R1,R2]. N = 5, R1 = -1, R2 = 1 Chebyshev points: 0: -1 1: -0.707107 2: 0 3: 0.707107 4: 1 N = 7, R1 = 0, R2 = 10 Chebyshev points: 0: 0 1: 0.669873 2: 2.5 3: 5 4: 7.5 5: 9.33013 6: 10 R8VEC_CONCATENATE_NEW_TEST R8VEC_CONCATENATE_NEW concatenates two R8VECs Array 1: 0: 91.1 1: 31.2 2: 71.3 3: 51.4 4: 31.5 Array 2: 0: 42.6 1: 22.7 2: 12.8 Array 3 = Array 1 + Array 2: 0: 91.1 1: 31.2 2: 71.3 3: 51.4 4: 31.5 5: 42.6 6: 22.7 7: 12.8 R8VEC_CONVOLUTION_TEST R8VEC_CONVOLUTION computes the convolution of two vectors. The factor X: 0: 1 1: 2 2: 3 3: 4 The factor Y: 0: -1 1: 5 2: 3 The convolution z = x star y: 0: -1 1: 3 2: 10 3: 17 4: 29 5: 12 Correct answer: 0: -1 1: 3 2: 10 3: 17 4: 29 5: 12 R8VEC_CONVOLUTION_CIRC_TEST R8VEC_CONVOLUTION_CIRC computes the circular convolution of two vectors. The factor X: 0: 1 1: 2 2: 3 3: 4 The factor Y: 0: 1 1: 2 2: 4 3: 8 The circular convolution z = xCCy: 0: 37 1: 44 2: 43 3: 26 Correct answer: 0: 37 1: 44 2: 43 3: 26 R8VEC_DIF_TEST R8VEC_DIF estimates derivatives. Estimate the derivative of order N = 4 Using H = 0.01 at argument X = 1 The difference coefficients: 0: 6.25e+06 1: -2.5e+07 2: 3.75e+07 3: -2.5e+07 4: 6.25e+06 Estimate is FDIF = 2.71846 R8VEC_DIRECT_PRODUCT_TEST R8VEC_DIRECT_PRODUCT forms the entries of a direct product of a given number of R8VEC factors. J X(1) X(2) X(3) 0 1 50 800 1 2 50 800 2 3 50 800 3 4 50 800 4 1 60 800 5 2 60 800 6 3 60 800 7 4 60 800 8 1 70 800 9 2 70 800 10 3 70 800 11 4 70 800 12 1 50 900 13 2 50 900 14 3 50 900 15 4 50 900 16 1 60 900 17 2 60 900 18 3 60 900 19 4 60 900 20 1 70 900 21 2 70 900 22 3 70 900 23 4 70 900 R8VEC_DIRECT_PRODUCT2_TEST R8VEC_DIRECT_PRODUCT2 forms the entries of a direct product of a given number of R8VEC factors. J W(J) 0 418 1 627 2 1045 3 1463 4 494 5 741 6 1235 7 1729 8 646 9 969 10 1615 11 2261 12 462 13 693 14 1155 15 1617 16 546 17 819 18 1365 19 1911 20 714 21 1071 22 1785 23 2499 R8VEC_EVEN_TEST R8VEC_EVEN computes N evenly spaced values between XLO and XHI. XLO = 0 XHI = 99 while N = 10 Resulting array: 0: 0 1: 11 2: 22 3: 33 4: 44 5: 55 6: 66 7: 77 8: 88 9: 99 R8VEC_EVEN2_TEST: R8VEC_EVEN2 interpolates a specified number of points pairs of values in a vector. Input data: 0 (4) 1 (3) 5 (5) 2 (0) 0 Resulting vector: * 0 0.2 0.4 0.6 0.8 * 1 2 3 4 * 5 4.5 4 3.5 3 2.5 * 2 * 0 R8VEC_EXPAND_LINEAR_TEST R8VEC_EXPAND_LINEAR linearly interpolates new data between old values. Original vector: 0: 16 1: 4 2: 0 3: 4 4: 16 5: 36 Expansion factor is 3 Fattened vector: 0: 16 1: 13 2: 10 3: 7 4: 4 5: 3 6: 2 7: 1 8: 0 9: 1 10: 2 11: 3 12: 4 13: 7 14: 10 15: 13 16: 16 17: 21 18: 26 19: 31 20: 36 R8VEC_FRAC_TEST R8VEC_FRAC: K-th smallest R8VEC entry; Array to search: 0: 0.218418 1: 0.956318 2: 0.829509 3: 0.561695 4: 0.415307 5: 0.0661187 6: 0.257578 7: 0.109957 8: 0.043829 9: 0.633966 Fractile Value 1 0.043829 6 0.415307 R8VEC_HISTOGRAM_TEST R8VEC_HISTOGRAM histograms a real vector. Uniform data: Histogram of data: 0 0 0 0.05 63 0.05 0.1 37 0.1 0.15 49 0.15 0.2 37 0.2 0.25 46 0.25 0.3 57 0.3 0.35 49 0.35 0.4 52 0.4 0.45 51 0.45 0.5 49 0.5 0.55 50 0.55 0.6 56 0.6 0.65 60 0.65 0.7 52 0.7 0.75 44 0.75 0.8 47 0.8 0.85 54 0.85 0.9 48 0.9 0.95 52 0.95 1 47 1 0 Normal data: Histogram of data: -3 0 -3 -2.7 2 -2.7 -2.4 2 -2.4 -2.1 11 -2.1 -1.8 12 -1.8 -1.5 32 -1.5 -1.2 55 -1.2 -0.9 66 -0.9 -0.6 75 -0.6 -0.3 115 -0.3 0 111 0 0.3 115 0.3 0.6 117 0.6 0.9 103 0.9 1.2 65 1.2 1.5 46 1.5 1.8 29 1.8 2.1 17 2.1 2.4 15 2.4 2.7 7 2.7 3 4 3 1 R8VEC_HOUSE_COLUMN_TEST R8VEC_HOUSE_COLUMN returns the compact form of a Householder matrix that packs a column of a matrix. Matrix A: Col: 0 1 2 3 Row 0: 1.09209 2.07654 0.219145 2.00653 1: 4.78159 0.330594 3.16983 3.77337 2: 4.14755 1.28789 0.308636 3.98643 3: 2.80848 0.549784 2.24769 0.00919186 Working on column K = 1 Householder matrix H: Col: 0 1 2 3 Row 0: -0.155781 -0.682069 -0.591626 -0.400615 1: -0.682069 0.597486 -0.34914 -0.236418 2: -0.591626 -0.34914 0.697156 -0.205068 3: -0.400615 -0.236418 -0.205068 0.86114 Product H*A: Col: 0 1 2 3 Row 0: -7.01042 -1.53117 -3.27924 -5.24844 1: -1.11022e-16 -1.79845 1.1053 -0.508058 2: -7.77156e-16 -0.558841 -1.48213 0.272729 3: -4.44089e-16 -0.700714 1.03509 -2.50551 Working on column K = 2 Householder matrix H: Col: 0 1 2 3 Row 0: 1 0 0 0 1: 0 -0.895014 -0.278112 -0.348717 2: 0 -0.278112 0.959184 -0.0511776 3: 0 -0.348717 -0.0511776 0.93583 Product H*A: Col: 0 1 2 3 Row 0: -7.01042 -1.53117 -3.27924 -5.24844 1: 4.70364e-16 2.00941 -0.938018 1.25258 2: -6.91832e-16 4.85723e-17 -1.78201 0.531121 3: -3.37104e-16 1.11022e-16 0.659083 -2.18152 Working on column K = 3 Householder matrix H: Col: 0 1 2 3 Row 0: 1 0 0 0 1: 0 1 0 0 2: 0 0 -0.937906 0.346889 3: 0 0 0.346889 0.937906 Product H*A: Col: 0 1 2 3 Row 0: -7.01042 -1.53117 -3.27924 -5.24844 1: 4.70364e-16 2.00941 -0.938018 1.25258 2: 5.31936e-16 -7.04386e-18 1.89999 -1.25489 3: -5.5616e-16 1.20978e-16 1.11022e-16 -1.86183 R8VEC_INDEX_DELETE_ALL_TEST R8VEC_INDEX_DELETE_ALL deletes all copies of a particular value. 4 19 17 11 8 1 5 2 1 13 1 9 8 15 16 0 18 7 2 0 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 18 8 0 2 22 7 0 3 8 4 1 4 13 19 1 5 11 17 1 6 10 11 2 7 21 8 2 8 3 1 4 9 9 5 5 10 2 2 7 11 20 1 7 12 23 13 7 13 1 1 8 14 15 9 8 15 24 8 8 16 7 15 8 17 14 16 9 18 6 0 11 19 12 18 13 20 16 7 15 21 17 2 16 22 5 0 17 23 19 7 18 24 4 8 19 Call R8VEC_INDEX_DELETE_ALL to delete all values of 7: Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 17 8 0 2 20 4 0 3 7 19 1 4 12 17 1 5 10 11 1 6 9 8 2 7 19 1 2 8 2 5 4 9 8 2 5 10 1 1 8 11 14 13 8 12 21 1 8 13 6 9 8 14 13 8 9 15 5 15 11 16 11 16 13 17 15 0 15 18 16 18 16 19 4 2 17 20 18 0 18 21 3 8 19 R8VEC_INDEX_DELETE_DUPES_TEST R8VEC_INDEX_DELETE_DUPES deletes duplicates. 4 19 17 11 8 1 5 2 1 13 1 9 8 15 16 0 18 7 2 0 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 18 8 0 2 22 7 0 3 8 4 1 4 13 19 1 5 11 17 1 6 10 11 2 7 21 8 2 8 3 1 4 9 9 5 5 10 2 2 7 11 20 1 7 12 23 13 7 13 1 1 8 14 15 9 8 15 24 8 8 16 7 15 8 17 14 16 9 18 6 0 11 19 12 18 13 20 16 7 15 21 17 2 16 22 5 0 17 23 19 7 18 24 4 8 19 Call R8VEC_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 4 5 5 5 6 6 7 7 7 8 8 8 9 9 9 11 10 10 13 11 11 15 12 12 16 13 13 17 14 14 18 15 15 19 R8VEC_INDEX_DELETE_ONE_TEST R8VEC_INDEX_DELETE_ONE deletes one copies of a particular value. 4 19 17 11 8 1 5 2 1 13 1 9 8 15 16 0 18 7 2 0 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 18 8 0 2 22 7 0 3 8 4 1 4 13 19 1 5 11 17 1 6 10 11 2 7 21 8 2 8 3 1 4 9 9 5 5 10 2 2 7 11 20 1 7 12 23 13 7 13 1 1 8 14 15 9 8 15 24 8 8 16 7 15 8 17 14 16 9 18 6 0 11 19 12 18 13 20 16 7 15 21 17 2 16 22 5 0 17 23 19 7 18 24 4 8 19 Call R8VEC_INDEX_DELETE_ONE to delete one value of 8: Indexed list of unique entries: I INDX(I) X(I) 1 18 8 2 22 7 3 8 4 4 13 19 5 11 17 6 10 11 7 21 8 8 3 1 9 9 5 10 2 2 11 20 1 12 23 13 13 1 1 14 15 9 15 7 8 16 14 15 17 6 16 18 12 0 19 16 18 20 17 7 21 5 2 22 19 0 23 4 7 R8VEC_INDEX_INSERT_TEST R8VEC_INDEX_INSERT inserts values into an index sorted array. 4 19 17 11 8 1 5 2 1 13 1 9 8 15 16 0 18 7 2 0 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 18 8 0 2 22 7 0 3 8 4 1 4 13 19 1 5 11 17 1 6 10 11 2 7 21 8 2 8 3 1 4 9 9 5 5 10 2 2 7 11 20 1 7 12 23 13 7 13 1 1 8 14 15 9 8 15 24 8 8 16 7 15 8 17 14 16 9 18 6 0 11 19 12 18 13 20 16 7 15 21 17 2 16 22 5 0 17 23 19 7 18 24 4 8 19 R8VEC_INDEX_INSERT_UNIQUE_TEST R8VEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. 4 19 17 11 8 1 5 2 1 13 1 9 8 15 16 0 18 7 2 0 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 2 6 19 1 3 8 17 2 4 1 11 4 5 7 8 5 6 15 1 7 7 5 5 8 8 10 2 9 9 4 13 11 10 9 9 13 11 11 15 15 12 12 16 16 13 3 0 17 14 14 18 18 15 2 7 19 16 23 7 3.18299e-313 Results of search for given XVAL: XVAL Less Equal More 0 0 1 2 1 1 2 3 2 2 3 4 3 3 0 4 4 3 4 5 5 4 5 6 6 5 0 6 7 5 6 7 8 6 7 8 9 7 8 9 10 8 0 9 11 8 9 10 12 9 0 10 13 9 10 11 14 10 0 11 15 10 11 12 16 11 12 13 17 12 13 14 18 13 14 15 19 14 15 16 20 15 0 16 R8VEC_INDEX_ORDER_TEST R8VEC_INDEX_ORDER sorts an index sorted array. Generate some random values: 4 19 17 11 8 1 5 2 1 13 1 9 8 15 16 0 18 7 2 0 Indexed list of unique entries: I INDX(I) X(I) X(INDX(I)) 1 13 4 0 2 6 19 1 3 8 17 2 4 1 11 4 5 7 8 5 6 15 1 7 7 5 5 8 8 10 2 9 9 4 13 11 10 9 9 13 11 11 15 15 12 12 16 16 13 3 0 17 14 14 18 18 15 2 7 19 Now call R8VEC_INDEX_ORDER to carry out the sorting: X: 0: 0 1: 1 2: 2 3: 4 4: 5 5: 7 6: 8 7: 9 8: 11 9: 13 10: 15 11: 16 12: 17 13: 18 14: 19 R8VEC_INDEX_SEARCH_TEST R8VEC_INDEX_SEARCH searches for an entry with a given value. Generate some random values: 4 19 17 11 8 1 5 2 1 13 1 9 8 15 16 0 18 7 2 0 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 2 6 19 1 3 8 17 2 4 1 11 4 5 7 8 5 6 15 1 7 7 5 5 8 8 10 2 9 9 4 13 11 10 9 9 13 11 11 15 15 12 12 16 16 13 3 0 17 14 14 18 18 15 2 7 19 16 12 18 16 Results of search for given XVAL: XVAL Less Equal More 0 0 1 2 1 1 2 3 2 2 3 4 3 3 0 4 4 3 4 5 5 4 5 6 6 5 0 6 7 5 6 7 8 6 7 8 9 7 8 9 10 8 0 9 11 8 9 10 12 9 0 10 13 9 10 11 14 10 0 11 15 10 11 12 16 11 12 13 17 12 13 14 18 13 14 15 19 14 15 16 20 15 0 16 R8VEC_INDEX_SORTED_RANGE_TEST R8VEC_INDEX_SORTED_RANGE seeks the range I_LO:I_HI of entries of sorted indexed R so that R_LO <= R(INDX(I)) <= R_HI for I_LO <= I <= I_HI. Array 0: 0.218418 1: 0.956318 2: 0.829509 3: 0.561695 4: 0.415307 5: 0.0661187 6: 0.257578 7: 0.109957 8: 0.043829 9: 0.633966 10: 0.0617272 11: 0.449539 12: 0.401306 13: 0.754673 14: 0.797287 15: 0.00183837 16: 0.897504 17: 0.350752 18: 0.0945448 19: 0.0136169 I INDX R(INDX(I)) 0 15 0.00183837 1 19 0.0136169 2 8 0.043829 3 10 0.0617272 4 5 0.0661187 5 18 0.0945448 6 7 0.109957 7 0 0.218418 8 6 0.257578 9 17 0.350752 10 12 0.401306 11 4 0.415307 12 11 0.449539 13 3 0.561695 14 9 0.633966 15 13 0.754673 16 14 0.797287 17 2 0.829509 18 16 0.897504 19 1 0.956318 R_LO 0.840847 R_HI 0.859097 Empty range in R. Array 0: 0.123104 1: 0.00751236 2: 0.260303 3: 0.912484 4: 0.113664 5: 0.351629 6: 0.822887 7: 0.267132 8: 0.692066 9: 0.561662 10: 0.861216 11: 0.453794 12: 0.911977 13: 0.597917 14: 0.188955 15: 0.761492 16: 0.396988 17: 0.185314 18: 0.574366 19: 0.367027 I INDX R(INDX(I)) 0 1 0.00751236 1 4 0.113664 2 0 0.123104 3 17 0.185314 4 14 0.188955 5 2 0.260303 6 7 0.267132 7 5 0.351629 8 19 0.367027 9 16 0.396988 10 11 0.453794 11 9 0.561662 12 18 0.574366 13 13 0.597917 14 8 0.692066 15 15 0.761492 16 6 0.822887 17 10 0.861216 18 12 0.911977 19 3 0.912484 R_LO 0.361529 8 19 0.367027 9 16 0.396988 10 11 0.453794 11 9 0.561662 12 18 0.574366 13 13 0.597917 R_HI 0.617205 Array 0: 0.21293 1: 0.714471 2: 0.117707 3: 0.299329 4: 0.825003 5: 0.82466 6: 0.0618618 7: 0.710781 8: 0.0882833 9: 0.777994 10: 0.745303 11: 0.308675 12: 0.899373 13: 0.763537 14: 0.761731 15: 0.40697 16: 0.938749 17: 0.562088 18: 0.01782 19: 0.501103 I INDX R(INDX(I)) 0 18 0.01782 1 6 0.0618618 2 8 0.0882833 3 2 0.117707 4 0 0.21293 5 3 0.299329 6 11 0.308675 7 15 0.40697 8 19 0.501103 9 17 0.562088 10 7 0.710781 11 1 0.714471 12 10 0.745303 13 14 0.761731 14 13 0.763537 15 9 0.777994 16 5 0.82466 17 4 0.825003 18 12 0.899373 19 16 0.938749 R_LO 0.0419093 1 6 0.0618618 2 8 0.0882833 3 2 0.117707 4 0 0.21293 5 3 0.299329 6 11 0.308675 R_HI 0.368851 Array 0: 0.271724 1: 0.858573 2: 0.0290366 3: 0.0174423 4: 0.152384 5: 0.114319 6: 0.353907 7: 0.119308 8: 0.206653 9: 0.212924 10: 0.612948 11: 0.809519 12: 0.58709 13: 0.215492 14: 0.768056 15: 0.723297 16: 0.448019 17: 0.855176 18: 0.945017 19: 0.909057 I INDX R(INDX(I)) 0 3 0.0174423 1 2 0.0290366 2 5 0.114319 3 7 0.119308 4 4 0.152384 5 8 0.206653 6 9 0.212924 7 13 0.215492 8 0 0.271724 9 6 0.353907 10 16 0.448019 11 12 0.58709 12 10 0.612948 13 15 0.723297 14 14 0.768056 15 11 0.809519 16 17 0.855176 17 1 0.858573 18 19 0.909057 19 18 0.945017 R_LO 0.0301946 2 5 0.114319 3 7 0.119308 4 4 0.152384 5 8 0.206653 6 9 0.212924 7 13 0.215492 8 0 0.271724 9 6 0.353907 10 16 0.448019 R_HI 0.519726 Array 0: 0.481067 1: 0.292313 2: 0.90264 3: 0.667842 4: 0.412278 5: 0.156948 6: 0.833282 7: 0.964404 8: 0.74079 9: 0.456099 10: 0.653561 11: 0.406827 12: 0.540539 13: 0.832281 14: 0.145756 15: 0.717128 16: 0.775651 17: 0.362262 18: 0.531111 19: 0.379977 I INDX R(INDX(I)) 0 14 0.145756 1 5 0.156948 2 1 0.292313 3 17 0.362262 4 19 0.379977 5 11 0.406827 6 4 0.412278 7 9 0.456099 8 0 0.481067 9 18 0.531111 10 12 0.540539 11 10 0.653561 12 3 0.667842 13 15 0.717128 14 8 0.74079 15 16 0.775651 16 13 0.832281 17 6 0.833282 18 2 0.90264 19 7 0.964404 R_LO 0.269285 2 1 0.292313 3 17 0.362262 4 19 0.379977 5 11 0.406827 6 4 0.412278 7 9 0.456099 8 0 0.481067 9 18 0.531111 10 12 0.540539 11 10 0.653561 12 3 0.667842 13 15 0.717128 14 8 0.74079 15 16 0.775651 16 13 0.832281 17 6 0.833282 R_HI 0.877418 R8VEC_INDEXED_HEAP_D_TEST R8VEC_INDEXED_HEAP_D creates a descending heap from an indexed vector. The data vector: 0: 101 1: 102 2: 103 3: 104 4: 105 5: 106 6: 107 7: 108 8: 109 9: 110 10: 111 11: 112 12: 113 13: 114 14: 115 15: 116 16: 117 17: 118 18: 119 19: 120 The index vector: 0: 0 1: 10 2: 16 3: 4 4: 6 5: 12 6: 14 7: 2 8: 18 9: 8 A(INDX): 0 101 1 111 2 117 3 105 4 107 5 113 6 115 7 103 8 119 9 109 The data vector (should NOT change): 0: 101 1: 102 2: 103 3: 104 4: 105 5: 106 6: 107 7: 108 8: 109 9: 110 10: 111 11: 112 12: 113 13: 114 14: 115 15: 116 16: 117 17: 118 18: 119 19: 120 The index vector (may change): 0: 18 1: 10 2: 16 3: 4 4: 8 5: 12 6: 14 7: 2 8: 0 9: 6 A(INDX) is now a descending heap: 0 119 1 111 2 117 3 105 4 109 5 113 6 115 7 103 8 101 9 107 R8VEC_INDEXED_HEAP_D_EXTRACT_TEST For an indexed R8VEC, R8VEC_INDEXED_HEAP_D_EXTRACT extracts the maximum value; The data vector: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 10: 11 11: 12 12: 13 13: 14 14: 15 15: 16 16: 17 17: 18 18: 19 19: 20 The index vector: 0: 8 1: 1 2: 7 3: 13 4: 4 A(INDX): 0 9 1 2 2 8 3 14 4 5 The index vector after heaping: 0: 13 1: 8 2: 7 3: 1 4: 4 A(INDX) after heaping: 0 14 1 9 2 8 3 2 4 5 Inserting value 7 Current maximum is 14 Inserting value 15 Current maximum is 15 Inserting value 1 Current maximum is 15 Inserting value 19 Current maximum is 19 Inserting value 20 Current maximum is 20 The data vector after insertions: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 10: 11 11: 12 12: 13 13: 14 14: 15 15: 16 16: 17 17: 18 18: 19 19: 20 The index vector after insertions: 0: 19 1: 18 2: 13 3: 8 4: 14 5: 6 6: 7 7: 0 8: 1 9: 4 A(INDX) after insertions: 0 20 1 19 2 14 3 9 4 15 5 7 6 8 7 1 8 2 9 5 Now extract the maximum several times. Extracting maximum element A[19] = 20 Extracting maximum element A[18] = 19 Extracting maximum element A[14] = 15 Extracting maximum element A[13] = 14 Extracting maximum element A[8] = 9 The data vector after extractions: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 10: 11 11: 12 12: 13 13: 14 14: 15 15: 16 16: 17 17: 18 18: 19 19: 20 The index vector after extractions: 0: 7 1: 4 2: 6 3: 1 4: 0 A(INDX) after extractions: 0 8 1 5 2 7 3 2 4 1 R8VEC_INDEXED_HEAP_D_INSERT_TEST For an indexed R8VEC, R8VEC_INDEXED_HEAP_D_INSERT inserts a value into the heap. The data vector: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 10: 11 11: 12 12: 13 13: 14 14: 15 15: 16 16: 17 17: 18 18: 19 19: 20 The index vector: 0: 8 1: 1 2: 7 3: 13 4: 4 A(INDX): 0 9 1 2 2 8 3 14 4 5 The index vector after heaping: 0: 13 1: 8 2: 7 3: 1 4: 4 A(INDX) after heaping: 0 14 1 9 2 8 3 2 4 5 Inserting value 7 Current maximum is 14 Inserting value 15 Current maximum is 15 Inserting value 1 Current maximum is 15 Inserting value 19 Current maximum is 19 Inserting value 20 Current maximum is 20 The data vector after insertions: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 10: 11 11: 12 12: 13 13: 14 14: 15 15: 16 16: 17 17: 18 18: 19 19: 20 The index vector after insertions: 0: 19 1: 18 2: 13 3: 8 4: 14 5: 6 6: 7 7: 0 8: 1 9: 4 A(INDX) after insertions: 0 20 1 19 2 14 3 9 4 15 5 7 6 8 7 1 8 2 9 5 R8VEC_INDEXED_HEAP_D_MAX_TEST For an indexed R8VEC, R8VEC_INDEXED_HEAP_D_MAX reports the maximum value. The data vector: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 10: 11 11: 12 12: 13 13: 14 14: 15 15: 16 16: 17 17: 18 18: 19 19: 20 The index vector: 0: 8 1: 1 2: 7 3: 13 4: 4 A(INDX): 0 9 1 2 2 8 3 14 4 5 The index vector after heaping: 0: 13 1: 8 2: 7 3: 1 4: 4 A(INDX) after heaping: 0 14 1 9 2 8 3 2 4 5 Inserting value 7 Current maximum is 14 Inserting value 15 Current maximum is 15 Inserting value 1 Current maximum is 15 Inserting value 19 Current maximum is 19 Inserting value 20 Current maximum is 20 The data vector after insertions: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 10: 11 11: 12 12: 13 13: 14 14: 15 15: 16 16: 17 17: 18 18: 19 19: 20 The index vector after insertions: 0: 19 1: 18 2: 13 3: 8 4: 14 5: 6 6: 7 7: 0 8: 1 9: 4 A(INDX) after insertions: 0 20 1 19 2 14 3 9 4 15 5 7 6 8 7 1 8 2 9 5 TEST012555 R8VEC_INDICATOR0_NEW returns an indicator vector. Indicator0 vector: 0: 0 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 R8VEC_LEGENDRE_TEST R8VEC_LEGENDRE computes N Legendre points in [R1,R2]. N = 5 R1 = -1 R2 = 1 Legendre points: 0: -0.90618 1: -0.538469 2: 0 3: 0.538469 4: 0.90618 N = 7 R1 = 0 R2 = 10 Legendre points: 0: 0.25446 1: 1.29234 2: 2.97077 3: 5 4: 7.02923 5: 8.70766 6: 9.74554 R8VEC_LINSPACE_NEW_TEST For a R8VEC: R8VEC_LINSPACE_NEW: evenly spaced points between A and B; r8vec_linspace ( 5, 10, 20 ) 0: 10 1: 12.5 2: 15 3: 17.5 4: 20 R8VEC_MAX_TEST R8VEC_MAX produces the maximum entry in a real array. The array: 0: 0.218418 1: 0.956318 2: 0.829509 3: 0.561695 4: 0.415307 5: 0.0661187 6: 0.257578 7: 0.109957 8: 0.043829 9: 0.633966 R8VEC_MAX reports the maximum value is 0.956318. R8VEC_MAX_INDEX_TEST For an R8VEC: R8VEC_MAX_INDEX: index of maximum entry; Input vector: 0: -5.63163 1: 9.12635 2: 6.59018 3: 1.23391 4: -1.69386 5: -8.67763 6: -4.84844 7: -7.80086 8: -9.12342 9: 2.67931 Maximum index: 1 R8VEC_MEAN_TEST R8VEC_MEAN computes the mean of an R8VEC; Input vector: 0: -2.81582 1: 4.56318 2: 3.29509 3: 0.616954 4: -0.846929 5: -4.33881 6: -2.42422 7: -3.90043 8: -4.56171 9: 1.33966 Mean: -0.907304 R8VEC_MEDIAN_TEST For an R8VEC: R8VEC_MEDIAN: median value; Input vector: 0: -5.63163 1: 9.12635 2: 6.59018 3: 1.23391 4: -1.69386 5: -8.67763 6: -4.84844 7: -7.80086 8: -9.12342 9: 2.67931 Median: -4.84844 R8VEC_MIDSPACE_NEW_TEST For a R8VEC: R8VEC_MIDSPACE_NEW: evenly spaced midpoints between A and B r8vec_midspace ( 5, 10, 20 ) 0: 11 1: 13 2: 15 3: 17 4: 19 R8VEC_MIN_TEST R8VEC_MIN produces the minimum entry. The array: 0: 0.218418 1: 0.956318 2: 0.829509 3: 0.561695 4: 0.415307 5: 0.0661187 6: 0.257578 7: 0.109957 8: 0.043829 9: 0.633966 R8VEC_MIN reports the minimum value is 0.043829. R8VEC_MIN_INDEX_TEST For an R8VEC: R8VEC_MIN_INDEX: index of minimum entry; Input vector: 0: -5.63163 1: 9.12635 2: 6.59018 3: 1.23391 4: -1.69386 5: -8.67763 6: -4.84844 7: -7.80086 8: -9.12342 9: 2.67931 Minimum index: 8 R8VEC_NINT_TEST R8VEC_NINT rounds an R8VEC. Vector A: 0: -2.81582 1: 4.56318 2: 3.29509 3: 0.616954 4: -0.846929 Rounded vector A: 0: -3 1: 5 2: 3 3: 1 4: -1 R8VEC_NORM_L0_TEST R8VEC_NORM_L0 computes the L0 'norm' of an R8VEC. Input vector: 0: -1 1: 2 2: 1 3: 0 4: 0 5: -2 6: -1 7: -2 8: -2 9: 1 L0 norm: 8 R8VEC_NORM_L1_TEST R8VEC_NORM_L1 computes the L1 norm of an R8VEC. Input vector: 0: -5.63163 1: 9.12635 2: 6.59018 3: 1.23391 4: -1.69386 5: -8.67763 6: -4.84844 7: -7.80086 8: -9.12342 9: 2.67931 L1 norm: 57.4056 R8VEC_NORM_L2_TEST R8VEC_NORM_L2 computes the L2 norm of an R8VEC. Input vector: 0: -5.63163 1: 9.12635 2: 6.59018 3: 1.23391 4: -1.69386 5: -8.67763 6: -4.84844 7: -7.80086 8: -9.12342 9: 2.67931 L2 norm: 20.3201 R8VEC_NORM_LI_TEST R8VEC_NORM_LI computes the Loo norm of an R8VEC. Input vector: 0: -5.63163 1: 9.12635 2: 6.59018 3: 1.23391 4: -1.69386 5: -8.67763 6: -4.84844 7: -7.80086 8: -9.12342 9: 2.67931 L-Infinity norm: 9.12635 R8VEC_NORMAL_01_TEST R8VEC_NORMAL_01 computes a vector of normally distributed random numbers. Using initial random number seed = 123456789 Test #1: Call 5 times, 1 value each time. 0 1.67904 1 -0.56606 2 1.21293 3 1.26938 4 -1.66609 Test #2: Restore the random number seed. Call 5 times, 1 value each time. The results should be identical. 0 1.67904 1 -0.56606 2 1.21293 3 1.26938 4 -1.66609 Test #3: Restore the random number seed. Call 1 time for 5 values. The results should be identical. 0 1.67904 1 -0.472769 2 -0.56606 3 -0.231124 4 1.21293 Test #4: Restore the random number seed. Call for 2, 1, and 2 values. The results should be identical. 0 1.67904 1 -0.472769 0 -0.56606 0 1.21293 1 0.535037 Test #5: Number of samples was 1000 Minimum value was -3.02975 Maximum value was 3.32858 Average value was -0.0169841 Variance was 1.001 Expected average = 0.0 Expected variance = 1.0 R8VEC_NORMALIZE_L1_TEST For an R8VEC: R8VEC_NORMALIZE_L1: make unit sum; Input vector: 0: -5.63163 1: 9.12635 2: 6.59018 3: 1.23391 4: -1.69386 5: -8.67763 6: -4.84844 7: -7.80086 8: -9.12342 9: 2.67931 After calling R8VEC_NORMALIZE_L1: 0: 0.31035 1: -0.502938 2: -0.363174 3: -0.0679986 4: 0.0933457 5: 0.478209 6: 0.26719 7: 0.429892 8: 0.502776 9: -0.147652 R8VEC_ORDER_TYPE_TEST R8VEC_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. 0: 1 1: 3 2: 2 3: 4 The following vector has order type 0. 0: 2 1: 2 2: 2 3: 2 The following vector has order type 1. 0: 1 1: 2 2: 2 3: 4 The following vector has order type 2. 0: 1 1: 2 2: 3 3: 4 The following vector has order type 3. 0: 4 1: 4 2: 3 3: 1 The following vector has order type 4. 0: 9 1: 7 2: 3 3: 0 R8VEC_PERMUTE_TEST R8VEC_PERMUTE permutes an R8VEC in place. Original Array X[]: 0: 1 1: 2 2: 3 3: 4 4: 5 Permutation Vector P[]: 0: 1 1: 3 2: 4 3: 0 4: 2 Permuted array X[P[]]: 0: 2 1: 4 2: 5 3: 1 4: 3 R8VEC_PERMUTE_UNIFORM_TEST R8VEC_PERMUTE_UNIFORM randomly reorders an R8VEC. A, before rearrangement: 0: 101 1: 102 2: 103 3: 104 4: 105 5: 106 6: 107 7: 108 8: 109 9: 110 A, after random permutation: 0: 103 1: 110 2: 109 3: 107 4: 104 5: 106 6: 108 7: 105 8: 101 9: 102 R8VEC_POLARIZE_TEST R8VEC_POLARIZE decomposes a vector into components parallel and normal to a direction. Original vector: 0: 1 1: 2 2: 3 Direction vector: 0: 3 1: 1 2: -2 Normal component: 0: 1.21429 1: 2.07143 2: 2.85714 Parallel component: 0: -0.214286 1: -0.0714286 2: 0.142857 Dot product of P and A_normal (should be 0) 8.88178e-16 Cosine of angle between P and A_parallel (should be 1 or -1) -1 Sum of components (should equal A): 0: 1 1: 2 2: 3 TEST1335 R8VEC_PRINT prints an R8VEC. The R8VEC: 0: 123.456 1: 5e-06 2: -1e+06 3: 3.14159 R8VEC_ROTATE_TEST R8VEC_ROTATE rotates an R8VEC in place. Rotate entries 2 places to the right. Original array: 0: 1 1: 2 2: 3 3: 4 4: 5 Rotated array: 0: 4 1: 5 2: 1 3: 2 4: 3 R8VEC_REVERSE_TEST R8VEC_REVERSE reverses an R8VEC. Original array: 0: 1 1: 2 2: 3 3: 4 4: 5 Reversed array: 0: 5 1: 4 2: 3 3: 2 4: 1 R8VEC_SEARCH_BINARY_A_TEST For ascending order: R8VEC_SEARCH_BINARY_A searches a sorted array; Using initial random number seed = 123456789 Sorted vector A: 0: 0.043829 1: 0.0661187 2: 0.109957 3: 0.218418 4: 0.257578 5: 0.415307 6: 0.561695 7: 0.633966 8: 0.829509 9: 0.956318 Search the array for the value 0.218418 SEARCH RESULT: The value occurs in index 4 R8VEC_SORT_BUBBLE_A_TEST R8VEC_SORT_BUBBLE_A sorts a real array. Using random seed 123456789. Unsorted array: 0: 0.218418 1: 0.956318 2: 0.829509 3: 0.561695 4: 0.415307 5: 0.0661187 6: 0.257578 7: 0.109957 8: 0.043829 9: 0.633966 10: 0.0617272 11: 0.449539 12: 0.401306 13: 0.754673 14: 0.797287 15: 0.00183837 16: 0.897504 17: 0.350752 18: 0.0945448 19: 0.0136169 Sorted array: 0: 0.00183837 1: 0.0136169 2: 0.043829 3: 0.0617272 4: 0.0661187 5: 0.0945448 6: 0.109957 7: 0.218418 8: 0.257578 9: 0.350752 10: 0.401306 11: 0.415307 12: 0.449539 13: 0.561695 14: 0.633966 15: 0.754673 16: 0.797287 17: 0.829509 18: 0.897504 19: 0.956318 R8VEC_SORT_HEAP_A_TEST R8VEC_SORT_HEAP_A ascending sorts an R8VEC. Original array: 1: 13.1051 2: 57.3791 3: 49.7706 4: 33.7017 5: 24.9184 6: 3.96712 7: 15.4547 8: 6.59741 9: 2.62974 10: 38.0379 Ascending sorted array: 1: 0.110302 2: 0.817013 3: 2.62974 4: 3.70363 5: 3.96712 6: 5.67269 7: 6.59741 8: 13.1051 9: 15.4547 10: 21.0451 R8VEC_SORT_HEAP_D_TEST R8VEC_SORT_HEAP_D descending sorts an R8VEC. Original array: 1: 13.1051 2: 57.3791 3: 49.7706 4: 33.7017 5: 24.9184 6: 3.96712 7: 15.4547 8: 6.59741 9: 2.62974 10: 38.0379 Descending sorted array: 1: 0.110302 2: 57.3791 3: 33.7017 4: 38.0379 5: 0.817013 6: 45.2804 7: 6.59741 8: 21.0451 9: 24.9184 10: 3.70363 R8VEC_SORT_HEAP_INDEX_A_NEW_TEST R8VEC_SORT_HEAP_INDEX_A_NEW creates an ascending sort index for an R8VEC. Unsorted array: 0: 13.1051 1: 57.3791 2: 49.7706 3: 33.7017 4: 24.9184 5: 3.96712 6: 15.4547 7: 6.59741 8: 2.62974 9: 38.0379 10: 3.70363 11: 26.9723 12: 24.0784 13: 45.2804 14: 47.8372 15: 0.110302 16: 53.8502 17: 21.0451 18: 5.67269 19: 0.817013 After indexed ascending sort: I INDX(I) A(I) 0 15 13.1051 1 19 57.3791 2 8 49.7706 3 10 33.7017 4 5 24.9184 5 18 3.96712 6 7 15.4547 7 0 6.59741 8 6 2.62974 9 17 38.0379 10 12 3.70363 11 4 26.9723 12 11 24.0784 13 3 45.2804 14 9 47.8372 15 13 0.110302 16 14 53.8502 17 2 21.0451 18 16 5.67269 19 1 0.817013 Now use the index array to carry out the permutation implicitly. INDX(I) A(INDX(I)) 15 0.110302 19 0.817013 8 2.62974 10 3.70363 5 3.96712 18 5.67269 7 6.59741 0 13.1051 6 15.4547 17 21.0451 12 24.0784 4 24.9184 11 26.9723 3 33.7017 9 38.0379 13 45.2804 14 47.8372 2 49.7706 16 53.8502 1 57.3791 Call R8VEC_PERMUTE to carry out the permutation explicitly. I, A(I) 0: 0.110302 1: 0.817013 2: 2.62974 3: 3.70363 4: 3.96712 5: 5.67269 6: 6.59741 7: 13.1051 8: 15.4547 9: 21.0451 10: 24.0784 11: 24.9184 12: 26.9723 13: 33.7017 14: 38.0379 15: 45.2804 16: 47.8372 17: 49.7706 18: 53.8502 19: 57.3791 R8VEC_SORT_HEAP_INDEX_D_NEW_TEST R8VEC_SORT_HEAP_INDEX_D_NEW creates a descending sort index for an R8VEC. Unsorted array: 0: 13.1051 1: 57.3791 2: 49.7706 3: 33.7017 4: 24.9184 5: 3.96712 6: 15.4547 7: 6.59741 8: 2.62974 9: 38.0379 10: 3.70363 11: 26.9723 12: 24.0784 13: 45.2804 14: 47.8372 15: 0.110302 16: 53.8502 17: 21.0451 18: 5.67269 19: 0.817013 After indexed descending sort: I INDX(I) A(I) 0 1 13.1051 1 16 57.3791 2 2 49.7706 3 14 33.7017 4 13 24.9184 5 9 3.96712 6 3 15.4547 7 11 6.59741 8 4 2.62974 9 12 38.0379 10 17 3.70363 11 6 26.9723 12 0 24.0784 13 7 45.2804 14 18 47.8372 15 5 0.110302 16 10 53.8502 17 8 21.0451 18 19 5.67269 19 15 0.817013 Now use the index array to carry out the permutation implicitly. INDX(I) A(INDX(I)) 1 57.3791 16 53.8502 2 49.7706 14 47.8372 13 45.2804 9 38.0379 3 33.7017 11 26.9723 4 24.9184 12 24.0784 17 21.0451 6 15.4547 0 13.1051 7 6.59741 18 5.67269 5 3.96712 10 3.70363 8 2.62974 19 0.817013 15 0.110302 Call R8VEC_PERMUTE to carry out the permutation explicitly. I, A(I) 0: 57.3791 1: 53.8502 2: 49.7706 3: 47.8372 4: 45.2804 5: 38.0379 6: 33.7017 7: 26.9723 8: 24.9184 9: 24.0784 10: 21.0451 11: 15.4547 12: 13.1051 13: 6.59741 14: 5.67269 15: 3.96712 16: 3.70363 17: 2.62974 18: 0.817013 19: 0.110302 R8VEC_SORT_HEAP_MASK_A_TEST R8VEC_SORT_HEAP_MASK_A creates an ascending sort index for a masked R8VEC. Unsorted array: 0: 13.1051 1: 57.3791 2: 49.7706 3: 33.7017 4: 24.9184 5: 3.96712 6: 15.4547 7: 6.59741 8: 2.62974 9: 38.0379 10: 3.70363 11: 26.9723 12: 24.0784 13: 45.2804 14: 47.8372 15: 0.110302 16: 53.8502 17: 21.0451 18: 5.67269 19: 0.817013 The mask array: 0: 1 1: 3 2: 6 3: 7 4: 8 5: 11 6: 12 7: 15 8: 17 9: 18 Masked vector printout: The masked unsorted array: 0: 1 13.1051 1: 3 49.7706 2: 6 3.96712 3: 7 15.4547 4: 8 6.59741 5: 11 3.70363 6: 12 26.9723 7: 15 47.8372 8: 17 53.8502 9: 18 21.0451 After masked indexed ascending sort: I, INDX(I), MASK(INDX(I)), A(MASK(INDX(I))) 0 5 11 26.9723 1 2 6 15.4547 2 4 8 2.62974 3 0 1 57.3791 4 3 7 6.59741 5 9 18 5.67269 6 6 12 24.0784 7 7 15 0.110302 8 1 3 33.7017 9 8 17 21.0451 Call I4VEC_PERMUTE to carry out the index permutation explicitly on the MASK vector. The reordered mask array: 0: 11 1: 6 2: 8 3: 1 4: 7 5: 18 6: 12 7: 15 8: 3 9: 17 Masked vector printout: The reordered masked sorted array: 0: 11 3.70363 1: 6 3.96712 2: 8 6.59741 3: 1 13.1051 4: 7 15.4547 5: 18 21.0451 6: 12 26.9723 7: 15 47.8372 8: 3 49.7706 9: 17 53.8502 R8VEC_SORT_INSERT_A_TEST R8VEC_SORT_INSERT_A ascending sorts an R8VEC. Unsorted array: 1: 13.1051 2: 57.3791 3: 49.7706 4: 33.7017 5: 24.9184 6: 3.96712 7: 15.4547 8: 6.59741 9: 2.62974 10: 38.0379 Sorted array: 1: 0.110302 2: 0.817013 3: 2.62974 4: 3.70363 5: 3.96712 6: 5.67269 7: 6.59741 8: 13.1051 9: 15.4547 10: 21.0451 R8VEC_SORT_INSERT_INDEX_A_TEST R8VEC_SORT_INSERT_INDEX_A creates an ascending sort index for an R8VEC. Unsorted array: 1: 13.1051 2: 57.3791 3: 49.7706 4: 33.7017 5: 24.9184 6: 3.96712 7: 15.4547 8: 6.59741 9: 2.62974 10: 38.0379 After indexed ascending sort: I INDX(I), A(I) 0 15 13.1051 1 19 57.3791 2 8 49.7706 3 10 33.7017 4 5 24.9184 5 18 3.96712 6 7 15.4547 7 0 6.59741 8 6 2.62974 9 17 38.0379 10 12 3.70363 11 4 26.9723 12 11 24.0784 13 3 45.2804 14 9 47.8372 15 13 0.110302 16 14 53.8502 17 2 21.0451 18 16 5.67269 19 1 0.817013 Now use the index array to carry out the permutation implicitly. I INDX(I), A(INDX(I)) 0 15 0.110302 1 19 0.817013 2 8 2.62974 3 10 3.70363 4 5 3.96712 5 18 5.67269 6 7 6.59741 7 0 13.1051 8 6 15.4547 9 17 21.0451 10 12 24.0784 11 4 24.9184 12 11 26.9723 13 3 33.7017 14 9 38.0379 15 13 45.2804 16 14 47.8372 17 2 49.7706 18 16 53.8502 19 1 57.3791 Call R8VEC_PERMUTE to carry out the permutation explicitly. Permuted data 1: 0.110302 2: 0.817013 3: 2.62974 4: 3.70363 5: 3.96712 6: 5.67269 7: 6.59741 8: 13.1051 9: 15.4547 10: 21.0451 R8VEC_SORT_QUICK_A_TEST R8VEC_SORT_QUICK_A sorts an R8VEC using quick sort. Unsorted array: 0: 2.18418 1: 9.56318 2: 8.29509 3: 5.61695 4: 4.15307 5: 0.661187 6: 2.57578 7: 1.09957 8: 0.43829 9: 6.33966 10: 0.617272 11: 4.49539 12: 4.01306 13: 7.54673 14: 7.97287 15: 0.0183837 16: 8.97504 17: 3.50752 18: 0.945448 19: 0.136169 Sorted array: 0: 0.0183837 1: 0.136169 2: 0.43829 3: 0.617272 4: 0.661187 5: 0.945448 6: 1.09957 7: 2.18418 8: 2.57578 9: 3.50752 10: 4.01306 11: 4.15307 12: 4.49539 13: 5.61695 14: 6.33966 15: 7.54673 16: 7.97287 17: 8.29509 18: 8.97504 19: 9.56318 R8VEC_SORTED_MERGE_A_TEST For ascending order: R8VEC_SORTED_MERGE_A merges two sorted R8VEC's; Using initial random number seed = 123456789 Sorted vector A: 0: 0.043829 1: 0.0661187 2: 0.109957 3: 0.218418 4: 0.257578 5: 0.415307 6: 0.561695 7: 0.633966 8: 0.829509 9: 0.956318 Sorted vector B: 0: 0.00183837 1: 0.0136169 2: 0.0617272 3: 0.0945448 4: 0.350752 5: 0.401306 6: 0.449539 7: 0.754673 8: 0.797287 9: 0.897504 Merged vector C: 0: 0.00183837 1: 0.0136169 2: 0.043829 3: 0.0617272 4: 0.0661187 5: 0.0945448 6: 0.109957 7: 0.218418 8: 0.257578 9: 0.350752 10: 0.401306 11: 0.415307 12: 0.449539 13: 0.561695 14: 0.633966 15: 0.754673 16: 0.797287 17: 0.829509 18: 0.897504 19: 0.956318 R8VEC_SORTED_NEAREST_TEST R8VEC_SORTED_NEAREST finds the nearest entry in a sorted real array. Sorted array: 0: 0.43829 1: 0.661187 2: 1.09957 3: 2.18418 4: 2.57578 5: 4.15307 6: 5.61695 7: 6.33966 8: 8.29509 9: 9.56318 Test Nearest Value Index Value 0.0617272 1 0.43829 0.449539 1 0.43829 0.401306 1 0.43829 0.754673 2 0.661187 0.797287 2 0.661187 0.00183837 1 0.43829 0.897504 3 1.09957 0.350752 1 0.43829 0.0945448 1 0.43829 0.0136169 1 0.43829 R8VEC_SORTED_RANGE_TEST R8VEC_SORTED_RANGE seeks the range of indices in a sorted vector R so that R_LO <= R(I_LO:I_HI) <= R_HI. Sorted array R: 0: 0.043829 1: 0.0661187 2: 0.109957 3: 0.218418 4: 0.257578 5: 0.415307 6: 0.561695 7: 0.633966 8: 0.829509 9: 0.956318 R_LO 0.0617272 1 0.0661187 2 0.109957 3 0.218418 4 0.257578 5 0.415307 R_HI 0.449539 Sorted array R: 0: 0.00183837 1: 0.0136169 2: 0.0945448 3: 0.350752 4: 0.401306 5: 0.754673 6: 0.797287 7: 0.840847 8: 0.859097 9: 0.897504 R_LO 0.00751236 1 0.0136169 2 0.0945448 R_HI 0.123104 Sorted array R: 0: 0.113664 1: 0.260303 2: 0.267132 3: 0.351629 4: 0.453794 5: 0.561662 6: 0.692066 7: 0.822887 8: 0.861216 9: 0.912484 R_LO 0.597917 6 0.692066 7 0.822887 8 0.861216 R_HI 0.911977 Sorted array R: 0: 0.185314 1: 0.188955 2: 0.21293 3: 0.361529 4: 0.367027 5: 0.396988 6: 0.574366 7: 0.617205 8: 0.714471 9: 0.761492 R_LO 0.117707 0 0.185314 1 0.188955 2 0.21293 R_HI 0.299329 Sorted array R: 0: 0.0618618 1: 0.0882833 2: 0.308675 3: 0.710781 4: 0.745303 5: 0.763537 6: 0.777994 7: 0.82466 8: 0.825003 9: 0.899373 R_LO 0.40697 3 0.710781 4 0.745303 R_HI 0.761731 R8VEC_SORTED_SPLIT_TEST R8VEC_SORTED_SPLIT splits a sorted vector into entries less than and greater than a splitting value. The sorted array: 0: 0 1: 0 2: 0 3: 0 4: 0.5 5: 0.5 6: 0.5 7: 0.5 8: 0.5 9: 1 10: 1.5 11: 1.5 12: 2 13: 2 14: 2 15: 2 16: 3 17: 3 18: 4 19: 4 20: 4 21: 4 22: 4.5 23: 4.5 24: 5 Splitting value is 2.5 Lower index I_LT = 16 Upper index I_GT = 17 R8VEC_SORTED_UNDEX_TEST R8VEC_SORTED_UNDEX produces index vectors which create a sorted list of the unique elements of a sorted R8VEC, and a map from the original vector to the (implicit) vector of sorted unique elements. The vector X: 0: 11 1: 11 2: 11 3: 22 4: 22 5: 33 6: 33 7: 55 8: 55 Number of unique entries in X is 4 UNDX can be used to list the unique elements of X in sorted order. I UNDX X(UNDX) 0 0 11 1 3 22 2 5 33 3 7 55 UNDX can be used to created XU, a copy of X containing only the unique elements, in sorted order. I UNDX XU(I) 0 0 11 1 3 22 2 5 33 3 7 55 XDNU can be used to match each element of X with one of the unique elements I XDNU X(I) XU(XDNU(I)) 0 0 11 11 1 0 11 11 2 0 11 11 3 1 22 22 4 1 22 22 5 2 33 33 6 2 33 33 7 3 55 55 8 3 55 55 R8VEC_SORTED_UNIQUE_TEST R8VEC_SORTED_UNIQUE finds unique entries in a sorted R8VEC; Unsorted array: 1: 4 2: 19 3: 17 4: 11 5: 8 6: 1 7: 5 8: 2 9: 1 10: 13 Unique entries 0: 0 1: 1 2: 2 3: 4 4: 5 5: 7 6: 8 7: 9 8: 11 9: 13 10: 15 11: 16 12: 17 13: 18 14: 19 R8VEC_SORTED_UNIQUE_COUNT_TEST R8VEC_SORTED_UNIQUE_COUNT counts unique entries in a sorted R8VEC; Using a tolerance of 0.25 R8VEC_SORTED_UNIQUE_COUNT counts 30 unique entries in A. R8VEC_SORTED_UNIQUE_HIST_TEST R8VEC_SORTED_UNIQUE_HIST stores the unique entries and their multiplicities. Using random seed 123456789. Unsorted array: 0: 6.5 1: 28.5 2: 24.5 3: 16.5 4: 12.5 5: 1.5 6: 7.5 7: 3.5 8: 1.5 9: 19.5 10: 1.5 11: 13.5 12: 12.5 13: 22.5 14: 23.5 15: 0.5 16: 26.5 17: 10.5 18: 2.5 19: 0.5 20: 25.5 21: 25.5 22: 3.5 23: 0.5 24: 7.5 25: 27.5 26: 3.5 27: 10.5 28: 24.5 29: 8.5 Sorted array: 0: 0.5 1: 0.5 2: 0.5 3: 1.5 4: 1.5 5: 1.5 6: 2.5 7: 3.5 8: 3.5 9: 3.5 10: 6.5 11: 7.5 12: 7.5 13: 8.5 14: 10.5 15: 10.5 16: 12.5 17: 12.5 18: 13.5 19: 16.5 20: 19.5 21: 22.5 22: 23.5 23: 24.5 24: 24.5 25: 25.5 26: 25.5 27: 26.5 28: 27.5 29: 28.5 R8VEC_SORTED_UNIQUE_HIST counts 19 unique entries. Value Multiplicity 0 0.5 3 1 1.5 3 2 2.5 1 3 3.5 3 4 6.5 1 5 7.5 2 6 8.5 1 7 10.5 2 8 12.5 2 9 13.5 1 10 16.5 1 11 19.5 1 12 22.5 1 13 23.5 1 14 24.5 2 15 25.5 2 16 26.5 1 17 27.5 1 18 28.5 1 R8VEC_SPLIT_TEST R8VEC_SPLIT splits a vector into entries less than and greater than a splitting value. Splitting value is 1.25 The split array: 0: 1 1: 0 2: 0.5 3: 0 4: 0.5 5: 0.5 6: 0 7: 0.5 8: 0 9: 0.5 10: 2 11: 2 12: 4 13: 4 14: 3 15: 4.5 16: 2 17: 1.5 18: 2 19: 4.5 20: 4 21: 3 22: 4 23: 1.5 24: 5 Array entries <= SPLIT up to index 10 R8VEC_TRANSPOSE_PRINT_TEST R8VEC_TRANSPOSE_PRINT prints an R8VEC "transposed", that is, placing multiple entries on a line. The vector X: 0.218418 0.956318 0.829509 0.561695 0.415307 0.0661187 0.257578 0.109957 0.043829 0.633966 0.0617272 0.449539 R8VEC_UNDEX_TEST R8VEC_UNDEX produces index vectors which create a sorted list of the unique elements of an (unsorted) R8VEC, and a map from the original vector to the (implicit) vector of sorted unique elements. The vector X: 0: 33 1: 55 2: 11 3: 11 4: 55 5: 33 6: 22 7: 22 8: 11 Number of unique entries in X is 4 UNDX can be used to list the unique elements of X in sorted order. I UNDX X(UNDX) 0 2 11 1 6 22 2 5 33 3 4 55 UNDX can be used to created XU, a copy of X containing only the unique elements, in sorted order. I UNDX XU(I) 0 2 11 1 6 22 2 5 33 3 4 55 XDNU can be used to match each element of X with one of the unique elements I XDNU X(I) XU(XDNU(I)) 0 2 33 33 1 3 55 55 2 0 11 11 3 0 11 11 4 3 55 55 5 2 33 33 6 1 22 22 7 1 22 22 8 0 11 11 R8VEC_UNIFORM_01_NEW_TEST R8VEC_UNIFORM returns a random R8VEC with entries in [ 0.0, 1.0 ] Input SEED = 123456789 Random R8VEC: 0: 0.218418 1: 0.956318 2: 0.829509 3: 0.561695 4: 0.415307 5: 0.0661187 6: 0.257578 7: 0.109957 8: 0.043829 9: 0.633966 Input SEED = 1361431000 Random R8VEC: 0: 0.0617272 1: 0.449539 2: 0.401306 3: 0.754673 4: 0.797287 5: 0.00183837 6: 0.897504 7: 0.350752 8: 0.0945448 9: 0.0136169 Input SEED = 29242052 Random R8VEC: 0: 0.859097 1: 0.840847 2: 0.123104 3: 0.00751236 4: 0.260303 5: 0.912484 6: 0.113664 7: 0.351629 8: 0.822887 9: 0.267132 R8VEC_UNIFORM_AB_NEW_TEST R8VEC_UNIFORM returns a random R8VEC with entries in a given range [ A, B ] For this problem: A = 10 B = 20 Input SEED = 123456789 Random R8VEC: 0: 12.1842 1: 19.5632 2: 18.2951 3: 15.617 4: 14.1531 5: 10.6612 6: 12.5758 7: 11.0996 8: 10.4383 9: 16.3397 Input SEED = 1361431000 Random R8VEC: 0: 10.6173 1: 14.4954 2: 14.0131 3: 17.5467 4: 17.9729 5: 10.0184 6: 18.975 7: 13.5075 8: 10.9454 9: 10.1362 Input SEED = 29242052 Random R8VEC: 0: 18.591 1: 18.4085 2: 11.231 3: 10.0751 4: 12.603 5: 19.1248 6: 11.1366 7: 13.5163 8: 18.2289 9: 12.6713 R8VEC_VARIANCE_TEST R8VEC_VARIANCE computes the variance of an R8VEC; Input vector: 0: -2.81582 1: 4.56318 2: 3.29509 3: 0.616954 4: -0.846929 5: -4.33881 6: -2.42422 7: -3.90043 8: -4.56171 9: 1.33966 Variance: 10.5549 R8VEC2_SORT_A_TEST For a pair of R8VEC's: R8VEC2_SORT_A ascending sorts; The pair of arrays: 0: 1.43684 5.30864 1: 2.91264 7.24769 2: 1.43684 5.30864 3: 2.12339 8.77337 4: 1.83061 8.98643 5: 2.91264 7.24769 6: 1.51516 9.48752 7: 1.21991 6.75376 8: 1.43684 5.30864 9: 2.26793 5.06808 Arrays after ascending sort: 0: 1.21991 6.75376 1: 1.43684 5.30864 2: 1.43684 5.30864 3: 1.43684 5.30864 4: 1.51516 9.48752 5: 1.83061 8.98643 6: 2.12339 8.77337 7: 2.26793 5.06808 8: 2.91264 7.24769 9: 2.91264 7.24769 R8VEC2_SORT_D_TEST For a pair of R8VEC's: R8VEC2_SORT_D descending sorts; The pair of arrays: 0: 1.43684 5.30864 1: 2.91264 7.24769 2: 1.43684 5.30864 3: 2.12339 8.77337 4: 1.83061 8.98643 5: 2.91264 7.24769 6: 1.51516 9.48752 7: 1.21991 6.75376 8: 1.43684 5.30864 9: 2.26793 5.06808 Arrays after descending sort: 0: 2.91264 7.24769 1: 2.91264 7.24769 2: 2.26793 5.06808 3: 2.12339 8.77337 4: 1.83061 8.98643 5: 1.51516 9.48752 6: 1.43684 5.30864 7: 1.43684 5.30864 8: 1.43684 5.30864 9: 1.21991 6.75376 R8VEC2_SORT_HEAP_INDEX_A_TEST R8VEC2_SORT_HEAP_INDEX_A creates a sort index for an (X,Y) array. The unsorted array: I X(I), Y(I) 0 0.2 1 1 0.85 0.55 2 0.4 0.05 3 0.25 0.1 4 0 0.65 5 0.05 0.45 6 0.4 0.75 7 0.8 0 8 0.9 0.35 9 0.05 0 10 0.9 0.85 11 0.1 0 12 0.25 0.95 13 0.1 0.35 14 0.85 0.25 15 0.7 0.55 16 0.9 0.45 17 0.95 0.6 18 0.15 0.75 19 0.4 0.15 After sorting: I INDX(I), X(I), Y(I) 0 4 0.2 1 1 9 0.85 0.55 2 5 0.4 0.05 3 11 0.25 0.1 4 13 0 0.65 5 18 0.05 0.45 6 0 0.4 0.75 7 3 0.8 0 8 12 0.9 0.35 9 2 0.05 0 10 19 0.9 0.85 11 6 0.1 0 12 15 0.25 0.95 13 7 0.1 0.35 14 14 0.85 0.25 15 1 0.7 0.55 16 8 0.9 0.45 17 16 0.95 0.6 18 10 0.15 0.75 19 17 0.4 0.15 Now use the index array to carry out the permutation implicitly. I INDX(I), X(INDX(I)), Y(INDX(I)) 0 4 0 0.65 1 9 0.05 0 2 5 0.05 0.45 3 11 0.1 0 4 13 0.1 0.35 5 18 0.15 0.75 6 0 0.2 1 7 3 0.25 0.1 8 12 0.25 0.95 9 2 0.4 0.05 10 19 0.4 0.15 11 6 0.4 0.75 12 15 0.7 0.55 13 7 0.8 0 14 14 0.85 0.25 15 1 0.85 0.55 16 8 0.9 0.35 17 16 0.9 0.45 18 10 0.9 0.85 19 17 0.95 0.6 R8VEC_PERMUTE carries out the permutation. I X(I), Y(I) 0 0 0.65 1 0.05 0 2 0.05 0.45 3 0.1 0 4 0.1 0.35 5 0.15 0.75 6 0.2 1 7 0.25 0.1 8 0.25 0.95 9 0.4 0.05 10 0.4 0.15 11 0.4 0.75 12 0.7 0.55 13 0.8 0 14 0.85 0.25 15 0.85 0.55 16 0.9 0.35 17 0.9 0.45 18 0.9 0.85 19 0.95 0.6 R8VEC2_SORTED_UNIQUE_TEST For a pair of R8VEC's: R8VEC2_SORTED_UNIQUE counts unique entries. The pair of arrays: 0: 1.43684 5.30864 1: 2.91264 7.24769 2: 1.43684 5.30864 3: 2.12339 8.77337 4: 1.83061 8.98643 5: 2.91264 7.24769 6: 1.51516 9.48752 7: 1.21991 6.75376 8: 1.43684 5.30864 9: 2.26793 5.06808 Arrays after ascending sort: 0: 1.21991 6.75376 1: 1.43684 5.30864 2: 1.43684 5.30864 3: 1.43684 5.30864 4: 1.51516 9.48752 5: 1.83061 8.98643 6: 2.12339 8.77337 7: 2.26793 5.06808 8: 2.91264 7.24769 9: 2.91264 7.24769 UNIQed array: 0: 1.21991 6.75376 1: 1.43684 5.30864 2: 1.51516 9.48752 3: 1.83061 8.98643 4: 2.12339 8.77337 5: 2.26793 5.06808 6: 2.91264 7.24769 R8VEC2_SORTED_UNIQUE_INDEX_TEST For a pair of R8VEC's: R8VEC2_SORTED_UNIQUE_INDEX indexes unique entries. The pair of arrays: 0: 1.43684 5.30864 1: 2.91264 7.24769 2: 1.43684 5.30864 3: 2.12339 8.77337 4: 1.83061 8.98643 5: 2.91264 7.24769 6: 1.51516 9.48752 7: 1.21991 6.75376 8: 1.43684 5.30864 9: 2.26793 5.06808 The number of unique elements is 10 Index of Unique Elements: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 After Indexed Nonunique Deletion. 0: 1.43684 5.30864 1: 2.91264 7.24769 2: 1.43684 5.30864 3: 2.12339 8.77337 4: 1.83061 8.98643 5: 2.91264 7.24769 6: 1.51516 9.48752 7: 1.21991 6.75376 8: 1.43684 5.30864 9: 2.26793 5.06808 R8VEC2_SUM_MAX_INDEX_TEST For a pair of R8VEC's: R8VEC2_SUM_MAX_INDEX: index of the sum vector with maximum value. The pair of vectors: 0: 2.18418 0.308636 1: 9.56318 2.24769 2: 8.29509 2.00653 3: 5.61695 3.77337 4: 4.15307 3.98643 5: 0.661187 0.00919186 6: 2.57578 4.48752 7: 1.09957 1.75376 8: 0.43829 0.472724 9: 6.33966 0.0680845 Index of maximum in A+B: 2 ROOTS_TO_R8POLY_TEST: ROOTS_TO_R8POLY is given N real roots, and constructs the coefficient vector of the corresponding polynomial. N real roots: 0: 1 1: -4 2: 3 3: 0 4: 3 Corresponding polynomial: p(x) = 1 * x ^ 5 - 3 * x ^ 4 - 13 * x ^ 3 + 51 * x ^ 2 - 36 * x R8LIB_PRB Normal end of execution. 24 May 2015 11:39:00 AM