>> r8lib_test 08-Aug-2012 12:19:06 R8LIB_TEST MATLAB version Test the R8LIB library. TEST001 R8_ABS returns the absolute value of an R8. X R8_ABS(X) -1.252654 1.252654 4.650541 4.650541 3.636074 3.636074 1.493564 1.493564 0.322457 0.322457 -2.471050 2.471050 -0.939378 0.939378 -2.120346 2.120346 -2.649368 2.649368 2.071726 2.071726 TEST002 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.000000 0.000000 0.000000 0.000000 1.000000 1.000000 0.785398 0.785398 0.000000 1.000000 1.570796 1.570796 -1.000000 1.000000 2.356194 2.356194 -1.000000 0.000000 3.141593 3.141593 -1.000000 -1.000000 -2.356194 3.926991 0.000000 -1.000000 -1.570796 4.712389 1.000000 -1.000000 -0.785398 5.497787 TEST003 R8_CAS evaluates the casine of a number. X R8_CAS ( X ) 0.000000 1.000000 0.261799 1.224745 0.523599 1.366025 0.785398 1.414214 1.047198 1.366025 1.308997 1.224745 1.570796 1.000000 1.832596 0.707107 2.094395 0.366025 2.356194 0.000000 2.617994 -0.366025 2.879793 -0.707107 3.141593 -1.000000 TEST004 R8_CEILING rounds a value up. -1.200000 -1 -1.000000 -1 -0.800000 0 -0.600000 0 -0.400000 0 -0.200000 0 0.000000 0 0.200000 1 0.400000 1 0.600000 1 0.800000 1 1.000000 1 1.200000 2 TEST005 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.000000 0.062500 0.937500 0.875000 1.000000 0.125000 0.875000 0.875000 1.000000 0.250000 0.750000 0.750000 1.000000 0.500000 0.500000 0.500000 1.000000 0.874000 0.126000 0.125000 1.000000 0.876000 0.124000 0.125000 1.000000 0.900000 0.100000 0.125000 1.000000 0.950000 0.050000 0.000000 1.000000 0.990000 0.010000 0.000000 1.000000 1.000000 0.000000 0.000000 1.000000 1.010000 -0.010000 0.000000 1.000000 1.050000 -0.050000 0.000000 1.000000 1.100000 -0.100000 -0.137500 1.000000 3.000000 -2.000000 -1.875000 1.000000 10.000000 -9.000000 -8.750000 TEST006 R8_DIGIT extracts decimal digits. Here, we get digits of 3.141593 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 TEST007 R8_EPSILON produces the R8 roundoff unit. R = R8_EPSILON() = 2.220446e-16 ( 1 + R ) - 1 = 2.220446e-16 ( 1 + (R/2) ) - 1 = 0.000000e+00 R = EPS = 2.220446e-16 ( 1 + R ) - 1 = 2.220446e-16 ( 1 + (R/2) ) - 1 = 0.000000e+00 TEST008 R8_FRACTIONAL returns the fractional part of an R8. -1.252654 0.252654 4.650541 0.650541 3.636074 0.636074 1.493564 0.493564 0.322457 0.322457 -2.471050 0.471050 -0.939378 0.939378 -2.120346 0.120346 -2.649368 0.649368 2.071726 0.071726 TEST009 R8_HUGE returns the largest R8 value; R8_HUGE = 1000000000000000019884624838656.000000 TEST010 R8_LOG_2 computes the logarithm base 2. X, D_LOG_2 0.000000 -Inf 1.000000 0.000000 2.000000 1.000000 3.000000 1.584963 9.000000 3.169925 10.000000 3.321928 11.000000 3.459432 99.000000 6.629357 101.000000 6.658211 -1.000000 0.000000 -2.000000 1.000000 -3.000000 1.584963 -9.000000 3.169925 0.500000 -1.000000 0.330000 -1.599462 0.250000 -2.000000 0.200000 -2.321928 0.010000 -6.643856 TEST011 R8_LOG_B computes the logarithm base B. X, B, R8_LOG_B 16.000000 2.000000 4.000000 16.000000 3.000000 2.523719 16.000000 4.000000 2.000000 16.000000 5.000000 1.722706 16.000000 6.000000 1.547411 16.000000 7.000000 1.424829 16.000000 8.000000 1.333333 16.000000 16.000000 1.000000 16.000000 32.000000 0.800000 16.000000 256.000000 0.500000 TEST012 R8_MANT decomposes a value. Number to be decomposed: -314.159000 R8_MANT: X = -1 * 1.227184 * 2^ 8 TEST013 R8_MOD returns the remainder after division. X Y MOD(X,Y) R8_MOD(X,Y) -5.631634 9.126352 3.494717 -5.631634 6.590185 1.233909 0.420640 0.420640 -1.693858 -8.677625 -1.693858 -1.693858 -4.848444 -7.800864 -4.848444 -4.848444 -9.123420 2.679314 1.593837 -1.085477 -8.765455 -1.009221 -0.691689 -0.691689 -1.973874 5.093470 3.119595 -1.973874 5.945739 -9.963233 -4.017493 5.945739 7.950081 -2.984953 -1.004779 1.980175 -8.109105 -9.727662 -8.109105 -8.109105 TEST014 R8_MODP returns the remainder after division. Unlike the MATLAB MOD, R8_MODP ( X, Y ) is positive. X Y MOD(X,Y) R8_MODP(X,Y) -5.631634 9.126352 3.494717 3.494717 6.590185 1.233909 0.420640 0.420640 -1.693858 -8.677625 -1.693858 6.983767 -4.848444 -7.800864 -4.848444 2.952420 -9.123420 2.679314 1.593837 1.593837 -8.765455 -1.009221 -0.691689 0.317532 -1.973874 5.093470 3.119595 3.119595 5.945739 -9.963233 -4.017493 5.945739 7.950081 -2.984953 -1.004779 1.980175 -8.109105 -9.727662 -8.109105 1.618557 TEST015 R8_NINT produces the nearest integer. -5.631634 -6 9.126352 10 6.590185 7 1.233909 2 -1.693858 -2 -8.677625 -9 -4.848444 -5 -7.800864 -8 -9.123420 -10 2.679314 3 TEST016 R8_NORMAL_01 generates normally distributed random values. Using initial random number seed = 123456789 1.679040 -0.472769 -0.566060 -0.231124 1.212934 0.535037 1.269381 1.049543 -1.666087 -1.865228 -2.242464 0.735809 0.039675 -1.350736 0.673068 0.007775 -0.275127 0.374940 2.164005 0.185600 TEST017 R8_PI returns the value of PI. R8_PI = 3.1415926535897931 4 * Atan(1) = 3.1415926535897931 PI = 3.1415926535897931 TEST018 R8_POWER computes R^P. R P R8_POWER 2.000000 -5 0.031250 2.000000 -4 0.062500 2.000000 -3 0.125000 2.000000 -2 0.250000 2.000000 -1 0.500000 2.000000 0 1.000000 2.000000 1 2.000000 2.000000 2 4.000000 2.000000 3 8.000000 2.000000 4 16.000000 2.000000 5 32.000000 TEST019 R8_POWER_FAST computes R^P, economizing on multiplications. R P R^P Mults 2.000000 -10 0.000977 7 2.000000 -9 0.001953 7 2.000000 -8 0.003906 6 2.000000 -7 0.007812 7 2.000000 -6 0.015625 6 2.000000 -5 0.031250 6 2.000000 -4 0.062500 5 2.000000 -3 0.125000 5 2.000000 -2 0.250000 4 2.000000 -1 0.500000 1 2.000000 0 1.000000 0 2.000000 1 2.000000 0 2.000000 2 4.000000 3 2.000000 3 8.000000 4 2.000000 4 16.000000 4 2.000000 5 32.000000 5 2.000000 6 64.000000 5 2.000000 7 128.000000 6 2.000000 8 256.000000 5 2.000000 9 512.000000 6 2.000000 10 1024.000000 6 2.000000 11 2048.000000 7 2.000000 12 4096.000000 6 2.000000 13 8192.000000 7 2.000000 14 16384.000000 7 2.000000 15 32768.000000 8 2.000000 16 65536.000000 6 2.000000 17 131072.000000 7 2.000000 18 262144.000000 7 2.000000 19 524288.000000 8 2.000000 20 1048576.000000 7 2.000000 21 2097152.000000 8 2.000000 22 4194304.000000 8 2.000000 23 8388608.000000 9 2.000000 24 16777216.000000 7 2.000000 25 33554432.000000 8 2.000000 26 67108864.000000 8 2.000000 27 134217728.000000 9 2.000000 28 268435456.000000 8 2.000000 29 536870912.000000 9 2.000000 30 1073741824.000000 9 2.000000 31 2147483648.000000 10 2.000000 32 4294967296.000000 7 2.000000 33 8589934592.000000 8 2.000000 34 17179869184.000000 8 2.000000 35 34359738368.000000 9 2.000000 36 68719476736.000000 8 2.000000 37 137438953472.000000 9 2.000000 38 274877906944.000000 9 2.000000 39 549755813888.000000 10 2.000000 40 1099511627776.000000 8 TEST020 R8_ROUND2 rounds a number to a specified number of base 2 digits. Test effect on PI: X = 3.141593 NPLACE XROUND 0 0.000000 1 2.000000 2 3.000000 3 3.000000 4 3.000000 5 3.125000 6 3.125000 7 3.125000 8 3.140625 9 3.140625 10 3.140625 11 3.140625 12 3.140625 13 3.141113 14 3.141357 15 3.141479 16 3.141541 17 3.141571 18 3.141586 19 3.141586 20 3.141590 TEST021 R8_ROUNDB rounds a number to a specified number of base BASE digits. Here, we will use BASE = 3 Test effect on PI: X = 3.141593 NPLACE XROUND 0 0.000000 1 3.000000 2 3.000000 3 3.000000 4 3.111111 5 3.111111 6 3.135802 7 3.139918 8 3.141289 9 3.141289 10 3.141442 11 3.141543 12 3.141577 13 3.141589 14 3.141592 15 3.141592 16 3.141593 17 3.141593 18 3.141593 19 3.141593 20 3.141593 Try with a negative base: Input quantity is X = 121.000000 to be rounded in base -3 Output value to 1 places is 81.000000 Output value to 2 places is 108.000000 Output value to 3 places is 117.000000 Output value to 4 places is 120.000000 Output value to 5 places is 121.000000 TEST022 R8_ROUNDX rounds a number to a specified number of decimal digits. Test effect on PI: X = 3.141593 NPLACE XROUND 0 0.000000 1 3.000000 2 3.100000 3 3.140000 4 3.141000 5 3.141500 6 3.141590 7 3.141592 8 3.141593 9 3.141593 10 3.141593 Test effect on random values: NPLACE X XROUND 0 0.218418 0.000000 2 0.218418 0.210000 4 0.218418 0.218400 6 0.218418 0.218418 8 0.218418 0.218418 10 0.218418 0.218418 0 0.956318 0.000000 2 0.956318 0.950000 4 0.956318 0.956300 6 0.956318 0.956317 8 0.956318 0.956318 10 0.956318 0.956318 0 0.829509 0.000000 2 0.829509 0.820000 4 0.829509 0.829500 6 0.829509 0.829509 8 0.829509 0.829509 10 0.829509 0.829509 0 0.561695 0.000000 2 0.561695 0.560000 4 0.561695 0.561600 6 0.561695 0.561695 8 0.561695 0.561695 10 0.561695 0.561695 0 0.415307 0.000000 2 0.415307 0.410000 4 0.415307 0.415300 6 0.415307 0.415307 8 0.415307 0.415307 10 0.415307 0.415307 TEST023 R8_SIGN returns the sign of a number. -1.250000 -1.000000 -0.250000 -1.000000 0.000000 1.000000 0.500000 1.000000 9.000000 1.000000 TEST0235 R8_SWAP swaps two reals. Before swapping: X = 1.000000 Y = 3.141590 After swapping: X = 3.141590 Y = 1.000000 TEST024 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.000000, 10.000000] R RD 1.839438 1.947368 11.432128 10.000000 9.783620 10.000000 6.302041 6.210526 4.398992 4.315789 -0.140456 1.000000 2.348511 2.421053 0.429438 1.000000 -0.430223 1.000000 7.241554 7.157895 -0.197546 1.000000 4.844006 4.789474 4.216982 4.315789 8.810755 8.578947 9.364730 9.526316 TEST025 R8_TO_I4 finds an integer IX in [IXMIN,IXMAX] corresponding to X in [XMIN,XMAX]. XMIN = 2.500000, X = 3.500000, XMAX = 5.500000 IXMIN = 10, IX = 20, IXMAX = 40 TEST026 R8_UNIFORM returns random values in a given range: [ B, C ] For this problem: B = 10.000000 C = 20.000000 12.184183 19.563176 18.295092 15.616954 14.153071 10.661187 12.575778 11.099568 10.438290 16.339657 TEST027 R8_UNIFORM_01 produces a sequence of random values. Using random seed 123456789 SEED R8_UNIFORM_01(SEED) 469049721 0.218418 2053676357 0.956318 1781357515 0.829509 1206231778 0.561695 891865166 0.415307 141988902 0.066119 553144097 0.257578 236130416 0.109957 94122056 0.043829 1361431000 0.633966 Verify that the sequence can be restarted. Set the seed back to its original value, and see that we generate the same sequence. SEED R8_UNIFORM_01(SEED) 469049721 0.218418 2053676357 0.956318 1781357515 0.829509 1206231778 0.561695 891865166 0.415307 141988902 0.066119 553144097 0.257578 236130416 0.109957 94122056 0.043829 1361431000 0.633966 TEST028 R8_UNIFORM_01 samples a uniform random distribution in [0,1]. Starting with seed = 123456789 First few values: 1 0.218418 2 0.956318 3 0.829509 4 0.561695 5 0.415307 Number of values computed was N = 1000 Average value was 0.503040 Minimum value was 0.001838 Maximum value was 0.997908 Variance was 0.082332 TEST029 R8_WALSH_1D evaluates 1D Walsh functions: X W(+2) W(+1) W(0) W(-1) W(-2) W(-3) 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.250000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.500000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.750000 0.000000 0.000000 0.000000 1.000000 1.000000 0.000000 1.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.250000 0.000000 0.000000 1.000000 0.000000 1.000000 0.000000 1.500000 0.000000 0.000000 1.000000 1.000000 0.000000 0.000000 1.750000 0.000000 0.000000 1.000000 1.000000 1.000000 0.000000 2.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 2.250000 0.000000 1.000000 0.000000 0.000000 1.000000 0.000000 2.500000 0.000000 1.000000 0.000000 1.000000 0.000000 0.000000 2.750000 0.000000 1.000000 0.000000 1.000000 1.000000 0.000000 3.000000 0.000000 1.000000 1.000000 0.000000 0.000000 0.000000 3.250000 0.000000 1.000000 1.000000 0.000000 1.000000 0.000000 3.500000 0.000000 1.000000 1.000000 1.000000 0.000000 0.000000 3.750000 0.000000 1.000000 1.000000 1.000000 1.000000 0.000000 4.000000 1.000000 0.000000 0.000000 0.000000 0.000000 0.000000 4.250000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 4.500000 1.000000 0.000000 0.000000 1.000000 0.000000 0.000000 4.750000 1.000000 0.000000 0.000000 1.000000 1.000000 0.000000 5.000000 1.000000 0.000000 1.000000 0.000000 0.000000 0.000000 5.250000 1.000000 0.000000 1.000000 0.000000 1.000000 0.000000 5.500000 1.000000 0.000000 1.000000 1.000000 0.000000 0.000000 5.750000 1.000000 0.000000 1.000000 1.000000 1.000000 0.000000 6.000000 1.000000 1.000000 0.000000 0.000000 0.000000 0.000000 6.250000 1.000000 1.000000 0.000000 0.000000 1.000000 0.000000 6.500000 1.000000 1.000000 0.000000 1.000000 0.000000 0.000000 6.750000 1.000000 1.000000 0.000000 1.000000 1.000000 0.000000 7.000000 1.000000 1.000000 1.000000 0.000000 0.000000 0.000000 7.250000 1.000000 1.000000 1.000000 0.000000 1.000000 0.000000 7.500000 1.000000 1.000000 1.000000 1.000000 0.000000 0.000000 7.750000 1.000000 1.000000 1.000000 1.000000 1.000000 0.000000 8.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 TEST0295 R8_WRAP "wraps" an R8 to lie within an interval: Wrapping interval is 3.000000, 6.500000 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 R8LIB_TEST031 R82POLY2_TYPE determines the type of a second order equation in two variables. p(x,y) = 9 * x^2 + -4 * y^2 + 0 * xy + -36 * x + -24 * y + -36 Type = 1 The set of solutions forms a hyperbola. p(x,y) = 4 * x^2 + 1 * y^2 + -4 * xy + 3 * x + -4 * y + 1 Type = 2 The set of solutions forms a parabola. p(x,y) = 9 * x^2 + 16 * y^2 + 0 * xy + 36 * x + -32 * y + -92 Type = 3 The set of solutions forms an ellipse. p(x,y) = 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). p(x,y) = 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. p(x,y) = 1 * x^2 + 2 * y^2 + 0 * xy + -2 * x + 16 * y + 33 Type = 6 The set of solutions is a single point. p(x,y) = 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. p(x,y) = 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). p(x,y) = 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. p(x,y) = 0 * x^2 + 0 * y^2 + 0 * xy + 2 * x + -1 * y + 1 Type = 10 The set of solutions forms a single line. p(x,y) = 0 * x^2 + 0 * y^2 + 0 * xy + 0 * x + 0 * y + 0 Type = 11 The set of solutions is all space. p(x,y) = 0 * x^2 + 0 * y^2 + 0 * xy + 0 * x + 0 * y + 1 Type = 12 The set of solutions is empty. R8LIB_TEST032 R82VEC_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 1: 1 3 2: 2 2 3: 1 0 4: 1 0 Order type = -1 1: 0 2 2: 0 1 3: 1 2 4: 2 0 Order type = -1 1: 3 1 2: 0 0 3: 3 3 4: 0 0 Order type = -1 1: 1 3 2: 0 1 3: 2 1 4: 2 2 Order type = -1 1: 3 1 2: 3 2 3: 1 2 4: 1 1 Order type = 3 1: 2 1 2: 2 1 3: 1 2 4: 0 1 Order type = -1 1: 2 2 2: 0 2 3: 0 2 4: 2 1 Order type = -1 1: 3 2 2: 2 1 3: 3 2 4: 0 2 Order type = -1 1: 0 1 2: 1 3 3: 0 0 4: 0 0 Order type = -1 1: 1 0 2: 1 1 3: 2 2 4: 2 1 R8LIB_TEST033 R82VEC_PART_QUICK_A reorders a D2 vector as part of a quick sort. Using initial random number seed = Before rearrangement: 1: 2.18418 9.56318 2: 8.29509 5.61695 3: 4.15307 0.661187 4: 2.57578 1.09957 5: 0.43829 6.33966 6: 0.617272 4.49539 7: 4.01306 7.54673 8: 7.97287 0.0183837 9: 8.97504 3.50752 10: 0.945448 0.136169 11: 8.59097 8.40847 12: 1.23104 0.0751236 Rearranged array Left index = 4 Key index = 5 Right index = 6 Left half: 1: 1.23104 0.0751236 2: 0.945448 0.136169 3: 0.617272 4.49539 4: 0.43829 6.33966 Key: 1: 2.18418 9.56318 Right half: 1: 4.01306 7.54673 2: 7.97287 0.0183837 3: 8.97504 3.50752 4: 2.57578 1.09957 5: 8.59097 8.40847 6: 4.15307 0.661187 7: 8.29509 5.61695 R8LIB_TEST034 R82VEC_SORT_HEAP_INDEX_A index sorts an R82VEC using heapsort. Using initial random number seed = 123456789 Before rearrangement: 1: 2.18418 9.56318 2: 8.29509 3.50752 3: 0.43829 0.661187 4: 1.23104 1.09957 5: 0.43829 6.33966 6: 0.617272 9.56318 7: 8.59097 8.40847 8: 7.97287 0.0183837 9: 8.97504 3.50752 10: 0.945448 0.136169 11: 8.59097 8.40847 12: 1.23104 0.0751236 I Index A(Index) 1 3 4.382900e-01 6.611873e-01 2 5 4.382900e-01 6.339657e+00 3 6 6.172723e-01 9.563176e+00 4 10 9.454475e-01 1.361689e-01 5 12 1.231039e+00 7.512364e-02 6 4 1.231039e+00 1.099568e+00 7 1 2.184183e+00 9.563176e+00 8 8 7.972870e+00 1.838371e-02 9 2 8.295092e+00 3.507523e+00 10 7 8.590969e+00 8.408475e+00 11 11 8.590969e+00 8.408475e+00 12 9 8.975041e+00 3.507523e+00 After rearrangement by R82VEC_PERMUTE: 1: 0.43829 0.661187 2: 0.43829 6.33966 3: 0.617272 9.56318 4: 0.945448 0.136169 5: 1.23104 0.0751236 6: 1.23104 1.09957 7: 2.18418 9.56318 8: 7.97287 0.0183837 9: 8.29509 3.50752 10: 8.59097 8.40847 11: 8.59097 8.40847 12: 8.97504 3.50752 R8LIB_TEST035 R82VEC_SORT_QUICK_A sorts an R82VEC using quick sort. Using initial random number seed = 123456789 Before rearrangement: 1: 2.18418 9.56318 2: 8.29509 3.50752 3: 0.43829 0.661187 4: 1.23104 1.09957 5: 0.43829 6.33966 6: 0.617272 9.56318 7: 8.59097 8.40847 8: 7.97287 0.0183837 9: 8.97504 3.50752 10: 0.945448 0.136169 11: 8.59097 8.40847 12: 1.23104 0.0751236 Sorted array: 1: 0.43829 0.661187 2: 0.43829 6.33966 3: 0.617272 9.56318 4: 0.945448 0.136169 5: 1.23104 0.0751236 6: 1.23104 1.09957 7: 2.18418 9.56318 8: 7.97287 0.0183837 9: 8.29509 3.50752 10: 8.59097 8.40847 11: 8.59097 8.40847 12: 8.97504 3.50752 R8LIB_TEST036 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 R8LIB_TEST0365 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 R8LIB_TEST037 R8COL_FIND finds a column in a table matching a given set of data. R8COL_FIND returns ICOL = 3 R8LIB_TEST038 R8COL_SORT_HEAP_A ascending heap sorts a table of columns. R8COL_INSERT inserts new columns. The unsorted matrix: Col: 1 2 3 4 Row 1 : 2 4 1 3 2 : 6 8 5 7 3 : 10 12 9 11 The sorted matrix: Col: 1 2 3 4 Row 1 : 1 2 3 4 2 : 5 6 7 8 3 : 9 10 11 12 New column: 1: 3 2: 7 3: 11 The data was already in column 3 New column: 1: 3 2: 4 3: 18 The updated matrix: Col: 1 2 3 4 5 Row 1 : 1 2 3 3 4 2 : 5 6 4 7 8 3 : 9 10 18 11 12 R8LIB_TEST0385 R8COL_SORT_HEAP_INDEX_A computes an index vector which ascending heap sorts an R8COL. The unsorted R8COL (transposed): Row: 1 2 3 Col 1: 2.000000 6.000000 10.000000 2: 4.000000 8.000000 12.000000 3: 1.000000 5.000000 9.000000 4: 3.000000 7.000000 11.000000 5: 2.000000 6.000000 0.000000 6: 3.000000 4.000000 18.000000 7: 0.000000 0.000000 0.000000 8: 0.000000 6.000000 10.000000 9: 2.000000 6.000000 10.000000 10: 3.000000 7.000000 11.000000 11: 2.000000 0.000000 10.000000 12: 2.000000 6.000000 10.000000 13: 1.000000 5.000000 9.000000 14: 1.000000 5.000000 9.100000 15: 1.000000 5.100000 9.000000 The (implicitly) sorted R8COL (transposed) 7: 0.000000 0.000000 0.000000 8: 0.000000 6.000000 10.000000 13: 1.000000 5.000000 9.000000 3: 1.000000 5.000000 9.000000 14: 1.000000 5.000000 9.100000 15: 1.000000 5.100000 9.000000 11: 2.000000 0.000000 10.000000 5: 2.000000 6.000000 0.000000 12: 2.000000 6.000000 10.000000 9: 2.000000 6.000000 10.000000 1: 2.000000 6.000000 10.000000 6: 3.000000 4.000000 18.000000 10: 3.000000 7.000000 11.000000 4: 3.000000 7.000000 11.000000 2: 4.000000 8.000000 12.000000 R8LIB_TEST039 R8COL_SORT_QUICK_A sorts a table of columns. The unsorted matrix: Col: 1 2 3 4 5 Row 1 : 2.18418 5.61695 2.57578 6.33966 4.01306 2 : 9.56318 4.15307 1.09957 0.617272 7.54673 3 : 8.29509 0.661187 0.43829 4.49539 7.97287 Col: 6 7 8 9 10 Row 1 : 0.0183837 0.945448 8.40847 2.60303 3.51629 2 : 8.97504 0.136169 1.23104 9.12484 8.22887 3 : 3.50752 8.59097 0.0751236 1.13664 2.67132 The sorted matrix: Col: 1 2 3 4 5 Row 1 : 0.0183837 0.945448 2.18418 2.57578 2.60303 2 : 8.97504 0.136169 9.56318 1.09957 9.12484 3 : 3.50752 8.59097 8.29509 0.43829 1.13664 Col: 6 7 8 9 10 Row 1 : 3.51629 4.01306 5.61695 6.33966 8.40847 2 : 8.22887 7.54673 4.15307 0.617272 1.23104 3 : 2.67132 7.97287 0.661187 4.49539 0.0751236 R8LIB_TEST0393 R8COL_SORTED_TOL_UNIQUE returns tolerably unique columns in a sorted R8COL. The unsorted R8COL (transposed): Row: 1 2 3 Col 1: 1.900000 0.000000 10.000000 2: 2.000000 6.000000 10.000000 3: 4.000000 8.000000 12.000000 4: 1.000000 5.000000 9.000000 5: 3.000000 7.000000 11.000000 6: 2.000000 6.000000 0.000000 7: 2.000000 0.000000 10.100000 8: 2.000000 0.100000 10.000000 9: 3.000000 4.000000 18.000000 10: 1.900000 8.000000 10.000000 11: 0.000000 0.000000 0.000000 12: 0.000000 6.000000 10.000000 13: 2.100000 0.000000 10.000000 14: 2.000000 6.000000 10.000000 15: 3.000000 7.000000 11.000000 16: 2.000000 0.000000 10.000000 17: 2.000000 0.000000 10.000000 18: 2.000000 6.000000 10.000000 19: 1.000000 5.000000 9.000000 20: 2.000000 0.000000 10.100000 21: 1.000000 5.000000 9.100000 22: 1.000000 5.100000 9.000000 The sorted R8COL (transposed): Row: 1 2 3 Col 1: 0.000000 0.000000 0.000000 2: 0.000000 6.000000 10.000000 3: 1.000000 5.000000 9.000000 4: 1.000000 5.000000 9.000000 5: 1.000000 5.000000 9.100000 6: 1.000000 5.100000 9.000000 7: 1.900000 0.000000 10.000000 8: 1.900000 8.000000 10.000000 9: 2.000000 0.000000 10.000000 10: 2.000000 0.000000 10.000000 11: 2.000000 0.000000 10.100000 12: 2.000000 0.000000 10.100000 13: 2.000000 0.100000 10.000000 14: 2.000000 6.000000 0.000000 15: 2.000000 6.000000 10.000000 16: 2.000000 6.000000 10.000000 17: 2.000000 6.000000 10.000000 18: 2.100000 0.000000 10.000000 19: 3.000000 4.000000 18.000000 20: 3.000000 7.000000 11.000000 21: 3.000000 7.000000 11.000000 22: 4.000000 8.000000 12.000000 Equality tolerance set to 2.500000e-01 Number of tolerably unique columns is 10 The tolerably unique sorted R8COL (transposed): Row: 1 2 3 Col 1: 0.000000 0.000000 0.000000 2: 0.000000 6.000000 10.000000 3: 1.000000 5.000000 9.000000 4: 1.900000 0.000000 10.000000 5: 1.900000 8.000000 10.000000 6: 2.000000 6.000000 0.000000 7: 2.000000 6.000000 10.000000 8: 3.000000 4.000000 18.000000 9: 3.000000 7.000000 11.000000 10: 4.000000 8.000000 12.000000 R8LIB_TEST0395 R8COL_SORTED_TOL_UNIQUE_COUNT counts tolerably unique columns in a sorted R8COL. The unsorted R8COL (transposed): Row: 1 2 3 Col 1: 1.900000 0.000000 10.000000 2: 2.000000 6.000000 10.000000 3: 4.000000 8.000000 12.000000 4: 1.000000 5.000000 9.000000 5: 3.000000 7.000000 11.000000 6: 2.000000 6.000000 0.000000 7: 2.000000 0.000000 10.100000 8: 2.000000 0.100000 10.000000 9: 3.000000 4.000000 18.000000 10: 1.900000 8.000000 10.000000 11: 0.000000 0.000000 0.000000 12: 0.000000 6.000000 10.000000 13: 2.100000 0.000000 10.000000 14: 2.000000 6.000000 10.000000 15: 3.000000 7.000000 11.000000 16: 2.000000 0.000000 10.000000 17: 2.000000 0.000000 10.000000 18: 2.000000 6.000000 10.000000 19: 1.000000 5.000000 9.000000 20: 2.000000 0.000000 10.100000 21: 1.000000 5.000000 9.100000 22: 1.000000 5.100000 9.000000 The sorted R8COL (transposed): Row: 1 2 3 Col 1: 0.000000 0.000000 0.000000 2: 0.000000 6.000000 10.000000 3: 1.000000 5.000000 9.000000 4: 1.000000 5.000000 9.000000 5: 1.000000 5.000000 9.100000 6: 1.000000 5.100000 9.000000 7: 1.900000 0.000000 10.000000 8: 1.900000 8.000000 10.000000 9: 2.000000 0.000000 10.000000 10: 2.000000 0.000000 10.000000 11: 2.000000 0.000000 10.100000 12: 2.000000 0.000000 10.100000 13: 2.000000 0.100000 10.000000 14: 2.000000 6.000000 0.000000 15: 2.000000 6.000000 10.000000 16: 2.000000 6.000000 10.000000 17: 2.000000 6.000000 10.000000 18: 2.100000 0.000000 10.000000 19: 3.000000 4.000000 18.000000 20: 3.000000 7.000000 11.000000 21: 3.000000 7.000000 11.000000 22: 4.000000 8.000000 12.000000 Equality tolerance set to 2.500000e-01 Number of tolerably unique columns is 10 R8LIB_TEST0397 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: 1 2 3 Col 1: 1.900000 0.000000 10.000000 2: 2.000000 6.000000 10.000000 3: 4.000000 8.000000 12.000000 4: 1.000000 5.000000 9.000000 5: 3.000000 7.000000 11.000000 6: 2.000000 6.000000 0.000000 7: 2.000000 0.000000 10.100000 8: 2.000000 0.100000 10.000000 9: 3.000000 4.000000 18.000000 10: 1.900000 8.000000 10.000000 11: 0.000000 0.000000 0.000000 12: 0.000000 6.000000 10.000000 13: 2.100000 0.000000 10.000000 14: 2.000000 6.000000 10.000000 15: 3.000000 7.000000 11.000000 16: 2.000000 0.000000 10.000000 17: 2.000000 0.000000 10.000000 18: 2.000000 6.000000 10.000000 19: 1.000000 5.000000 9.000000 20: 2.000000 0.000000 10.100000 21: 1.000000 5.000000 9.100000 22: 1.000000 5.100000 9.000000 The sorted R8COL (transposed): Row: 1 2 3 Col 1: 0.000000 0.000000 0.000000 2: 0.000000 6.000000 10.000000 3: 1.000000 5.000000 9.000000 4: 1.000000 5.000000 9.000000 5: 1.000000 5.000000 9.100000 6: 1.000000 5.100000 9.000000 7: 1.900000 0.000000 10.000000 8: 1.900000 8.000000 10.000000 9: 2.000000 0.000000 10.000000 10: 2.000000 0.000000 10.000000 11: 2.000000 0.000000 10.100000 12: 2.000000 0.000000 10.100000 13: 2.000000 0.100000 10.000000 14: 2.000000 6.000000 0.000000 15: 2.000000 6.000000 10.000000 16: 2.000000 6.000000 10.000000 17: 2.000000 6.000000 10.000000 18: 2.100000 0.000000 10.000000 19: 3.000000 4.000000 18.000000 20: 3.000000 7.000000 11.000000 21: 3.000000 7.000000 11.000000 22: 4.000000 8.000000 12.000000 Tolerance for equality is 2.500000e-01 Number of unique entries in X is 10 XDNU points to the representative for each item. UNDX selects the representatives.. 1 1 1 2 2 2 3 3 3 4 3 7 5 3 8 6 3 14 7 4 15 8 5 19 9 4 20 10 4 22 11 4 12 4 13 4 14 6 15 7 16 7 17 7 18 4 19 8 20 9 21 9 22 10 The tolerably unique R8COL (transposed): Row: 1 2 3 Col 1: 0.000000 0.000000 0.000000 2: 0.000000 6.000000 10.000000 3: 1.000000 5.000000 9.000000 4: 1.900000 0.000000 10.000000 5: 1.900000 8.000000 10.000000 6: 2.000000 6.000000 0.000000 7: 2.000000 6.000000 10.000000 8: 3.000000 4.000000 18.000000 9: 3.000000 7.000000 11.000000 10: 4.000000 8.000000 12.000000 TEST040 For an R8COL, an array of column vectors; R8COL_MAX computes maximums; R8COL_MIN computes minimums; The array: Col: 1 2 3 4 Row 1 : 1 2 3 4 2 : 5 6 7 8 3 : 9 10 11 12 Column, maximum, minimum: 1 3.000000 1.000000 2 3.000000 2.000000 3 3.000000 3.000000 4 3.000000 4.000000 TEST041 For an R8COL, an array of column vectors; R8COL_MEAN computes means; R8COL_SUM computes sums; The array: Col: 1 2 3 4 Row 1 : 1 2 3 4 2 : 5 6 7 8 3 : 9 10 11 12 Column sum, mean: 1 15.000000 5.000000 2 18.000000 6.000000 3 21.000000 7.000000 4 24.000000 8.000000 TEST0415 R8COL_PERMUTE permutes an R8COL in place. A (Unpermuted): Col: 1 2 3 4 5 Row 1 : 11 12 13 14 15 2 : 21 22 23 24 25 3 : 31 32 33 34 35 The (column) permutation vector: 1: 2 2: 4 3: 5 4: 1 5: 3 A (Permuted): Col: 1 2 3 4 5 Row 1 : 12 14 15 11 13 2 : 22 24 25 21 23 3 : 32 34 35 31 33 TEST042 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: 1 2 3 Row 1 : 2.18418 0.617272 8.59097 2 : 9.56318 4.49539 8.40847 3 : 8.29509 4.01306 1.23104 4 : 5.61695 7.54673 0.0751236 5 : 4.15307 7.97287 2.60303 6 : 0.661187 0.0183837 9.12484 7 : 2.57578 8.97504 1.13664 8 : 1.09957 3.50752 3.51629 9 : 0.43829 0.945448 8.22887 10 : 6.33966 0.136169 2.67132 Sorted array: Col: 1 2 3 Row 1 : 0.661187 0.0183837 9.12484 2 : 6.33966 0.136169 2.67132 3 : 2.18418 0.617272 8.59097 4 : 0.43829 0.945448 8.22887 5 : 1.09957 3.50752 3.51629 6 : 8.29509 4.01306 1.23104 7 : 9.56318 4.49539 8.40847 8 : 5.61695 7.54673 0.0751236 9 : 4.15307 7.97287 2.60303 10 : 2.57578 8.97504 1.13664 TEST043 For an R8COL, an array of column vectors; R8COL_SWAP swaps two columns; The array: Col: 1 2 3 4 Row 1 : 1 2 3 4 2 : 5 6 7 8 3 : 9 10 11 12 Swap columns 1 and 3 The updated matrix: Col: 1 2 3 4 Row 1 : 3 2 1 4 2 : 7 6 5 8 3 : 11 10 9 12 TEST044 R8COL_TO_R8VEC converts an array of columns to a vector. The array of columns: Col: 1 2 3 4 Row 1 : 11 12 13 14 2 : 21 22 23 24 3 : 31 32 33 34 The resulting vector of columns: 1: 11 2: 21 3: 31 4: 12 5: 22 6: 32 7: 13 8: 23 9: 33 10: 14 11: 24 12: 34 R8LIB_TEST0442 R8COL_TOL_UNDEX produces index vectors which create a sorted list of the tolerably unique columns of an (unsorted) R8COL, and a map from the original R8COL to the (implicit) R8COL of sorted unique elements. The unsorted R8COL (transposed): Row: 1 2 3 Col 1: 1.900000 0.000000 10.000000 2: 2.000000 6.000000 10.000000 3: 4.000000 8.000000 12.000000 4: 1.000000 5.000000 9.000000 5: 3.000000 7.000000 11.000000 6: 2.000000 6.000000 0.000000 7: 2.000000 0.000000 10.100000 8: 2.000000 0.100000 10.000000 9: 3.000000 4.000000 18.000000 10: 1.900000 8.000000 10.000000 11: 0.000000 0.000000 0.000000 12: 0.000000 6.000000 10.000000 13: 2.100000 0.000000 10.000000 14: 2.000000 6.000000 10.000000 15: 3.000000 7.000000 11.000000 16: 2.000000 0.000000 10.000000 17: 2.000000 0.000000 10.000000 18: 2.000000 6.000000 10.000000 19: 1.000000 5.000000 9.000000 20: 2.000000 0.000000 10.100000 21: 1.000000 5.000000 9.100000 22: 1.000000 5.100000 9.000000 Tolerance for equality = 0.250000 Number of unique entries in X is 10 XDNU points to the representative for each item. UNDX selects the representatives.. 1 4 11 2 7 12 3 10 19 4 3 1 5 9 10 6 6 6 7 4 14 8 4 9 9 8 15 10 5 3 11 1 12 2 13 4 14 7 15 9 16 4 17 4 18 7 19 3 20 4 21 3 22 3 The Unique R8COL (transposed): Row: 1 2 3 Col 1: 0.000000 0.000000 0.000000 2: 0.000000 6.000000 10.000000 3: 1.000000 5.000000 9.000000 4: 1.900000 0.000000 10.000000 5: 1.900000 8.000000 10.000000 6: 2.000000 6.000000 0.000000 7: 2.000000 6.000000 10.000000 8: 3.000000 4.000000 18.000000 9: 3.000000 7.000000 11.000000 10: 4.000000 8.000000 12.000000 R8LIB_TEST0443 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: 1 2 3 Col 1: 1.900000 0.000000 10.000000 2: 2.000000 6.000000 10.000000 3: 4.000000 8.000000 12.000000 4: 1.000000 5.000000 9.000000 5: 3.000000 7.000000 11.000000 6: 2.000000 6.000000 0.000000 7: 2.000000 0.000000 10.100000 8: 2.000000 0.100000 10.000000 9: 3.000000 4.000000 18.000000 10: 1.900000 8.000000 10.000000 11: 0.000000 0.000000 0.000000 12: 0.000000 6.000000 10.000000 13: 2.100000 0.000000 10.000000 14: 2.000000 6.000000 10.000000 15: 3.000000 7.000000 11.000000 16: 2.000000 0.000000 10.000000 17: 2.000000 0.000000 10.000000 18: 2.000000 6.000000 10.000000 19: 1.000000 5.000000 9.000000 20: 2.000000 0.000000 10.100000 21: 1.000000 5.000000 9.100000 22: 1.000000 5.100000 9.000000 Number of unique entries in X is 16 XDNU points to the representative for each item. UNDX selects the representatives.. 1 6 11 2 12 12 3 16 19 4 3 21 5 15 22 6 11 1 7 9 10 8 10 16 9 14 7 10 7 8 11 1 6 12 2 14 13 13 13 14 12 9 15 15 15 16 8 3 17 8 18 12 19 3 20 9 21 4 22 5 The Unique R8COL (transposed): Row: 1 2 3 Col 1: 0.000000 0.000000 0.000000 2: 0.000000 6.000000 10.000000 3: 1.000000 5.000000 9.000000 4: 1.000000 5.000000 9.100000 5: 1.000000 5.100000 9.000000 6: 1.900000 0.000000 10.000000 7: 1.900000 8.000000 10.000000 8: 2.000000 0.000000 10.000000 9: 2.000000 0.000000 10.100000 10: 2.000000 0.100000 10.000000 11: 2.000000 6.000000 0.000000 12: 2.000000 6.000000 10.000000 13: 2.100000 0.000000 10.000000 14: 3.000000 4.000000 18.000000 15: 3.000000 7.000000 11.000000 16: 4.000000 8.000000 12.000000 SUBPAK_TEST0455 For an R8COL; R8COL_UNIQUE_COUNT counts unique columns. The R8COL (transposed): Row: 1 2 3 Col 1: 2.000000 6.000000 10.000000 2: 4.000000 8.000000 12.000000 3: 1.000000 5.000000 9.000000 4: 3.000000 7.000000 11.000000 5: 2.000000 6.000000 0.000000 6: 3.000000 4.000000 18.000000 7: 0.000000 0.000000 0.000000 8: 0.000000 6.000000 10.000000 9: 2.000000 6.000000 10.000000 10: 3.000000 7.000000 11.000000 11: 2.000000 0.000000 10.000000 12: 2.000000 6.000000 10.000000 13: 1.000000 5.000000 9.000000 14: 1.000000 5.000000 9.100000 15: 1.000000 5.100000 9.000000 Number of unique columns is 11 TEST045 For an R8COL, an array of column vectors; R8COL_VARIANCE computes variances; The array: Col: 1 2 3 4 Row 1 : 1 2 3 4 2 : 5 6 7 8 3 : 9 10 11 12 Column variance: 1 16.000000 2 16.000000 3 16.000000 4 16.000000 TEST046 R8R8VEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. Generate 30 random values: Index XVAL YVAL 1 2.000000 3.000000 2 3.000000 2.000000 3 2.000000 1.000000 3 2.000000 1.000000 4 1.000000 2.000000 4 1.000000 2.000000 1 2.000000 3.000000 5 3.000000 1.000000 6 4.000000 2.000000 7 1.000000 1.000000 8 4.000000 3.000000 7 1.000000 1.000000 1 2.000000 3.000000 4 1.000000 2.000000 2 3.000000 2.000000 2 3.000000 2.000000 6 4.000000 2.000000 6 4.000000 2.000000 1 2.000000 3.000000 3 2.000000 1.000000 2 3.000000 2.000000 2 3.000000 2.000000 9 2.000000 2.000000 4 1.000000 2.000000 10 3.000000 3.000000 4 1.000000 2.000000 11 1.000000 3.000000 2 3.000000 2.000000 8 4.000000 3.000000 2 3.000000 2.000000 Vector of unique X Y values: I X(I) Y(I) 1 2.000000 3.000000 2 3.000000 2.000000 3 2.000000 1.000000 4 1.000000 2.000000 5 3.000000 1.000000 6 4.000000 2.000000 7 1.000000 1.000000 8 4.000000 3.000000 9 2.000000 2.000000 10 3.000000 3.000000 11 1.000000 3.000000 X, Y sorted by index I INDX(I) X(INDX(I)) Y(INDX(I)) 1 7.000000 1.000000 1 2 4.000000 1.000000 2 3 11.000000 1.000000 3 4 3.000000 2.000000 1 5 9.000000 2.000000 2 6 1.000000 2.000000 3 7 5.000000 3.000000 1 8 2.000000 3.000000 2 9 10.000000 3.000000 3 10 6.000000 4.000000 2 11 8.000000 4.000000 3 TEST047 R8R8R8VEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. Number of random values to generate = 30 XVAL YVAL ZVAL Index 1 2.000000 3.000000 3.000000 2 3.000000 2.000000 1.000000 3 2.000000 1.000000 1.000000 4 3.000000 1.000000 2.000000 1 2.000000 3.000000 3.000000 5 1.000000 3.000000 2.000000 6 1.000000 1.000000 4.000000 7 4.000000 1.000000 1.000000 8 2.000000 3.000000 1.000000 9 2.000000 3.000000 2.000000 10 3.000000 2.000000 4.000000 1 2.000000 3.000000 3.000000 9 2.000000 3.000000 2.000000 11 2.000000 2.000000 2.000000 12 3.000000 2.000000 2.000000 4 3.000000 1.000000 2.000000 13 3.000000 3.000000 1.000000 14 3.000000 1.000000 3.000000 10 3.000000 2.000000 4.000000 15 3.000000 3.000000 2.000000 16 4.000000 2.000000 1.000000 4 3.000000 1.000000 2.000000 8 2.000000 3.000000 1.000000 17 1.000000 1.000000 1.000000 18 2.000000 1.000000 2.000000 19 2.000000 2.000000 3.000000 14 3.000000 1.000000 3.000000 10 3.000000 2.000000 4.000000 20 4.000000 3.000000 3.000000 21 1.000000 2.000000 2.000000 Vector of unique X Y Z values: I X(I) Y(I) Z(I) 1 2.000000 3.000000 3.000000 2 3.000000 2.000000 1.000000 3 2.000000 1.000000 1.000000 4 3.000000 1.000000 2.000000 5 1.000000 3.000000 2.000000 6 1.000000 1.000000 4.000000 7 4.000000 1.000000 1.000000 8 2.000000 3.000000 1.000000 9 2.000000 3.000000 2.000000 10 3.000000 2.000000 4.000000 11 2.000000 2.000000 2.000000 12 3.000000 2.000000 2.000000 13 3.000000 3.000000 1.000000 14 3.000000 1.000000 3.000000 15 3.000000 3.000000 2.000000 16 4.000000 2.000000 1.000000 17 1.000000 1.000000 1.000000 18 2.000000 1.000000 2.000000 19 2.000000 2.000000 3.000000 20 4.000000 3.000000 3.000000 21 1.000000 2.000000 2.000000 X Y Z sorted by index: I INDX(I) X(I) X(INDX(I)) 1 17.000000 1.000000 1.000000 1 2 6.000000 1.000000 1.000000 4 3 21.000000 1.000000 2.000000 2 4 5.000000 1.000000 3.000000 2 5 3.000000 2.000000 1.000000 1 6 18.000000 2.000000 1.000000 2 7 11.000000 2.000000 2.000000 2 8 19.000000 2.000000 2.000000 3 9 8.000000 2.000000 3.000000 1 10 9.000000 2.000000 3.000000 2 11 1.000000 2.000000 3.000000 3 12 4.000000 3.000000 1.000000 2 13 14.000000 3.000000 1.000000 3 14 2.000000 3.000000 2.000000 1 15 12.000000 3.000000 2.000000 2 16 10.000000 3.000000 2.000000 4 17 13.000000 3.000000 3.000000 1 18 15.000000 3.000000 3.000000 2 19 7.000000 4.000000 1.000000 1 20 16.000000 4.000000 2.000000 1 21 20.000000 4.000000 3.000000 3 TEST048 For data in an interval, I4INT_TO_R8INT converts an I4 to an R8; R8INT_TO_I4INT converts an R8 to an I4. I4 interval: [1, 11] R8 interval: [100.000000, 200.000000] R I(R) R(I(R)) 113.394379 2 110.000000 209.321285 12 210.000000 192.836200 10 190.000000 158.020408 7 160.000000 138.989921 5 140.000000 93.595436 0 90.000000 118.485113 3 120.000000 99.294383 1 100.000000 90.697770 0 90.000000 167.415543 8 170.000000 SUBPAK_TEST049 For a positive definite symmetric matrix, R8MAT_CHOLESKY_FACTOR computes the lower triangular Cholesky factor L; R8MAT_CHORESKY_FACTOR computes the upper triangular "Choresky" factor R; R8MAT_CHOLESKY_SOLVE solves a linear system using the Cholesky factorization. Matrix to be factored: Col: 1 2 3 4 5 Row 1 : 2 -1 0 0 0 2 : -1 2 -1 0 0 3 : 0 -1 2 -1 0 4 : 0 0 -1 2 -1 5 : 0 0 0 -1 2 Cholesky factor L: Col: 1 2 3 4 5 Row 1 : 1.41421 0 0 0 0 2 : -0.707107 1.22474 0 0 0 3 : 0 -0.816497 1.1547 0 0 4 : 0 0 -0.866025 1.11803 0 5 : 0 0 0 -0.894427 1.09545 Product L * L': Col: 1 2 3 4 5 Row 1 : 2 -1 0 0 0 2 : -1 2 -1 0 0 3 : 0 -1 2 -1 0 4 : 0 0 -1 2 -1 5 : 0 0 0 -1 2 Choresky factor R: Col: 1 2 3 4 5 Row 1 : 1.09545 -0.894427 0 0 0 2 : 0 1.11803 -0.866025 0 0 3 : 0 0 1.1547 -0.816497 0 4 : 0 0 0 1.22474 -0.707107 5 : 0 0 0 0 1.41421 Product R * R': Col: 1 2 3 4 5 Row 1 : 2 -1 0 0 0 2 : -1 2 -1 0 0 3 : 0 -1 2 -1 0 4 : 0 0 -1 2 -1 5 : 0 0 0 -1 2 Right hand side: 1: 0 2: 0 3: 0 4: 0 5: 6 Computed solution: 1: 1 2: 2 3: 3 4: 4 5: 5 TEST050 R8MAT_DET_2D: determinant of a 2 by 2 matrix; Matrix: Col: 1 2 Row 1 : 1 1 2 : 1 10 R8MAT_DET_2D computes determinant: 9.000000 Exact determinant is 9.000000 TEST051 R8MAT_DET_3D: determinant of a 3 by 3 matrix; Matrix: Col: 1 2 3 Row 1 : 1 1 1 2 : 1 10 100 3 : 1 4 16 R8MAT_DET_3D computes determinant: -162.000000 Exact determinant is -162.000000 TEST052 R8MAT_DET_4D determinant of a 4 by 4 matrix; Matrix: Col: 1 2 3 4 Row 1 : 1 1 1 1 2 : 1 10 100 1000 3 : 1 4 16 64 4 : 1 2 4 8 R8MAT_DET_4D computes determinant: -2592.000000 Exact determinant is -2592.000000 TEST053 R8MAT_DET_5D: determinant of 5 by 5 matrix. Matrix: Col: 1 2 3 4 5 Row 1 : 1 1 1 1 1 2 : 1 10 100 1000 10000 3 : 1 4 16 64 256 4 : 1 2 4 8 16 5 : 1 3 9 27 81 R8MAT_DET_5D computes determinant: -36288.000000 Exact determinant is -36288.000000 TEST054 R8MAT_EXPAND_LINEAR linearly interpolates new data between old values in a matrix. Original matrix: Col: 1 2 3 Row 1 : 1 1 1 2 : 2 4 8 3 : 3 9 27 4 : 4 16 64 MFAT = 2 NFAT = 1 Fattened matrix: Col: 1 2 3 4 5 Row 1 : 1 1 1 1 1 2 : 1.33333 1.66667 2 2.66667 3.33333 3 : 1.66667 2.33333 3 4.33333 5.66667 4 : 2 3 4 6 8 5 : 2.33333 4 5.66667 10 14.3333 6 : 2.66667 5 7.33333 14 20.6667 7 : 3 6 9 18 27 8 : 3.33333 7.33333 11.3333 25.3333 39.3333 9 : 3.66667 8.66667 13.6667 32.6667 51.6667 10 : 4 10 16 40 64 TEST055 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: 1 2 Row 1 : 11 12 2 : 21 22 3 : 31 32 Expanded array A2: Col: 1 2 3 4 5 Row 1 : 11 11.25 11.5 11.75 12 2 : 13.2222 13.4722 13.7222 13.9722 14.2222 3 : 15.4444 15.6944 15.9444 16.1944 16.4444 4 : 17.6667 17.9167 18.1667 18.4167 18.6667 5 : 19.8889 20.1389 20.3889 20.6389 20.8889 6 : 22.1111 22.3611 22.6111 22.8611 23.1111 7 : 24.3333 24.5833 24.8333 25.0833 25.3333 8 : 26.5556 26.8056 27.0556 27.3056 27.5556 9 : 28.7778 29.0278 29.2778 29.5278 29.7778 10 : 31 31.25 31.5 31.75 32 TEST0555 For a matrix in general storage, R8MAT_FSS factors and solves multiple linear systems. Matrix order N = 10 Solution: Col: 1 2 3 Row 1 : 1 1 1 2 : 1 2 2 3 : 1 3 3 4 : 1 4 1 5 : 1 5 2 6 : 1 6 3 7 : 1 7 1 8 : 1 8 2 9 : 1 9 3 10 : 1 10 1 TEST056 R8MAT_GIVENS_POST computes a Givens postmultiplier rotation matrix. Matrix A: Col: 1 2 3 Row 1 : 1 1 1 2 : 1 2 4 3 : 1 3 9 I = 3, J = 2 G Col: 1 2 3 Row 1 : 1 0 0 2 : 0 0.948683 0.316228 3 : 0 -0.316228 0.948683 A * G Col: 1 2 3 Row 1 : 1 0.632456 1.26491 2 : 1 0.632456 4.42719 3 : 1 -4.44089e-16 9.48683 TEST057 R8MAT_GIVENS_PRE computes a Givens premultiplier rotation matrix. Matrix A: Col: 1 2 3 Row 1 : 1 1 1 2 : 1 2 4 3 : 1 3 9 I = 3, J = 2 G Col: 1 2 3 Row 1 : 1 0 0 2 : 0 0.5547 0.83205 3 : 0 -0.83205 0.5547 G*A Col: 1 2 3 Row 1 : 1 1 1 2 : 1.38675 3.60555 9.70725 3 : -0.27735 2.22045e-16 1.6641 TEST058 R8MAT_HESS estimates the Hessian matrix of a scalar function. Estimated jacobian: Col: 1 2 3 Row 1 : 2 1 0 2 : 1 2.381e-06 9.88032 3 : 0 9.88032 -30.8503 Exact jacobian: Col: 1 2 3 Row 1 : 2 1 0 2 : 1 0 9.88032 3 : 0 9.88032 -30.8503 TEST059 R8VEC_HOUSE_COLUMN returns the compact form of a Householder matrix that "packs" a column of a matrix. Matrix A: Col: 1 2 3 4 Row 1 : 1.09209 2.07654 0.219145 2.00653 2 : 4.78159 0.330594 3.16983 3.77337 3 : 4.14755 1.28789 0.308636 3.98643 4 : 2.80848 0.549784 2.24769 0.00919186 Working on column K = 1 Householder matrix H: Col: 1 2 3 4 Row 1 : 0.5 -0.5 -0.5 -0.5 2 : -0.5 0.5 -0.5 -0.5 3 : -0.5 -0.5 0.5 -0.5 4 : -0.5 -0.5 -0.5 0.5 Product H*A: Col: 1 2 3 4 Row 1 : -5.32276 -0.0458656 -2.75351 -2.88123 2 : -1.63326 -1.79181 0.197176 -1.1144 3 : -2.26731 -0.834512 -2.66402 -0.901328 4 : -3.60637 -1.57262 -0.724957 -4.87857 Working on column K = 2 Householder matrix H: Col: 1 2 3 4 Row 1 : 1 0 0 0 2 : 0 0.333333 -0.666667 -0.666667 3 : 0 -0.666667 0.333333 -0.666667 4 : 0 -0.666667 -0.666667 0.333333 Product H*A: Col: 1 2 3 4 Row 1 : -5.32276 -0.0458656 -2.75351 -2.88123 2 : 3.37137 1.00748 2.32504 3.4818 3 : 2.73732 1.96478 -0.536151 3.69487 4 : 1.39825 1.22667 1.40291 -0.282375 Working on column K = 3 Householder matrix H: Col: 1 2 3 4 Row 1 : 1 0 0 0 2 : 0 1 0 0 3 : 0 0 0 -1 4 : 0 0 -1 0 Product H*A: Col: 1 2 3 4 Row 1 : -5.32276 -0.0458656 -2.75351 -2.88123 2 : 3.37137 1.00748 2.32504 3.4818 3 : -1.39825 -1.22667 -1.40291 0.282375 4 : -2.73732 -1.96478 0.536151 -3.69487 TEST060 R8MAT_HOUSE_FORM forms a Householder matrix from its compact form. Compact vector form V: 1: 0 2: 0 3: 1 4: 2 5: 3 Householder matrix H: Col: 1 2 3 4 5 Row 1 : 1 0 0 0 0 2 : 0 1 0 0 0 3 : 0 0 0.857143 -0.285714 -0.428571 4 : 0 0 -0.285714 0.428571 -0.857143 5 : 0 0 -0.428571 -0.857143 -0.285714 TEST061 R8MAT_HOUSE_POST computes a Householder postmultiplier; Matrix A: Col: 1 2 3 4 5 Row 1 : 1.09209 0.330594 0.308636 0.00919186 4.29548 2 : 4.78159 1.28789 2.24769 4.48752 4.20424 3 : 4.14755 0.549784 2.00653 1.75376 0.61552 4 : 2.80848 0.219145 3.77337 0.472724 0.0375618 5 : 2.07654 3.16983 3.98643 0.0680845 1.30151 I = 2, J = 3 Householder matrix H: Col: 1 2 3 4 5 Row 1 : 1 0 0 0 0 2 : 0 1 0 0 0 3 : 0 0 0.333333 -0.666667 -0.666667 4 : 0 0 -0.666667 0.333333 -0.666667 5 : 0 0 -0.666667 -0.666667 0.333333 Product A*H: Col: 1 2 3 4 5 Row 1 : 1.09209 0.330594 -2.76691 -3.06635 1.21994 2 : 4.78159 1.28789 -5.04527 -2.80545 -3.08873 3 : 4.14755 0.549784 -0.910677 -1.16345 -2.30169 4 : 2.80848 0.219145 0.917599 -2.38304 -2.81821 5 : 2.07654 3.16983 0.415745 -3.50261 -2.26917 TEST062 R8MAT_HOUSE_PRE computes a Householder premultiplier; Matrix A: Col: 1 2 3 4 5 Row 1 : 1.09209 0.330594 0.308636 0.00919186 4.29548 2 : 4.78159 1.28789 2.24769 4.48752 4.20424 3 : 4.14755 0.549784 2.00653 1.75376 0.61552 4 : 2.80848 0.219145 3.77337 0.472724 0.0375618 5 : 2.07654 3.16983 3.98643 0.0680845 1.30151 I = 2, J = 3 Householder matrix H: Col: 1 2 3 4 5 Row 1 : 1 0 0 0 0 2 : 0 0.5 -0.5 -0.5 -0.5 3 : 0 -0.5 0.5 -0.5 -0.5 4 : 0 -0.5 -0.5 0.5 -0.5 5 : 0 -0.5 -0.5 -0.5 0.5 Product H*A: Col: 1 2 3 4 5 Row 1 : 1.09209 0.330594 0.308636 0.00919186 4.29548 2 : -2.12549 -1.32543 -3.75932 1.09648 1.12482 3 : -2.75953 -2.06354 -4.00048 -1.63728 -2.4639 4 : -4.0986 -2.39418 -2.23365 -2.91832 -3.04186 5 : -4.83054 0.556505 -2.02058 -3.32296 -1.7779 TEST063 For an R8MAT, R8MAT_MAX_INDEX locates the maximum entry; R8MAT_MIN_INDEX locates the minimum entry; Random array: Col: 1 2 3 Row 1 : 2.18418 0.661187 0.617272 2 : 9.56318 2.57578 4.49539 3 : 8.29509 1.09957 4.01306 4 : 5.61695 0.43829 7.54673 5 : 4.15307 6.33966 7.97287 Maximum I,J indices = (2,1) Minimum I,J indices = (4,2) TEST064 R8MAT_INVERSE_2D inverts a 2 by 2 matrix. Matrix A to invert: Col: 1 2 Row 1 : 1 2 2 : 3 4 Inverse matrix B: Col: 1 2 Row 1 : -2 1 2 : 1.5 -0.5 Product C = A * B: Col: 1 2 Row 1 : 1 0 2 : 0 1 TEST065 R8MAT_INVERSE_3D inverts a 3 by 3 matrix. Matrix A to be inverted: Col: 1 2 3 Row 1 : 1 2 3 2 : 4 5 6 3 : 7 8 0 Inverse matrix B: Col: 1 2 3 Row 1 : -1.77778 0.888889 -0.111111 2 : 1.55556 -0.777778 0.222222 3 : -0.111111 0.222222 -0.111111 Product C = A * B: Col: 1 2 3 Row 1 : 1 -1.11022e-16 0 2 : 3.33067e-16 1 1.11022e-16 3 : 1.77636e-15 -8.88178e-16 1 TEST066 R8MAT_INVERSE_4D inverts a 4 x 4 matrix. Matrix A to be inverted: Col: 1 2 3 4 Row 1 : 4 3 2 1 2 : 3 3 2 1 3 : 0 2 2 1 4 : 0 0 1 1 Determinant is 1.000000 Inverse B: Col: 1 2 3 4 Row 1 : 1 -1 0 -0 2 : -3 4 -1 0 3 : 6 -8 3 -1 4 : -6 8 -3 2 Product C = A * B: Col: 1 2 3 4 Row 1 : 1 0 0 0 2 : 0 1 0 0 3 : 0 0 1 0 4 : 0 0 0 1 TEST067 R8MAT_JAC estimates the M by N jacobian matrix of a nonlinear function. Estimated jacobian: Col: 1 2 3 4 Row 1 : -0.83233 -0.41616 0 0 2 : 0.70711 0 1 0 3 : 1 2 3 4 Exact jacobian: Col: 1 2 3 4 Row 1 : -0.832294 -0.416147 0 0 2 : 0.707107 0 1 0 3 : 1 2 3 4 TEST068 R8MAT_L_INVERSE inverts a lower triangular matrix. Matrix A to be inverted: Col: 1 2 3 4 Row 1 : 1 0 0 0 2 : 2 3 0 0 3 : 4 5 6 0 4 : 7 8 9 10 Inverse matrix B: Col: 1 2 3 4 Row 1 : 1 0 0 0 2 : -0.666667 0.333333 0 0 3 : -0.111111 -0.277778 0.166667 0 4 : -0.0666667 -0.0166667 -0.15 0.1 Product C = A * B: Col: 1 2 3 4 Row 1 : 1 0 0 0 2 : 0 1 0 0 3 : 0 0 1 0 4 : 0 0 0 1 TEST069 R8MAT_L_PRINT prints a lower triangular matrix 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 11 21 3 11 21 31 4 11 21 31 41 5 11 21 31 41 51 6 11 21 31 41 51 61 7 11 21 31 41 51 61 71 A 7 by 3 matrix. Col 1 2 3 Row 1 11 2 11 21 3 11 21 31 4 11 21 31 5 11 21 31 6 11 21 31 7 11 21 31 A 4 by 7 matrix. Col 1 2 3 4 Row 1 11 2 11 21 3 11 21 31 4 11 21 31 41 TEST070 R8MAT_L1_INVERSE inverts a unit lower triangular matrix. Matrix A to be inverted: Col: 1 2 3 4 5 Row 1 : 1 0 0 0 0 2 : 2 1 0 0 0 3 : 0 0 1 0 0 4 : 5 0 3 1 0 5 : 0 0 0 0 1 6 : 75 0 0 6 4 Col: 6 Row 1 : 0 2 : 0 3 : 0 4 : 0 5 : 0 6 : 1 Inverse matrix B: Col: 1 2 3 4 5 Row 1 : 1 0 0 0 0 2 : -2 1 0 0 0 3 : -0 -0 1 0 0 4 : -5 -0 -3 1 0 5 : -0 -0 -0 -0 1 6 : -45 -0 18 -6 -4 Col: 6 Row 1 : 0 2 : 0 3 : 0 4 : 0 5 : 0 6 : 1 Product C = A * B: Col: 1 2 3 4 5 Row 1 : 1 0 0 0 0 2 : 0 1 0 0 0 3 : 0 0 1 0 0 4 : 0 0 0 1 0 5 : 0 0 0 0 1 6 : 0 0 0 0 0 Col: 6 Row 1 : 0 2 : 0 3 : 0 4 : 0 5 : 0 6 : 1 TEST071 R8MAT_LU computes the LU factors of a matrix. Matrix to be factored: Col: 1 2 3 4 5 Row 1 : 1 1 1 1 1 2 : 1 10 100 1000 10000 3 : 1 4 16 64 256 4 : 1 2 4 8 16 5 : 1 3 9 27 81 P factor: Col: 1 2 3 4 5 Row 1 : 1 0 0 0 0 2 : 0 1 0 0 0 3 : 0 0 1 0 0 4 : 0 0 0 1 0 5 : 0 0 0 0 1 L factor: Col: 1 2 3 4 5 Row 1 : 1 0 0 0 0 2 : 1 1 0 0 0 3 : 1 0.333333 1 0 0 4 : 1 0.111111 0.444444 1 0 5 : 1 0.222222 0.777778 0.875 1 U factor: Col: 1 2 3 4 5 Row 1 : 1 1 1 1 1 2 : 0 9 99 999 9999 3 : 0 0 -18 -270 -3078 4 : 0 0 0 16 272 5 : 0 0 0 0 14 P*L*U: Col: 1 2 3 4 5 Row 1 : 1 1 1 1 1 2 : 1 10 100 1000 10000 3 : 1 4 16 64 256 4 : 1 2 4 8 16 5 : 1 3 9 27 81 TEST072 For a real matrix, R8MAT_MAX computes the maximum value; R8MAT_MIN computes the minimum value; Random array: Col: 1 2 3 Row 1 : 2.18418 0.661187 0.617272 2 : 9.56318 2.57578 4.49539 3 : 8.29509 1.09957 4.01306 4 : 5.61695 0.43829 7.54673 5 : 4.15307 6.33966 7.97287 Minimum value = 0.438290 Maximum value = 9.563176 TEST073 R8MAT_MAXCOL_MINROW computes the maximum over columns of the mininum over rows; R8MAT_MAXROW_MINCOL computes the maximum over rows of the mininum over columns; R8MAT_MINCOL_MAXROW computes the minimum over columns of the maxinum over rows; R8MAT_MINROW_MAXCOL computes the minimum over rows of the maxinum over columns; Random array: Col: 1 2 3 Row 1 : 2.18418 0.661187 0.617272 2 : 9.56318 2.57578 4.49539 3 : 8.29509 1.09957 4.01306 4 : 5.61695 0.43829 7.54673 5 : 4.15307 6.33966 7.97287 MAXCOL_MINROW = 4.153071 MINROW_MAXCOL = 6.339657 MAXROW_MINCOL = 2.184183 MINCOL_MAXROW = 4.153071 TEST0737 R8MAT_NULLSPACE_SIZE computes the size of the nullspace of a matrix. R8MAT_NULLSPACE computes the nullspace of a matrix. Input A: Col: 1 2 3 4 5 Row 1 : 1 3 0 2 6 2 : -2 -6 0 -2 -8 3 : 3 9 0 0 6 4 : -1 -3 0 1 0 Col: 6 7 Row 1 : 3 1 2 : 3 1 3 : 6 2 4 : 9 3 Nullspace size is 4 Nullspace vectors: Col: 1 2 3 4 Row 1 : -3 0 -2 0 2 : 1 0 0 0 3 : 0 1 0 0 4 : 0 0 -2 0 5 : 0 0 1 0 6 : 0 0 0 -0.333333 7 : 0 0 0 1 Product A * Nullspace vectors: Col: 1 2 3 4 Row 1 : 0 0 0 0 2 : 0 0 0 0 3 : 0 0 0 0 4 : 0 0 0 0 TEST074 R8MAT_ORTH_UNIFORM computes a random orthogonal matrix. Random orthogonal matrix A Col: 1 2 3 4 5 Row 1 : 0.6 0.4 -0.4 0.4 0.4 2 : -0.4 0.9 0.1 -0.1 -0.1 3 : -0.4 -0.1 0.433333 0.566667 0.566667 4 : -0.4 -0.1 -0.566667 0.566667 -0.433333 5 : -0.4 -0.1 -0.566667 -0.433333 0.566667 AT*A Col: 1 2 3 4 5 Row 1 : 1 -1.38778e-17 -1.11022e-16 1.11022e-16 1.38778e-16 2 :-1.38778e-17 1 -1.66533e-16 1.73472e-16 1.73472e-16 3 :-1.11022e-16 -1.66533e-16 1 -5.55112e-17 -5.55112e-17 4 : 1.11022e-16 1.73472e-16 -5.55112e-17 1 2.77556e-17 5 : 1.11022e-16 1.73472e-16 -5.55112e-17 5.55112e-17 1 TEST075 R8MAT_PLOT prints a symbolic picture of a matrix. Typically, "-" for negative, " " for zero, and "+" for positive entries or "X" for nonzero and, " " 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 TEST076 R8MAT_POWER_METHOD applies the power method to a matrix. Estimated eigenvalue = 3.731980 Estimated eigenvector V: 1: 0.292877 2: -0.499987 3: 0.573126 4: -0.499987 5: 0.292877 Value of A*V: 1: 1.08574 2: -1.86598 3: 2.14622 4: -1.86598 5: 1.08574 TEST0764 R8MAT_REF computes the row echelon form of a matrix. Input A: Col: 1 2 3 4 5 Row 1 : 1 3 0 2 6 2 : -2 -6 0 -2 -8 3 : 3 9 0 0 6 4 : -1 -3 0 1 0 Col: 6 7 Row 1 : 3 1 2 : 3 1 3 : 6 2 4 : 9 3 REF form: Col: 1 2 3 4 5 Row 1 : 1 3 0 2 6 2 : 0 0 0 1 2 3 : 0 0 0 0 0 4 : 0 0 0 0 0 Col: 6 7 Row 1 : 3 1 2 : 4.5 1.5 3 : 1 0.333333 4 : 0 0 TEST0766 R8MAT_RREF computes the reduced row echelon form of a matrix. Input A: Col: 1 2 3 4 5 Row 1 : 1 3 0 2 6 2 : -2 -6 0 -2 -8 3 : 3 9 0 0 6 4 : -1 -3 0 1 0 Col: 6 7 Row 1 : 3 1 2 : 3 1 3 : 6 2 4 : 9 3 RREF form: Col: 1 2 3 4 5 Row 1 : 1 3 0 0 2 2 : 0 0 0 1 2 3 : 0 0 0 0 0 4 : 0 0 0 0 0 Col: 6 7 Row 1 : 0 0 2 : 0 0 3 : 1 0.333333 4 : 0 0 TEST077 R8MAT_SOLVE solves linear systems. The linear system: Col: 1 2 3 4 5 Row 1 : 1 2 3 14 7 2 : 4 5 6 32 16 3 : 7 8 0 23 7 The computed solutions Col: 1 2 Row 1 : 1 1 2 : 2 0 3 : 3 2 R8LIB_TEST0775 R8MAT_SOLVE_2D solves 2D linear systems. Solution / Computed: 0.415307 0.415307 0.066119 0.066119 Solution / Computed: 0.061727 0.061727 0.449539 0.449539 Solution / Computed: 0.897504 0.897504 0.350752 0.350752 Solution / Computed: 0.123104 0.123104 0.007512 0.007512 Solution / Computed: 0.822887 0.822887 0.267132 0.267132 R8LIB_TEST0776 R8MAT_SOLVE_3D solves 3D linear systems. Solution / Computed: 0.633966 0.633966 0.061727 0.061727 0.449539 0.449539 Solution / Computed: 0.840847 0.840847 0.123104 0.123104 0.007512 0.007512 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.406970 0.406970 TEST078 R8MAT_SOLVE2 is a linear solver. Right hand side: 1: 5 2: 11 The system is nonsingular. Computed solution: 1: 1 2: 2 Right hand side: 1: 4 2: 2 3: 2 R8MAT_SOLVE2 - Warning: Consistent singularity, equation = 3 The system is singular, but consistent. Computed solution: 1: 2 2: 0 3: 0 Right hand side: 1: 5 2: 11 3: 16 4: 15 The system is nonsingular. Computed solution: 1: -2 2: -6 3: 10 4: 7 Right hand side: 1: 13 2: 17 3: 20 R8MAT_SOLVE2 - Error: Inconsistent singularity, equation = 2 The system is singular and inconsistent. Computed solution: 1: 6.42857 2: 0 3: 0.142857 TEST079 For a symmetric R8MAT: R8MAT_SYMM_JACOBI diagonalizes; Matrix to diagonalize: Col: 1 2 3 4 5 Row 1 : 2.6 1.38778e-16 1.2 0.4 0.8 2 : 1.66533e-16 1.9 -0.4 -0.2 -0.3 3 : 1.2 -0.4 3.63333 -0.5 0.0666667 4 : 0.4 -0.2 -0.5 3.36667 -1.06667 5 : 0.8 -0.3 0.0666667 -1.06667 3.5 Computed Eigenvalues: 1.000000 2.000000 5.000000 4.000000 3.000000 TEST080 R8MAT_TO_R8PLU determines the compressed PLU factors of an R8MAT. R8PLU_TO_R8MAT determines the original matrix from the compressed PLU factors. Using initial random number seed = 123456789 Matrix order N = 5 The matrix A: Col: 1 2 3 4 5 Row 1 : 0.218418 0.0661187 0.0617272 0.00183837 0.859097 2 : 0.956318 0.257578 0.449539 0.897504 0.840847 3 : 0.829509 0.109957 0.401306 0.350752 0.123104 4 : 0.561695 0.043829 0.754673 0.0945448 0.00751236 5 : 0.415307 0.633966 0.797287 0.0136169 0.260303 The pivot vector P: 1: 2 2: 5 3: 4 4: 4 5: 5 The compressed LU factors: Col: 1 2 3 4 5 Row 1 : 0.956318 0.257578 0.449539 0.897504 0.840847 2 : -0.228395 0.522106 0.602062 -0.376149 -0.104858 3 : -0.867399 0.217324 0.614552 -0.510026 -0.507943 4 : -0.587352 0.20582 -0.231419 -0.391459 -0.511487 5 : -0.434277 -0.0139612 0.0803036 -0.610161 0.939815 The recovered matrix A2: Col: 1 2 3 4 5 Row 1 : 0.218418 0.0661187 0.0617272 0.00183837 0.859097 2 : 0.956318 0.257578 0.449539 0.897504 0.840847 3 : 0.829509 0.109957 0.401306 0.350752 0.123104 4 : 0.561695 0.043829 0.754673 0.0945448 0.00751236 5 : 0.415307 0.633966 0.797287 0.0136169 0.260303 TEST081 R8MAT_TRACE computes the trace of a matrix Matrix: Col: 1 2 3 4 Row 1 : 4 3 2 1 2 : 3 3 2 1 3 : 0 2 2 1 4 : 0 0 1 1 Trace is 10.000000 TEST082 R8MAT_TRANSPOSE_PRINT prints a R8MAT, transposed. Matrix row order M = 7 Matrix column order N = 12 The transposed matrix A: Row: 1 2 3 4 5 Col 1: 101.000000 201.000000 301.000000 401.000000 501.000000 2: 102.000000 202.000000 302.000000 402.000000 502.000000 3: 103.000000 203.000000 303.000000 403.000000 503.000000 4: 104.000000 204.000000 304.000000 404.000000 504.000000 5: 105.000000 205.000000 305.000000 405.000000 505.000000 6: 106.000000 206.000000 306.000000 406.000000 506.000000 7: 107.000000 207.000000 307.000000 407.000000 507.000000 8: 108.000000 208.000000 308.000000 408.000000 508.000000 9: 109.000000 209.000000 309.000000 409.000000 509.000000 10: 110.000000 210.000000 310.000000 410.000000 510.000000 11: 111.000000 211.000000 311.000000 411.000000 511.000000 12: 112.000000 212.000000 312.000000 412.000000 512.000000 Row: 6 7 Col 1: 601.000000 701.000000 2: 602.000000 702.000000 3: 603.000000 703.000000 4: 604.000000 704.000000 5: 605.000000 705.000000 6: 606.000000 706.000000 7: 607.000000 707.000000 8: 608.000000 708.000000 9: 609.000000 709.000000 10: 610.000000 710.000000 11: 611.000000 711.000000 12: 612.000000 712.000000 TEST083 R8MAT_U_INVERSE inverts an upper triangular matrix. Input matrix A Col: 1 2 3 4 Row 1 : 1 2 4 7 2 : 0 3 5 8 3 : 0 0 6 9 4 : 0 0 0 10 Inverse matrix B: Col: 1 2 3 4 Row 1 : 1 -0.666667 -0.111111 -0.0666667 2 : 0 0.333333 -0.277778 -0.0166667 3 : 0 0 0.166667 -0.15 4 : 0 0 0 0.1 Product C = A * B: Col: 1 2 3 4 Row 1 : 1 0 0 0 2 : 0 1 0 0 3 : 0 0 1 1.11022e-16 4 : 0 0 0 1 TEST084 R8MAT_U1_INVERSE inverts a unit upper triangular matrix. Input matrix A Col: 1 2 3 4 5 Row 1 : 1 2 0 5 0 2 : 0 1 0 0 0 3 : 0 0 1 3 0 4 : 0 0 0 1 0 5 : 0 0 0 0 1 6 : 0 0 0 0 0 Col: 6 Row 1 : 75 2 : 0 3 : 0 4 : 6 5 : 4 6 : 1 Inverse matrix B: Col: 1 2 3 4 5 Row 1 : 1 -2 -0 -5 -0 2 : 0 1 -0 -0 -0 3 : 0 0 1 -3 -0 4 : 0 0 0 1 -0 5 : 0 0 0 0 1 6 : 0 0 0 0 0 Col: 6 Row 1 : -45 2 : -0 3 : 18 4 : -6 5 : -4 6 : 1 Product C = A * B: Col: 1 2 3 4 5 Row 1 : 1 0 0 0 0 2 : 0 1 0 0 0 3 : 0 0 1 0 0 4 : 0 0 0 1 0 5 : 0 0 0 0 1 6 : 0 0 0 0 0 Col: 6 Row 1 : 0 2 : 0 3 : 0 4 : 0 5 : 0 6 : 1 TEST085 R8MAT_UNIFORM sets a matrix to random values. Using initial random number seed = 123456789 The random matrix: Col: 1 2 3 4 Row 1 : 3.74735 2.52895 2.49382 2.01471 2 : 9.65054 4.06062 5.59631 9.18003 3 : 8.63607 2.87965 5.21045 4.80602 4 : 6.49356 2.35063 8.03739 2.75636 5 : 5.32246 7.07173 8.3783 2.10894 TEST086 R8PLU_DET determines the determinant of a matrix from its compressed PLU factors. Using initial random number seed = 123456789 Matrix order N = 5 The matrix A: Col: 1 2 3 4 5 Row 1 : 0.218418 0.0661187 0.0617272 0.00183837 0.859097 2 : 0.956318 0.257578 0.449539 0.897504 0.840847 3 : 0.829509 0.109957 0.401306 0.350752 0.123104 4 : 0.561695 0.043829 0.754673 0.0945448 0.00751236 5 : 0.415307 0.633966 0.797287 0.0136169 0.260303 The determinant = 0.112888 TEST087 R8PLU_INVERSE determines the inverse of a matrix from its compressed PLU factors. Using initial random number seed = 123456789 Matrix order N = 5 The matrix A: Col: 1 2 3 4 5 Row 1 : 0.218418 0.0661187 0.0617272 0.00183837 0.859097 2 : 0.956318 0.257578 0.449539 0.897504 0.840847 3 : 0.829509 0.109957 0.401306 0.350752 0.123104 4 : 0.561695 0.043829 0.754673 0.0945448 0.00751236 5 : 0.415307 0.633966 0.797287 0.0136169 0.260303 The inverse matrix B: Col: 1 2 3 4 5 Row 1 : 0.625209 -1.0222 2.84978 -0.868794 -0.0840984 2 : -0.471548 -0.149728 0.892032 -2.1207 1.67928 3 : -0.274368 0.546937 -1.95265 2.05705 0.00285593 4 : -1.39029 1.75848 -1.70625 0.283212 -0.293107 5 : 1.06404 0.228349 -0.649235 0.235691 -0.107439 The product matrix C = A * B: Col: 1 2 3 4 5 Row 1 : 1 1.11022e-16 -1.11022e-16 0 -1.38778e-17 2 :-2.22045e-16 1 1.11022e-16 -1.38778e-16 -2.77556e-17 3 : -2.498e-16 3.53884e-16 1 -1.76942e-16 0 4 :-3.01842e-16 3.60389e-16 -2.10769e-16 1 -1.01915e-17 5 :-1.11022e-16 6.245e-17 -1.66533e-16 -1.94289e-16 1 TEST088 R8PLU_MUL computes the product A*x=b using the compressed PLU factors of A. Using initial random number seed = 123456789 Matrix order N = 5 The matrix A: Col: 1 2 3 4 5 Row 1 : 0.218418 0.0661187 0.0617272 0.00183837 0.859097 2 : 0.956318 0.257578 0.449539 0.897504 0.840847 3 : 0.829509 0.109957 0.401306 0.350752 0.123104 4 : 0.561695 0.043829 0.754673 0.0945448 0.00751236 5 : 0.415307 0.633966 0.797287 0.0136169 0.260303 The right hand side B (computed from A): 1: 4.83868 2: 10.6143 3: 4.27187 4: 3.32911 5: 5.43108 The right hand side B (computed from PLU): 1: 4.83868 2: 10.6143 3: 4.27187 4: 3.32911 5: 5.43108 TEST089 R8PLU_SOL solves a linear system A*x=b using the compressed PLU factors of A. Using initial random number seed = 123456789 Matrix order N = 5 The matrix A: Col: 1 2 3 4 5 Row 1 : 0.218418 0.0661187 0.0617272 0.00183837 0.859097 2 : 0.956318 0.257578 0.449539 0.897504 0.840847 3 : 0.829509 0.109957 0.401306 0.350752 0.123104 4 : 0.561695 0.043829 0.754673 0.0945448 0.00751236 5 : 0.415307 0.633966 0.797287 0.0136169 0.260303 The right hand side B: 1: 4.83868 2: 10.6143 3: 4.27187 4: 3.32911 5: 5.43108 The computed solution X: 1: 1 2: 2 3: 3 4: 4 5: 5 TEST090 R8POLY_DERIV computes the coefficients of the derivative of a polynomial. The initial polynomial p(x) = - 10 * x^3 + 35 * x^2 - 50 * x + 24 The derivative of order 0 p(x) = - 10 * x^3 + 35 * x^2 - 50 * x + 24 The derivative of order 1 p(x) = - 30 * x^2 + 70 * x - 50 The derivative of order 2 p(x) = - 60 * x + 70 The derivative of order 3 p(x) = - 60 The derivative of order 4 p(x) = 0 TEST091 R8POLY_LAGRANGE_COEF returns the coefficients for a Lagrange basis polynomial. R8POLY_PRINT prints a polynomial. Abscissas: 1: 1 2: 2 3: 3 4: 4 5: 5 The Lagrange basis polynomial: p(x) = - 0.583333 * x^3 + 2.95833 * x^2 - 6.41667 * x + 5 The Lagrange basis polynomial: p(x) = 2.16667 * x^3 - 9.83333 * x^2 + 17.8333 * x - 10 The Lagrange basis polynomial: p(x) = - 3 * x^3 + 12.25 * x^2 - 19.5 * x + 10 The Lagrange basis polynomial: p(x) = 1.83333 * x^3 - 6.83333 * x^2 + 10.1667 * x - 5 The Lagrange basis polynomial: p(x) = - 0.416667 * x^3 + 1.45833 * x^2 - 2.08333 * x + 1 TEST092 R8POLY_LAGRANGE_COEF returns the coefficients for a Lagrange basis polynomial. R8POLY_DERIV computes derivatives of a polynomial. Abscissas: 1: 1 2: 2 3: 3 4: 4 5: 5 The Lagrange basis polynomial: p(x) = - 0.583333 * x^3 + 2.95833 * x^2 - 6.41667 * x + 5 The derivative of order 1 p(x) = - 1.75 * x^2 + 5.91667 * x - 6.41667 The derivative of order 2 p(x) = - 3.5 * x + 5.91667 The derivative of order 3 p(x) = - 3.5 The derivative of order 4 p(x) = 0 The Lagrange basis polynomial: p(x) = 2.16667 * x^3 - 9.83333 * x^2 + 17.8333 * x - 10 The derivative of order 1 p(x) = 6.5 * x^2 - 19.6667 * x + 17.8333 The derivative of order 2 p(x) = 13 * x - 19.6667 The derivative of order 3 p(x) = 13 The derivative of order 4 p(x) = 0 The Lagrange basis polynomial: p(x) = - 3 * x^3 + 12.25 * x^2 - 19.5 * x + 10 The derivative of order 1 p(x) = - 9 * x^2 + 24.5 * x - 19.5 The derivative of order 2 p(x) = - 18 * x + 24.5 The derivative of order 3 p(x) = - 18 The derivative of order 4 p(x) = 0 The Lagrange basis polynomial: p(x) = 1.83333 * x^3 - 6.83333 * x^2 + 10.1667 * x - 5 The derivative of order 1 p(x) = 5.5 * x^2 - 13.6667 * x + 10.1667 The derivative of order 2 p(x) = 11 * x - 13.6667 The derivative of order 3 p(x) = 11 The derivative of order 4 p(x) = 0 The Lagrange basis polynomial: p(x) = - 0.416667 * x^3 + 1.45833 * x^2 - 2.08333 * x + 1 The derivative of order 1 p(x) = - 1.25 * x^2 + 2.91667 * x - 2.08333 The derivative of order 2 p(x) = - 2.5 * x + 2.91667 The derivative of order 3 p(x) = - 2.5 The derivative of order 4 p(x) = 0 TEST093 R8POLY_LAGRANGE_0 evaluates the Lagrange factor W(X) at a point. R8POLY_LAGRANGE_1 evaluates the Lagrange factor W'(X) at a point. R8POLY_LAGRANGE_2 evaluates the Lagrange factor W"(X) at a point. The number of data points is 5 Abscissas: 1: 0 2: 1 3: 2 4: 3 5: 4 X W(X) W'(X) W"(X) 0.000000 0.000000e+00 2.400000e+01 -1.000000e+02 0.222222 3.224441e+00 6.536199e+00 -5.903978e+01 0.444444 3.489983e+00 -3.020271e+00 -2.861454e+01 0.666667 2.304527e+00 -6.864198e+00 -7.407407e+00 0.888889 7.207573e-01 -6.897729e+00 5.898491e+00 1.111111 -5.988247e-01 -4.730376e+00 1.262003e+01 1.333333 -1.316872e+00 -1.679012e+00 1.407407e+01 1.555556 -1.356162e+00 1.232129e+00 1.157750e+01 1.777778 -8.345611e-01 3.271453e+00 6.447188e+00 2.000000 0.000000e+00 4.000000e+00 0.000000e+00 2.222222 8.345611e-01 3.271453e+00 -6.447188e+00 2.444444 1.356162e+00 1.232129e+00 -1.157750e+01 2.666667 1.316872e+00 -1.679012e+00 -1.407407e+01 2.888889 5.988247e-01 -4.730376e+00 -1.262003e+01 3.111111 -7.207573e-01 -6.897729e+00 -5.898491e+00 3.333333 -2.304527e+00 -6.864198e+00 7.407407e+00 3.555556 -3.489983e+00 -3.020271e+00 2.861454e+01 3.777778 -3.224441e+00 6.536199e+00 5.903978e+01 4.000000 0.000000e+00 2.400000e+01 1.000000e+02 TEST094 R8POLY_LAGRANGE_FACTOR evaluates the Lagrange factor W(X) at a point. For this test, we use 5 functions. Abscissas: 1: 0 2: 0.8 3: 1.6 4: 2.4 5: 3.2 X W(X) W'(X) 4.500000 131.818050 274.542900 4.000000 39.321600 112.230400 3.500000 5.925150 32.142900 3.000000 -1.108800 2.030400 2.500000 -0.267750 -2.857100 2.000000 0.460800 0.230400 1.500000 -0.160650 1.542900 1.000000 -0.369600 -1.169600 0.500000 0.846450 -2.657100 0.000000 0.000000 9.830400 TEST095 R8POLY_LAGRANGE_VAL evaluates a Lagrange interpolating polynomial at a point. Number of data points = 5 Abscissas: 1: 0 2: 1 3: 2 4: 3 5: 4 Here are the values of the functions at several points: X L1 L2 L3 L4 L5 0.000000 1.000000 0.000000 -0.000000 0.000000 -0.000000 0.500000 0.273438 1.093750 -0.546875 0.218750 -0.039062 1.000000 -0.000000 1.000000 0.000000 -0.000000 0.000000 1.500000 -0.039062 0.468750 0.703125 -0.156250 0.023438 2.000000 0.000000 -0.000000 1.000000 0.000000 -0.000000 2.500000 0.023438 -0.156250 0.703125 0.468750 -0.039062 3.000000 -0.000000 0.000000 -0.000000 1.000000 0.000000 3.500000 -0.039062 0.218750 -0.546875 1.093750 0.273438 4.000000 0.000000 -0.000000 0.000000 -0.000000 1.000000 And the derivatives: X L'1 L'2 L'3 L'4 L'5 0.000000 -2.083333 4.000000 -3.000000 1.333333 -0.250000 0.500000 -0.916667 0.708333 0.375000 -0.208333 0.041667 1.000000 -0.250000 -0.833333 1.500000 -0.500000 0.083333 1.500000 0.041667 -1.125000 1.125000 -0.041667 0.000000 2.000000 0.083333 -0.666667 0.000000 0.666667 -0.083333 2.500000 0.000000 0.041667 -1.125000 1.125000 -0.041667 3.000000 -0.083333 0.500000 -1.500000 0.833333 0.250000 3.500000 -0.041667 0.208333 -0.375000 -0.708333 0.916667 4.000000 0.250000 -1.333333 3.000000 -4.000000 2.083333 R8LIB_TEST098 R8POLY_VALUE_HORNER evaluates a polynomial at a point, using Horner's method. The polynomial: p(x) = - 10 * x^3 + 35 * x^2 - 50 * x + 24 X P(X) 0.000000 24.000000 0.333333 10.851852 0.666667 3.259259 1.000000 -1.000000 1.333333 -4.148148 1.666667 -8.407407 2.000000 -16.000000 2.333333 -29.148148 2.666667 -50.074074 3.000000 -81.000000 3.333333 -124.148148 3.666667 -181.740741 4.000000 -256.000000 4.333333 -349.148148 4.666667 -463.407407 5.000000 -601.000000 TEST099 R8POLY2_EX finds the extreme value of a parabola determined by three points. R8POLY2_EX2 finds the extreme value of a parabola determined by three points. Parabolic coefficients: A = 2.000000, B = -4.000000, C = 10.000000 Point 1 : ( 1, 8 ) Point 2 : ( 2, 10 ) Point 3 : ( 3, 16 ) R8POLY2_EX returns XMIN = 1.000000, YMIN = 8.000000 R8POLY2_EX2 returns XMIN = 1.000000, YMIN = 8.000000 and A = 2.000000, B = -4.000000, C = 10.000000 TEST100 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.000000 0.000000 1.000000 6.000000 3.000000 28.000000 Sampled data: X, Y, Y', Y" 0.000000 1.000000 3.000000 4.000000 1.000000 6.000000 7.000000 4.000000 2.000000 15.000000 11.000000 4.000000 3.000000 28.000000 15.000000 4.000000 Case 2: X1=X2, X3 distinct: -1.000000 0.000000 -1.000000 -1.000000 3.000000 28.000000 Sampled data: X, Y, Y', Y" 0.000000 1.000000 3.000000 4.000000 1.000000 6.000000 7.000000 4.000000 2.000000 15.000000 11.000000 4.000000 3.000000 28.000000 15.000000 4.000000 Case 3: X1=X2=X3: -1.000000 0.000000 -1.000000 -1.000000 -1.000000 4.000000 Sampled data: X, Y, Y', Y" 0.000000 1.000000 3.000000 4.000000 1.000000 6.000000 7.000000 4.000000 2.000000 15.000000 11.000000 4.000000 3.000000 28.000000 15.000000 4.000000 TEST101 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. 1 2.000000 15.000000 17.000000 2 4.000000 45.000000 61.000000 3 6.000000 91.000000 137.000000 4 8.000000 153.000000 245.000000 5 10.000000 231.000000 385.000000 Interpolated data: LEFT, X, Y1, Y2 1 1.000000 6.000000 7.000000 2 3.000000 28.000000 35.000000 3 5.000000 66.000000 95.000000 3 7.000000 120.000000 187.000000 3 9.000000 190.000000 311.000000 TEST102 R8POLY2_ROOT finds quadratic equation roots. A B C R1 R2 2.000000 -2.000000 -24.000000 4.000000 -3.000000 1.000000 -20.000000 100.000000 10.000000 10.000000 1.000000 -2.000000 10.000000 1.000000 1.000000 TEST103 R8POLY3_ROOT finds roots of cubic equations. Polynomial coefficients: A = 1.000000, B = -6.000000, C = 11.000000, D = -6.000000 Roots: 1.000000 3.000000 2.000000 Polynomial coefficients: A = 9.000000, B = -36.000000, C = 54.000000, D = -27.000000 Roots: 1.000000 1.500000 1.500000 Polynomial coefficients: A = 1.000000, B = -5.000000, C = 8.000000, D = -4.000000 Roots: 1.000000 2.000000 2.000000 Polynomial coefficients: A = 1.000000, B = -8.000000, C = 25.000000, D = -26.000000 Roots: 2.000000 3.000000 3.000000 TEST104 R8POLY4_ROOT finds roots of quartic equations. A = 1.000000 B = -10.000000 C = 35.000000 D = -50.000000 E = 24.000000 Roots: 4.000000 1.000000 3.000000 2.000000 A = 1.000000 B = -5.000000 C = 1.000000 D = 21.000000 E = -18.000000 Roots: 3.000000 3.000000 1.000000 -2.000000 A = 1.000000 B = -22.000000 C = 141.000000 D = -220.000000 E = 100.000000 Roots: 10.000000 10.000000 1.000000 1.000000 A = 1.000000 B = -16.000000 C = 72.000000 D = -128.000000 E = 80.000000 Roots: 10.000000 2.000000 2.000000 2.000000 A = 1.000000 B = -20.000000 C = 150.000000 D = -500.000000 E = 625.000000 Roots: 5.000000 5.000000 5.000000 5.000000 A = 1.000000 B = 2.000000 C = 1.000000 D = 8.000000 E = -12.000000 Roots: -0.000000 -0.000000 1.000000 -3.000000 A = 1.000000 B = 0.000000 C = 13.000000 D = 0.000000 E = 36.000000 Roots: 0.000000 0.000000 0.000000 -0.000000 TEST105 For a R8ROW (a matrix regarded as rows): R8ROW_MAX computes maximums; R8ROW_MIN computes minimums; The original matrix: Col: 1 2 3 4 Row 1 : 1 2 3 4 2 : 5 6 7 8 3 : 9 10 11 12 Row maximum, minimum: 1 4.000000 1.000000 2 8.000000 5.000000 3 12.000000 9.000000 TEST106 For a R8ROW (a matrix regarded as rows): R8ROW_MEAN computes means; R8ROW_SUM computes sums; The original matrix: Col: 1 2 3 4 Row 1 : 1 2 3 4 2 : 5 6 7 8 3 : 9 10 11 12 Row sum, mean: 1 10.000000 2.500000 2 26.000000 6.500000 3 42.000000 10.500000 TEST107 For a R8ROW (a matrix regarded as rows): R8ROW_SWAP swaps two rows; The original matrix: Col: 1 2 3 4 Row 1 : 1 2 3 4 2 : 5 6 7 8 3 : 9 10 11 12 Swap rows 1 and 3 The modified matrix: Col: 1 2 3 4 Row 1 : 9 10 11 12 2 : 5 6 7 8 3 : 1 2 3 4 TEST108 R8ROW_TO_R8VEC converts an R8ROW to an R8VEC. The array of rows: Col: 1 2 3 4 Row 1 : 11 12 13 14 2 : 21 22 23 24 3 : 31 32 33 34 The resulting vector of rows: 1: 11 2: 12 3: 13 4: 14 5: 21 6: 22 7: 23 8: 24 9: 31 10: 32 11: 33 12: 34 TEST109 For a R8ROW (a matrix regarded as rows): R8ROW_VARIANCE computes variances; The original matrix: Col: 1 2 3 4 Row 1 : 1 2 3 4 2 : 5 6 7 8 3 : 9 10 11 12 Row variances: 1 1.666667 2 1.666667 3 1.666667 TEST110 R8SLMAT_PRINT prints a strictly lower triangular matrix stored compactly. Only the (possibly) nonzero elements are printed. R8SLMAT Col 1 2 3 4 5 6 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 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 TEST111 For an R8VEC: R8VEC_AMAX: maximum magnitude entry; R8VEC_AMIN: minimum magnitude entry. Input vector: 1: -5.63163 2: 9.12635 3: 6.59018 4: 1.23391 5: -1.69386 6: -8.67763 7: -4.84844 8: -7.80086 9: -9.12342 10: 2.67931 Maximum absolute: 9.126352 Minimum absolute: 1.233909 TEST112 R8VEC_BRACKET finds a pair of entries in a sorted real array which bracket a value. Sorted array: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 5 7: 7 8: 8 9: 9 10: 10 LEFT RIGHT X(LEFT) XVAL X(RIGHT) 1 2 1.000000 -10.000000 2.000000 1 2 1.000000 1.000000 2.000000 4 5 4.000000 4.500000 5.000000 6 7 5.000000 5.000000 7.000000 9 10 9.000000 10.000000 10.000000 9 10 9.000000 12.000000 10.000000 TEST113 R8VEC_BRACKET2 finds a pair of entries in a sorted DVEC which bracket a value. Sorted array: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 5 7: 7 8: 8 9: 9 10: 10 Search for XVAL = Start = 5 Left = 1 Right = 2 X(LEFT) = 1.000000 X(RIGHT) = 2.000000 Search for XVAL = Start = 1 Left = 1 Right = 1 X(LEFT) = 1.000000 X(RIGHT) = 1.000000 Search for XVAL = Start = 1 Left = 4 Right = 5 X(LEFT) = 4.000000 X(RIGHT) = 5.000000 Search for XVAL = Start = 4 Left = 5 Right = 5 X(LEFT) = 5.000000 X(RIGHT) = 5.000000 Search for XVAL = Start = 5 Left = 9 Right = 10 X(LEFT) = 9.000000 X(RIGHT) = 10.000000 Search for XVAL = Start = 9 Left = 10 Right = -1 X(LEFT) = 10.000000 TEST114 R8VEC_BRACKET3 finds a pair of entries in a sorted real array which bracket a value. Sorted array: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 5 7: 7 8: 8 9: 9 10: 10 Search for XVAL = -10.000000 Starting guess for interval is = 5 Nearest interval: X[1]= 1.000000 X[2]= 2.000000 Search for XVAL = 1.000000 Starting guess for interval is = 1 Nearest interval: X[1]= 1.000000 X[2]= 2.000000 Search for XVAL = 4.500000 Starting guess for interval is = 1 Nearest interval: X[4]= 4.000000 X[5]= 5.000000 Search for XVAL = 5.000000 Starting guess for interval is = 4 Nearest interval: X[4]= 4.000000 X[5]= 5.000000 Search for XVAL = 10.000000 Starting guess for interval is = 4 Nearest interval: X[9]= 9.000000 X[10]= 10.000000 Search for XVAL = 12.000000 Starting guess for interval is = 9 Nearest interval: X[9]= 9.000000 X[10]= 10.000000 R8LIB_TEST1145 R8VEC_CHEBYSPACE computes N Chebyshev points in [R1,R2]. N = 5, R1 = -1.000000, R2 = 1.000000 Chebyshev points: 1: -1 2: -0.707107 3: 0 4: 0.707107 5: 1 N = 7, R1 = 0.000000, R2 = 10.000000 Chebyshev points: 1: 0 2: 0.669873 3: 2.5 4: 5 5: 7.5 6: 9.33013 7: 10 R8LIB_TEST1147 R8VEC_CONVOLUTION computes the convolution of two vectors. The factor X: 1: 1 2: 2 3: 3 4: 4 The factor Y: 1: -1 2: 5 3: 3 The circular convolution z = x star y: 1: -1 2: 3 3: 10 4: 17 5: 29 6: 12 Correct answer: 1: -1 2: 3 3: 10 4: 17 5: 29 6: 12 R8LIB_TEST115 R8VEC_CONVOLUTION_CIRC computes the circular convolution of two vectors. The factor X: 1: 1 2: 2 3: 3 4: 4 The factor Y: 1: 1 2: 2 3: 4 4: 8 The circular convolution z = xCCy: 1: 37 2: 44 3: 43 4: 26 Correct answer: 1: 37 2: 44 3: 43 4: 26 TEST116 R8VEC_DIF estimates derivatives. Estimate the derivative of order N = 4 Using H = 0.010000 at argument X = 1.000000 The difference coefficients: 1: 6.25e+06 2: -2.5e+07 3: 3.75e+07 4: -2.5e+07 5: 6.25e+06 Estimate is FDIF = 2.718463 TEST1165 R8VEC_DIRECT_PRODUCT forms the entries of a direct product of a given number of R8VEC factors. J X(1) X(2) X(3) 1 1.000000 50.000000 800.000000 2 2.000000 50.000000 800.000000 3 3.000000 50.000000 800.000000 4 4.000000 50.000000 800.000000 5 1.000000 60.000000 800.000000 6 2.000000 60.000000 800.000000 7 3.000000 60.000000 800.000000 8 4.000000 60.000000 800.000000 9 1.000000 70.000000 800.000000 10 2.000000 70.000000 800.000000 11 3.000000 70.000000 800.000000 12 4.000000 70.000000 800.000000 13 1.000000 50.000000 900.000000 14 2.000000 50.000000 900.000000 15 3.000000 50.000000 900.000000 16 4.000000 50.000000 900.000000 17 1.000000 60.000000 900.000000 18 2.000000 60.000000 900.000000 19 3.000000 60.000000 900.000000 20 4.000000 60.000000 900.000000 21 1.000000 70.000000 900.000000 22 2.000000 70.000000 900.000000 23 3.000000 70.000000 900.000000 24 4.000000 70.000000 900.000000 TEST1166 R8VEC_DIRECT_PRODUCT2 forms the entries of a direct product of a given number of R8VEC factors. J W(J) 1 40000.000000 2 80000.000000 3 120000.000000 4 160000.000000 5 48000.000000 6 96000.000000 7 144000.000000 8 192000.000000 9 56000.000000 10 112000.000000 11 168000.000000 12 224000.000000 13 45000.000000 14 90000.000000 15 135000.000000 16 180000.000000 17 54000.000000 18 108000.000000 19 162000.000000 20 216000.000000 21 63000.000000 22 126000.000000 23 189000.000000 24 252000.000000 TEST117 R8VEC_EVEN computes N evenly spaced values between XLO and XHI. XLO = 0.000000 XHI = 99.000000 while N = 10 Resulting array: 1: 0 2: 11 3: 22 4: 33 5: 44 6: 55 7: 66 8: 77 9: 88 10: 99 TEST118 R8VEC_EVEN2 interpolates a specified number of points pairs of values in a vector. Input data: 0.000000 4 1.000000 3 5.000000 5 2.000000 0 0.000000 Resulting vector: * 0.000000 0.200000 0.400000 0.600000 0.800000 * 1.000000 2.000000 3.000000 4.000000 * 5.000000 4.500000 4.000000 3.500000 3.000000 2.500000 * 2.000000 * 0.000000 TEST119 R8VEC_EVEN3 tries to evenly interpolate new data between old values. Original vector: 1: 0 2: 5.1 3: 7 4: 10 New vector: 1: 0 2: 1.02 3: 2.04 4: 3.06 5: 4.08 6: 5.1 7: 5.73333 8: 6.36667 9: 7 10: 8 11: 9 12: 10 TEST120 R8VEC_EXPAND_LINEAR linearly interpolates new data between old values. Original vector: 1: 16 2: 4 3: 0 4: 4 5: 16 6: 36 Expansion factor is 3 Fattened vector: 1: 16 2: 13 3: 10 4: 7 5: 4 6: 3 7: 2 8: 1 9: 0 10: 1 11: 2 12: 3 13: 4 14: 7 15: 10 16: 13 17: 16 18: 21 19: 26 20: 31 21: 36 TEST121 R8VEC_FRAC: K-th smallest DVEC entry; Array to search: 1: 0.218418 2: 0.956318 3: 0.829509 4: 0.561695 5: 0.415307 6: 0.0661187 7: 0.257578 8: 0.109957 9: 0.043829 10: 0.633966 Fractile Value 1 0.043829 6 0.415307 TEST122 R8VEC_HISTOGRAM histograms an integer vector. Uniform data: Histogram of data: 0.000000 0 0.000000 0.050000 63 0.050000 0.100000 37 0.100000 0.150000 49 0.150000 0.200000 37 0.200000 0.250000 46 0.250000 0.300000 57 0.300000 0.350000 49 0.350000 0.400000 52 0.400000 0.450000 51 0.450000 0.500000 49 0.500000 0.550000 50 0.550000 0.600000 56 0.600000 0.650000 60 0.650000 0.700000 52 0.700000 0.750000 44 0.750000 0.800000 47 0.800000 0.850000 54 0.850000 0.900000 48 0.900000 0.950000 52 0.950000 1.000000 47 1.000000 0 Normal data: Histogram of data: -3.000000 0 -3.000000 -2.700000 2 -2.700000 -2.400000 2 -2.400000 -2.100000 11 -2.100000 -1.800000 12 -1.800000 -1.500000 32 -1.500000 -1.200000 56 -1.200000 -0.900000 66 -0.900000 -0.600000 75 -0.600000 -0.300000 114 -0.300000 0.000000 111 0.000000 0.300000 115 0.300000 0.600000 117 0.600000 0.900000 103 0.900000 1.200000 65 1.200000 1.500000 46 1.500000 1.800000 29 1.800000 2.100000 17 2.100000 2.400000 15 2.400000 2.700000 7 2.700000 3.000000 4 3.000000 1 TEST123 R8VEC_INDEX_INSERT inserts values into an index sorted array. R8VEC_INDEX_DELETE_ALL deletes all copies of a particular value. R8VEC_INDEX_DELETE_ONE deletes one copies of a particular value. R8VEC_INDEX_DELETE_DUPES deletes duplicates. Generate some random values: 4.000000 19.000000 17.000000 11.000000 8.000000 1.000000 5.000000 2.000000 1.000000 13.000000 1.000000 9.000000 8.000000 15.000000 16.000000 0.000000 18.000000 7.000000 2.000000 0.000000 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 18 8.000000 0.000000 2 22 7.000000 0.000000 3 8 4.000000 1.000000 4 13 19.000000 1.000000 5 11 17.000000 1.000000 6 10 11.000000 2.000000 7 21 8.000000 2.000000 8 3 1.000000 4.000000 9 9 5.000000 5.000000 10 2 2.000000 7.000000 11 20 1.000000 7.000000 12 23 13.000000 7.000000 13 1 1.000000 8.000000 14 15 9.000000 8.000000 15 24 8.000000 8.000000 16 7 15.000000 8.000000 17 14 16.000000 9.000000 18 6 0.000000 11.000000 19 12 18.000000 13.000000 20 16 7.000000 15.000000 21 17 2.000000 16.000000 22 5 0.000000 17.000000 23 19 7.000000 18.000000 24 4 8.000000 19.000000 Call R8VEC_INDEX_DELETE_ONE to delete one value of 8: 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.000000 0.000000 2 20 4.000000 0.000000 3 7 19.000000 1.000000 4 12 17.000000 1.000000 5 10 11.000000 1.000000 6 9 8.000000 2.000000 7 19 1.000000 2.000000 8 2 5.000000 4.000000 9 8 2.000000 5.000000 10 1 1.000000 8.000000 11 14 13.000000 8.000000 12 6 1.000000 8.000000 13 13 9.000000 9.000000 14 5 8.000000 11.000000 15 11 15.000000 13.000000 16 15 16.000000 15.000000 17 16 0.000000 16.000000 18 4 18.000000 17.000000 19 18 2.000000 18.000000 20 3 0.000000 19.000000 Call R8VEC_INDEX_DELETE_DUPES to delete duplicates: Indexed list of unique entries: I INDX(I) X(I) 1 1 0.000000 2 2 1.000000 3 3 2.000000 4 4 4.000000 5 5 5.000000 6 6 8.000000 7 7 9.000000 8 8 11.000000 9 9 13.000000 10 10 15.000000 11 11 16.000000 12 12 17.000000 13 13 18.000000 14 14 19.000000 TEST124 R8VEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. R8VEC_INDEX_ORDER sorts an index sorted array. Generate some random values: 4.000000 19.000000 17.000000 11.000000 8.000000 1.000000 5.000000 2.000000 1.000000 13.000000 1.000000 9.000000 8.000000 15.000000 16.000000 0.000000 18.000000 7.000000 2.000000 0.000000 Indexed list of unique entries: I INDX(I) X(I) X(INDX(I)) 1 13 4.000000 0.000000 2 6 19.000000 1.000000 3 8 17.000000 2.000000 4 1 11.000000 4.000000 5 7 8.000000 5.000000 6 15 1.000000 7.000000 7 5 5.000000 8.000000 8 10 2.000000 9.000000 9 4 13.000000 11.000000 10 9 9.000000 13.000000 11 11 15.000000 15.000000 12 12 16.000000 16.000000 13 3 0.000000 17.000000 14 14 18.000000 18.000000 15 2 7.000000 19.000000 Now call DVEC_INDEX_ORDER to carry out the sorting: X: 1: 0 2: 1 3: 2 4: 4 5: 5 6: 7 7: 8 8: 9 9: 11 10: 13 11: 15 12: 16 13: 17 14: 18 15: 19 TEST125 R8VEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. R8VEC_INDEX_SEARCH searches for an entry with a given value. Generate some random values: 4.000000 19.000000 17.000000 11.000000 8.000000 1.000000 5.000000 2.000000 1.000000 13.000000 1.000000 9.000000 8.000000 15.000000 16.000000 0.000000 18.000000 7.000000 2.000000 0.000000 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 13 4.000000 0.000000 2 6 19.000000 1.000000 3 8 17.000000 2.000000 4 1 11.000000 4.000000 5 7 8.000000 5.000000 6 15 1.000000 7.000000 7 5 5.000000 8.000000 8 10 2.000000 9.000000 9 4 13.000000 11.000000 10 9 9.000000 13.000000 11 11 15.000000 15.000000 12 12 16.000000 16.000000 13 3 0.000000 17.000000 14 14 18.000000 18.000000 15 2 7.000000 19.000000 Results of search for given XVAL: XVAL Less Equal More 0.000000 0 1 2 1.000000 1 2 3 2.000000 2 3 4 3.000000 3 0 4 4.000000 3 4 5 5.000000 4 5 6 6.000000 5 0 6 7.000000 5 6 7 8.000000 6 7 8 9.000000 7 8 9 10.000000 8 0 9 11.000000 8 9 10 12.000000 9 0 10 13.000000 9 10 11 14.000000 10 0 11 15.000000 10 11 12 16.000000 11 12 13 17.000000 12 13 14 18.000000 13 14 15 19.000000 14 15 16 20.000000 15 0 16 R8LIB_TEST1251 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 1: 0.218418 2: 0.956318 3: 0.829509 4: 0.561695 5: 0.415307 6: 0.0661187 7: 0.257578 8: 0.109957 9: 0.043829 10: 0.633966 11: 0.0617272 12: 0.449539 13: 0.401306 14: 0.754673 15: 0.797287 16: 0.00183837 17: 0.897504 18: 0.350752 19: 0.0945448 20: 0.0136169 I INDX R(INDX(I)) 1 16 0.001838 2 20 0.013617 3 9 0.043829 4 11 0.061727 5 6 0.066119 6 19 0.094545 7 8 0.109957 8 1 0.218418 9 7 0.257578 10 18 0.350752 11 13 0.401306 12 5 0.415307 13 12 0.449539 14 4 0.561695 15 10 0.633966 16 14 0.754673 17 15 0.797287 18 3 0.829509 19 17 0.897504 20 2 0.956318 R_LO 0.840847 R_HI 0.859097 Empty range in R. Array 1: 0.123104 2: 0.00751236 3: 0.260303 4: 0.912484 5: 0.113664 6: 0.351629 7: 0.822887 8: 0.267132 9: 0.692066 10: 0.561662 11: 0.861216 12: 0.453794 13: 0.911977 14: 0.597917 15: 0.188955 16: 0.761492 17: 0.396988 18: 0.185314 19: 0.574366 20: 0.367027 I INDX R(INDX(I)) 1 2 0.007512 2 5 0.113664 3 1 0.123104 4 18 0.185314 5 15 0.188955 6 3 0.260303 7 8 0.267132 8 6 0.351629 9 20 0.367027 10 17 0.396988 11 12 0.453794 12 10 0.561662 13 19 0.574366 14 14 0.597917 15 9 0.692066 16 16 0.761492 17 7 0.822887 18 11 0.861216 19 13 0.911977 20 4 0.912484 R_LO 0.361529 9 20 0.367027 10 17 0.396988 11 12 0.453794 12 10 0.561662 13 19 0.574366 14 14 0.597917 R_HI 0.617205 Array 1: 0.21293 2: 0.714471 3: 0.117707 4: 0.299329 5: 0.825003 6: 0.82466 7: 0.0618618 8: 0.710781 9: 0.0882833 10: 0.777994 11: 0.745303 12: 0.308675 13: 0.899373 14: 0.763537 15: 0.761731 16: 0.40697 17: 0.938749 18: 0.562088 19: 0.01782 20: 0.501103 I INDX R(INDX(I)) 1 19 0.017820 2 7 0.061862 3 9 0.088283 4 3 0.117707 5 1 0.212930 6 4 0.299329 7 12 0.308675 8 16 0.406970 9 20 0.501103 10 18 0.562088 11 8 0.710781 12 2 0.714471 13 11 0.745303 14 15 0.761731 15 14 0.763537 16 10 0.777994 17 6 0.824660 18 5 0.825003 19 13 0.899373 20 17 0.938749 R_LO 0.041909 2 7 0.061862 3 9 0.088283 4 3 0.117707 5 1 0.212930 6 4 0.299329 7 12 0.308675 R_HI 0.368851 Array 1: 0.271724 2: 0.858573 3: 0.0290366 4: 0.0174423 5: 0.152384 6: 0.114319 7: 0.353907 8: 0.119308 9: 0.206653 10: 0.212924 11: 0.612948 12: 0.809519 13: 0.58709 14: 0.215492 15: 0.768056 16: 0.723297 17: 0.448019 18: 0.855176 19: 0.945017 20: 0.909057 I INDX R(INDX(I)) 1 4 0.017442 2 3 0.029037 3 6 0.114319 4 8 0.119308 5 5 0.152384 6 9 0.206653 7 10 0.212924 8 14 0.215492 9 1 0.271724 10 7 0.353907 11 17 0.448019 12 13 0.587090 13 11 0.612948 14 16 0.723297 15 15 0.768056 16 12 0.809519 17 18 0.855176 18 2 0.858573 19 20 0.909057 20 19 0.945017 R_LO 0.030195 3 6 0.114319 4 8 0.119308 5 5 0.152384 6 9 0.206653 7 10 0.212924 8 14 0.215492 9 1 0.271724 10 7 0.353907 11 17 0.448019 R_HI 0.519726 Array 1: 0.481067 2: 0.292313 3: 0.90264 4: 0.667842 5: 0.412278 6: 0.156948 7: 0.833282 8: 0.964404 9: 0.74079 10: 0.456099 11: 0.653561 12: 0.406827 13: 0.540539 14: 0.832281 15: 0.145756 16: 0.717128 17: 0.775651 18: 0.362262 19: 0.531111 20: 0.379977 I INDX R(INDX(I)) 1 15 0.145756 2 6 0.156948 3 2 0.292313 4 18 0.362262 5 20 0.379977 6 12 0.406827 7 5 0.412278 8 10 0.456099 9 1 0.481067 10 19 0.531111 11 13 0.540539 12 11 0.653561 13 4 0.667842 14 16 0.717128 15 9 0.740790 16 17 0.775651 17 14 0.832281 18 7 0.833282 19 3 0.902640 20 8 0.964404 R_LO 0.269285 3 2 0.292313 4 18 0.362262 5 20 0.379977 6 12 0.406827 7 5 0.412278 8 10 0.456099 9 1 0.481067 10 19 0.531111 11 13 0.540539 12 11 0.653561 13 4 0.667842 14 16 0.717128 15 9 0.740790 16 17 0.775651 17 14 0.832281 18 7 0.833282 R_HI 0.877418 TEST1252 R8VEC_INDEXED_HEAP_D creates a descending heap from an indexed R8VEC. The data vector: 1: 101 2: 102 3: 103 4: 104 5: 105 6: 106 7: 107 8: 108 9: 109 10: 110 11: 111 12: 112 13: 113 14: 114 15: 115 16: 116 17: 117 18: 118 19: 119 20: 120 The index vector: 1: 1 2: 11 3: 17 4: 5 5: 7 6: 13 7: 15 8: 3 9: 19 10: 9 A(INDX): 1 101 2 111 3 117 4 105 5 107 6 113 7 115 8 103 9 119 10 109 The data vector (should NOT change): 1: 101 2: 102 3: 103 4: 104 5: 105 6: 106 7: 107 8: 108 9: 109 10: 110 11: 111 12: 112 13: 113 14: 114 15: 115 16: 116 17: 117 18: 118 19: 119 20: 120 The index vector (may change): 1: 19 2: 11 3: 17 4: 5 5: 9 6: 13 7: 15 8: 3 9: 1 10: 7 A(INDX) is now a heap: 1 119 2 111 3 117 4 105 5 109 6 113 7 115 8 103 9 101 10 107 TEST1255 For an indexed R8VEC, R8VEC_INDEXED_HEAP_D_INSERT inserts a value into the heap. R8VEC_INDEXED_HEAP_D_EXTRACT extracts the maximum value; R8VEC_INDEXED_HEAP_D_MAX reports the maximum value. These 3 operations are enough to model a priority queue. The data vector: 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: 20 The index vector: 1: 9 2: 2 3: 8 4: 14 5: 5 A(INDX): 1 9.000000 2 2.000000 3 8.000000 4 14.000000 5 5.000000 The index vector after heaping: 1: 14 2: 9 3: 8 4: 2 5: 5 A(INDX) after heaping: 1 14.000000 2 9.000000 3 8.000000 4 2.000000 5 5.000000 Inserting value 7.000000 Current maximum is 14.000000 Inserting value 15.000000 Current maximum is 15.000000 Inserting value 1.000000 Current maximum is 15.000000 Inserting value 19.000000 Current maximum is 19.000000 Inserting value 20.000000 Current maximum is 20.000000 The data vector after insertions: 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: 20 The index vector after insertions: 1: 20 2: 19 3: 14 4: 9 5: 15 6: 7 7: 8 8: 1 9: 2 10: 5 A(INDX) after insertions: 1 20.000000 2 19.000000 3 14.000000 4 9.000000 5 15.000000 6 7.000000 7 8.000000 8 1.000000 9 2.000000 10 5.000000 Now extract the maximum several times. Extracting maximum element A(20) = 20.000000 Extracting maximum element A(19) = 19.000000 Extracting maximum element A(15) = 15.000000 Extracting maximum element A(14) = 14.000000 Extracting maximum element A(9) = 9.000000 The data vector after extractions: 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: 20 The index vector after extractions: 1: 8 2: 5 3: 7 4: 2 5: 1 A(INDX) after extractions: 1 8.000000 2 5.000000 3 7.000000 4 2.000000 5 1.000000 R8LIB_TEST1256 R8VEC_LEGENDRE computes N Legendre points in [R1,R2]. N = 5, R1 = -1, R2 = 1 Legendre points: 1: -0.90618 2: -0.538469 3: 0 4: 0.538469 5: 0.90618 N = 7, R1 = 0, R2 = 10 Legendre points: 1: 0.25446 2: 1.29234 3: 2.97077 4: 5 5: 7.02923 6: 8.70766 7: 9.74554 TEST1258 For a R8VEC: R8VEC_LINSPACE: evenly spaced points between A and B; R8VEC_MIDSPACE: evenly spaced midpoints between A and B r8vec_linspace ( 5, 10, 20 ) 1: 10 2: 12.5 3: 15 4: 17.5 5: 20 r8vec_midspace ( 5, 10, 20 ) 1: 11 2: 13 3: 15 4: 17 5: 19 TEST126 For an R8VEC: R8VEC_MAX: maximum entry; R8VEC_MIN: minimum entry. Input vector: 1: -5.63163 2: 9.12635 3: 6.59018 4: 1.23391 5: -1.69386 6: -8.67763 7: -4.84844 8: -7.80086 9: -9.12342 10: 2.67931 Maximum: 9.126352 Minimum: -9.123420 TEST127 For an R8VEC: R8VEC_MAX_INDEX: index of maximum entry; R8VEC_MIN_INDEX: index of minimum entry; Input vector: 1: -5.63163 2: 9.12635 3: 6.59018 4: 1.23391 5: -1.69386 6: -8.67763 7: -4.84844 8: -7.80086 9: -9.12342 10: 2.67931 Maximum index: 2 Minimum index: 9 TEST128 For an R8VEC R8VEC_MEAN: mean value; R8VEC_MEDIAN: median value; Input vector: 1: -5.63163 2: 9.12635 3: 6.59018 4: 1.23391 5: -1.69386 6: -8.67763 7: -4.84844 8: -7.80086 9: -9.12342 10: 2.67931 Mean: -1.814609 Median: -1.693858 TEST129 For an R8VEC: R8VEC_NORM_L1: L1 norm. R8VEC_NORM_L2: L2 norm. R8VEC_NORM_LI: L-infinity norm. Input vector: 1: -5.63163 2: 9.12635 3: 6.59018 4: 1.23391 5: -1.69386 6: -8.67763 7: -4.84844 8: -7.80086 9: -9.12342 10: 2.67931 L1 norm: 57.405605 L2 norm: 20.320074 L-Infinity norm: 9.126352 TEST130 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. 1 -0.552650 2 1.679040 3 -0.472769 4 -0.566060 5 -0.231124 Test #2: Restore the random number seed. Call 5 times, 1 value each time. The results should be identical. 1 1.679040 2 -0.472769 3 -0.566060 4 -0.231124 5 1.212934 Test #3: Restore the random number seed. Call 1 time for 5 values. The results should be identical. 1 1.679040 2 -0.472769 3 -0.566060 4 -0.231124 5 1.212934 Test #4: Restore the random number seed. Call for 2, 1, and 2 values. The results should be identical. 1 1.679040 2 -0.472769 1 -0.566060 1 -0.231124 2 1.212934 Test #5: Number of samples was 1000 Minimum value was -3.029754 Maximum value was 3.328581 Average value was -0.015156 Variance was 0.999674 Expected average 0.000000 Expected variance 1.000000 TEST131 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 1: 1 2: 3 3: 2 4: 4 The following vector has order type 0 1: 2 2: 2 3: 2 4: 2 The following vector has order type 1 1: 1 2: 2 3: 2 4: 4 The following vector has order type 2 1: 1 2: 2 3: 3 4: 4 The following vector has order type 3 1: 4 2: 4 3: 3 4: 1 The following vector has order type 4 1: 9 2: 7 3: 3 4: 0 TEST132 R8VEC_PERMUTE permutes a DVEC in place. I, Perm(I), X(I) 1 2 1.000000 2 4 2.000000 3 5 3.000000 4 1 4.000000 5 3 5.000000 Permuted array: 1: 2 2: 4 3: 5 4: 1 5: 3 R8LIB_TEST133 R8VEC_POLARIZE decomposes a vector into components parallel and normal to a direction. Original vector: 1: 1 2: 2 3: 3 Direction vector: 1: 3 2: 1 3: -2 Normal component: 1: 1.21429 2: 2.07143 3: 2.85714 Parallel component: 1: -0.214286 2: -0.0714286 3: 0.142857 Dot product of P and A_normal (should be 0) 0.000000 Cosine of angle between P and A_parallel (should be 1 or -1) -1.000000 Sum of components (should equal A): 1: 1 2: 2 3: 3 TEST134 R8VEC_ROTATE rotates a DVEC in place. Rotate entries 2 places to the right. Original array: 1: 1 2: 2 3: 3 4: 4 5: 5 Rotated array: 1: 4 2: 5 3: 1 4: 2 5: 3 TEST135 R8VEC_REVERSE reverses a DVEC. Original array: 1: 1 2: 2 3: 3 4: 4 5: 5 Reversed array: 1: 5 2: 4 3: 3 4: 2 5: 1 TEST136 For ascending order: R8VEC_SEARCH_BINARY_A searches a sorted array; Using initial random number seed = 123456789 Sorted vector A: 1: 0.043829 2: 0.0661187 3: 0.109957 4: 0.218418 5: 0.257578 6: 0.415307 7: 0.561695 8: 0.633966 9: 0.829509 10: 0.956318 Search the array for the value 0.218418 SEARCH RESULT: The value occurs in index 4 TEST137 R8VEC_SORT_BUBBLE_A ascending sorts a real vector. Original array: 1: 13.105098 2: 57.379055 3: 49.770554 4: 33.701727 5: 24.918425 6: 3.967124 7: 15.454668 8: 6.597408 9: 2.629740 10: 38.037943 Ascending sorted array: 1: 0.110302 2: 0.817013 3: 2.629740 4: 3.703634 5: 3.967124 6: 5.672685 7: 6.597408 8: 13.105098 9: 15.454668 10: 21.045140 TEST138 R8VEC_SORT_HEAP_A ascending sorts an R8VEC. Original array: 1: 13.105098 2: 57.379055 3: 49.770554 4: 33.701727 5: 24.918425 6: 3.967124 7: 15.454668 8: 6.597408 9: 2.629740 10: 38.037943 Ascending sorted array: 1: 0.110302 2: 0.817013 3: 2.629740 4: 3.703634 5: 3.967124 6: 5.672685 7: 6.597408 8: 13.105098 9: 15.454668 10: 21.045140 TEST139 R8VEC_SORT_HEAP_D descending sorts a DVEC. Original array: 1: 13.105098 2: 57.379055 3: 49.770554 4: 33.701727 5: 24.918425 6: 3.967124 7: 15.454668 8: 6.597408 9: 2.629740 10: 38.037943 Descending sorted array: 1: 57.379055 2: 53.850244 3: 49.770554 4: 47.837217 5: 45.280409 6: 38.037943 7: 33.701727 8: 26.972338 9: 24.918425 10: 24.078377 TEST140 R8VEC_SORT_HEAP_INDEX_A creates an ascending sort index for an R8VEC. R8VEC_SORT_HEAP_INDEX_D creates a descending sort index for an R8VEC. Unsorted array: 1: 13.105098 2: 57.379055 3: 49.770554 4: 33.701727 5: 24.918425 6: 3.967124 7: 15.454668 8: 6.597408 9: 2.629740 10: 38.037943 After indexed ascending sort: I, INDX(I), A(I) 1 16 13.105098 2 20 57.379055 3 9 49.770554 4 11 33.701727 5 6 24.918425 6 19 3.967124 7 8 15.454668 8 1 6.597408 9 7 2.629740 10 18 38.037943 11 13 3.703634 12 5 26.972338 13 12 24.078377 14 4 45.280409 15 10 47.837217 16 14 0.110302 17 15 53.850244 18 3 21.045140 19 17 5.672685 20 2 0.817013 Now use the index array to carry out the permutation implicitly. INDX(I), A(INDX(I)) 16 0.110302 20 0.817013 9 2.629740 11 3.703634 6 3.967124 19 5.672685 8 6.597408 1 13.105098 7 15.454668 18 21.045140 13 24.078377 5 24.918425 12 26.972338 4 33.701727 10 38.037943 14 45.280409 15 47.837217 3 49.770554 17 53.850244 2 57.379055 Call R8VEC_PERMUTE to carry out the permutation explicitly. I, A(I) 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 11: 24.0784 12: 24.9184 13: 26.9723 14: 33.7017 15: 38.0379 16: 45.2804 17: 47.8372 18: 49.7706 19: 53.8502 20: 57.3791 After indexed descending sort: I, INDX(I), A(I) 1 20 0.110302 2 19 0.817013 3 18 2.629740 4 17 3.703634 5 16 3.967124 6 15 5.672685 7 14 6.597408 8 13 13.105098 9 12 15.454668 10 11 21.045140 11 10 24.078377 12 9 24.918425 13 8 26.972338 14 7 33.701727 15 6 38.037943 16 5 45.280409 17 4 47.837217 18 3 49.770554 19 2 53.850244 20 1 57.379055 Now use the index array to carry out the permutation implicitly. INDX(I), ARRAY(INDX(I)) 20 57.379055 19 53.850244 18 49.770554 17 47.837217 16 45.280409 15 38.037943 14 33.701727 13 26.972338 12 24.918425 11 24.078377 10 21.045140 9 15.454668 8 13.105098 7 6.597408 6 5.672685 5 3.967124 4 3.703634 3 2.629740 2 0.817013 1 0.110302 TEST141 R8VEC_SORT_HEAP_MASK_A creates an ascending sort index for a masked DVEC. 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 11: 3.70363 12: 26.9723 13: 24.0784 14: 45.2804 15: 47.8372 16: 0.110302 17: 53.8502 18: 21.0451 19: 5.67269 20: 0.817013 The mask array: 1: 2 2: 4 3: 7 4: 8 5: 9 6: 12 7: 13 8: 16 9: 18 10: 19 Masked vector printout: The masked unsorted array: 1: 2 57.3791 2: 4 33.7017 3: 7 15.4547 4: 8 6.59741 5: 9 2.62974 6: 12 26.9723 7: 13 24.0784 8: 16 0.110302 9: 18 21.0451 10: 19 5.67269 After masked indexed ascending sort: I, INDX(I), MASK(INDX(I)), A(MASK(INDX(I))) 1 8 $6d 16.000000 1.103023e-01 2 5 $6d 9.000000 2.629740e+00 3 10 $6d 19.000000 5.672685e+00 4 4 $6d 8.000000 6.597408e+00 5 3 $6d 7.000000 1.545467e+01 6 9 $6d 18.000000 2.104514e+01 7 7 $6d 13.000000 2.407838e+01 8 6 $6d 12.000000 2.697234e+01 9 2 $6d 4.000000 3.370173e+01 10 1 $6d 2.000000 5.737905e+01 Call I4VEC_PERMUTE to carry out the index permutation explicitly on the MASK vector. The reordered mask array: 1: 16 2: 9 3: 19 4: 8 5: 7 6: 18 7: 13 8: 12 9: 4 10: 2 Masked vector printout: The reordered masked sorted array: 1: 16 0.110302 2: 9 2.62974 3: 19 5.67269 4: 8 6.59741 5: 7 15.4547 6: 18 21.0451 7: 13 24.0784 8: 12 26.9723 9: 4 33.7017 10: 2 57.3791 TEST142 R8VEC_SORT_INSERT_A ascending sorts an R8VEC. Unsorted array: 1: 13.105098 2: 57.379055 3: 49.770554 4: 33.701727 5: 24.918425 6: 3.967124 7: 15.454668 8: 6.597408 9: 2.629740 10: 38.037943 Sorted array: 1: 0.110302 2: 0.817013 3: 2.629740 4: 3.703634 5: 3.967124 6: 5.672685 7: 6.597408 8: 13.105098 9: 15.454668 10: 21.045140 TEST143 R8VEC_SORT_INSERT_INDEX_A creates an ascending sort index for an R8VEC. Unsorted array: 1: 13.105098 2: 57.379055 3: 49.770554 4: 33.701727 5: 24.918425 6: 3.967124 7: 15.454668 8: 6.597408 9: 2.629740 10: 38.037943 After indexed ascending sort: I, INDX(I), A(I) 1 16 13.105098 2 20 57.379055 3 9 49.770554 4 11 33.701727 5 6 24.918425 6 19 3.967124 7 8 15.454668 8 1 6.597408 9 7 2.629740 10 18 38.037943 11 13 3.703634 12 5 26.972338 13 12 24.078377 14 4 45.280409 15 10 47.837217 16 14 0.110302 17 15 53.850244 18 3 21.045140 19 17 5.672685 20 2 0.817013 Now use the index array to carry out the permutation implicitly. I, INDX(I), A(INDX(I)) 1 16 0.110302 2 20 0.817013 3 9 2.629740 4 11 3.703634 5 6 3.967124 6 19 5.672685 7 8 6.597408 8 1 13.105098 9 7 15.454668 10 18 21.045140 11 13 24.078377 12 5 24.918425 13 12 26.972338 14 4 33.701727 15 10 38.037943 16 14 45.280409 17 15 47.837217 18 3 49.770554 19 17 53.850244 20 2 57.379055 Call R8VEC_PERMUTE to carry out the permutation explicitly. Permuted data 1: 0.110302 2: 0.817013 3: 2.629740 4: 3.703634 5: 3.967124 6: 5.672685 7: 6.597408 8: 13.105098 9: 15.454668 10: 21.045140 TEST144 R8VEC_SORT_QUICK_A sorts an R8VEC using quick sort. Unsorted array: 1: 2.18418 2: 9.56318 3: 8.29509 4: 5.61695 5: 4.15307 6: 0.661187 7: 2.57578 8: 1.09957 9: 0.43829 10: 6.33966 11: 0.617272 12: 4.49539 13: 4.01306 14: 7.54673 15: 7.97287 16: 0.0183837 17: 8.97504 18: 3.50752 19: 0.945448 20: 0.136169 Sorted array: 1: 0.0183837 2: 0.136169 3: 0.43829 4: 0.617272 5: 0.661187 6: 0.945448 7: 1.09957 8: 2.18418 9: 2.57578 10: 3.50752 11: 4.01306 12: 4.15307 13: 4.49539 14: 5.61695 15: 6.33966 16: 7.54673 17: 7.97287 18: 8.29509 19: 8.97504 20: 9.56318 TEST145 For ascending order: R8VEC_SORTED_MERGE_A merges two sorted DVEC's; Using initial random number seed = 123456789 Sorted vector A: 1: 0.043829 2: 0.0661187 3: 0.109957 4: 0.218418 5: 0.257578 6: 0.415307 7: 0.561695 8: 0.633966 9: 0.829509 10: 0.956318 Sorted vector B: 1: 0.00183837 2: 0.0136169 3: 0.0617272 4: 0.0945448 5: 0.350752 6: 0.401306 7: 0.449539 8: 0.754673 9: 0.797287 10: 0.897504 Merged vector C: 1: 0.00183837 2: 0.0136169 3: 0.043829 4: 0.0617272 5: 0.0661187 6: 0.0945448 7: 0.109957 8: 0.218418 9: 0.257578 10: 0.350752 11: 0.401306 12: 0.415307 13: 0.449539 14: 0.561695 15: 0.633966 16: 0.754673 17: 0.797287 18: 0.829509 19: 0.897504 20: 0.956318 TEST146 R8VEC_SORTED_NEAREST finds the nearest entry in a sorted real array. Sorted array: 1: 0.43829 2: 0.661187 3: 1.09957 4: 2.18418 5: 2.57578 6: 4.15307 7: 5.61695 8: 6.33966 9: 8.29509 10: 9.56318 Test Nearest Value Index Value 0.617272 2 0.661187 4.495390 6 4.153071 4.013063 6 4.153071 7.546735 9 8.295092 7.972870 9 8.295092 0.018384 1 0.438290 8.975041 10 9.563176 3.507523 6 4.153071 0.945448 3 1.099568 0.136169 1 0.438290 TEST1465 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: 1: 0.043829 2: 0.0661187 3: 0.109957 4: 0.218418 5: 0.257578 6: 0.415307 7: 0.561695 8: 0.633966 9: 0.829509 10: 0.956318 R_LO 0.061727 2 0.066119 3 0.109957 4 0.218418 5 0.257578 6 0.415307 R_HI 0.449539 Sorted array R: 1: 0.00183837 2: 0.0136169 3: 0.0945448 4: 0.350752 5: 0.401306 6: 0.754673 7: 0.797287 8: 0.840847 9: 0.859097 10: 0.897504 R_LO 0.007512 2 0.013617 3 0.094545 R_HI 0.123104 Sorted array R: 1: 0.113664 2: 0.260303 3: 0.267132 4: 0.351629 5: 0.453794 6: 0.561662 7: 0.692066 8: 0.822887 9: 0.861216 10: 0.912484 R_LO 0.597917 7 0.692066 8 0.822887 9 0.861216 R_HI 0.911977 Sorted array R: 1: 0.185314 2: 0.188955 3: 0.21293 4: 0.361529 5: 0.367027 6: 0.396988 7: 0.574366 8: 0.617205 9: 0.714471 10: 0.761492 R_LO 0.117707 1 0.185314 2 0.188955 3 0.212930 R_HI 0.299329 Sorted array R: 1: 0.0618618 2: 0.0882833 3: 0.308675 4: 0.710781 5: 0.745303 6: 0.763537 7: 0.777994 8: 0.82466 9: 0.825003 10: 0.899373 R_LO 0.406970 4 0.710781 5 0.745303 R_HI 0.761731 TEST147 R8VEC_SORTED_SPLIT splits a sorted vector into entries less than and greater than a splitting value. R8VEC_SPLIT splits an unsorted vector in the same way. The sorted array: 1: 0 2: 0 3: 0 4: 0 5: 0.5 6: 0.5 7: 0.5 8: 0.5 9: 0.5 10: 1 11: 1.5 12: 1.5 13: 2 14: 2 15: 2 16: 2 17: 3 18: 3 19: 4 20: 4 21: 4 22: 4 23: 4.5 24: 4.5 25: 5 Splitting value is 2.500000 Lower index I_LT = 16 Upper index I_GT = 17 Now repeat test with R8VEC_SPLIT. The shuffled array: 1: 4.5 2: 0 3: 1.5 4: 4 5: 1 6: 4 7: 3 8: 0 9: 2 10: 4.5 11: 0.5 12: 2 13: 0 14: 3 15: 0.5 16: 4 17: 4 18: 2 19: 0.5 20: 0 21: 0.5 22: 1.5 23: 0.5 24: 5 25: 2 The split array: 1: 2 2: 0 3: 1.5 4: 0.5 5: 1 6: 1.5 7: 0.5 8: 0 9: 2 10: 0 11: 0.5 12: 2 13: 0 14: 0.5 15: 0.5 16: 2 17: 4 18: 4 19: 3 20: 4.5 21: 3 22: 4 23: 5 24: 4 25: 4.5 Array entries <= SPLIT up to index 16 SUBPAK_TEST1475 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: 1: 11 2: 11 3: 11 4: 22 5: 22 6: 33 7: 33 8: 55 9: 55 Tolerance for equality is 2.220446e-16 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) 1 1 11.000000 2 4 22.000000 3 6 33.000000 4 8 55.000000 UNDX can be used to created XU, a copy of X containing only the unique elements, in sorted order. I UNDX XU(I) 1 1 11.000000 2 4 22.000000 3 6 33.000000 4 8 55.000000 XDNU can be used to match each element of X with one of the unique elements I XDNU X(I) XU(XDNU(I)) 1 1 11.000000 11.000000 2 1 11.000000 11.000000 3 1 11.000000 11.000000 4 2 22.000000 22.000000 5 2 22.000000 22.000000 6 3 33.000000 33.000000 7 3 33.000000 33.000000 8 4 55.000000 55.000000 9 4 55.000000 55.000000 TEST148 R8VEC_SORTED_UNIQUE finds the unique entries in a sorted R8VEC; Unsorted array: 1: 6.000000 2: 28.000000 3: 24.000000 4: 16.000000 5: 12.000000 6: 1.000000 7: 7.000000 8: 3.000000 9: 1.000000 10: 19.000000 Unique entries 1: 0 2: 1 3: 2 4: 3 5: 6 6: 7 7: 8 8: 10 9: 12 10: 13 11: 16 12: 19 13: 22 14: 23 15: 24 16: 25 17: 26 18: 27 19: 28 SUBPAK_TEST149 R8VEC_SORTED_UNIQUE_COUNT counts the unique entries of a sorted R8VEC; Using a tolerance of 0.250000 R8VEC_SORTED_UNIQUE_COUNT counts 29 unique entries in A. R8LIB_TEST150 R8VEC_SORTED_UNIQUE_HIST makes a historgram of the unique entries in a real vector. Using random number seed 123456789 Unsorted array: 1: 7.5 2: 29.5 3: 25.5 4: 17.5 5: 12.5 6: 2.5 7: 8.5 8: 3.5 9: 1.5 10: 19.5 11: 2.5 12: 13.5 13: 12.5 14: 23.5 15: 24.5 16: 0.5 17: 27.5 18: 11.5 19: 3.5 20: 0.5 21: 26.5 22: 25.5 23: 4.5 24: 0.5 25: 8.5 26: 27.5 27: 3.5 28: 11.5 29: 25.5 30: 8.5 Ascending sorted array: 1: 0.5 2: 0.5 3: 0.5 4: 1.5 5: 2.5 6: 2.5 7: 3.5 8: 3.5 9: 3.5 10: 4.5 11: 7.5 12: 8.5 13: 8.5 14: 8.5 15: 11.5 16: 11.5 17: 12.5 18: 12.5 19: 13.5 20: 17.5 21: 19.5 22: 23.5 23: 24.5 24: 25.5 25: 25.5 26: 25.5 27: 26.5 28: 27.5 29: 27.5 30: 29.5 R8VEC_SORTED_UNIQUE_HIST counts 18 unique entries. Value Multiplicity 1 0.500000 3 2 1.500000 1 3 2.500000 2 4 3.500000 3 5 4.500000 1 6 7.500000 1 7 8.500000 3 8 11.500000 2 9 12.500000 2 10 13.500000 1 11 17.500000 1 12 19.500000 1 13 23.500000 1 14 24.500000 1 15 25.500000 3 16 26.500000 1 17 27.500000 2 18 29.500000 1 R8LIB_TEST1504 R8VEC_TRANSPOSE_PRINT prints an R8VEC "tranposed", 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 R8LIB_TEST1505 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: 1: 33 2: 55 3: 11 4: 11 5: 55 6: 33 7: 22 8: 22 9: 11 Tolerance for equality is 2.220446e-16 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) 1 3 11.000000 2 7 22.000000 3 6 33.000000 4 5 55.000000 UNDX can be used to created XU, a copy of X containing only the unique elements, in sorted order. I UNDX XU(I) 1 3 11.000000 2 7 22.000000 3 6 33.000000 4 5 55.000000 XDNU can be used to match each element of X with one of the unique elements I XDNU X(I) XU(XDNU(I)) 1 3 33.000000 33.000000 2 4 55.000000 55.000000 3 1 11.000000 11.000000 4 1 11.000000 11.000000 5 4 55.000000 55.000000 6 3 33.000000 33.000000 7 2 22.000000 22.000000 8 2 22.000000 22.000000 9 1 11.000000 11.000000 R8LIB_TEST151 R8VEC_UNIFORM returns a random R8VEC with entries in a given range [ ALO, AHI ] For this problem: ALO = 10.000000 AHI = 20.000000 Input SEED = 123456789 Random vector: 1: 12.184183 2: 19.563176 3: 18.295092 4: 15.616954 5: 14.153071 6: 10.661187 7: 12.575778 8: 11.099568 9: 10.438290 10: 16.339657 Input SEED = 29242052 Random vector: 1: 18.590969 2: 18.408475 3: 11.231039 4: 10.075124 5: 12.603030 6: 19.124837 7: 11.136640 8: 13.516287 9: 18.228873 10: 12.671323 Input SEED = 397959036 Random vector: 1: 15.743659 2: 13.670267 3: 16.172048 4: 13.615287 5: 12.129300 6: 17.144712 7: 11.177069 8: 12.993291 9: 18.250030 10: 18.246601 R8LIB_TEST152 For an R8VEC: R8VEC_NORMALIZE_L1: make unit sum; Input vector: 1: -5.63163 2: 9.12635 3: 6.59018 4: 1.23391 5: -1.69386 6: -8.67763 7: -4.84844 8: -7.80086 9: -9.12342 10: 2.67931 After calling R8VEC_NORMALIZE_L1: 1: 0.31035 2: -0.502938 3: -0.363174 4: -0.0679986 5: 0.0933457 6: 0.478209 7: 0.26719 8: 0.429892 9: 0.502776 10: -0.147652 R8LIB_TEST153 For a pair of R8VEC's: R8VEC2_SORT_A ascending sorts; R8VEC2_SORT_D descending sorts; The pair of arrays: 1: 1.43684 5.30864 2: 2.91264 7.24769 3: 1.43684 5.30864 4: 2.12339 8.77337 5: 1.83061 8.98643 6: 2.91264 7.24769 7: 1.51516 9.48752 8: 1.21991 6.75376 9: 1.43684 5.30864 10: 2.26793 5.06808 Arrays after ascending sort: 1: 1.21991 6.75376 2: 1.43684 5.30864 3: 1.43684 5.30864 4: 1.43684 5.30864 5: 1.51516 9.48752 6: 1.83061 8.98643 7: 2.12339 8.77337 8: 2.26793 5.06808 9: 2.91264 7.24769 10: 2.91264 7.24769 Arrays after descending sort: 1: 2.91264 7.24769 2: 2.91264 7.24769 3: 2.26793 5.06808 4: 2.12339 8.77337 5: 1.83061 8.98643 6: 1.51516 9.48752 7: 1.43684 5.30864 8: 1.43684 5.30864 9: 1.43684 5.30864 10: 1.21991 6.75376 R8LIB_TEST154 R8VEC2_SORT_HEAP_INDEX_A creates a sort index for an (X,Y) array. The unsorted array: I, X(I), Y(I) 1 0.200000 0.900000 2 1.000000 0.850000 3 0.850000 0.100000 4 0.550000 0.000000 5 0.400000 0.250000 6 0.050000 0.950000 7 0.250000 0.100000 8 0.100000 0.350000 9 0.000000 0.850000 10 0.650000 0.250000 11 0.050000 0.700000 12 0.450000 0.550000 13 0.400000 0.900000 14 0.750000 0.450000 15 0.800000 0.950000 16 0.000000 0.600000 17 0.900000 0.150000 18 0.350000 0.750000 19 0.050000 0.400000 20 0.000000 0.150000 After sorting: I, INDX(I), X(I), Y(I) 1 20 0.200000 0.900000 2 16 1.000000 0.850000 3 9 0.850000 0.100000 4 19 0.550000 0.000000 5 11 0.400000 0.250000 6 6 0.050000 0.950000 7 8 0.250000 0.100000 8 1 0.100000 0.350000 9 7 0.000000 0.850000 10 18 0.650000 0.250000 11 5 0.050000 0.700000 12 13 0.450000 0.550000 13 12 0.400000 0.900000 14 4 0.750000 0.450000 15 10 0.800000 0.950000 16 14 0.000000 0.600000 17 15 0.900000 0.150000 18 3 0.350000 0.750000 19 17 0.050000 0.400000 20 2 0.000000 0.150000 Now use the index array to carry out the permutation implicitly. I, INDX(I), X(INDX(I)), Y(INDX(I)) 1 20 0.000000 0.150000 2 16 0.000000 0.600000 3 9 0.000000 0.850000 4 19 0.050000 0.400000 5 11 0.050000 0.700000 6 6 0.050000 0.950000 7 8 0.100000 0.350000 8 1 0.200000 0.900000 9 7 0.250000 0.100000 10 18 0.350000 0.750000 11 5 0.400000 0.250000 12 13 0.400000 0.900000 13 12 0.450000 0.550000 14 4 0.550000 0.000000 15 10 0.650000 0.250000 16 14 0.750000 0.450000 17 15 0.800000 0.950000 18 3 0.850000 0.100000 19 17 0.900000 0.150000 20 2 1.000000 0.850000 R8VEC_PERMUTE carries out the permutation. I, X(I), Y(I) 1 0.000000 0.150000 2 0.000000 0.600000 3 0.000000 0.850000 4 0.050000 0.400000 5 0.050000 0.700000 6 0.050000 0.950000 7 0.100000 0.350000 8 0.200000 0.900000 9 0.250000 0.100000 10 0.350000 0.750000 11 0.400000 0.250000 12 0.400000 0.900000 13 0.450000 0.550000 14 0.550000 0.000000 15 0.650000 0.250000 16 0.750000 0.450000 17 0.800000 0.950000 18 0.850000 0.100000 19 0.900000 0.150000 20 1.000000 0.850000 R8LIB_TEST155 For a pair of R8VEC's: R8VEC2_SORTED_UNIQUE counts unique entries. The pair of arrays: 1: 1.43684 5.30864 2: 2.91264 7.24769 3: 1.43684 5.30864 4: 2.12339 8.77337 5: 1.83061 8.98643 6: 2.91264 7.24769 7: 1.51516 9.48752 8: 1.21991 6.75376 9: 1.43684 5.30864 10: 2.26793 5.06808 Arrays after ascending sort: 1: 1.21991 6.75376 2: 1.43684 5.30864 3: 1.43684 5.30864 4: 1.43684 5.30864 5: 1.51516 9.48752 6: 1.83061 8.98643 7: 2.12339 8.77337 8: 2.26793 5.06808 9: 2.91264 7.24769 10: 2.91264 7.24769 UNIQed array: 1: 1.21991 6.75376 2: 1.43684 5.30864 3: 1.51516 9.48752 4: 1.83061 8.98643 5: 2.12339 8.77337 6: 2.26793 5.06808 7: 2.91264 7.24769 R8LIB_TEST156 For a pair of R8VEC's: R8VEC2_SORTED_UNIQUE_INDEX indexes unique entries. Sorted arrays: 1: 1.21991 6.75376 2: 1.43684 5.30864 3: 1.43684 5.30864 4: 1.43684 5.30864 5: 1.51516 9.48752 6: 1.83061 8.98643 7: 2.12339 8.77337 8: 2.26793 5.06808 9: 2.91264 7.24769 10: 2.91264 7.24769 The number of unique elements is 7 Index of Unique Elements: 1: 1 2: 2 3: 5 4: 6 5: 7 6: 8 7: 9 After Indexed Nonunique Deletion. 1: 1.21991 6.75376 2: 1.43684 5.30864 3: 1.51516 9.48752 4: 1.83061 8.98643 5: 2.12339 8.77337 6: 2.26793 5.06808 7: 2.91264 7.24769 R8LIB_TEST157 For a pair of R8VEC's: R8VEC2_SUM_MAX_INDEX: index of the sum vector with maximum value. The pair of vectors: 1: 2.18418 0.308636 2: 9.56318 2.24769 3: 8.29509 2.00653 4: 5.61695 3.77337 5: 4.15307 3.98643 6: 0.661187 0.00919186 7: 2.57578 4.48752 8: 1.09957 1.75376 9: 0.43829 0.472724 10: 6.33966 0.0680845 Index of maximum in A+B: 2 R8LIB_TEST Normal end of execution. 08-Aug-2012 12:19:07 >>