23-Jul-2022 08:11:05 i4lib_test(): MATLAB/Octave version 9.8.0.1380330 (R2020a) Update 2 Test i4lib(). i4_abs_test(): i4_abs() returns the absolute value of an I4. A B=I4_ABS(A) 63 63 82 82 -75 75 83 83 27 27 -81 81 -45 45 9 9 92 92 93 93 i4_and_test(): i4_and() returns the bitwise AND of two integers. MATLAB provides a BITAND operator. I J I4_AND BITAND 15 98 2 2 96 49 32 32 80 14 0 0 42 92 8 8 80 96 64 64 66 3 2 2 85 94 84 84 68 76 68 68 75 39 3 3 66 17 0 0 i4_bclr_test(): i4_bclr() sets a given bit to 0. Working on I4 = 101 Pos I4_BCLR 0 100 1 101 2 97 3 101 4 101 5 69 6 37 7 101 8 101 9 101 10 101 11 101 12 101 13 101 14 101 15 101 16 101 17 101 18 101 19 101 20 101 21 101 22 101 23 101 24 101 25 101 26 101 27 101 28 101 29 101 30 101 31 101 Working on I4 = -31 Pos I4_BCLR 0 -32 1 -31 2 -31 3 -31 4 -31 5 -63 6 -95 7 -159 8 -287 9 -543 10 -1055 11 -2079 12 -4127 13 -8223 14 -16415 15 -32799 16 -65567 17 -131103 18 -262175 19 -524319 20 -1048607 21 -2097183 22 -4194335 23 -8388639 24 -16777247 25 -33554463 26 -67108895 27 -134217759 28 -268435487 29 -536870943 30 -1073741855 31 2147483617 i4_bit_hi1_test(): i4_bit_hi1() returns the location of the high 1 bit. I I4_BIT_HI1(I) 71 7 3 2 27 5 4 3 9 4 83 7 70 7 32 6 95 7 3 2 i4_bit_lo0_test(): i4_bit_lo0() returns the location of the low 0 bit. I I4_BIT_LO0(I) 44 1 38 1 77 2 80 1 18 1 49 2 45 2 65 2 71 4 76 1 i4_bit_lo1_test(): i4_bit_lo1() returns the location of the low 1 bit. I I4_BIT_LO1(I) 27 1 68 3 66 2 16 5 12 3 50 2 96 6 34 2 59 1 22 2 i4_bit_reverse_test(): i4_bit_reverse() bit reverses I with respect to 2^J I J I4_BIT_REVERSE(I,J) 0 0 0 0 1 0 1 1 1 0 2 0 1 2 2 2 2 1 3 2 3 0 3 0 1 3 4 2 3 2 3 3 6 4 3 1 5 3 5 6 3 3 7 3 7 0 4 0 1 4 8 2 4 4 3 4 12 4 4 2 5 4 10 6 4 6 7 4 14 8 4 1 9 4 9 10 4 5 11 4 13 12 4 3 13 4 11 14 4 7 15 4 15 i4_bset_test(): i4_bset() sets a given bit to 1. Working on I4 = 101 Pos I4_BSET 0 101 1 103 2 101 3 109 4 117 5 101 6 101 7 229 8 357 9 613 10 1125 11 2149 12 4197 13 8293 14 16485 15 32869 16 65637 17 131173 18 262245 19 524389 20 1048677 21 2097253 22 4194405 23 8388709 24 16777317 25 33554533 26 67108965 27 134217829 28 268435557 29 536871013 30 1073741925 31 -2147483547 Working on I4 = -31 Pos I4_BSET 0 -31 1 -29 2 -27 3 -23 4 -15 5 -31 6 -31 7 -31 8 -31 9 -31 10 -31 11 -31 12 -31 13 -31 14 -31 15 -31 16 -31 17 -31 18 -31 19 -31 20 -31 21 -31 22 -31 23 -31 24 -31 25 -31 26 -31 27 -31 28 -31 29 -31 30 -31 31 -31 i4_btest_test(): i4_btest() reports whether a given bit is 0 or 1. Analyze the integer I4 = 101 Pos I4_BTEST(I4,POS) 0 1 1 0 2 1 3 0 4 0 5 1 6 1 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 Analyze the integer I4 = -31 Pos I4_BTEST(I4,POS) 0 1 1 0 2 0 3 0 4 0 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 i4_ceiling_test(): i4_ceiling() evaluates the "ceiling" of an R8. R8 I4_CEILING(R8) 50.2534 51 -48.9810 -48 1.1914 2 39.8153 40 78.1807 79 91.8583 92 9.4431 10 -72.2751 -72 -70.1412 -70 -48.4983 -48 i4_characteristic_test(): i4_characteristic() computes the characteristic of an integer Q, which is Q if Q is prime; P, if Q = P^N for some prime P; 0, if Q is negative, 0, 1, or the product of more than 1 distinct prime. I, I4_CHARACTERISTIC 1 0 2 2 3 3 4 2 5 5 6 0 7 7 8 2 9 3 10 0 11 11 12 0 13 13 14 0 15 0 16 2 17 17 18 0 19 19 20 0 21 0 22 0 23 23 24 0 25 5 26 0 27 3 28 0 29 29 30 0 31 31 32 2 33 0 34 0 35 0 36 0 37 37 38 0 39 0 40 0 41 41 42 0 43 43 44 0 45 0 46 0 47 47 48 0 49 7 50 0 i4_choose_test(): i4_choose() evaluates C(N,K). N K CNK 0 0 1 1 0 1 1 1 1 2 0 1 2 1 2 2 2 1 3 0 1 3 1 3 3 2 3 3 3 1 4 0 1 4 1 4 4 2 6 4 3 4 4 4 1 i4_choose_check_test(): i4_choose_check() checks whether C(N,K) can be computed with integer arithmetic or not. N K CHECK? I4_CHOOSE 10 3 1 120 1000 999 1 1000 100 3 1 161700 100 10 0 Not computable i4_choose_log_test(): i4_choose_log() evaluates log(C(N,K)). N K lcnk elcnk CNK 0 0 0 1 1 1 0 0 1 1 1 1 0 1 1 2 0 0 1 1 2 1 0.693147 2 2 2 2 0 1 1 3 0 0 1 1 3 1 1.09861 3 3 3 2 1.09861 3 3 3 3 0 1 1 4 0 0 1 1 4 1 1.38629 4 4 4 2 1.79176 6 6 4 3 1.38629 4 4 4 4 0 1 1 i4_div_rounded_test(): i4_div_rounded() performs rounded integer division. C0 = int ( a / b ) C1 = I4_DIV_ROUNDED ( A, B ) C2 = nint ( a / b ) A B C0 C1 C2 68 -5 -14 -14 -14 63 -5 -13 -13 -13 86 -3 -29 -29 -29 -61 -5 12 12 12 23 -1 -23 -23 -23 -30 7 -5 -4 -4 17 1 17 17 17 84 -4 -21 -21 -21 52 5 10 10 10 -24 1 -24 -24 -24 -85 -9 9 9 9 6 6 1 1 1 87 -8 -11 -11 -11 14 -1 -14 -14 -14 -98 -3 32 33 33 -68 6 -12 -11 -11 -38 1 -38 -38 -38 -67 2 -34 -33 -34 -48 3 -16 -16 -16 38 5 7 8 8 i4_divp_test(): i4_divp() returns the smallest multiplier of J that is less than I A B C D -10 -9 2 -18 -54 9 -6 -54 -70 7 -10 -70 8 10 1 10 -85 -1 87 -87 -79 10 -7 -70 -100 6 -16 -96 64 8 8 64 -84 -2 43 -86 -48 6 -8 -48 -14 9 -1 -9 -64 -5 14 -70 -71 -8 10 -80 74 2 37 74 10 -7 -1 7 71 3 24 72 -30 7 -4 -28 -20 -9 3 -27 -52 -8 7 -56 -64 -5 14 -70 i4_factorial_test(): i4_factorial() evaluates the factorial function. N Exact I4_FACTORIAL(N) 0 1 1 1 1 1 2 2 2 3 6 6 4 24 24 5 120 120 6 720 720 7 5040 5040 8 40320 40320 9 362880 362880 10 3628800 3628800 11 39916800 39916800 12 479001600 479001600 i4_factorial_log_test(): i4_factorial_log() evaluates the log(N!). N lfact elfact fact 0 0 1 1 1 0 1 1 2 0.693147 2 2 3 1.79176 6 6 4 3.17805 24 24 5 4.78749 120 120 6 6.57925 720 720 7 8.52516 5040 5040 8 10.6046 40320 40320 9 12.8018 362880 362880 10 15.1044 3.6288e+06 3628800 11 17.5023 3.99168e+07 39916800 12 19.9872 4.79002e+08 479001600 i4_factorial2_test(): i4_factorial2() evaluates the double factorial function. N Exact I4_FACTORIAL2(N) 0 1 1 1 1 1 2 2 2 3 3 3 4 8 8 5 15 15 6 48 48 7 105 105 8 384 384 9 945 945 10 3840 3840 11 10395 10395 12 46080 46080 13 135135 135135 14 645120 645120 15 2027025 2027025 i4_fall_test(): i4_fall() evaluates the falling factorial function. M N Exact I4_FALL(M,N) 5 0 1 1 5 1 5 5 5 2 20 20 5 3 60 60 5 4 120 120 5 5 120 120 5 6 0 0 50 0 1 1 10 1 10 10 4000 1 4000 4000 10 2 90 90 18 3 4896 4896 4 4 24 24 98 3 912576 912576 1 7 0 0 i4_floor_test(): i4_floor() evaluates the "floor" of an R8. R8 I4_FLOOR(R8) -16.5466 -17 -90.0691 -91 80.5432 80 88.9574 88 -1.8272 -2 -2.1495 -3 -32.4561 -33 80.0108 80 -26.1506 -27 -77.7594 -78 i4_gcd_test(): i4_gcd() computes the greatest common factor I J I4_GCD 36 30 6 49 -7 7 0 71 71 12 12 12 36 49 1 1 42 1 91 28 7 i4_huge_test(): i4_huge() returns a huge integer. I4_HUGE() = 2147483647 i4_huge_normalizer_test(): i4_huge_normalizer() returns 1/(I4_HUGE+1). I4_HUGE() = 2147483647 I4_HUGE_NORMALIZER() = 4.656613e-10 I4_HUGE * I4_HUGE_NORMALIZER = 1.000000e+00 i4_is_even_test(): i4_is_even() reports whether an I4 is even. I I4_IS_EVEN(I) -2 1 -1 0 0 1 1 0 2 1 3 0 4 1 5 0 6 1 7 0 8 1 9 0 10 1 11 0 12 1 13 0 14 1 15 0 16 1 17 0 18 1 19 0 20 1 21 0 22 1 23 0 24 1 25 0 i4_is_integer_test(): i4_is_integer() is TRUE if i4 stores an integer value. Example 1: Obviously integer: a = 6 A is an integer value. Example 2: Obviously NOT integer: a = 6.5000 A is NOT an integer value. Example 3: Not Integer, Not obvious: a = 6.0000 A is NOT an integer value. Example 4: Not Integer, Not obvious: a = 3.0000e+08 A is NOT an integer value. i4_is_odd_test(): i4_is_odd() reports whether an I4 is odd. I I4_IS_ODD(I) -2 0 -1 1 0 0 1 1 2 0 3 1 4 0 5 1 6 0 7 1 8 0 9 1 10 0 11 1 12 0 13 1 14 0 15 1 16 0 17 1 18 0 19 1 20 0 21 1 22 0 23 1 24 0 25 1 i4_is_power_of_2_test(): i4_is_power_of_2() reports whether an I4 is a power of 2. I I4_IS_POWER_OF_2(I) -4 0 -3 0 -2 0 -1 0 0 0 1 1 2 1 3 0 4 1 5 0 6 0 7 0 8 1 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 1 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 i4_is_power_of_10_test(): i4_is_power_of_10() reports whether an I4 is a power of 10. I I4_IS_POWER_OF_10(I) 97 0 98 0 99 0 100 1 101 0 102 0 103 0 i4_is_prime_test(): i4_is_prime() reports whether an integer is prime. I I4_IS_PRIME(I) -2 0 -1 0 0 0 1 0 2 1 3 1 4 0 5 1 6 0 7 1 8 0 9 0 10 0 11 1 12 0 13 1 14 0 15 0 16 0 17 1 18 0 19 1 20 0 21 0 22 0 23 1 24 0 25 0 i4_lcm_test(): i4_lcm() computes the least common multiple. I J I4_LCM 36 30 180 49 -7 49 0 71 0 12 12 12 36 49 1764 1 42 42 91 28 364 i4_lcm_12n_test(): i4_lcm_12n() computes the least common multiple of integer 1 through N N I4_LCM_12N ( 1 1 ( 2 2 ( 3 6 ( 4 12 ( 5 60 ( 6 60 ( 7 420 ( 8 420 ( 9 1260 ( 10 1260 i4_log_10_test(): i4_log_10(): whole part of log base 10, X, I4_LOG_10 0 0 1 0 2 0 3 0 9 0 10 1 11 1 99 1 101 2 -1 0 -2 0 -3 0 -9 0 i4_log_2_test(): i4_log_2(): whole part of log base 2. X I4_LOG_2 0 -Inf 1 0 2 1 3 1 9 3 10 3 11 3 99 6 101 6 -1 0 -2 1 -3 1 -9 3 1000 9 1023 9 1024 10 1025 10 i4_log_i4_test(): i4_log_i4(): logarith of I4 base J4, I4 J4 I4_LOG_I4 0 2 0 1 2 0 2 2 1 3 2 1 4 2 2 5 2 2 6 2 2 7 2 2 8 2 3 9 2 3 10 2 3 0 3 0 1 3 0 2 3 0 3 3 1 4 3 1 5 3 1 6 3 1 7 3 1 8 3 1 9 3 2 10 3 2 0 4 0 1 4 0 2 4 0 3 4 0 4 4 1 5 4 1 6 4 1 7 4 1 8 4 1 9 4 1 10 4 1 0 5 0 1 5 0 2 5 0 3 5 0 4 5 0 5 5 1 6 5 1 7 5 1 8 5 1 9 5 1 10 5 1 i4_log_r8_test(): i4_log_r8(): whole part of log base B, X B I4_LOG_R8 16 2.000000 3 16 3.000000 2 16 4.000000 1 16 5.000000 1 16 6.000000 1 16 7.000000 1 16 8.000000 1 16 16.000000 0 16 32.000000 0 16 256.000000 0 i4_mant_test(): i4_mant() decomposes an integer. Number to be decomposed is X = -314.159000 X = -1 * ( 2763371787763843 / 2251799813685248 ) * 2 ^ (8) i4_max_test(): i4_max() returns the maximum of two I4's. A B C=I4_MAX(A,B) 56 -22 56 -52 -19 -19 -81 -74 -74 89 92 92 15 -88 15 -53 -30 -30 65 -97 65 -92 -67 -67 30 47 47 30 -10 30 i4_min_test(): i4_min() returns the minimum of two I4's. A B C=I4_MIN(A,B) 9 -41 -41 49 -63 -63 38 -64 -64 -26 25 -26 56 -84 -84 86 55 55 -3 -13 -13 -11 -39 -39 2 2 2 64 59 59 i4_moddiv_test(): i4_moddiv() factors a number into a multiple and a remainder. Number Divisor Multiple Remainder 107 50 2 7 107 -50 -3 -43 -107 50 -3 43 -107 -50 2 -7 Repeat using MOD: 107 50 2 7 107 -50 -3 -43 -107 50 -3 43 -107 -50 2 -7 i4_modp_test(): i4_modp() factors a number into a multiple and a remainder. Number Divisor Multiple Remainder 107 50 2 7 107 -50 -2 7 -107 50 -3 43 -107 -50 3 43 Repeat using MOD: 107 50 2 7 107 -50 -3 -43 -107 50 -3 43 -107 -50 2 -7 i4_not_test(): i4_not() returns the bitwise NOT of an integer I with respect to some maximum value J. MATLAB provides a BITCMP operator. I I4_NOT(255) BITCMP(uint8) l = 91 164 91 91 l = 159 96 159 159 l = 48 207 48 48 l = 119 136 119 119 l = 166 89 166 166 l = 15 240 15 15 l = 31 224 31 31 l = 115 140 115 115 l = 96 159 96 96 l = 105 150 105 105 i4_or_test(): i4_or() returns the bitwise inclusive OR of two integers. MATLAB provides a BITOR operator. I J I4_OR BITOR 20 30 30 30 47 23 63 63 85 19 87 87 22 17 23 23 22 44 62 62 31 93 95 95 43 18 59 59 91 98 123 123 44 11 47 47 26 41 59 59 i4_rise_test(): i4_rise() evaluates the rising factorial function. M N Exact I4_RISE(M,N) 5 0 1 1 5 1 5 5 5 2 30 30 5 3 210 210 5 4 1680 1680 5 5 15120 15120 5 6 151200 151200 50 0 1 1 i4_sign_test(): i4_sign() returns the sign of a number. I4 I4_SIGN(I4) -10 -1 -7 -1 0 1 5 1 9 1 i4_sign3_test(): i4_sign3() returns the three-way sign of a number. I4 I4_SIGN3(I4) -10 -1 -7 -1 0 0 5 1 9 1 i4_swap_test(): i4_swap() swaps two integers. Before swapping: I = 1 J = 202 After swapping: I = 202 J = 1 i4_to_halton_test(): i4_to_halton() computes a Halton sequence. The user specifies all data explicitly. In this test, we call I4_TO_HALTON repeatedly. We use distinct primes as bases. I R(0) R(1) R(2) 0 0.000000 0.000000 0.000000 1 0.500000 0.333333 0.200000 2 0.250000 0.666667 0.400000 3 0.750000 0.111111 0.600000 4 0.125000 0.444444 0.800000 5 0.625000 0.777778 0.040000 6 0.375000 0.222222 0.240000 7 0.875000 0.555556 0.440000 8 0.062500 0.888889 0.640000 9 0.562500 0.037037 0.840000 10 0.312500 0.370370 0.080000 i4_to_l4_test(): i4_to_l4() converts an I4 to an L4. I4 L4 -5 1 -4 1 -3 1 -2 1 -1 1 0 0 1 1 2 1 3 1 4 1 5 1 i4_to_pascal_test(): i4_to_pascal() converts a linear index to Pascal triangle indices. K => I J 1 0 0 2 1 0 3 0 1 4 2 0 5 1 1 6 0 2 7 3 0 8 2 1 9 1 2 10 0 3 11 4 0 12 3 1 13 2 2 14 1 3 15 0 4 16 5 0 17 4 1 18 3 2 19 2 3 20 1 4 i4_to_pascal_degree_test(): i4_to_pascal_degree() converts a linear index to the degree of the corresponding Pascal triangle indices. K => D 1 0 2 1 3 1 4 2 5 2 6 2 7 3 8 3 9 3 10 3 11 4 12 4 13 4 14 4 15 4 16 5 17 5 18 5 19 5 20 5 i4_to_triangle_lower_test(): i4_to_triangle_lower() converts a linear index to a lower triangular one. K => I J 1 1 1 2 2 1 3 2 2 4 3 1 5 3 2 6 3 3 7 4 1 8 4 2 9 4 3 10 4 4 11 5 1 12 5 2 13 5 3 14 5 4 15 5 5 16 6 1 17 6 2 18 6 3 19 6 4 20 6 5 i4_to_triangle_upper_test(): i4_to_triangle_upper() converts a linear index to an upper triangular one. K => I J 1 1 1 2 1 2 3 2 2 4 1 3 5 2 3 6 3 3 7 1 4 8 2 4 9 3 4 10 4 4 11 1 5 12 2 5 13 3 5 14 4 5 15 5 5 16 1 6 17 2 6 18 3 6 19 4 6 20 5 6 i4_uniform_ab_test(): i4_uniform_ab() computes pseudorandom values in an interval [A,B]. The lower endpoint A = -100.000000 The upper endpoint B = 200.000000 1 79 2 -22 3 81 4 114 5 -34 6 -65 7 -11 8 -5 9 27 10 52 11 -75 12 -21 13 141 14 -92 15 179 16 119 17 47 18 74 19 -29 20 38 i4_walsh_1d_test(): i4_walsh_1d() evaluates 1D Walsh functions: X W(+2) W(+1) W(0) W(-1) W(-2) W(-3) 0.000000 0 0 0 0 0 0 0.250000 0 0 0 0 1 0 0.500000 0 0 0 1 0 0 0.750000 0 0 0 1 1 0 1.000000 0 0 1 0 0 0 1.250000 0 0 1 0 1 0 1.500000 0 0 1 1 0 0 1.750000 0 0 1 1 1 0 2.000000 0 1 0 0 0 0 2.250000 0 1 0 0 1 0 2.500000 0 1 0 1 0 0 2.750000 0 1 0 1 1 0 3.000000 0 1 1 0 0 0 3.250000 0 1 1 0 1 0 3.500000 0 1 1 1 0 0 3.750000 0 1 1 1 1 0 4.000000 1 0 0 0 0 0 4.250000 1 0 0 0 1 0 4.500000 1 0 0 1 0 0 4.750000 1 0 0 1 1 0 5.000000 1 0 1 0 0 0 5.250000 1 0 1 0 1 0 5.500000 1 0 1 1 0 0 5.750000 1 0 1 1 1 0 6.000000 1 1 0 0 0 0 6.250000 1 1 0 0 1 0 6.500000 1 1 0 1 0 0 6.750000 1 1 0 1 1 0 7.000000 1 1 1 0 0 0 7.250000 1 1 1 0 1 0 7.500000 1 1 1 1 0 0 7.750000 1 1 1 1 1 0 8.000000 0 0 0 0 0 0 i4_wrap_test(): i4_wrap() forces an integer to lie within given limits. ilo = 4 ihi = 8 i i4_wrap(i,ilo,ihi) -10 5 -9 6 -8 7 -7 8 -6 4 -5 5 -4 6 -3 7 -2 8 -1 4 0 5 1 6 2 7 3 8 4 4 5 5 6 6 7 7 8 8 9 4 10 5 11 6 12 7 13 8 14 4 15 5 16 6 17 7 18 8 19 4 20 5 i4_xor_test(): i4_xor() returns the bitwise exclusive OR of two integers. MATLAB provides a BITXOR operator which should be used instead! I J I4_XOR BITXOR 97 55 86 86 52 23 35 35 49 63 14 14 68 39 99 99 37 99 70 70 3 89 90 90 92 80 12 12 9 26 19 19 33 68 101 101 13 72 69 69 i4block_print_test(): i4block_print() prints an I4BLOCK. The 3D array: K = 1 J: 1 2 3 1: 1 1 1 2: 2 4 8 3: 3 9 27 4: 4 16 64 K = 2 J: 1 2 3 1: 2 2 2 2: 4 8 16 3: 6 18 54 4: 8 32 128 i4col_find_item_test(): i4col_find_item() finds the first occurrence of an item in an integer array of columns. The matrix of columns: Col: 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 4: 41 42 43 44 5: 51 52 53 54 Item 34 occurs in row 3 and column 4. Item 12 occurs in row 1 and column 2. Item 90 occurs in row -1 and column -1. I4col_find_pair_wrap_test(): i4col_find_pair_wrap() finds the first occurrence of a pair of item in an integer array of columns. Items in the array are ordered by column, and wraparound is allowed. The matrix of columns: Col: 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 4: 41 42 43 44 5: 51 52 53 54 Item 22 followed by item 32 occurs in row 2 and column 2 Item 32 followed by item 22 occurs in row -1 and column -1 Item 22 followed by item 23 occurs in row -1 and column -1 Item 54 followed by item 14 occurs in row 5 and column 4 Item 54 followed by item 11 occurs in row -1 and column -1 i4col_sort_a_test(): i4col_sort_a() ascending sorts an integer array as a table of columns. The original matrix: Col: 1 2 3 4 Row 1: 2 10 1 7 2: 7 9 8 7 3: 5 4 6 9 4: 8 7 5 9 5: 8 2 10 6 Ascending sorted: Col: 1 2 3 4 Row 1: 1 2 7 10 2: 8 7 7 9 3: 6 5 9 4 4: 5 8 9 7 5: 10 8 6 2 i4col_sort_d_test(): i4col_sort_d() descending sorts an integer array as a table of columns. The original matrix: Col: 1 2 3 4 Row 1: 2 2 1 1 2: 3 10 7 9 3: 9 8 1 9 4: 1 6 1 8 5: 5 5 6 2 Descending sorted: Col: 1 2 3 4 Row 1: 2 2 1 1 2: 10 3 9 7 3: 8 9 9 1 4: 6 1 8 1 5: 5 5 2 6 i4col_sort2_a_test(): i4col_sort2_a() sorts the elements of the columns. The matrix: Col: 1 2 3 4 Row 1: 13 9 17 13 2: 10 17 16 13 3: 20 1 1 6 4: 13 2 8 9 5: 16 3 11 0 6: 9 8 8 20 The element-sorted column matrix: Col: 1 2 3 4 Row 1: 9 1 1 0 2: 10 2 8 6 3: 13 3 8 9 4: 13 8 11 13 5: 16 9 16 13 6: 20 17 17 20 i4col_sorted_singleton_count_test(): i4col_sorted_singleton_count() counts singletons in a sorted I4COL; Ascending sorted I4COL: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 0 0 2 2 2 2 2 3 3 3 2: 0 1 0 1 2 3 3 0 1 3 3: 1 1 0 1 2 1 2 0 2 0 Number of singletons = 10 Ascending sorted I4COL: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 0 1 2 2 2 2 2 3 3 3 2: 1 1 0 0 1 1 1 0 2 3 3: 1 0 1 3 0 1 3 3 1 1 Number of singletons = 10 i4col_sorted_unique_count_test(): i4col_sorted_unique_count() counts the unique entries of a sorted I4COL; Ascending sorted I4COL: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 0 1 1 1 1 1 1 2 2 3 2: 2 0 0 0 2 2 3 0 0 2 3: 3 0 1 2 2 2 2 0 1 1 Number of unique entries = 9 Ascending sorted I4COL: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 0 0 0 1 2 2 2 2 3 3 2: 1 1 1 2 1 1 3 3 0 2 3: 0 1 1 2 3 3 1 2 2 0 Number of unique entries = 8 i4mat_elim_test(): i4mat_elim() does exact Gauss elimination. The original matrix: Col: 1 2 3 4 5 Row 1: 1 2 3 4 5 2: 6 7 8 9 10 3: 11 12 13 14 15 4: 16 17 18 19 20 5: 21 22 23 24 25 The matrix returned by I4MAT_ELIM: Col: 1 2 3 4 5 Row 1: 21 22 23 24 25 2: 0 -1 -2 -3 -4 3: 0 0 0 0 0 4: 0 0 0 0 0 5: 0 0 0 0 0 The original matrix: Col: 1 2 3 4 5 Row 1: 40320 20160 13440 10080 8064 2: 20160 13440 10080 8064 6720 3: 13440 10080 8064 6720 5760 4: 10080 8064 6720 5760 5040 5: 8064 6720 5760 5040 4480 The matrix returned by I4MAT_ELIM: Col: 1 2 3 4 5 Row 1: 60 30 20 15 12 2: 0 -840 -960 -945 -896 3: 0 0 80 135 168 4: 0 0 0 15 32 5: 0 0 0 0 1 The original matrix: Col: 1 2 3 4 5 Row 1: 1 2 3 4 5 2: 2 4 6 8 10 3: 3 6 9 12 15 4: 4 8 12 16 20 5: 5 10 15 20 25 The matrix returned by I4MAT_ELIM: Col: 1 2 3 4 5 Row 1: 1 2 3 4 5 2: 0 0 0 0 0 3: 0 0 0 0 0 4: 0 0 0 0 0 5: 0 0 0 0 0 i4mat_indicator_test(): i4mat_indicator() returns an indicator matrix; Indicator matrix: Col: 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 4: 41 42 43 44 5: 51 52 53 54 i4mat_is_binary_test(): i4mat_is_binary() is TRUE if an I4MAT only contains 0 or 1 entries. Matrix: Col: 1 2 3 Row 1: 0 1 0 2: 1 0 1 X is binary Matrix: Col: 1 2 3 Row 1: 1 1 1 2: 1 1 1 X is binary Matrix: Col: 1 2 3 Row 1: 0 1 0 2: 1 2 1 X is binary i4mat_is_integer_test(): i4mat_is_integer() is TRUE if every entry of an I4MAT is an integer. Example 1: Obviously integer: a = 1 2 3 4 5 6 A is an integer matrix. Example 2: Obviously NOT integer: a = 1.0000 2.0000 3.0000 4.0000 5.0000 6.5000 A is NOT an integer matrix. Example 3: Not Integer, Not obvious: a = 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 A is NOT an integer matrix. Example 4: Not Integer, Not obvious: a = 1.0e+08 * 0.0000 0.0000 3.0000 0.0000 0.0000 0.0000 A is NOT an integer matrix. i4mat_is_ternary_test(): i4mat_is_ternary() is TRUE if an I4MAT only contains -1, 0, and +1 entries. Matrix: Col: 1 2 3 Row 1: 0 -1 0 2: 1 0 1 X is ternary Matrix: Col: 1 2 3 Row 1: 1 1 1 2: 1 1 1 X is ternary Matrix: Col: 1 2 3 Row 1: 0 1 0 2: -1 2 -1 X is NOT ternary. i4mat_l1_inverse_test(): i4mat_l1_inverse() inverts a unit lower triangular matrix. The original matrix: Col: 1 2 3 4 5 6 Row 1: 1 0 0 0 0 0 2: 2 1 0 0 0 0 3: 0 0 1 0 0 0 4: 5 0 3 1 0 0 5: 0 0 0 0 1 0 6: 75 0 0 6 4 1 The inverse matrix: Col: 1 2 3 4 5 6 Row 1: 1 0 0 0 0 0 2: -2 1 0 0 0 0 3: 0 0 1 0 0 0 4: -5 0 -3 1 0 0 5: 0 0 0 0 1 0 6: -45 0 18 -6 -4 1 The product: Col: 1 2 3 4 5 6 Row 1: 1 0 0 0 0 0 2: 0 1 0 0 0 0 3: 0 0 1 0 0 0 4: 0 0 0 1 0 0 5: 0 0 0 0 1 0 6: 0 0 0 0 0 1 i4mat_max_test(): i4mat_max() returns the maximum; Random array: Col: 1 2 3 4 5 6 7 Row 1: 5 0 3 10 1 7 2 2: 8 1 6 2 6 7 7 3: 3 7 2 8 7 7 2 4: 8 5 8 2 6 6 1 5: 5 1 2 3 4 10 6 Maximum entry = 10 i4mat_max_index_test(): i4mat_max_index() locates the maximum; Random array: Col: 1 2 3 4 5 6 7 Row 1: 4 7 6 3 7 5 0 2: 5 4 6 1 5 10 4 3: 7 9 5 10 7 2 4 4: 8 9 9 7 5 1 4 5: 3 2 2 5 7 1 8 Maximum I,J indices = 3 4 i4mat_min_test(): i4mat_min() returns the minimum; Random array: Col: 1 2 3 4 5 6 7 Row 1: 6 1 9 5 0 3 4 2: 8 7 5 3 8 8 0 3: 10 1 4 1 2 4 3 4: 10 5 7 6 4 7 4 5: 2 5 8 2 7 7 2 Minimum entry = 0 i4mat_min_index_test(): i4mat_min_index() locates the minimum; Random array: Col: 1 2 3 4 5 6 7 Row 1: 2 8 2 4 10 2 3 2: 9 4 8 9 5 4 5 3: 4 8 10 8 9 8 0 4: 9 8 3 1 6 9 1 5: 4 4 7 9 1 8 1 Minimum I,J indices = 3 7 i4mat_perm_uniform_test(): i4mat_perm_uniform() applies a random permutation to a square integer matrix. The original matrix: 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 4: 41 42 43 44 45 5: 51 52 53 54 55 The permuted matrix: Col: 1 2 3 4 5 Row 1: 44 43 42 41 45 2: 34 33 32 31 35 3: 24 23 22 21 25 4: 14 13 12 11 15 5: 54 53 52 51 55 i4mat_product_elementwise_test(): i4mat_product_elementwise() computes the elementwise product of two I4MATs. A: Col: 1 2 3 Row 1: 1 2 3 2: 4 5 6 B: Col: 1 2 3 Row 1: 1 3 5 2: 2 4 6 Elementwise product = 86 i4mat_print_test(): i4mat_print() prints an I4MAT. The I4MAT: Col: 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 4: 41 42 43 44 5: 51 52 53 54 6: 61 62 63 64 i4mat_print_some_test(): i4mat_print_some() prints some of an I4MAT. The I4MAT, rows 2:4, cols 1:2: Col: 1 2 Row 2: 21 22 3: 31 32 4: 41 42 i4mat_rank_test(): i4mat_rank() computes the rank of an integer matrix. Matrix A1: Col: 1 2 3 Row 1: 1 2 3 2: 4 5 6 3: 7 8 9 The rank is 2 Matrix A2: Col: 1 2 3 Row 1: 1 2 3 2: 4 5 6 3: 7 8 0 The rank is 3 Matrix A3: Col: 1 2 3 Row 1: 1 2 3 2: 4 5 6 3: 7 8 0 4: 10 11 12 The rank is 3 Matrix A4: Col: 1 2 3 4 Row 1: 1 2 3 7 2: 4 5 6 8 3: 7 8 0 3 The rank is 3 Matrix A5: Col: 1 2 3 Row 1: 1 2 3 2: 4 5 6 3: 7 8 9 4: 10 11 12 5: 3 3 3 The rank is 2 Matrix A6: Col: 1 2 Row 1: 0 0 2: 0 0 3: 0 0 The rank is 0 i4mat_ref_test(): i4mat_ref() computes the integer row echelon form of an I4MAT. Input A: Col: 1 2 3 4 5 6 7 Row 1: 1 3 0 2 6 3 1 2: -2 -6 0 -2 -8 3 1 3: 3 9 0 0 6 6 2 4: -1 -3 0 1 0 9 3 The pseudo-determinant = 6 IREF of A: Col: 1 2 3 4 5 6 7 Row 1: 1 3 0 2 6 3 1 2: 0 0 0 2 4 9 3 3: 0 0 0 0 0 3 1 4: 0 0 0 0 0 0 0 i4mat_row_reduce_test(): i4mat_row_reduce() divides out any common factors in the entries of a row of an I4MAT. Original matrix: Col: 1 2 3 Row 1: 12 88 9 2: 4 8 192 3: -12 99 94 4: 30 18 42 5: 0 4 8 After reducing a row: Col: 1 2 3 Row 1: 12 88 9 2: 4 8 192 3: -12 99 94 4: 30 18 42 5: 0 1 2 After reducing a row: Col: 1 2 3 Row 1: 12 88 9 2: 4 8 192 3: -12 99 94 4: 5 3 7 5: 0 1 2 After reducing a row: Col: 1 2 3 Row 1: 12 88 9 2: 4 8 192 3: -12 99 94 4: 5 3 7 5: 0 1 2 After reducing a row: Col: 1 2 3 Row 1: 12 88 9 2: 1 2 48 3: -12 99 94 4: 5 3 7 5: 0 1 2 After reducing a row: Col: 1 2 3 Row 1: 12 88 9 2: 1 2 48 3: -12 99 94 4: 5 3 7 5: 0 1 2 i4mat_row_swap_test(): i4mat_row_swap() swaps two rows of an I4MAT. Input A: Col: 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 4: 41 42 43 44 5: 51 52 53 54 Swap rows 2 and 5 Modified matrix: Col: 1 2 3 4 Row 1: 11 12 13 14 2: 51 52 53 54 3: 31 32 33 34 4: 41 42 43 44 5: 21 22 23 24 i4mat_rref_test() i4mat_rref() computes the integer reduced row echelon form of an I4MAT. Input A: Col: 1 2 3 4 5 6 7 Row 1: 1 3 0 2 6 3 1 2: -2 -6 0 -2 -8 3 1 3: 3 9 0 0 6 6 2 4: -1 -3 0 1 0 9 3 The pseudo-determinant = 6 IRREF form: Col: 1 2 3 4 5 6 7 Row 1: 1 3 0 0 2 0 0 2: 0 0 0 1 2 0 0 3: 0 0 0 0 0 3 1 4: 0 0 0 0 0 0 0 i4mat_rref_solve_binary_test(): i4mat_rref_solve_binary() seeks binary solutions of an Integer Row-Reduced Echelon Form (IRREF) system A*x=b when A and b contain integer values. The IRREF matrix A: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 1 0 0 0 0 0 1 0 -1 0 2: 0 1 0 0 0 0 0 0 1 0 3: 0 0 1 0 0 0 1 0 -1 0 4: 0 0 0 1 0 0 0 0 1 1 5: 0 0 0 0 1 0 0 0 0 1 6: 0 0 0 0 0 1 -1 0 1 0 7: 0 0 0 0 0 0 0 1 0 -1 8: 0 0 0 0 0 0 0 0 0 0 9: 0 0 0 0 0 0 0 0 0 0 The right hand side b: 1: 0 2: 1 3: 0 4: 1 5: 1 6: 1 7: 0 8: 0 9: 0 Binary solution vectors x: Col: 1 2 3 4 Row 1: 0 0 1 0 2: 1 1 0 0 3: 0 0 1 0 4: 1 0 0 0 5: 1 0 1 1 6: 1 1 0 1 7: 0 0 0 1 8: 0 1 0 0 9: 0 0 1 1 10: 0 1 0 0 i4mat_rref_solve_binary_nz_test(): i4mat_rref_solve_binary_nz() seeks binary solutions of an Integer Row-Reduced Echelon Form (IRREF) system A*x=b which have exactly NZ nonzeros. The IRREF matrix A: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 1 0 0 0 0 0 1 0 -1 0 2: 0 1 0 0 0 0 0 0 1 0 3: 0 0 1 0 0 0 1 0 -1 0 4: 0 0 0 1 0 0 0 0 1 1 5: 0 0 0 0 1 0 0 0 0 1 6: 0 0 0 0 0 1 -1 0 1 0 7: 0 0 0 0 0 0 0 1 0 -1 8: 0 0 0 0 0 0 0 0 0 0 9: 0 0 0 0 0 0 0 0 0 0 The right hand side b: 1: 0 2: 1 3: 0 4: 1 5: 1 6: 1 7: 0 8: 0 9: 0 Only consider binary solutions with exactly 4 nonzeros. Binary solution vectors x: Col: 1 2 3 4 Row 1: 0 1 0 0 2: 1 0 1 0 3: 0 1 0 0 4: 1 0 0 0 5: 1 1 0 1 6: 1 0 1 1 7: 0 0 0 1 8: 0 0 1 0 9: 0 1 0 1 10: 0 0 1 0 i4mat_u_solve_test(): i4mat_u_solve() solves an upper triangular system A*x=b, where A and b contain only integer values. 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 Right hand side b: 1: 45 2: 53 3: 54 4: 40 Integer solution x: 1: 1 2: 2 3: 3 4: 4 Norm of A*x-b = 0 i4mat_u1_inverse_test(): i4mat_u1_inverse() inverts a unit upper triangular matrix. The original matrix: Col: 1 2 3 4 5 6 Row 1: 1 2 0 5 0 75 2: 0 1 0 0 0 0 3: 0 0 1 3 0 0 4: 0 0 0 1 0 6 5: 0 0 0 0 1 4 6: 0 0 0 0 0 1 The inverse matrix: Col: 1 2 3 4 5 6 Row 1: 1 -2 0 -5 0 -45 2: 0 1 0 0 0 0 3: 0 0 1 -3 0 18 4: 0 0 0 1 0 -6 5: 0 0 0 0 1 -4 6: 0 0 0 0 0 1 The product: Col: 1 2 3 4 5 6 Row 1: 1 0 0 0 0 0 2: 0 1 0 0 0 0 3: 0 0 1 0 0 0 4: 0 0 0 1 0 0 5: 0 0 0 0 1 0 6: 0 0 0 0 0 1 i4mat_width_test(): i4mat_width() determines the printing width of an I4MAT. A1: Col: 1 2 3 Row 1: 11 211 3111 2: 12 222 3222 3: 13 233 3333 The printing width of A1 is 4 A2: Col: 1 2 3 Row 1: 10 23 45 2: 42 -1000 63 3: 77 63 90 The printing width of A2 is 5 i4row_max_test(): i4row_max() computes row maximums; The matrix: Col: 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 Row maximums: 1: 4 2: 8 3: 12 i4row_mean_test(): i4row_mean() computes row means; The matrix: Col: 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 Sum, mean: 1 10 2.500000 2 26 6.500000 3 42 10.500000 i4row_min_test(): i4row_min() computes row minimums; The matrix: Col: 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 Row minimums: 1: 1 2: 5 3: 9 i4row_sort_a_test(): i4row_sort_a() sorts the rows; The original matrix: Col: 1 2 3 4 Row 1: 1 0 6 9 2: 0 9 9 10 3: 9 6 8 8 4: 6 10 6 6 5: 10 5 2 10 6: 7 5 7 6 7: 6 8 0 0 8: 8 2 6 1 9: 9 5 7 9 10: 10 9 8 5 The row-sorted matrix: Col: 1 2 3 4 Row 1: 0 9 9 10 2: 1 0 6 9 3: 6 8 0 0 4: 6 10 6 6 5: 7 5 7 6 6: 8 2 6 1 7: 9 5 7 9 8: 9 6 8 8 9: 10 5 2 10 10: 10 9 8 5 i4row_sort_d_test(): i4row_sort_d() sorts the rows; The original matrix: Col: 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 4: 41 42 43 44 5: 51 52 53 54 6: 61 62 63 64 The matrix, permuted by I4MAT_PERM2_UNIFORM: Col: 1 2 3 4 Row 1: 62 61 63 64 2: 32 31 33 34 3: 52 51 53 54 4: 22 21 23 24 5: 42 41 43 44 6: 12 11 13 14 The row-sorted matrix: Col: 1 2 3 4 Row 1: 62 61 63 64 2: 52 51 53 54 3: 42 41 43 44 4: 32 31 33 34 5: 22 21 23 24 6: 12 11 13 14 The element-sorted row-sorted matrix: Col: 1 2 3 4 Row 1: 64 63 62 61 2: 54 53 52 51 3: 44 43 42 41 4: 34 33 32 31 5: 24 23 22 21 6: 14 13 12 11 i4row_sort_rotate_ascending_test(): i4row_sort_rotate_ascending_test() sorts each row of an, integer matrix, with respect to the lexicographic order, using only rotations of vector substrings. Matrix A: 1 2 3 4 3 1 4 2 9 8 0 3 2 9 2 4 8 7 1 9 Matrix A after row sorting: 1 2 3 4 1 4 2 3 0 3 9 8 2 4 2 9 1 9 8 7 i4row_sort2_d_test(): i4row_sort2_d() sorts the elements of the rows. The original matrix: Col: 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 4: 41 42 43 44 5: 51 52 53 54 6: 61 62 63 64 The matrix, permuted by I4MAT_PERM2_UNIFORM: Col: 1 2 3 4 Row 1: 12 13 14 11 2: 32 33 34 31 3: 22 23 24 21 4: 42 43 44 41 5: 52 53 54 51 6: 62 63 64 61 The row-sorted matrix: Col: 1 2 3 4 Row 1: 62 63 64 61 2: 52 53 54 51 3: 42 43 44 41 4: 32 33 34 31 5: 22 23 24 21 6: 12 13 14 11 The element-sorted row-sorted matrix: Col: 1 2 3 4 Row 1: 64 63 62 61 2: 54 53 52 51 3: 44 43 42 41 4: 34 33 32 31 5: 24 23 22 21 6: 14 13 12 11 i4row_sum_test(): i4row_sum() computes row sums; The matrix: Col: 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 Sum, mean: 1 10 2.500000 2 26 6.500000 3 42 10.500000 i4row_swap_test(): i4row_swap() swaps two rows; The 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 new matrix: Col: 1 2 3 4 Row 1: 9 10 11 12 2: 5 6 7 8 3: 1 2 3 4 i4row_variance_test(): i4row_variance() computes row variances; The 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 m = 3 n = 4 i4rows_to_i4mat_test(): i4rows_to_i4mat() allows an I4MAT to be initialized by data stored ROW-WISE in a vector. The data vector: 1: 11 2: 12 3: 13 4: 14 5: 21 6: 22 7: 23 8: 24 9: 31 10: 32 11: 33 12: 34 The data copied into an array: Col: 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 i4vec_add_test(): i4vec_add() adds two I4VEC's; I A B C 1 1 -2 -1 2 -1 -6 -7 3 -8 9 1 4 0 -9 -9 5 7 -8 -1 6 8 -8 0 7 -5 -7 -12 8 -6 3 -3 9 1 2 3 10 3 -9 -6 i4vec_amax_test(): i4vec_amax(): maximum absolute entry; Input vector: 1: 9 2: 5 3: 5 4: -9 5: 8 6: 9 7: 10 8: 8 9: 6 10: 0 Maximum absolute value: 10.000000 i4vec_amax_index_test(): i4vec_amax_index(): index of maximum absolute entry; Input vector: 1: -7 2: -2 3: -8 4: -10 5: 9 6: -4 7: -4 8: -4 9: -1 10: 3 Maximum abs index: 4 i4vec_amin_test(): i4vec_amin(): minimum absolute entry; Input vector: 1: -10 2: 7 3: 1 4: 7 5: -3 6: -1 7: -9 8: -7 9: 3 10: -4 Minimum absolute value: 1.000000 i4vec_amin_index_test(): i4vec_amin_index(): index minimum absolute entry; Input vector: 1: 8 2: -8 3: 10 4: 1 5: 4 6: 10 7: -4 8: -2 9: -1 10: 6 Minimum abs index: 4 i4vec_aminz_test(): i4vec_aminz(): minimum nonzero absolute entry; Input vector: 1: 7 2: -8 3: -7 4: -3 5: -9 6: 0 7: -3 8: -7 9: -6 10: 9 Minimum abs nonzero: 3.000000 i4vec_aminz_index_test(): i4vec_aminz_index(): index of minimum nonzero absolute entry; Input vector: 1: 4 2: -1 3: 9 4: -8 5: 5 6: 5 7: 1 8: -7 9: 2 10: -4 Minimum abs nonzero index: 2 i4vec_ascend_sub_test(): i4vec_ascend_sub() computes a longest ascending subsequence of an integer vector. The vector to be tested: 1: 2 2: 3 3: 9 4: 1 5: 3 6: 1 7: 5 8: 1 9: 9 10: 2 11: 1 12: 4 13: 5 14: 2 A longest ascending subsequence: 1: 1 2: 2 3: 4 4: 5 The vector to be tested: 1: 10 2: 4 3: 3 4: 1 5: 3 6: 1 7: 6 8: 8 9: 7 10: 1 11: 1 12: 8 13: 10 14: 6 A longest ascending subsequence: 1: 1 2: 3 3: 6 4: 7 5: 8 6: 10 The vector to be tested: 1: 2 2: 9 3: 4 4: 3 5: 8 6: 1 7: 1 8: 7 9: 7 10: 6 11: 8 12: 8 13: 8 14: 3 A longest ascending subsequence: 1: 2 2: 3 3: 6 4: 8 The vector to be tested: 1: 7 2: 6 3: 4 4: 1 5: 8 6: 4 7: 7 8: 8 9: 2 10: 2 11: 6 12: 5 13: 9 14: 8 A longest ascending subsequence: 1: 1 2: 4 3: 7 4: 8 5: 9 The vector to be tested: 1: 8 2: 1 3: 1 4: 1 5: 8 6: 10 7: 7 8: 2 9: 8 10: 2 11: 2 12: 7 13: 4 14: 7 A longest ascending subsequence: 1: 1 2: 2 3: 4 4: 7 The vector to be tested: 1: 8 2: 6 3: 8 4: 3 5: 8 6: 10 7: 9 8: 1 9: 4 10: 4 11: 7 12: 6 13: 8 14: 4 A longest ascending subsequence: 1: 1 2: 4 3: 6 4: 8 i4vec_binary_next_test(): i4vec_binary_next() generates the next binary vector. 000 001 010 011 100 101 110 111 i4vec_bracket_test(): i4vec_bracket() finds a pair of entries in a sorted integer array which bracket a value. Sorted array: 1: 2 2: 4 3: 6 4: 8 5: 10 6: 10 7: 14 8: 16 9: 18 10: 20 Search for AVAL = -10 Left = 1 Right = 2 A(LEFT) = 2 A(RIGHT) = 4 Sorted, augmented array: 1: 2 2: -10 3: 4 4: 6 5: 8 6: 10 7: 10 8: 14 9: 16 10: 18 11: 20 Search for AVAL = 2 Left = 2 Right = 3 A(LEFT) = -10 A(RIGHT) = 4 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 10 8: 10 9: 14 10: 16 11: 18 12: 20 Search for AVAL = 9 Left = 6 Right = 7 A(LEFT) = 8 A(RIGHT) = 10 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 14 11: 16 12: 18 13: 20 Search for AVAL = 10 Left = 9 Right = 10 A(LEFT) = 10 A(RIGHT) = 14 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 10 11: 14 12: 16 13: 18 14: 20 Search for AVAL = 20 Left = 13 Right = 14 A(LEFT) = 18 A(RIGHT) = 20 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 10 11: 14 12: 16 13: 18 14: 20 15: 20 Search for AVAL = 24 Left = 14 Right = 15 A(LEFT) = 20 A(RIGHT) = 20 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 10 11: 14 12: 16 13: 18 14: 20 15: 24 16: 20 i4vec_choose_test(): i4vec_choose() computes the generalized binomial coefficient. N: 4 1 9 4 3 K: 3 1 4 3 1 M V1 V2 0 1 1 1 4 4 2 4 4 3 504 504 4 2016 2016 5 6048 6048 i4vec_compare_test(): i4vec_compare() compares the order of two i4vec's. V1 and V2: 1: 1 0 2: 2 5 3: 3 10 compare = 1 V1 and V2: 1: 1 1 2: 2 2 3: 3 3 compare = 0 V1 and V2: 1: 1 1 2: 2 3 3: 3 0 compare = -1 i4vec_concatenate_test(): i4vec_concatenate() concatenates two I4VECs Array 1: 1: 91 2: 31 3: 71 4: 51 5: 31 Array 2: 1: 42 2: 22 3: 12 Array 3 = Array 1 + Array 2: 1: 91 2: 31 3: 71 4: 51 5: 31 6: 42 7: 22 8: 12 i4vec_cum_test(): i4vec_cum(): cumulative sum; Input vector: 1: 8 2: 1 3: 3 4: 2 5: 5 6: 1 7: 4 8: 1 9: 1 10: 8 Cumulative sums: 1: 8 2: 9 3: 12 4: 14 5: 19 6: 20 7: 24 8: 25 9: 26 10: 34 i4vec_cum0_test(): i4vec_cum0(): cumulative sum (zero based); Input vector: 1: 3 2: 6 3: 10 4: 4 5: 7 6: 8 7: 4 8: 7 9: 1 10: 10 0-based cumulative sums: 1: 0 2: 3 3: 9 4: 19 5: 23 6: 30 7: 38 8: 42 9: 49 10: 50 11: 60 i4vec_decrement_test(): i4vec_decrement() decrements an I4VEC. The I4VEC: 1: -3 2: -1 3: 7 4: 2 The I4VEC after decrementing: 1: -4 2: -2 3: 6 4: 1 i4vec_direct_product_test(): i4vec_direct_product() forms the entries of a direct product of a given number of I4VEC factors. J X(1) X(2) X(3) 1 1 50 800 2 2 50 800 3 3 50 800 4 4 50 800 5 1 60 800 6 2 60 800 7 3 60 800 8 4 60 800 9 1 70 800 10 2 70 800 11 3 70 800 12 4 70 800 13 1 50 900 14 2 50 900 15 3 50 900 16 4 50 900 17 1 60 900 18 2 60 900 19 3 60 900 20 4 60 900 21 1 70 900 22 2 70 900 23 3 70 900 24 4 70 900 i4vec_direct_product2_test(): i4vec_direct_product2() forms the entries of a direct product of a given number of I4VEC factors. J W(J) 1 40000 2 80000 3 120000 4 160000 5 48000 6 96000 7 144000 8 192000 9 56000 10 112000 11 168000 12 224000 13 45000 14 90000 15 135000 16 180000 17 54000 18 108000 19 162000 20 216000 21 63000 22 126000 23 189000 24 252000 i4vec_dot_product_test(): i4vec_dot_product() computes the dot product of two I4VECs. The vector A: 1: 8 2: 4 3: 3 4: 0 5: 7 The vector B: 1: 4 2: 4 3: 6 4: 0 5: 3 The dot product is 87 i4vec_eq_test: i4vec_eq() determines if i4vec V1 is equal to V2. V1 and V2: 1: 1 0 2: 2 5 3: 3 10 V1 == V2? = False V1 and V2: 1: 1 1 2: 2 2 3: 3 3 V1 == V2? = True V1 and V2: 1: 1 1 2: 2 3 3: 3 0 V1 == V2? = False i4vec_frac_test(): i4vec_frac(): K-th smallest integer vector entry. The array to search: 1: 16 2: 14 3: 3 4: 3 5: 2 6: 1 7: 9 8: 14 9: 15 10: 11 Fractile Value 1 1 6 11 i4vec_gcd_test i4vec_gcd computes the greatest common divisor of the entries in an I4VEC. The I4VEC: 1: 120120 2: 90090 3: 750750 4: 330330 GCD = 30030 i4vec_ge_test: i4vec_ge determines if i4VEC V1 is greater than or equal to V2. V1 and V2: 1: 1 0 2: 2 5 3: 3 10 V1 => V2? = True V1 and V2: 1: 1 1 2: 2 2 3: 3 3 V1 => V2? = True V1 and V2: 1: 1 1 2: 2 3 3: 3 0 V1 => V2? = True i4vec_gt_test: i4vec_gt determines if i4vec V1 is greater than V2. V1 and V2: 1: 1 0 2: 2 5 3: 3 10 V1 > V2? = True V1 and V2: 1: 1 1 2: 2 2 3: 3 3 V1 > V2? = False V1 and V2: 1: 1 1 2: 2 3 3: 3 0 V1 > V2? = False i4vec_heap_a_test(): i4vec_heap_a() puts into ascending heap form. Unsorted array: 1: 1 2: 6 3: 1 4: 1 5: 1 6: 1 7: 1 8: 2 9: 3 10: 3 Ascending heap form: 1: 1 2: 1 3: 1 4: 2 5: 1 6: 1 7: 1 8: 6 9: 3 10: 3 i4vec_heap_d_test(): i4vec_heap_d() puts into descending heap form. Unsorted array: 1: 2 2: 2 3: 9 4: 7 5: 6 6: 2 7: 2 8: 0 9: 10 10: 7 Descending heap form: 1: 10 2: 7 3: 9 4: 2 5: 7 6: 2 7: 2 8: 0 9: 2 10: 6 i4vec_heap_d_extract_test(): i4vec_heap_d_extract() extracts the maximum value; Inserting value 6 Current maximum value is 6 Inserting value 3 Current maximum value is 6 Inserting value 1 Current maximum value is 6 Inserting value 6 Current maximum value is 6 Inserting value 10 Current maximum value is 10 Inserting value 1 Current maximum value is 10 Inserting value 2 Current maximum value is 10 Inserting value 4 Current maximum value is 10 Inserting value 0 Current maximum value is 10 Inserting value 7 Current maximum value is 10 Current heap as a vector: 1: 10 2: 7 3: 2 4: 4 5: 6 6: 1 7: 1 8: 3 9: 0 10: 6 Now extract the maximum several times. Extracting maximum element = 10 Extracting maximum element = 7 Extracting maximum element = 6 Extracting maximum element = 6 Extracting maximum element = 4 Current heap as a vector: 1: 3 2: 2 3: 1 4: 1 5: 0 i4vec_heap_d_insert_test(): i4vec_heap_d_insert() inserts a value into the heap. Inserting value 4 Current maximum value is 4 Inserting value 10 Current maximum value is 10 Inserting value 4 Current maximum value is 10 Inserting value 6 Current maximum value is 10 Inserting value 1 Current maximum value is 10 Inserting value 4 Current maximum value is 10 Inserting value 1 Current maximum value is 10 Inserting value 8 Current maximum value is 10 Inserting value 9 Current maximum value is 10 Inserting value 3 Current maximum value is 10 Current heap as a vector: 1: 10 2: 9 3: 4 4: 8 5: 3 6: 4 7: 1 8: 4 9: 6 10: 1 i4vec_heap_d_max_test(): i4vec_heap_d_max() reports the maximum value. Inserting value 7 Current maximum value is 7 Inserting value 3 Current maximum value is 7 Inserting value 5 Current maximum value is 7 Inserting value 9 Current maximum value is 9 Inserting value 6 Current maximum value is 9 Inserting value 3 Current maximum value is 9 Inserting value 3 Current maximum value is 9 Inserting value 4 Current maximum value is 9 Inserting value 4 Current maximum value is 9 Inserting value 3 Current maximum value is 9 Current heap as a vector: 1: 9 2: 7 3: 5 4: 4 5: 6 6: 3 7: 3 8: 3 9: 4 10: 3 i4vec_histogram_test(): i4vec_histogram() histograms an integer vector. Histogram of data from 0 to 20 0 34 1 39 2 32 3 40 4 37 5 35 6 34 7 28 8 35 9 41 10 46 11 53 12 25 13 39 14 45 15 42 16 38 17 38 18 47 19 41 20 31 i4vec_identity_row_test(): i4vec_identity_row() returns a row of the identity matrix. 0: 0 0 0 0 0 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 i4vec_increment_test(): i4vec_increment() increments an I4VEC. The I4VEC: 1: 1 2: -5 3: 6 4: -3 The I4VEC after incrementing: 1: 2 2: -4 3: 7 4: -2 i4vec_index_test(): i4vec_index(): first index of given value; Input vector: 1: -7 2: 2 3: -5 4: -4 5: -2 6: -2 7: -2 8: 2 9: -7 10: -7 Index of first occurrence of -2 is 5 Index of first occurrence of -1 is -1 i4vec_index_delete_all_test(): i4vec_index_delete_all() deletes all copies of a particular value. 1 6 16 4 15 14 17 17 6 6 10 6 17 17 11 5 14 4 9 8 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 3 8 1 2 6 7 4 3 20 1 4 4 18 6 5 5 4 16 6 6 12 4 6 7 14 15 6 8 11 14 6 9 2 17 7 10 23 17 7 11 1 6 8 12 22 6 8 13 24 10 8 14 21 6 9 15 13 17 10 16 17 17 11 17 8 11 14 18 19 5 14 19 7 14 15 20 5 4 16 21 9 9 17 22 10 8 17 23 15 7 17 24 16 8 17 Call i4vec_index_delete_all() to delete values of 7: Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 2 8 1 2 5 1 4 3 19 6 4 4 17 16 5 5 3 4 6 6 11 15 6 7 13 14 6 8 10 17 6 9 1 17 8 10 21 6 8 11 22 6 8 12 20 10 9 13 12 6 10 14 16 17 11 15 7 17 14 16 18 11 14 17 6 5 15 18 4 14 16 19 8 4 17 20 9 9 17 21 14 8 17 22 15 8 17 i4vec_index_delete_dupes_test(): i4vec_index_delete_dupes() deletes duplicates. 11 20 15 20 4 11 1 15 12 18 20 19 8 0 11 4 4 6 2 15 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 16 8 0 2 9 7 1 3 21 11 2 4 7 20 4 5 19 15 4 6 18 20 4 7 20 4 6 8 2 11 7 9 23 1 7 10 1 15 8 11 24 12 8 12 15 18 8 13 3 20 11 14 8 19 11 15 17 8 11 16 11 0 12 17 5 11 15 18 10 4 15 19 22 4 15 20 12 6 18 21 14 2 19 22 4 15 20 23 6 7 20 24 13 8 20 Call I4VEC_INDEX_DELETE_ONE to delete a value of 8: Call I4VEC_INDEX_DELETE_ALL to delete values of 7: Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 14 8 0 2 8 11 1 3 19 20 2 4 6 15 4 5 17 20 4 6 16 4 4 7 18 11 6 8 1 1 8 9 21 15 8 10 2 12 11 11 7 18 11 12 15 20 11 13 10 19 12 14 4 0 15 15 9 11 15 16 20 4 15 17 11 4 18 18 13 6 19 19 3 2 20 20 5 15 20 21 12 8 20 Call I4VEC_INDEX_DELETE_DUPES to delete duplicates: Indexed list of unique entries: I INDX(I) X(I) 1 1 0 2 2 1 3 3 2 4 4 4 5 5 6 6 6 8 7 7 11 8 8 12 9 9 15 10 10 18 11 11 19 12 12 20 i4vec_index_delete_one_test(): i4vec_index_delete_one() deletes one copies of a particular value. 15 11 7 17 11 20 18 7 11 7 13 16 15 2 17 0 8 15 16 7 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 18 8 0 2 16 7 2 3 2 15 7 4 12 11 7 5 10 7 7 6 5 17 7 7 23 11 7 8 22 20 7 9 1 18 8 10 24 7 8 11 19 11 8 12 4 7 11 13 11 13 11 14 7 16 11 15 13 15 13 16 3 2 15 17 15 17 15 18 20 0 15 19 14 8 16 20 21 15 16 21 6 16 17 22 17 7 17 23 9 7 18 24 8 8 20 Call I4VEC_INDEX_DELETE_ONE to delete a value of 8: Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 17 7 0 2 15 15 2 3 1 11 7 4 11 7 7 5 9 17 7 6 4 11 7 7 22 20 7 8 21 18 7 9 23 7 8 10 18 11 8 11 3 7 11 12 10 13 11 13 6 16 11 14 12 15 13 15 2 2 15 16 14 17 15 17 19 0 15 18 13 8 16 19 20 15 16 20 5 16 17 21 16 7 17 22 8 7 18 23 7 8 20 i4vec_index_insert_test(): i4vec_index_insert() inserts values into an index sorted array of integers. 15 18 5 2 4 7 6 19 1 12 3 17 3 10 20 7 0 4 8 7 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 19 8 0 2 11 7 1 3 6 15 2 4 13 18 3 5 15 5 3 6 7 2 4 7 20 4 4 8 5 7 5 9 9 6 6 10 2 19 7 11 8 1 7 12 23 12 7 13 22 3 7 14 18 17 7 15 1 3 8 16 24 10 8 17 21 20 8 18 16 7 10 19 12 0 12 20 3 4 15 21 14 8 17 22 4 7 18 23 10 7 19 24 17 8 20 i4vec_index_insert_unique_test(): i4vec_index_insert_unique() inserts unique values into an index sorted array. Generate some random values: 4 19 14 20 9 19 0 12 16 4 19 16 17 12 16 6 4 6 12 17 Indexed list of unique entries: I INDX(I) X(I) X(INDX(I)) 1 6 4 0 2 1 19 4 3 10 14 6 4 5 20 9 5 7 9 12 6 3 0 14 7 8 12 16 8 9 16 17 9 2 17 19 10 4 6 20 i4vec_index_order_test(): i4vec_index_order() sorts an index sorted array. Generate some random values: 6 8 18 12 20 4 17 14 5 9 8 12 16 2 17 17 7 9 12 14 Indexed list of unique entries: I INDX(I) X(I) X(INDX(I)) 1 12 6 2 2 6 8 4 3 9 18 5 4 1 12 6 5 13 20 7 6 2 4 8 7 10 17 9 8 4 14 12 9 8 5 14 10 11 9 16 11 7 16 17 12 3 2 18 13 5 7 20 Now call I4VEC_INDEX_ORDER to carry out the sorting: X: 1: 2 2: 4 3: 5 4: 6 5: 7 6: 8 7: 9 8: 12 9: 14 10: 16 11: 17 12: 18 13: 20 i4vec_index_search_test(): i4vec_index_search() searches for an entry with a given value. Generate some random values: Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 9 15 1 2 13 8 3 3 7 9 5 4 2 20 8 5 3 12 9 6 10 17 10 7 5 5 12 8 8 13 13 9 1 1 15 10 12 10 16 11 6 18 17 12 11 16 18 13 4 3 20 Results of search for given XVAL: XVAL Less Equal More 0 0 0 1 1 0 1 2 2 1 0 2 3 1 2 3 4 2 0 3 5 2 3 4 6 3 0 4 7 3 0 4 8 3 4 5 9 4 5 6 10 5 6 7 11 6 0 7 12 6 7 8 13 7 8 9 14 8 0 9 15 8 9 10 16 9 10 11 17 10 11 12 18 11 12 13 19 12 0 13 20 12 13 14 i4vec_indexed_heap_d_test(): i4vec_indexed_heap_d() creates a descending heap from an indexed vector. 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 descending heap: 1 119 2 111 3 117 4 105 5 109 6 113 7 115 8 103 9 101 10 107 i4vec_indexed_heap_d_extract_test(): i4vec_indexed_heap_d_extract() extracts the maximum value; 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 2 2 3 8 4 14 5 5 The index vector after heaping: 1: 14 2: 9 3: 8 4: 2 5: 5 A(INDX) after heaping: 1 14 2 9 3 8 4 2 5 5 Inserting value 7 Current maximum is 14 Inserting value 15 Current maximum is 15 Inserting value 1 Current maximum is 15 Inserting value 19 Current maximum is 19 Inserting value 20 Current maximum is 20 The data vector after insertions: 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 2 19 3 14 4 9 5 15 6 7 7 8 8 1 9 2 10 5 Now extract the maximum several times. Extracting maximum element A(20) = 20 Extracting maximum element A(19) = 19 Extracting maximum element A(15) = 15 Extracting maximum element A(14) = 14 Extracting maximum element A(9) = 9 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 2 5 3 7 4 2 5 1 i4vec_indexed_heap_d_insert_test(): i4vec_indexed_heap_d_insert() inserts a value into the heap. 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 2 2 3 8 4 14 5 5 The index vector after heaping: 1: 14 2: 9 3: 8 4: 2 5: 5 A(INDX) after heaping: 1 14 2 9 3 8 4 2 5 5 Inserting value 7 Current maximum is 14 Inserting value 15 Current maximum is 15 Inserting value 1 Current maximum is 15 Inserting value 19 Current maximum is 19 Inserting value 20 Current maximum is 20 The data vector after insertions: 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 2 19 3 14 4 9 5 15 6 7 7 8 8 1 9 2 10 5 i4vec_indexed_heap_d_max_test(): i4vec_indexed_heap_d_max() reports the maximum value. 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 2 2 3 8 4 14 5 5 The index vector after heaping: 1: 14 2: 9 3: 8 4: 2 5: 5 A(INDX) after heaping: 1 14 2 9 3 8 4 2 5 5 Inserting value 7 Current maximum is 14 Inserting value 15 Current maximum is 15 Inserting value 1 Current maximum is 15 Inserting value 19 Current maximum is 19 Inserting value 20 Current maximum is 20 The data vector after insertions: 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 2 19 3 14 4 9 5 15 6 7 7 8 8 1 9 2 10 5 i4vec_indicator0_test(): i4vec_indicator0() returns an indicator vector. The "indicator0" vector: 1: 0 2: 1 3: 2 4: 3 5: 4 6: 5 7: 6 8: 7 9: 8 10: 9 i4vec_indicator1_test(): i4vec_indicator1() returns an indicator vector. The "indicator1" vector: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 i4vec_insert_test(): i4vec_insert() inserts a value into a vector. Sorted array: 1: 2 2: 4 3: 6 4: 8 5: 10 6: 10 7: 14 8: 16 9: 18 10: 20 Search for AVAL = -10 Left = 1 Right = 2 A(LEFT) = 2 A(RIGHT) = 4 Sorted, augmented array: 1: 2 2: -10 3: 4 4: 6 5: 8 6: 10 7: 10 8: 14 9: 16 10: 18 11: 20 Search for AVAL = 2 Left = 2 Right = 3 A(LEFT) = -10 A(RIGHT) = 4 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 10 8: 10 9: 14 10: 16 11: 18 12: 20 Search for AVAL = 9 Left = 6 Right = 7 A(LEFT) = 8 A(RIGHT) = 10 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 14 11: 16 12: 18 13: 20 Search for AVAL = 10 Left = 9 Right = 10 A(LEFT) = 10 A(RIGHT) = 14 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 10 11: 14 12: 16 13: 18 14: 20 Search for AVAL = 20 Left = 13 Right = 14 A(LEFT) = 18 A(RIGHT) = 20 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 10 11: 14 12: 16 13: 18 14: 20 15: 20 Search for AVAL = 24 Left = 14 Right = 15 A(LEFT) = 20 A(RIGHT) = 20 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 10 11: 14 12: 16 13: 18 14: 20 15: 24 16: 20 i4vec_is_ascending_test(): i4vec_is_ascending() determines if an integer vector ascends. Test vector: 1: 1 2: 3 3: 2 4: 4 I4VEC_IS_ASCENDING = 0 Test vector: 1: 2 2: 2 3: 2 4: 2 I4VEC_IS_ASCENDING = 1 Test vector: 1: 1 2: 2 3: 2 4: 4 I4VEC_IS_ASCENDING = 1 Test vector: 1: 1 2: 2 3: 3 4: 4 I4VEC_IS_ASCENDING = 1 Test vector: 1: 4 2: 4 3: 3 4: 1 I4VEC_IS_ASCENDING = 0 Test vector: 1: 9 2: 7 3: 3 4: 0 I4VEC_IS_ASCENDING = 0 i4vec_is_binary_test(): i4vec_is_binary() is TRUE if an I4VEC only contains 0 or 1 entries. X: 0 0 0 X is binary X: 1 0 1 X is binary X: 0 2 1 X is NOT binary. i4vec_is_coprime_test(): i4vec_is_coprime() determines if a vector of integers is pairwise prime. Row Vector Coprime? 1 3 2 4 False 2 2 2 2 False 5 7 12 29 True 1 13 1 11 True 1 4 9 16 False 6 35 13 77 False i4vec_is_descending_test(): i4vec_is_descending() determines if an integer vector descends. Test vector: 1: 1 2: 3 3: 2 4: 4 I4VEC_IS_DESCENDING = 0 Test vector: 1: 2 2: 2 3: 2 4: 2 I4VEC_IS_DESCENDING = 1 Test vector: 1: 1 2: 2 3: 2 4: 4 I4VEC_IS_DESCENDING = 0 Test vector: 1: 1 2: 2 3: 3 4: 4 I4VEC_IS_DESCENDING = 0 Test vector: 1: 4 2: 4 3: 3 4: 1 I4VEC_IS_DESCENDING = 1 Test vector: 1: 9 2: 7 3: 3 4: 0 I4VEC_IS_DESCENDING = 1 i4vec_is_integer_test(): i4vec_is_integer() is TRUE if every entry of an I4VEC is an integer. Example 1: Obviously integer: a = 1 2 3 A is an integer vector. Example 2: Obviously NOT integer: a = 4.0000 5.0000 6.5000 A is NOT an integer vector. Example 3: Not Integer, Not obvious: a = 1.0000 2.0000 3.0000 A is NOT an integer vector. Example 4: Not Integer, Not obvious: a = 1.0e+08 * 0.0000 0.0000 3.0000 A is NOT an integer vector. i4vec_is_permutation_test(): i4vec_is_permutation() is TRUE if an I4VEC represents a permutation. Example 1: Obvious: a = 1 2 3 A is a permutation. Example 2: Obviously NOT: a = 4.0000 5.0000 6.5000 A is NOT a permutation. Example 3: Something is missing: a = 1 8 6 3 4 2 7 A is NOT a permutation. Example 4: Must be 1-based, not 0!: a = 2 0 1 A is NOT a permutation. Example 5: An array is OK: a = 3 6 2 5 1 4 A is a permutation. i4vec_lcm_test() i4vec_lcm() computes the least common multiple of the entries in an I4VEC. The I4VEC: 1: 120120 2: 90090 3: 750750 4: 330330 LCM = 99099000 i4vec_le_test(): i4vec_le() determines if V1 is less than or equal to V2, using lexical order, for the i4vec data type. V1 and V2: 1: 1 0 2: 2 5 3: 3 10 V1 <= V2? = False V1 and V2: 1: 1 1 2: 2 2 3: 3 3 V1 <= V2? = True V1 and V2: 1: 1 1 2: 2 3 3: 3 0 V1 <= V2? = True i4vec_lt_test(): i4vec_lt() determines if V1 is less than V2, using lexical order, for the i4vec data type. V1 and V2: 1: 1 0 2: 2 5 3: 3 10 V1 < V2? = False V1 and V2: 1: 1 1 2: 2 2 3: 3 3 V1 < V2? = False V1 and V2: 1: 1 1 2: 2 3 3: 3 0 V1 < V2? = True i4vec_max_test(): i4vec_max(): maximum entry; Input vector: 1: 19 2: 8 3: 14 4: 26 5: 6 6: 10 7: 15 8: 11 9: 24 10: 30 Maximum: 30 i4vec_max_index_test(): i4vec_max_index(): a maximal index; Input vector: 1: -7 2: -6 3: 4 4: -3 5: 10 6: 10 7: 3 8: 8 9: -2 10: 3 Maximum index: 5 i4vec_max_index_last_test(): i4vec_max_index_last(): last maximal index; Input vector: 1: 10 2: 1 3: 9 4: 5 5: 0 6: 3 7: 8 8: -6 9: -2 10: 10 Last maximum index: 10 i4vec_max_last_test(): i4vec_max_last() identifies the largest element in an I4VEC, and moves it to the final entry. Input vector: 1: 13 2: 20 3: 28 4: 30 5: 20 6: 4 7: 2 8: 19 9: 18 10: 29 Maximum: 30 Output vector: 1: 13 2: 20 3: 28 4: 20 5: 4 6: 2 7: 19 8: 18 9: 29 10: 30 i4vec_mean_test(): i4vec_mean(): mean value; Input vector: 1: 5 2: 3 3: 0 4: -5 5: 10 6: 1 7: -10 8: 4 9: 0 10: -9 Mean: -0.100000 i4vec_median_test(): i4vec_median(): median value; Input vector: 1: 8 2: -4 3: -6 4: -8 5: -4 6: -6 7: 3 8: -9 9: -5 10: -5 Median: -5 i4vec_merge_a_test(): i4vec_merge_a() merges two ascending sorted integer arrays; Input vector A1: 1: 0 2: 1 3: 4 4: 5 5: 6 6: 8 7: 8 8: 9 9: 9 10: 10 Input vector A2: 1: 0 2: 2 3: 3 4: 4 5: 4 6: 5 7: 6 8: 6 9: 6 10: 6 Merged vector A3: 1: 0 2: 1 3: 2 4: 3 5: 4 6: 5 7: 6 8: 8 9: 9 10: 10 i4vec_min_test(): i4vec_min(): minimum entry of an I4VEC. Input vector: 1: 4 2: 14 3: 14 4: 17 5: 25 6: 22 7: 27 8: 2 9: 7 10: 14 Minimum: 2 i4vec_min_index_test(): i4vec_min_index(): a minimal index; Input vector: 1: 10 2: 6 3: -1 4: -3 5: -9 6: 5 7: 0 8: -6 9: -2 10: -7 Minimum index: 5 i4vec_ne_test(): i4vec_ne() determines if i4vec V1 is not equal to V2. V1 and V2: 1: 1 0 2: 2 5 3: 3 10 V1 =/= V2? = True V1 and V2: 1: 1 1 2: 2 2 3: 3 3 V1 =/= V2? = False V1 and V2: 1: 1 1 2: 2 3 3: 3 0 V1 =/= V2? = True i4vec_nonzero_count_test(): i4vec_nonzero_count(): number of nonzeroes; Input vector: 1: 5 2: -3 3: 9 4: -10 5: 7 6: 3 7: 1 8: 3 9: 5 10: -9 Number of nonzeroes: 10 i4vec_nonzero_first_test(): i4vec_nonzero_first() left shifts the nonzero entries of an I4VEC so they appear first. ----------Before-------------- ----------After--------------- 2 -1 0 -1 2 -1 1 1 1 2 2 -1 -1 2 -1 1 1 1 2 0 -1 2 1 1 -1 1 1 2 0 -1 -1 2 1 1 -1 1 1 2 -1 0 -1 1 2 1 0 2 1 2 -1 -1 -1 1 2 1 2 1 2 -1 -1 0 2 2 2 0 -1 2 2 0 -1 0 2 2 2 -1 2 2 -1 0 0 0 2 2 1 1 0 1 2 0 0 0 2 2 1 1 1 2 0 0 0 0 The value NZ counts the nonzeros, and the vector INDX indicates the original positions: Original vector: 0 1 2 2 1 0 1 -1 -1 -1 Number of nonzeros NZ = 8 Shifted vector: 1 2 2 1 1 -1 -1 -1 0 0 Index vector: 2 3 4 5 7 8 9 10 1 6 i4vec_order_type_test(): i4vec_order_type() classifies an integer vector as -1: no order 0: all equal; 1: ascending; 2: strictly ascending; 3: descending; 4: strictly descending. The following vector has order type -1 1 1 2 3 3 2 4 4 The following vector has order type 0 1 2 2 2 3 2 4 2 The following vector has order type 1 1 1 2 2 3 2 4 4 The following vector has order type 2 1 1 2 2 3 3 4 4 The following vector has order type 3 1 4 2 4 3 3 4 1 The following vector has order type 4 1 9 2 7 3 3 4 0 i4vec_part_test(): i4vec_part() partitions an integer. NVAL = 17 Partitioned: 1: 4 2: 4 3: 3 4: 3 5: 3 NVAL = -49 Partitioned: 1: -10 2: -10 3: -10 4: -10 5: -9 i4vec_part_quick_a_test(): i4vec_part_quick_a() reorders an integer vector as part of a quick sort. Before rearrangement: 1: 1 2: 7 3: 0 4: 10 5: 9 6: 12 7: 6 8: 8 9: 11 10: 7 11: 3 12: 12 Rearranged array Left index = 1 Key index = 2 Right index = 3 Left half: 1: 0 Key: 1: 1 Right half: 1: 10 2: 9 3: 12 4: 6 5: 8 6: 11 7: 7 8: 3 9: 12 10: 7 i4vec_permute_test(): i4vec_permute() reorders an integer vector according to a given permutation. A, before rearrangement: 1: 0 2: 4 3: 12 4: 4 5: 4 6: 1 7: 11 8: 1 9: 4 10: 11 11: 6 12: 7 Permutation vector P: 1: 7 2: 9 3: 3 4: 8 5: 5 6: 11 7: 2 8: 12 9: 1 10: 6 11: 4 12: 10 A, after rearrangement: 1: 11 2: 4 3: 12 4: 1 5: 4 6: 6 7: 4 8: 7 9: 0 10: 1 11: 4 12: 11 i4vec_permute_uniform_test(): i4vec_permute_uniform() randomly reorders an I4VEC. A, before rearrangement: 1: 101 2: 102 3: 103 4: 104 5: 105 6: 106 7: 107 8: 108 9: 109 10: 110 11: 111 12: 112 A, after rearrangement: 1: 101 2: 102 3: 103 4: 110 5: 109 6: 106 7: 111 8: 107 9: 105 10: 104 11: 108 12: 112 i4vec_red_test(): i4vec_red() divides out any common factors in the entries of an I4VEC. Apply I4VEC_RED to each row of this matrix: Col: 1 2 3 Row 1: 12 88 9 2: 4 8 192 3: -12 88 94 4: 30 18 42 5: 0 4 8 Reduced matrix: Col: 1 2 3 Row 1: 12 88 9 2: 1 2 48 3: -6 44 47 4: 5 3 7 5: 0 1 2 i4vec_reverse_test(): i4vec_reverse() reverses a list of integers. Original vector: 1: 24 2: 2 3: 7 4: 7 5: 3 6: 26 7: 21 8: 22 9: 20 10: 16 Reversed: 1: 16 2: 20 3: 22 4: 21 5: 26 6: 3 7: 7 8: 7 9: 2 10: 24 i4vec_rotate_test(): i4vec_rotate() rotates an I4VEC by M positions. The vector: 1 2 3 4 5 6 7 8 9 10 M = -3: 8 9 10 1 2 3 4 5 6 7 M = -2: 9 10 1 2 3 4 5 6 7 8 M = -1: 10 1 2 3 4 5 6 7 8 9 M = 0: 1 2 3 4 5 6 7 8 9 10 M = 1: 2 3 4 5 6 7 8 9 10 1 M = 2: 3 4 5 6 7 8 9 10 1 2 M = 3: 4 5 6 7 8 9 10 1 2 3 M = 4: 5 6 7 8 9 10 1 2 3 4 M = 5: 6 7 8 9 10 1 2 3 4 5 i4vec_run_count_test(): i4vec_run_count() counts runs in an I4VEC Run Count Sequence 12 0 1 0 0 0 1 1 0 0 1 0 1 1 0 0 1 1 1 0 1 12 0 1 1 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 1 1 7 1 0 0 1 1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 1 12 0 0 0 0 1 1 0 1 0 1 1 1 0 1 0 0 1 1 0 1 12 1 0 1 0 0 0 1 0 0 1 0 1 1 1 1 0 0 1 1 0 12 1 1 1 1 1 1 0 0 1 0 1 0 1 0 0 1 0 1 1 0 11 0 1 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 1 1 0 8 1 1 1 1 1 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 15 0 1 0 1 0 1 1 0 1 0 1 1 0 0 1 1 0 0 1 0 10 1 1 0 1 1 1 0 0 1 1 1 1 0 1 1 1 1 0 1 0 i4vec_search_binary_a_test(): i4vec_search_binary_a() searches an ascending sorted vector. Ascending sorted array: 1: 0 2: 1 3: 1 4: 2 5: 3 6: 4 7: 5 8: 6 9: 7 10: 8 Now search for an instance of the value 5 The value occurs at index = 7 i4vec_search_binary_d_test(): i4vec_search_binary_d() searches a descending sorted vector. Descending sorted array: 1: 8 2: 7 3: 6 4: 5 5: 4 6: 3 7: 2 8: 1 9: 1 10: 0 Now search for an instance of the value 5 The value occurs at index = 4 i4vec_sort_bubble_a_test(): i4vec_sort_bubble_a() ascending sorts, Unsorted: 1: 34 2: 54 3: 51 4: 54 5: 57 6: 49 7: 0 8: 0 9: 5 10: 15 11: 1 12: 25 13: 20 14: 33 15: 56 16: 18 17: 20 18: 52 19: 20 20: 8 Ascending sorted: 1: 0 2: 0 3: 1 4: 5 5: 8 6: 15 7: 18 8: 20 9: 20 10: 20 11: 25 12: 33 13: 34 14: 49 15: 51 16: 52 17: 54 18: 54 19: 56 20: 57 i4vec_sort_heap_a_test(): i4vec_sort_heap_a() ascending sorts, Unsorted: 1: 30 2: 52 3: 23 4: 42 5: 38 6: 27 7: 28 8: 57 9: 5 10: 17 11: 27 12: 35 13: 53 14: 28 15: 26 16: 45 17: 28 18: 52 19: 28 20: 30 Ascending sorted: 1: 5 2: 17 3: 23 4: 26 5: 27 6: 27 7: 28 8: 28 9: 28 10: 28 11: 30 12: 30 13: 35 14: 38 15: 42 16: 45 17: 52 18: 52 19: 53 20: 57 i4vec_sort_heap_d_test(): i4vec_sort_heap_d() descending sorts. Unsorted: 1: 29 2: 13 3: 5 4: 4 5: 54 6: 14 7: 52 8: 43 9: 53 10: 57 11: 8 12: 24 13: 59 14: 39 15: 54 16: 29 17: 0 18: 37 19: 14 20: 32 Descending sorted: 1: 59 2: 57 3: 54 4: 54 5: 53 6: 52 7: 43 8: 39 9: 37 10: 32 11: 29 12: 29 13: 24 14: 14 15: 14 16: 13 17: 8 18: 5 19: 4 20: 0 i4vec_sort_heap_index_a_test(): i4vec_sort_heap_index_a() creates an ascending sort index for an I4VEC. Unsorted array: 1: 44 2: 37 3: 35 4: 26 5: 14 6: 26 7: 0 8: 37 9: 58 10: 5 11: 2 12: 54 13: 15 14: 0 15: 49 16: 8 17: 53 18: 5 19: 21 20: 36 Sort vector INDX: 1: 14 2: 7 3: 11 4: 18 5: 10 6: 16 7: 5 8: 13 9: 19 10: 6 11: 4 12: 3 13: 20 14: 8 15: 2 16: 1 17: 15 18: 17 19: 12 20: 9 I, INDX(I), A(INDX(I)) 1 14 0 2 7 0 3 11 2 4 18 5 5 10 5 6 16 8 7 5 14 8 13 15 9 19 21 10 6 26 11 4 26 12 3 35 13 20 36 14 8 37 15 2 37 16 1 44 17 15 49 18 17 53 19 12 54 20 9 58 i4vec_sort_heap_index_d_test(): i4vec_sort_heap_index_d() creates a descending sort index for an integer array. Unsorted array: 1: 35 2: 40 3: 39 4: 26 5: 8 6: 45 7: 14 8: 39 9: 52 10: 5 11: 59 12: 1 13: 50 14: 50 15: 3 16: 33 17: 57 18: 19 19: 49 20: 36 Sort vector INDX: 1: 11 2: 17 3: 9 4: 14 5: 13 6: 19 7: 6 8: 2 9: 3 10: 8 11: 20 12: 1 13: 16 14: 4 15: 18 16: 7 17: 5 18: 10 19: 15 20: 12 I, INDX(I), A(INDX(I)) 1 11 59 2 17 57 3 9 52 4 14 50 5 13 50 6 19 49 7 6 45 8 2 40 9 3 39 10 8 39 11 20 36 12 1 35 13 16 33 14 4 26 15 18 19 16 7 14 17 5 8 18 10 5 19 15 3 20 12 1 i4vec_sort_insert_a_test(): i4vec_sort_insert_a() sorts an integer array. Unsorted array: 1: 8 2: 8 3: 0 4: 3 5: 7 6: 5 7: 10 8: 8 9: 6 10: 3 Sorted array: 1: 0 2: 3 3: 3 4: 5 5: 6 6: 7 7: 8 8: 8 9: 8 10: 10 i4vec_sort_insert_d_test(): i4vec_sort_insert_d() descending sorts an I4VEC. Unsorted array: 1: 2 2: 9 3: 4 4: 8 5: 1 6: 9 7: 0 8: 9 9: 9 10: 5 Descending sorted array: 1: 9 2: 9 3: 9 4: 9 5: 8 6: 5 7: 4 8: 2 9: 1 10: 0 i4vec_sort_quick_a_test(): i4vec_sort_quick_a() quick sorts an integer vector. Unsorted array: 1: 7 2: 10 3: 43 4: 50 5: 2 6: 46 7: 58 8: 20 9: 38 10: 20 11: 13 12: 47 13: 44 14: 17 15: 35 16: 25 17: 5 18: 1 19: 29 20: 16 Sorted array: 1: 1 2: 2 3: 5 4: 7 5: 10 6: 13 7: 16 8: 17 9: 20 10: 20 11: 25 12: 29 13: 35 14: 38 15: 43 16: 44 17: 46 18: 47 19: 50 20: 58 i4vec_sort_shell_a_test(): i4vec_sort_shell_a() sorts an integer vector using Shell's sort. Unsorted array: 1: 20 2: 17 3: 10 4: 24 5: 42 6: 12 7: 40 8: 27 9: 26 10: 10 11: 11 12: 37 13: 16 14: 34 15: 57 16: 43 17: 41 18: 58 19: 47 20: 37 Sorted array: 1: 10 2: 10 3: 11 4: 12 5: 16 6: 17 7: 20 8: 24 9: 26 10: 27 11: 34 12: 37 13: 37 14: 40 15: 41 16: 42 17: 43 18: 47 19: 57 20: 58 i4vec_sorted_undex_test(): i4vec_sorted_undex() produces index vectors which create a sorted list of the unique elements of a sorted I4VEC, 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 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 2 4 22 3 6 33 4 8 55 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 2 4 22 3 6 33 4 8 55 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 11 2 1 11 11 3 1 11 11 4 2 22 22 5 2 22 22 6 3 33 33 7 3 33 33 8 4 55 55 9 4 55 55 i4vec_sorted_unique_test(): i4vec_sorted_unique() finds unique entries in a sorted array. Input vector: 1: 0 2: 1 3: 4 4: 5 5: 7 6: 7 7: 8 8: 8 9: 8 10: 9 11: 9 12: 9 13: 11 14: 14 15: 16 16: 17 17: 17 18: 19 19: 20 20: 20 Unique entries: 1: 0 2: 1 3: 4 4: 5 5: 7 6: 8 7: 9 8: 11 9: 14 10: 16 11: 17 12: 19 13: 20 i4vec_sorted_unique_count_test(): i4vec_sorted_unique_count() counts unique entries in a sorted array. Input vector: 1: 0 2: 1 3: 2 4: 3 5: 7 6: 9 7: 10 8: 11 9: 11 10: 11 11: 13 12: 13 13: 15 14: 17 15: 18 16: 19 17: 19 18: 20 19: 20 20: 20 Number of unique entries is i4vec_sorted_unique_hist_test(): i4vec_sorted_unique_hist() is given a sorted array of integers, and returns the number of unique values, the unique values, and their frequency. The sorted vector: 1: 0 2: 0 3: 0 4: 0 5: 0 6: 0 7: 0 8: 0 9: 0 10: 0 11: 0 12: 1 13: 4 14: 5 15: 5 16: 7 17: 9 18: 9 19: 9 20: 12 21: 14 22: 14 23: 16 24: 18 25: 18 26: 18 27: 20 28: 20 29: 21 30: 25 31: 25 32: 27 33: 28 34: 30 35: 30 36: 30 37: 30 38: 32 39: 36 40: 36 41: 36 42: 45 43: 45 44: 45 45: 54 46: 63 47: 63 48: 63 49: 72 50: 100 Unique values and frequencies: 1: 0 11 2: 1 1 3: 4 1 4: 5 2 5: 7 1 6: 9 3 7: 12 1 8: 14 2 9: 16 1 10: 18 3 11: 20 2 12: 21 1 13: 25 2 14: 27 1 15: 28 1 16: 30 4 17: 32 1 18: 36 3 19: 45 3 20: 54 1 21: 63 3 22: 72 1 23: 100 1 i4vec_sum_test(): i4vec_sum() sums an integer vector. The vector: 1: 7 2: 9 3: 10 4: 2 5: 8 The vector entries sum to 36 i4vec_sum_vec_test(): Test i4vec_sum_vec(). A: 6 4 5 5 7 B: 8 3 0 9 4 C = A + B: 14 7 5 14 11 i4vec_transpose_print_test(): i4vec_transpose_print() prints an I4VEC with 5 entries to a row, and a title. Output from I4VEC_PRINT: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 11: 11 12: 12 My array: 1 2 3 4 5 6 7 8 9 10 11 12 i4vec_undex_test(): i4vec_undex() produces index vectors which create a sorted list of the unique elements of an (unsorted) I4VEC, 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 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 2 7 22 3 6 33 4 5 55 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 2 7 22 3 6 33 4 5 55 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 33 2 4 55 55 3 1 11 11 4 1 11 11 5 4 55 55 6 3 33 33 7 2 22 22 8 2 22 22 9 1 11 11 i4vec_uniform_ab_test(): i4vec_uniform_ab() computes pseudorandom values in an interval [A,B]. The lower endpoint A = -100.000000 The upper endpoint B = 200.000000 The random vector: 1: 133 2: -47 3: -68 4: 172 5: 163 6: 200 7: 160 8: -89 9: 63 10: 200 11: 53 12: 162 13: -79 14: 197 15: 177 16: 69 17: 29 18: 1 19: 116 20: -96 i4vec_unique_count_test(): i4vec_unique_count() counts unique entries in an I4VEC. Input vector: 1: 7 2: 19 3: 11 4: 9 5: 10 6: 6 7: 19 8: 20 9: 10 10: 20 11: 9 12: 8 13: 4 14: 4 15: 17 16: 15 17: 11 18: 17 19: 10 20: 11 Number of unique entries is 11 i4vec_unique_index_test(): i4vec_unique_index(), for each entry in an I4VEC indexes the unique elements. I A(I) UNIQUE 1 2 1 2 3 2 3 1 3 4 1 3 5 4 4 6 4 4 7 2 1 8 3 2 9 4 4 10 3 2 11 1 3 12 1 3 13 1 3 14 3 2 15 3 2 16 1 3 17 4 4 18 1 3 19 1 3 20 5 5 i4vec_value_index_test(): i4vec_value_index() indexes entries equal to a given value. The desired value is The maximum number of indices to find is 3 Input vector A: 1: 5 2: 1 3: 3 4: 5 5: 2 6: 5 7: 5 8: 4 9: 1 10: 2 11: 5 12: 4 13: 2 14: 4 15: 2 16: 3 17: 5 18: 5 19: 2 20: 4 21: 2 22: 5 23: 1 24: 2 25: 5 Indices of entries equal to given value: 1: 3 2: 16 i4vec_variance_test(): i4vec_variance() variance of an integer vector. Input vector: 1: -9 2: 1 3: 6 4: 5 5: -8 6: -1 7: -3 8: 0 9: 2 10: -7 Variance: 27.822222 i4vec_width_test(): i4vec_width() determines the printing "width" of an I4VEC. The vector 1: 0 2: 1 3: 2 4: 3 5: 9 6: 10 7: 11 8: 99 9: 101 10: -1 11: -2 12: -3 13: -9 The printing width is 3 i4vec_wrap_test(): i4vec_wrap() wraps an I4VEC into [LO,HI]. The vector: -2 4 7 2 9 5 Wrap interval is [2,5] Wrapped vector: 2 4 3 2 5 5 i4vec2_compare_test(): i4vec2_compare() order-compares two I4VEC2's; I: A1 A2 1: 1 4 2: 1 0 3: 2 1 4: 2 2 5: 3 2 Comparison matrix: 0 1 -1 -1 -1 -1 0 -1 -1 -1 1 1 0 -1 -1 1 1 1 0 -1 1 1 1 1 0 i4vec2_print_test(): i4vec2_print() prints a pair of I4VECs I, sum of I, sum of I^2: 1: 0 0 2: 1 1 3: 3 5 4: 6 14 5: 10 30 6: 15 55 7: 21 91 8: 28 140 9: 36 204 10: 45 285 11: 55 385 i4vec2_sort_a_test(): i4vec2_sort_a() ascending sorts a pair of I4VECs; The array: 1: 3 1 2: 2 1 3: 3 1 4: 2 3 5: 2 1 6: 3 3 7: 3 1 8: 2 2 9: 3 1 10: 2 3 After ascending sort: 1: 2 1 2: 2 1 3: 2 2 4: 2 3 5: 2 3 6: 3 1 7: 3 1 8: 3 1 9: 3 1 10: 3 3 i4vec2_sort_d_test(): i4vec2_sort_d() descending sorts a pair of I4VECs; The array: 1: 2 2 2: 2 3 3: 2 2 4: 3 3 5: 2 3 6: 1 2 7: 3 1 8: 1 1 9: 2 2 10: 1 1 After descending sort: 1: 3 3 2: 3 1 3: 2 3 4: 2 3 5: 2 2 6: 2 2 7: 2 2 8: 1 2 9: 1 1 10: 1 1 i4vec2_sort_insert_a_test(): i4vec2_sort_insert_a() uses insert to perform an ascending sort of a pair of I4VECs; The array: 1: 3 2 2: 2 1 3: 3 2 4: 3 2 5: 2 1 6: 1 3 7: 3 2 8: 3 3 9: 3 2 10: 1 3 After ascending insertion sort: 1: 1 3 2: 1 3 3: 2 1 4: 2 1 5: 3 2 6: 3 2 7: 3 2 8: 3 2 9: 3 2 10: 3 3 i4vec2_sorted_unique_test(): i4vec2_sorted_unique() finds unique entries in a pair of sorted I4VECs. The array: 1: 1 3 2: 3 1 3: 1 3 4: 3 2 5: 3 1 6: 3 2 7: 2 3 8: 2 1 9: 1 3 10: 1 3 After ascending sort: 1: 1 3 2: 1 3 3: 1 3 4: 1 3 5: 2 1 6: 2 3 7: 3 1 8: 3 1 9: 3 2 10: 3 2 After descending sort: 1: 3 2 2: 3 2 3: 3 1 4: 3 1 5: 2 3 6: 2 1 7: 1 3 8: 1 3 9: 1 3 10: 1 3 Unique entries 1: 3 2 2: 3 1 3: 2 3 4: 2 1 5: 1 3 i4vec2_sorted_unique_count_test(): i4vec2_sorted_unique_count() counts unique entries in a pair of sorted I4VECs. The sorted array: 1: 1 2 2: 1 3 3: 1 3 4: 1 3 5: 1 3 6: 3 1 7: 3 1 8: 3 1 9: 3 2 10: 3 2 Number of unique items is 4 intspace_test(): intspace() returns a set of min(N,B+1-A)\n equally spaced integers between A and B. a = 5, b = 10, n = 20 5 6 7 8 9 10 a = 5, b = 77, n = 20 Columns 1 through 13 5 9 13 16 20 24 28 32 35 39 43 47 50 Columns 14 through 20 54 58 62 66 69 73 77 a = 5, b = 100, n = 20 Columns 1 through 13 5 10 15 20 25 30 35 40 45 50 55 60 65 Columns 14 through 20 70 75 80 85 90 95 100 a = 5, b = 1000, n = 20 Columns 1 through 6 5 57 110 162 214 267 Columns 7 through 12 319 372 424 476 529 581 Columns 13 through 18 633 686 738 791 843 895 Columns 19 through 20 948 1000 ksub_next4_test(): ksub_next4() generates K subsets of an N set. N = 5 K = 3 Rank Subset 1 1 2 3 2 1 2 4 3 1 3 4 4 2 3 4 5 1 2 5 6 1 3 5 7 2 3 5 8 1 4 5 9 2 4 5 10 3 4 5 l4_to_i4_test(): l4_to_i4() converts an L4 to an I4. L4 I4 0 0 1 1 pascal_to_i4_test(): pascal_to_i4() converts Pascal triangle indices to a linear index. I J => K 0 0 1 1 0 2 0 1 3 2 0 4 1 1 5 0 2 6 3 0 7 2 1 8 1 2 9 0 3 10 4 0 11 3 1 12 2 2 13 1 3 14 0 4 15 perm0_check_test(): perm0_check() checks a permutation of 0,...,N-1. Permutation 1: 5 2 3 4 1 PERM0_CHECK - Warning! Permutation is missing the value 0. Permutation 2: 4 1 3 0 2 Permutation 3: 0 2 1 3 2 PERM0_CHECK - Warning! Permutation is missing the value 4. perm0_uniform_test(): perm0_uniform() randomly selects a permutation of 0, ..., N-1. 4 6 5 3 9 1 7 8 2 0 3 6 9 7 5 1 0 4 2 8 6 2 0 3 9 7 8 1 4 5 3 1 5 0 8 2 9 6 7 4 5 3 4 8 9 6 2 7 0 1 perm1_check_test(): perm1_check() checks a permutation of 1,...,N. Permutation 1: 5 2 3 4 1 Permutation 2: 4 1 3 0 2 PERM1_CHECK - Warning! Permutation is missing the value 5. Permutation 3: 0 2 1 3 2 PERM1_CHECK - Warning! Permutation is missing the value 4. perm1_uniform_test(): perm1_uniform() randomly selects a permutation of 1, ..., N. 5 8 1 4 7 9 3 6 10 2 9 4 6 10 1 7 2 8 5 3 1 5 6 3 4 7 10 2 9 8 5 7 6 1 10 3 4 8 9 2 8 7 4 10 1 2 9 3 5 6 permutation_symbol_test(): permutation_symbol() evaluates the Levi-Civita permutation symbol. Input vector: 1 2 3 4 5 Levi-Civita permutation symbol = 1 Input vector: 4 2 3 1 5 Levi-Civita permutation symbol = -1 Input vector: 1 2 3 4 2 Levi-Civita permutation symbol = 0 prime_test(): prime() returns primes from a table. Number of primes stored is 1600 I Prime(I) 1 2 2 3 3 5 4 7 5 11 6 13 7 17 8 19 9 23 10 29 1590 13411 1591 13417 1592 13421 1593 13441 1594 13451 1595 13457 1596 13463 1597 13469 1598 13477 1599 13487 1600 13499 r8vec_is_integer_test(): r8vec_is_integer() is TRUE if every entry of an R8VEC is an integer. Example 1: Obviously integer: a = 1 2 3 4 5 6 A is an integer vector. Example 2: Obviously NOT integer: a = 1.0000 2.0000 3.0000 4.0000 5.0000 6.5000 A is NOT an integer vector. Example 3: Not Integer, Not obvious: a = 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 A is NOT an integer vector. Example 4: Not Integer, Not obvious: a = 1.0e+08 * 0.0000 0.0000 3.0000 0.0000 0.0000 0.0000 A is NOT an integer vector. r8vec_print_test(): r8vec_print() prints an R8VEC. The R8VEC: 1: 123.456 2: 5e-06 3: -1e+06 4: 3.14159 triangle_lower_to_i4_test(): triangle_lower_to_i4() converts a lower triangular index to a linear one. I, J => K i = 1 1 1 1 i = 2 2 1 2 i = 3 3 1 4 i = 4 4 1 7 triangle_upper_to_i4_test(): triangle_upper_to_i4() converts an upper triangular index to a linear one. I, J => K 1 1 1 1 2 2 1 3 4 1 4 7 2 2 3 2 3 5 2 4 8 3 3 6 3 4 9 4 4 10 i4lib_test(): Normal end of execution. 23-Jul-2022 08:11:06